Andley_OGNTa/Scripts/Step4-Combine-CUV.py

34 lines
958 B
Python
Raw Normal View History

2021-11-26 01:13:28 +00:00
import re
from datetime import date
todays_date = date.today()
2023-07-24 14:06:49 +00:00
inputFile = "./tmp/OGNTa-Ruby.nt"
2021-11-26 01:13:28 +00:00
cuvFile = "./CUV.txt"
2023-07-24 14:06:49 +00:00
outputFile = "./tmp/OGNTa-Ruby+CUV.nt"
2021-11-26 01:13:28 +00:00
2021-12-09 01:29:52 +00:00
f = open(inputFile,'r',encoding="utf_8_sig")
2021-11-26 01:13:28 +00:00
Lines = f.readlines()
f.close()
2021-12-09 01:29:52 +00:00
f = open(cuvFile,'r',encoding="utf_8_sig")
2021-11-26 01:13:28 +00:00
cuvLines = f.readlines()
f.close()
2021-12-09 01:29:52 +00:00
f = open(outputFile,'w',encoding='utf_8_sig')
2021-11-26 01:13:28 +00:00
for i in range(len(cuvLines)):
2021-12-09 01:29:52 +00:00
#print(Lines[i])
2023-07-30 07:39:46 +00:00
Lines[i] = re.sub('<RUBY><ruby><ruby>(.*?)<rt>(.*?)</rt></ruby><rt>(.*?)</rt></ruby><rt>(.*?)</rt></RUBY> ', r'\1', Lines[i])
2021-12-09 01:29:52 +00:00
#print (Lines[i])
2023-07-24 22:18:55 +00:00
Lines[i] = re.sub('<rt>(.*?)</rt>', r'\1', Lines[i])
2021-11-26 01:13:28 +00:00
ol = Lines[i].strip()+cuvLines[i]
f.write(ol)
#print (ol)
2023-07-30 07:39:46 +00:00
f.write("\n\n\nlang=grc\n notags=1\nshort.title=OGNTa-Ruby+CUV\nversion.major="+str(todays_date.year)+"\nversion.minor="+str(todays_date.month)+str(todays_date.day)+"\nversion.date="+str(todays_date)+"\ndescription=OGNTa-Ruby+CUV (https://github.com/Andley/OGNTa)")
2021-11-26 01:13:28 +00:00
f.close()