def main(self, *, context): # noqa: D102 distributions = set() all_entry_points = get_all_entry_points() for group in all_entry_points.values(): for dist, _ in group.values(): distributions.add(dist) pypi = ServerProxy('https://pypi.python.org/pypi') for dist in sorted(distributions, key=lambda d: d.project_name): versions = pypi.package_releases(dist.project_name) if not versions: print('{dist.project_name}: could not find package on PyPI'. format_map(locals()), file=sys.stderr) continue latest_version = versions[0] if parse_version(latest_version) == parse_version(dist.version): print('{dist.project_name} {dist.version}: up-to-date'. format_map(locals())) continue if parse_version(dist.version) < parse_version(latest_version): print('{dist.project_name} {dist.version}: newer version ' 'available ({latest_version})'.format_map(locals())) continue print('{dist.project_name} {dist.version}: local version is newer ' 'than latest release ({latest_version})'.format_map( locals())) continue
def main(self, *, context): # noqa: D102 all_entry_points = get_all_entry_points() for group_name in sorted(all_entry_points.keys()): if context.args.group_name is not None: if group_name != context.args.group_name: continue print(group_name) group = all_entry_points[group_name] for entry_point_name in sorted(group.keys()): (dist, entry_point) = group[entry_point_name] self._print_entry_point(context.args, dist, entry_point)
def add_arguments(self, *, parser): # noqa: D102 all_entry_points = get_all_entry_points() parser.add_argument( 'group_name', nargs='?', choices=sorted(list(all_entry_points.keys())), metavar='GROUP_NAME', help='Only show the extensions in a specific group') parser.add_argument( '--all', '-a', action='store_true', default=False, help='Also show extensions which failed to load or are ' 'incompatible. (prefixed with `- `)') parser.add_argument('--verbose', '-v', action='store_true', default=False, help='Show more information for each extension')
def test_all_entry_points(): with patch('colcon_core.entry_point.iter_entry_points', side_effect=iter_entry_points): with patch('colcon_core.entry_point.WorkingSet', side_effect=working_set): # successfully load a known entry point assert set(get_all_entry_points().keys()) == {'group1', 'group2'} assert set(get_all_entry_points()['group1'].keys()) == \ {'extA', 'extB'} assert len(get_all_entry_points()['group1']['extA']) == 2 assert isinstance(get_all_entry_points()['group1']['extA'][1], EntryPoint) assert get_all_entry_points()['group1']['extA'][1] .group_name == \ 'group1' assert get_all_entry_points()['group1']['extA'][1].name == 'extA'