1.1 --- a/modules.py Fri Jan 20 00:08:26 2017 +0100
1.2 +++ b/modules.py Fri Jan 20 00:09:45 2017 +0100
1.3 @@ -4,7 +4,7 @@
1.4 Module abstractions.
1.5
1.6 Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013,
1.7 - 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.8 + 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -71,6 +71,10 @@
1.13 self.function_targets = {}
1.14 self.function_arguments = {}
1.15
1.16 + # Exception handler details.
1.17 +
1.18 + self.exception_namespaces = set()
1.19 +
1.20 # Attribute usage at module and function levels.
1.21
1.22 self.attr_usage = {}
1.23 @@ -401,6 +405,7 @@
1.24 self._get_attr_access_modifiers(f)
1.25 self._get_constant_literals(f)
1.26 self._get_constant_values(f)
1.27 + self._get_exception_namespaces(f)
1.28
1.29 finally:
1.30 f.close()
1.31 @@ -633,6 +638,12 @@
1.32 self.constant_values[name] = value, value_type, encoding
1.33 line = f.readline().rstrip()
1.34
1.35 + def _get_exception_namespaces(self, f):
1.36 + f.readline() # "exception namespaces:"
1.37 + values = f.readline.rstrip().split(", ")
1.38 + self.exception_namespaces = set(values)
1.39 + f.readline()
1.40 +
1.41 # Generic parsing methods.
1.42
1.43 def from_lines(self, f, d):
1.44 @@ -759,10 +770,15 @@
1.45 (empty line)
1.46 "attribute access modifiers:"
1.47 zero or more: qualified function name " " local/global variable name " " attribute name " " access modifiers
1.48 + (empty line)
1.49 "constant literals:"
1.50 zero or more: qualified scope name " " value type " " constant literal
1.51 + (empty line)
1.52 "constant values:"
1.53 zero or more: qualified name " " value type " " constant literal
1.54 + (empty line)
1.55 + "exception namespaces:"
1.56 + qualified names
1.57
1.58 All collections of names are separated by ", " characters.
1.59
1.60 @@ -995,6 +1011,12 @@
1.61 value, value_type, encoding = self.constant_values[name]
1.62 print >>f, name, value_type, encoding or "{}", repr(value)
1.63
1.64 + print >>f
1.65 + print >>f, "exception namespaces:"
1.66 + paths = list(self.exception_namespaces)
1.67 + paths.sort()
1.68 + print >>f, ", ".join(paths)
1.69 +
1.70 finally:
1.71 f.close()
1.72