MCPcopy Create free account
hub / github.com/Boris-code/feapder / zip

Function zip

feapder/commands/zip.py:24–44  ·  view source on GitHub ↗
(dir_path, zip_name, ignore_dirs: list = None, ignore_files: list = None)

Source from the content-addressed store, hash-verified

22
23
24def zip(dir_path, zip_name, ignore_dirs: list = None, ignore_files: list = None):
25 print(f"正在压缩 {dir_path} >> {zip_name}")
26 ignore_files.append(os.path.basename(zip_name))
27 with zipfile.ZipFile(zip_name, "w") as file:
28 dir_name = os.path.basename(dir_path)
29 parent_dir = os.path.dirname(dir_path)
30 if parent_dir:
31 os.chdir(parent_dir)
32 for path, dirs, filenames in os.walk(dir_name):
33 # 修改原dirs,方式遍历忽略文件夹里的文件
34 if ignore_dirs:
35 dirs[:] = [d for d in dirs if d not in ignore_dirs]
36 for filename in filenames:
37 if ignore_files and is_ignore_file(ignore_files, filename):
38 continue
39
40 filepath = os.path.join(path, filename)
41 print(f" adding {filepath}")
42 file.write(filepath)
43
44 print(f"压缩成功 {dir_path} >> {zip_name}")
45
46
47def parse_args():

Callers 15

test_task.pyFile · 0.85
addMethod · 0.85
getMethod · 0.85
setMethod · 0.85
rows2jsonFunction · 0.85
make_batch_sqlFunction · 0.85
mainFunction · 0.85
distribute_taskMethod · 0.85
distribute_taskMethod · 0.85
__add_item_to_dbMethod · 0.85
findMethod · 0.85
addMethod · 0.85

Calls 2

is_ignore_fileFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected