summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-07-05 11:57:04 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-07-05 11:57:04 -0400
commite7df10e709c9a847e14d1db8d744b39c0183cf8c (patch)
treefdce3574e57e4c789ce92edf421680a9b416d320 /pkg_resources.py
parent8ef8b53e1dc4563c63ddd2ae009bea42fe97f522 (diff)
downloadpython-setuptools-git-e7df10e709c9a847e14d1db8d744b39c0183cf8c.tar.gz
Split MemoizedZipManifests from ZipManifests. Ref #154.
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index b2631be7..f4c7f5e9 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -1533,22 +1533,8 @@ empty_provider = EmptyProvider()
class ZipManifests(dict):
"""
- Memoized zipfile manifests.
+ zip manifest builder
"""
- manifest_mod = collections.namedtuple('manifest_mod', 'manifest mtime')
-
- def load(self, path):
- """
- Load a manifest at path or return a suitable manifest already loaded.
- """
- path = os.path.normpath(path)
- mtime = os.stat(path).st_mtime
-
- if path not in self or self[path].mtime != mtime:
- manifest = self.build(path)
- self[path] = self.manifest_mod(manifest, mtime)
-
- return self[path].manifest
@classmethod
def build(cls, path):
@@ -1569,6 +1555,28 @@ class ZipManifests(dict):
)
return dict(items)
+ load = build
+
+
+class MemoizedZipManifests(ZipManifests):
+ """
+ Memoized zipfile manifests.
+ """
+ manifest_mod = collections.namedtuple('manifest_mod', 'manifest mtime')
+
+ def load(self, path):
+ """
+ Load a manifest at path or return a suitable manifest already loaded.
+ """
+ path = os.path.normpath(path)
+ mtime = os.stat(path).st_mtime
+
+ if path not in self or self[path].mtime != mtime:
+ manifest = self.build(path)
+ self[path] = self.manifest_mod(manifest, mtime)
+
+ return self[path].manifest
+
class ContextualZipFile(zipfile.ZipFile):
"""