mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 05:32:00 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -59,6 +59,7 @@ def zip_dir(path, stream, include_dir=True, fnct_sort=None): # TODO add ign
|
|||
if len_prefix:
|
||||
len_prefix += 1
|
||||
|
||||
dir_root_path = os.path.realpath(path)
|
||||
with zipfile.ZipFile(stream, 'w', compression=zipfile.ZIP_DEFLATED, allowZip64=True) as zipf:
|
||||
for dirpath, _dirnames, filenames in os.walk(path):
|
||||
filenames = sorted(filenames, key=fnct_sort)
|
||||
|
|
@ -66,9 +67,10 @@ def zip_dir(path, stream, include_dir=True, fnct_sort=None): # TODO add ign
|
|||
bname, ext = os.path.splitext(fname)
|
||||
ext = ext or bname
|
||||
if ext not in ['.pyc', '.pyo', '.swp', '.DS_Store']:
|
||||
path = os.path.normpath(os.path.join(dirpath, fname))
|
||||
if os.path.isfile(path):
|
||||
zipf.write(path, path[len_prefix:])
|
||||
fpath = os.path.normpath(os.path.join(dirpath, fname))
|
||||
real_fpath = os.path.realpath(fpath)
|
||||
if os.path.isfile(real_fpath) and os.path.commonpath([dir_root_path, real_fpath]) == dir_root_path:
|
||||
zipf.write(real_fpath, fpath[len_prefix:])
|
||||
|
||||
|
||||
if os.name != 'nt':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue