MCPcopy Index your code
hub / github.com/secdev/scapy / _load

Function _load

scapy/main.py:300–327  ·  view source on GitHub ↗

Loads a Python module to make variables, objects and functions available globally. The idea is to load the module using importlib, then copy the symbols to the global symbol table.

(module, globals_dict=None, symb_list=None)

Source from the content-addressed store, hash-verified

298
299
300def _load(module, globals_dict=None, symb_list=None):
301 # type: (str, Optional[Dict[str, Any]], Optional[List[str]]) -> None
302 """Loads a Python module to make variables, objects and functions
303available globally.
304
305 The idea is to load the module using importlib, then copy the
306symbols to the global symbol table.
307
308 """
309 if globals_dict is None:
310 globals_dict = builtins.__dict__
311 try:
312 mod = importlib.import_module(module)
313 if '__all__' in mod.__dict__:
314 # import listed symbols
315 for name in mod.__dict__['__all__']:
316 if symb_list is not None:
317 symb_list.append(name)
318 globals_dict[name] = mod.__dict__[name]
319 else:
320 # only import non-private symbols
321 for name, sym in mod.__dict__.items():
322 if _validate_local(name):
323 if symb_list is not None:
324 symb_list.append(name)
325 globals_dict[name] = sym
326 except Exception:
327 log_interactive.error("Loading module %s", module, exc_info=True)
328
329
330def load_module(name, globals_dict=None, symb_list=None):

Callers 3

load_moduleFunction · 0.85
load_layerFunction · 0.85
load_contribFunction · 0.85

Calls 3

_validate_localFunction · 0.85
itemsMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected