| 561 | self.version = version |
| 562 | |
| 563 | def register(self, name, mode, path, default=None): |
| 564 | assert mode in self.MODE, "mode must be one of ScapyExt.MODE !" |
| 565 | fullname = f"scapy.{mode.value}.{name}" |
| 566 | spec = importlib.util.spec_from_file_location( |
| 567 | fullname, |
| 568 | str(path), |
| 569 | ) |
| 570 | spec = self.ScapyExtSpec( |
| 571 | fullname=fullname, |
| 572 | mode=mode, |
| 573 | spec=spec, |
| 574 | default=default or False, |
| 575 | ) |
| 576 | if default is None: |
| 577 | spec.default = bool(importlib.util.find_spec(spec.fullname)) |
| 578 | self.specs[fullname] = spec |
| 579 | |
| 580 | def register_bashcompletion(self, script: pathlib.Path): |
| 581 | self.bash_completions[script.name] = script |