1414
1515def copysection (block ):
1616 #Just makes a straight copy of blocks that don't need any work
17- regex = "^\s*\[%s\](.+?)(?:^\s*\[|\Z)" % block
17+ regex = r "^\s*\[%s\](.+?)(?:^\s*\[|\Z)" % block
1818 section = re .search (regex , inistring , re .M | re .DOTALL )
1919 newini .write ("\n [%s]" % block )
2020 if section != None :
@@ -178,7 +178,7 @@ def writeifexists(file, section, src_item, dest_item = "None"):
178178 inistring = open (filename ,'r' ).read ()
179179 newini = open (filename , 'w' )
180180 # Get a list of all sections
181- all_sections = re .findall ("^\s*\[(.+)\]" , inistring , re .MULTILINE )
181+ all_sections = re .findall (r "^\s*\[(.+)\]" , inistring , re .MULTILINE )
182182
183183 # A C-style Switch would be nice here, to allow us to fall through successive
184184 # version updates.
@@ -190,13 +190,13 @@ def writeifexists(file, section, src_item, dest_item = "None"):
190190 newini .write ("# The original config files may be found in the %s directory\n \n " % backupdir )
191191
192192 # reproduce everything before the first [section] verbatim
193- section = re .match ("(.*?)^\[" , inistring , re .DOTALL | re .MULTILINE )
193+ section = re .match (r "(.*?)^\[" , inistring , re .DOTALL | re .MULTILINE )
194194 if section != None :
195195 newini .write (section .group (1 ))
196196
197197 #[EMC] Section, change the version number
198198 all_sections .remove ("EMC" )
199- section = re .search ("\[EMC\](.+?)\n \[" , inistring , re .DOTALL )
199+ section = re .search (r "\[EMC\](.+?)\n\[" , inistring , re .DOTALL )
200200 if section : section = section .group (1 )
201201 newini .write ("[EMC]\n " )
202202 if section != None :
@@ -215,7 +215,7 @@ def writeifexists(file, section, src_item, dest_item = "None"):
215215
216216 #[RS274NGC] Section, change FEATURES to separate entries
217217 all_sections .remove ("RS274NGC" )
218- section = re .search ("\[RS274NGC\](.+?)\n \[" , inistring , re .DOTALL )
218+ section = re .search (r "\[RS274NGC\](.+?)\n\[" , inistring , re .DOTALL )
219219 if section : section = section .group (1 )
220220 newini .write ("\n [RS274NGC]\n " )
221221 if section != None :
@@ -233,7 +233,7 @@ def writeifexists(file, section, src_item, dest_item = "None"):
233233 newini .write (section )
234234
235235 all_sections .remove ("EMCMOT" )
236- section = re .search ("\[EMCMOT\](.+?)\n \[" , inistring , re .DOTALL )
236+ section = re .search (r "\[EMCMOT\](.+?)\n\[" , inistring , re .DOTALL )
237237 if section : section = section .group (1 )
238238 newini .write ("[EMCMOT]\n " )
239239 section = re .sub ("# Interval between tries to emcmot.*?\n " , "" , section )
@@ -264,14 +264,14 @@ def writeifexists(file, section, src_item, dest_item = "None"):
264264 for halfile in halpaths :
265265 hal = open (os .path .join (os .path .dirname (filename ), halfile ), 'r' )
266266 for line in hal .readlines ():
267- match = re .match ('(?:#autoconverted|loadrt) +(\w+kins)' , line )
267+ match = re .match (r '(?:#autoconverted|loadrt) +(\w+kins)' , line )
268268 if match :
269269 kins = match .group (1 )
270- match = re .search ('coordinates *= *(\w+)' , line )
270+ match = re .search (r 'coordinates *= *(\w+)' , line )
271271 if match :
272272 coordinates = list (match .group (1 ))
273273 coords_entry = 1
274- match = re .search ('kinstype *= *(\w+)' , line )
274+ match = re .search (r 'kinstype *= *(\w+)' , line )
275275 if kinstype : kinstype = match .group (1 )
276276 break
277277 if kins : break
@@ -286,7 +286,7 @@ def writeifexists(file, section, src_item, dest_item = "None"):
286286 for halfile in halpaths :
287287 hal = open (os .path .join (os .path .dirname (filename ), halfile ), 'r' )
288288 for line in hal .readlines ():
289- match = re .match ('setp +gantrykins.joint-(\d) +(\d)' , line )
289+ match = re .match (r 'setp +gantrykins.joint-(\d) +(\d)' , line )
290290 if match :
291291 j = int (match .group (1 ))
292292 if j > joints : joints = j
@@ -298,15 +298,15 @@ def writeifexists(file, section, src_item, dest_item = "None"):
298298
299299 # In JA [TRAJ] expects MAX_LINEAR_VELOCITY not MAX_VELOCITY
300300 all_sections .remove ("TRAJ" )
301- section = re .search ("\[TRAJ\](.+?)\n \[" , inistring , re .DOTALL )
301+ section = re .search (r "\[TRAJ\](.+?)\n\[" , inistring , re .DOTALL )
302302 if section : section = section .group (1 )
303303 newini .write ("\n [TRAJ]\n " )
304304 if section != None :
305305 if not re .search ("MAX_LINEAR_VELOCITY" , section ):
306306 if re .search ("MAX_VELOCITY" , section ):
307307 section = re .sub ("MAX_VELOCITY" , "MAX_LINEAR_VELOCITY" , section )
308308 else :
309- mv = re .findall ("MAX_VELOCITY[\s=]+(\d*(\.\d+)?)" , inistring , re .MULTILINE )
309+ mv = re .findall (r "MAX_VELOCITY[\s=]+(\d*(\.\d+)?)" , inistring , re .MULTILINE )
310310 section = ("\n # this value based on fastest single axis" +
311311 "\n MAX_LINEAR_VELOCITY = %s" % max (mv )[0 ] + section )
312312 if not re .search ("DEFAULT_LINEAR_VELOCITY" , section ):
@@ -338,8 +338,8 @@ def writeifexists(file, section, src_item, dest_item = "None"):
338338 L2J = {}
339339 while 1 :
340340 # Search preferentially in "[JOINT_N] in case the file is part-converted already
341- if re .search ("^(\[JOINT_%i\])" % j , inistring , re .MULTILINE ):
342- if re .search ("^(\[AXIS_%s\])" % "XYZABCUVW" [j ], inistring , re .MULTILINE ):
341+ if re .search (r "^(\[JOINT_%i\])"% j , inistring , re .MULTILINE ):
342+ if re .search (r "^(\[AXIS_%s\])" % "XYZABCUVW" [j ], inistring , re .MULTILINE ):
343343 copysection ("AXIS_%s" % "XYZABCUVW" [j ])
344344 # copysection("JOINT_%i" % j)
345345 elif j < len (coordinates ):
@@ -385,17 +385,17 @@ def writeifexists(file, section, src_item, dest_item = "None"):
385385 for J in L2J [L ]:
386386 # Take the coordinates index as the JOINT_Number
387387 newini .write ("\n [JOINT_%i]" % J )
388- section = re .search ("\[AXIS_%i\](.+?)(\n \[|$)" % J , inistring , re .DOTALL )
388+ section = re .search (r "\[AXIS_%i\](.+?)(\n\[|$)" % J , inistring , re .DOTALL )
389389 if not section :
390- section = re .search ("\[AXIS_%i\](.+?)(\n \[|$)" % "XYZABCUVW" .index (coordinates [J ]), inistring , re .DOTALL )
390+ section = re .search (r "\[AXIS_%i\](.+?)(\n\[|$)" % "XYZABCUVW" .index (coordinates [J ]), inistring , re .DOTALL )
391391 if section :
392392 section = re .sub ("HOME_SEQUENCE.*" , sequence , section .group (1 ))
393393 newini .write (section )
394- if not '\[AXIS_%i\]' % axisnum in subs :
395- subs .update ({'\[AXIS_%i\]' % axisnum : '[JOINT_%i]' % J })
396- subs2 .update ({'joint\.%i\.' % axisnum : 'joint.%i.' % J })
394+ if not r '\[AXIS_%i\]' % axisnum in subs :
395+ subs .update ({r '\[AXIS_%i\]' % axisnum : '[JOINT_%i]' % J })
396+ subs2 .update ({r 'joint\.%i\.' % axisnum : 'joint.%i.' % J })
397397 else :
398- subs .update ({'\[AXIS_%i\]' % J : '[JOINT_%i]' % J })
398+ subs .update ({r '\[AXIS_%i\]' % J : '[JOINT_%i]' % J })
399399 else :
400400 print ("File parsing error, found an [AXIS_%i] section, but no content" % J )
401401 exit ()
@@ -484,7 +484,7 @@ def writeifexists(file, section, src_item, dest_item = "None"):
484484 'halui.joint.selected' : 'halui.joint.selected' ,
485485 'halui.joint.selected.is_homed' :'halui.joint.selected.is-homed' ,
486486 'halui.joint.selected.on-soft-limit' :'halui.joint.selected.on-soft-max-limit' ,
487- 'num_joints=\ [TRAJ\ ]AXES' : 'num_joints=[KINS]JOINTS' ,
487+ 'num_joints=[TRAJ]AXES' : 'num_joints=[KINS]JOINTS' ,
488488 'loadrt(.+kins)' : 'loadrt [KINS]KINEMATICS\n #autoconverted \\ 1' ,
489489 'shuttlexpress' : 'shuttle' ,
490490 'shuttlepro' : 'shuttle' ,
@@ -495,7 +495,7 @@ def writeifexists(file, section, src_item, dest_item = "None"):
495495
496496 # converts @axN@ pattern to axis.L and splits any malformed setp from mpg
497497 subs2 .update ({
498- '^\s*setp\s+(joint\S+)\s+(axis\S+)\s+(\S+)\s*$' :
498+ r '^\s*setp\s+(joint\S+)\s+(axis\S+)\s+(\S+)\s*$' :
499499 'setp \\ 1 \\ 3\n setp \\ 2 \\ 3\n ' ,
500500 '@ax0@' : 'axis.x' ,
501501 '@ax1@' : 'axis.y' ,
0 commit comments