Skip to content

Commit 9e7f21c

Browse files
committedMay 26, 2018
Attempts to make clever code more readable
1 parent 6debcce commit 9e7f21c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎thanks/package_tools.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ def get_local_dist_metadata_filepath(dist):
3232
# Dist filename syntax
3333
# name ["-" version ["-py" pyver ["-" required_platform]]] "." ext
3434
# https://setuptools.readthedocs.io/en/latest/formats.html#filename-embedded-metadata
35-
filename = ''.join(chain(*takewhile(lambda x: x[1], (
35+
36+
valid_component = lambda x: x[1]
37+
# Stop taking filename components at the first missing/invalid component
38+
filename_component = takewhile(valid_component, (
3639
('', pkg_resources.to_filename(pkg_resources.safe_name(dist.project_name))),
3740
('-', pkg_resources.to_filename(pkg_resources.safe_version(dist.version))),
3841
('-py', dist.py_version),
3942
('-', dist.platform),
40-
))))
43+
))
44+
filename = ''.join(chain(*filename_component))
45+
4146
if isinstance(dist, pkg_resources.EggInfoDistribution):
4247
ext = 'egg-info'
4348
metadata_file = 'PKG-INFO'

0 commit comments

Comments
 (0)