diff options
author | Éric Araujo <merwok@netwok.org> | 2011-06-09 12:07:46 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-06-09 12:07:46 (GMT) |
commit | e00a6703e8d13ae4ab30466998ef62098868f98c (patch) | |
tree | a4d6fcb7fe4b323727b491c7a7b042fc0f14a657 /Lib | |
parent | 9a82eaade3cbfba9895b6121daf8ddb65b5aaa4d (diff) | |
parent | e6792c1e771fab4ed025beeb8f71fb2d5c7d53e8 (diff) | |
download | cpython-e00a6703e8d13ae4ab30466998ef62098868f98c.zip cpython-e00a6703e8d13ae4ab30466998ef62098868f98c.tar.gz cpython-e00a6703e8d13ae4ab30466998ef62098868f98c.tar.bz2 |
Branch merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/packaging/create.py | 8 | ||||
-rw-r--r-- | Lib/packaging/database.py | 6 | ||||
-rw-r--r-- | Lib/packaging/depgraph.py | 29 | ||||
-rw-r--r-- | Lib/packaging/dist.py | 8 | ||||
-rw-r--r-- | Lib/packaging/pypi/dist.py | 6 | ||||
-rw-r--r-- | Lib/packaging/pypi/simple.py | 7 | ||||
-rw-r--r-- | Lib/packaging/run.py | 21 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_bdist_dumb.py | 1 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_build_py.py | 4 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_install_dist.py | 2 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_install_lib.py | 2 | ||||
-rw-r--r-- | Lib/packaging/tests/test_command_sdist.py | 10 | ||||
-rw-r--r-- | Lib/packaging/tests/test_config.py | 4 | ||||
-rw-r--r-- | Lib/packaging/util.py | 2 |
14 files changed, 47 insertions, 63 deletions
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py index c18d42f..917b6cf 100644 --- a/Lib/packaging/create.py +++ b/Lib/packaging/create.py @@ -175,11 +175,11 @@ def convert_yn_to_bool(yn, yes=True, no=False): def _build_classifiers_dict(classifiers): d = {} for key in classifiers: - subDict = d + subdict = d for subkey in key.split(' :: '): - if not subkey in subDict: - subDict[subkey] = {} - subDict = subDict[subkey] + if subkey not in subdict: + subdict[subkey] = {} + subdict = subdict[subkey] return d CLASSIFIERS = _build_classifiers_dict(_CLASSIFIERS_LIST) diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py index 22d4b13..e3c57ba 100644 --- a/Lib/packaging/database.py +++ b/Lib/packaging/database.py @@ -104,12 +104,12 @@ def _generate_cache(use_egg_info=False, paths=sys.path): for dist in _yield_distributions(gen_dist, gen_egg, paths): if isinstance(dist, Distribution): _cache_path[dist.path] = dist - if not dist.name in _cache_name: + if dist.name not in _cache_name: _cache_name[dist.name] = [] _cache_name[dist.name].append(dist) else: _cache_path_egg[dist.path] = dist - if not dist.name in _cache_name_egg: + if dist.name not in _cache_name_egg: _cache_name_egg[dist.name] = [] _cache_name_egg[dist.name].append(dist) @@ -150,7 +150,7 @@ class Distribution: self.version = self.metadata['Version'] self.path = path - if _cache_enabled and not path in _cache_path: + if _cache_enabled and path not in _cache_path: _cache_path[path] = self def __repr__(self): diff --git a/Lib/packaging/depgraph.py b/Lib/packaging/depgraph.py index 48ea3d9..b3c555a 100644 --- a/Lib/packaging/depgraph.py +++ b/Lib/packaging/depgraph.py @@ -58,7 +58,7 @@ class DependencyGraph: """ self.adjacency_list[x].append((y, label)) # multiple edges are allowed, so be careful - if not x in self.reverse_list[y]: + if x not in self.reverse_list[y]: self.reverse_list[y].append(x) def add_missing(self, distribution, requirement): @@ -72,7 +72,7 @@ class DependencyGraph: self.missing[distribution].append(requirement) def _repr_dist(self, dist): - return '%s %s' % (dist.name, dist.metadata['Version']) + return '%r %s' % (dist.name, dist.metadata['Version']) def repr_node(self, dist, level=1): """Prints only a subgraph""" @@ -154,10 +154,10 @@ def generate_graph(dists): if len(comps) == 2: version = comps[1] if len(version) < 3 or version[0] != '(' or version[-1] != ')': - raise PackagingError('Distribution %s has ill formed' \ - 'provides field: %s' % (dist.name, p)) + raise PackagingError('distribution %r has ill-formed' + 'provides field: %r' % (dist.name, p)) version = version[1:-1] # trim off parenthesis - if not name in provided: + if name not in provided: provided[name] = [] provided[name].append((version, dist)) @@ -174,7 +174,7 @@ def generate_graph(dists): name = predicate.name - if not name in provided: + if name not in provided: graph.add_missing(dist, req) else: matched = False @@ -204,8 +204,9 @@ def dependent_dists(dists, dist): :param dists: a list of distributions :param dist: a distribution, member of *dists* for which we are interested """ - if not dist in dists: - raise ValueError('The given distribution is not a member of the list') + if dist not in dists: + raise ValueError('given distribution %r is not a member of the list' % + dist.name) graph = generate_graph(dists) dep = [dist] # dependent distributions @@ -215,7 +216,7 @@ def dependent_dists(dists, dist): node = fringe.pop() dep.append(node) for prev in graph.reverse_list[node]: - if not prev in dep: + if prev not in dep: fringe.append(prev) dep.pop(0) # remove dist from dep, was there to prevent infinite loops @@ -236,17 +237,19 @@ def main(): except Exception as e: tempout.seek(0) tempout = tempout.read() - print('Could not generate the graph\n%s\n%s\n' % (tempout, e)) + print('Could not generate the graph') + print(tempout) + print(e) sys.exit(1) for dist, reqs in graph.missing.items(): if len(reqs) > 0: - print("Warning: Missing dependencies for %s:" % dist.name, + print("Warning: Missing dependencies for %r:" % dist.name, ", ".join(reqs)) # XXX replace with argparse if len(sys.argv) == 1: print('Dependency graph:') - print(' ' + repr(graph).replace('\n', '\n ')) + print(' ', repr(graph).replace('\n', '\n ')) sys.exit(0) elif len(sys.argv) > 1 and sys.argv[1] in ('-d', '--dot'): if len(sys.argv) > 2: @@ -259,7 +262,7 @@ def main(): tempout.seek(0) tempout = tempout.read() print(tempout) - print('Dot file written at "%s"' % filename) + print('Dot file written at %r' % filename) sys.exit(0) else: print('Supported option: -d [filename]') diff --git a/Lib/packaging/dist.py b/Lib/packaging/dist.py index 6065e78..5c390ce 100644 --- a/Lib/packaging/dist.py +++ b/Lib/packaging/dist.py @@ -509,14 +509,14 @@ Common commands: (see '--help-commands' for more) options = self.global_options parser.set_option_table(options) parser.print_help(self.common_usage + "\nGlobal options:") - print('') + print() if display_options: parser.set_option_table(self.display_options) parser.print_help( "Information display options (just display " + "information, ignore any commands)") - print('') + print() for command in self.commands: if isinstance(command, type) and issubclass(command, Command): @@ -529,7 +529,7 @@ Common commands: (see '--help-commands' for more) else: parser.set_option_table(cls.user_options) parser.print_help("Options for %r command:" % cls.__name__) - print('') + print() print(gen_usage(self.script_name)) @@ -544,7 +544,7 @@ Common commands: (see '--help-commands' for more) # we ignore "foo bar"). if self.help_commands: self.print_commands() - print('') + print() print(gen_usage(self.script_name)) return 1 diff --git a/Lib/packaging/pypi/dist.py b/Lib/packaging/pypi/dist.py index db04cda..d3824c2 100644 --- a/Lib/packaging/pypi/dist.py +++ b/Lib/packaging/pypi/dist.py @@ -256,7 +256,7 @@ class DistInfo(IndexReference): hashlib.new(hashname) except ValueError: raise UnsupportedHashName(hashname) - if not url in [u['url'] for u in self.urls]: + if url not in [u['url'] for u in self.urls]: self.urls.append({ 'url': url, 'hashname': hashname, @@ -329,7 +329,7 @@ class DistInfo(IndexReference): url param""" hashname = self.url['hashname'] expected_hashval = self.url['hashval'] - if not None in (expected_hashval, hashname): + if None not in (expected_hashval, hashname): with open(filename, 'rb') as f: hashval = hashlib.new(hashname) hashval.update(f.read()) @@ -409,7 +409,7 @@ class ReleasesList(IndexReference): (release.name, self.name)) version = str(release.version) - if not version in self.get_versions(): + if version not in self.get_versions(): # append only if not already exists self.releases.append(release) for dist in release.dists.values(): diff --git a/Lib/packaging/pypi/simple.py b/Lib/packaging/pypi/simple.py index c372c6f..1dcb8ce 100644 --- a/Lib/packaging/pypi/simple.py +++ b/Lib/packaging/pypi/simple.py @@ -231,7 +231,8 @@ class Crawler(BaseClient): """ self._mirrors_used.add(self.index_url) index_url = self._mirrors.pop() - if not ("http://" or "https://" or "file://") in index_url: + # XXX use urllib.parse for a real check of missing scheme part + if not index_url.startswith(("http://", "https://", "file://")): index_url = "http://%s" % index_url if not index_url.endswith("/simple"): @@ -282,7 +283,7 @@ class Crawler(BaseClient): name = release.name else: name = release_info['name'] - if not name.lower() in self._projects: + if name.lower() not in self._projects: self._projects[name.lower()] = ReleasesList(name, index=self._index) if release: @@ -320,7 +321,7 @@ class Crawler(BaseClient): # it's a distribution, so create a dist object try: infos = get_infos_from_url(link, project_name, - is_external=not self.index_url in url) + is_external=self.index_url not in url) except CantParseArchiveName as e: if self.verbose: logger.warning( diff --git a/Lib/packaging/run.py b/Lib/packaging/run.py index c17ccfd..3e720cf 100644 --- a/Lib/packaging/run.py +++ b/Lib/packaging/run.py @@ -286,9 +286,9 @@ def _metadata(dispatcher, args, **kw): value = metadata[key] if isinstance(value, list): for v in value: - print(' ' + v) + print(' ', v) else: - print(' ' + value.replace('\n', '\n ')) + print(' ', value.replace('\n', '\n ')) @action_help(remove_usage) @@ -366,7 +366,7 @@ def _list(dispatcher, args, **kw): print('%s %s at %s' % (dist.name, dist.metadata['version'], dist.path)) number += 1 - print('') + print() if number == 0: print('Nothing seems to be installed.') else: @@ -405,7 +405,6 @@ class Dispatcher: self.verbose = 1 self.dry_run = False self.help = False - self.script_name = 'pysetup' self.cmdclass = {} self.commands = [] self.command_options = {} @@ -574,17 +573,17 @@ class Dispatcher: from packaging.command.cmd import Command print('Usage: pysetup [options] action [action_options]') - print('') + print() if global_options_: self.print_usage(self.parser) - print('') + print() if display_options_: parser.set_option_table(display_options) parser.print_help( "Information display options (just display " + "information, ignore any commands)") - print('') + print() for command in commands: if isinstance(command, type) and issubclass(command, Command): @@ -598,15 +597,15 @@ class Dispatcher: parser.set_option_table(cls.user_options) parser.print_help("Options for %r command:" % cls.__name__) - print('') + print() def _show_command_help(self, command): if isinstance(command, str): command = get_command_class(command) desc = getattr(command, 'description', '(no description available)') - print('Description: %s' % desc) - print('') + print('Description:', desc) + print() if (hasattr(command, 'help_options') and isinstance(command.help_options, list)): @@ -616,7 +615,7 @@ class Dispatcher: self.parser.set_option_table(command.user_options) self.parser.print_help("Options:") - print('') + print() def _get_command_groups(self): """Helper function to retrieve all the command class names divided diff --git a/Lib/packaging/tests/test_command_bdist_dumb.py b/Lib/packaging/tests/test_command_bdist_dumb.py index 41b0dd0..b235795 100644 --- a/Lib/packaging/tests/test_command_bdist_dumb.py +++ b/Lib/packaging/tests/test_command_bdist_dumb.py @@ -49,7 +49,6 @@ class BuildDumbTestCase(support.TempdirManager, 'py_modules': ['foo'], 'url': 'xxx', 'author': 'xxx', 'author_email': 'xxx'}) - dist.script_name = 'setup.py' os.chdir(pkg_dir) sys.argv[:] = ['setup.py'] diff --git a/Lib/packaging/tests/test_command_build_py.py b/Lib/packaging/tests/test_command_build_py.py index 49069f5..243a863 100644 --- a/Lib/packaging/tests/test_command_build_py.py +++ b/Lib/packaging/tests/test_command_build_py.py @@ -33,9 +33,7 @@ class BuildPyTestCase(support.TempdirManager, dist = Distribution({"packages": ["pkg"], "package_dir": sources}) - # script_name need not exist, it just need to be initialized - dist.script_name = os.path.join(sources, "setup.py") dist.command_obj["build"] = support.DummyCommand( force=False, build_lib=destination, @@ -89,8 +87,6 @@ class BuildPyTestCase(support.TempdirManager, dist = Distribution({"packages": ["pkg"], "package_dir": sources, "package_data": {"pkg": ["doc/*"]}}) - # script_name need not exist, it just need to be initialized - dist.script_name = os.path.join(sources, "setup.py") dist.script_args = ["build"] dist.parse_command_line() diff --git a/Lib/packaging/tests/test_command_install_dist.py b/Lib/packaging/tests/test_command_install_dist.py index 1974a2f..7821a3a 100644 --- a/Lib/packaging/tests/test_command_install_dist.py +++ b/Lib/packaging/tests/test_command_install_dist.py @@ -30,8 +30,6 @@ class InstallTestCase(support.TempdirManager, destination = os.path.join(builddir, "installation") dist = Distribution({"name": "foopkg"}) - # script_name need not exist, it just need to be initialized - dist.script_name = os.path.join(builddir, "setup.py") dist.command_obj["build"] = support.DummyCommand( build_base=builddir, build_lib=os.path.join(builddir, "lib"), diff --git a/Lib/packaging/tests/test_command_install_lib.py b/Lib/packaging/tests/test_command_install_lib.py index 96749e3..b46f3bd 100644 --- a/Lib/packaging/tests/test_command_install_lib.py +++ b/Lib/packaging/tests/test_command_install_lib.py @@ -65,7 +65,6 @@ class InstallLibTestCase(support.TempdirManager, self.write_file(f, '# python package') cmd.distribution.ext_modules = [Extension('foo', ['xxx'])] cmd.distribution.packages = [pkg_dir] - cmd.distribution.script_name = 'setup.py' # make sure the build_lib is set the temp dir build_dir = os.path.split(pkg_dir)[0] @@ -86,7 +85,6 @@ class InstallLibTestCase(support.TempdirManager, self.write_file(f, '# python package') cmd.distribution.ext_modules = [Extension('foo', ['xxx'])] cmd.distribution.packages = [pkg_dir] - cmd.distribution.script_name = 'setup.py' # get_input should return 2 elements self.assertEqual(len(cmd.get_inputs()), 2) diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py index 7be349f..bcaa630 100644 --- a/Lib/packaging/tests/test_command_sdist.py +++ b/Lib/packaging/tests/test_command_sdist.py @@ -24,12 +24,6 @@ from packaging.util import find_executable from packaging.tests import support from shutil import get_archive_formats -SETUP_PY = """ -from packaging.core import setup -import somecode - -setup(name='fake') -""" MANIFEST = """\ # file GENERATED by packaging, do NOT edit @@ -57,8 +51,6 @@ class SDistTestCase(support.TempdirManager, restore_environ = ['HOME'] def setUp(self): - # PyPIRCCommandTestCase creates a temp dir already - # and put it in self.tmp_dir super(SDistTestCase, self).setUp() self.tmp_dir = self.mkdtemp() os.environ['HOME'] = self.tmp_dir @@ -69,7 +61,6 @@ class SDistTestCase(support.TempdirManager, # a package, and a README self.write_file((self.tmp_dir, 'README'), 'xxx') self.write_file((self.tmp_dir, 'somecode', '__init__.py'), '#') - self.write_file((self.tmp_dir, 'setup.py'), SETUP_PY) os.chdir(self.tmp_dir) def tearDown(self): @@ -84,7 +75,6 @@ class SDistTestCase(support.TempdirManager, 'url': 'xxx', 'author': 'xxx', 'author_email': 'xxx'} dist = Distribution(metadata) - dist.script_name = 'setup.py' dist.packages = ['somecode'] dist.include_package_data = True cmd = sdist(dist) diff --git a/Lib/packaging/tests/test_config.py b/Lib/packaging/tests/test_config.py index a276730..9198ead 100644 --- a/Lib/packaging/tests/test_config.py +++ b/Lib/packaging/tests/test_config.py @@ -114,7 +114,7 @@ libraries = gecodeint gecodekernel -- sys.platform != 'win32' GecodeInt GecodeKernel -- sys.platform == 'win32' [extension=fast_taunt] -name = three.fast_taunt +name = two.fast_taunt sources = cxx_src/utils_taunt.cxx cxx_src/python_module.cxx include_dirs = /usr/include/gecode @@ -305,7 +305,7 @@ class ConfigTestCase(support.TempdirManager, self.assertEqual(ext.extra_link_args, ['`gcc -print-file-name=libgcc.a`', '-shared']) - ext = ext_modules.get('three.fast_taunt') + ext = ext_modules.get('two.fast_taunt') self.assertEqual(ext.sources, ['cxx_src/utils_taunt.cxx', 'cxx_src/python_module.cxx']) self.assertEqual(ext.include_dirs, diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py index d4aae41..812dbe3 100644 --- a/Lib/packaging/util.py +++ b/Lib/packaging/util.py @@ -1099,7 +1099,7 @@ def ask(message, options): response = input(message) response = response.strip().lower() if response not in options: - print('invalid response: %r' % response) + print('invalid response:', repr(response)) print('choose one of', ', '.join(repr(o) for o in options)) else: return response |