]> Frank Brehm's Git Trees - my-stuff/isc-config-parser.git/commitdiff
Split unquotet tokens by ';' or '{' or '}'
authorFrank Brehm <frank@brehm-online.com>
Fri, 28 Jan 2011 12:31:54 +0000 (12:31 +0000)
committerFrank Brehm <frank@brehm-online.com>
Fri, 28 Jan 2011 12:31:54 +0000 (12:31 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/python/IscConfigParser/trunk@192 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

IscConfigParser.py

index 31f7bb6566a4920de311996263187f329265afb0..e7d16d4d9881c782affe875f777b601496491828 100755 (executable)
@@ -180,8 +180,8 @@ class IscConfigParser(LoggingObject):
            The number of the beginning of line is after in
            self._files[ self._current_filename ]['current_rownum'] (except in case of EOF).
 
-           @return: the content of this line or None if EOF
-           @rtype:  str or None
+           @return: the content of this line as a list of tokens or None if EOF
+           @rtype:  list or None
         """
 
         filename = self._current_filename
@@ -249,17 +249,26 @@ class IscConfigParser(LoggingObject):
             # Tokens without quotings
             match = re.search( r'^([^"\s]+)', line )
             if match is not None:
+
                 token = match.group(1)
-                if token == ';':
-                    res_array.append( ';' )
+
+                # Split token by ';' or '{' or '}'
+                if token == ';' or token == '{' or token == '}':
+                    res_array.append( token )
                 else:
-                    semicolon_match = re.search( r';$', token )
-                    if semicolon_match is not None:
-                        token = re.sub( r';$', '', token )
-                        res_array.append( token )
-                        res_array.append( ';' )
-                    else:
-                        res_array.append( token )
+                    while token != '':
+                        specialchar_match = re.search( r'^([^;{}]*)([;{}])', token )
+                        if specialchar_match is not None:
+                            first = specialchar_match.group(1)
+                            specialchar = specialchar_match.group(2)
+                            if first is not None and first != '':
+                                res_array.append( first )
+                            res_array.append( specialchar )
+                            token = re.sub( r'^[^;{}]*[;{}]', '', token )
+                        else:
+                            res_array.append( token )
+                            token = ''
+
                 line = re.sub( r'^[^"\s]+\s*', '', line )
                 continue