rename set_local_raw to set_local
set_local_raw is the new set_local, adjust the code to use the better name. Change-Id: I0f16ca647ada37049bdaf570b4695a73b60007ec
This commit is contained in:
parent
de46354ed3
commit
cf9093ec58
|
@ -43,11 +43,11 @@ def extract_config(local_conf, args):
|
||||||
|
|
||||||
|
|
||||||
def setlc(local_conf, args):
|
def setlc(local_conf, args):
|
||||||
local_conf.set_local(args.name, args.value)
|
local_conf.set_local("%s=%s" % (args.name, args.value))
|
||||||
|
|
||||||
|
|
||||||
def setlc_raw(local_conf, args):
|
def setlc_raw(local_conf, args):
|
||||||
local_conf.set_raw(" ".join(args.items))
|
local_conf.set_local(" ".join(args.items))
|
||||||
|
|
||||||
|
|
||||||
def setlc_conf(local_conf, args):
|
def setlc_conf(local_conf, args):
|
||||||
|
|
|
@ -209,7 +209,7 @@ class LocalConf(object):
|
||||||
if not done:
|
if not done:
|
||||||
func(writer, None)
|
func(writer, None)
|
||||||
|
|
||||||
def set_local_raw(self, line):
|
def set_local(self, line):
|
||||||
if not os.path.exists(self.fname):
|
if not os.path.exists(self.fname):
|
||||||
with open(self.fname, "w+") as writer:
|
with open(self.fname, "w+") as writer:
|
||||||
writer.write("[[local|localrc]]\n")
|
writer.write("[[local|localrc]]\n")
|
||||||
|
@ -292,20 +292,7 @@ class LocalConf(object):
|
||||||
for group, conf in groups:
|
for group, conf in groups:
|
||||||
if group == "local":
|
if group == "local":
|
||||||
for line in lc._section(group, conf):
|
for line in lc._section(group, conf):
|
||||||
self.set_local_raw(line)
|
self.set_local(line)
|
||||||
# if line.startswith('#'):
|
|
||||||
# continue
|
|
||||||
# m = re.match(r"([^#=\s]+)\s*\=\s*(.+)", line)
|
|
||||||
|
|
||||||
# if m:
|
|
||||||
# self.set_local(m.group(1), m.group(2))
|
|
||||||
# elif re.match("(enable|disable)", line):
|
|
||||||
# # special case appending enable* disable*
|
|
||||||
# # function lines
|
|
||||||
# self.set_local_raw(line)
|
|
||||||
# else:
|
|
||||||
# print("SKIPPING ``%s`` from '%s'" %
|
|
||||||
# (line.lstrip(), lcfile))
|
|
||||||
else:
|
else:
|
||||||
for section, name, value in lc._conf(group, conf):
|
for section, name, value in lc._conf(group, conf):
|
||||||
self.set(group, conf, section, name, value)
|
self.set(group, conf, section, name, value)
|
||||||
|
|
|
@ -90,22 +90,22 @@ class TestLcSet(testtools.TestCase):
|
||||||
|
|
||||||
def test_set_new(self):
|
def test_set_new(self):
|
||||||
conf = dsconf.LocalConf(self._path)
|
conf = dsconf.LocalConf(self._path)
|
||||||
conf.set_local_raw("g=2")
|
conf.set_local("g=2")
|
||||||
with open(self._path) as f:
|
with open(self._path) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.assertEqual(content, RESULT1)
|
self.assertEqual(content, RESULT1)
|
||||||
|
|
||||||
def test_set_existing(self):
|
def test_set_existing(self):
|
||||||
conf = dsconf.LocalConf(self._path)
|
conf = dsconf.LocalConf(self._path)
|
||||||
conf.set_local_raw("a=2")
|
conf.set_local("a=2")
|
||||||
with open(self._path) as f:
|
with open(self._path) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.assertEqual(content, RESULT2)
|
self.assertEqual(content, RESULT2)
|
||||||
|
|
||||||
def test_set_raw(self):
|
def test_set_raw(self):
|
||||||
conf = dsconf.LocalConf(self._path)
|
conf = dsconf.LocalConf(self._path)
|
||||||
conf.set_local_raw("enable_plugin foo http://foo branch")
|
conf.set_local("enable_plugin foo http://foo branch")
|
||||||
conf.set_local_raw("enable_plugin bar http://foo branch")
|
conf.set_local("enable_plugin bar http://foo branch")
|
||||||
with open(self._path) as f:
|
with open(self._path) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.assertEqual(content, RESULT3)
|
self.assertEqual(content, RESULT3)
|
||||||
|
|
Loading…
Reference in New Issue