(self, skip_missing=False)
return data
Return fields as a dict.

        Field names will be converted to use the underscore-lowercase style
        instead of hyphen-mixed case (i.e. home_page instead of Home-page).
Return fields as a dict.
Return fields as a dict .
def todict(self, skip_missing=False):
        """Return fields as a dict.

        Field names will be converted to use the underscore-lowercase style
        instead of hyphen-mixed case (i.e. home_page instead of Home-page).
        """
        self.set_metadata_version()

        mapping_1_0 = (
            ('metadata_version', 'Metadata-Version'),
            ('name', 'Name'),
            ('version', 'Version'),
            ('summary', 'Summary'),
            ('home_page', 'Home-page'),
            ('author', 'Author'),
            ('author_email', 'Author-email'),
            ('license', 'License'),
            ('description', 'Description'),
            ('keywords', 'Keywords'),
            ('platform', 'Platform'),
            ('classifiers', 'Classifier'),
            ('download_url', 'Download-URL'),
        )

        data = {}
        for key, field_name in mapping_1_0:
            if not skip_missing or field_name in self._fields:
                data[key] = self[field_name]

        if self['Metadata-Version'] == '1.2':
            mapping_1_2 = (
                ('requires_dist', 'Requires-Dist'),
                ('requires_python', 'Requires-Python'),
                ('requires_external', 'Requires-External'),
                ('provides_dist', 'Provides-Dist'),
                ('obsoletes_dist', 'Obsoletes-Dist'),
                ('project_url', 'Project-URL'),
                ('maintainer', 'Maintainer'),
                ('maintainer_email', 'Maintainer-email'),
            )
            for key, field_name in mapping_1_2:
                if not skip_missing or field_name in self._fields:
                    if key != 'project_url':
                        data[key] = self[field_name]
                    else:
                        data[key] = [','.join(u) for u in self[field_name]]

        elif self['Metadata-Version'] == '1.1':
            mapping_1_1 = (
                ('provides', 'Provides'),
                ('requires', 'Requires'),
                ('obsoletes', 'Obsoletes'),
            )
            for key, field_name in mapping_1_1:
                if not skip_missing or field_name in self._fields:
                    data[key] = self[field_name]

        return data
def todict ( self , skip_missing = False ) : self . set_metadata_version ( ) mapping_1_0 = ( ( 'metadata_version' , 'Metadata-Version' ) , ( 'name' , 'Name' ) , ( 'version' , 'Version' ) , ( 'summary' , 'Summary' ) , ( 'home_page' , 'Home-page' ) , ( 'author' , 'Author' ) , ( 'author_email' , 'Author-email' ) , ( 'license' , 'License' ) , ( 'description' , 'Description' ) , ( 'keywords' , 'Keywords' ) , ( 'platform' , 'Platform' ) , ( 'classifiers' , 'Classifier' ) , ( 'download_url' , 'Download-URL' ) , ) data = { } for key , field_name in mapping_1_0 : if not skip_missing or field_name in self . _fields : data [ key ] = self [ field_name ] if self [ 'Metadata-Version' ] == '1.2' : mapping_1_2 = ( ( 'requires_dist' , 'Requires-Dist' ) , ( 'requires_python' , 'Requires-Python' ) , ( 'requires_external' , 'Requires-External' ) , ( 'provides_dist' , 'Provides-Dist' ) , ( 'obsoletes_dist' , 'Obsoletes-Dist' ) , ( 'project_url' , 'Project-URL' ) , ( 'maintainer' , 'Maintainer' ) , ( 'maintainer_email' , 'Maintainer-email' ) , ) for key , field_name in mapping_1_2 : if not skip_missing or field_name in self . _fields : if key != 'project_url' : data [ key ] = self [ field_name ] else : data [ key ] = [ ',' . join ( u ) for u in self [ field_name ] ] elif self [ 'Metadata-Version' ] == '1.1' : mapping_1_1 = ( ( 'provides' , 'Provides' ) , ( 'requires' , 'Requires' ) , ( 'obsoletes' , 'Obsoletes' ) , ) for key , field_name in mapping_1_1 : if not skip_missing or field_name in self . _fields : data [ key ] = self [ field_name ] return data