How to use _inspect_object method in localstack

Best Python code snippet using localstack_python

factory.py

Source: factory.py Github

copy

Full Screen

...91 module object is parsed again.92 """93 self.__cache = None94 self.__inspect_cache = None95 def _inspect_object(self, obj):96 """97 This method verifies if given object is a valid plugin.98 @return: True, if valid99 @rtype: bool100 """101 if self.__inspect_cache is None:102 self.__inspect_cache = {}103 # use memory position104 obj_memory_pos = id(obj)105 # To avoid infinite recursion and improve106 # objects inspection, check if obj has been already107 # analyzed108 inspected_rc = self.__inspect_cache.get(obj_memory_pos)109 if inspected_rc is not None:110 # avoid infinite recursion111 return inspected_rc112 base_api = self.__base_class.BASE_PLUGIN_API_VERSION113 if not inspect.isclass(obj):114 self.__inspect_cache[obj_memory_pos] = False115 return False116 if not issubclass(obj, self.__base_class):117 self.__inspect_cache[obj_memory_pos] = False118 return False119 if hasattr(obj, '__subclasses__'):120 # new style class121 if obj.__subclasses__(): # only lower classes taken122 self.__inspect_cache[obj_memory_pos] = False123 return False124 else:125 sys.stderr.write("!!! Molecule Plugin warning: " \126 "%s is not a new style class !!!\n" % (obj,))127 if obj is self.__base_class:128 # in this case, obj is our base class,129 # so we are very sure that obj is not valid130 self.__inspect_cache[obj_memory_pos] = False131 return False132 if not hasattr(obj, "PLUGIN_API_VERSION"):133 sys.stderr.write("!!! Molecule Plugin warning: " \134 "no PLUGIN_API_VERSION in %s !!!\n" % (obj,))135 self.__inspect_cache[obj_memory_pos] = False136 return False137 if obj.PLUGIN_API_VERSION != base_api:138 sys.stderr.write("!!! Molecule Plugin warning: " \139 "PLUGIN_API_VERSION mismatch in %s !!!\n" % (obj,))140 self.__inspect_cache[obj_memory_pos] = False141 return False142 if hasattr(obj, 'PLUGIN_DISABLED'):143 if obj.PLUGIN_DISABLED:144 # this plugin has been disabled145 self.__inspect_cache[obj_memory_pos] = False146 return False147 self.__inspect_cache[obj_memory_pos] = True148 return True149 def _scan_dir(self):150 """151 Scan modules in given directory looking for a valid plugin class.152 Directory is os.path.dirname(self.__modfile).153 @return: module dictionary composed by module name as key and plugin154 class as value155 @rtype: dict156 """157 available = {}158 pkg_modname = self.__plugin_package_module.__name__159 mod_dir = os.path.dirname(self.__modfile)160 modules = []161 for modname in os.listdir(mod_dir):162 if modname.startswith("__"):163 continue # python stuff164 if not (modname.endswith(PluginFactory._PYTHON_EXTENSION) \165 or "." not in modname):166 continue # not something we want to load167 if modname.endswith(PluginFactory._PYTHON_EXTENSION):168 modname = modname[:-len(PluginFactory._PYTHON_EXTENSION)]169 if not modname.endswith(PluginFactory._PLUGIN_SUFFIX):170 continue171 # remove suffix172 modname_clean = modname[:-len(PluginFactory._PLUGIN_SUFFIX)]173 modpath = "%s.%s" % (pkg_modname, modname,)174 modules.append(modpath)175 plugin_modules = self._PLUGIN_MODULES176 if plugin_modules:177 modules.extend(plugin_modules.split(":"))178 for modpath in modules:179 try:180 __import__(modpath)181 except ImportError as err:182 sys.stderr.write("!!! Molecule Plugin warning, cannot " \183 "load module: %s | %s !!!\n" % (modpath, err,))184 continue185 for obj in list(sys.modules[modpath].__dict__.values()):186 valid = self._inspect_object(obj)187 if not valid:188 continue189 available[modpath] = obj190 return available191 def _scan_egg_group(self):192 """193 Scan classes in given Python Egg group name looking for a valid plugin.194 @return: module dictionary composed by module name as key and plugin195 class as value196 @rtype: dict197 """198 # needs setuptools199 import pkg_resources200 available = {}201 for entry in pkg_resources.iter_entry_points(self.__egg_entry_group):202 obj = entry.load()203 valid = self._inspect_object(obj)204 if not valid:205 continue206 available[entry.name] = obj207 return available208 def get_available_plugins(self):209 """210 Return currently available plugin classes.211 Note: Molecule plugins can either be Python packages or modules and212 their name MUST end with PluginFactory._PLUGIN_SUFFIX ("_plugin").213 @return: dictionary composed by Molecule plugin id as key and Molecule214 Python module as value215 @rtype: dict216 """217 if self.__cache is not None:...

Full Screen

Full Screen

bpy_data_inspect_base.py

Source: bpy_data_inspect_base.py Github

copy

Full Screen

...58 def _inspect_all_objects(self):59 objs = self.bpy_data.objects60 missed = []61 for idx, obj in enumerate(objs):62 if not self._inspect_object(obj):63 missed.append(obj.name)64 print("missed objs", missed)65 def _inspect_object(self, obj):66 return False 67 def _inspect_all_meshes(self):68 meshes = self.bpy_data.meshes69 for idx, mesh in enumerate(meshes):70 self._inspect_mesh(mesh)71 def _inspect_mesh(self, mesh):72 pass73 def _inspect_all_materials(self):74 materials = self.bpy_data.materials75 for idx, mat in enumerate(materials):76 if mat.name not in self.name2materials:77 self.name2materials[mat.name] = mat78 self._inspect_material(mat)79 def _inspect_material(self, mat):...

Full Screen

Full Screen

inspector.py

Source: inspector.py Github

copy

Full Screen

...66 classes = set()67 for scope, frame in zip(stack, frames):68 variables = frame.f_locals69 scope['members'] = [70 {'key': key, 'value': self._inspect_object(heap, variables[key], classes, module)}71 for key, value in variables.items() if not key.startswith('_')72 ]73 if event == 'return' and len(stack) > 1:74 stack[-1]['members'].append({'key': '#return#', 'value': self._inspect_object(heap, args, classes, module)})75 elif event == 'exception':76 stack[-1]['members'].append({'key': '#exception#', 'value': repr(args[1])})77 return heap78 def _inspect_object(self, heap: dict, obj, classes: set, module: str):79 """80 Recursively inspect objects in the heap.81 String and Number like objects are transformed in str or int.82 Complex objects are transformed in dictionaries that contain information of their type and members and added to83 the snapshot, then their references are returned as a list.84 - heap: `dict`: heap dict to be filled with obj information85 - obj: `*any`: object to be processed86 - classes: `set<str>`: set of user defined classes, which is used to known which objects shall be analyzed87 - module: main module name, used to only save classes that where declared in it88 - return `int | float | str | [str]`: the transformed value89 """90 if isinstance(obj, Inspector.STRING_LIKE_TYPES):91 return str(obj)92 elif isinstance(obj, Inspector.NUMBER_LIKE_TYPES):93 return obj if abs(obj) < 2 ** 53 else str(obj)94 elif isinstance(obj, type):95 if obj.__module__ == module:96 classes.add(obj)97 return str(obj)98 id_ = str(id(obj))99 if id_ in self.ordered_ids:100 ordered_id = self.ordered_ids[id_]101 elif id_ in self.previous_ordered_ids:102 ordered_id = self.ordered_ids[id_] = self.previous_ordered_ids[id_]103 else:104 ordered_id = self.ordered_ids[id_] = self.ordered_id_count105 self.ordered_id_count += 1106 if ordered_id in heap:107 return [ordered_id]108 type_ = type(obj).__name__109 category = 'other'110 members = None111 if isinstance(obj, (tuple, list, set)):112 category = 'list' if not isinstance(obj, set) else 'set'113 members = [*enumerate(obj)]114 elif isinstance(obj, dict):115 category = 'map'116 members = [*obj.items()]117 elif isinstance(obj, (*classes,)):118 category = 'map'119 members = [(key, value) for key, value in vars(obj).items() if not key.startswith('_')]120 if members is not None: # known object type121 # add object id to the heap before further inspections to avoid stack overflows122 obj = heap[ordered_id] = {}123 obj['id'] = ordered_id124 obj['category'] = category125 obj['type'] = type_126 obj['members'] = [127 {128 'key': self._inspect_object(heap, key, classes, module),129 'value': self._inspect_object(heap, value, classes, module)130 }131 for key, value in members132 ]133 return [ordered_id]134 else: # unknown object type135 # instead of inspecting unknown objects, inspect their type only...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful