[ooo-build-commit] .: 2 commits - bin/parse-scp2.py

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Jul 13 18:31:44 PDT 2010


 bin/parse-scp2.py |   27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

New commits:
commit 320f36c0fac1bc8a0f4c53cdfba6f7a9c9770b8c
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jul 13 21:30:44 2010 -0400

    Store node locations for easy backtracking to their definitions.
    
    * bin/parse-scp2.py:

diff --git a/bin/parse-scp2.py b/bin/parse-scp2.py
index 8941f04..79fcd93 100755
--- a/bin/parse-scp2.py
+++ b/bin/parse-scp2.py
@@ -50,8 +50,9 @@ class Scp2Parser(object):
         'WindowsCustomAction'
     ]
 
-    def __init__ (self, content):
+    def __init__ (self, content, filename):
         self.content = content
+        self.filename = filename
         self.nodes = {}
 
     def tokenize (self):
@@ -83,12 +84,13 @@ class Scp2Parser(object):
             t = self.token()
             if t in Scp2Parser.NodeTypes:
                 name, attrs = self.__parseEntity()
-                attrs['__node_type__'] = t # special attribute name
+                attrs['__node_type__'] = t                 # type of node
+                attrs['__node_location__'] = self.filename # file where the node is defined
                 if self.nodes.has_key(name):
                     raise ParseError("node named %s already exists"%name, 1)
                 self.nodes[name] = attrs
             else:
-                raise ParseError("Unknown block type: %s"%t)
+                raise ParseError("Unknown node type: %s"%t)
 
             self.next()
 
@@ -190,7 +192,7 @@ class Scp2Processor(object):
         file = open(Scp2Processor.tmpout, 'r')
         content = file.read()
         file.close()
-        parser = Scp2Parser(content)
+        parser = Scp2Parser(content, self.to_relative(scp))
         parser.tokenize()
         try:
             parser.parse()
@@ -209,10 +211,15 @@ class Scp2Processor(object):
         for name in names:
             attrs = self.nodes[name]
             node_type = attrs['__node_type__']
+            print ('-'*70)
             print ("%s (%s)"%(name, node_type))
+            print ("[node location: %s]"%attrs['__node_location__'])
             attr_names = attrs.keys()
             attr_names.sort()
             for attr_name in attr_names:
+                if attr_name in ['__node_type__', '__node_location__']:
+                    # Skip special attribute.
+                    continue
                 print ("  %s = %s"%(attr_name, attrs[attr_name]))
 
     @staticmethod
commit 4d1ac5d1b2ced356875064d2ac26adf274ce3d40
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jul 13 19:52:11 2010 -0400

    Print summary after successful parsing.
    
    * bin/parse-scp2.py:

diff --git a/bin/parse-scp2.py b/bin/parse-scp2.py
index dc782ba..8941f04 100755
--- a/bin/parse-scp2.py
+++ b/bin/parse-scp2.py
@@ -83,6 +83,7 @@ class Scp2Parser(object):
             t = self.token()
             if t in Scp2Parser.NodeTypes:
                 name, attrs = self.__parseEntity()
+                attrs['__node_type__'] = t # special attribute name
                 if self.nodes.has_key(name):
                     raise ParseError("node named %s already exists"%name, 1)
                 self.nodes[name] = attrs
@@ -202,6 +203,18 @@ class Scp2Processor(object):
                 # This is a severe error.  Exit right away.
                 sys.exit(1)
 
+    def print_summary (self):
+        names = self.nodes.keys()
+        names.sort()
+        for name in names:
+            attrs = self.nodes[name]
+            node_type = attrs['__node_type__']
+            print ("%s (%s)"%(name, node_type))
+            attr_names = attrs.keys()
+            attr_names.sort()
+            for attr_name in attr_names:
+                print ("  %s = %s"%(attr_name, attrs[attr_name]))
+
     @staticmethod
     def visit (arg, dirname, names):
         instance = arg
@@ -223,5 +236,6 @@ if __name__ == '__main__':
     try:
         processor = Scp2Processor(cur_dir, options.mod_output_dir)
         processor.run()
+        processor.print_summary()
     except ParseError as e:
         print (e.value)


More information about the ooo-build-commit mailing list