|
import glob
|
|
import subprocess
|
|
import os
|
|
import time
|
|
import shutil
|
|
|
|
repoRoot='/home/lou/Public/ELTeC-'
|
|
#webRoot='/home/lou/Public/distantreading.github.io/ELTeC/'
|
|
webRoot='/home/lou/Desktop/'
|
|
scriptRoot='/home/lou/Public/Scripts/'
|
|
summarizer=scriptRoot+'summarize.xsl'
|
|
|
|
dateLine='<p>Summary produced: '+time.strftime("%Y-%m-%d")+'</p>'
|
|
summaryTail="</table>"+dateLine+"</body></html>"
|
|
|
|
LANGS=('cze', 'deu', 'eng', 'fra', 'gre', 'gsw', 'hrv', 'hun', 'ita', 'lav', 'nor', 'pol', 'por', 'rom', 'slv', 'spa', 'srp', 'swe', 'ukr')
|
|
|
|
shutil.copyfile(scriptRoot+'summary-head.html', webRoot+'index.html')
|
|
|
|
import sys
|
|
sys.path.append("/usr/lib/Saxon.C.API/python-saxon")
|
|
# import the Saxon/C library
|
|
import saxonc
|
|
with saxonc.PySaxonProcessor(license=False) as proc:
|
|
print(proc.version)
|
|
proc.set_configuration_property("xi", "on")
|
|
xdmAtomicval = proc.make_boolean_value(False)
|
|
xsltproc = proc.new_xslt30_processor()
|
|
for LANG in LANGS:
|
|
repoName=repoRoot+LANG
|
|
os.chdir(repoName)
|
|
lastUpdate = str(subprocess.check_output(['git', 'log', '-1', '--date=short', '--format=format:%cd']),encoding='UTF8')
|
|
print("Summarizing repo "+repoName+ " on "+lastUpdate)
|
|
xdm_lang= proc.make_string_value(LANG)
|
|
xdm_lastUpdate = proc.make_string_value(lastUpdate)
|
|
xsltproc.set_parameter("corpus", xdm_lang)
|
|
xsltproc.set_parameter("lastUpdate",xdm_lastUpdate)
|
|
result = xsltproc.transform_to_string(source_file=repoName + "/driver.tei", stylesheet_file=scriptRoot+"summarize.xsl")
|
|
print(result)
|
|
with open(webRoot+'index.html', 'a') as file:
|
|
file.write(summaryTail)
|