Use raw strings in all pattern matching strings

This removes some of the deprecation warnings on
unsupported escape sequence for python3.6 and up

Change-Id: Ibb70a8d5be79af89faf625b939bb959661231aa3
This commit is contained in:
Eyal 2019-08-07 14:36:54 +03:00
parent fc4bcc7805
commit f11565a317
11 changed files with 22 additions and 20 deletions

View File

@ -181,7 +181,7 @@ class CeilometerDriver(AlarmDriverBase):
def _convert_alarm(cls, alarm):
alarm_type = alarm.type
if alarm_type == CeilProps.EVENT and \
_is_vitrage_alarm(alarm.event_rule):
_is_vitrage_alarm(alarm.event_rule):
return cls._convert_vitrage_alarm(alarm)
elif alarm_type == CeilProps.EVENT:
return cls._convert_event_alarm(alarm)

View File

@ -124,6 +124,7 @@ class VitrageGraphInit(object):
def subscribe_presist_notifier(self):
self.graph.subscribe(PersistNotifier().notify_when_applicable)
PRIORITY_DELAY = 0.05

View File

@ -21,6 +21,7 @@ class ActionType(object):
MARK_DOWN = 'mark_down'
EXECUTE_MISTRAL = 'execute_mistral'
action_types = [ActionType.SET_STATE,
ActionType.RAISE_ALARM,
ActionType.ADD_CAUSAL_RELATIONSHIP,

View File

@ -68,7 +68,7 @@ def is_function(str):
A function has the format: func_name(params)
Search for a regex with open and close parenthesis
"""
return re.match('.*\(.*\)', str)
return re.match(r'.*\(.*\)', str)
def _is_wanted_function(str, func_name):
@ -77,4 +77,4 @@ def _is_wanted_function(str, func_name):
A function has the format: func_name(params)
Search for a regex with open and close parenthesis
"""
return re.match(func_name + '\(.*\)', str)
return re.match(func_name + r'\(.*\)', str)

View File

@ -132,7 +132,7 @@ def _validate_not_condition_relationships_recursive(dnf_result):
if isinstance(dnf_result, Not):
for arg in dnf_result.args:
if isinstance(arg, Symbol) and not str(arg).startswith(RELATION):
raise ValidationError(86, arg)
raise ValidationError(86, arg)
else:
_validate_not_condition_relationships_recursive(arg)
return
@ -143,5 +143,5 @@ def _validate_not_condition_relationships_recursive(dnf_result):
def _validate_positive_term_in_condition(dnf_condition):
if not dnf.is_condition_include_positive_clause(dnf_condition):
raise ValidationError(134)
if not dnf.is_condition_include_positive_clause(dnf_condition):
raise ValidationError(134)

View File

@ -19,10 +19,10 @@ mutable_default_args = re.compile(r"^\s*def .+\((.+={\}|.+=\[\])")
asse_trueinst_re = re.compile(
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
"(\w|\.|\'|\"|\[|\])+\)\)")
r"(\w|\.|\'|\"|\[|\])+\)\)")
asse_equal_type_re = re.compile(
r"(.)*assertEqual\(type\((\w|\.|\'|\"|\[|\])+\), "
"(\w|\.|\'|\"|\[|\])+\)")
r"(\w|\.|\'|\"|\[|\])+\)")
asse_equal_end_with_none_re = re.compile(
r"(.)*assertEqual\((\w|\.|\'|\"|\[|\])+, None\)")
asse_equal_start_with_none_re = re.compile(

View File

@ -82,7 +82,7 @@ class KeycloakAuth(base.ConfigurableMiddleware):
return realm_name
def process_request(self, req):
self._authenticate(req)
self._authenticate(req)
def _authenticate(self, req):
decoded = {}

View File

@ -40,8 +40,8 @@ NEXT = 'next'
WITH_VALS = 'with_values'
SEVERITY = 'SEVERITY'
ALARM_OID = 'ALARM_OID'
IP_PAT = re.compile('\d+\.\d+\.\d+\.\d+')
PORT_PAT = re.compile('\d+')
IP_PAT = re.compile(r'\d+\.\d+\.\d+\.\d+')
PORT_PAT = re.compile(r'\d+')
class SnmpSender(SnmpSenderBase):

View File

@ -146,7 +146,7 @@ class Webhook(NotifierBase):
if value is None:
return False
elif filter.match(value) is None:
return False
return False
return True
def _filter_fields(self, data):

View File

@ -43,8 +43,8 @@ class TransformerManagerTest(base.BaseTest):
self.manager = TransformerManager()
def test_transformer_registration_nagios(self):
self.assertIsInstance(self.manager.get_transformer
(NAGIOS_DATASOURCE), NagiosTransformer)
self.assertIsInstance(self.manager.get_transformer
(NAGIOS_DATASOURCE), NagiosTransformer)
def test_transformer_registration_nova_host(self):
self.assertIsInstance(self.manager.get_transformer

View File

@ -448,10 +448,10 @@ class TestGraph(GraphTestBase):
self.final_result = None
def _assert_none_or_equals(self, exp, act, msg):
if exp:
self.assertEqual(exp, act, msg)
else:
self.assertIsNone(act, msg)
if exp:
self.assertEqual(exp, act, msg)
else:
self.assertIsNone(act, msg)
# noinspection PyAttributeOutsideInit
def test_graph_callbacks(self):
@ -560,7 +560,7 @@ class TestFilter(base.BaseTest):
attr_filter = {
"vitrage_category": "ALARM",
"rawtext.regex": "Interface ([_a-zA-Z0-9'\-]+) down on {"
"rawtext.regex": r"Interface ([_a-zA-Z0-9'\-]+) down on {"
"HOST.NAME}",
"host": "some_host_kukoo"
}
@ -578,7 +578,7 @@ class TestFilter(base.BaseTest):
attr_filter = {
"vitrage_category": "ALARM",
"rawtext.RegEx": "Interface ([_a-zA-Z0-9'\-]+) down on {"
"rawtext.RegEx": r"Interface ([_a-zA-Z0-9'\-]+) down on {"
"HOST.NAME}",
"host": "some_host_kukoo"
}