From d0a579cf4ba34394b15fe0af662b62c12845bd82 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 24 Feb 2021 01:28:46 +0100 Subject: [PATCH] Fixed old regex sequences to r'' format --- platypush/message/event/__init__.py | 6 +++--- platypush/message/request/__init__.py | 4 ++-- platypush/procedure/__init__.py | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/platypush/message/event/__init__.py b/platypush/message/event/__init__.py index 3a0f83c88f..6c6cbe798d 100644 --- a/platypush/message/event/__init__.py +++ b/platypush/message/event/__init__.py @@ -119,8 +119,8 @@ class Event(Message): """ result = EventMatchResult(is_match=False) - event_tokens = re.split('\s+', self.args[argname].strip().lower()) - condition_tokens = re.split('\s+', condition_value.strip().lower()) + event_tokens = re.split(r'\s+', self.args[argname].strip().lower()) + condition_tokens = re.split(r'\s+', condition_value.strip().lower()) while event_tokens and condition_tokens: event_token = event_tokens[0] @@ -138,7 +138,7 @@ class Event(Message): condition_tokens.pop(0) else: - m = re.match('[^\\\]*\${(.+?)}', condition_token) + m = re.match(r'[^\\\]*\${(.+?)}', condition_token) if m: argname = m.group(1) if argname not in result.parsed_args: diff --git a/platypush/message/request/__init__.py b/platypush/message/request/__init__.py index 690b7c349d..710e2b429c 100644 --- a/platypush/message/request/__init__.py +++ b/platypush/message/request/__init__.py @@ -129,7 +129,7 @@ class Request(Message): except: if isinstance(v, str): try: - exec('{}="{}"'.format(k, re.sub('(^|[^\\\])"', '\1\\"', v))) + exec('{}="{}"'.format(k, re.sub(r'(^|[^\\\])"', '\1\\"', v))) except: pass @@ -138,7 +138,7 @@ class Request(Message): parsed_value = _value while _value and isinstance(_value, str): - m = re.match('([^$]*)(\${\s*(.+?)\s*})(.*)', _value) + m = re.match(r'([^$]*)(\${\s*(.+?)\s*})(.*)', _value) if m and not m.group(1).endswith('\\'): prefix = m.group(1) expr = m.group(2) diff --git a/platypush/procedure/__init__.py b/platypush/procedure/__init__.py index 83872b6ca4..591a922496 100644 --- a/platypush/procedure/__init__.py +++ b/platypush/procedure/__init__.py @@ -58,7 +58,7 @@ class Procedure(object): # Check if this request is an if-else if len(request_config.keys()) >= 1: key = list(request_config.keys())[0] - m = re.match('\s*(if)\s+\${(.*)}\s*', key) + m = re.match(r'\s*(if)\s+\${(.*)}\s*', key) if m: if_count += 1 @@ -94,7 +94,7 @@ class Procedure(object): # Check if this request is a for loop if len(request_config.keys()) == 1: key = list(request_config.keys())[0] - m = re.match('\s*(fork?)\s+([\w\d_]+)\s+in\s+(.*)\s*', key) + m = re.match(r'\s*(fork?)\s+([\w\d_]+)\s+in\s+(.*)\s*', key) if m: for_count += 1 @@ -118,7 +118,7 @@ class Procedure(object): # Check if this request is a while loop if len(request_config.keys()) == 1: key = list(request_config.keys())[0] - m = re.match('\s*while\s+\${(.*)}\s*', key) + m = re.match(r'\s*while\s+\${(.*)}\s*', key) if m: while_count += 1 @@ -145,6 +145,7 @@ class Procedure(object): pending_if = if_config.get() reqs.append(IfProcedure.build(**pending_if)) + # noinspection PyArgumentList return procedure_class(name=name, _async=_async, requests=reqs, args=args, backend=backend, **kwargs) @staticmethod @@ -338,7 +339,7 @@ class WhileProcedure(LoopProcedure): if isinstance(v, str): # noinspection PyBroadException try: - context[k] = eval('"{}"'.format(re.sub('(^|[^\\\])"', '\1\\"', v))) + context[k] = eval('"{}"'.format(re.sub(r'(^|[^\\\])"', '\1\\"', v))) except: pass @@ -451,7 +452,7 @@ class IfProcedure(Procedure): except: if isinstance(v, str): try: - exec('{}="{}"'.format(k, re.sub('(^|[^\\\])"', '\1\\"', v))) + exec('{}="{}"'.format(k, re.sub(r'(^|[^\\\])"', '\1\\"', v))) except: pass