# HG changeset patch # User Paul Boddie # Date 1352070474 -3600 # Node ID b7fe1463a3c62519ab798790ae1fa748b6f66ce8 # Parent a61f326ec2b2ecf19f35ffcf4e74bc893658d5b5 Added a method to get the class name for a constant so that a pre-made class can be retrieved during inspection and constant attributes deduced. diff -r a61f326ec2b2 -r b7fe1463a3c6 micropython/basicdata.py --- a/micropython/basicdata.py Sun Nov 04 23:41:06 2012 +0100 +++ b/micropython/basicdata.py Mon Nov 05 00:07:54 2012 +0100 @@ -134,6 +134,9 @@ return ".".join(self.value_type_name_parts()) def value_type_name_parts(self): - return "__builtins__", self.value.__class__.__name__ + return "__builtins__", self.get_class_name() + + def get_class_name(self): + return self.value.__class__.__name__ # vim: tabstop=4 expandtab shiftwidth=4 diff -r a61f326ec2b2 -r b7fe1463a3c6 micropython/inspect.py --- a/micropython/inspect.py Sun Nov 04 23:41:06 2012 +0100 +++ b/micropython/inspect.py Mon Nov 05 00:07:54 2012 +0100 @@ -693,6 +693,13 @@ self._visitAttrUser(expr, attrname, node) + # Constants provide specific kinds of expressions. + # NOTE: If attributes are accessed on a pre-made, but not yet defined + # NOTE: class, no useful attribute will be available. + + elif isinstance(expr, Const): + attr = get_constant_class(expr.get_class_name()).all_attributes().get(attrname) or make_instance() + # No particular attribute has been identified, thus a general instance # is assumed.