Update 2026-01-20 20:47:44
This commit is contained in:
@@ -83,6 +83,19 @@ def parse_txt_with_st(file_path: Path) -> dict:
|
||||
|
||||
return dict(data)
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# 슬롯 우선순위 설정
|
||||
# ------------------------------------------------------------
|
||||
# 환경변수에서 슬롯 우선순위 읽기 (예: "38,39,37,36,32,33,34,35,31,40")
|
||||
slot_priority_str = os.getenv("GUID_SLOT_PRIORITY", "")
|
||||
if slot_priority_str:
|
||||
SLOT_PRIORITY = [s.strip() for s in slot_priority_str.split(",") if s.strip()]
|
||||
print(f"[INFO] 사용자 지정 슬롯 우선순위: {SLOT_PRIORITY}")
|
||||
else:
|
||||
# 기본 우선순위 (10개)
|
||||
SLOT_PRIORITY = ['38', '39', '37', '36', '32', '33', '34', '35', '31', '40']
|
||||
print(f"[INFO] 기본 슬롯 우선순위 사용: {SLOT_PRIORITY}")
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Load list of file basenames from guid_list.txt
|
||||
# ------------------------------------------------------------
|
||||
@@ -103,7 +116,43 @@ for name in file_names:
|
||||
# rows.append({"S/T": name})
|
||||
continue
|
||||
|
||||
rows.append(parse_txt_with_st(txt_path))
|
||||
parsed_data = parse_txt_with_st(txt_path)
|
||||
|
||||
# 슬롯 우선순위에 따라 데이터 재정렬
|
||||
reordered_data = OrderedDict()
|
||||
reordered_data["S/T"] = parsed_data.get("S/T", "")
|
||||
|
||||
# 슬롯 데이터를 우선순위 순서대로 추가
|
||||
# 슬롯 데이터를 우선순위 순서대로 추가하며 GUID 문자열 재구성
|
||||
new_guid_list = []
|
||||
|
||||
for slot_num in SLOT_PRIORITY:
|
||||
slot_key = f"Slot.{slot_num}"
|
||||
val = parsed_data.get(slot_key)
|
||||
|
||||
# 데이터가 있으면 컬럼 추가
|
||||
if val:
|
||||
reordered_data[slot_key] = val
|
||||
|
||||
# GUID 재구성을 위한 수집 (Not Found 제외, 포맷 확인)
|
||||
if val != "Not Found" and ":" in val:
|
||||
# 예: 3825:F303:0085:07A6 -> 0x3825F303008507A6
|
||||
clean_hex = val.replace(":", "").upper()
|
||||
new_guid_list.append(f"0x{clean_hex}")
|
||||
|
||||
# 1순위: 재구성된 GUID (사용자가 지정한 슬롯 순서대로)
|
||||
# 2순위: 파일에 있던 원본 GUID
|
||||
if new_guid_list:
|
||||
reordered_data["GUID"] = ";".join(new_guid_list)
|
||||
elif "GUID" in parsed_data:
|
||||
reordered_data["GUID"] = parsed_data["GUID"]
|
||||
|
||||
# 나머지 필드들 추가 (슬롯이 아닌 것들)
|
||||
for key, value in parsed_data.items():
|
||||
if key not in reordered_data:
|
||||
reordered_data[key] = value
|
||||
|
||||
rows.append(dict(reordered_data))
|
||||
|
||||
# Build DataFrame (union of keys across all rows)
|
||||
df = pd.DataFrame(rows)
|
||||
|
||||
Reference in New Issue
Block a user