Browse Source

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
Sean Dague 2 years ago
parent
commit
cf9093ec58
3 changed files with 8 additions and 21 deletions
  1. 2
    2
      devstack/cmd.py
  2. 2
    15
      devstack/dsconf.py
  3. 4
    4
      devstack/tests/test_localconf_set_local.py

+ 2
- 2
devstack/cmd.py View File

@@ -43,11 +43,11 @@ def extract_config(local_conf, args):
43 43
 
44 44
 
45 45
 def setlc(local_conf, args):
46
-    local_conf.set_local(args.name, args.value)
46
+    local_conf.set_local("%s=%s" % (args.name, args.value))
47 47
 
48 48
 
49 49
 def setlc_raw(local_conf, args):
50
-    local_conf.set_raw(" ".join(args.items))
50
+    local_conf.set_local(" ".join(args.items))
51 51
 
52 52
 
53 53
 def setlc_conf(local_conf, args):

+ 2
- 15
devstack/dsconf.py View File

@@ -209,7 +209,7 @@ class LocalConf(object):
209 209
             if not done:
210 210
                 func(writer, None)
211 211
 
212
-    def set_local_raw(self, line):
212
+    def set_local(self, line):
213 213
         if not os.path.exists(self.fname):
214 214
             with open(self.fname, "w+") as writer:
215 215
                 writer.write("[[local|localrc]]\n")
@@ -292,20 +292,7 @@ class LocalConf(object):
292 292
         for group, conf in groups:
293 293
             if group == "local":
294 294
                 for line in lc._section(group, conf):
295
-                    self.set_local_raw(line)
296
-                    # if line.startswith('#'):
297
-                    #     continue
298
-                    # m = re.match(r"([^#=\s]+)\s*\=\s*(.+)", line)
299
-
300
-                    # if m:
301
-                    #     self.set_local(m.group(1), m.group(2))
302
-                    # elif re.match("(enable|disable)", line):
303
-                    #     # special case appending enable* disable*
304
-                    #     # function lines
305
-                    #     self.set_local_raw(line)
306
-                    # else:
307
-                    #     print("SKIPPING ``%s`` from '%s'" %
308
-                    #           (line.lstrip(), lcfile))
295
+                    self.set_local(line)
309 296
             else:
310 297
                 for section, name, value in lc._conf(group, conf):
311 298
                     self.set(group, conf, section, name, value)

+ 4
- 4
devstack/tests/test_localconf_set_local.py View File

@@ -90,22 +90,22 @@ class TestLcSet(testtools.TestCase):
90 90
 
91 91
     def test_set_new(self):
92 92
         conf = dsconf.LocalConf(self._path)
93
-        conf.set_local_raw("g=2")
93
+        conf.set_local("g=2")
94 94
         with open(self._path) as f:
95 95
             content = f.read()
96 96
             self.assertEqual(content, RESULT1)
97 97
 
98 98
     def test_set_existing(self):
99 99
         conf = dsconf.LocalConf(self._path)
100
-        conf.set_local_raw("a=2")
100
+        conf.set_local("a=2")
101 101
         with open(self._path) as f:
102 102
             content = f.read()
103 103
             self.assertEqual(content, RESULT2)
104 104
 
105 105
     def test_set_raw(self):
106 106
         conf = dsconf.LocalConf(self._path)
107
-        conf.set_local_raw("enable_plugin foo http://foo branch")
108
-        conf.set_local_raw("enable_plugin bar http://foo branch")
107
+        conf.set_local("enable_plugin foo http://foo branch")
108
+        conf.set_local("enable_plugin bar http://foo branch")
109 109
         with open(self._path) as f:
110 110
             content = f.read()
111 111
             self.assertEqual(content, RESULT3)

Loading…
Cancel
Save