Loads a Scapy contrib module to make variables, objects and functions available globally. If no contrib module can be found with the given name, try to find a layer module, since a contrib module may become a layer module.
(name, globals_dict=None, symb_list=None)
| 348 | |
| 349 | |
| 350 | def load_contrib(name, globals_dict=None, symb_list=None): |
| 351 | # type: (str, Optional[Dict[str, Any]], Optional[List[str]]) -> None |
| 352 | """Loads a Scapy contrib module to make variables, objects and |
| 353 | functions available globally. |
| 354 | |
| 355 | If no contrib module can be found with the given name, try to find |
| 356 | a layer module, since a contrib module may become a layer module. |
| 357 | |
| 358 | """ |
| 359 | try: |
| 360 | importlib.import_module("scapy.contrib." + name) |
| 361 | _load("scapy.contrib." + name, |
| 362 | globals_dict=globals_dict, symb_list=symb_list) |
| 363 | except ImportError as e: |
| 364 | # if layer not found in contrib, try in layers |
| 365 | try: |
| 366 | load_layer(name, |
| 367 | globals_dict=globals_dict, symb_list=symb_list) |
| 368 | except ImportError: |
| 369 | raise e # Let's raise the original error to avoid confusion |
| 370 | |
| 371 | |
| 372 | def list_contrib(name=None, # type: Optional[str] |
no test coverage detected