예제 #1
0
 def _get_readme(self, repository_format):
     if repository_format == constants.RepositoryFormat.MULTI:
         try:
             return readmeutils.get_readme(directory=self.path)
         except readmeutils.FileSizeError as e:
             self.log.warning(e)
     return None
예제 #2
0
    def _load_collection_readme(self):
        if not self.collection_info.readme:
            raise exc.ManifestValidationError('No readme listed in manifest')

        readme_path = os.path.join(self.path, self.collection_info.readme)
        try:
            readme_file = readmeutils.get_readme(directory=self.path,
                                                 filename=readme_path)
        except readmeutils.FileSizeError as e:
            raise exc.ManifestValidationError(
                'Manifest readme FileSizeError: {}'.format(e))

        if not readme_file:
            raise exc.ManifestValidationError(
                'Readme listed in manifest not found: '
                '{}'.format(self.collection_info.readme))

        if readme_file.mimetype not in ALLOWED_TYPES:
            raise exc.ManifestValidationError(
                'Readme type must be in {}'.format(ALLOWED_TYPES))

        html = readmeutils.render_html(readme_file)

        self.readme = {
            'mimetype': readme_file.mimetype,
            'text': readme_file.text,
            'html': html,
        }
예제 #3
0
파일: base.py 프로젝트: yohannna/yohanna
 def _get_readme(self, directory=None):
     try:
         return readmeutils.get_readme(directory or self.path, self.root)
     except readmeutils.FileSizeError as e:
         self.log.warning(e)