30 lines
1.7 KiB
Python
30 lines
1.7 KiB
Python
import sys,json,subprocess,glob,os
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
sys.path.insert(0,r'C:\Aislo_wt\sub_laptop_2\tmp\M01_고침\sub2')
|
|
import tool
|
|
out=subprocess.run(['git','diff','--name-only','--','resources/master_data'],capture_output=True,text=True,encoding='utf-8',cwd=r'C:\Aislo_wt\sub_laptop_2').stdout.split('\n')
|
|
files=[l.strip().strip('"') for l in out if l.strip()]
|
|
import codecs
|
|
def decode(p):
|
|
return p
|
|
n=0
|
|
res=subprocess.run(['git','-c','core.quotepath=off','ls-files','-m','--','resources/master_data'],capture_output=True,cwd=r'C:\Aislo_wt\sub_laptop_2')
|
|
names=[x.decode('utf-8') for x in res.stdout.split(b'\n') if x]
|
|
for f in names:
|
|
old=json.loads(subprocess.run(['git','show','HEAD:'+f],capture_output=True,cwd=r'C:\Aislo_wt\sub_laptop_2').stdout.decode('utf-8'))
|
|
new=json.load(open('C:/Aislo_wt/sub_laptop_2/'+f,encoding='utf-8'))
|
|
ol={l['키']:l for l in old['줄']}
|
|
for l in new['줄']:
|
|
o=ol[l['키']]
|
|
if o==l: continue
|
|
for i,(a,b) in enumerate(zip(o.get('호표',[]),l.get('호표',[]))):
|
|
if a!=b:
|
|
n+=1
|
|
na=a.get('요소'); nb=b.get('요소')
|
|
ck={k for k in set(a)|set(b) if a.get(k)!=b.get(k)}
|
|
cnt,hs=(tool.hits(nb,b.get('단위'),1) if isinstance(nb,dict) and nb.get('검색어') else (0,[]))
|
|
print(f"{l['키']}[{i}] {b['이름']} [{b.get('단위')}] 바뀐칸{sorted(ck)} | {json.dumps(na,ensure_ascii=False) if isinstance(na,dict) else na} -> {json.dumps(nb,ensure_ascii=False) if isinstance(nb,dict) else nb} => {hs[0] if hs else ''}")
|
|
for k in l:
|
|
if k!='호표' and o.get(k)!=l.get(k): print(' ★그 밖 바뀜',l['키'],k,str(o.get(k))[:100],'->',str(l.get(k))[:100])
|
|
print('호표 줄 바뀜',n)
|