You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2020/08/07 21:30:35 UTC

[qpid-dispatch] branch master updated: DISPATCH-1707: Accept trailing brace on separate line

This is an automated email from the ASF dual-hosted git repository.

chug pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
     new 2348f53  DISPATCH-1707: Accept trailing brace on separate line
2348f53 is described below

commit 2348f53af186b54dcf21bc8d967869bf48c5b2ed
Author: Chuck Rolke <ch...@apache.org>
AuthorDate: Fri Aug 7 17:29:02 2020 -0400

    DISPATCH-1707: Accept trailing brace on separate line
    
    This patch reorganizes the parse accounting for json fields embedded
    in a dispatch-config formatted config file. Policy vhost groups hold
    doubly-nested maps and those need to be detected and retired as they
    come and go.
    
    This closes #811
---
 python/qpid_dispatch_internal/management/config.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/python/qpid_dispatch_internal/management/config.py b/python/qpid_dispatch_internal/management/config.py
index 031d41c..c6c0f68 100644
--- a/python/qpid_dispatch_internal/management/config.py
+++ b/python/qpid_dispatch_internal/management/config.py
@@ -110,8 +110,10 @@ class Config(object):
         #
         entity = re.compile(r'([\w-]+)[ \t]*{[ \t]*$')                    # WORD {
         attr_map = re.compile(r'([\$]*[\w-]+)[ \t]*:[ \t]*{[ \t]*$')      # WORD: {
+        json_map = re.compile(r'("[\$]*[\w-]+)"[ \t]*:[ \t]*{[ \t]*$')    # "WORD": {
         attr_item = re.compile(r'([\w-]+)[ \t]*:[ \t]*([^ \t{]+.*)$')     # WORD1: VALUE
-        end = re.compile(r'^}$')                                          # }
+        end = re.compile(r'^}$')                                          # } (only)
+        json_end = re.compile(r'}$')                                      # } (at eol)
 
         # The 'pattern:' and 'bindingKey:' attributes in the schema are special
         # snowflakes. They allow '#' characters in their value, so they cannot
@@ -138,8 +140,16 @@ class Config(object):
                 self._line_num += 1
                 return ""
 
-            # just pass JSON values along
-            if self._in_json and not end.search(line.split('#')[0].strip()):
+            # watch JSON for embedded maps and map terminations
+            # always pass JSON as-is except appending a comma at the end
+            if self._in_json:
+                if json_map.search(line):
+                    self._child_level += 1
+                if json_end.search(line):
+                    self._child_level -= 1
+                    if self._child_level == 0:
+                        self._in_json = False
+                        line = re.sub(json_end, r'},', line)
                 self._line_num += 1
                 return line
 
@@ -170,7 +180,6 @@ class Config(object):
                 if self._child_level > 0:
                     line = re.sub(end, r'},', line)
                     self._child_level -= 1
-                    self._in_json = False
                 else:
                     # end top level entity list item
                     line = re.sub(end, r'}],', line)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org