Use raw string notation for regexes in hacking checks

Since regular expressions typically include lots of '\', raw
strings should be used for regexes, to prevent the '\' being
intepreted as a string escape character.

Change-Id: I7e131bc50bb31dde979541924b143123da39e3b8
This commit is contained in:
Daniel P. Berrange
2014-02-10 16:46:19 +00:00
parent 1efa961e18
commit 8ae82075d4

View File

@@ -29,13 +29,14 @@ Guidelines for writing new hacking checks
"""
session_check = re.compile("\w*def [a-zA-Z0-9].*[(].*session.*[)]")
cfg_re = re.compile(".*\scfg\.")
vi_header_re = re.compile("^#\s+vim?:.+")
virt_file_re = re.compile("\./nova/(?:tests/)?virt/(\w+)/")
session_check = re.compile(r"\w*def [a-zA-Z0-9].*[(].*session.*[)]")
cfg_re = re.compile(r".*\scfg\.")
vi_header_re = re.compile(r"^#\s+vim?:.+")
virt_file_re = re.compile(r"\./nova/(?:tests/)?virt/(\w+)/")
virt_import_re = re.compile(
"^\s*(?:import|from) nova\.(?:tests\.)?virt\.(\w+)")
virt_config_re = re.compile("CONF\.import_opt\('.*?', 'nova\.virt\.(\w+)('|.)")
r"^\s*(?:import|from) nova\.(?:tests\.)?virt\.(\w+)")
virt_config_re = re.compile(
r"CONF\.import_opt\('.*?', 'nova\.virt\.(\w+)('|.)")
def import_no_db_in_virt(logical_line, filename):