def _update_json_file(data_dir, data, model_str):
if len(model_str) > 100:
model_str = model_str[:100]
model_dir = os.path.abspath(os.path.join(data_dir, data['model']))
_ensure_dirs(model_dir)
record_path = os.path.abspath(os.path.join(
model_dir, '%s_%s.json' % (data['id'], model_str)))
updated_paths = [record_path]
# Name changed
if not os.path.exists(record_path):
for root, dirs, files in os.walk(model_dir):
for file in files:
if file.startswith(data['id']):
print(file)
old = os.path.abspath(os.path.join(root, file))
os.rename(old, record_path)
updated_paths.append(old)
with open(record_path, 'w') as f:
json.dump(data, f, indent=4, sort_keys=True)
return updated_paths
评论列表
文章目录