forked from HIllya51/Cartagra_FHD_CHS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckformat.py
39 lines (37 loc) · 1.44 KB
/
checkformat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
for f in os.listdir('SCRIPT_FHD/text'):
#if f!='0206-05-03':continue
#if f!='a2-7-1ED02':continue
if f=='_varstr':continue
with open('SCRIPT_FHD/text/'+f,'r',encoding='utf8') as ff:
bs=ff.read()
if len(bs)==0:continue
if bs[0]=='\ufeff':
with open('SCRIPT_FHD/text/'+f,'w',encoding='utf8') as ff:
ff.write(bs[1:])
with open('SCRIPT_FHD/text/'+f,'r',encoding='utf8') as ff:
lines=ff.read().split('\n')
with open('SCRIPT_FHD/text2/'+f,'r',encoding='utf8') as ff:
lines2=ff.read().split('\n')
with open('SCRIPT_FHD/SCRIPT_FHD/'+f,'rb') as ff:
cankao=ff.read()
for i in range(len(lines)-1):
if i%3==2:
if lines[i]!='':raise Exception(i,f)
else:
if lines[i]=='':raise Exception(i,f)
if i%3 in [0,2] and lines[i]!=lines2[i]:
print( lines[i])
print( lines2[i])
print(list(lines[i]))
print(list(lines2[i]))
raise Exception(i,f)
elif i%3==1 :
if lines2[i].endswith('$') and not lines[i].endswith('$'):
print( lines[i])
print( lines2[i])
lines[i]=lines[i].replace('―。','―')
lines[i]=lines[i].replace('—。','—')
lines[i]=lines[i].replace('。」','」')
with open('SCRIPT_FHD/text/'+f,'w',encoding='utf8') as ff:
ff.write('\n'.join(lines))