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:
Sean Dague 2017-02-10 17:01:42 -05:00
parent de46354ed3
commit cf9093ec58
3 changed files with 8 additions and 21 deletions

View File

@ -43,11 +43,11 @@ def extract_config(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):
local_conf.set_raw(" ".join(args.items))
local_conf.set_local(" ".join(args.items))
def setlc_conf(local_conf, args):

View File

@ -209,7 +209,7 @@ class LocalConf(object):
if not done:
func(writer, None)
def set_local_raw(self, line):
def set_local(self, line):
if not os.path.exists(self.fname):
with open(self.fname, "w+") as writer:
writer.write("[[local|localrc]]\n")
@ -292,20 +292,7 @@ class LocalConf(object):
for group, conf in groups:
if group == "local":
for line in lc._section(group, conf):
self.set_local_raw(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))
self.set_local(line)
else:
for section, name, value in lc._conf(group, conf):
self.set(group, conf, section, name, value)

View File

@ -90,22 +90,22 @@ class TestLcSet(testtools.TestCase):
def test_set_new(self):
conf = dsconf.LocalConf(self._path)
conf.set_local_raw("g=2")
conf.set_local("g=2")
with open(self._path) as f:
content = f.read()
self.assertEqual(content, RESULT1)
def test_set_existing(self):
conf = dsconf.LocalConf(self._path)
conf.set_local_raw("a=2")
conf.set_local("a=2")
with open(self._path) as f:
content = f.read()
self.assertEqual(content, RESULT2)
def test_set_raw(self):
conf = dsconf.LocalConf(self._path)
conf.set_local_raw("enable_plugin foo http://foo branch")
conf.set_local_raw("enable_plugin bar http://foo branch")
conf.set_local("enable_plugin foo http://foo branch")
conf.set_local("enable_plugin bar http://foo branch")
with open(self._path) as f:
content = f.read()
self.assertEqual(content, RESULT3)