Skip to content

Commit

Permalink
Merge pull request #571 from inguin/python-syntax-warnings
Browse files Browse the repository at this point in the history
Fix syntax warnings with Python 3.12
  • Loading branch information
mraineri authored Jan 19, 2024
2 parents 24715d5 + 6bd330f commit 38cb8e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions redfish_service_validator/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

REDFISH_ABSENT = "n/a"

URI_ID_REGEX = '\{[A-Za-z0-9]*Id\}'
URI_ID_REGEX = r'\{[A-Za-z0-9]*Id\}'

VALID_ID_REGEX = '([A-Za-z0-9.!#$&-;=?\[\]_~])+'
VALID_ID_REGEX = r'([A-Za-z0-9.!#$&-;=?\[\]_~])+'


# Excerpt definitions
Expand Down
8 changes: 4 additions & 4 deletions redfish_service_validator/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def splitVersionString(v_string):
:return: tuple of integers
"""
if(re.match('([a-zA-Z0-9_.-]*\.)+[a-zA-Z0-9_.-]*', v_string) is not None):
if(re.match(r'([a-zA-Z0-9_.-]*\.)+[a-zA-Z0-9_.-]*', v_string) is not None):
new_string = getVersion(v_string)
if new_string is not None:
v_string = new_string
Expand Down Expand Up @@ -161,7 +161,7 @@ def checkPayloadConformance(jsondata, uri):
if odata_name == 'odata.id':
paramPass = isinstance(decoded[key], str)
paramPass = re.match(
'(\/.*)+(#([a-zA-Z0-9_.-]*\.)+[a-zA-Z0-9_.-]*)?', decoded[key]) is not None
r'(\/.*)+(#([a-zA-Z0-9_.-]*\.)+[a-zA-Z0-9_.-]*)?', decoded[key]) is not None
if not paramPass:
my_logger.error("{} {}: Expected format is /path/to/uri, but received: {}".format(uri, key, decoded[key]))
else:
Expand All @@ -174,15 +174,15 @@ def checkPayloadConformance(jsondata, uri):
elif odata_name == 'odata.context':
paramPass = isinstance(decoded[key], str)
paramPass = re.match(
'/redfish/v1/\$metadata#([a-zA-Z0-9_.-]*\.)[a-zA-Z0-9_.-]*', decoded[key]) is not None
r'/redfish/v1/\$metadata#([a-zA-Z0-9_.-]*\.)[a-zA-Z0-9_.-]*', decoded[key]) is not None
if not paramPass:
my_logger.warning("{} {}: Expected format is /redfish/v1/$metadata#ResourceType, but received: {}".format(uri, key, decoded[key]))
info[key] = (decoded[key], 'odata', 'Exists', 'WARN')
continue
elif odata_name == 'odata.type':
paramPass = isinstance(decoded[key], str)
paramPass = re.match(
'#([a-zA-Z0-9_.-]*\.)+[a-zA-Z0-9_.-]*', decoded[key]) is not None
r'#([a-zA-Z0-9_.-]*\.)+[a-zA-Z0-9_.-]*', decoded[key]) is not None
if not paramPass:
my_logger.error("{} {}: Expected format is #Namespace.Type, but received: {}".format(uri, key, decoded[key]))
else:
Expand Down

0 comments on commit 38cb8e5

Please sign in to comment.