Fix deprecation escape sequence errors under 3.6

Python 3.6 is more strict about strings containing escape sequences.
We've cleaned up other regex strings but a few sneaked back in. This
converts a few more instances to raw strings to get rid of the escape
warnings.

Change-Id: I102a3b27a2f8e55de117007b183d5c4ad40284fb
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2019-04-04 12:20:38 -05:00
parent 06ab31adce
commit 6c9609911d
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
4 changed files with 12 additions and 12 deletions

View File

@ -417,12 +417,12 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
def _get_regexes(self): def _get_regexes(self):
text = r'(\\"|[^"])*' text = r'(\\"|[^"])*'
isotime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}Z' isotime_re = r'\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}Z'
strtime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}\.\d{6}' strtime_re = r'\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}\.\d{6}'
extension_update = ( extension_update = (
'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}') r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}')
strtime_url_re = ('\d{4}-[0,1]\d-[0-3]\d' strtime_url_re = (r'\d{4}-[0,1]\d-[0-3]\d'
'\+\d{2}\%3A\d{2}\%3A\d{2}\.\d{6}') r'\+\d{2}\%3A\d{2}\%3A\d{2}\.\d{6}')
return { return {
'isotime': isotime_re, 'isotime': isotime_re,
@ -436,7 +436,7 @@ class ApiSampleTestBase(functional_helpers._FunctionalTestBase):
'-[0-9a-f]{4}-[0-9a-f]{12}', '-[0-9a-f]{4}-[0-9a-f]{12}',
'request_id': 'req-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}' 'request_id': 'req-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}'
'-[0-9a-f]{4}-[0-9a-f]{12}', '-[0-9a-f]{4}-[0-9a-f]{12}',
'host': 'https?://[0-9]+(?:\.[0-9]+){3}:[0-9]+', 'host': r'https?://[0-9]+(?:\.[0-9]+){3}:[0-9]+',
'host_name': r'\w+', 'host_name': r'\w+',
'glance_host': self._get_glance_host(), 'glance_host': self._get_glance_host(),
'os-vol-host-attr:host': self.volume.host, 'os-vol-host-attr:host': self.volume.host,

View File

@ -30,18 +30,18 @@ class FakeSession(test_utils.FakeBaseSession):
'/storagePool$': '/storagePool$':
{'storagePools': [{'poolName': 'fake_pool_name', {'storagePools': [{'poolName': 'fake_pool_name',
'poolId': 'fake_pool_id'}]}, 'poolId': 'fake_pool_id'}]},
'/storagePool\?poolId=0': r'/storagePool\?poolId=0':
{'storagePools': [{'poolName': 'fake_pool_name1', {'storagePools': [{'poolName': 'fake_pool_name1',
'poolId': 0}]}, 'poolId': 0}]},
'/volume/queryByName\?volName=fake_name': r'/volume/queryByName\?volName=fake_name':
{'errorCode': 0, 'lunDetailInfo': {'errorCode': 0, 'lunDetailInfo':
[{'volume_id': 'fake_id', [{'volume_id': 'fake_id',
'volume_name': 'fake_name'}]}, 'volume_name': 'fake_name'}]},
'/volume/queryById\?volId=fake_id': r'/volume/queryById\?volId=fake_id':
{'errorCode': 0, 'lunDetailInfo': {'errorCode': 0, 'lunDetailInfo':
[{'volume_id': 'fake_id', [{'volume_id': 'fake_id',
'volume_name': 'fake_name'}]}, 'volume_name': 'fake_name'}]},
'/lun/wwn/list\?wwn=fake_wwn': r'/lun/wwn/list\?wwn=fake_wwn':
{'errorCode': 0, 'lunDetailInfo': {'errorCode': 0, 'lunDetailInfo':
[{'volume_id': 'fake_id', [{'volume_id': 'fake_id',
'volume_wwn': 'fake_wwn'}]}, 'volume_wwn': 'fake_wwn'}]},

View File

@ -328,7 +328,7 @@ class HuaweiConf(object):
if ini_type in dev: if ini_type in dev:
# Analyze initiators configure text, convert to: # Analyze initiators configure text, convert to:
# [{'Name':'xxx'}, {'Name':'xxx','CHAPinfo':'mm-usr#mm-pwd'}] # [{'Name':'xxx'}, {'Name':'xxx','CHAPinfo':'mm-usr#mm-pwd'}]
ini_list = re.split('\s', dev[ini_type]) ini_list = re.split(r'\s', dev[ini_type])
def _convert_one_iscsi_info(ini_text): def _convert_one_iscsi_info(ini_text):
# get initiator configure attr list # get initiator configure attr list

View File

@ -372,7 +372,7 @@ def get_export_host_junction_path(share):
if '[' in share and ']' in share: if '[' in share and ']' in share:
try: try:
# ipv6 # ipv6
host = re.search('\[(.*)\]', share).group(1) host = re.search(r'\[(.*)\]', share).group(1)
junction_path = share.split(':')[-1] junction_path = share.split(':')[-1]
except AttributeError: except AttributeError:
raise exception.NetAppDriverException(_("Share '%s' is " raise exception.NetAppDriverException(_("Share '%s' is "