diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2022-02-06 11:41:00 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-02-06 13:38:37 -0500 |
commit | c5f7e3b19c153712f4e77e3c71ce5a7ba9668bc6 (patch) | |
tree | cabfefa848589a53defbe15fae09d4f59385a5c0 | |
parent | 282f2120979d0d97ae52feb557a19c094e548c87 (diff) | |
download | python-setuptools-git-c5f7e3b19c153712f4e77e3c71ce5a7ba9668bc6.tar.gz |
Refactor to construct data in a single expression and extract 'to_str'.
-rw-r--r-- | setuptools/command/egg_info.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 439fe213..473b7aa4 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -721,13 +721,15 @@ def write_entries(cmd, basename, filename): if isinstance(ep, str) or ep is None: data = ep else: - lines = [] - for section, contents in sorted(ep.items()): - if not isinstance(contents, str): - contents = EntryPoint.parse_group(section, contents) - contents = '\n'.join(sorted(map(str, contents.values()))) - lines.append('[%s]\n%s\n\n' % (section, contents)) - data = ''.join(lines) + def to_str(contents): + if isinstance(contents, str): + return contents + eps = EntryPoint.parse_group('anything', contents) + return '\n'.join(sorted(map(str, eps.values()))) + data = ''.join( + f'[{section}]\n{to_str(contents)}\n\n' + for section, contents in sorted(ep.items()) + ) cmd.write_or_delete_file('entry points', filename, data, True) |