diff --git a/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py b/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py index a9f0e083dc..3008d6e032 100644 --- a/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py +++ b/src/Mod/CAM/Path/Post/scripts/KineticNCBeamicon2_post.py @@ -56,7 +56,10 @@ KineticNCBeamicon2_post.export(object,"/path/to/file.ncc","") now = datetime.datetime.now() -parser = argparse.ArgumentParser(prog="linuxcnc", add_help=False) +parser = argparse.ArgumentParser( + prog="linuxcnc", + add_help=False, +) parser.add_argument("--no-header", action="store_true", help="suppress header output") parser.add_argument("--no-comments", action="store_true", help="suppress comment output") parser.add_argument("--line-numbers", action="store_true", help="prefix with line numbers") @@ -68,11 +71,11 @@ parser.add_argument( parser.add_argument("--precision", default="3", help="number of digits of precision, default=3") parser.add_argument( "--preamble", - help='set commands to be issued before the first command, default="%\\nG17 G21 G40 G49 G80 G90\\nM08\\n"', + help=r'set commands to be issued before the first command, default="%%\nG17 G21 G40 G49 G80 G90\nM08\n"', ) parser.add_argument( "--postamble", - help='set commands to be issued after the last command, default="M05 M09\\nG17 G90 G80 G40\\nM30\\n"', + help=r'set commands to be issued after the last command, default="M05 M09\nG17 G90 G80 G40\nM30\n"', ) parser.add_argument( "--inches", action="store_true", help="Convert output for US imperial mode (G20)" diff --git a/src/Mod/CAM/Path/Post/scripts/snapmaker_post.py b/src/Mod/CAM/Path/Post/scripts/snapmaker_post.py index 7606c18276..1b13581edc 100644 --- a/src/Mod/CAM/Path/Post/scripts/snapmaker_post.py +++ b/src/Mod/CAM/Path/Post/scripts/snapmaker_post.py @@ -65,7 +65,7 @@ class CoordinatesAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): match = re.match( - "^\s*(?P-?\d+\.?\d*),?\s*(?P-?\d+\.?\d*),?\s*(?P-?\d+\.?\d*)\s*$", values + r"^\s*(?P-?\d+\.?\d*),?\s*(?P-?\d+\.?\d*),?\s*(?P-?\d+\.?\d*)\s*$", values ) if match: # setattr(namespace, self.dest, 'G0 X{0} Y{1} Z{2}'.format(*match.groups())) @@ -79,7 +79,7 @@ class ExtremaAction(argparse.Action): """argparse Action to handle integer extrema (min,max)""" def __call__(self, parser, namespace, values, option_string=None): - if match := re.match("^ *(\d+),? *(\d+) *$", values): + if match := re.match(r"^ *(\d+),? *(\d+) *$", values): # setattr(namespace, self.dest, 'G0 X{0} Y{1} Z{2}'.format(*match.groups())) params = { key: int(value) @@ -507,7 +507,7 @@ class Snapmaker(Path.Post.Processor.PostProcessor): for index, commandline in enumerate( gcode ): # .split(self.values["END_OF_LINE_CHARACTERS"]): - if match := re.match("(?PM0?[34])\D.*(?PS\d+.?\d*)", commandline): + if match := re.match(r"(?PM0?[34])\D.*(?PS\d+.?\d*)", commandline): percent = ( float(match.group("spindle")[1:]) * 100 / self.values["SPINDLE_SPEEDS"]["max"] ) @@ -528,13 +528,13 @@ class Snapmaker(Path.Post.Processor.PostProcessor): relative = False for index, commandline in enumerate(gcode): - if re.match("G90(?:\D|$)", commandline): + if re.match(r"G90(?:\D|$)", commandline): relative = False - elif re.match("G91(?:\D|$)", commandline): + elif re.match(r"G91(?:\D|$)", commandline): relative = True - elif re.match("G0?[12](?:\D|$)", commandline): + elif re.match(r"G0?[12](?:\D|$)", commandline): for axis, value in re.findall( - "(?P[XYZ])(?P-?\d+\.?\d*)(?:\D|$)", commandline + r"(?P[XYZ])(?P-?\d+\.?\d*)(?:\D|$)", commandline ): if relative: position[axis] += float(value)