Index: /branches/0.4/parse_ganglia.py
===================================================================
--- /branches/0.4/parse_ganglia.py	(revision 694)
+++ /branches/0.4/parse_ganglia.py	(revision 695)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
 
-import shlex, sys
+import shlex, sys, pprint
 from glob import glob
 
@@ -9,4 +9,5 @@
 
         self.conf_lijst   = [ ]
+        self.conf_dict    = { }
         self.filename     = filename
         self.file_pointer = file( filename, 'r' )
@@ -15,4 +16,5 @@
 
         self.parse()
+
 
     def __del__( self ):
@@ -43,6 +45,6 @@
 
         t = 'bogus'
-        c= False
-        i= False
+        c = False
+        i = False
 
         while t != self.lexx.eof:
@@ -50,15 +52,25 @@
             t = self.lexx.get_token()
 
-            if t == '/*':
-                c = True
-                print 'comment start'
-                print 'skipping: %s' %t
-                continue
-
-            if t == '*/':
-                c = False
-                print 'skipping: %s' %t
-                print 'comment end'
-                continue
+            if len( t ) >= 2:
+
+                if len( t ) >= 4:
+
+                    if t[:2] == '/*' and t[-2:] == '*/':
+
+                        print 'comment line'
+                        print 'skipping: %s' %t
+                        continue
+
+                if t == '/*' or t[:2] == '/*':
+                    c = True
+                    print 'comment start'
+                    print 'skipping: %s' %t
+                    continue
+
+                if t == '*/' or t[-2:] == '*/':
+                    c = False
+                    print 'skipping: %s' %t
+                    print 'comment end'
+                    continue
 
             if c:
@@ -100,9 +112,104 @@
         return self.conf_lijst
 
+    def confListToDict( self, parent_list=None ):
+
+        new_dict = { }
+        count    = 0
+        skip     = 0
+
+        if not parent_list:
+            parent_list = self.conf_lijst
+
+        print 'entering confListToDict(): (parent) list size %s' %len(parent_list)
+
+        for n, c in enumerate( parent_list ):
+
+            count = count + 1
+
+            print 'CL: n %d c %s' %(n, c)
+
+            if skip > 0:
+
+                #print '- skipped'
+                skip = skip - 1
+                continue
+
+            if (n+1) <= (len( parent_list )-1):
+
+                if parent_list[(n+1)] == '{':
+
+                    if not new_dict.has_key( c ):
+                        new_dict[ c ] = [ ]
+
+                    (temp_new_dict, skip) = self.confListToDict( parent_list[(n+2):] )
+                    new_dict[ c ].append( temp_new_dict )
+
+                if parent_list[(n+1)] == '=' and (n+2) <= (len( parent_list )-1):
+
+                    if not new_dict.has_key( c ):
+                        new_dict[ c ] = [ ]
+
+                    new_dict[ c ].append( parent_list[ (n+2) ] )
+
+                    skip = 2
+
+                if parent_list[n] == '}':
+
+                    #print 'parent_list = %s' %parent_list
+                    print 'leaving confListToDict(): new dict = %s' %new_dict
+                    return (new_dict, count)
+
+    def getConfDict( self ):
+
+        return self.conf_dict
+
+    def makeConfDict( self ):
+
+        new_dict = { }
+        skip     = 0
+
+        print 'entering makeConfDict()'
+
+        for n, c in enumerate( self.conf_lijst ):
+
+            print 'M: n %d c %s' %(n, c)
+
+            if skip > 0:
+
+                print '- skipped'
+                skip = skip - 1
+                continue
+
+            if (n+1) <= (len( self.conf_lijst )-1):
+
+                if self.conf_lijst[(n+1)] == '{':
+
+                    if not new_dict.has_key( c ):
+                        new_dict[ c ] = [ ]
+
+                    ( temp_new_dict, skip ) = self.confListToDict( self.conf_lijst[(n+2):] )
+                    new_dict[ c ].append( temp_new_dict )
+
+                if self.conf_lijst[(n+1)] == '=' and (n+2) <= (len( self.conf_lijst )-1):
+
+                    if not new_dict.has_key( c ):
+                        new_dict[ c ] = [ ]
+
+                    new_dict[ c ].append( self.conf_lijst[ (n+2) ] )
+
+                    skip = 2
+
+        self.conf_dict = new_dict
+        print 'leaving makeConfDict(): conf dict size %d' %len( self.conf_dict )
+
 GMOND_LOCATION = '/etc/ganglia/gmond.conf'
 
 g = GangliaConfigParser( GMOND_LOCATION )
 
-print g.getConfLijst()
+pprint.pprint( g.getConfLijst(), width=1 )
+
+g.makeConfDict()
+
+pprint.pprint( g.getConfDict(), width=1 )
 
 print 'exiting..'
