---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v2.4.0 # Use the ref you want to point at
+ rev: v4.1.0 # Use the ref you want to point at
hooks:
- - id: flake8
- language_version: python3
- additional_dependencies: ['flake8~=3.5.0']
- id: trailing-whitespace
# this hook will remove any blank lines at the end of a file, whereas the robot hook will add one
# so to prevent this conflict we will ignore .robot files in this trailing-whitespace hook
exclude: '\.robot'
+ - repo: https://github.com/PyCQA/flake8
+ rev: 4.0.1
+ hooks:
+ - id: flake8
+
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
if "dependency" in tag:
for one_dependency in tag["dependency"]:
_context_id = re.findall(
- "\d{8}-\d{4}-\d{4}-\d{4}-\d{12}", one_dependency
+ r"\d{8}-\d{4}-\d{4}-\d{4}-\d{12}", one_dependency
)[0]
if _context_id == context_id:
long_resource_id = re.findall(
- "resource-id='[a-zA-Z\-]*'", one_dependency
+ r"resource-id='[a-zA-Z\-]*'", one_dependency
)[0]
short_resource_id = re.findall("'.*'", long_resource_id)[0]
_resource_id = short_resource_id.replace("'", "")
"""Verifies two hex messages are equal even in case, their arguments are misplaced.
Converts hex message arguments to integers and sums them up and returns the sum."""
return sum(
- [int(x, 16) for x in re.compile("[a-f\d]{2}").findall(hex_string[32:])]
+ [int(x, 16) for x in re.compile(r"[a-f\d]{2}").findall(hex_string[32:])]
)
# |---------------------------------(0)---------------------------------|
# |------(1)-------||------(2)-----|
matches = re.search(
- "(.*0x)(\w+) +Connected", self.datapath_id_output_string
+ r"(.*0x)(\w+) +Connected", self.datapath_id_output_string
)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)
# Datapath ID : 000af0921c22bac0
# |-----------------(0)---------------------|
# |-----------(1)----------| |------(2)-----|
- matches = re.search("(.*: )(\w+)", self.datapath_id_output_string)
+ matches = re.search(r"(.*: )(\w+)", self.datapath_id_output_string)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)
iso_result = "pass"
for controller in controllers:
controller_regex_string = (
- "[\s\S]*" + isolated_controller + " *" + controller + "[\s\S]*"
+ r"[\s\S]*" + isolated_controller + " *" + controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if not controller_regex.match(ip_tables):
iso_result = ip_tables
controller_regex_string = (
- "[\s\S]*" + controller + " *" + isolated_controller + "[\s\S]*"
+ r"[\s\S]*" + controller + " *" + isolated_controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if not controller_regex.match(ip_tables):
iso_result = "pass"
for controller in controllers:
controller_regex_string = (
- "[\s\S]*" + isolated_controller + " *" + controller + "[\s\S]*"
+ r"[\s\S]*" + isolated_controller + " *" + controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if controller_regex.match(ip_tables):
iso_result = ip_tables
controller_regex_string = (
- "[\s\S]*" + controller + " *" + isolated_controller + "[\s\S]*"
+ r"[\s\S]*" + controller + " *" + isolated_controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if controller_regex.match(ip_tables):
def notvar(m):
return "'%s' not in __obj" % m.group(1)
- loc = re.sub("!@\.([a-zA-Z@_]+)", notvar, loc)
+ loc = re.sub(r"!@\.([a-zA-Z@_]+)", notvar, loc)
# replace @.name.... with __obj['name']....
# handle @.name[.name...].length
# Determine distribution version
distribution_name = os.path.splitext(os.path.basename(self.distribution))[0]
distribution_ver = re.search(
- "(\d+\.\d+\.\d+-\w+\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-RC\d+\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-RC\d+(\.\d+)\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-SR\d+\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-SR\d+(\.\d+)\Z)",
+ r"(\d+\.\d+\.\d+-\w+\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-RC\d+\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-RC\d+(\.\d+)\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-SR\d+\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-SR\d+(\.\d+)\Z)",
distribution_name,
) # noqa
if re.search("openflow", inv[n]["id"]) is not None:
sinv.append(inv[n])
- sinv = sorted(sinv, key=lambda k: int(re.findall("\d+", k["id"])[0]))
+ sinv = sorted(sinv, key=lambda k: int(re.findall(r"\d+", k["id"])[0]))
for n in range(len(sinv)):
try: