From: rnv Date: Fri, 19 May 2017 12:31:00 +0000 (+0300) Subject: Python3 porting: read/write uniciode files. X-Git-Tag: V9_0_0~7^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=379b4d2dd836a4a2f437f3daf0101030a50b10cf;p=modules%2Fgui.git Python3 porting: read/write uniciode files. --- 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: