Commits

Anonymous committed 42914ae

Added batchset for multiline configs

Comments (0)

Files changed (4)

  Done
 ======
 
+- setting many configs using batchset in dialogs : December 1, 2007
 - updating buffers with moved files : December 1, 2007
 - showing the old value of a field in dialogs : November 30, 2007
 - new file/directory/module/package; ``C-x p n [fdmp]`` : November 30, 2007
 > Public Release 0.3
 
 * showing proposal type in code-assist
-* batchset in dialog

ropemacs/dialog.py

 
 
 def _parse_batchset(sets):
-    result = {}
-    for line in sets.splitlines():
-        tokens = line.split(None, 1)
-        result[tokens[0]] = tokens[1]
-    return result
+    result = []
+    multiline = False
+    for line in sets.splitlines(True):
+        if line[0].isspace() and multiline:
+            result[-1][1] += line[1:]
+        else:
+            if not line:
+                continue
+            multiline= False
+            tokens = line.split(None, 1)
+            value = ''
+            if len(tokens) > 1:
+                result.append([tokens[0], tokens[1].rstrip('\r\n')])
+            else:
+                multiline = True
+                result.append([tokens[0], ''])
+    return dict(result)
         self.assertEquals({'name1': 'value1', 'name2': 'value2'}, result)
         self.assertEquals('done', action)
 
-    def test_trivial_batchset(self):
+    def test_multiline_sets(self):
         optionals = {'name': dialog.Data()}
-        minibuffer = _MockAskConfig(['batchset', 'name value', 'done'])
+        minibuffer = _MockAskConfig(
+            ['batchset', 'name\n line1\n  line2\n', 'done'])
         action, result = dialog.show_dialog(minibuffer, ['done', 'cancel'],
                                             optionals=optionals)
-        self.assertEquals({'name': 'value'}, result)
+        self.assertEquals({'name': 'line1\n line2\n'}, result)
+        self.assertEquals('done', action)
+
+    def test_complex_batchset(self):
+        optionals = {'name1': dialog.Data(), 'name2': dialog.Data(),
+                     'name3': dialog.Data()}
+        minibuffer = _MockAskConfig(
+            ['batchset', 'name3\n value3\nname1\n line1\n  line2\n\nname2 value2\n', 'done'])
+        action, result = dialog.show_dialog(minibuffer, ['done', 'cancel'],
+                                            optionals=optionals)
+        self.assertEquals(
+            {'name1': 'line1\n line2\n', 'name2': 'value2',
+             'name3': 'value3\n'}, result)
         self.assertEquals('done', action)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.