코드 리뷰, 수정
파일 이름을 파싱해서 각 항목에 삽입하는 설명 추가
This commit is contained in:
+10
-26
@@ -7,6 +7,7 @@ import shutil
|
||||
import difflib
|
||||
import subprocess
|
||||
import hashlib
|
||||
import glob
|
||||
|
||||
try:
|
||||
import rarfile
|
||||
@@ -244,36 +245,19 @@ def CreateZIP(output_zip: str, files: list[str]) -> bool:
|
||||
|
||||
# 파일 리스트에 들어있는 파일만 골라서 압축을 합니다. 상대경로를 제거하는게 기본값.
|
||||
def CreateZIPShell(zipName: str, files: list[str], bRmvRPath: bool = True) -> bool:
|
||||
command = "zip "
|
||||
|
||||
command = ["zip"]
|
||||
if True == bRmvRPath:
|
||||
command += "-j "
|
||||
|
||||
command += f"\"{zipName}\" "
|
||||
|
||||
# 이중 리스트인 이유를 모르겠다.
|
||||
for file in files:
|
||||
command += f"\"{file}\" "
|
||||
|
||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
|
||||
bRet = False
|
||||
if 0 == result.returncode:
|
||||
bRet = True
|
||||
|
||||
return bRet
|
||||
command.append("-j")
|
||||
command.extend([zipName, *files])
|
||||
result = subprocess.run(command, capture_output=True, text=True)
|
||||
return result.returncode == 0
|
||||
|
||||
# 특정 확장자만 쉘을 이용해서 압축한다
|
||||
def CreateZIPShExt(zipName: str, TrgExt: str)-> bool:
|
||||
command = f"zip -j {zipName} *.{TrgExt}"
|
||||
|
||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
|
||||
bRet = False
|
||||
if 0 == result.returncode:
|
||||
bRet = True
|
||||
|
||||
return bRet
|
||||
matching_files = glob.glob(f"*.{TrgExt}")
|
||||
command = ["zip", "-j", zipName, *matching_files]
|
||||
result = subprocess.run(command, capture_output=True, text=True)
|
||||
return result.returncode == 0
|
||||
|
||||
# 압축 파일 내의 모든 파일 및 디렉토리 목록 가져오기
|
||||
def GetZipContentList(path: str) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user