Hello Everyone
The Python formatter that I mentioned a few weeks ago is attached. It has a doc
string that explains its usage.
One thing I'm wondering about is what happens to the memory used by the
liblouis table when the program ends. I don't see how to clear it.
John
--
John J. Boyer
Email: john.boyer@xxxxxxxxxxxxxxxxx
website: http://www.abilitiessoft.org
Status: Company dissolved but website and email addresses live.
Location: Madison, Wisconsin, USA
Mission: developing assistive technology software and providing STEM services
that are available at no cost
""" This program, lou_transtext.py, takes an input file, translates it with
liblouis according to the tablelist variable
and formats it with a line length given in the lineLength variable. It asks for
the names of the input file and the output file.
As provided, tableList is ["en-ueb-g2.ctb] Note that it is a Python list.
lineLength is currently set to 38. You can set tableList and lineLength
according to your preferences.
"""
tableList = ["en-ueb-g2.ctb"]
lineLength = 38
import louis
import textwrap
fileIn = input ("Please enter the input file name: ")
fileOut = input ("Please enter the output file name: ")
inputFile = open (fileIn, "rt")
outputFile = open (fileOut, "wt", newline='\r\n')
while True:
line = next(inputFile, None)
if line is None:
break
line2 = line.strip()
if line2 == "":
continue
translation = louis.translateString (tableList, line2, 0, 0)
outputFile.write (textwrap.fill (translation, lineLength))
outputFile.write("\n")
inputFile.close()
outputFile.close()
print ("Done.")