[Python-checkins] distutils2: Some fixes after Eric's suggestions
tarek.ziade
python-checkins at python.org
Sun Aug 8 11:50:46 CEST 2010
tarek.ziade pushed 6bdf9e1e1b16 to distutils2:
http://hg.python.org/distutils2/rev/6bdf9e1e1b16
changeset: 432:6bdf9e1e1b16
user: Josip Djolonga
date: Mon Jul 19 02:22:06 2010 +0200
summary: Some fixes after Eric's suggestions
files: docs/source/pkgutil.rst, src/distutils2/_backport/pkgutil.py, src/distutils2/command/install.py
diff --git a/docs/source/pkgutil.rst b/docs/source/pkgutil.rst
--- a/docs/source/pkgutil.rst
+++ b/docs/source/pkgutil.rst
@@ -23,7 +23,8 @@
For performance purposes, the list of distributions is being internally
cached. It is enabled by default, but you can turn it off or clear
it using
-:func:`distutils2._backport.pkgutil.set_cache_enabled` and
+:func:`distutils2._backport.pkgutil.enable_cache`,
+:func:`distutils2._backport.pkgutil.disable_cache` and
:func:`distutils2._backport.pkgutil.clear_cache`.
@@ -58,7 +59,7 @@
print('=====')
for (path, md5, size) in dist.get_installed_files():
print('* Path: %s' % path)
- print(' Hash %s, Size: %s bytes' % (md5, size))
+ print(' Hash %s, Size: %s bytes' % (md5, size))
print('Metadata')
print('========')
for key, value in dist.metadata.items():
diff --git a/src/distutils2/_backport/pkgutil.py b/src/distutils2/_backport/pkgutil.py
--- a/src/distutils2/_backport/pkgutil.py
+++ b/src/distutils2/_backport/pkgutil.py
@@ -27,8 +27,8 @@
'ImpImporter', 'ImpLoader', 'read_code', 'extend_path',
'Distribution', 'EggInfoDistribution', 'distinfo_dirname',
'get_distributions', 'get_distribution', 'get_file_users',
- 'provides_distribution', 'obsoletes_distribution', 'set_cache_enabled',
- 'clear_cache'
+ 'provides_distribution', 'obsoletes_distribution',
+ 'enable_cache', 'disable_cache', 'clear_cache'
]
@@ -626,20 +626,27 @@
_cache_enabled = True
-def set_cache_enabled(flag):
+def enable_cache():
"""
- Enables or disables the internal cache depending on *flag*.
+ Enables the internal cache.
Note that this function will not clear the cache in any case, for that
functionality see :func:`clear_cache`.
-
- :parameter flag:
- :type flag: boolean
"""
global _cache_enabled
- _cache_enabled = flag
+ _cache_enabled = True
+def disable_cache():
+ """
+ Disables the internal cache.
+
+ Note that this function will not clear the cache in any case, for that
+ functionality see :func:`clear_cache`.
+ """
+ global _cache_enabled
+
+ _cache_enabled = False
def clear_cache():
""" Clears the internal cache. """
@@ -654,12 +661,12 @@
_cache_generated_egg = False
-def _yield_distributions(dist, egg):
+def _yield_distributions(include_dist, include_egg):
"""
Yield .dist-info and .egg(-info) distributions, based on the arguments
- :parameter dist: yield .dist-info distributions
- :parameter egg: yield .egg(-info) distributions
+ :parameter include_dist: yield .dist-info distributions
+ :parameter include_egg: yield .egg(-info) distributions
"""
for path in sys.path:
realpath = os.path.realpath(path)
@@ -667,10 +674,10 @@
continue
for dir in os.listdir(realpath):
dist_path = os.path.join(realpath, dir)
- if dist and dir.endswith('.dist-info'):
+ if include_dist and dir.endswith('.dist-info'):
yield Distribution(dist_path)
- elif egg and (dir.endswith('.egg-info') or
- dir.endswith('.egg')):
+ elif include_egg and (dir.endswith('.egg-info') or
+ dir.endswith('.egg')):
yield EggInfoDistribution(dist_path)
@@ -716,7 +723,7 @@
requested = False
"""A boolean that indicates whether the ``REQUESTED`` metadata file is
present (in other words, whether the package was installed by user
- request)."""
+ request or it was installed as a dependency)."""
def __init__(self, path):
if _cache_enabled and path in _cache_path:
diff --git a/src/distutils2/command/install.py b/src/distutils2/command/install.py
--- a/src/distutils2/command/install.py
+++ b/src/distutils2/command/install.py
@@ -79,7 +79,7 @@
('record=', None,
"filename in which to record list of installed files"),
-
+
# .dist-info related arguments, read by install_dist_info
('no-distinfo', None, 'do not create a .dist-info directory'),
('distinfo-dir=', None,
@@ -170,7 +170,7 @@
#self.install_info = None
self.record = None
-
+
# .dist-info related options
self.no_distinfo = None
self.distinfo_dir = None
@@ -323,7 +323,7 @@
# Punt on doc directories for now -- after all, we're punting on
# documentation completely!
-
+
if self.no_distinfo is None:
self.no_distinfo = False
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list