def projects_from_parsed(parsed): """Take parsed arguments from CLI to create a list of specified projects.""" projects = [] projects.extend(projects_.projects_from_requirements(parsed.requirements)) metadata = [] for metadata_path in parsed.metadata: with io.open(metadata_path) as file: metadata.append(file.read()) projects.extend(projects_.projects_from_metadata(metadata)) projects.extend(map(packaging.utils.canonicalize_name, parsed.projects)) projects = {i for i in projects if i not in parsed.exclude} return projects
def projects_from_cli(args): """Take arguments through the CLI can create a list of specified projects.""" description = ('Determine if a set of project dependencies will work with ' 'Python 3') parser = argparse.ArgumentParser(description=description) req_help = 'path(s) to a pip requirements file (e.g. requirements.txt)' parser.add_argument('--requirements', '-r', nargs='+', default=(), help=req_help) meta_help = 'path(s) to a PEP 426 metadata file (e.g. PKG-INFO, pydist.json)' parser.add_argument('--metadata', '-m', nargs='+', default=(), help=meta_help) parser.add_argument( '--projects', '-p', nargs='+', default=(), help='name(s) of projects to test for Python 3 support') parser.add_argument( '--verbose', '-v', action='store_true', help='verbose output (e.g. list compatibility overrides)') parser.add_argument('--exclude', '-e', action='append', default=[], help='Ignore list') parsed = parser.parse_args(args) if not (parsed.requirements or parsed.metadata or parsed.projects): parser.error("Missing 'requirements', 'metadata', or 'projects'") projects = [] if parsed.verbose: logging.getLogger('ciu').setLevel(logging.INFO) projects.extend(projects_.projects_from_requirements(parsed.requirements)) metadata = [] for metadata_path in parsed.metadata: with io.open(metadata_path) as file: metadata.append(file.read()) projects.extend(projects_.projects_from_metadata(metadata)) projects.extend(map(packaging.utils.canonicalize_name, parsed.projects)) projects = {i for i in projects if i not in parsed.exclude} return projects
def projects_from_cli(args): projects = [] kepversion = args.keep_version if args.verbose: logging.getLogger('ciu').setLevel(logging.INFO) projects.extend(projects_.projects_from_requirements(args.requirements)) metadata = [] for metadata_path in args.metadata: with io.open(metadata_path) as file: metadata.append(file.read()) projects.extend(projects_.projects_from_metadata(metadata)) # transform list of projects into requirements: projects.extend(projects_.projects_from_list(args.projects)) projects = [i for i in projects if i['name'] not in args.exclude] return projects
def check(requirements_paths=[], metadata=[], projects=[]): """Return True if all of the specified dependencies have been ported to Python 3. The requirements_paths argument takes a sequence of file paths to requirements files. The 'metadata' argument takes a sequence of strings representing metadata. The 'projects' argument takes a sequence of project names. Any project that is not listed on PyPI will be considered ported. """ dependencies = [] dependencies.extend(projects_.projects_from_requirements(requirements_paths)) dependencies.extend(projects_.projects_from_metadata(metadata)) dependencies.extend(projects) manual_overrides = pypi.manual_overrides() for dependency in dependencies: if dependency['name'] in manual_overrides: continue elif not pypi.supports_py3(dependency): return False return True
def test_multiple_metadata(self): got = projects.projects_from_metadata([EXAMPLE_METADATA, EXAMPLE_EXTRA_METADATA]) want = self.expected_metadata.union(self.expected_extra_metadata) self.assertEqual(set(got), want)
def test_metadata(self): got = projects.projects_from_metadata([EXAMPLE_METADATA]) self.assertEqual(set(got), self.expected_metadata)
def test_multiple_metadata(self): got = projects.projects_from_metadata([EXAMPLE_METADATA, EXAMPLE_EXTRA_METADATA]) want = self.expected_metadata.union(self.expected_extra_metadata) self.assertEqual(set(got), want)
def test_metadata(self): got = projects.projects_from_metadata([EXAMPLE_METADATA]) self.assertEqual(set(got), self.expected_metadata)