Fix invalid escape sequence warnings

There are a lot of DeprecationWarning message emited when running
under python 3.6 due mostly to non-raw strings being used for
regex expressions.

DeprecationWarning: invalid escape sequence \

These had previously been ignored, but starting with python 3.6,
and the commit for issue 27364, these are now considered deprecated
and will no longer be supported going forward. Per the discussion
on that issue, these strings should really be raw strings any way:

https://bugs.python.org/issue27364#msg272696

Change-Id: If6ff206e4bbcf10ab52d2895f606dafad2936ddb
This commit is contained in:
Sean McGinnis 2018-06-20 16:00:16 -05:00
parent e396560f33
commit 09654af518
11 changed files with 12 additions and 12 deletions

View File

@ -38,7 +38,7 @@ UNDERSCORE_IMPORT_FILES = ['cinder/objects/__init__.py',
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
translated_log = re.compile(
r"(.)*LOG\.(audit|debug|error|info|warn|warning|critical|exception)"
"\(\s*_\(\s*('|\")")
r"\(\s*_\(\s*('|\")")
string_translation = re.compile(r"(.)*_\(\s*('|\")")
vi_header_re = re.compile(r"^#\s+vim?:.+")
underscore_import_check = re.compile(r"(.)*i18n\s+import(.)* _$")

View File

@ -587,7 +587,7 @@ class RBDTestCase(test.TestCase):
8 * units.Gi]
mock_get_image_status.side_effect = [
{'watchers': []},
{'watchers': [{"address": "192.168.120.61:0\/3012034728",
{'watchers': [{"address": "192.168.120.61:0/3012034728",
"client": 44431941, "cookie": 94077162321152}]},
{'watchers': []}]
res = self.driver.get_manageable_volumes(

View File

@ -1115,7 +1115,7 @@ class RemoteFSManageableVolumesTestCase(test.TestCase):
Exception,
mock.sentinel.managed_volume]
self._driver._MANAGEABLE_IMAGE_RE = re.compile('.*\.(?:vhdx)$')
self._driver._MANAGEABLE_IMAGE_RE = re.compile(r'.*\.(?:vhdx)$')
managed_volumes = {'volume-1': mock.sentinel.vol1}

View File

@ -238,7 +238,7 @@ class StorPoolTestCase(test.TestCase):
self.assertEqual('storpool', stats['storage_protocol'])
self.assertListEqual(['default', 'template_hdd', 'template_ssd'],
sorted([p['pool_name'] for p in stats['pools']]))
r = re.compile('^template_([A-Za-z0-9_]+)$')
r = re.compile(r'^template_([A-Za-z0-9_]+)$')
for pool in stats['pools']:
self.assertEqual(21, pool['total_capacity_gb'])
self.assertEqual(5, int(pool['free_capacity_gb']))

View File

@ -170,7 +170,7 @@ class DatastoreTest(test.TestCase):
ds1a: ds1a_props,
ds1b: ds1b_props}
profile_id = mock.sentinel.profile_id
self._ds_sel._ds_regex = re.compile("ds-[1-9a]{1,2}$")
self._ds_sel._ds_regex = re.compile(r"ds-[1-9a]{1,2}$")
datastores = self._ds_sel._filter_datastores(
datastores,
512,

View File

@ -165,7 +165,7 @@ volume_opts = [
'storage if the driver supports it.'),
cfg.StrOpt('max_over_subscription_ratio',
default='20.0',
regex='^(auto|\d*\.\d+|\d+)$',
regex=r'^(auto|\d*\.\d+|\d+)$',
help='Representation of the over subscription ratio '
'when thin provisioning is enabled. Default ratio is '
'20.0, meaning provisioned capacity can be 20 times of '

View File

@ -218,7 +218,7 @@ class VMAXUtils(object):
"""
element_name = volume_id
uuid_regex = (re.compile(
'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}',
r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}',
re.I))
match = uuid_regex.search(volume_id)
if match:

View File

@ -188,7 +188,7 @@ class MStorageISMCLI(object):
else:
out, err, status = self._execute_nolock(command)
exstats = re.compile("(.*)ExitStatus(.*)\n")
exstats = re.compile(r"(.*)ExitStatus(.*)\n")
tmpout = exstats.sub('', out)
out = tmpout
if conf_ismview_path is not None:

View File

@ -263,7 +263,7 @@ def get_pool_name_filter_regex(configuration):
# If the configuration parameter is specified as an empty string
# (interpreted as matching all pools), we replace it here with
# (.+) to be explicit with CSV compatibility support implemented below.
pool_patterns = configuration.netapp_pool_name_search_pattern or '(.+)'
pool_patterns = configuration.netapp_pool_name_search_pattern or r'(.+)'
# Strip whitespace from start/end and then 'or' all regex patterns
pool_patterns = '|'.join(['^' + pool_pattern.strip('^$ \t') + '$' for

View File

@ -91,7 +91,7 @@ class WindowsSmbfsDriver(remotefs_drv.RevertToSnapshotMixin,
_DISK_FORMAT_VHDX]
_VALID_IMAGE_EXTENSIONS = [_DISK_FORMAT_VHD, _DISK_FORMAT_VHDX]
_MANAGEABLE_IMAGE_RE = re.compile(
'.*\.(?:%s)$' % '|'.join(_VALID_IMAGE_EXTENSIONS),
r'.*\.(?:%s)$' % '|'.join(_VALID_IMAGE_EXTENSIONS),
re.IGNORECASE)
_always_use_temp_snap_when_cloning = False

View File

@ -790,7 +790,7 @@ def read_proc_mounts():
def extract_id_from_volume_name(vol_name):
regex = re.compile(
CONF.volume_name_template.replace('%s', '(?P<uuid>.+)'))
CONF.volume_name_template.replace('%s', r'(?P<uuid>.+)'))
match = regex.match(vol_name)
return match.group('uuid') if match else None
@ -813,7 +813,7 @@ def check_already_managed_volume(vol_id):
def extract_id_from_snapshot_name(snap_name):
"""Return a snapshot's ID from its name on the backend."""
regex = re.compile(
CONF.snapshot_name_template.replace('%s', '(?P<uuid>.+)'))
CONF.snapshot_name_template.replace('%s', r'(?P<uuid>.+)'))
match = regex.match(snap_name)
return match.group('uuid') if match else None