Update .gitignore, StoreXLS.py, and 4 more files...

This commit is contained in:
2024-10-31 16:08:01 +09:00
parent 401627a58f
commit 8f64bb2fc1
6 changed files with 303 additions and 12 deletions

View File

@@ -60,6 +60,25 @@ def ListSubDirectories(root_dir):
return subdirectories
# 자식 폴더를 구해온다. 직계 자식만
def ListChildDirectories(pathDir):
listRet = []
for name in os.listdir(pathDir):
pathChild = os.path.join(pathDir, name)
if os.path.isdir(pathChild):
listRet.append(pathChild)
return listRet
# 파일목록만 구해온다. 자식 폴더에 있는건 무시.
def ListContainFiles(pathDir):
listRet = []
for name in os.listdir(pathDir):
pathChild = os.path.join(pathDir, name)
if not os.path.isdir(pathChild):
listRet.append(pathChild)
return listRet
def ListFileExtRcr(pathTrg, strExt):
listRet= []
@@ -73,6 +92,22 @@ def ListFileExtRcr(pathTrg, strExt):
return listRet
# 입력된 패스에서 부모 폴더를 찾는다. 0 은 자기자신 1은 부모, 숫자대로 위로.
def GetParentDirName(FullPath, nUp):
parts = FullPath.split(os.sep)
nTrgIdx = 0
if nUp < len(parts):
nTrgIdx = len(parts) -nUp -1
elif nUp < 0:
nTrgIdx = len(parts) - 1
else:
nTrgIdx = 0
return parts[nTrgIdx]
# 입력된 경로가 자식 폴더를 가지고 있는지 판단한다.- 최종 폴더인지 여부
# 자식이 없으면 True, 자식이 있으면 False
def IsFinalFolder(path):
@@ -193,6 +228,32 @@ def CreateZIPShExt(zipName, TrgExt):
bRet = True
return bRet
# 압축 파일 내의 모든 파일 및 디렉토리 목록 가져오기
def GetZipContentList(path):
if None == path or not os.path.isfile(path):
return []
listRet = []
with zipfile.ZipFile( path , 'r') as zip_file:
listRet = zip_file.namelist()
return listRet
def GetZippedFileByte(pathZip, FileName):
if None == pathZip or not os.path.isfile(pathZip):
return None
retBytes = None
with zipfile.ZipFile( pathZip , 'r') as zip_file:
if not FileName in zip_file.namelist():
return None
with zip_file.open(FileName) as file:
retBytes = file.read()
return retBytes
# JSON 을 트리 구조로 출력한다.
def PrintJSONTree(data, indent=0):