summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-05-11 12:43:23 +0100
committerJason R. Coombs <jaraco@jaraco.com>2013-05-11 12:43:23 +0100
commit9027ce5419a346e068927df72dbfcd650cdee33f (patch)
tree767f086dc69424d3a63ef042825c8fec17e212bc /pkg_resources.py
parent065e8eb834d65b4e0572611c16f7f2950db4512b (diff)
downloadpython-setuptools-git-9027ce5419a346e068927df72dbfcd650cdee33f.tar.gz
Extract static method for calculating size and timestamp on a zip resource
--HG-- branch : distribute extra : rebase_source : 3acd099bb90d9abf4d3b265946e0c59b8edcae6e
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 9d406e38..579e3b46 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -1392,6 +1392,16 @@ class ZipProvider(EggProvider):
self._extract_resource(manager, self._eager_to_zip(name))
return self._extract_resource(manager, zip_path)
+ @staticmethod
+ def _get_date_and_size(zip_stat):
+ t,d,size = zip_stat[5], zip_stat[6], zip_stat[3]
+ date_time = (
+ (d>>9)+1980, (d>>5)&0xF, d&0x1F, # ymd
+ (t&0xFFFF)>>11, (t>>5)&0x3F, (t&0x1F) * 2, 0, 0, -1 # hms, etc.
+ )
+ timestamp = time.mktime(date_time)
+ return timestamp, size
+
def _extract_resource(self, manager, zip_path):
if zip_path in self._index():
@@ -1401,13 +1411,7 @@ class ZipProvider(EggProvider):
)
return os.path.dirname(last) # return the extracted directory name
- zip_stat = self.zipinfo[zip_path]
- t,d,size = zip_stat[5], zip_stat[6], zip_stat[3]
- date_time = (
- (d>>9)+1980, (d>>5)&0xF, d&0x1F, # ymd
- (t&0xFFFF)>>11, (t>>5)&0x3F, (t&0x1F) * 2, 0, 0, -1 # hms, etc.
- )
- timestamp = time.mktime(date_time)
+ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
if not WRITE_SUPPORT:
raise IOError('"os.rename" and "os.unlink" are not supported '