1.1 --- a/viewer.py Sun Jan 07 20:09:39 2007 +0100
1.2 +++ b/viewer.py Sun Jan 07 23:44:39 2007 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 View annotated sources.
1.6
1.7 -Copyright (C) 2006 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2006, 2007 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This software is free software; you can redistribute it and/or
1.11 modify it under the terms of the GNU General Public License as
1.12 @@ -872,13 +872,25 @@
1.13 self._types_list(node.namespace.raises, style_class="raises")
1.14
1.15 def _scopes(self, node):
1.16 +
1.17 + "Output the scope information for the given simplified 'node'."
1.18 +
1.19 + # Straightforward name loading/storing involves the local scope.
1.20 +
1.21 if isinstance(node, StoreName) or isinstance(node, LoadName):
1.22 self.stream.write("<div class='scopes'>\n")
1.23 self.stream.write("<div class='scope'>")
1.24 self.stream.write("(local)")
1.25 self.stream.write("</div>\n")
1.26 self.stream.write("</div>\n")
1.27 +
1.28 + # Other loading/storing involves attributes accessed on modules, classes
1.29 + # and objects.
1.30 +
1.31 else:
1.32 +
1.33 + # Loading...
1.34 +
1.35 if hasattr(node, "accesses") and node.accesses:
1.36 self.stream.write("<div class='scopes'>\n")
1.37 for ref, accesses in node.accesses.items():
1.38 @@ -891,6 +903,9 @@
1.39 self.stream.write(" (via " + self._text(access_fn) + ")")
1.40 self.stream.write("</div>\n")
1.41 self.stream.write("</div>\n")
1.42 +
1.43 + # Storing...
1.44 +
1.45 if hasattr(node, "writes") and node.writes:
1.46 self.stream.write("<div class='scopes'>\n")
1.47 for ref in node.writes.keys():
1.48 @@ -899,8 +914,14 @@
1.49 self.stream.write(self._text(fn))
1.50 self.stream.write("</div>\n")
1.51 self.stream.write("</div>\n")
1.52 +
1.53 + # Non-loading...
1.54 +
1.55 if hasattr(node, "non_accesses") and node.non_accesses:
1.56 self._types_list(node.non_accesses, style_class="non-accesses")
1.57 +
1.58 + # Non-storing...
1.59 +
1.60 if hasattr(node, "non_writes") and node.non_writes:
1.61 self._types_list(node.non_writes, style_class="non-writes")
1.62