From e3569d7e57c81784242f2c392acb6d6bf179b1d3 Mon Sep 17 00:00:00 2001 From: mzn Date: Tue, 31 Jul 2018 10:53:54 +0300 Subject: [PATCH] Porting on Python3; remove study id from SALOME Python API calls. --- correction_auto_2.py | 358 +++++++++--------- salome_pid.py | 2 +- src/CollectionAPI/CollectionAPI.i | 2 +- src/Config/Config_ModuleReader.cpp | 2 +- src/ConnectorAPI/Test/TestExportToGEOM.py | 10 +- .../TestExportToGEOMAllGroupsAndFields.py | 6 +- src/ConnectorPlugin/ConnectorPlugin.py | 2 +- .../ConnectorPlugin_ExportFeature.py | 4 +- src/ExchangePlugin/Test/TestExport.py | 2 +- src/ExchangePlugin/Test/TestImport.py | 2 +- src/FeaturesPlugin/Test/TestMultiBoolean.py | 8 +- src/FeaturesPlugin/Test/TestSerialBoolean.py | 8 +- .../InitializationPlugin_PyInterp.cpp | 21 +- src/ModelAPI/ModelAPI.i | 14 +- src/ModelAPI/Test/TestCustomName_CutGroup.py | 2 +- src/ModelHighAPI/ModelHighAPI.i | 20 +- src/ModelHighAPI/ModelHighAPI_Tools.cpp | 8 +- .../Test/TestParameterCreation.py | 2 +- src/PythonAPI/doc/source/conf.py | 16 +- src/PythonAPI/model/__init__.py | 28 +- src/PythonAPI/model/dump/__init__.py | 2 +- src/PythonAPI/model/sketcher/__init__.py | 4 +- src/PythonAPI/model/sketcher/tools.py | 2 +- src/PythonAPI/model/tests/__init__.py | 2 +- src/PythonAPI/model/tests/tests.py | 12 +- src/PythonAddons/addons_Features.py | 2 +- src/SketchAPI/SketchAPI.i | 2 +- src/SketchPlugin/Test/Test1673.py | 4 +- src/SketchPlugin/Test/Test1966.py | 6 +- src/SketchPlugin/Test/Test1967.py | 4 +- src/SketchPlugin/Test/TestConstraintFixed.py | 4 +- src/SketchPlugin/Test/TestHighload.py | 6 +- src/SketchPlugin/Test/TestMirror.py | 2 +- src/SketchPlugin/Test/TestSnowflake.py | 6 +- test.API/SHAPER/GDML/TestAPI_ConeSegment.py | 16 +- test.API/SHAPER/Primitives/TestAPI_Box.py | 24 +- .../SHAPER/Primitives/TestAPI_Cylinder.py | 30 +- .../TestAPI_MultiTranslation.py | 4 +- .../Transformations/TestAPI_Rotation.py | 22 +- .../SHAPER/Transformations/TestAPI_Scale.py | 12 +- .../Transformations/TestAPI_Symmetry.py | 2 +- .../Transformations/TestAPI_Translation.py | 10 +- .../shared/scripts/bdd_hooks.py | 2 +- .../shared/steps/steps.py | 2 +- utils.py | 24 +- 45 files changed, 363 insertions(+), 360 deletions(-) mode change 100755 => 100644 salome_pid.py diff --git a/correction_auto_2.py b/correction_auto_2.py index ec3b240fc..7d48ea142 100644 --- a/correction_auto_2.py +++ b/correction_auto_2.py @@ -40,14 +40,14 @@ from utils import * ### whitespace/semicolon ### def extra_space_before_last_semicolon(ligne, previous_ligne = None, warning=None): - liste=ligne.split(u';\n') + liste=ligne.split(';\n') ligne2=liste[0] ligne3=ligne2.rstrip() - ligne=ligne3 + u';\n' + ligne=ligne3 + ';\n' return ligne, previous_ligne, False def missing_space_after_semicolon(ligne, previous_ligne = None, warning=None): - ligne=ligne.replace(u';',u'; ') + ligne=ligne.replace(';','; ') return ligne, previous_ligne, False ######################### @@ -55,86 +55,86 @@ def missing_space_after_semicolon(ligne, previous_ligne = None, warning=None): ### whitespace/operators ### def missing_space_around_operator_egal(ligne, previous_ligne = None, warning=None): - i=ligne.find(u'=') + i=ligne.find('=') nextchar=ligne[i+1] previouschar=ligne[i-1] if nextchar not in OPERATORS and previouschar not in OPERATORS: if nextchar.isspace() == False and previouschar.isspace()==True: - ligne=ligne.replace(u'=', u'= ') + ligne=ligne.replace('=', '= ') elif nextchar.isspace() == True and previouschar.isspace()==False: - ligne=ligne.replace(u'=', u' =') + ligne=ligne.replace('=', ' =') elif nextchar.isspace() == False and previouschar.isspace()==False: - ligne=ligne.replace(u'=', u' = ') + ligne=ligne.replace('=', ' = ') else: pass return ligne, previous_ligne, False def extra_space_for_operator_add(ligne, previous_ligne = None, warning=None): - while ligne.find(u'++ ') > -1: - ligne = ligne.replace(u'++ ',u'++') - while ligne.find(u' ++') > -1 and ligne.find(u'; ++') == -1: - ligne = ligne.replace(u' ++',u'++') + while ligne.find('++ ') > -1: + ligne = ligne.replace('++ ','++') + while ligne.find(' ++') > -1 and ligne.find('; ++') == -1: + ligne = ligne.replace(' ++','++') return ligne, previous_ligne, False def extra_space_for_operator_diff(ligne, previous_ligne = None, warning=None): - while ligne.find(u'! ') > -1: - ligne = ligne.replace(u'! ',u'!') + while ligne.find('! ') > -1: + ligne = ligne.replace('! ','!') return ligne, previous_ligne, False def missing_space_around_operator_double_chevron(ligne, previous_ligne = None, warning=None): - i=ligne.find(u'<<') + i=ligne.find('<<') nextchar=ligne[i+1] previouschar=ligne[i-1] if nextchar.isspace() == False and previouschar.isspace()==True: - ligne=ligne.replace(u'<<', u'<< ') + ligne=ligne.replace('<<', '<< ') elif nextchar.isspace() == True and previouschar.isspace()==False: - ligne=ligne.replace(u'<<', u' <<') + ligne=ligne.replace('<<', ' <<') elif nextchar.isspace() == False and previouschar.isspace()==False: - ligne=ligne.replace(u'<<', u' << ') + ligne=ligne.replace('<<', ' << ') else: pass return ligne, previous_ligne, False def missing_space_around_operator_simple_chevron(ligne, previous_ligne = None, warning=None): - i=ligne.find(u'<') + i=ligne.find('<') nextchar=ligne[i+1] previouschar=ligne[i-1] if nextchar not in OPERATORS and previouschar not in OPERATORS: if nextchar.isspace() == False and previouschar.isspace()==True: - ligne=ligne.replace(u'<', u'< ') + ligne=ligne.replace('<', '< ') elif nextchar.isspace() == True and previouschar.isspace()==False: - ligne=ligne.replace(u'<', u' <') + ligne=ligne.replace('<', ' <') elif nextchar.isspace() == False and previouschar.isspace()==False: - ligne=ligne.replace(u'<', u' < ') + ligne=ligne.replace('<', ' < ') else: pass return ligne, previous_ligne, False def missing_space_around_operator_diff_egal(ligne, previous_ligne = None, warning=None): - i=ligne.find(u'!=') + i=ligne.find('!=') nextchar=ligne[i+1] previouschar=ligne[i-1] if nextchar.isspace() == False and previouschar.isspace()==True: - ligne=ligne.replace(u'!=', u'!= ') + ligne=ligne.replace('!=', '!= ') elif nextchar.isspace() == True and previouschar.isspace()==False: - ligne=ligne.replace(u'!=', u' !=') + ligne=ligne.replace('!=', ' !=') elif nextchar.isspace() == False and previouschar.isspace()==False: - ligne=ligne.replace(u'!=', u' != ') + ligne=ligne.replace('!=', ' != ') else: pass return ligne, previous_ligne, False def missing_space_around_operator_double_egal(ligne, previous_ligne = None, warning=None): - i=ligne.find(u'==') + i=ligne.find('==') nextchar=ligne[i+1] previouschar=ligne[i-1] if nextchar.isspace() == False and previouschar.isspace()==True: - ligne=ligne.replace(u'==', u'== ') + ligne=ligne.replace('==', '== ') elif nextchar.isspace() == True and previouschar.isspace()==False: - ligne=ligne.replace(u'==', u' ==') + ligne=ligne.replace('==', ' ==') elif nextchar.isspace() == False and previouschar.isspace()==False: - ligne=ligne.replace(u'==', u' == ') + ligne=ligne.replace('==', ' == ') else: pass return ligne, previous_ligne, False @@ -145,16 +145,16 @@ def missing_space_around_operator_double_egal(ligne, previous_ligne = None, warn ### whitespace/comments ### def space_between_comments_and_code(ligne, previous_ligne = None, warning=None): - if ligne.find(u'//')>=0 : - ligne=ligne.replace(u'//', u' //') - elif ligne.find(u' //')>=0 : - ligne=ligne.replace(u' //', u' //') + if ligne.find('//')>=0 : + ligne=ligne.replace('//', ' //') + elif ligne.find(' //')>=0 : + ligne=ligne.replace(' //', ' //') else: pass return ligne, previous_ligne, False def space_between_comments_and_double_slash(ligne, previous_ligne = None, warning=None): - return ligne.replace(u'//', u'// '), previous_ligne, False + return ligne.replace('//', '// '), previous_ligne, False ######################### @@ -175,11 +175,11 @@ def ifndef_header(ficpath, ficline, warning): # replace_fic_ifndef(ficpath, ficline, warning, "no_guard_found") def endif_line(ligne, previous_ligne = None, warning=None): - liste1=warning.split(u'// ') + liste1=warning.split('// ') ligne1=liste1[1] - liste2=ligne1.split(u'"') + liste2=ligne1.split('"') header_guard=liste2[0] - ligne= u'#endif // ' + header_guard +u'\n' + ligne= '#endif // ' + header_guard +'\n' return ligne, previous_ligne, False ######################### @@ -196,7 +196,7 @@ def whitespace_end_of_line(ligne, previous_ligne = None, warning=None): ### whitespace/comma ### def missing_space_after_comma(ligne, previous_ligne = None, warning=None): - ligne=ligne.replace(u',',u', ') + ligne=ligne.replace(',',', ') return ligne, previous_ligne, False ######################### @@ -204,18 +204,18 @@ def missing_space_after_comma(ligne, previous_ligne = None, warning=None): ### readability/namespace ### def namespace_should_be_terminated(ligne, previous_ligne = None, warning=None): - ligne2=ligne.rstrip(u'\n') - liste = warning.split(u'"') + ligne2=ligne.rstrip('\n') + liste = warning.split('"') namespace=liste[1] - if ligne.find(u'\r')>=0: - ligne=ligne2+u' '+namespace+u'\r\n' + if ligne.find('\r')>=0: + ligne=ligne2+' '+namespace+'\r\n' else: - ligne=ligne2+u' '+namespace+u'\n' + ligne=ligne2+' '+namespace+'\n' return ligne, previous_ligne, False def anonymous_namespace_should_be_terminated(ligne, previous_ligne = None, warning=None): - ligne2=ligne.rstrip(u'\n') - ligne=ligne2+u' // namespace\n' + ligne2=ligne.rstrip('\n') + ligne=ligne2+' // namespace\n' return ligne, previous_ligne, False ######################### @@ -223,37 +223,37 @@ def anonymous_namespace_should_be_terminated(ligne, previous_ligne = None, warni ### whitespace/parens ### def extra_space_after_opening_paranthesis(ligne, previous_ligne = None, warning=None): - while ligne.find(u'( ') > -1: - ligne = ligne.replace(u'( ',u'(') + while ligne.find('( ') > -1: + ligne = ligne.replace('( ','(') return ligne, previous_ligne, False def extra_space_before_closing_paranthesis(ligne, previous_ligne = None, warning=None): - while ligne.find(u' )') > -1: - ligne = ligne.replace(u' )',u')') + while ligne.find(' )') > -1: + ligne = ligne.replace(' )',')') return ligne, previous_ligne, False def extra_space_before_opening_paranthesis_in_function_call(ligne, previous_ligne = None, warning=None): - while ligne.find(u' (') > -1 and ligne.find(u', (')==-1: - ligne = ligne.replace(u' (',u'(') + while ligne.find(' (') > -1 and ligne.find(', (')==-1: + ligne = ligne.replace(' (','(') return ligne, previous_ligne, False def missing_space_before_opening_parenthesis_in_for(ligne, previous_ligne = None, warning=None): - return ligne.replace(u'for(',u'for ('), previous_ligne, False + return ligne.replace('for(','for ('), previous_ligne, False def missing_space_before_opening_parenthesis_in_if(ligne, previous_ligne = None, warning=None): - return ligne.replace(u'if(',u'if ('), previous_ligne, False + return ligne.replace('if(','if ('), previous_ligne, False def missing_space_before_opening_parenthesis_in_switch(ligne, previous_ligne = None, warning=None): - return ligne.replace(u'switch(',u'switch ('), previous_ligne, False + return ligne.replace('switch(','switch ('), previous_ligne, False def missing_space_before_opening_parenthesis_in_while(ligne, previous_ligne = None, warning=None): - return ligne.replace(u'while(',u'while ('), previous_ligne, False + return ligne.replace('while(','while ('), previous_ligne, False def mismatching_spaces_inside_paranthesis(ligne, previous_ligne = None, warning=None): - while ligne.find(u'( ') > -1: - ligne = ligne.replace(u'( ',u'(') - while ligne.find(u' )') > -1: - ligne = ligne.replace(u' )',u')') + while ligne.find('( ') > -1: + ligne = ligne.replace('( ','(') + while ligne.find(' )') > -1: + ligne = ligne.replace(' )',')') return ligne, previous_ligne, False ######################### @@ -322,7 +322,7 @@ def use_spaces_instead_of_tab(ligne, previous_ligne = None, warning=None): ### readability/braces ### def no_semicolon_after_brace(ligne, previous_ligne = None, warning=None): - return ligne.replace(u'};',u'}'), previous_ligne, False + return ligne.replace('};','}'), previous_ligne, False def position_of_else(ligne, previous_ligne=None, warning=None): '''Remonte une ligne du type } else {''' @@ -347,21 +347,21 @@ def position_of_opening_brace(ligne, previous_ligne=None, warning=None): m = re.match("(\s*){(.*)", ligne) # On ne fait rien si on trouve un commentaire sur la ligne précédente (ce sera une correction manuelle) - if previous_ligne.find(u'//') == -1: + if previous_ligne.find('//') == -1: previous_ligne = previous_ligne.rstrip("\n") + ' {' + m.group(2) + '\n' ligne = '' else: - print "The previous line contains a comment, fixing has to be manual." + print("The previous line contains a comment, fixing has to be manual.") return ligne, previous_ligne, False def missing_space_before_opening_brace(ligne, previous_ligne = None, warning=None): m = re.match("(.+)(\S){(.*)", ligne) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) - print 'group_2', m.group(2) - print 'group_3', m.group(3) + print('group_0', m.group(0)) + print('group_1', m.group(1)) + print('group_2', m.group(2)) + print('group_3', m.group(3)) ligne = m.group(1) + m.group(2) + ' {' + m.group(3) + '\n' return ligne, previous_ligne, False @@ -373,10 +373,10 @@ def missing_space_before_opening_brace(ligne, previous_ligne = None, warning=Non def missing_space_before_else(ligne, previous_ligne = None, warning=None): m = re.match("(.+)(\S)else(.*)", ligne) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) - print 'group_2', m.group(2) - print 'group_3', m.group(3) + print('group_0', m.group(0)) + print('group_1', m.group(1)) + print('group_2', m.group(2)) + print('group_3', m.group(3)) ligne = m.group(1) + m.group(2) + ' else' + m.group(3) + '\n' return ligne, previous_ligne, False @@ -385,15 +385,15 @@ def missing_space_before_else(ligne, previous_ligne = None, warning=None): def make_const_reference(ficpath, ligne, previous_ligne = None, warning=None): """ Adding keyword 'const' """ - print "ficpath = ", ficpath - print "ligne = ", ligne - print "warning = ", warning + print("ficpath = ", ficpath) + print("ligne = ", ligne) + print("warning = ", warning) m = re.match("(.+)Is this a non-const reference\? If so, make const or use a pointer: (.+) (.+)", warning) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) - print 'group_2', m.group(2) - print 'group_3', m.group(3) + print('group_0', m.group(0)) + print('group_1', m.group(1)) + print('group_2', m.group(2)) + print('group_3', m.group(3)) arg_to_modify = m.group(2) ligne = ligne.replace(arg_to_modify, "const "+arg_to_modify) @@ -404,13 +404,13 @@ def make_const_reference(ficpath, ligne, previous_ligne = None, warning=None): global H_FILE_MAKE_CONST_REFERENCE_MODIFIED H_FILE_MAKE_CONST_REFERENCE_MODIFIED = True else: - print "ERROR : The following pattern was not found : 'Is this a non-const reference? If so, make const or use a pointer:'" + print("ERROR : The following pattern was not found : 'Is this a non-const reference? If so, make const or use a pointer:'") return ligne, previous_ligne, False def make_const_reference_cpp_file(ficpath, arg_to_modify): if not os.path.isfile(ficpath): - print "WARNING : The file ", ficpath, " doesn't exist, manual fixing is required in methods of the file ", ficpath.replace('.cpp', '.h'), " in which arguments have been declared 'const'" + print("WARNING : The file ", ficpath, " doesn't exist, manual fixing is required in methods of the file ", ficpath.replace('.cpp', '.h'), " in which arguments have been declared 'const'") return fic = open(get_src_path(ficpath),'r') @@ -436,12 +436,12 @@ def make_const_reference_cpp_file(ficpath, arg_to_modify): ### runtime/int ### def replace_short_by_int16(ligne, previous_ligne = None, warning=None): - ligne = ligne.replace(u'short', u'int16_t') + ligne = ligne.replace('short', 'int16_t') return ligne, None, False def replace_long_by_int64(ligne, previous_ligne = None, warning=None): - ligne = ligne.replace(u'long', u'int64_t') + ligne = ligne.replace('long', 'int64_t') return ligne, None, False @@ -452,10 +452,10 @@ def replace_long_by_int64(ligne, previous_ligne = None, warning=None): def make_constructor_explicit(ligne, previous_ligne = None, warning=None): m = re.match("(\s*)(.+)", ligne) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) - print 'group_2', m.group(2) - ligne = ligne.replace(m.group(2), u'explicit '+m.group(2)) + print('group_0', m.group(0)) + print('group_1', m.group(1)) + print('group_2', m.group(2)) + ligne = ligne.replace(m.group(2), 'explicit '+m.group(2)) return ligne, None, False @@ -470,9 +470,9 @@ def cpp_file_should_include_h_file(ficpath, ficline, warning): m = re.match("(.+) should include its header file (.+) (.+)", warning) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) - print 'group_2', m.group(2) + print('group_0', m.group(0)) + print('group_1', m.group(1)) + print('group_2', m.group(2)) # Nouveau chemin du fichier .h new_h_file_path = m.group(2) @@ -483,13 +483,13 @@ def cpp_file_should_include_h_file(ficpath, ficline, warning): for ligne in liste: m2 = re.match("#include.*"+h_file_name+".*", ligne) if(m2): - print "FOUND : ", ligne + print("FOUND : ", ligne) new_liste.append("#include \""+new_h_file_path+"\"\n") else: - print "NOT FOUND : ", ligne + print("NOT FOUND : ", ligne) new_liste.append(ligne) else: - print "ERROR : Pattern not found : \"should include its header file\"" + print("ERROR : Pattern not found : \"should include its header file\"") newliste=fic_writelines(new_liste) fichier = open(get_src_path(ficpath), "w") @@ -515,7 +515,7 @@ def do_not_leave_blank_line_after_public_protected_private(ficpath, ficline, war flag = True if flag and ligne.isspace(): # Supprimer les lignes vides après public:, protected: et :private - print "Deleting empty line" + print("Deleting empty line") new_liste.append("") continue if not ligne.isspace() and not re.match(".*public.*:|.*protected.*:|.*private.*:", ligne): @@ -538,7 +538,7 @@ def do_not_leave_blank_line_at_the_start_of_code_block(ficpath, ficline, warning flag = True if flag and ligne.isspace(): # Supprimer les lignes vides après un début de bloc - print "Deleting empty line" + print("Deleting empty line") new_liste.append("") continue if not ligne.isspace() and not re.match(".*{", ligne): @@ -599,8 +599,8 @@ def add_include_what_you_use(ficpath, ficline, warning): m = re.match("\s*Add (.+) for (.+)", warning) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) + print('group_0', m.group(0)) + print('group_1', m.group(1)) include = m.group(1) # Recherche la ligne dans laquelle ajouter le #include @@ -617,7 +617,7 @@ def add_include_what_you_use(ficpath, ficline, warning): num_ligne_include = max(num_ligne_include_system, num_ligne_include_local) if num_ligne_include == 0: - print "WARNING : #include not found in file ", ficpath + print("WARNING : #include not found in file ", ficpath) return new_liste = [] @@ -634,75 +634,75 @@ def add_include_what_you_use(ficpath, ficline, warning): fichier = open(get_src_path(ficpath), "w") fichier.writelines(newliste) else: - print "ERROR : Pattern of include_what_you_use not found" + print("ERROR : Pattern of include_what_you_use not found") return ################################## HOOKS_DICT = { - extra_space_before_last_semicolon:{'pattern':u'whitespace/semicolon', 'pattern_AND':u'Extra space before last semicolon'}, - missing_space_after_semicolon:{'pattern':u'whitespace/semicolon', 'pattern_AND':u'Missing space after'}, - missing_space_around_operator_egal:{'pattern':u'whitespace/operators', 'pattern_AND':u'Missing spaces around = '}, - extra_space_for_operator_add:{'pattern':u'whitespace/operators', 'pattern_AND':u'Extra space for operator ++'}, - extra_space_for_operator_diff:{'pattern':u'whitespace/operators', 'pattern_AND':u'Extra space for operator !'}, - missing_space_around_operator_double_chevron:{'pattern':u'whitespace/operators', 'pattern_AND':u'Missing spaces around << '}, - missing_space_around_operator_simple_chevron:{'pattern':u'whitespace/operators', 'pattern_AND':u'Missing spaces around < '}, - missing_space_around_operator_diff_egal:{'pattern':u'whitespace/operators', 'pattern_AND':u'Missing spaces around !='}, - missing_space_around_operator_double_egal:{'pattern':u'whitespace/operators', 'pattern_AND':u'Missing spaces around =='}, - space_between_comments_and_code:{'pattern':u'whitespace/comments', 'pattern_AND':u'At least two spaces is best between code and comments'}, - space_between_comments_and_double_slash:{'pattern':u'whitespace/comments', 'pattern_AND':u'Should have a space between // and comment '}, - legal_copyright:{'pattern':u'legal/copyright'}, # Script à n'executer qu'une fois - ifndef_header:{'pattern':u'build/header_guard', 'pattern_AND':u'#ifndef header guard has wrong style, please use'}, + extra_space_before_last_semicolon:{'pattern':'whitespace/semicolon', 'pattern_AND':'Extra space before last semicolon'}, + missing_space_after_semicolon:{'pattern':'whitespace/semicolon', 'pattern_AND':'Missing space after'}, + missing_space_around_operator_egal:{'pattern':'whitespace/operators', 'pattern_AND':'Missing spaces around = '}, + extra_space_for_operator_add:{'pattern':'whitespace/operators', 'pattern_AND':'Extra space for operator ++'}, + extra_space_for_operator_diff:{'pattern':'whitespace/operators', 'pattern_AND':'Extra space for operator !'}, + missing_space_around_operator_double_chevron:{'pattern':'whitespace/operators', 'pattern_AND':'Missing spaces around << '}, + missing_space_around_operator_simple_chevron:{'pattern':'whitespace/operators', 'pattern_AND':'Missing spaces around < '}, + missing_space_around_operator_diff_egal:{'pattern':'whitespace/operators', 'pattern_AND':'Missing spaces around !='}, + missing_space_around_operator_double_egal:{'pattern':'whitespace/operators', 'pattern_AND':'Missing spaces around =='}, + space_between_comments_and_code:{'pattern':'whitespace/comments', 'pattern_AND':'At least two spaces is best between code and comments'}, + space_between_comments_and_double_slash:{'pattern':'whitespace/comments', 'pattern_AND':'Should have a space between // and comment '}, + legal_copyright:{'pattern':'legal/copyright'}, # Script à n'executer qu'une fois + ifndef_header:{'pattern':'build/header_guard', 'pattern_AND':'#ifndef header guard has wrong style, please use'}, # no_ifndef_header:{'pattern':u'build/header_guard', 'pattern_AND':u'No #ifndef header guard found'}, - endif_line:{'pattern':u'build/header_guard', 'pattern_AND':u'#endif line should be'}, - whitespace_end_of_line:{'pattern':u'whitespace/end_of_line', 'pattern_AND':u'Line ends in whitespace'}, - missing_space_after_comma:{'pattern':u'whitespace/comma'}, - namespace_should_be_terminated:{'pattern':u'readability/namespace', 'pattern_AND':u'Namespace should be terminated with'}, - anonymous_namespace_should_be_terminated:{'pattern':u'readability/namespace', 'pattern_AND':u'Anonymous namespace should be terminated with'}, - extra_space_after_opening_paranthesis:{'pattern':u'whitespace/parens', 'pattern_AND':u'Extra space after ('}, - extra_space_before_closing_paranthesis:{'pattern':u'whitespace/parens', 'pattern_AND':u'Extra space before )'}, - extra_space_before_opening_paranthesis_in_function_call:{'pattern':u'whitespace/parens', 'pattern':u'Extra space before ( in function call'}, - missing_space_before_opening_parenthesis_in_for:{'pattern':u'whitespace/parens', 'pattern_AND':u'Missing space before ( in for('}, - missing_space_before_opening_parenthesis_in_if:{'pattern':u'whitespace/parens', 'pattern_AND':u'Missing space before ( in if('}, - missing_space_before_opening_parenthesis_in_switch:{'pattern':u'whitespace/parens', 'pattern_AND':u'Missing space before ( in switch('}, - missing_space_before_opening_parenthesis_in_while:{'pattern':u'whitespace/parens', 'pattern_AND':u'Missing space before ( in while('}, - mismatching_spaces_inside_paranthesis:{'pattern':u'whitespace/parens', 'pattern_AND':u'Mismatching spaces inside ()'}, - missing_space_before_public_protected_private:{'pattern':u'whitespace/indent', 'pattern_AND':u' should be indented +1 space inside class'}, + endif_line:{'pattern':'build/header_guard', 'pattern_AND':'#endif line should be'}, + whitespace_end_of_line:{'pattern':'whitespace/end_of_line', 'pattern_AND':'Line ends in whitespace'}, + missing_space_after_comma:{'pattern':'whitespace/comma'}, + namespace_should_be_terminated:{'pattern':'readability/namespace', 'pattern_AND':'Namespace should be terminated with'}, + anonymous_namespace_should_be_terminated:{'pattern':'readability/namespace', 'pattern_AND':'Anonymous namespace should be terminated with'}, + extra_space_after_opening_paranthesis:{'pattern':'whitespace/parens', 'pattern_AND':'Extra space after ('}, + extra_space_before_closing_paranthesis:{'pattern':'whitespace/parens', 'pattern_AND':'Extra space before )'}, + extra_space_before_opening_paranthesis_in_function_call:{'pattern':'whitespace/parens', 'pattern':'Extra space before ( in function call'}, + missing_space_before_opening_parenthesis_in_for:{'pattern':'whitespace/parens', 'pattern_AND':'Missing space before ( in for('}, + missing_space_before_opening_parenthesis_in_if:{'pattern':'whitespace/parens', 'pattern_AND':'Missing space before ( in if('}, + missing_space_before_opening_parenthesis_in_switch:{'pattern':'whitespace/parens', 'pattern_AND':'Missing space before ( in switch('}, + missing_space_before_opening_parenthesis_in_while:{'pattern':'whitespace/parens', 'pattern_AND':'Missing space before ( in while('}, + mismatching_spaces_inside_paranthesis:{'pattern':'whitespace/parens', 'pattern_AND':'Mismatching spaces inside ()'}, + missing_space_before_public_protected_private:{'pattern':'whitespace/indent', 'pattern_AND':' should be indented +1 space inside class'}, - wrong_number_of_spaces_while_indenting:{'pattern':u'whitespace/indent', 'pattern_AND':u'Weird number of spaces at line-start'}, + wrong_number_of_spaces_while_indenting:{'pattern':'whitespace/indent', 'pattern_AND':'Weird number of spaces at line-start'}, - no_newline_at_the_end_of_file:{'pattern':u'whitespace/ending_newline'}, + no_newline_at_the_end_of_file:{'pattern':'whitespace/ending_newline'}, - order_of_storage_class_specifier:{'pattern':u'build/storage_class'}, + order_of_storage_class_specifier:{'pattern':'build/storage_class'}, - use_spaces_instead_of_tab:{'pattern':u'whitespace/tab'}, + use_spaces_instead_of_tab:{'pattern':'whitespace/tab'}, - no_semicolon_after_brace:{'pattern':u'readability/braces', 'pattern_AND':u'You don\'t need a ; after a }'}, + no_semicolon_after_brace:{'pattern':'readability/braces', 'pattern_AND':'You don\'t need a ; after a }'}, # position_of_else:{'pattern':u'readability/braces', 'pattern_AND':u'If an else has a brace on one side'}, # else_should_be_previous_line:{'pattern':u'whitespace/newline', 'pattern_AND':u'An else should appear on the same line as the preceding'}, - position_of_opening_brace:{'pattern':u'whitespace/braces', 'pattern_AND':u'{ should almost always be at the end of the previous line'}, - missing_space_before_opening_brace:{'pattern':u'whitespace/braces', 'pattern_AND':u'Missing space before {'}, - missing_space_before_else:{'pattern':u'whitespace/braces', 'pattern_AND':u'Missing space before else'}, + position_of_opening_brace:{'pattern':'whitespace/braces', 'pattern_AND':'{ should almost always be at the end of the previous line'}, + missing_space_before_opening_brace:{'pattern':'whitespace/braces', 'pattern_AND':'Missing space before {'}, + missing_space_before_else:{'pattern':'whitespace/braces', 'pattern_AND':'Missing space before else'}, - make_const_reference:{'pattern':u'runtime/references', 'pattern_AND':u'Is this a non-const reference? If so, make const or use a pointer'}, + make_const_reference:{'pattern':'runtime/references', 'pattern_AND':'Is this a non-const reference? If so, make const or use a pointer'}, - make_constructor_explicit:{'pattern':u'runtime/explicit'}, + make_constructor_explicit:{'pattern':'runtime/explicit'}, - cpp_file_should_include_h_file:{'pattern':u'build/include', 'pattern_AND':u'should include its header file'}, - _h_file_already_included:{'pattern':u'build/include', 'pattern_AND':u'already included at'}, + cpp_file_should_include_h_file:{'pattern':'build/include', 'pattern_AND':'should include its header file'}, + _h_file_already_included:{'pattern':'build/include', 'pattern_AND':'already included at'}, - replace_short_by_int16:{'pattern':u'runtime/int', 'pattern_AND':u'Use int16/int64/etc, rather than the C type short'}, - replace_long_by_int64:{'pattern':u'runtime/int', 'pattern_AND':u'Use int16/int64/etc, rather than the C type long'}, + replace_short_by_int16:{'pattern':'runtime/int', 'pattern_AND':'Use int16/int64/etc, rather than the C type short'}, + replace_long_by_int64:{'pattern':'runtime/int', 'pattern_AND':'Use int16/int64/etc, rather than the C type long'}, - do_not_leave_blank_line_after_public_protected_private:{'pattern':u'whitespace/blank_line', 'pattern_AND':u'Do not leave a blank line after'}, - do_not_leave_blank_line_at_the_start_of_code_block:{'pattern':u'whitespace/blank_line', 'pattern_AND':u'Redundant blank line at the start of a code block should be deleted'}, - do_not_leave_blank_line_at_the_end_of_code_block:{'pattern':u'whitespace/blank_line', 'pattern_AND':u'Redundant blank line at the end of a code block should be deleted'}, - add_blank_line_before_public:{'pattern':u'whitespace/blank_line', 'pattern_AND':u'"public:" should be preceded by a blank line'}, - add_blank_line_before_protected:{'pattern':u'whitespace/blank_line', 'pattern_AND':u'"protected:" should be preceded by a blank line'}, - add_blank_line_before_private:{'pattern':u'whitespace/blank_line', 'pattern_AND':u'"private:" should be preceded by a blank line'}, + do_not_leave_blank_line_after_public_protected_private:{'pattern':'whitespace/blank_line', 'pattern_AND':'Do not leave a blank line after'}, + do_not_leave_blank_line_at_the_start_of_code_block:{'pattern':'whitespace/blank_line', 'pattern_AND':'Redundant blank line at the start of a code block should be deleted'}, + do_not_leave_blank_line_at_the_end_of_code_block:{'pattern':'whitespace/blank_line', 'pattern_AND':'Redundant blank line at the end of a code block should be deleted'}, + add_blank_line_before_public:{'pattern':'whitespace/blank_line', 'pattern_AND':'"public:" should be preceded by a blank line'}, + add_blank_line_before_protected:{'pattern':'whitespace/blank_line', 'pattern_AND':'"protected:" should be preceded by a blank line'}, + add_blank_line_before_private:{'pattern':'whitespace/blank_line', 'pattern_AND':'"private:" should be preceded by a blank line'}, - add_include_what_you_use:{'pattern':u'build/include_what_you_use'}, + add_include_what_you_use:{'pattern':'build/include_what_you_use'}, } @@ -716,14 +716,14 @@ def replace_line_no(path, nol, oldline, newline): Remplace, la ligne No nol du fichier path (relatif à SRCROOTDIR) par la chaîne newline (un unicode) oldline sert uniquement pour vérifier que tout est ok """ - print "replace_line_no : ", oldline, " by ", newline + print("replace_line_no : ", oldline, " by ", newline) # récupérer le contenu du fichier fic = open(get_src_path(path), "r") liste = fic.readlines() fic.close() # test de corruption if liste[nol-1].decode(ENCODING) != oldline : - raise Exception(u"Le fichier source %s semble être corrompu" %path) + raise Exception("Le fichier source %s semble être corrompu" %path) # remplacement de la ligne liste[nol-1] = newline.encode(ENCODING) # recréation du fichier corrigé @@ -740,8 +740,8 @@ def replace_fic_copyright(ficpath, warning=None): liste=fic_readlines(fic) fic.close() new_liste = [] - if liste[0].find(u'/ Copyright (C) 2014-20xx CEA/DEN, EDF R&D\n\n')== -1: - newliste=[u'// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\n\n']+liste + if liste[0].find('/ Copyright (C) 2014-20xx CEA/DEN, EDF R&D\n\n')== -1: + newliste=['// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\n\n']+liste newliste=fic_writelines(newliste) fic = open(get_src_path(ficpath), "w") fic.writelines(newliste) @@ -762,9 +762,9 @@ def replace_fic_ifndef(ficpath, ficline, warning, mode): m = re.match("(.*)ifndef header guard has wrong style, please use: (.+) (.+)", warning) if(m): - print 'group_0', m.group(0) - print 'group_1', m.group(1) - print 'group_2', m.group(2) + print('group_0', m.group(0)) + print('group_1', m.group(1)) + print('group_2', m.group(2)) # Header à changer header_guard=m.group(2) @@ -775,24 +775,24 @@ def replace_fic_ifndef(ficpath, ficline, warning, mode): for ligne in liste: i += 1 if i == ficline: - if ligne.find(u'#ifndef') >= 0: + if ligne.find('#ifndef') >= 0: new_liste.append("#ifndef "+header_guard+"\n") trouve = True else: - print "ERROR : Pattern #ifndef not found in line ", ficline + print("ERROR : Pattern #ifndef not found in line ", ficline) return else: if trouve == True: - if ligne.find(u'#define') >= 0: + if ligne.find('#define') >= 0: new_liste.append("#define "+header_guard+"\n") trouve = False else: - print "WARNING : Pattern #define not found in the line following the pattern #ifndef, we abandon." + print("WARNING : Pattern #define not found in the line following the pattern #ifndef, we abandon.") return else: new_liste.append(ligne) else: - print "ERROR : Pattern not found : \"#ifndef header guard has wrong style, please use\"" + print("ERROR : Pattern not found : \"#ifndef header guard has wrong style, please use\"") newliste=fic_writelines(new_liste) fichier = open(get_src_path(ficpath), "w") @@ -848,33 +848,33 @@ def main_routine(cpplint_output_file): previous_oldline = get_line_no(ficpath, ficline-1) else: previous_oldline = None - print "===\nNew warning:" - print "\tFile = "+ficpath - print "\tlast_ficpath_with_modified_nb_lines = "+last_ficpath_with_modified_nb_lines - print "\tNo ligne =" , ficline + print("===\nNew warning:") + print("\tFile = "+ficpath) + print("\tlast_ficpath_with_modified_nb_lines = "+last_ficpath_with_modified_nb_lines) + print("\tNo ligne =" , ficline) if VERBOSE_FLAG == "True": - print "\tWarning ='"+warning+"'" - print "\tOld text of current line = '"+oldline+"'" + print("\tWarning ='"+warning+"'") + print("\tOld text of current line = '"+oldline+"'") if previous_oldline: - print "\tOld text of previous line = '"+previous_oldline+"'" + print("\tOld text of previous line = '"+previous_oldline+"'") if ficpath == last_ficpath_with_modified_nb_lines: - print "File ", ficpath, "already modified. Waiting next cpplint run to process it." + print("File ", ficpath, "already modified. Waiting next cpplint run to process it.") continue hook = get_hook(warning, ficpath) - print "hook = ", hook + print("hook = ", hook) if hook is None: - print u"No hook found" + print("No hook found") continue if VERBOSE_FLAG == "True": - print "\t=> Processing with hook", hook + print("\t=> Processing with hook", hook) if hook in HOOKS_DELETING_OR_ADDING_LINES: last_ficpath_with_modified_nb_lines = ficpath if hook in HOOKS_PARSING_THE_WHOLE_FILE: hook(ficpath, ficline, warning) - print "Done" + print("Done") continue # Cas particulier pour le hook make_const_reference : il faut faire un traitement sur le fichier .cpp associé au fichier .h concerné par le hook @@ -890,31 +890,31 @@ def main_routine(cpplint_output_file): newline, previous_newline, huchk = hook(oldline, previous_oldline, warning) if VERBOSE_FLAG == "True": - print "\tNew text = '"+newline+"'" + print("\tNew text = '"+newline+"'") if huchk: if previous_newline: - print "Replace line : \n'%s'\n with line \n'%s'\n O/N ? :"%(previous_oldline, previous_newline) - reponse = raw_input() + print("Replace line : \n'%s'\n with line \n'%s'\n O/N ? :"%(previous_oldline, previous_newline)) + reponse = input() if reponse in ['O', 'o']: replace_line_no(ficpath, ficline-1, previous_oldline, previous_newline) - print "Replacement done." + print("Replacement done.") else : - print "Replacement aborted." + print("Replacement aborted.") - print "Replace line : \n'%s'\n with line \n'%s'\n O/N ? :"%(oldline, newline) - reponse = raw_input() + print("Replace line : \n'%s'\n with line \n'%s'\n O/N ? :"%(oldline, newline)) + reponse = input() if reponse in ['O', 'o']: replace_line_no(ficpath, ficline, oldline, newline) - print "Replacement done." + print("Replacement done.") else : - print "Replacement aborted." + print("Replacement aborted.") else : if previous_newline: replace_line_no(ficpath, ficline-1, previous_oldline, previous_newline) replace_line_no(ficpath, ficline, oldline, newline) - print "Done" + print("Done") logfile.close() if __name__ == '__main__': diff --git a/salome_pid.py b/salome_pid.py old mode 100755 new mode 100644 index 07ebf9f06..ca879e5a8 --- a/salome_pid.py +++ b/salome_pid.py @@ -35,4 +35,4 @@ for list_item in process_ids: if process in name_list: pid = _pid -print pid +print(pid) diff --git a/src/CollectionAPI/CollectionAPI.i b/src/CollectionAPI/CollectionAPI.i index 821bcd33c..26d54394e 100644 --- a/src/CollectionAPI/CollectionAPI.i +++ b/src/CollectionAPI/CollectionAPI.i @@ -39,7 +39,7 @@ #include "ModelHighAPI_swig.h" // fix for SWIG v2.0.4 - #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj)) + #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) %} %include "doxyhelp.i" diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 452fc4ca3..4471234b4 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -211,7 +211,7 @@ void Config_ModuleReader::loadScript(const std::string& theFileName, bool theSen PyErr_Fetch(&ptype, &pvalue, &ptraceback); PyErr_NormalizeException(&ptype, &pvalue, &ptraceback); pstr = PyObject_Str(pvalue); - std::string aPyError = std::string(PyString_AsString(pstr)); + std::string aPyError = std::string(PyUnicode_AsUTF8(pstr)); if (!aPyError.empty()) { anErrorMsg += ":\n" + aPyError; } diff --git a/src/ConnectorAPI/Test/TestExportToGEOM.py b/src/ConnectorAPI/Test/TestExportToGEOM.py index 0403f1e9e..fd363f3c7 100644 --- a/src/ConnectorAPI/Test/TestExportToGEOM.py +++ b/src/ConnectorAPI/Test/TestExportToGEOM.py @@ -26,8 +26,8 @@ from salome.geom import geomBuilder import os import tempfile -salome.salome_init(0,1) -geompy = geomBuilder.New(salome.myStudy) +salome.salome_init(1) +geompy = geomBuilder.New() ## Get the last object published in the GEOM section of the object browser def getLastGEOMShape(): @@ -124,10 +124,10 @@ def testSeveralExportsToGEOM(): dumpShaper(dumpFileShaper) # Load SHAPER dump - execfile(dumpFileShaper) + exec(compile(open(dumpFileShaper).read(), dumpFileShaper, 'exec')) # Load GEOM dump - execfile(dumpFileGeom) + exec(compile(open(dumpFileGeom).read(), dumpFileGeom, 'exec')) # Clean files files = [dumpFileGeom, dumpFileShaper] @@ -139,4 +139,4 @@ def testSeveralExportsToGEOM(): if __name__ == '__main__': - testSeveralExportsToGEOM() \ No newline at end of file + testSeveralExportsToGEOM() diff --git a/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py b/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py index 49b09bc6f..130fb7090 100644 --- a/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py +++ b/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py @@ -31,7 +31,7 @@ theStudy = salome.myStudy from salome.shaper import model from salome.geom import geomBuilder -geompy = geomBuilder.New(salome.myStudy) +geompy = geomBuilder.New() ## Get the last object published in the GEOM section of the object browser def getLastGEOMShape(): @@ -185,10 +185,10 @@ def checkDump(): dumpShaper(dumpFileShaper) # Load SHAPER dump - execfile(dumpFileShaper) + exec(compile(open(dumpFileShaper).read(), dumpFileShaper, 'exec')) # Load GEOM dump - execfile(dumpFileGeom) + exec(compile(open(dumpFileGeom).read(), dumpFileGeom, 'exec')) # Clean files files = [dumpFileGeom, dumpFileShaper] diff --git a/src/ConnectorPlugin/ConnectorPlugin.py b/src/ConnectorPlugin/ConnectorPlugin.py index e91ca3152..78c1c65eb 100644 --- a/src/ConnectorPlugin/ConnectorPlugin.py +++ b/src/ConnectorPlugin/ConnectorPlugin.py @@ -39,7 +39,7 @@ class ConnectorPlugin(ModelAPI.ModelAPI_Plugin): if theFeatureID == ExportFeature.ID(): return ExportFeature().__disown__() else: - print "ConnectorPlugin: No such feature %s" % theFeatureID + print("ConnectorPlugin: No such feature %s" % theFeatureID) ## The plugin created on module importing (from c++) plugin = ConnectorPlugin() diff --git a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py index b529eac73..1fccfcef6 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py @@ -104,8 +104,8 @@ class ExportFeature(ModelAPI.ModelAPI_Feature): ## List of objects created in the old geom for later use self.geomObjects = [] ## geomBuilder tool - salome.salome_init(0,1) - self.geompy = geomBuilder.New(salome.myStudy) + salome.salome_init(1) + self.geompy = geomBuilder.New() self.exportViaXAO() diff --git a/src/ExchangePlugin/Test/TestExport.py b/src/ExchangePlugin/Test/TestExport.py index 696a2b0c2..c0a007f3c 100644 --- a/src/ExchangePlugin/Test/TestExport.py +++ b/src/ExchangePlugin/Test/TestExport.py @@ -66,7 +66,7 @@ def testExport(theType, theFormat, theFile, theVolume, theDelta): aSession.startOperation("Export part") anExportFeature = aPart.addFeature("Export") anExportFeature.string("file_format").setValue(theFormat) - print "theFile=",theFile + print("theFile=",theFile) anExportFeature.string("file_path").setValue(theFile) anExportFeature.string("ExportType").setValue("Regular") aSelectionListAttr = anExportFeature.selectionList("selection_list") diff --git a/src/ExchangePlugin/Test/TestImport.py b/src/ExchangePlugin/Test/TestImport.py index 8f95e8a23..201566987 100644 --- a/src/ExchangePlugin/Test/TestImport.py +++ b/src/ExchangePlugin/Test/TestImport.py @@ -104,7 +104,7 @@ def testImportXAO(): assert aSelectionList.selectionType() == "face" assert aSelectionList.size() == 2 assert aSelectionList.value(0).namingName("") == "mygeom_1/Shape1" - print aSelectionList.value(1).namingName("") + print(aSelectionList.value(1).namingName("")) assert aSelectionList.value(1).namingName("") == "mygeom_1/Shape2" aFeature3 = aCompositeFeature.subFeature(2, False) diff --git a/src/FeaturesPlugin/Test/TestMultiBoolean.py b/src/FeaturesPlugin/Test/TestMultiBoolean.py index d332d786f..c65d2c4bc 100644 --- a/src/FeaturesPlugin/Test/TestMultiBoolean.py +++ b/src/FeaturesPlugin/Test/TestMultiBoolean.py @@ -67,8 +67,8 @@ radius = 95. / N / 2. aSession.startOperation() aSketchFeatures = [] -for i in xrange(0, N): - for j in xrange(0, N): +for i in range(0, N): + for j in range(0, N): # Create circle aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) @@ -95,7 +95,7 @@ aSession.finishOperation() aSession.startOperation() anExtrusions = [] -for i in xrange(0, N * N): +for i in range(0, N * N): aSketchResult = aSketchFeatures[i].firstResult() aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt() @@ -196,7 +196,7 @@ aSession.startOperation() aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(aCurrentResult, aCurrentResult.shape()) -for i in xrange(0, N * N): +for i in range(0, N * N): anExtrusionResult = modelAPI_ResultBody(anExtrusions[i].firstResult()) aBooleanFt.selectionList("tool_objects").append(anExtrusionResult, anExtrusionResult.shape()) aBooleanFt.execute() diff --git a/src/FeaturesPlugin/Test/TestSerialBoolean.py b/src/FeaturesPlugin/Test/TestSerialBoolean.py index 08f4887d0..ddbde4793 100644 --- a/src/FeaturesPlugin/Test/TestSerialBoolean.py +++ b/src/FeaturesPlugin/Test/TestSerialBoolean.py @@ -67,8 +67,8 @@ radius = 95. / N / 2. aSession.startOperation() aSketchFeatures = [] -for i in xrange(0, N): - for j in xrange(0, N): +for i in range(0, N): + for j in range(0, N): # Create circle aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) @@ -95,7 +95,7 @@ aSession.finishOperation() aSession.startOperation() anExtrusions = [] -for i in xrange(0, N * N): +for i in range(0, N * N): aSketchResult = aSketchFeatures[i].firstResult() aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt() @@ -195,7 +195,7 @@ aSession.finishOperation() aCurrentResult = modelAPI_ResultBody(aBox.firstResult()) aSession.startOperation() aFactory = ModelAPI_Session.get().validators() -for i in xrange(0, N * N): +for i in range(0, N * N): anExtrusionResult = modelAPI_ResultBody(anExtrusions[i].firstResult()) aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(aCurrentResult, aCurrentResult.shape()) diff --git a/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp b/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp index de159cffc..b7d591b29 100644 --- a/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp +++ b/src/InitializationPlugin/InitializationPlugin_PyInterp.cpp @@ -68,8 +68,8 @@ InitializationPlugin_PyInterp::positions(const std::string& theExpression, std::string anExpression = adjustExpression(theExpression); // extend aContext with variables - PyDict_SetItemString(aContext, "expression", PyString_FromString(anExpression.c_str())); - PyDict_SetItemString(aContext, "name", PyString_FromString(theName.c_str())); + PyDict_SetItemString(aContext, "expression", PyUnicode_FromString(anExpression.c_str())); + PyDict_SetItemString(aContext, "name", PyUnicode_FromString(theName.c_str())); PyDict_SetItemString(aContext, "positions", Py_BuildValue("[]")); // run the search code @@ -84,8 +84,8 @@ InitializationPlugin_PyInterp::positions(const std::string& theExpression, PyObject* aColOffset = PyTuple_GetItem(aPosition, 1); aResult.push_back( - std::pair((int)PyInt_AsLong(aLineNo), - (int)PyInt_AsLong(aColOffset))); + std::pair((int)PyLong_AsLong(aLineNo), + (int)PyLong_AsLong(aColOffset))); } // TODO(spo): after this refCount of the variable is not 0. Is there memory leak? @@ -117,17 +117,18 @@ std::list InitializationPlugin_PyInterp::compile(const std::string& } PyCodeObject* aCodeObj = (PyCodeObject*) aCodePyObj; - std::string aCodeName(PyString_AsString(aCodeObj->co_code)); + std::string aCodeName(PyBytes_AsString(aCodeObj->co_code)); // co_names should be tuple, but can be changed in modern versions of python (>2.7.3) - if(!PyTuple_Check(aCodeObj->co_names)) + if(!PyTuple_Check(aCodeObj->co_names)) { return aResult; + } size_t params_size = PyTuple_Size(aCodeObj->co_names); if (params_size > 0) { for (size_t i = 0; i < params_size; i++) { PyObject* aParamObj = PyTuple_GetItem(aCodeObj->co_names, i); PyObject* aParamObjStr = PyObject_Str(aParamObj); - std::string aParamName(PyString_AsString(aParamObjStr)); + std::string aParamName(PyUnicode_AsUTF8(aParamObjStr)); aResult.push_back(aParamName); Py_XDECREF(aParamObjStr); } @@ -171,7 +172,7 @@ double InitializationPlugin_PyInterp::evaluate(const std::string& theExpression, return 0.; } - PyObject* anEvalResult = PyEval_EvalCode(anExprCode, _global_context, _local_context); + PyObject* anEvalResult = PyEval_EvalCode((PyObject *)anExprCode, _global_context, _local_context); if(!anEvalResult) { theError = errorMessage(); Py_XDECREF(anExprCode); @@ -180,7 +181,7 @@ double InitializationPlugin_PyInterp::evaluate(const std::string& theExpression, } PyObject* anEvalStrObj = PyObject_Str(anEvalResult); - std::string anEvalStr(PyString_AsString(anEvalStrObj)); + std::string anEvalStr(PyUnicode_AsUTF8(anEvalStrObj)); Py_XDECREF(anExprCode); Py_XDECREF(anEvalResult); Py_XDECREF(anEvalStrObj); @@ -207,7 +208,7 @@ std::string InitializationPlugin_PyInterp::errorMessage() PyErr_Fetch(&ptype, &pvalue, &ptraceback); PyErr_NormalizeException(&ptype, &pvalue, &ptraceback); pstr = PyObject_Str(pvalue); - aPyError = std::string(PyString_AsString(pstr)); + aPyError = std::string(PyUnicode_AsUTF8(pstr)); Py_XDECREF(pstr); Py_XDECREF(ptype); Py_XDECREF(pvalue); diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 61403edf6..e4b224280 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -93,22 +93,22 @@ %shared_ptr(ModelAPI_ResultCompSolid) %typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value { - $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input) || PyBool_Check($input)) ? 1 : 0; + $1 = (PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input) || PyBool_Check($input)) ? 1 : 0; } // Tables Value reading as int, double, boolean or string %typemap(in) const ModelAPI_AttributeTables::Value { - if (PyInt_Check($input)) { - $1.myInt = int(PyInt_AsLong($input)); - $1.myDouble = double(PyInt_AsLong($input)); - $1.myBool = PyInt_AsLong($input) != 0; + if (PyLong_Check($input)) { + $1.myInt = int(PyLong_AsLong($input)); + $1.myDouble = double(PyLong_AsLong($input)); + $1.myBool = PyLong_AsLong($input) != 0; } else if (PyFloat_Check($input)) { $1.myInt = int(PyFloat_AsDouble($input)); $1.myDouble = PyFloat_AsDouble($input); } else if (PyBool_Check($input)) { $1.myBool = $input == Py_True; - } else if (PyString_Check($input)) { - $1.myStr = PyString_AsString($input); + } else if (PyUnicode_Check($input)) { + $1.myStr = PyUnicode_AsUTF8($input); } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool."); diff --git a/src/ModelAPI/Test/TestCustomName_CutGroup.py b/src/ModelAPI/Test/TestCustomName_CutGroup.py index 211275e52..ca2ac6c92 100644 --- a/src/ModelAPI/Test/TestCustomName_CutGroup.py +++ b/src/ModelAPI/Test/TestCustomName_CutGroup.py @@ -94,7 +94,7 @@ model.do() Extrusions = [Extrusion_1, Extrusion_2, Extrusion_3] BooleanResults = Boolean_1.results() -for i in xrange(len(BooleanResults)): +for i in range(len(BooleanResults)): assert(BooleanResults[i].name() == Extrusions[i].result().name()), "Name of result {} of Boolean CUT '{}' != '{}'".format(i, BooleanResults[i].name(), Extrusions[i].result().name()) BooleanName = Boolean_1.name() + "_" + str(i + 1) for sub in range(0, BooleanResults[i].numberOfSubs()): diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 0b49cf05c..2d4b6a8c8 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -32,7 +32,7 @@ #include "ModelHighAPI_swig.h" // fix for SWIG v2.0.4 - #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj)) + #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) %} %include "doxyhelp.i" @@ -62,11 +62,11 @@ // typemaps %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) { - if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) { + if (PyFloat_Check($input) || PyLong_Check($input)) { temp = ModelHighAPI_Double(PyFloat_AsDouble($input)); $1 = &temp; - } else if (PyString_Check($input)) { - temp = ModelHighAPI_Double(PyString_AsString($input)); + } else if (PyUnicode_Check($input)) { + temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input)); $1 = &temp; } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { @@ -75,15 +75,15 @@ } } %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & { - $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0; + $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0; } %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) { - if (PyInt_Check($input)) { - temp = ModelHighAPI_Integer(static_cast(PyInt_AsLong($input))); + if (PyLong_Check($input)) { + temp = ModelHighAPI_Integer(static_cast(PyLong_AsLong($input))); $1 = &temp; - } else if (PyString_Check($input)) { - temp = ModelHighAPI_Integer(PyString_AsString($input)); + } else if (PyUnicode_Check($input)) { + temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input)); $1 = &temp; } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { @@ -92,7 +92,7 @@ } } %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & { - $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0; + $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0; } %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) { diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index b7b5f1dab..70995d6a7 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -435,7 +435,7 @@ bool checkPythonDump() return false; // something is wrong during dump } - // map from document name to feature name to feature data + // map from document name to feature name to feature data std::map > aStore; std::string anError = storeFeatures( aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, false); @@ -444,14 +444,16 @@ bool checkPythonDump() anErrorMsg.send(); return false; } + // close all before importation of the script aSession->closeAll(); + // execute the dumped PyGILState_STATE gstate = PyGILState_Ensure(); /* acquire python thread */ static char aDumpName[] = "./check_dump.py"; static char aReadMode[] = "r"; - PyObject* PyFileObject = PyFile_FromString(aDumpName, aReadMode); - PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), aDumpName, 1); + FILE* aFile = _Py_fopen(aDumpName, aReadMode); + PyRun_SimpleFileEx(aFile, aDumpName, 1); PyGILState_Release(gstate); /* release python thread */ // compare with the stored data diff --git a/src/ParametersPlugin/Test/TestParameterCreation.py b/src/ParametersPlugin/Test/TestParameterCreation.py index 0c98f7a80..3e5b38c1f 100644 --- a/src/ParametersPlugin/Test/TestParameterCreation.py +++ b/src/ParametersPlugin/Test/TestParameterCreation.py @@ -89,7 +89,7 @@ for name, expr in zip(ltNames, ltExpressions): assert(aResultAttr.data()) assert(aResultAttr.data().real("Value")) aResultValue = aResultAttr.data().real("Value").value() - print aResultValue, " == ", float(expr) + print(aResultValue, " == ", float(expr)) assert(aResultValue == float(expr)) # Check referencing between parameters diff --git a/src/PythonAPI/doc/source/conf.py b/src/PythonAPI/doc/source/conf.py index 2acabd660..3f3490f55 100644 --- a/src/PythonAPI/doc/source/conf.py +++ b/src/PythonAPI/doc/source/conf.py @@ -74,8 +74,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'Shaper python API' -copyright = u'2014-20xx CEA/DEN, EDF R&D' +project = 'Shaper python API' +copyright = '2014-20xx CEA/DEN, EDF R&D' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -227,8 +227,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'ShaperpythonAPI.tex', u'Shaper python API Documentation', - u'Renaud Nédélec', 'manual'), + ('index', 'ShaperpythonAPI.tex', 'Shaper python API Documentation', + 'Renaud Nédélec', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -257,8 +257,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'shaperpythonapi', u'Shaper python API Documentation', - [u'Renaud Nédélec'], 1) + ('index', 'shaperpythonapi', 'Shaper python API Documentation', + ['Renaud Nédélec'], 1) ] # If true, show URL addresses after external links. @@ -271,8 +271,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'ShaperpythonAPI', u'Shaper python API Documentation', - u'Renaud Nédélec', 'ShaperpythonAPI', 'One line description of project.', + ('index', 'ShaperpythonAPI', 'Shaper python API Documentation', + 'Renaud Nédélec', 'ShaperpythonAPI', 'One line description of project.', 'Miscellaneous'), ] diff --git a/src/PythonAPI/model/__init__.py b/src/PythonAPI/model/__init__.py index 29364c692..d4d142f13 100644 --- a/src/PythonAPI/model/__init__.py +++ b/src/PythonAPI/model/__init__.py @@ -8,20 +8,20 @@ All features are available via model.add*() functions. Exceptions are: # General purpose functions and abstract root classes -from services import * -from roots import * +from .services import * +from .roots import * # Built-in features -from build import * -from sketcher import * -from connection import * -from construction import * -from exchange import * -from features import * -from collection import * -from parameter import * -from partset import * -from primitives import * -from gdml import * -from tests import * +from .build import * +from .sketcher import * +from .connection import * +from .construction import * +from .exchange import * +from .features import * +from .collection import * +from .parameter import * +from .partset import * +from .primitives import * +from .gdml import * +from .tests import * diff --git a/src/PythonAPI/model/dump/__init__.py b/src/PythonAPI/model/dump/__init__.py index 78a1de4e5..2bb02cfdc 100644 --- a/src/PythonAPI/model/dump/__init__.py +++ b/src/PythonAPI/model/dump/__init__.py @@ -1,4 +1,4 @@ """Package for dumping purposes. """ -from DumpAssistant import * +from .DumpAssistant import * diff --git a/src/PythonAPI/model/sketcher/__init__.py b/src/PythonAPI/model/sketcher/__init__.py index 8c0319a1e..2d5622aee 100644 --- a/src/PythonAPI/model/sketcher/__init__.py +++ b/src/PythonAPI/model/sketcher/__init__.py @@ -2,5 +2,5 @@ """ from SketchAPI import addSketch -from tools import * -from tests import * +from .tools import * +from .tests import * diff --git a/src/PythonAPI/model/sketcher/tools.py b/src/PythonAPI/model/sketcher/tools.py index f3dcdb37a..0a2c4f6d4 100644 --- a/src/PythonAPI/model/sketcher/tools.py +++ b/src/PythonAPI/model/sketcher/tools.py @@ -68,7 +68,7 @@ def dof(sketch): aSketch = sketch if issubclass(type(aSketch), ModelHighAPI.ModelHighAPI_Interface): aSketch = sketch.feature() - return int(filter(str.isdigit, aSketch.string("SolverDOF").value())) + return int(''.join(filter(str.isdigit, aSketch.string("SolverDOF").value()))) def distancePointPoint(thePoint1, thePoint2): aPnt1 = toList(thePoint1) diff --git a/src/PythonAPI/model/tests/__init__.py b/src/PythonAPI/model/tests/__init__.py index f853b103f..b8f079e04 100644 --- a/src/PythonAPI/model/tests/__init__.py +++ b/src/PythonAPI/model/tests/__init__.py @@ -1 +1 @@ -from tests import * \ No newline at end of file +from .tests import * \ No newline at end of file diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index 7cd30c2ca..39c468a29 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -42,14 +42,14 @@ def generateTests(theFeature, theFeatureName, theTestsList = []): """ if "testNbResults" in theTestsList or len(theTestsList) == 0: aNbResults = len(theFeature.results()) - print "model.testNbResults({}, {})".format(theFeatureName, aNbResults) + print("model.testNbResults({}, {})".format(theFeatureName, aNbResults)) if "testNbSubResults" in theTestsList or len(theTestsList) == 0: aNbResults = len(theFeature.results()) aNbSubResults = [] for anIndex in range(0, aNbResults): aNbSubResults.append(theFeature.results()[anIndex].numberOfSubs()) - print "model.testNbSubResults({}, {})".format(theFeatureName, aNbSubResults) + print("model.testNbSubResults({}, {})".format(theFeatureName, aNbSubResults)) if "testNbSubShapes" in theTestsList or len(theTestsList) == 0: aNbResults = len(theFeature.results()) @@ -61,16 +61,16 @@ def generateTests(theFeature, theFeatureName, theTestsList = []): aShapeExplorer = GeomAPI_ShapeExplorer(aShape, aShapeType) while aShapeExplorer.more(): aNbResultSubShapes += 1 - aShapeExplorer.next(); + aShapeExplorer.next() aNbSubShapes.append(aNbResultSubShapes) - print "model.testNbSubShapes({}, {}, {})".format(theFeatureName, aShapeTypes[aShapeType], aNbSubShapes) + print("model.testNbSubShapes({}, {}, {})".format(theFeatureName, aShapeTypes[aShapeType], aNbSubShapes)) if "testResultsVolumes" in theTestsList or len(theTestsList) == 0: aNbResults = len(theFeature.results()) aResultsVolumes = [] for anIndex in range(0, aNbResults): aResultsVolumes.append(GeomAlgoAPI_ShapeTools_volume(theFeature.results()[anIndex].resultSubShapePair()[0].shape())) - print "model.testResultsVolumes({}, [{}])".format(theFeatureName, ", ".join("{:0.27f}".format(i) for i in aResultsVolumes)) + print("model.testResultsVolumes({}, [{}])".format(theFeatureName, ", ".join("{:0.27f}".format(i) for i in aResultsVolumes))) def testNbResults(theFeature, theExpectedNbResults): @@ -112,7 +112,7 @@ def testNbSubShapes(theFeature, theShapeType, theExpectedNbSubShapes): aShapeExplorer = GeomAPI_ShapeExplorer(aShape, theShapeType) while aShapeExplorer.more(): aNbResultSubShapes += 1 - aShapeExplorer.next(); + aShapeExplorer.next() assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes) diff --git a/src/PythonAddons/addons_Features.py b/src/PythonAddons/addons_Features.py index b5ebf59fa..3fcb67d12 100644 --- a/src/PythonAddons/addons_Features.py +++ b/src/PythonAddons/addons_Features.py @@ -50,7 +50,7 @@ class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin): aFeature = SketchPlugin_Rectangle().__disown__() else: - raise StandardError("No such feature %s" % theFeatureID) + raise Exception("No such feature %s" % theFeatureID) return aFeature diff --git a/src/SketchAPI/SketchAPI.i b/src/SketchAPI/SketchAPI.i index e443e5f23..0f76546eb 100644 --- a/src/SketchAPI/SketchAPI.i +++ b/src/SketchAPI/SketchAPI.i @@ -27,7 +27,7 @@ #include "ModelHighAPI_swig.h" // fix for SWIG v2.0.4 - #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj)) + #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) %} %include "doxyhelp.i" diff --git a/src/SketchPlugin/Test/Test1673.py b/src/SketchPlugin/Test/Test1673.py index 6eea668e5..af9cc1f11 100644 --- a/src/SketchPlugin/Test/Test1673.py +++ b/src/SketchPlugin/Test/Test1673.py @@ -248,7 +248,7 @@ SketchConstraintVertical_11.setName("SketchConstraintVertical_12") model.do() sketchTime = timer() - sketchTime -print "Sketch creation time: {0}".format(sketchTime) +print("Sketch creation time: {0}".format(sketchTime)) expectedTime = MOVE_BUILD_RATIO * sketchTime averageTime = 0 nbMoves = 0 @@ -289,7 +289,7 @@ for ang in range(0, 50): nbMoves += 1 aDeltaX = aEndPoint.x() - aCenter.x() aDeltaY = aEndPoint.y() - aCenter.y() -print "Movement average time: {0}".format(averageTime / nbMoves) +print("Movement average time: {0}".format(averageTime / nbMoves)) model.end() diff --git a/src/SketchPlugin/Test/Test1966.py b/src/SketchPlugin/Test/Test1966.py index a42983b7e..8da4ac2dc 100644 --- a/src/SketchPlugin/Test/Test1966.py +++ b/src/SketchPlugin/Test/Test1966.py @@ -288,7 +288,7 @@ SketchConstraintLength_8 = Sketch_1.setLength(SketchLine_37.result(), 0.088) model.do() sketchTime = timer() - sketchTime -print "Sketch creation time: {0}".format(sketchTime) +print("Sketch creation time: {0}".format(sketchTime)) expectedTime = MOVE_BUILD_RATIO * sketchTime averageTime = 0 nbMoves = 0 @@ -310,7 +310,7 @@ for deltaX, deltaY in deltas: assert math.fabs(aPoint.x() - X) < TOLERANCE and math.fabs(aPoint.y() - Y) < TOLERANCE, "({0}, {1}) != ({2}, {3})".format(aPoint.x(), aPoint.y(), X, Y) averageTime += movementTime nbMoves += 1 -print "Movement average time: {0}".format(averageTime / nbMoves) +print("Movement average time: {0}".format(averageTime / nbMoves)) #========================================================================= # Change value of SketchConstraintAngle_6 and check execution time. @@ -329,7 +329,7 @@ for ang in range(12, 30): assert math.fabs(curAngle - ang) < TOLERANCE, "angle {0} != {1} expected".format(curAngle, ang) averageTime += movementTime nbMoves += 1 -print "Changing angle average time: {0}".format(averageTime / nbMoves) +print("Changing angle average time: {0}".format(averageTime / nbMoves)) model.end() diff --git a/src/SketchPlugin/Test/Test1967.py b/src/SketchPlugin/Test/Test1967.py index ae9bfaf69..05c5a1b0b 100644 --- a/src/SketchPlugin/Test/Test1967.py +++ b/src/SketchPlugin/Test/Test1967.py @@ -267,7 +267,7 @@ SketchConstraintMiddle_3 = Sketch_1.setMiddlePoint(SketchLine_17.startPoint(), S model.do() sketchTime = timer() - sketchTime -print "Sketch creation time: {0}".format(sketchTime) +print("Sketch creation time: {0}".format(sketchTime)) expectedTime = MOVE_BUILD_RATIO * sketchTime averageTime = 0 nbMoves = 0 @@ -290,7 +290,7 @@ for deltaX, deltaY in deltas: averageTime += movementTime nbMoves += 1 -print "Movement average time: {0}".format(averageTime / nbMoves) +print("Movement average time: {0}".format(averageTime / nbMoves)) model.end() diff --git a/src/SketchPlugin/Test/TestConstraintFixed.py b/src/SketchPlugin/Test/TestConstraintFixed.py index db20680aa..ad3921f04 100644 --- a/src/SketchPlugin/Test/TestConstraintFixed.py +++ b/src/SketchPlugin/Test/TestConstraintFixed.py @@ -92,8 +92,8 @@ kLineCEnd = (aLineCEndPoint.x(), aLineCEndPoint.y()) #========================================================================= # Link triange lines with concidence #========================================================================= -concidenceLinks = zip([aLineBStartPoint, aLineCStartPoint, aLineAStartPoint], - [aLineAEndPoint, aLineBEndPoint, aLineCEndPoint]) +concidenceLinks = list(zip([aLineBStartPoint, aLineCStartPoint, aLineAStartPoint], + [aLineAEndPoint, aLineBEndPoint, aLineCEndPoint])) aSession.startOperation() for eachLink in concidenceLinks: aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence") diff --git a/src/SketchPlugin/Test/TestHighload.py b/src/SketchPlugin/Test/TestHighload.py index befac2e27..dc9c84bf7 100644 --- a/src/SketchPlugin/Test/TestHighload.py +++ b/src/SketchPlugin/Test/TestHighload.py @@ -44,7 +44,7 @@ def createNAngle(theSketch, theN, theRadius, theEdgeLength=0): # Create an N-Angle at (0,0) rad = 2. * math.pi / theN points = [] - for a in xrange(theN): + for a in range(theN): x = round(math.cos(rad * a), 10) * theRadius y = round(math.sin(rad * a), 10) * theRadius points.append((x, y)) @@ -126,8 +126,8 @@ aDOF = 0 deltaX = deltaY = 50. n = 5 aSession.startOperation() -for i in xrange(4): - for j in xrange(4): +for i in range(4): + for j in range(4): allNangleLines = createNAngle(aSketchFeature, n, 50) fixLineLength(aSketchFeature, allNangleLines) moveTo(allNangleLines, deltaX, deltaY) diff --git a/src/SketchPlugin/Test/TestMirror.py b/src/SketchPlugin/Test/TestMirror.py index c51f35a83..73d51f1e0 100644 --- a/src/SketchPlugin/Test/TestMirror.py +++ b/src/SketchPlugin/Test/TestMirror.py @@ -245,7 +245,7 @@ refAttrA.setAttr(anArcStartPoint) refAttrB.setAttr(aMirroredArcStartPoint) aConstraint.real("ConstraintValue").setValue(200.) aSession.finishOperation() -print "Sketch error : {}".format(aSketchErrorAttr.value()) +print("Sketch error : {}".format(aSketchErrorAttr.value())) assert len(aSketchErrorAttr.value()) != 0, "ERROR: Sketch has not been failed as expected" aSession.startOperation() aDocument.removeFeature(aConstraint) diff --git a/src/SketchPlugin/Test/TestSnowflake.py b/src/SketchPlugin/Test/TestSnowflake.py index c98b5a4da..ebdcd2b11 100644 --- a/src/SketchPlugin/Test/TestSnowflake.py +++ b/src/SketchPlugin/Test/TestSnowflake.py @@ -81,7 +81,7 @@ def initContour(theNumLines): prevPoint = (35, 0) result = [] deltaY = random.uniform(20, 25) - for i in xrange(1, theNumLines): + for i in range(1, theNumLines): rangeXMax = (prevPoint[1] + deltaY) * (30. / i if i % 2 != 0 else 2) newX = random.uniform(prevPoint[1] + deltaY, max(rangeXMax, prevPoint[1] + deltaY + 25.)) @@ -102,9 +102,9 @@ def makeLinesCoincident(theSketch, allLines): anEndPointValue = (anEndPoint.x(), anEndPoint.y()) allPoints[aStartPointValue].append(aStartPoint) allPoints[anEndPointValue].append(anEndPoint) - for keyPoint, valuePoints in allPoints.iteritems(): + for keyPoint, valuePoints in allPoints.items(): if len(valuePoints) != 2: - print "Strange point: ", keyPoint, "has in coincidence: ", len(valuePoints) + print("Strange point: ", keyPoint, "has in coincidence: ", len(valuePoints)) continue aConstraint = theSketch.addFeature("SketchConstraintCoincidence") aConstraint.refattr("ConstraintEntityA").setAttr(valuePoints[0]) diff --git a/test.API/SHAPER/GDML/TestAPI_ConeSegment.py b/test.API/SHAPER/GDML/TestAPI_ConeSegment.py index fde6fef28..6b6205fab 100644 --- a/test.API/SHAPER/GDML/TestAPI_ConeSegment.py +++ b/test.API/SHAPER/GDML/TestAPI_ConeSegment.py @@ -32,40 +32,40 @@ CS7 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,360.) try : CS8 = shaperpy.makeConeSegment(-5.,11.,5.,8.,12.,0.,270.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: rmin1 is negative.") try : CS9 = shaperpy.makeConeSegment(11.,7.,5.,8.,12.,0.,270.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: rmin1 is larger than rmax1.") try : CS10 = shaperpy.makeConeSegment(7.,11.,8.,5.,12.,0.,270.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: rmin2 is larger than rmax2.") try : CS11 = shaperpy.makeConeSegment(7.,11.,-3.,5.,12.,0.,270.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: rmin2 is negative.") try : CS12 = shaperpy.makeConeSegment(7.,11.,5.,8.,0.,0.,270.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: z is negative or null.") try : CS13 = shaperpy.makeConeSegment(7.,11.,5.,8.,-10.,0.,270.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: z is negative or null.") try : CS14 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,-45.,-45.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: deltaphi is negative or null.") try : CS15 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,45.,450.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cone Segment builder :: deltaphi is larger than 360 degree.") \ No newline at end of file diff --git a/test.API/SHAPER/Primitives/TestAPI_Box.py b/test.API/SHAPER/Primitives/TestAPI_Box.py index 8b24b8049..8ea9d29dc 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Box.py +++ b/test.API/SHAPER/Primitives/TestAPI_Box.py @@ -27,32 +27,32 @@ Box_1 = shaperpy.makeBox(10.,10.,10.) try : Box_2 = shaperpy.makeBox(0.,10.,10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.") try : Box_3 = shaperpy.makeBox(10.,0.,10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.") try : Box_4 = shaperpy.makeBox(10.,10.,0.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.") try : Box_5 = shaperpy.makeBox(-10.,10.,10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with dimensions :: Dx is null or negative.") try : Box_6 = shaperpy.makeBox(10.,-10.,10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with dimensions :: Dy is null or negative.") try : Box_7 = shaperpy.makeBox(10.,10.,-10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with dimensions :: Dz is null or negative.") # Create a box with two points defining the diagonal @@ -62,33 +62,33 @@ Box_8 = shaperpy.makeBox(pnt1,pnt2) try : Box_9 = shaperpy.makeBox(pnt1,pnt1) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with points :: the distance between the two points is null.") try : pnt3 = pnt(0.,50.,50.) Box_10 = shaperpy.makeBox(pnt1,pnt3) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : pnt4 = pnt(50.,0.,50.) Box_11 = shaperpy.makeBox(pnt1,pnt4) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : pnt5 = pnt(50.,50.,0.) Box_12 = shaperpy.makeBox(pnt1,pnt5) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : Box_13 = shaperpy.makeBox(None, pnt2) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with points :: the first point is not valid.") try : Box_14 = shaperpy.makeBox(pnt2, None) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Box builder with points :: the second point is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Primitives/TestAPI_Cylinder.py b/test.API/SHAPER/Primitives/TestAPI_Cylinder.py index f6862ab88..95cb08f95 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Cylinder.py +++ b/test.API/SHAPER/Primitives/TestAPI_Cylinder.py @@ -46,32 +46,32 @@ Cylinder_3 = shaperpy.makeCylinder(pnt2, edg1, 7., 12.) try: Cylinder_4 = shaperpy.makeCylinder(0., 10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: radius is negative or null.") try: Cylinder_5 = shaperpy.makeCylinder(-5., 10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: radius is negative or null.") try: Cylinder_6 = shaperpy.makeCylinder(5., 0.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: height is negative or null.") try: Cylinder_7 = shaperpy.makeCylinder(5., -10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: height is negative or null.") try: Cylinder_8 = shaperpy.makeCylinder(None, edgz, 5., 10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: the base point is not valid.") try: Cylinder_9 = shaperpy.makeCylinder(pnt1, None, 5., 10.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: the axis is not valid.") Cylinder_14 = shaperpy.makeCylinder(5., 10., 45.) @@ -81,45 +81,45 @@ Cylinder_17 = shaperpy.makeCylinder(pnt2, edgy, 5., 10., 360.) try: Cylinder_18 = shaperpy.makeCylinder(0., 10., 45.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: radius is negative or null.") try: Cylinder_19 = shaperpy.makeCylinder(-5., 10., 45.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: radius is negative or null.") try: Cylinder_20 = shaperpy.makeCylinder(5., 0., 45.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: height is negative or null.") try: Cylinder_21 = shaperpy.makeCylinder(5., -10., 45.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: height is negative or null.") try: Cylinder_22 = shaperpy.makeCylinder(5., 10., 0.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: angle is negative or null.") try: Cylinder_23 = shaperpy.makeCylinder(5., 10., -45.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: angle is negative or null.") try: Cylinder_24 = shaperpy.makeCylinder(5., 10., 450.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: angle greater than 360 degrees.") try: Cylinder_25 = shaperpy.makeCylinder(None, edgz, 5., 10., 90.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: the base point is not valid.") try: Cylinder_26 = shaperpy.makeCylinder(pnt1, None, 5., 10., 90.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Cylinder builder :: the axis is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py b/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py index 2195df285..0a3ac7619 100644 --- a/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py +++ b/test.API/SHAPER/Transformations/TestAPI_MultiTranslation.py @@ -51,7 +51,7 @@ MultiTranslation_2 = shaperpy.makeMultiTranslation(Box_2, ax1, -15., 5) try: MultiTranslation_3 = shaperpy.makeMultiTranslation(Box_3, ax1, 15., -2) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Multitranslation builder :: the number of copies for the first direction is null or negative.") MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_5, ax1, 10., 5, ax2, 10., 5) @@ -66,7 +66,7 @@ MultiTranslation_6 = shaperpy.makeMultiTranslation(Box_6, ax1, 15., 5, ax2, -10. # Pas d'exception levee alors qu'une devrait y en avoir une try: MultiTranslation_7 = shaperpy.makeMultiTranslation(Box_7, ax1, 15., 5, ax2, 10., -2) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Multitranslation builder :: the number of copies for the second direction is null or negative.") #try: diff --git a/test.API/SHAPER/Transformations/TestAPI_Rotation.py b/test.API/SHAPER/Transformations/TestAPI_Rotation.py index 5b0800484..1e9323572 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Rotation.py +++ b/test.API/SHAPER/Transformations/TestAPI_Rotation.py @@ -58,22 +58,22 @@ Rotation_4 = shaperpy.makeRotation(Box_4, ax1, -360) try: Rotation_5 = shaperpy.makeRotation(Box_5, ax1, 450) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: angle greater than 360 degrees.") try: Rotation_6 = shaperpy.makeRotation(Box_6, ax1, -450) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: angle smaller than -360 degrees.") try: Rotation_7 = shaperpy.makeRotation(Box_7, None, 180) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: axis is not valid.") try: Rotation_8 = shaperpy.makeRotation(None, ax1, 180) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: source shape is not valid.") Rotation_9 = shaperpy.makeRotation(Box_8, pntOrigin, pnt1, pnt2) @@ -81,35 +81,35 @@ Rotation_10 = shaperpy.makeRotation(Box_9, pnt3, pnt1, pnt2) try: Rotation_11 = shaperpy.makeRotation(Box_10, pnt3, pnt1, pnt1) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: start point and end point coincide.") try: Rotation_12 = shaperpy.makeRotation(Box_11, pnt3, pnt3, pnt1) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: center point and start point coincide.") try: Rotation_13 = shaperpy.makeRotation(Box_12, pnt3, pnt1, pnt3) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: center point and end point coincide.") try: Rotation_14 = shaperpy.makeRotation(Box_13, pntOrigin, pnt1, None) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: end point is not valid.") try: Rotation_15 = shaperpy.makeRotation(Box_14, None, pnt3, pnt2) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: center point is not valid.") try: Rotation_16 = shaperpy.makeRotation(Box_15, pntOrigin, None, pnt1) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: start point is not valid.") try: Rotation_17 = shaperpy.makeRotation(None, pntOrigin, pnt3, pnt2) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Rotation builder :: source shape is not valid.") diff --git a/test.API/SHAPER/Transformations/TestAPI_Scale.py b/test.API/SHAPER/Transformations/TestAPI_Scale.py index 2904d5bd4..8fc2c5244 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Scale.py +++ b/test.API/SHAPER/Transformations/TestAPI_Scale.py @@ -46,14 +46,14 @@ Scale_1 = shaperpy.makeScale(Box_1, pntOrigin, 2.) Scale_2 = shaperpy.makeScale(Box_2, pnt1, 2.) try : Scale_6 = shaperpy.makeScale(Box_3, pntOrigin, 0) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Scale builder :: the scale factor is null.") Scale_7 = shaperpy.makeScale(Box_4, pntOrigin, -3.) try : Scale_8 = shaperpy.makeScale(Box_5, None, 2.) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Scale builder :: center point is not valid.") Scale_9 = shaperpy.makeScale(Box_6, pntOrigin, 2., 3., 1.) @@ -61,20 +61,20 @@ Scale_10 = shaperpy.makeScale(Box_7, pnt1, 2., 3., 1.) try : Scale_14 = shaperpy.makeScale(Box_8, pntOrigin, 0., 3., 1.) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Scale builder :: the scale factor in X is null.") try : Scale_15 = shaperpy.makeScale(Box_9, pntOrigin, 2., 0., 1.) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Scale builder :: the scale factor in Y is null.") try : Scale_16 = shaperpy.makeScale(Box_10, pntOrigin, 2., 3., 0.) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Scale builder :: the scale factor in Z is null.") Scale_17 = shaperpy.makeScale(Box_11, pntOrigin, -2., -3., 0.5) try : Scale_18 = shaperpy.makeScale(Box_12, None, 2., 3., 1.) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Scale builder :: center point is not valid.") \ No newline at end of file diff --git a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py index 0e0110fa3..6356d227f 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Symmetry.py +++ b/test.API/SHAPER/Transformations/TestAPI_Symmetry.py @@ -64,7 +64,7 @@ Symmetry_2 = shaperpy.makeSymmetry(Box_2, pnt1) try : Symmetry_6 = shaperpy.makeSymmetry(Box_2, None) -except myExcept,ec : +except myExcept as ec : assert(ec.what() == "Symmetry builder :: point is not valid.") Symmetry_7 = shaperpy.makeSymmetry(Box_7, axZ) diff --git a/test.API/SHAPER/Transformations/TestAPI_Translation.py b/test.API/SHAPER/Transformations/TestAPI_Translation.py index 376f12497..1d6a18c1f 100644 --- a/test.API/SHAPER/Transformations/TestAPI_Translation.py +++ b/test.API/SHAPER/Transformations/TestAPI_Translation.py @@ -69,7 +69,7 @@ Translation_3 = shaperpy.makeTranslation(Box_3, ax1, -15.) try: Translation_4 = shaperpy.makeTranslation(Box_4, None, 15.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Translation builder :: axis is not valid.") Translation_9 = shaperpy.makeTranslation(Box_5, ax4, 15.) @@ -86,7 +86,7 @@ Translation_12 = shaperpy.makeTranslation(MultiTranslation_3, ax3, -15.) MultiTranslation_4 = shaperpy.makeMultiTranslation(Box_9, ax1, 15., 3, ax2, 15., 3) try: Translation_13 = shaperpy.makeTranslation(MultiTranslation_4, None, 15.) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Translation builder :: axis is not valid.") MultiTranslation_5 = shaperpy.makeMultiTranslation(Box_10, ax1, 15., 3, ax2, 15., 3) @@ -106,15 +106,15 @@ Translation_99 = shaperpy.makeTranslation(Box_11, pnt1, pnt2) try: Translation_100 = shaperpy.makeTranslation(Box_11, pnt1, pnt1) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Translation builder :: start point and end point coincide.") try: Translation_101 = shaperpy.makeTranslation(Box_11, None, pnt1) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Translation builder :: start point is not valid.") try: Translation_102 = shaperpy.makeTranslation(Box_11, pnt1, None) -except myExcept,ec: +except myExcept as ec: assert(ec.what() == "Translation builder :: end point is not valid.") \ No newline at end of file diff --git a/test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py b/test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py index c67df2890..93d49269c 100644 --- a/test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py +++ b/test.squish/suite_FEATURE_PARAMETERS/shared/scripts/bdd_hooks.py @@ -36,7 +36,7 @@ # See the section 'Performing Actions During Test Execution Via Hooks' in the Squish # manual for a complete reference of the available API. -import __builtin__ +import builtins # Detach (i.e. potentially terminate) all AUTs at the end of a scenario @OnScenarioEnd diff --git a/test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py b/test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py index 81e103f7f..77b413af5 100644 --- a/test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py +++ b/test.squish/suite_FEATURE_PARAMETERS/shared/steps/steps.py @@ -48,7 +48,7 @@ # specified. In that case, make sure to set the (optional) 'regexp' argument # to True. -import __builtin__ +import builtins @Given("Launch application in salome mode") def step(context): diff --git a/utils.py b/utils.py index 847f242d8..5e811fd40 100644 --- a/utils.py +++ b/utils.py @@ -26,8 +26,8 @@ import os, os.path SHAPER_SRC = os.environ['PWD'] # VERBOSE_FLAG = os.environ['VERBOSE_FLAG'] VERBOSE_FLAG = "" -ENCODING = u"utf-8" -OPERATORS=[u">", u"<", u"+", u"=", u"-", u"*", u"/"] +ENCODING = "utf-8" +OPERATORS=[">", "<", "+", "=", "-", "*", "/"] def create_warning_generator(fichier): """ @@ -40,14 +40,14 @@ def create_warning_generator(fichier): while ligne.strip("\n") : ligne = ligne.decode(ENCODING) liste = ligne.split(":") - print "Size of liste = ", len(liste) - print "ligne = ", ligne - print "n° ligne = ", i - print "XXX : ", ligne.find(u'Done processing ') + print("Size of liste = ", len(liste)) + print("ligne = ", ligne) + print("n° ligne = ", i) + print("XXX : ", ligne.find('Done processing ')) if len(liste) < 3: - if ligne.find(u'Done processing ') == -1 and ligne.find(u'Category ') == -1 and ligne.find(u'Total errors found: ') == -1: - raise Exception(u"Fichier de log mal formé") + if ligne.find('Done processing ') == -1 and ligne.find('Category ') == -1 and ligne.find('Total errors found: ') == -1: + raise Exception("Fichier de log mal formé") else: ligne = fichier.readline() i += 1 @@ -55,12 +55,12 @@ def create_warning_generator(fichier): elif len(liste) != 3: item1=liste[0] item2=liste[1] - merge = u"" - sep = u"" + merge = "" + sep = "" for item in liste[2:]: merge += sep merge += item - sep = u":" + sep = ":" liste = [item1, item2, merge] ligne = fichier.readline() i += 1 @@ -73,7 +73,7 @@ def get_line_no(path, nol): """retourne la ligne No nol du fichier path (relatif à DST_SRC_PARENT) sous forme d'un unicode""" ligne = "" fic = open(get_src_path(path), "r") - for i in xrange(nol): + for i in range(nol): ligne = fic .readline() fic.close() ligne_u = ligne.decode(ENCODING) -- 2.39.2