Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix escape sequences in regular expressions #1837

Merged
merged 1 commit into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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