Commit 405454a8 authored by Boris Kocherov's avatar Boris Kocherov Committed by Romain Courteaud

x2t: use with block for open file

(cherry picked from commit e0068547)
parent 3528fff1
...@@ -116,25 +116,23 @@ class Handler(object): ...@@ -116,25 +116,23 @@ class Handler(object):
os.mkdir(output_dir) os.mkdir(output_dir)
output_file_name = os.path.join(output_dir, "body.txt") output_file_name = os.path.join(output_dir, "body.txt")
config_file = open(config_file_name, "w") with open(config_file_name, "w") as config_file:
config = {
config = { # 'm_sKey': 'from',
# 'm_sKey': 'from', 'm_sFileFrom': input_file_name,
'm_sFileFrom': input_file_name, 'm_nFormatFrom': in_format,
'm_nFormatFrom': in_format, 'm_sFileTo': output_file_name,
'm_sFileTo': output_file_name, 'm_nFormatTo': out_format,
'm_nFormatTo': out_format, # 'm_bPaid': 'true',
# 'm_bPaid': 'true', # 'm_bEmbeddedFonts': 'false',
# 'm_bEmbeddedFonts': 'false', # 'm_bFromChanges': 'false',
# 'm_bFromChanges': 'false', # 'm_sFontDir': '/usr/share/fonts',
# 'm_sFontDir': '/usr/share/fonts', # 'm_sThemeDir': '/var/www/onlyoffice/documentserver/FileConverterService/presentationthemes',
# 'm_sThemeDir': '/var/www/onlyoffice/documentserver/FileConverterService/presentationthemes', }
} root = ElementTree.Element('root')
root = ElementTree.Element('root') for key, value in config.items():
for key, value in config.items(): ElementTree.SubElement(root, key).text = value
ElementTree.SubElement(root, key).text = value ElementTree.ElementTree(root).write(config_file, encoding='utf-8', xml_declaration=True, default_namespace=None, method="xml")
ElementTree.ElementTree(root).write(config_file, encoding='utf-8', xml_declaration=True, default_namespace=None, method="xml")
config_file.close()
# run convertion binary # run convertion binary
p = Popen( p = Popen(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment