IF(WIN32)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
- SET(PYTHON_LIBRARY_FILE "python27_d.lib")
+ SET(PYTHON_LIBRARY_FILE "python36_d.lib")
ElSE()
- SET(PYTHON_LIBRARY_FILE "python27.lib")
+ SET(PYTHON_LIBRARY_FILE "python36.lib")
ENDIF()
ElSE()
- SET(PYTHON_LIBRARY_FILE "libpython2.7.so")
+ SET(PYTHON_LIBRARY_FILE "libpython3.6.so")
ENDIF()
-IF($ENV{PYTHONHOME})
+IF(DEFINED ENV{PYTHONHOME})
IF(WIN32)
FILE(TO_CMAKE_PATH "$ENV{PYTHONHOME}/libs/${PYTHON_LIBRARY_FILE}" PATH_PYTHON_LIBRARY)
ElSE()
SET(PYTHON_LIBRARY ${PATH_PYTHON_LIBRARY} CACHE FILEPATH "path to the python library" FORCE)
ENDIF()
-IF($ENV{PYTHON_INCLUDE})
+IF(DEFINED ENV{PYTHON_INCLUDE})
FILE(TO_CMAKE_PATH $ENV{PYTHON_INCLUDE} PATH_PYTHON_INCLUDE_DIR)
SET(PYTHON_INCLUDE_DIR ${PATH_PYTHON_INCLUDE_DIR} CACHE PATH "path to where Python.h is found" FORCE)
ENDIF()
-FIND_PACKAGE(PythonLibs REQUIRED)
FIND_PACKAGE(PythonInterp REQUIRED)
+FIND_PACKAGE(PythonLibs REQUIRED)
-INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
\ No newline at end of file
### 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
#########################
### 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
### 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
#########################
# 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
#########################
### 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
#########################
### 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
#########################
### 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
#########################
### 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 {'''
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
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
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)
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')
### 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
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
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)
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")
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):
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):
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
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 = []
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'},
}
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é
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)
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)
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")
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
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__':
if process in name_list:
pid = _pid
-print pid
+print(pid)
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(BuildAPI python BuildAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(BuildAPI LANGUAGE python SOURCES BuildAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(BuildAPI python BuildAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(BuildAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(CollectionAPI python CollectionAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(CollectionAPI LANGUAGE python SOURCES CollectionAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(CollectionAPI python CollectionAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(CollectionAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
#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"
Config
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(ConfigAPI python ConfigAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ConfigAPI LANGUAGE python SOURCES ConfigAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ConfigAPI python ConfigAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ConfigAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
SET_TARGET_PROPERTIES(_ConfigAPI PROPERTIES DEBUG_OUTPUT_NAME _ConfigAPI_d)
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;
}
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(ConnectorAPI python ConnectorAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ConnectorAPI LANGUAGE python SOURCES ConnectorAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ConnectorAPI python ConnectorAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ConnectorAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
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():
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]
if __name__ == '__main__':
- testSeveralExportsToGEOM()
\ No newline at end of file
+ testSeveralExportsToGEOM()
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():
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]
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()
## 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()
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(ConstructionAPI python ConstructionAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ConstructionAPI LANGUAGE python SOURCES ConstructionAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ConstructionAPI python ConstructionAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ConstructionAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(EventsAPI python Events.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(EventsAPI LANGUAGE python SOURCES Events.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(EventsAPI python Events.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(EventsAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(ExchangeAPI python ExchangeAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ExchangeAPI LANGUAGE python SOURCES ExchangeAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ExchangeAPI python ExchangeAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ExchangeAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
Test2290.py
Test2459.py
TestExportToXAOWithGroupNotUpdated.py)
-
-SET(DATA_FILES
- solid.brep
- solid.brp
- screw.step
- screw.stp
- bearing.iges
- bearing.igs
- Box_1.brep
- test.xao
- export_ref.xao
-)
-
-FOREACH(file ${DATA_FILES})
- CONFIGURE_FILE(
- ${CMAKE_CURRENT_SOURCE_DIR}/Test/Data/${file}
- ${CMAKE_CURRENT_BINARY_DIR}/Data/${file}
- COPYONLY)
-ENDFOREACH(file ${DATA_FIELS})
-
#=========================================================================
import os
import math
+from tempfile import TemporaryDirectory
from ModelAPI import *
aSession.startOperation("Import screw")
anImportFeature = aPart.addFeature("Import")
- anImportFeature.string("file_path").setValue("Data/screw.step")
+ aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "screw.step")
+ anImportFeature.string("file_path").setValue(aShapePath)
aSession.finishOperation()
removeFile(theFile)
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")
# Test exported file by importing
testImport(theType, theFile, theVolume, theDelta)
-def testExportXAO():
+def testExportXAO(theFile):
# Import a reference part
aSession.startOperation("Add part")
aPartFeature = aSession.moduleDocument().addFeature("Part")
aSession.startOperation("Import Box_1")
anImportFeature = aPart.addFeature("Import")
- anImportFeature.string("file_path").setValue("Data/Box_1.brep")
+ aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Brep", "box1.brep")
+ anImportFeature.string("file_path").setValue(aShapePath)
aSession.finishOperation()
# Create groups
aGroupFeature.data().setName("")
aSelectionListAttr = aGroupFeature.selectionList("group_list")
aSelectionListAttr.setSelectionType("face")
- aSelectionListAttr.append("Box_1_1/Shape1")
- aSelectionListAttr.append("Box_1_1/Shape2")
+ aSelectionListAttr.append("box1_1/Shape1")
+ aSelectionListAttr.append("box1_1/Shape2")
aSession.finishOperation()
aSession.startOperation("Create a field")
aField = aSession.activeDocument().addFeature("Field")
aSelectionListAttr = aField.selectionList("selected")
aSelectionListAttr.setSelectionType("face")
- aSelectionListAttr.append("Box_1_1/Shape1")
- aSelectionListAttr.append("Box_1_1/Shape2")
+ aSelectionListAttr.append("box1_1/Shape1")
+ aSelectionListAttr.append("box1_1/Shape2")
aComponentNames = aField.stringArray("components_names")
aComponentNames.setSize(2) # two components
aComponentNames.setValue(0, "temperatue")
# Export
aSession.startOperation("Export to XAO")
anExportFeature = aPart.addFeature("Export")
- anExportFeature.string("xao_file_path").setValue("Data/export.xao")
+ anExportFeature.string("xao_file_path").setValue(theFile)
anExportFeature.string("file_format").setValue("XAO")
anExportFeature.string("ExportType").setValue("XAO")
anExportFeature.string("xao_author").setValue("me")
aSession.finishOperation()
# Check exported file
+ aRefPath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Xao", "box2.xao")
import filecmp
- assert filecmp.cmp("Data/export.xao", "Data/export_ref.xao")
+ assert filecmp.cmp(theFile, aRefPath)
if __name__ == '__main__':
-#=========================================================================
-# Export a shape into BREP
-#=========================================================================
- aRealVolume = 3.78827401738e-06
- testExport("BREP", "BREP", os.path.join(os.getcwd(), "Data", "screw_export.brep"), aRealVolume, 10 ** -17)
- testExport("BRP", "BREP", os.path.join(os.getcwd(), "Data", "screw_export.brp"), aRealVolume, 10 ** -17)
-#=========================================================================
-# Export a shape into STEP
-#=========================================================================
- testExport("STEP", "STEP", os.path.join(os.getcwd(), "Data", "screw_export.step"), 3.78825807533e-06, 10 ** -17)
- testExport("STP", "STEP", os.path.join(os.getcwd(), "Data", "screw_export.stp"), 3.78825807533e-06, 10 ** -17)
-#=========================================================================
-# Export a shape into IGES
-#=========================================================================
- testExport("IGES-5.1", "IGES-5.1", os.path.join(os.getcwd(), "Data", "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17)
- testExport("IGS-5.1", "IGES-5.1", os.path.join(os.getcwd(), "Data", "screw_export-5.1.igs"), 3.78829613776e-06, 10 ** -17)
- testExport("IGES-5.3", "IGES-5.3", os.path.join(os.getcwd(), "Data", "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17)
- testExport("IGS-5.3", "IGES-5.3", os.path.join(os.getcwd(), "Data", "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17)
-#=========================================================================
-# Export a shape into XAO
-#=========================================================================
- testExportXAO()
-#=========================================================================
-# End of test
-#=========================================================================
-
-assert(model.checkPythonDump())
+ with TemporaryDirectory() as tmp_dir:
+ #=========================================================================
+ # Export a shape into BREP
+ #=========================================================================
+ aRealVolume = 3.78827401738e-06
+ testExport("BREP", "BREP", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 10 ** -17)
+ testExport("BRP", "BREP", os.path.join(tmp_dir, "screw_export.brp"), aRealVolume, 10 ** -17)
+ #=========================================================================
+ # Export a shape into STEP
+ #=========================================================================
+ testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17)
+ testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.78825807533e-06, 10 ** -17)
+ #=========================================================================
+ # Export a shape into IGES
+ #=========================================================================
+ testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17)
+ testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 3.78829613776e-06, 10 ** -17)
+ testExport("IGES-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17)
+ testExport("IGS-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17)
+ #=========================================================================
+ # Export a shape into XAO
+ #=========================================================================
+ testExportXAO(os.path.join(tmp_dir, "export.xao"))
+ #=========================================================================
+ # End of test
+ #=========================================================================
+
+ assert(model.checkPythonDump())
#=========================================================================
from ModelAPI import *
from GeomAlgoAPI import *
+
+import os
import math
+import shutil
+from tempfile import TemporaryDirectory
__updated__ = "2015-05-22"
aSession = ModelAPI_Session.get()
+
#=========================================================================
# Common test function
#=========================================================================
+def getShapePath(path):
+ shapes_dir = os.path.join(os.getenv("DATA_DIR"), "Shapes")
+ return os.path.join(shapes_dir, path)
+
def testImport(theType, theFile, theVolume, theDelta):
# Create a part for import
aSession.startOperation("Create part for import")
aSession.startOperation("Import XAO")
anImportFeature = aPart.addFeature("Import")
- anImportFeature.string("file_path").setValue("Data/test.xao")
+ anImportFeature.string("file_path").setValue(getShapePath("Xao/box1.xao"))
aSession.finishOperation()
# Check results
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)
assert aFeature3.selectionList("selected").size() == 1
if __name__ == '__main__':
-#=========================================================================
-# Create a shape imported from BREP
-#=========================================================================
- testImport("BREP", "Data/solid.brep", 259982.297176, 10 ** -5)
- testImport("BRP", "Data/solid.brp", 259982.297176, 10 ** -5)
-#=========================================================================
-# Create a shape imported from STEP
-#=========================================================================
- testImport("STP", "Data/screw.stp", 3.78827401738e-06, 10 ** -17)
- testImport("STEP", "Data/screw.step", 3.78827401738e-06, 10 ** -17)
-#=========================================================================
-# Create a shape imported from IGES
-#=========================================================================
- testImport("IGES", "Data/bearing.iges", 6.86970803067e-14, 10 ** -25)
- testImport("IGS", "Data/bearing.igs", 6.86970803067e-14, 10 ** -25)
-#=========================================================================
-# Create a shape imported from XAO
-#=========================================================================
- testImportXAO()
-#=========================================================================
-# End of test
-#=========================================================================
-
-from salome.shaper import model
-assert(model.checkPythonDump())
+ with TemporaryDirectory() as tmp_dir:
+ #=========================================================================
+ # Create a shape imported from BREP
+ #=========================================================================
+ shape_path = getShapePath("Brep/solid.brep")
+ testImport("BREP", shape_path, 259982.297176, 10 ** -5)
+ shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "solid.brp"))
+ testImport("BRP", shape_path, 259982.297176, 10 ** -5)
+ #=========================================================================
+ # Create a shape imported from STEP
+ #=========================================================================
+ shape_path = getShapePath("Step/screw.step")
+ testImport("STP", shape_path, 3.78827401738e-06, 10 ** -17)
+ shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "screw.stp"))
+ testImport("STEP", shape_path, 3.78827401738e-06, 10 ** -17)
+ #=========================================================================
+ # Create a shape imported from IGES
+ #=========================================================================
+ shape_path = getShapePath("Iges/bearing.igs")
+ testImport("IGES", shape_path, 6.86970803067e-14, 10 ** -25)
+ shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "bearing.iges"))
+ testImport("IGS", shape_path, 6.86970803067e-14, 10 ** -25)
+
+ #=========================================================================
+ # Create a shape imported from XAO
+ #=========================================================================
+ testImportXAO()
+
+ #=========================================================================
+ # End of test
+ #=========================================================================
+
+ from salome.shaper import model
+ assert(model.checkPythonDump())
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(FeaturesAPI python FeaturesAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(FeaturesAPI LANGUAGE python SOURCES FeaturesAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(FeaturesAPI python FeaturesAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(FeaturesAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
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"))
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()
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()
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"))
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()
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())
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(GDMLAPI python GDMLAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(GDMLAPI LANGUAGE python SOURCES GDMLAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(GDMLAPI python GDMLAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(GDMLAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(GeomAPI python GeomAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(GeomAPI LANGUAGE python SOURCES GeomAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(GeomAPI python GeomAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(GeomAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
return false;
Handle(IntTools_Context) aContext = new IntTools_Context();
- // Double check needed bacause BOPTools_AlgoTools::CheckSameGeom not very smart.
- Standard_Boolean aRes = BOPTools_AlgoTools::CheckSameGeom(aMyFace, aInFace, aContext)
- && BOPTools_AlgoTools::CheckSameGeom(aInFace, aMyFace, aContext);
+ // Double check needed because BOPTools_AlgoTools::AreFacesSameDomain not very smart.
+ Standard_Boolean aRes = BOPTools_AlgoTools::AreFacesSameDomain(aMyFace, aInFace, aContext)
+ && BOPTools_AlgoTools::AreFacesSameDomain(aInFace, aMyFace, aContext);
return aRes == Standard_True;
}
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(GeomAlgoAPI python GeomAlgoAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(GeomAlgoAPI LANGUAGE python SOURCES GeomAlgoAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(GeomAlgoAPI python GeomAlgoAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(GeomAlgoAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(GeomDataAPI python GeomDataAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(GeomDataAPI LANGUAGE python SOURCES GeomDataAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(GeomDataAPI python GeomDataAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(GeomDataAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
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
PyObject* aColOffset = PyTuple_GetItem(aPosition, 1);
aResult.push_back(
- std::pair<int, int>((int)PyInt_AsLong(aLineNo),
- (int)PyInt_AsLong(aColOffset)));
+ std::pair<int, int>((int)PyLong_AsLong(aLineNo),
+ (int)PyLong_AsLong(aColOffset)));
}
// TODO(spo): after this refCount of the variable is not 0. Is there memory leak?
}
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);
}
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);
}
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);
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);
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(ModelAPI python ModelAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ModelAPI LANGUAGE python SOURCES ModelAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ModelAPI python ModelAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ModelAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
%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.");
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()):
${PYTHON_LIBRARIES}
)
-SWIG_ADD_MODULE(ModelGeomAlgo python ModelGeomAlgo.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ModelGeomAlgo LANGUAGE python SOURCES ModelGeomAlgo.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ModelGeomAlgo python ModelGeomAlgo.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ModelGeomAlgo ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(ModelHighAPI python ModelHighAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ModelHighAPI LANGUAGE python SOURCES ModelHighAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ModelHighAPI python ModelHighAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ModelHighAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
#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"
// 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 {
}
}
%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<int>(PyInt_AsLong($input)));
+ if (PyLong_Check($input)) {
+ temp = ModelHighAPI_Integer(static_cast<int>(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 {
}
}
%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) {
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<std::string, std::map<std::string, ModelHighAPI_FeatureStore> > aStore;
std::string anError = storeFeatures(
aSession->moduleDocument()->kind(), aSession->moduleDocument(), aStore, false);
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
AIS_Shape::ComputeSelection(aSelection, theMode);
if (myAdditionalSelectionPriority > 0) {
- for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
- Handle(SelectBasics_EntityOwner) aBasicsOwner =
- aSelection->Sensitive()->BaseSensitive()->OwnerId();
+ NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> anEntities = aSelection->Entities();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIt(anEntities);
+ anIt.More();
+ anIt.Next()) {
+ Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value();
+ Handle(SelectBasics_EntityOwner) aBasicsOwner = anEntity->BaseSensitive()->OwnerId();
if (!aBasicsOwner.IsNull())
aBasicsOwner->Set(aBasicsOwner->Priority() + myAdditionalSelectionPriority);
}
StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection,
aDeflection, myDrawer->HLRAngle(), 9, 500);
- for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
+
+ NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> anEntities = aSelection->Entities();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIt(anEntities);
+ anIt.More();
+ anIt.Next()) {
+ Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value();
Handle(SelectMgr_EntityOwner) anOwner =
Handle(SelectMgr_EntityOwner)
- ::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
+ ::DownCast(anEntity->BaseSensitive()->OwnerId());
anOwner->Set(this);
}
+
return true;
}
return false;
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(ParametersAPI python ParametersAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(ParametersAPI LANGUAGE python SOURCES ParametersAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(ParametersAPI python ParametersAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(ParametersAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
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
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(PartSetAPI python PartSetAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(PartSetAPI LANGUAGE python SOURCES PartSetAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(PartSetAPI python PartSetAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(PartSetAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(PrimitivesAPI python PrimitivesAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(PrimitivesAPI LANGUAGE python SOURCES PrimitivesAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(PrimitivesAPI python PrimitivesAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(PrimitivesAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
ExchangeAPI.ExchangeAPI_Import(self.part.addFeature("Import"))
import FeaturesAPI
- FeaturesAPI.FeaturesAPI_Boolean(self.part.addFeature("Boolean"))
+ FeaturesAPI.FeaturesAPI_BooleanCut(self.part.addFeature("BooleanCut"))
+ FeaturesAPI.FeaturesAPI_BooleanFuse(self.part.addFeature("BooleanFuse"))
+ FeaturesAPI.FeaturesAPI_BooleanCommon(self.part.addFeature("BooleanCommon"))
+ FeaturesAPI.FeaturesAPI_BooleanFill(self.part.addFeature("BooleanFill"))
+ FeaturesAPI.FeaturesAPI_BooleanSmash(self.part.addFeature("BooleanSmash"))
FeaturesAPI.FeaturesAPI_Extrusion(self.part.addFeature("Extrusion"))
FeaturesAPI.FeaturesAPI_ExtrusionCut(self.part.addFeature("ExtrusionCut"))
FeaturesAPI.FeaturesAPI_ExtrusionFuse(self.part.addFeature("ExtrusionFuse"))
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
# (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
# 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.
# (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'),
]
# 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 *
"""Package for dumping purposes.
"""
-from DumpAssistant import *
+from .DumpAssistant import *
"""
from SketchAPI import addSketch
-from tools import *
-from tests import *
+from .tools import *
+from .tests import *
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)
-from tests import *
\ No newline at end of file
+from .tests import *
\ No newline at end of file
"""
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())
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):
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)
aFeature = SketchPlugin_Rectangle().__disown__()
else:
- raise StandardError("No such feature %s" % theFeatureID)
+ raise Exception("No such feature %s" % theFeatureID)
return aFeature
${PROJECT_HEADERS}
)
-SWIG_ADD_MODULE(SketchAPI python SketchAPI.i ${PROJECT_HEADERS})
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(SketchAPI LANGUAGE python SOURCES SketchAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(SketchAPI python SketchAPI.i ${PROJECT_HEADERS})
+ENDIF()
SWIG_LINK_LIBRARIES(SketchAPI ${SWIG_LINK_LIBRARIES})
IF(WIN32)
#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"
static std::string ID()
{
- static const std::string DUMMY;
- return DUMMY;
+ static const std::string MY_SKETCH_CONSTRAINT_ID = "SketchConstraint";
+ return MY_SKETCH_CONSTRAINT_ID;
}
virtual std::string getID() { return ID(); }
TestMovementComplex.py
)
endif()
-
-# Copy data-files to corresponding directory
-file(GLOB DATA_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Test/Data/*")
-foreach(data_file ${DATA_FILES})
- get_filename_component(data_file_name "${data_file}" NAME)
- configure_file(
- ${data_file}
- ${CMAKE_CURRENT_BINARY_DIR}/Data/${data_file_name}
- COPYONLY)
-endforeach()
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
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()
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
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.
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()
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
averageTime += movementTime
nbMoves += 1
-print "Movement average time: {0}".format(averageTime / nbMoves)
+print("Movement average time: {0}".format(averageTime / nbMoves))
model.end()
from math import fabs
+import os
+
model.begin()
partSet = model.moduleDocument()
Part_1 = model.addPart(partSet)
Part_1_doc = Part_1.document()
-Import_1 = model.addImport(Part_1_doc, "Data/profile_top.brep")
+shape_path = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Brep", "profile_top.brep")
+Import_1 = model.addImport(Part_1_doc, shape_path)
model.do()
Import_1.setName("profile_top")
Import_1.result().setName("profile_top_1")
#=========================================================================
# 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")
# 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))
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)
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)
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.))
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])
void readBrep(Geometry* geom, const std::string& fileName)
{
- char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName));
+ std::string filePath = "Shapes/Brep/" + fileName;
+ char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(filePath));
geom->setShapeString(txt);
}
void BrepGeometryTest::testGetIDs()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_1.brep");
+ readBrep(geom, "box1.brep");
CPPUNIT_ASSERT_EQUAL(8, geom->countElements(XAO::VERTEX));
CPPUNIT_ASSERT_EQUAL(8, geom->countVertices());
void BrepGeometryTest::testGetReferences()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_1.brep");
+ readBrep(geom, "box1.brep");
// vertex of index 1 has id = 7
CPPUNIT_ASSERT_EQUAL(std::string("7"), geom->getElementReference(XAO::VERTEX, 1));
void BrepGeometryTest::testGetNames()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_1.brep");
+ readBrep(geom, "box1.brep");
int id;
void BrepGeometryTest::testGetEdgeVertices()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
// edge of index 23, id = #63
// vertex are 47 (#12), 59 (#15)
void BrepGeometryTest::testGetFaceEdges()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
CPPUNIT_ASSERT_EQUAL(2, geom->countFaceWires(1)); // face 13
CPPUNIT_ASSERT_EQUAL(1, geom->countFaceWires(2)); // face 29
void BrepGeometryTest::testSolidFaces()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Cut_2.brep");
+ readBrep(geom, "cut.brep");
CPPUNIT_ASSERT_EQUAL(5, geom->countSolidShells(0));
void BrepGeometryTest::testGetVertex()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
double x, y, z;
geom->getVertexXYZ(15, x, y, z);
void BrepGeometryTest::testGetEdgeLength()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
// edges 0 (#5), 7 (#21)
CPPUNIT_ASSERT_DOUBLES_EQUAL(200., geom->getEdgeLength(0), 0);
void BrepGeometryTest::testGetFaceArea()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
// faces 0 (#3), 1 (#13)
CPPUNIT_ASSERT_DOUBLES_EQUAL(40000., geom->getFaceArea(0), 1e-9);
void BrepGeometryTest::testGetSolidVolume()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
CPPUNIT_ASSERT_DOUBLES_EQUAL(7488000., geom->getSolidVolume(0), 1e-9);
void BrepGeometryTest::testParse()
{
BrepGeometry* geom = new BrepGeometry("box");
- readBrep(geom, "Box_2.brep");
+ readBrep(geom, "box2.brep");
std::cout << std::endl;
for (int solidIndex = 0; solidIndex < geom->countSolids(); ++solidIndex)
CPPUNIT_ASSERT_THROW(geom->setVertexName(0, "aa"), XAO_Exception);
- char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("Box_1.brep"));
+ char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("Shapes/Brep/box1.brep"));
geom->setShapeString(txt);
CPPUNIT_ASSERT_EQUAL(false, geom->hasVertexName(0));
void ImportExportTest::testImportXao()
{
Xao xao;
- xao.importXAO(TestUtils::getTestFilePath("test.xao"));
+ xao.importXAO(TestUtils::getTestFilePath("Shapes/Xao/box1.xao"));
checkImport(xao);
}
void ImportExportTest::testImportXaoFromText()
{
- char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("test.xao"));
+ char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath("Shapes/Xao/box1.xao"));
Xao xao;
xao.setXML(txt);
class TestUtils
{
public:
- static std::string getTestFilePath(const std::string& fileName)
+ static std::string getTestFilePath(const std::string& filePath)
{
- std::string dataDir = getenv("GEOM_SRC_DIR");
- dataDir += "/src/XAO/tests/data/";
- dataDir += fileName;
+ std::string dataDir = getenv("DATA_DIR");
+ dataDir += filePath;
return dataDir;
}
continue;
Handle(SelectMgr_Selection) aSelection = theObject->Selection(aMode);
- for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
+ NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> anEntities = aSelection->Entities();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIt(anEntities);
+ anIt.More();
+ anIt.Next()) {
+ Handle(SelectMgr_SensitiveEntity) anEntity = anIt.Value();
if (anEntity.IsNull())
continue;
- Handle(SelectMgr_EntityOwner) anOwner =
+ Handle(SelectMgr_EntityOwner) anOwner =
Handle(SelectMgr_EntityOwner)::DownCast(anEntity->BaseSensitive()->OwnerId());
if (!anOwner.IsNull())
theOwners.Add(anOwner);
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
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
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
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.)
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
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)
# 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:
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)
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.")
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.)
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
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)
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.)
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)
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
# 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
# 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):
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):
"""
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
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
"""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)