Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Change-Id: Ia1bbe6bd173435674075bee595001a7e8aa0d4ec
This commit is contained in:
parent
58e562be3a
commit
22a7d65de8
@ -37,11 +37,11 @@ class IniFile(object):
|
|||||||
|
|
||||||
with open(self.fname, "r+") as reader:
|
with open(self.fname, "r+") as reader:
|
||||||
for line in reader.readlines():
|
for line in reader.readlines():
|
||||||
m = re.match("\[([^\[\]]+)\]", line)
|
m = re.match(r"\[([^\[\]]+)\]", line)
|
||||||
if m:
|
if m:
|
||||||
current_section = m.group(1)
|
current_section = m.group(1)
|
||||||
if current_section == section:
|
if current_section == section:
|
||||||
if re.match("%s\s*\=" % name, line):
|
if re.match(r"%s\s*\=" % name, line):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class IniFile(object):
|
|||||||
with open(temp.name) as reader:
|
with open(temp.name) as reader:
|
||||||
for line in reader.readlines():
|
for line in reader.readlines():
|
||||||
writer.write(line)
|
writer.write(line)
|
||||||
m = re.match("\[([^\[\]]+)\]", line)
|
m = re.match(r"\[([^\[\]]+)\]", line)
|
||||||
if m and m.group(1) == section:
|
if m and m.group(1) == section:
|
||||||
found = True
|
found = True
|
||||||
writer.write("%s = %s\n" % (name, value))
|
writer.write("%s = %s\n" % (name, value))
|
||||||
@ -72,7 +72,7 @@ class IniFile(object):
|
|||||||
writer.write("[%s]\n" % section)
|
writer.write("[%s]\n" % section)
|
||||||
writer.write("%s = %s\n" % (name, value))
|
writer.write("%s = %s\n" % (name, value))
|
||||||
|
|
||||||
def _at_existing_key(self, section, name, func, match="%s\s*\="):
|
def _at_existing_key(self, section, name, func, match=r"%s\s*\="):
|
||||||
"""Run a function at a found key.
|
"""Run a function at a found key.
|
||||||
|
|
||||||
NOTE(sdague): if the file isn't found, we end up
|
NOTE(sdague): if the file isn't found, we end up
|
||||||
@ -86,7 +86,7 @@ class IniFile(object):
|
|||||||
with open(temp.name) as reader:
|
with open(temp.name) as reader:
|
||||||
with open(self.fname, "w+") as writer:
|
with open(self.fname, "w+") as writer:
|
||||||
for line in reader.readlines():
|
for line in reader.readlines():
|
||||||
m = re.match("\[([^\[\]]+)\]", line)
|
m = re.match(r"\[([^\[\]]+)\]", line)
|
||||||
if m:
|
if m:
|
||||||
current_section = m.group(1)
|
current_section = m.group(1)
|
||||||
if current_section == section:
|
if current_section == section:
|
||||||
@ -113,10 +113,10 @@ class IniFile(object):
|
|||||||
|
|
||||||
def uncomment(self, section, name):
|
def uncomment(self, section, name):
|
||||||
def _do_uncomment(writer, line):
|
def _do_uncomment(writer, line):
|
||||||
writer.write(re.sub("^#\s*", "", line))
|
writer.write(re.sub(r"^#\s*", "", line))
|
||||||
|
|
||||||
self._at_existing_key(section, name, _do_uncomment,
|
self._at_existing_key(section, name, _do_uncomment,
|
||||||
match="#\s*%s\s*\=")
|
match=r"#\s*%s\s*\=")
|
||||||
|
|
||||||
def set(self, section, name, value):
|
def set(self, section, name, value):
|
||||||
def _do_set(writer, line):
|
def _do_set(writer, line):
|
||||||
@ -136,7 +136,7 @@ class LocalConf(object):
|
|||||||
def _conf(self, group, conf):
|
def _conf(self, group, conf):
|
||||||
current_section = ""
|
current_section = ""
|
||||||
for line in self._section(group, conf):
|
for line in self._section(group, conf):
|
||||||
m = re.match("\[([^\[\]]+)\]", line)
|
m = re.match(r"\[([^\[\]]+)\]", line)
|
||||||
if m:
|
if m:
|
||||||
current_section = m.group(1)
|
current_section = m.group(1)
|
||||||
continue
|
continue
|
||||||
@ -169,7 +169,7 @@ class LocalConf(object):
|
|||||||
continue
|
continue
|
||||||
# any other meta section means we aren't in the
|
# any other meta section means we aren't in the
|
||||||
# section we want to be.
|
# section we want to be.
|
||||||
elif re.match("\[\[.*\|.*\]\]", line):
|
elif re.match(r"\[\[.*\|.*\]\]", line):
|
||||||
in_section = False
|
in_section = False
|
||||||
continue
|
continue
|
||||||
if in_section:
|
if in_section:
|
||||||
@ -267,7 +267,7 @@ class LocalConf(object):
|
|||||||
if re.match(re.escape("[[%s|%s]]" % (group, conf)), line):
|
if re.match(re.escape("[[%s|%s]]" % (group, conf)), line):
|
||||||
in_meta = True
|
in_meta = True
|
||||||
writer.write(line)
|
writer.write(line)
|
||||||
elif re.match("\[\[.*\|.*\]\]", line):
|
elif re.match(r"\[\[.*\|.*\]\]", line):
|
||||||
# if we're not done yet, we
|
# if we're not done yet, we
|
||||||
if in_meta:
|
if in_meta:
|
||||||
if not in_section:
|
if not in_section:
|
||||||
@ -283,7 +283,7 @@ class LocalConf(object):
|
|||||||
# we found a relevant section
|
# we found a relevant section
|
||||||
writer.write(line)
|
writer.write(line)
|
||||||
in_section = True
|
in_section = True
|
||||||
elif re.match("\[[^\[\]]+\]", line):
|
elif re.match(r"\[[^\[\]]+\]", line):
|
||||||
if in_meta and in_section:
|
if in_meta and in_section:
|
||||||
# We've ended our section, in our meta,
|
# We've ended our section, in our meta,
|
||||||
# never found the key. Time to add it.
|
# never found the key. Time to add it.
|
||||||
@ -292,7 +292,7 @@ class LocalConf(object):
|
|||||||
in_section = False
|
in_section = False
|
||||||
writer.write(line)
|
writer.write(line)
|
||||||
elif (in_meta and in_section and
|
elif (in_meta and in_section and
|
||||||
re.match("\s*%s\s*\=" % re.escape(name), line)):
|
re.match(r"\s*%s\s*\=" % re.escape(name), line)):
|
||||||
# we found our match point
|
# we found our match point
|
||||||
func(writer, line)
|
func(writer, line)
|
||||||
done = True
|
done = True
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# of appearance. Changing the order has an impact on the overall integration
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
|
|
||||||
hacking>=0.12.0,<0.13 # Apache-2.0
|
hacking>=3.0,<3.1.0 # Apache-2.0
|
||||||
|
|
||||||
coverage>=4.0 # Apache-2.0
|
coverage>=4.0 # Apache-2.0
|
||||||
python-subunit>=0.0.18 # Apache-2.0/BSD
|
python-subunit>=0.0.18 # Apache-2.0/BSD
|
||||||
|
4
tox.ini
4
tox.ini
@ -35,8 +35,8 @@ commands = oslo_debug_helper {posargs}
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
# W504 line break after binary operator
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E123,E125
|
ignore = E123,E125,W504
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||||
|
Loading…
Reference in New Issue
Block a user