Spaces:
Sleeping
Sleeping
File size: 781 Bytes
0523803 92a8514 0523803 92a8514 0523803 92a8514 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import hashlib
import json
import os
def get_all_files_in_directory(directory, ext=''):
all_files = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(ext):
file_path = os.path.join(root, file)
all_files.append(file_path)
return all_files
# ========== 哈希函数 ==========
def x_hash(x: str):
return hashlib.sha1(x.encode('utf-8')).hexdigest()
# ========== 读取配置文件 ==========
with open('rp_config.json', encoding='utf-8') as f:
tmp = f.read()
cfg = json.loads(tmp)
for path in get_all_files_in_directory('config', ext='.json'):
with open(path, encoding='utf-8') as f:
cfg.update(json.load(f))
cfg['setting_cache_path']['value'] += x_hash(tmp)
|