|
|
|
|
@ -1,16 +1,41 @@
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
RANGE_NUM: int = 100
|
|
|
|
|
WORK_PATH = "E:/商品资料汇总/商品资料(1151-1200)"
|
|
|
|
|
# WORK_PATH = "C:/Users/Administrator/Desktop/测试"
|
|
|
|
|
|
|
|
|
|
RANGE_NUM: int = 0
|
|
|
|
|
WORK_PATH = ""
|
|
|
|
|
INPUT_PATH = ""
|
|
|
|
|
# INPUT_PATH = "E:/商品资料汇总/商品资料(1101-1150)/ppt1135-世界海洋日"
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def load_config():
|
|
|
|
|
# 构建 config/index.js 的相对路径
|
|
|
|
|
config_file_path = os.path.join(
|
|
|
|
|
os.path.dirname(__file__), "..", "config", "index.js"
|
|
|
|
|
)
|
|
|
|
|
with open(config_file_path, "r", encoding="utf-8") as file:
|
|
|
|
|
content = file.read()
|
|
|
|
|
# 移除注释行
|
|
|
|
|
uncommented_content = re.sub(r"//.*", "", content)
|
|
|
|
|
input_dir_match = re.search(
|
|
|
|
|
r'inputDir:\s*["\']?(.*?)["\']?\s*,', uncommented_content
|
|
|
|
|
)
|
|
|
|
|
directory_path_match = re.search(
|
|
|
|
|
r'directoryPath:\s*["\']?(.*?)["\']?\s*,', uncommented_content
|
|
|
|
|
)
|
|
|
|
|
range_num_match = re.search(
|
|
|
|
|
r'rangeNum:\s*["\']?(.*?)["\']?\s*,', uncommented_content
|
|
|
|
|
)
|
|
|
|
|
if input_dir_match:
|
|
|
|
|
Config.INPUT_PATH = input_dir_match.group(1)
|
|
|
|
|
if directory_path_match:
|
|
|
|
|
Config.WORK_PATH = directory_path_match.group(1)
|
|
|
|
|
if range_num_match:
|
|
|
|
|
Config.RANGE_NUM = range_num_match.group(1)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get_latest_folder(base_directory):
|
|
|
|
|
if Config.INPUT_PATH is not None and Config.INPUT_PATH != "":
|
|
|
|
|
if Config.INPUT_PATH:
|
|
|
|
|
return Config.INPUT_PATH
|
|
|
|
|
folders = [
|
|
|
|
|
os.path.join(base_directory, d)
|
|
|
|
|
@ -21,3 +46,6 @@ class Config:
|
|
|
|
|
return None
|
|
|
|
|
latest_folder = max(folders, key=os.path.getctime) # 获取最新创建的文件夹
|
|
|
|
|
return latest_folder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Config.load_config()
|
|
|
|
|
|