Skip to content

Commit

Permalink
improved write to file function, in emit.py (and fixed latin-1)
Browse files Browse the repository at this point in the history
  • Loading branch information
quintijn committed Nov 22, 2023
1 parent fa10b9e commit 8c3730f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
18 changes: 2 additions & 16 deletions src/vocola2/exec/vcl2py/emit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
from vocola2.exec.vcl2py.ast import *
from natlinkcore.readwritefile import ReadWriteFile

log_error = None # temporary kludge

Expand Down Expand Up @@ -39,18 +38,6 @@ def emit_output(out_file, statements):
global Should_emit_dictation_support, OUT
# OUT is now a list, which is written in one stroke
OUT = []
OUT = open(out_file, "w", encoding='latin-1')
# encoding = 'utf-8'
# print(f'opening vocola output file: {out_file}')
# OUT = open(out_file, "w")
# except: UnicodeEncodeError:
# rwfile = readwritefile.ReadWriteFile()
# rwfile.writeAnything(out_file, output_string)
#
# except OSError as e:
# log_error("Unable to open output file '" + out_file + \
# "' for writing: " + str(e))
# return
emit_file_header()
if Should_emit_dictation_support: emit_dictation_grammar()
for statement in statements:
Expand Down Expand Up @@ -626,10 +613,9 @@ def menu_has_actions(menu):
def emit_write_to_file(out_file):
"""write list OUT to out_file
"""
rwfile = ReadWriteFile() # encodings= ['ascii', 'cp1252', 'latin-1'])
out_string = ''.join(OUT)
# print(f'emit_write_to_file: {out_file}')
rwfile.writeAnything(out_file, out_string)
with open(out_file, 'w', encoding='latin-1') as fp:
fp.write(out_string)

def menu_is_range(menu): # verified menu => can contain only 1 range as a 1st term
commands = menu["COMMANDS"]
Expand Down
2 changes: 1 addition & 1 deletion src/vocola2/extensions/vocola_ext_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Vocola procedure: Keys.SendInput
def send_input(specification):
print(f'vocola send_input: {specification}')
# print(f'vocola send_input: {specification}')
SendInput.send_input(
ExtendedSendDragonKeys.senddragonkeys_to_events(specification))

Expand Down

0 comments on commit 8c3730f

Please sign in to comment.