def ExportVMToPython(vm):
    """
        Export classes/methods/fields' names in the python namespace

        @param vm: a VM object (DalvikVMFormat, JVMFormat)
    """
    for _class in vm.get_classes():
        ### Class
        name = "CLASS_" + FormatClassToPython(_class.get_name())
        setattr(vm, name, _class)

        ### Methods
        m = {}
        for method in _class.get_methods():
            if method.get_name() not in m:
                m[ method.get_name() ] = []
            m[ method.get_name() ].append(method)

        for i in m:
            if len(m[i]) == 1:
                j = m[i][0]
                name = "METHOD_" + FormatNameToPython(j.get_name())
                setattr(_class, name, j)
            else:
                for j in m[i]:
                    name = "METHOD_" + FormatNameToPython(j.get_name()) + "_" + FormatDescriptorToPython(j.get_descriptor())
                    setattr(_class, name, j)

        ### Fields
        f = {}
        for field in _class.get_fields():
            if field.get_name() not in f:
                f[ field.get_name() ] = []
            f[ field.get_name() ].append(field)

        for i in f:
            if len(f[i]) == 1:
                j = f[i][0]
                name = "FIELD_" + FormatNameToPython(j.get_name())
                setattr(_class, name, j)
            else:
                for j in f[i]:
                    name = "FIELD_" + FormatNameToPython(j.get_name()) + "_" + FormatDescriptorToPython(j.get_descriptor())
                    setattr(_class, name, j)

        Export classes/methods/fields' names in the python namespace

        @param vm: a VM object (DalvikVMFormat, JVMFormat)
    
airtest/utils/apkparser/bytecode.py