[gobject-introspection/wip/transformer] Sort of fall back if we don't have a Node



commit 7327f050b2efd6c6b13f0271dfb5d22b2e5f9f45
Author: Colin Walters <walters verbum org>
Date:   Wed Jul 28 20:40:34 2010 -0400

    Sort of fall back if we don't have a Node
    
    Just print the repr of the type at least.

 giscanner/transformer.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 4322bda..36d88ec 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -188,11 +188,16 @@ the given node.  The optional context argument, if given, should be
 another Node type which will also be displayed.  If no file position
 information is available from the node, the position data from the
 context will be used."""
-        if len(node.file_positions) == 0 and \
-                (context is not None) and len(context.file_positions) > 0:
-            file_positions = context.file_positions
+        if hasattr(node, 'file_positions'):
+            if (len(node.file_positions) == 0 and
+                (context is not None) and len(context.file_positions) > 0):
+                file_positions = context.file_positions
+            else:
+                file_positions = node.file_positions
         else:
-            file_positions = node.file_positions
+            file_positions = None
+            if not context:
+                text = "context=%r %s" % (node, text)
 
         if context:
             text = "context=%r %s" % (context.name, text)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]