From f097e5da0ef8fafc0e2c65f4ea44082da9fb48f0 Mon Sep 17 00:00:00 2001 From: Samuel Abels Date: Sat, 19 Apr 2025 00:25:34 +0200 Subject: [PATCH] CAM: fix invalid syntax in snapmaker_post that caused test warnings --- src/Mod/CAM/Path/Post/scripts/snapmaker_post.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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)