Skip to content

Commit

Permalink
fix escape sequences in regular expressions (#1837)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgpfeiffer authored and mikepurvis committed Nov 23, 2019
1 parent 89cdd76 commit 796ef0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tools/rosgraph/src/rosgraph/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def load_mappings(argv):
import re

#~,/, or ascii char followed by (alphanumeric, _, /)
NAME_LEGAL_CHARS_P = re.compile('^[\~\/A-Za-z][\w\/]*$')
NAME_LEGAL_CHARS_P = re.compile(r'^[\~\/A-Za-z][\w\/]*$')
def is_legal_name(name):
"""
Check if name is a legal ROS name for graph resources
Expand All @@ -232,7 +232,7 @@ def is_legal_name(name):
m = NAME_LEGAL_CHARS_P.match(name)
return m is not None and m.group(0) == name and not '//' in name

BASE_NAME_LEGAL_CHARS_P = re.compile('^[A-Za-z][\w]*$') #ascii char followed by (alphanumeric, _)
BASE_NAME_LEGAL_CHARS_P = re.compile(r'^[A-Za-z][\w]*$') #ascii char followed by (alphanumeric, _)
def is_legal_base_name(name):
"""
Validates that name is a legal base name for a graph resource. A base name has
Expand All @@ -243,7 +243,7 @@ def is_legal_base_name(name):
m = BASE_NAME_LEGAL_CHARS_P.match(name)
return m is not None and m.group(0) == name

REMAP_PATTERN = re.compile('^([\~\/A-Za-z]|_|__)[\w\/]*' + REMAP + '.*')
REMAP_PATTERN = re.compile(r'^([\~\/A-Za-z]|_|__)[\w\/]*' + REMAP + '.*')

def is_legal_remap(arg):
"""
Expand Down
4 changes: 2 additions & 2 deletions tools/rosgraph/test/test_roslogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def test_rosconsole__logging_format():
log_out = ' '.join([
'INFO',
'on ' + loc,
'[0-9]*\.[0-9]*',
r'[0-9]*\.[0-9]*',
'[0-9]*',
'rosout',
re.escape(this_file),
'[0-9]*',
function,
# depending if rospy.get_name() is available
'(/unnamed|<unknown_node_name>)',
'[0-9]*\.[0-9]*',
r'[0-9]*\.[0-9]*',
])
assert_regexp_matches(lout.getvalue().splitlines()[i], log_out)

Expand Down
4 changes: 2 additions & 2 deletions tools/rosgraph/test/test_roslogging_user_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def test_roslogging_user_logger():
'INFO',
os.environ['ROS_IP'],
msg,
'[0-9]*\.[0-9]*',
r'[0-9]*\.[0-9]*',
'[0-9]*',
'rosout.custom_logger_test',
'<filename>',
'<lineno>',
'<func_name>',
# depending if rospy.get_name() is available
'(/unnamed|<unknown_node_name>)',
'[0-9]*\.[0-9]*',
r'[0-9]*\.[0-9]*',
])
assert_regexp_matches(lout.getvalue().strip(), log_expected)

Expand Down

0 comments on commit 796ef0c

Please sign in to comment.