Browse Source

add the ability for raw line insert during merge

Some localrc stanzas, like enable/disable* need to come over during
merge. These lines will not have an = in them.
Sean Dague 2 years ago
parent
commit
2c8054020b
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      devstack/dsconf.py

+ 19
- 1
devstack/dsconf.py View File

@@ -229,6 +229,17 @@ class LocalConf(object):
229 229
             writer.write("%s=%s\n" % (name, value))
230 230
         self._at_insert_point_local(name, _do_set)
231 231
 
232
+    def set_local_raw(self, line):
233
+        if not os.path.exists(self.fname):
234
+            with open(self.fname, "w+") as writer:
235
+                writer.write("[[local|localrc]]\n")
236
+                writer.write("%s" % line)
237
+                return
238
+
239
+        def _do_set(writer, no_line):
240
+            writer.write("%s" % line)
241
+        self._at_insert_point_local(line, _do_set)
242
+
232 243
     def _at_insert_point(self, group, conf, section, name, func):
233 244
         temp = tempfile.NamedTemporaryFile(mode='r')
234 245
         shutil.copyfile(self.fname, temp.name)
@@ -301,9 +312,16 @@ class LocalConf(object):
301 312
         for group, conf in groups:
302 313
             if group == "local":
303 314
                 for line in lc._section(group, conf):
304
-                    m = re.match(r"(\w+)\s*\=\s*(.+)", line)
315
+                    if line.startswith('#'):
316
+                        continue
317
+                    m = re.match(r"([^#=\s]+)\s*\=\s*(.+)", line)
318
+
305 319
                     if m:
306 320
                         self.set_local(m.group(1), m.group(2))
321
+                    elif re.match("(enable|disable)", line):
322
+                        # special case appending enable* disable*
323
+                        # function lines
324
+                        self.set_local_raw(line)
307 325
                     else:
308 326
                         print("SKIPPING ``%s`` from '%s'" % (line.lstrip(), lcfile))
309 327
             else:

Loading…
Cancel
Save