From 379b4d2dd836a4a2f437f3daf0101030a50b10cf Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 19 May 2017 15:31:00 +0300 Subject: [PATCH] Python3 porting: read/write uniciode files. --- tools/dlgfactory/dlgfactory.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/dlgfactory/dlgfactory.py b/tools/dlgfactory/dlgfactory.py index 96b8dc4bf..5b0c89975 100755 --- a/tools/dlgfactory/dlgfactory.py +++ b/tools/dlgfactory/dlgfactory.py @@ -81,7 +81,7 @@ salomeinclude_HEADERS += __CLASSNAME__.h if __name__ == "__main__": from optparse import OptionParser - import shutil, fileinput + import codecs tool_path = os.path.dirname( os.path.abspath( sys.argv[0] ) ) @@ -108,12 +108,13 @@ if __name__ == "__main__": else: file_src = os.path.join( tool_path, "__GDIALOG__" + ext ) pass - shutil.copyfile( file_src, file_dest ) - finput = fileinput.FileInput( file_dest, inplace=1 ) - for line in finput: + fi = codecs.open(file_src, 'r', encoding='utf-8') + fo = codecs.open(file_dest, 'w', encoding='utf-8') + for line in fi: line = line[:-1] line = line.replace( "__CLASSNAME__", className ) - print(line) + line = line + "\n" + fo.write(line) pass if options.verbose: -- 2.39.2