diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2022-02-06 12:00:14 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-02-06 13:38:37 -0500 |
commit | 161ff0ff6f679967d323e9fd461eff312d0f12e6 (patch) | |
tree | e9a01242011e30ae34d5988c81a8ab89ac3b6c2e /setuptools/command | |
parent | d47d35616920f2f373cc6afbdaf4f30f3faca90f (diff) | |
download | python-setuptools-git-161ff0ff6f679967d323e9fd461eff312d0f12e6.tar.gz |
Extract function for converting entry points to a string.
Diffstat (limited to 'setuptools/command')
-rw-r--r-- | setuptools/command/egg_info.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index b98b84d4..afab5cd6 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -716,18 +716,26 @@ def write_arg(cmd, basename, filename, force=False): @functools.singledispatch +def entry_point_definition_to_str(value): + """ + Given a value of an entry point or series of entry points, + return each entry point on a single line. + """ + parsed = EntryPoint.parse_group('anything', value) + return '\n'.join(sorted(map(str, parsed.values()))) + + +entry_point_definition_to_str.register(str, lambda x: x) + + +@functools.singledispatch def entry_points_definition(eps): """ Given a Distribution.entry_points, produce a multiline string definition of those entry points. """ - def to_str(contents): - if isinstance(contents, str): - return contents - parsed = EntryPoint.parse_group('anything', contents) - return '\n'.join(sorted(map(str, parsed.values()))) return ''.join( - f'[{section}]\n{to_str(contents)}\n\n' + f'[{section}]\n{entry_point_definition_to_str(contents)}\n\n' for section, contents in sorted(eps.items()) ) |