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:
parent
fc4bcc7805
commit
f11565a317
@ -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)
|
||||
|
@ -124,6 +124,7 @@ class VitrageGraphInit(object):
|
||||
def subscribe_presist_notifier(self):
|
||||
self.graph.subscribe(PersistNotifier().notify_when_applicable)
|
||||
|
||||
|
||||
PRIORITY_DELAY = 0.05
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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(
|
||||
|
@ -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 = {}
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user