From 189cb6be5bc553835dbbff5a3d9e30cedd9c7fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Mon, 5 Dec 2022 16:52:54 +0100 Subject: [PATCH] [nodes] Use raw strings for parameters that contain regular expressions Regular expressions in regular strings generate deprecation warnings with Python 3 ("invalid escape sequence \x"). To fix these warnings, the regex must be contained within a raw string. For nodes that have parameters whose description and/or value contain regex, the strings are transformed into raw strings. In the case of descriptions, which are generally written across several lines, regular strings are concatenated with regular strings to preserve line returns (with "\n", which becomes uneffective in raw strings). --- meshroom/nodes/aliceVision/CameraInit.py | 6 +++--- meshroom/nodes/aliceVision/SfMAlignment.py | 8 ++++---- meshroom/nodes/aliceVision/SfMTransfer.py | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/meshroom/nodes/aliceVision/CameraInit.py b/meshroom/nodes/aliceVision/CameraInit.py index 406123ea..feb529cd 100644 --- a/meshroom/nodes/aliceVision/CameraInit.py +++ b/meshroom/nodes/aliceVision/CameraInit.py @@ -222,9 +222,9 @@ The metadata needed are: description='Regex used to catch number used as viewId in filename.' 'You should capture specific parts of the filename with parenthesis to define matching elements. (only number will works)\n' 'Some examples of patterns:\n' - ' - Match the longest number at the end of filename (default value): ".*?(\d+)"\n' - ' - Match the first number found in filename : "(\d+).*"\n', - value='.*?(\d+)', + r' - Match the longest number at the end of filename (default value): ".*?(\d+)"' + '\n' + + r' - Match the first number found in filename : "(\d+).*"', + value=r'.*?(\d+)', uid=[], advanced=True, enabled=lambda node: node.viewIdMethod.value == 'filename', diff --git a/meshroom/nodes/aliceVision/SfMAlignment.py b/meshroom/nodes/aliceVision/SfMAlignment.py index accd9bfb..a001f7cd 100644 --- a/meshroom/nodes/aliceVision/SfMAlignment.py +++ b/meshroom/nodes/aliceVision/SfMAlignment.py @@ -57,10 +57,10 @@ The alignment can be based on: description='Matching regular expression for the "from_cameras_filepath" method. ' 'You should capture specific parts of the filepath with parenthesis to define matching elements.\n' 'Some examples of patterns:\n' - ' - Match the filename without extension (default value): ".*\/(.*?)\.\w{3}"\n' - ' - Match the filename suffix after "_": ".*\/.*(_.*?\.\w{3})"\n' - ' - Match the filename prefix before "_": ".*\/(.*?)_.*\.\w{3}"\n', - value='.*\/(.*?)\.\w{3}', + r' - Match the filename without extension (default value): ".*\/(.*?)\.\w{3}"' + '\n' + + r' - Match the filename suffix after "_": ".*\/.*(_.*?\.\w{3})"' + '\n' + + r' - Match the filename prefix before "_": ".*\/(.*?)_.*\.\w{3}"', + value=r'.*\/(.*?)\.\w{3}', uid=[0], ), desc.ListAttribute( diff --git a/meshroom/nodes/aliceVision/SfMTransfer.py b/meshroom/nodes/aliceVision/SfMTransfer.py index edc5acff..22f1313a 100644 --- a/meshroom/nodes/aliceVision/SfMTransfer.py +++ b/meshroom/nodes/aliceVision/SfMTransfer.py @@ -48,10 +48,10 @@ This node allows to transfer poses and/or intrinsics form one SfM scene onto ano description='Matching regular expression for the "from_cameras_filepath" method. ' 'You should capture specific parts of the filepath with parenthesis to define matching elements.\n' 'Some examples of patterns:\n' - ' - Match the filename without extension (default value): ".*\/(.*?)\.\w{3}"\n' - ' - Match the filename suffix after "_": ".*\/.*(_.*?\.\w{3})"\n' - ' - Match the filename prefix before "_": ".*\/(.*?)_.*\.\w{3}"\n', - value='.*\/(.*?)\.\w{3}', + r' - Match the filename without extension (default value): ".*\/(.*?)\.\w{3}"' + '\n' + + r' - Match the filename suffix after "_": ".*\/.*(_.*?\.\w{3})"' + '\n' + + r' - Match the filename prefix before "_": ".*\/(.*?)_.*\.\w{3}"', + value=r'.*\/(.*?)\.\w{3}', uid=[0], ), desc.ListAttribute(