feat(manual): 手工工程导入导出(决策229/230)与本页搜索共享层
This commit is contained in:
68
_inspect_div.py
Normal file
68
_inspect_div.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""临时解剖第二轮:分部开标签全属性 + 嵌套子分部实例 + .cos 对照(看完即删)。"""
|
||||
import re
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
sys.path.insert(0, r"D:\PricingReview\CostReview\app\core")
|
||||
import export_cos as ec
|
||||
|
||||
for PATH in sys.argv[1:]:
|
||||
z = zipfile.ZipFile(PATH)
|
||||
unit_nm = None
|
||||
proj_nm = None
|
||||
for nm in z.namelist():
|
||||
if not nm.lower().endswith(".xml"):
|
||||
continue
|
||||
txt0, _ = ec._decode(z.read(nm))
|
||||
root = re.sub(r"^.*?\?>", "", txt0, count=1, flags=re.S).lstrip()
|
||||
if root.startswith("<UnitWorks") and unit_nm is None:
|
||||
unit_nm = nm
|
||||
txt = txt0
|
||||
elif ("<SectionalWorks" in txt0 or "<DivisionalAndElementalProject" in txt0) and proj_nm is None:
|
||||
proj_nm = nm
|
||||
print("=" * 70)
|
||||
print("件:", PATH.split("/")[-1], "| 单位成员:", (unit_nm or "无")[:40], "| 项目成员:", (proj_nm or "无")[:40])
|
||||
if not unit_nm:
|
||||
continue
|
||||
txt, enc = ec._decode(z.read(unit_nm))
|
||||
# ① 全部 DivisionalWorks 开标签(前 5 个,全属性)
|
||||
ots = []
|
||||
pos = 0
|
||||
while len(ots) < 5:
|
||||
m = re.compile(r"<DivisionalWorks\b").search(txt, pos)
|
||||
if not m:
|
||||
break
|
||||
e = ec._open_tag_end(txt, m.start())
|
||||
ots.append(txt[m.start():e])
|
||||
pos = e
|
||||
for ot in ots:
|
||||
print("DW开标签:", ot[:300])
|
||||
# ② 嵌套深度普查:DW 起止配对算深度
|
||||
depth, maxd, stack = 0, 0, 0
|
||||
for m in re.finditer(r"<(/?)DivisionalWorks\b", txt):
|
||||
if m.group(1):
|
||||
depth -= 1
|
||||
else:
|
||||
depth += 1
|
||||
maxd = max(maxd, depth)
|
||||
print("DivisionalWorks 最大嵌套深度:", maxd)
|
||||
# ③ 一条清单的完整开标签(看清单属性集)
|
||||
m = re.compile(r"<WorkElement\b").search(txt)
|
||||
if m:
|
||||
e = ec._open_tag_end(txt, m.start())
|
||||
print("清单开标签:", txt[m.start():e][:400])
|
||||
# ④ 项目成员里的 SectionalWorks/DivisionalAndElementalProject 与 UnitWorks 引用
|
||||
if proj_nm:
|
||||
ptxt, _ = ec._decode(z.read(proj_nm))
|
||||
for t in ("SectionalWorks", "DivisionalAndElementalProject"):
|
||||
m2 = re.compile(r"<%s\b" % t).search(ptxt)
|
||||
if m2:
|
||||
e2 = ec._open_tag_end(ptxt, m2.start())
|
||||
print("%s 开标签:" % t, ptxt[m2.start():e2][:250])
|
||||
m3 = re.compile(r"<UnitWorks\b").search(ptxt)
|
||||
if m3:
|
||||
e3 = ec._open_tag_end(ptxt, m3.start())
|
||||
print("项目成员UnitWorks引用:", ptxt[m3.start():e3][:250])
|
||||
m4 = re.compile(r"<\w+:?\w*\b").search(re.sub(r"^.*?\?>", "", ptxt, count=1, flags=re.S).lstrip())
|
||||
print("项目成员根:", m4.group(0) if m4 else "?")
|
||||
Reference in New Issue
Block a user