(self, file)
Write the PKG-INFO format data to a file object.
Write the PKG-INFO format data to a file object.
Write the PKG - INFO format data to a file object .
def write_pkg_file(self, file):
    """Write the PKG-INFO format data to a file object.
    """
    version = self.get_metadata_version()

    if six.PY2:
        def write_field(key, value):
            file.write("%s: %s\n" % (key, self._encode_field(value)))
    else:
        def write_field(key, value):
            file.write("%s: %s\n" % (key, value))

    write_field('Metadata-Version', str(version))
    write_field('Name', self.get_name())
    write_field('Version', self.get_version())
    write_field('Summary', self.get_description())
    write_field('Home-page', self.get_url())

    if version < StrictVersion('1.2'):
        write_field('Author', self.get_contact())
        write_field('Author-email', self.get_contact_email())
    else:
        optional_fields = (
            ('Author', 'author'),
            ('Author-email', 'author_email'),
            ('Maintainer', 'maintainer'),
            ('Maintainer-email', 'maintainer_email'),
        )

        for field, attr in optional_fields:
            attr_val = getattr(self, attr)

            if attr_val is not None:
                write_field(field, attr_val)

    write_field('License', self.get_license())
    if self.download_url:
        write_field('Download-URL', self.download_url)
    for project_url in self.project_urls.items():
        write_field('Project-URL',  '%s, %s' % project_url)

    long_desc = rfc822_escape(self.get_long_description())
    write_field('Description', long_desc)

    keywords = ','.join(self.get_keywords())
    if keywords:
        write_field('Keywords', keywords)

    if version >= StrictVersion('1.2'):
        for platform in self.get_platforms():
            write_field('Platform', platform)
    else:
        self._write_list(file, 'Platform', self.get_platforms())

    self._write_list(file, 'Classifier', self.get_classifiers())

    # PEP 314
    self._write_list(file, 'Requires', self.get_requires())
    self._write_list(file, 'Provides', self.get_provides())
    self._write_list(file, 'Obsoletes', self.get_obsoletes())

    # Setuptools specific for PEP 345
    if hasattr(self, 'python_requires'):
        write_field('Requires-Python', self.python_requires)

    # PEP 566
    if self.long_description_content_type:
        write_field(
            'Description-Content-Type',
            self.long_description_content_type
        )
    if self.provides_extras:
        for extra in self.provides_extras:
            write_field('Provides-Extra', extra)
def write_pkg_file ( self , file ) : version = self . get_metadata_version ( ) if six . PY2 : def write_field ( key , value ) : file . write ( "%s: %s\n" % ( key , self . _encode_field ( value ) ) ) else : def write_field ( key , value ) : file . write ( "%s: %s\n" % ( key , value ) ) write_field ( 'Metadata-Version' , str ( version ) ) write_field ( 'Name' , self . get_name ( ) ) write_field ( 'Version' , self . get_version ( ) ) write_field ( 'Summary' , self . get_description ( ) ) write_field ( 'Home-page' , self . get_url ( ) ) if version < StrictVersion ( '1.2' ) : write_field ( 'Author' , self . get_contact ( ) ) write_field ( 'Author-email' , self . get_contact_email ( ) ) else : optional_fields = ( ( 'Author' , 'author' ) , ( 'Author-email' , 'author_email' ) , ( 'Maintainer' , 'maintainer' ) , ( 'Maintainer-email' , 'maintainer_email' ) , ) for field , attr in optional_fields : attr_val = getattr ( self , attr ) if attr_val is not None : write_field ( field , attr_val ) write_field ( 'License' , self . get_license ( ) ) if self . download_url : write_field ( 'Download-URL' , self . download_url ) for project_url in self . project_urls . items ( ) : write_field ( 'Project-URL' , '%s, %s' % project_url ) long_desc = rfc822_escape ( self . get_long_description ( ) ) write_field ( 'Description' , long_desc ) keywords = ',' . join ( self . get_keywords ( ) ) if keywords : write_field ( 'Keywords' , keywords ) if version >= StrictVersion ( '1.2' ) : for platform in self . get_platforms ( ) : write_field ( 'Platform' , platform ) else : self . _write_list ( file , 'Platform' , self . get_platforms ( ) ) self . _write_list ( file , 'Classifier' , self . get_classifiers ( ) ) # PEP 314 self . _write_list ( file , 'Requires' , self . get_requires ( ) ) self . _write_list ( file , 'Provides' , self . get_provides ( ) ) self . _write_list ( file , 'Obsoletes' , self . get_obsoletes ( ) ) # Setuptools specific for PEP 345 if hasattr ( self , 'python_requires' ) : write_field ( 'Requires-Python' , self . python_requires ) # PEP 566 if self . long_description_content_type : write_field ( 'Description-Content-Type' , self . long_description_content_type ) if self . provides_extras : for extra in self . provides_extras : write_field ( 'Provides-Extra' , extra )