Beispiel #1
0
    def inspect_module(self, module):
        """Flush inspect_console, get module class, object attributes and heritage"""

        module_attributes = None
        self.inspect_console.flush_console()
        self.inspect_console.eval_command("import "+module.title)
        self.inspect_console.eval_command(module.title + " = reload(" + module.title + ")")
        self.inspect_console.eval_command(
            "from " + module.title + " import " + module.classname)

        module.parent_classes = Module.get_parent_classes(module.py_file)

        self.inspect_console.eval_command("attributes = None")
        self.inspect_console.eval_command("""attributes = inspect.getmembers({classname},
                              lambda a:not(inspect.isroutine(a)))
                              """.format(classname=module.classname))

        attributes_exist = self.inspect_console.eval_command(
            """'true' if attributes is not None else 'false'""")

        if eval(attributes_exist) == 'true':
            class_attributes = self.inspect_console.eval_command("""[a[0] for a in attributes if not(a[0].startswith('_'))]""")
            instance_attributes = Module.get_instance_attributes(
                module.py_file);
            module_attributes = {'class_attributes': eval(class_attributes), 'instance_attributes': instance_attributes}
        else:
            print("Errors in module : " + module.title)

        return module_attributes