def convert(self):
        """Returns RPM SPECFILE.
        Returns:
            rendered RPM SPECFILE.
        """
        # move file into position
        try:
            local_file = self.getter.get()
        except (exceptions.NoSuchPackageException, OSError) as e:
            logger.error(
                "Failed and exiting:", exc_info=True)
            logger.info("Pyp2rpm failed. See log for more info.")

            sys.exit(e)

        # save name and version from the file (rewrite if set previously)
        self.name, self.version = self.getter.get_name_version()

        self.local_file = local_file
        data = self.metadata_extractor.extract_data(self.client)
        logger.debug("Extracted metadata:")
        logger.debug(pprint.pformat(data.data))
        self.merge_versions(data)

        jinja_env = jinja2.Environment(loader=jinja2.ChoiceLoader([
            jinja2.FileSystemLoader(['/']),
            jinja2.PackageLoader('pyp2rpm', 'templates'), ]))

        for filter in filters.__all__:
            jinja_env.filters[filter.__name__] = filter

        try:
            jinja_template = jinja_env.get_template(
                os.path.abspath(self.template))
        except jinja2.exceptions.TemplateNotFound:
            # absolute path not found => search in default template dir
            logger.warn('Template: {0} was not found in {1} using default '
                        'template dir.'.format(
                            self.template, os.path.abspath(self.template)))

            jinja_template = jinja_env.get_template(self.template)
            logger.info('Using default template: {0}.'.format(self.template))

        ret = jinja_template.render(data=data, name_convertor=name_convertor)
        return re.sub(r'[ \t]+\n', "\n", ret)
def convert ( self ) : try : local_file = self . getter . get ( ) except ( exceptions . NoSuchPackageException , OSError ) as e : logger . error ( "Failed and exiting:" , exc_info = True ) logger . info ( "Pyp2rpm failed. See log for more info." ) sys . exit ( e ) self . name , self . version = self . getter . get_name_version ( ) self . local_file = local_file data = self . metadata_extractor . extract_data ( self . client ) logger . debug ( "Extracted metadata:" ) logger . debug ( pprint . pformat ( data . data ) ) self . merge_versions ( data ) jinja_env = jinja2 . Environment ( loader = jinja2 . ChoiceLoader ( [ jinja2 . FileSystemLoader ( [ '/' ] ) , jinja2 . PackageLoader ( 'pyp2rpm' , 'templates' ) , ] ) ) for filter in filters . __all__ : jinja_env . filters [ filter . __name__ ] = filter try : jinja_template = jinja_env . get_template ( os . path . abspath ( self . template ) ) except jinja2 . exceptions . TemplateNotFound : logger . warn ( 'Template: {0} was not found in {1} using default ' 'template dir.' . format ( self . template , os . path . abspath ( self . template ) ) ) jinja_template = jinja_env . get_template ( self . template ) logger . info ( 'Using default template: {0}.' . format ( self . template ) ) ret = jinja_template . render ( data = data , name_convertor = name_convertor ) return re . sub ( r'[ \t]+\n' , "\n" , ret )
Returns RPM SPECFILE.
        Returns:
            rendered RPM SPECFILE.