webcam compress
This commit is contained in:
parent
016fa31ba4
commit
43bcd9a316
|
@ -9,11 +9,11 @@ import os
|
|||
|
||||
ROOT_PATH = sys.path[0] # 项目根目录
|
||||
|
||||
COMPRESS_SUFFIX = ['zip', 'tar']
|
||||
|
||||
# 判断压缩文件名称
|
||||
def is_compressFile(compressStyle):
|
||||
compressList = ['zip', 'tar']
|
||||
if compressStyle not in compressList:
|
||||
if compressStyle not in COMPRESS_SUFFIX:
|
||||
print(f'{compressStyle}:不正确!程序退出!')
|
||||
sys.exit()
|
||||
|
||||
|
@ -28,12 +28,12 @@ def webcam_compress(compressStyle, is_autoCompressName, compressName, preCompres
|
|||
file_list = os.listdir(preCompressFilePath) # 获取目录下的文件名称
|
||||
|
||||
# ----------压缩开始----------
|
||||
if (compressStyle == "zip"):
|
||||
if (compressStyle == COMPRESS_SUFFIX[0]):
|
||||
compress_file = zipfile.ZipFile(compressName, compressMode)
|
||||
for i in range(len(file_list)):
|
||||
compress_file.write(
|
||||
f'{preCompressFilePath}/{file_list[i]}', compress_type=zipfile.ZIP_DEFLATED)
|
||||
if (compressStyle == "tar"):
|
||||
if (compressStyle == COMPRESS_SUFFIX[1]):
|
||||
compress_file = tarfile.open(compressName, compressMode)
|
||||
for i in range(len(file_list)):
|
||||
compress_file.add(f'{preCompressFilePath}/{file_list[i]}')
|
||||
|
|
Loading…
Reference in New Issue