# -*- coding: utf-8 -*-
|
import io
|
|
base = r'C:\Users\jcxiong\Documents\Codex\MyProject\trafficAudit'
|
|
sql_path = base + r'\docs\init.sql'
|
with io.open(sql_path, encoding='utf-8') as f:
|
sql = f.read()
|
|
pairs = [
|
(""" -- 规上
|
above_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规上周转量',""",
|
""" -- 规上
|
above_scale_freight DECIMAL(15,2) DEFAULT 0 COMMENT '规上货运量',
|
above_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规上周转量',"""),
|
(""" -- 规下
|
below_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规下周转量',""",
|
""" -- 规下
|
below_scale_freight DECIMAL(15,2) DEFAULT 0 COMMENT '规下货运量',
|
below_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规下周转量',"""),
|
(""" -- 合计
|
total_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '运输量(规上+规下)',""",
|
""" -- 合计
|
total_freight DECIMAL(15,2) DEFAULT 0 COMMENT '运输量合计-货运量',
|
total_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '运输量合计-周转量',"""),
|
]
|
for old, new in pairs:
|
assert old in sql, 'anchor missing: ' + old[:40]
|
sql = sql.replace(old, new)
|
with io.open(sql_path, 'w', encoding='utf-8', newline='') as f:
|
f.write(sql)
|
print('init.sql updated')
|
|
md_path = base + r'\docs\database.md'
|
with io.open(md_path, encoding='utf-8') as f:
|
md = f.read()
|
pairs_md = [
|
('| above_scale_turnover | decimal(15,2) | 规上周转量 |',
|
'| above_scale_freight | decimal(15,2) | 规上货运量 |\n| above_scale_turnover | decimal(15,2) | 规上周转量 |'),
|
('| below_scale_turnover | decimal(15,2) | 规下周转量 |',
|
'| below_scale_freight | decimal(15,2) | 规下货运量 |\n| below_scale_turnover | decimal(15,2) | 规下周转量 |'),
|
("| total_turnover | decimal(15,2) | 运输量(规上+规下) |",
|
'| total_freight | decimal(15,2) | 运输量合计-货运量 |\n| total_turnover | decimal(15,2) | 运输量合计-周转量 |'),
|
]
|
for old, new in pairs_md:
|
assert old in md, 'md anchor missing: ' + old[:40]
|
md = md.replace(old, new)
|
with io.open(md_path, 'w', encoding='utf-8', newline='') as f:
|
f.write(md)
|
print('database.md updated')
|