summaryrefslogtreecommitdiff
path: root/Lib/packaging/database.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-06-16 23:43:15 +0200
committerÉric Araujo <merwok@netwok.org>2011-06-16 23:43:15 +0200
commit6f67765389f63b49c094ee08017309bcb45d7ed6 (patch)
treeaf25aaec48f44dfb11bac27c5919e6884f7249d3 /Lib/packaging/database.py
parentb6be20ca337348b7cf2b356f9354a4121627add0 (diff)
downloadcpython-git-6f67765389f63b49c094ee08017309bcb45d7ed6.tar.gz
Stop binding sys.path as default parameter value in packaging.
The two public functions in database default to sys.path if the given *paths* argument is None; the private functions don’t have default values for their arguments anymore, which is fine as the public functions that call them pass their arguments down. Likewise in install, the functions will pass down their *paths* arguments down to database functions. A one-line unneeded function in install was removed instead of being changed, and the few remaining tests that used brute-force restoration of sys.path have been cleaned up to use sys.path.remove.
Diffstat (limited to 'Lib/packaging/database.py')
-rw-r--r--Lib/packaging/database.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py
index e3c57bacab..67946a249b 100644
--- a/Lib/packaging/database.py
+++ b/Lib/packaging/database.py
@@ -72,7 +72,7 @@ def clear_cache():
_cache_generated_egg = False
-def _yield_distributions(include_dist, include_egg, paths=sys.path):
+def _yield_distributions(include_dist, include_egg, paths):
"""
Yield .dist-info and .egg(-info) distributions, based on the arguments
@@ -92,7 +92,7 @@ def _yield_distributions(include_dist, include_egg, paths=sys.path):
yield EggInfoDistribution(dist_path)
-def _generate_cache(use_egg_info=False, paths=sys.path):
+def _generate_cache(use_egg_info, paths):
global _cache_generated, _cache_generated_egg
if _cache_generated_egg or (_cache_generated and not use_egg_info):
@@ -472,7 +472,7 @@ def distinfo_dirname(name, version):
return '-'.join([name, normalized_version]) + file_extension
-def get_distributions(use_egg_info=False, paths=sys.path):
+def get_distributions(use_egg_info=False, paths=None):
"""
Provides an iterator that looks for ``.dist-info`` directories in
``sys.path`` and returns :class:`Distribution` instances for each one of
@@ -482,6 +482,9 @@ def get_distributions(use_egg_info=False, paths=sys.path):
:rtype: iterator of :class:`Distribution` and :class:`EggInfoDistribution`
instances
"""
+ if paths is None:
+ paths = sys.path
+
if not _cache_enabled:
for dist in _yield_distributions(True, use_egg_info, paths):
yield dist
@@ -513,7 +516,7 @@ def get_distribution(name, use_egg_info=False, paths=None):
:rtype: :class:`Distribution` or :class:`EggInfoDistribution` or None
"""
- if paths == None:
+ if paths is None:
paths = sys.path
if not _cache_enabled:
@@ -632,7 +635,7 @@ def get_file_users(path):
def get_file_path(distribution_name, relative_path):
"""Return the path to a resource file."""
dist = get_distribution(distribution_name)
- if dist != None:
+ if dist is not None:
return dist.get_resource_path(relative_path)
raise LookupError('no distribution named %r found' % distribution_name)