Refactor: typing cleanup, 경로 하드코딩 제거, GPS 데이터 Lon/Lat 분리, 불필요 모듈 삭제
This commit is contained in:
37
PoleXLS.py
37
PoleXLS.py
@@ -23,7 +23,8 @@ class PoleXLS(DBXLStorage):
|
||||
|
||||
self.getSheet(sheetName, True)
|
||||
|
||||
title, recp = util.GetSheetInfoValue(item)
|
||||
text = str(item) if item is not None else ""
|
||||
title, recp = util.GetSheetInfoValue(text)
|
||||
self.SetCellValueStr(sheetName, colIdx, 1, title)
|
||||
listRecp.append(recp)
|
||||
|
||||
@@ -43,17 +44,16 @@ class PoleXLS(DBXLStorage):
|
||||
# 헤더 다음 줄부터 읽는다.
|
||||
listDistance = []
|
||||
for row in sheet.iter_rows(min_row=2, values_only=True):
|
||||
temp = row[1]
|
||||
strLon = row[6]
|
||||
strLat = row[7]
|
||||
|
||||
if "None" in temp:
|
||||
if "None" in strLon or "None" in strLat:
|
||||
continue
|
||||
|
||||
dist = 0
|
||||
if temp != "":
|
||||
parts = temp.split(',')
|
||||
|
||||
trgLat = float(parts[0])
|
||||
trgLon = float(parts[1])
|
||||
if strLon != "" and strLat != "":
|
||||
trgLat = float(strLat)
|
||||
trgLon = float(strLon)
|
||||
dist = util.GetDistanceGPS(srcLat, srcLon, trgLat, trgLon)
|
||||
|
||||
listDistance.append(dist)
|
||||
@@ -67,7 +67,7 @@ class PoleXLS(DBXLStorage):
|
||||
return retIdx, round( min_value, 0 )
|
||||
|
||||
|
||||
def GetPoleInfoAll(self, nIdx):
|
||||
def GetPoleInfoAll(self, nIdx:int):
|
||||
sheet = self.getSheet("PoleInfo")
|
||||
if sheet is None:
|
||||
return None
|
||||
@@ -83,7 +83,7 @@ class PoleXLS(DBXLStorage):
|
||||
return retList
|
||||
|
||||
|
||||
def GetPoleInfo(self, nIdx, colNum):
|
||||
def GetPoleInfo(self, nIdx:int, colNum:int):
|
||||
sheet = self.getSheet("PoleInfo")
|
||||
if sheet is None:
|
||||
return None
|
||||
@@ -94,7 +94,7 @@ class PoleXLS(DBXLStorage):
|
||||
return sheet.cell(row=nIdx,column=colNum).value
|
||||
|
||||
|
||||
def AddImgInfo(self, TrgSheetName, EXIF_Date, EXIF_GPS, Path):
|
||||
def AddImgInfo(self, TrgSheetName:str, EXIF_Date:str, EXIF_GPS:str, Path:str):
|
||||
sheet = self.getSheet("ImgInfo")
|
||||
if sheet is None:
|
||||
return -1
|
||||
@@ -114,7 +114,7 @@ class PoleXLS(DBXLStorage):
|
||||
return TrgRow
|
||||
|
||||
|
||||
def FindRowCompValue(self, sheetNameTrg, nTrgCol, valueSrc, bCmpFile = False, pathBase = ""):
|
||||
def FindRowCompValue(self, sheetNameTrg:str, nTrgCol:int, valueSrc:str, bCmpFile:bool = False, pathBase:str = ""):
|
||||
sheet = self.getSheet(sheetNameTrg)
|
||||
if sheet is None:
|
||||
return -1
|
||||
@@ -129,12 +129,16 @@ class PoleXLS(DBXLStorage):
|
||||
for row in sheet.iter_rows(min_row=2, values_only=True):
|
||||
valueTrg = row[nTrgCol]
|
||||
|
||||
if valueTrg is None or valueTrg == "":
|
||||
continue;
|
||||
|
||||
if True == bCmpFile:
|
||||
# 상대경로로 저장했지만 혹시 절대경로 일 수도 있으니...
|
||||
if False == os.path.isabs(valueTrg):
|
||||
valueTrg = os.path.join(pathBase, valueTrg)
|
||||
|
||||
if True == os.path.samefile(value, valueTrg):
|
||||
|
||||
if True == os.path.samefile(os.path.normpath(value), os.path.normpath(valueTrg)):
|
||||
retIdx = trgIdx + 1
|
||||
break;
|
||||
else:
|
||||
@@ -147,16 +151,19 @@ class PoleXLS(DBXLStorage):
|
||||
return retIdx
|
||||
|
||||
|
||||
def FindInsertedImgPath(self, pathBase, pathImg):
|
||||
def FindInsertedImgPath(self, pathBase: str, pathImg: str):
|
||||
retIdx = self.FindRowCompValue("ImgInfo", 4, pathImg, True, pathBase )
|
||||
return retIdx
|
||||
|
||||
#
|
||||
def GetAllRowValue(self, SheetName, nRow, nColCount):
|
||||
def GetAllRowValue(self, SheetName:str, nRow:int, nColCount:int):
|
||||
sheet = self.getSheet(SheetName)
|
||||
if sheet is None:
|
||||
return None
|
||||
|
||||
if 0 >= nRow:
|
||||
return None
|
||||
|
||||
if 0 >= nColCount:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user