1.1 --- a/generator.py Sat Jan 21 00:03:13 2017 +0100
1.2 +++ b/generator.py Sat Jan 21 17:03:55 2017 +0100
1.3 @@ -918,9 +918,26 @@
1.4 path = ref.get_origin()
1.5 value_type = self.string_type
1.6
1.7 + # Provide constant values. These must match the values
1.8 + # originally recorded during inspection.
1.9 +
1.10 if attrname == "__file__":
1.11 module = self.importer.get_module(path)
1.12 value = module.filename
1.13 +
1.14 + # Function and class names are leafnames.
1.15 +
1.16 + elif attrname in ("__fname__", "__name__"):
1.17 + value = path.rsplit(".", 1)[-1]
1.18 +
1.19 + # Module names of classes and functions are derived from
1.20 + # their object paths.
1.21 +
1.22 + elif attrname == "__mname__" and not ref.has_kind("<module>"):
1.23 + value = self.importer.get_module_provider(ref)
1.24 +
1.25 + # All other names just use the object path information.
1.26 +
1.27 else:
1.28 value = path
1.29