pkt-builder 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. pkt_builder/__init__.py +47 -0
  2. pkt_builder/__main__.py +13 -0
  3. pkt_builder/_vendor/__init__.py +7 -0
  4. pkt_builder/_vendor/pkt_core/__init__.py +83 -0
  5. pkt_builder/_vendor/pkt_core/audit.py +1083 -0
  6. pkt_builder/_vendor/pkt_core/builder/__init__.py +21 -0
  7. pkt_builder/_vendor/pkt_core/builder/lab.py +1073 -0
  8. pkt_builder/_vendor/pkt_core/cli/__init__.py +2 -0
  9. pkt_builder/_vendor/pkt_core/cli/main.py +389 -0
  10. pkt_builder/_vendor/pkt_core/codec/__init__.py +2 -0
  11. pkt_builder/_vendor/pkt_core/codec/container.py +291 -0
  12. pkt_builder/_vendor/pkt_core/codec/qcompress.py +79 -0
  13. pkt_builder/_vendor/pkt_core/crypto/__init__.py +2 -0
  14. pkt_builder/_vendor/pkt_core/crypto/ciphers.py +477 -0
  15. pkt_builder/_vendor/pkt_core/crypto/ciphers_pure.py +991 -0
  16. pkt_builder/_vendor/pkt_core/crypto/keys.py +147 -0
  17. pkt_builder/_vendor/pkt_core/crypto/primitives.py +234 -0
  18. pkt_builder/_vendor/pkt_core/crypto/stream.py +70 -0
  19. pkt_builder/_vendor/pkt_core/data/__init__.py +1 -0
  20. pkt_builder/_vendor/pkt_core/data/device_templates.json +1 -0
  21. pkt_builder/_vendor/pkt_core/data/network_seed.xml +22661 -0
  22. pkt_builder/_vendor/pkt_core/diff.py +221 -0
  23. pkt_builder/_vendor/pkt_core/errors.py +43 -0
  24. pkt_builder/_vendor/pkt_core/export.py +241 -0
  25. pkt_builder/_vendor/pkt_core/models/__init__.py +70 -0
  26. pkt_builder/_vendor/pkt_core/models/base.py +164 -0
  27. pkt_builder/_vendor/pkt_core/models/lab.py +338 -0
  28. pkt_builder/_vendor/pkt_core/models/network.py +482 -0
  29. pkt_builder/_vendor/pkt_core/models/schema.py +494 -0
  30. pkt_builder/_vendor/pkt_core/models/services.py +342 -0
  31. pkt_builder/_vendor/pkt_core/py.typed +0 -0
  32. pkt_builder/_vendor/pkt_core/resources.py +77 -0
  33. pkt_builder/_vendor/pkt_core/xml/__init__.py +54 -0
  34. pkt_builder/_vendor/pkt_core/xml/nodes.py +456 -0
  35. pkt_builder/_vendor/pkt_core/xml/writer.py +40 -0
  36. pkt_builder/builder.py +373 -0
  37. pkt_builder/cli.py +353 -0
  38. pkt_builder/config.py +414 -0
  39. pkt_builder/data/8lab_result.pkt +0 -0
  40. pkt_builder/data/lab3_donor.pkt +0 -0
  41. pkt_builder/data/lab7_donor.pkt +0 -0
  42. pkt_builder/data/pt_accept.ps1 +76 -0
  43. pkt_builder/exporter.py +288 -0
  44. pkt_builder/miniyaml.py +516 -0
  45. pkt_builder/ports.py +344 -0
  46. pkt_builder/resources.py +73 -0
  47. pkt_builder/verify.py +219 -0
  48. pkt_builder-0.1.0.dist-info/METADATA +340 -0
  49. pkt_builder-0.1.0.dist-info/RECORD +53 -0
  50. pkt_builder-0.1.0.dist-info/WHEEL +5 -0
  51. pkt_builder-0.1.0.dist-info/entry_points.txt +2 -0
  52. pkt_builder-0.1.0.dist-info/licenses/LICENSE +674 -0
  53. pkt_builder-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,47 @@
1
+ # SPDX-License-Identifier: GPL-3.0-or-later
2
+ """pkt_builder -- build Packet Tracer .pkt files from a YAML description.
3
+
4
+ Modules
5
+ -------
6
+ ``miniyaml`` dependency-free YAML subset parser (no ``pip install`` needed)
7
+ ``config`` the YAML schema: normalisation and validation
8
+ ``ports`` per-model port catalogues, abbreviated-name resolution
9
+ ``builder`` LabSpec -> .pkt (the verified add/link/power/config order)
10
+ ``verify`` structural checks that predict "Incompatible File"
11
+ ``exporter`` .pkt -> YAML
12
+ ``resources`` access to the bundled donors and the acceptance harness
13
+ ``cli`` command line interface (the ``pkt-builder`` script)
14
+
15
+ The vendored ``pkt_core`` library lives in ``pkt_builder/_vendor/pkt_core/``
16
+ (GPL-3.0-or-later, unmodified upstream); this module puts
17
+ ``pkt_builder/_vendor`` on ``sys.path`` so the rest of the package can simply
18
+ ``import pkt_core``. ``pkt_core`` uses absolute imports internally
19
+ (``from pkt_core.x import y``), so keeping the upstream package name is the
20
+ smallest possible shim.
21
+ """
22
+ import pathlib
23
+ import sys
24
+
25
+ _HERE = pathlib.Path(__file__).resolve().parent
26
+
27
+ _candidate = _HERE / "_vendor"
28
+ if (_candidate / "pkt_core" / "__init__.py").is_file():
29
+ _path = str(_candidate)
30
+ if _path not in sys.path:
31
+ sys.path.insert(0, _path)
32
+
33
+ from pkt_builder.config import ConfigError, DeviceSpec, LabSpec, LinkSpec, parse_spec
34
+ from pkt_builder.ports import PortError, port_catalogue, resolve_port
35
+
36
+ __all__ = [
37
+ "ConfigError",
38
+ "DeviceSpec",
39
+ "LabSpec",
40
+ "LinkSpec",
41
+ "PortError",
42
+ "parse_spec",
43
+ "port_catalogue",
44
+ "resolve_port",
45
+ ]
46
+
47
+ __version__ = "0.1.0"
@@ -0,0 +1,13 @@
1
+ # SPDX-License-Identifier: GPL-3.0-or-later
2
+ """``python -m pkt_builder`` -- run the command line interface."""
3
+
4
+ import sys
5
+
6
+ from pkt_builder.cli import main
7
+
8
+ if __name__ == "__main__":
9
+ try:
10
+ sys.exit(main())
11
+ except KeyboardInterrupt:
12
+ print("\ninterrupted", file=sys.stderr)
13
+ sys.exit(130)
@@ -0,0 +1,7 @@
1
+ """Third-party code vendored into pkt_builder.
2
+
3
+ ``pkt_core`` is bundled here so that ``pip install pkt-builder`` brings
4
+ everything needed to read and write ``.pkt`` files. It is unmodified upstream
5
+ code and keeps its own ``pkt_core`` package name; :mod:`pkt_builder` puts this
6
+ directory on ``sys.path`` before importing anything from it.
7
+ """
@@ -0,0 +1,83 @@
1
+ """pkt-core — type-safe reader/writer for Cisco Packet Tracer ``.pkt``/``.pka`` files.
2
+
3
+ Library entry point. Everything needed to open, inspect, modify and re-write a
4
+ Packet Tracer save file is re-exported here; the CLI is a separate, thin consumer
5
+ and is never imported by this package.
6
+
7
+ Quick start::
8
+
9
+ from pkt_core import decode, encode_bytes
10
+
11
+ container = decode("lab.pkt") # verifier-based format detection
12
+ print(container.root_tag) # 'PACKETTRACER5'
13
+ xml = container.xml # the inner XML document
14
+ rebuilt = encode_bytes(xml, container.format_name)
15
+
16
+ The container is fully deterministic (fixed key + fixed IV), so re-encoding the
17
+ same XML yields the same bytes.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from pkt_core.codec.container import (
23
+ DEFAULT_FORMAT,
24
+ Container,
25
+ decode,
26
+ decode_bytes,
27
+ detect_format,
28
+ encode,
29
+ encode_bytes,
30
+ root_tag,
31
+ )
32
+ from pkt_core.codec.qcompress import qcompress, quncompress
33
+ from pkt_core.crypto.keys import FORMATS, BLOCK_SIZE, TAG_SIZE, FormatSpec, get_format
34
+ from pkt_core.crypto.primitives import eax_open, eax_seal, eax_verify
35
+ from pkt_core.errors import (
36
+ CompressionError,
37
+ FormatError,
38
+ IntegrityError,
39
+ PacketTracerError,
40
+ TruncatedFileError,
41
+ UnsupportedCipherError,
42
+ )
43
+
44
+ from pkt_core.builder import Lab, Layout, load_templates
45
+
46
+ __version__ = "0.4.1"
47
+
48
+ __all__ = [
49
+ # container
50
+ "Container",
51
+ "decode",
52
+ "decode_bytes",
53
+ "encode",
54
+ "encode_bytes",
55
+ "detect_format",
56
+ "root_tag",
57
+ "DEFAULT_FORMAT",
58
+ # key schedule
59
+ "FORMATS",
60
+ "FormatSpec",
61
+ "get_format",
62
+ "BLOCK_SIZE",
63
+ "TAG_SIZE",
64
+ # crypto primitives
65
+ "eax_seal",
66
+ "eax_open",
67
+ "eax_verify",
68
+ # framing
69
+ "qcompress",
70
+ "quncompress",
71
+ # errors
72
+ "PacketTracerError",
73
+ "FormatError",
74
+ "IntegrityError",
75
+ "TruncatedFileError",
76
+ "CompressionError",
77
+ "UnsupportedCipherError",
78
+ "__version__",
79
+ # authoring (imported last: the builder imports the codec above)
80
+ "Lab",
81
+ "Layout",
82
+ "load_templates",
83
+ ]