You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.4 KiB

"""copy staged .bru files into the docs repo (workspace-external -> python only)."""
import io
import os
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
STAGE = r"d:\code\crm-backend-matt\.scratch\customer-rework\bru-staging"
DOCS = r"D:\code\crm-api-docs"
MAPPING = [
("战略协议", "A4 客户管理/战略协议"), # whole dir, 5 files
("我的客户/批量更新工商信息.bru", "A4 客户管理/我的客户/批量更新工商信息.bru"),
("客户公海/上传导入文件并预校验.bru", "A4 客户管理/客户公海/上传导入文件并预校验.bru"),
("客户导入/上传导入文件并预校验.bru", "A4 客户管理/我的客户/客户导入/上传导入文件并预校验.bru"),
]
def copy_clean(src, dst):
data = open(src, "rb").read()
if data[:3] == b"\xef\xbb\xbf":
data = data[3:]
os.makedirs(os.path.dirname(dst), exist_ok=True)
open(dst, "wb").write(data)
print("OK", dst.replace(DOCS, ""), len(data), "bytes")
for src_rel, dst_rel in MAPPING:
s = os.path.join(STAGE, *src_rel.split("/"))
d = os.path.join(DOCS, *dst_rel.split("/"))
if os.path.isdir(s):
for root, _, files in os.walk(s):
for fn in files:
rel = os.path.relpath(os.path.join(root, fn), s)
copy_clean(os.path.join(root, fn), os.path.join(d, *rel.split(os.sep)))
else:
copy_clean(s, d)