easa-erules 0.1.2__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 (65) hide show
  1. easa_erules/__init__.py +4 -0
  2. easa_erules/adapters/__init__.py +42 -0
  3. easa_erules/adapters/astm.py +61 -0
  4. easa_erules/adapters/base.py +47 -0
  5. easa_erules/adapters/easa.py +46 -0
  6. easa_erules/adapters/faa.py +57 -0
  7. easa_erules/assets/__init__.py +0 -0
  8. easa_erules/cli.py +622 -0
  9. easa_erules/input/__init__.py +0 -0
  10. easa_erules/input/namespaces.py +127 -0
  11. easa_erules/input/package.py +393 -0
  12. easa_erules/input/relationships.py +87 -0
  13. easa_erules/model/__init__.py +88 -0
  14. easa_erules/model/assets.py +84 -0
  15. easa_erules/model/document.py +65 -0
  16. easa_erules/model/graph.py +148 -0
  17. easa_erules/model/metadata.py +304 -0
  18. easa_erules/model/node.py +364 -0
  19. easa_erules/model/references.py +71 -0
  20. easa_erules/normalize/__init__.py +28 -0
  21. easa_erules/normalize/headings.py +21 -0
  22. easa_erules/normalize/numbering.py +24 -0
  23. easa_erules/normalize/references.py +24 -0
  24. easa_erules/normalize/whitespace.py +56 -0
  25. easa_erules/parser/__init__.py +23 -0
  26. easa_erules/parser/document.py +287 -0
  27. easa_erules/parser/figures.py +206 -0
  28. easa_erules/parser/hyperlinks.py +103 -0
  29. easa_erules/parser/lists.py +80 -0
  30. easa_erules/parser/metadata.py +266 -0
  31. easa_erules/parser/paragraphs.py +386 -0
  32. easa_erules/parser/tables.py +198 -0
  33. easa_erules/parser/topics.py +321 -0
  34. easa_erules/py.typed +0 -0
  35. easa_erules/render/__init__.py +24 -0
  36. easa_erules/render/frontmatter.py +110 -0
  37. easa_erules/render/html.py +295 -0
  38. easa_erules/render/json.py +181 -0
  39. easa_erules/render/markdown.py +478 -0
  40. easa_erules/search/__init__.py +14 -0
  41. easa_erules/search/indexer.py +286 -0
  42. easa_erules/search/query.py +271 -0
  43. easa_erules/search/sqlite.py +150 -0
  44. easa_erules/sources/__init__.py +21 -0
  45. easa_erules/sources/cache.py +45 -0
  46. easa_erules/sources/downloader.py +317 -0
  47. easa_erules/sources/easa.yaml +135 -0
  48. easa_erules/sources/registry.py +105 -0
  49. easa_erules/sources/resolver.py +313 -0
  50. easa_erules/util/__init__.py +16 -0
  51. easa_erules/util/ids.py +76 -0
  52. easa_erules/util/logging.py +40 -0
  53. easa_erules/util/slugify.py +190 -0
  54. easa_erules/validation/__init__.py +98 -0
  55. easa_erules/validation/assets.py +98 -0
  56. easa_erules/validation/links.py +60 -0
  57. easa_erules/validation/output.py +207 -0
  58. easa_erules/validation/report.py +84 -0
  59. easa_erules/validation/structure.py +122 -0
  60. easa_erules-0.1.2.dist-info/METADATA +274 -0
  61. easa_erules-0.1.2.dist-info/RECORD +65 -0
  62. easa_erules-0.1.2.dist-info/WHEEL +5 -0
  63. easa_erules-0.1.2.dist-info/entry_points.txt +2 -0
  64. easa_erules-0.1.2.dist-info/licenses/LICENSE +21 -0
  65. easa_erules-0.1.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,4 @@
1
+ """EASA eRules - Universal toolkit for EASA Easy Access Rules XML publications."""
2
+
3
+ __version__ = "0.1.2"
4
+ __author__ = "EASA eRules Contributors"
@@ -0,0 +1,42 @@
1
+ """Multi-authority adapters (EASA implemented; FAA/ASTM scaffolded).
2
+
3
+ The Regulation AST is authority-agnostic. Each adapter is responsible for:
4
+
5
+ 1. resolving / fetching source packages for that authority,
6
+ 2. parsing into the shared AST,
7
+ 3. optional authority-specific designation normalization.
8
+
9
+ Only the EASA adapter is production-ready. FAA and ASTM modules define the
10
+ extension points and raise ``NotImplementedError`` until packages are available.
11
+ """
12
+
13
+ from .astm import AstmAdapter
14
+ from .base import AdapterCapabilities, RegulationAdapter
15
+ from .easa import EasaAdapter
16
+ from .faa import FaaAdapter
17
+
18
+ __all__ = [
19
+ "AdapterCapabilities",
20
+ "AstmAdapter",
21
+ "EasaAdapter",
22
+ "FaaAdapter",
23
+ "RegulationAdapter",
24
+ "get_adapter",
25
+ ]
26
+
27
+
28
+ def get_adapter(authority: str) -> RegulationAdapter:
29
+ """Return an adapter instance for ``authority`` (easa / faa / astm)."""
30
+ key = (authority or "").strip().lower()
31
+ mapping: dict[str, type[RegulationAdapter]] = {
32
+ "easa": EasaAdapter,
33
+ "faa": FaaAdapter,
34
+ "astm": AstmAdapter,
35
+ }
36
+ try:
37
+ cls = mapping[key]
38
+ except KeyError as exc:
39
+ raise ValueError(
40
+ f"Unknown authority {authority!r}. Known: {', '.join(sorted(mapping))}"
41
+ ) from exc
42
+ return cls()
@@ -0,0 +1,61 @@
1
+ """ASTM consensus standards adapter (scaffold).
2
+
3
+ Planned sources (not implemented):
4
+
5
+ - ASTM F44 (Normal Category Aeroplanes) consensus standards referenced from
6
+ CS-23 AMC / GM tables
7
+ - Other ASTM committees cited by EASA AMC material
8
+
9
+ ASTM documents are typically PDF/HTML under license; any future adapter must
10
+ respect ASTM redistribution terms and prefer official structured exports if
11
+ they become available.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from pathlib import Path
17
+ from typing import Any
18
+
19
+ from .base import AdapterCapabilities, RegulationAdapter
20
+
21
+
22
+ class AstmAdapter(RegulationAdapter):
23
+ """Scaffold for future ASTM standard ingestion."""
24
+
25
+ authority = "astm"
26
+
27
+ def capabilities(self) -> AdapterCapabilities:
28
+ return AdapterCapabilities(
29
+ authority=self.authority,
30
+ fetch=False,
31
+ parse=False,
32
+ search=False,
33
+ designations=False,
34
+ notes=(
35
+ "Scaffold only. Licensing and package format TBD. "
36
+ "Cross-refs from CS-23 AMC already surface ASTM designations via EASA parser."
37
+ ),
38
+ planned=[
39
+ "Catalog of F44 standards referenced by CS-23 AMC",
40
+ "Designation normalizer (e.g. ASTM F3264-…)",
41
+ "Optional local PDF/HTML extract under license compliance",
42
+ ],
43
+ )
44
+
45
+ def list_sources(self) -> list[dict[str, Any]]:
46
+ return []
47
+
48
+ def fetch(self, source_id: str, *, version: str | None = None) -> Path:
49
+ raise NotImplementedError(
50
+ "ASTM adapter is a scaffold. Licensing and fetch are not implemented."
51
+ )
52
+
53
+ def parse(self, path: str | Path) -> Any:
54
+ raise NotImplementedError(
55
+ "ASTM adapter is a scaffold. No ASTM package parser is implemented yet."
56
+ )
57
+
58
+ def normalize_designation(self, text: str) -> str:
59
+ cleaned = text.strip()
60
+ # ASTM F3264-17 → ASTM F3264-17
61
+ return " ".join(cleaned.split())
@@ -0,0 +1,47 @@
1
+ """Adapter protocol for multi-authority regulation sources."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from abc import ABC, abstractmethod
6
+ from dataclasses import dataclass, field
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+
11
+ @dataclass(slots=True)
12
+ class AdapterCapabilities:
13
+ """What an adapter can do today."""
14
+
15
+ authority: str
16
+ fetch: bool = False
17
+ parse: bool = False
18
+ search: bool = False
19
+ designations: bool = False
20
+ notes: str = ""
21
+ planned: list[str] = field(default_factory=list)
22
+
23
+
24
+ class RegulationAdapter(ABC):
25
+ """Authority-specific fetch/parse bridge into the shared Regulation AST."""
26
+
27
+ authority: str
28
+
29
+ @abstractmethod
30
+ def capabilities(self) -> AdapterCapabilities:
31
+ """Describe implemented vs planned features."""
32
+
33
+ @abstractmethod
34
+ def list_sources(self) -> list[dict[str, Any]]:
35
+ """Return catalog entries for this authority (may be empty)."""
36
+
37
+ @abstractmethod
38
+ def fetch(self, source_id: str, *, version: str | None = None) -> Path:
39
+ """Download / resolve a source into a local package path."""
40
+
41
+ @abstractmethod
42
+ def parse(self, path: str | Path) -> Any:
43
+ """Parse a local package into a ``ParseResult`` (or authority equivalent)."""
44
+
45
+ def normalize_designation(self, text: str) -> str:
46
+ """Optional authority-specific designation normalization."""
47
+ return text.strip()
@@ -0,0 +1,46 @@
1
+ """EASA Easy Access Rules adapter (production path)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from ..input.package import OpcPackage
9
+ from ..parser import EasaDocumentParser
10
+ from ..sources.registry import list_sources as registry_list
11
+ from ..util.slugify import normalize_designation
12
+ from .base import AdapterCapabilities, RegulationAdapter
13
+
14
+
15
+ class EasaAdapter(RegulationAdapter):
16
+ """Full EASA pipeline: registry + fetch + Flat OPC/SDT parse → AST."""
17
+
18
+ authority = "easa"
19
+
20
+ def capabilities(self) -> AdapterCapabilities:
21
+ return AdapterCapabilities(
22
+ authority=self.authority,
23
+ fetch=True,
24
+ parse=True,
25
+ search=True,
26
+ designations=True,
27
+ notes="Production adapter for EASA Easy Access Rules XML exports.",
28
+ planned=[],
29
+ )
30
+
31
+ def list_sources(self) -> list[dict[str, Any]]:
32
+ return list(registry_list())
33
+
34
+ def fetch(self, source_id: str, *, version: str | None = None) -> Path:
35
+ from ..sources import EasaDownloader
36
+
37
+ with EasaDownloader() as dl:
38
+ fetched = dl.fetch(source_id, version=version)
39
+ return Path(fetched.source_path)
40
+
41
+ def parse(self, path: str | Path) -> Any:
42
+ package = OpcPackage.from_file(path)
43
+ return EasaDocumentParser(package).parse()
44
+
45
+ def normalize_designation(self, text: str) -> str:
46
+ return normalize_designation(text)
@@ -0,0 +1,57 @@
1
+ """FAA regulations adapter (scaffold).
2
+
3
+ Planned sources (not implemented):
4
+
5
+ - eCFR Title 14 (FARs), especially Part 23 / Part 25 airworthiness
6
+ - FAA Advisory Circulars where structured XML/HTML is available
7
+
8
+ The shared Regulation AST already supports multi-authority documents; this
9
+ module only needs a package reader + designation normalizer when work resumes.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ from .base import AdapterCapabilities, RegulationAdapter
18
+
19
+
20
+ class FaaAdapter(RegulationAdapter):
21
+ """Scaffold for future FAA / eCFR ingestion."""
22
+
23
+ authority = "faa"
24
+
25
+ def capabilities(self) -> AdapterCapabilities:
26
+ return AdapterCapabilities(
27
+ authority=self.authority,
28
+ fetch=False,
29
+ parse=False,
30
+ search=False,
31
+ designations=False,
32
+ notes="Scaffold only. Prefer EASA designation quality before expanding.",
33
+ planned=[
34
+ "eCFR Title 14 package resolver",
35
+ "FAR section designation normalizer (e.g. § 23.2000)",
36
+ "Map AC / SFAR content into AMC/GM-like nodes where appropriate",
37
+ ],
38
+ )
39
+
40
+ def list_sources(self) -> list[dict[str, Any]]:
41
+ return []
42
+
43
+ def fetch(self, source_id: str, *, version: str | None = None) -> Path:
44
+ raise NotImplementedError(
45
+ "FAA adapter is a scaffold. Use authority='easa' or implement "
46
+ "eCFR fetch in easa_erules.adapters.faa."
47
+ )
48
+
49
+ def parse(self, path: str | Path) -> Any:
50
+ raise NotImplementedError(
51
+ "FAA adapter is a scaffold. No FAR/eCFR parser is implemented yet."
52
+ )
53
+
54
+ def normalize_designation(self, text: str) -> str:
55
+ # Placeholder: strip section sign and collapse spaces
56
+ cleaned = text.replace("§", "").strip()
57
+ return " ".join(cleaned.split())
File without changes