Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkginfo2/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@ def _collapse_leading_ws(header, txt):
('Dynamic', 'dynamic', True),
)

HEADER_ATTRS_2_4 = HEADER_ATTRS_2_2 + ( # PEP 639
('License-Expression', 'license_expression', False),
('License-Files', 'license_files', True),
)

HEADER_ATTRS = {
'1.0': HEADER_ATTRS_1_0,
'1.1': HEADER_ATTRS_1_1,
'1.2': HEADER_ATTRS_1_2,
'2.0': HEADER_ATTRS_2_0,
'2.1': HEADER_ATTRS_2_1,
'2.2': HEADER_ATTRS_2_2,
'2.3': HEADER_ATTRS_2_2,
'2.4': HEADER_ATTRS_2_4,
}

class Distribution(object):
Expand Down Expand Up @@ -110,6 +117,9 @@ class Distribution(object):
description_content_type = None
# version 2.2
dynamic = ()
# version 2.4
license_expression = None
license_files = ()

def extractMetadata(self):
data = self.read()
Expand All @@ -119,7 +129,11 @@ def read(self):
raise NotImplementedError

def _getHeaderAttrs(self):
return HEADER_ATTRS.get(self.metadata_version, [])
if self.metadata_version in HEADER_ATTRS:
return HEADER_ATTRS[self.metadata_version]
else:
# If the specific version is not available, use the latest version
return HEADER_ATTRS[HEADER_ATTRS.keys()[-1]]

def parse(self, data):
fp = StringIO(must_decode(data))
Expand Down