Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/virtualenv/util/zipapp.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
1 from __future__ import absolute_import, unicode_literals | |
2 | |
3 import logging | |
4 import os | |
5 import zipfile | |
6 | |
7 from virtualenv.info import IS_WIN, ROOT | |
8 from virtualenv.util.six import ensure_text | |
9 | |
10 | |
11 def read(full_path): | |
12 sub_file = _get_path_within_zip(full_path) | |
13 with zipfile.ZipFile(ROOT, "r") as zip_file: | |
14 with zip_file.open(sub_file) as file_handler: | |
15 return file_handler.read().decode("utf-8") | |
16 | |
17 | |
18 def extract(full_path, dest): | |
19 logging.debug("extract %s to %s", full_path, dest) | |
20 sub_file = _get_path_within_zip(full_path) | |
21 with zipfile.ZipFile(ROOT, "r") as zip_file: | |
22 info = zip_file.getinfo(sub_file) | |
23 info.filename = dest.name | |
24 zip_file.extract(info, ensure_text(str(dest.parent))) | |
25 | |
26 | |
27 def _get_path_within_zip(full_path): | |
28 full_path = os.path.abspath(str(full_path)) | |
29 sub_file = full_path[len(ROOT) + 1 :] | |
30 if IS_WIN: | |
31 # paths are always UNIX separators, even on Windows, though __file__ still follows platform default | |
32 sub_file = sub_file.replace(os.sep, "/") | |
33 return sub_file |