law4devs 0.1.0__tar.gz

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 (50) hide show
  1. law4devs-0.1.0/.github/workflows/publish.yml +18 -0
  2. law4devs-0.1.0/.github/workflows/test.yml +15 -0
  3. law4devs-0.1.0/.gitignore +17 -0
  4. law4devs-0.1.0/CHANGELOG.md +11 -0
  5. law4devs-0.1.0/LICENSE +21 -0
  6. law4devs-0.1.0/PKG-INFO +230 -0
  7. law4devs-0.1.0/README.md +207 -0
  8. law4devs-0.1.0/examples/compliance_report.py +49 -0
  9. law4devs-0.1.0/examples/quickstart.py +58 -0
  10. law4devs-0.1.0/law4devs/__init__.py +48 -0
  11. law4devs-0.1.0/law4devs/_http.py +79 -0
  12. law4devs-0.1.0/law4devs/_pagination.py +30 -0
  13. law4devs-0.1.0/law4devs/_version.py +1 -0
  14. law4devs-0.1.0/law4devs/client.py +46 -0
  15. law4devs-0.1.0/law4devs/exceptions.py +19 -0
  16. law4devs-0.1.0/law4devs/models/__init__.py +19 -0
  17. law4devs-0.1.0/law4devs/models/annex.py +34 -0
  18. law4devs-0.1.0/law4devs/models/article.py +62 -0
  19. law4devs-0.1.0/law4devs/models/compliance.py +25 -0
  20. law4devs-0.1.0/law4devs/models/framework.py +72 -0
  21. law4devs-0.1.0/law4devs/models/recital.py +21 -0
  22. law4devs-0.1.0/law4devs/models/requirement.py +37 -0
  23. law4devs-0.1.0/law4devs/models/search.py +32 -0
  24. law4devs-0.1.0/law4devs/models/tag.py +26 -0
  25. law4devs-0.1.0/law4devs/py.typed +0 -0
  26. law4devs-0.1.0/law4devs/resources/__init__.py +21 -0
  27. law4devs-0.1.0/law4devs/resources/_base.py +49 -0
  28. law4devs-0.1.0/law4devs/resources/annexes.py +19 -0
  29. law4devs-0.1.0/law4devs/resources/articles.py +23 -0
  30. law4devs-0.1.0/law4devs/resources/compliance.py +20 -0
  31. law4devs-0.1.0/law4devs/resources/frameworks.py +25 -0
  32. law4devs-0.1.0/law4devs/resources/recitals.py +19 -0
  33. law4devs-0.1.0/law4devs/resources/requirements.py +20 -0
  34. law4devs-0.1.0/law4devs/resources/search.py +16 -0
  35. law4devs-0.1.0/law4devs/resources/tags.py +19 -0
  36. law4devs-0.1.0/pyproject.toml +39 -0
  37. law4devs-0.1.0/tests/conftest.py +27 -0
  38. law4devs-0.1.0/tests/test_annexes.py +31 -0
  39. law4devs-0.1.0/tests/test_articles.py +40 -0
  40. law4devs-0.1.0/tests/test_client.py +71 -0
  41. law4devs-0.1.0/tests/test_compliance.py +30 -0
  42. law4devs-0.1.0/tests/test_exceptions.py +44 -0
  43. law4devs-0.1.0/tests/test_frameworks.py +47 -0
  44. law4devs-0.1.0/tests/test_iter.py +135 -0
  45. law4devs-0.1.0/tests/test_models.py +184 -0
  46. law4devs-0.1.0/tests/test_pagination.py +42 -0
  47. law4devs-0.1.0/tests/test_recitals.py +30 -0
  48. law4devs-0.1.0/tests/test_requirements.py +29 -0
  49. law4devs-0.1.0/tests/test_search.py +30 -0
  50. law4devs-0.1.0/tests/test_tags.py +30 -0
@@ -0,0 +1,18 @@
1
+ name: Publish to PyPI
2
+ on:
3
+ push:
4
+ tags: ["v*"]
5
+ jobs:
6
+ publish:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - uses: actions/setup-python@v5
11
+ with:
12
+ python-version: "3.11"
13
+ - run: pip install build twine
14
+ - run: python -m build
15
+ - run: twine upload dist/*
16
+ env:
17
+ TWINE_USERNAME: __token__
18
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,15 @@
1
+ name: Tests
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ python-version: ["3.9", "3.11", "3.12"]
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - uses: actions/setup-python@v5
12
+ with:
13
+ python-version: "${{ matrix.python-version }}"
14
+ - run: pip install -e ".[dev]"
15
+ - run: pytest
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.pyo
4
+ *.pyd
5
+ .Python
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ .eggs/
10
+ .env
11
+ .venv
12
+ venv/
13
+ env/
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ *.egg
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] — Unreleased
4
+
5
+ ### Added
6
+ - Initial release with full coverage of the Law4Devs REST API
7
+ - `FrameworksResource`, `ArticlesResource`, `RecitalsResource`, `RequirementsResource`
8
+ - `TagsResource`, `ComplianceResource`, `AnnexesResource`, `SearchResource`
9
+ - Auto-pagination via `iter()` generators on all list resources
10
+ - Zero runtime dependencies (stdlib urllib only)
11
+ - Full type annotations with dataclasses
law4devs-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 law4devs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: law4devs
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the Law4Devs EU Regulatory Compliance API
5
+ Project-URL: Homepage, https://law4devs.eu
6
+ Project-URL: Documentation, https://docs.law4devs.eu/sdks/python
7
+ Author-email: law4devs <sdk@law4devs.eu>
8
+ Maintainer-email: Sofiane Hamlaoui <contact@law4devs.eu>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai-act,compliance,cra,eu,gdpr,law4devs,nis2,regulatory
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+
24
+ # law4devs
25
+
26
+ Official Python SDK for the [Law4Devs](https://law4devs.eu) EU Regulatory Compliance API.
27
+
28
+ Access structured, developer-friendly data for EU regulations — GDPR, Cyber Resilience Act, NIS2, AI Act, and more.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install law4devs
34
+ ```
35
+
36
+ Python 3.9+ required. Zero runtime dependencies (stdlib urllib only).
37
+
38
+ ## Quick Start
39
+
40
+ ```python
41
+ from law4devs import Law4DevsClient
42
+
43
+ client = Law4DevsClient()
44
+
45
+ # List all frameworks
46
+ page = client.frameworks.list()
47
+ for fw in page:
48
+ print(fw.slug, fw.name)
49
+
50
+ # Get framework detail
51
+ cra = client.frameworks.get("cra")
52
+ print(cra.name, cra.requirement_count)
53
+
54
+ # Fetch a specific article
55
+ article = client.articles.get("cra", 13)
56
+ print(article.title, article.content)
57
+ ```
58
+
59
+ ## Authentication
60
+
61
+ The public API tier does not require authentication. Authenticated tiers provide higher rate limits:
62
+
63
+ ```python
64
+ client = Law4DevsClient(api_key="your-api-key")
65
+ ```
66
+
67
+ ## Resources
68
+
69
+ ### Frameworks
70
+
71
+ ```python
72
+ page = client.frameworks.list(page=1, per_page=10)
73
+ print(page.meta.total, page.meta.pages)
74
+
75
+ cra = client.frameworks.get("cra")
76
+
77
+ for fw in client.frameworks.iter():
78
+ print(fw.slug)
79
+ ```
80
+
81
+ ### Articles
82
+
83
+ ```python
84
+ page = client.articles.list("cra", per_page=20)
85
+ art = client.articles.get("cra", 13)
86
+ related = client.articles.related("cra", 13)
87
+
88
+ for art in client.articles.iter("cra"):
89
+ print(art.article_number, art.title)
90
+ ```
91
+
92
+ ### Recitals
93
+
94
+ ```python
95
+ page = client.recitals.list("cra")
96
+ recital = client.recitals.get("cra", 10)
97
+
98
+ for recital in client.recitals.iter("cra"):
99
+ print(recital.recital_number, recital.content[:80])
100
+ ```
101
+
102
+ ### Requirements
103
+
104
+ ```python
105
+ page = client.requirements.list()
106
+ page = client.requirements.list(framework_slug="cra")
107
+
108
+ for req in client.requirements.iter(framework_slug="cra"):
109
+ print(req.requirement_type, req.requirement_text[:60])
110
+ ```
111
+
112
+ ### Compliance Deadlines
113
+
114
+ ```python
115
+ page = client.compliance.deadlines()
116
+ page = client.compliance.deadlines(framework_slug="nis2")
117
+
118
+ for d in client.compliance.iter_deadlines(framework_slug="nis2"):
119
+ print(d.deadline_date, d.description)
120
+ ```
121
+
122
+ ### Tags
123
+
124
+ ```python
125
+ page = client.tags.list()
126
+ tag = client.tags.get("security")
127
+
128
+ for tag in client.tags.iter():
129
+ print(tag.slug, tag.name)
130
+ ```
131
+
132
+ ### Annexes
133
+
134
+ ```python
135
+ page = client.annexes.list("cra")
136
+ annex = client.annexes.get("cra", "I")
137
+
138
+ for annex in client.annexes.iter("cra"):
139
+ print(annex.annex_number, annex.title)
140
+ ```
141
+
142
+ ### Search
143
+
144
+ ```python
145
+ results = client.search.query("vulnerability reporting")
146
+ results = client.search.query("audit", framework="gdpr")
147
+ results = client.search.query("encryption", result_type="requirement")
148
+ ```
149
+
150
+ ## Auto-Pagination
151
+
152
+ All list resources support `iter()` which automatically fetches all pages:
153
+
154
+ ```python
155
+ all_articles = list(client.articles.iter("cra"))
156
+
157
+ for art in client.articles.iter("cra", per_page=50):
158
+ process(art)
159
+ ```
160
+
161
+ ## Error Handling
162
+
163
+ ```python
164
+ from law4devs import Law4DevsClient, NotFoundError, RateLimitError, Law4DevsError
165
+
166
+ client = Law4DevsClient()
167
+
168
+ try:
169
+ fw = client.frameworks.get("nonexistent")
170
+ except NotFoundError as e:
171
+ print(f"Not found: {e} (status {e.status_code})")
172
+ except RateLimitError:
173
+ print("Rate limited — slow down requests")
174
+ except Law4DevsError as e:
175
+ print(f"API error: {e}")
176
+ ```
177
+
178
+ ### Exception Hierarchy
179
+
180
+ | Exception | HTTP Status | Description |
181
+ |-----------|-------------|-------------|
182
+ | `Law4DevsError` | any | Base exception |
183
+ | `NotFoundError` | 404 | Resource not found |
184
+ | `ValidationError` | 400 | Invalid request parameters |
185
+ | `RateLimitError` | 429 | Rate limit exceeded |
186
+ | `ServerError` | 5xx | Server-side error |
187
+
188
+ ## Configuration
189
+
190
+ | Parameter | Default | Description |
191
+ |-----------|---------|-------------|
192
+ | `base_url` | `https://api.law4devs.eu/api/v1` | API base URL |
193
+ | `api_key` | `None` | API key for authenticated tiers |
194
+ | `timeout` | `30` | Request timeout in seconds |
195
+ | `max_retries` | `3` | Retries on 429/5xx with exponential backoff |
196
+
197
+ ## Available Frameworks
198
+
199
+ | Slug | Name | CELEX | Status |
200
+ |------|------|-------|--------|
201
+ | `cra` | Cyber Resilience Act | 32024R2847 | active |
202
+ | `nis2` | NIS2 Directive | 32022L2555 | active |
203
+ | `dora` | Digital Operational Resilience Act | 32022R2554 | active |
204
+ | `gdpr` | General Data Protection Regulation | 32016R0679 | active |
205
+ | `ai_act` | AI Act | 32024R1689 | active |
206
+ | `eidas` | eIDAS Regulation | 32014R0910 | active |
207
+ | `dsa` | Digital Services Act | 32022R2065 | active |
208
+ | `dma` | Digital Markets Act | 32022R1925 | active |
209
+ | `data_act` | Data Act | 32023R2854 | active |
210
+ | `dga` | Data Governance Act | 32022R0868 | active |
211
+ | `eidas2` | European Digital Identity Regulation | 32024R1183 | active |
212
+ | `cer` | Critical Entities Resilience Directive | 32022L2557 | active |
213
+ | `psd2` | Payment Services Directive 2 | 32015L2366 | active |
214
+ | `mica` | Markets in Crypto-Assets Regulation | 32023R1114 | active |
215
+ | `cybersecurity_act` | Cybersecurity Act | 32019R0881 | active |
216
+ | `eprivacy` | ePrivacy Directive | 32002L0058 | active |
217
+ | `red` | Radio Equipment Directive | 32014L0053 | active |
218
+ | `csrd` | Corporate Sustainability Reporting Dir. | 32022L2464 | active |
219
+ | `nis1` | NIS Directive (Original) | 32016L1148 | superseded |
220
+
221
+
222
+ ## License
223
+
224
+ MIT License. See [LICENSE](LICENSE) for details.
225
+
226
+ ## Links
227
+
228
+ - [Law4Devs API](https://law4devs.eu)
229
+ - [API Reference](https://docs.law4devs.eu)
230
+ - [PyPI](https://pypi.org/project/law4devs/)
@@ -0,0 +1,207 @@
1
+ # law4devs
2
+
3
+ Official Python SDK for the [Law4Devs](https://law4devs.eu) EU Regulatory Compliance API.
4
+
5
+ Access structured, developer-friendly data for EU regulations — GDPR, Cyber Resilience Act, NIS2, AI Act, and more.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install law4devs
11
+ ```
12
+
13
+ Python 3.9+ required. Zero runtime dependencies (stdlib urllib only).
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ from law4devs import Law4DevsClient
19
+
20
+ client = Law4DevsClient()
21
+
22
+ # List all frameworks
23
+ page = client.frameworks.list()
24
+ for fw in page:
25
+ print(fw.slug, fw.name)
26
+
27
+ # Get framework detail
28
+ cra = client.frameworks.get("cra")
29
+ print(cra.name, cra.requirement_count)
30
+
31
+ # Fetch a specific article
32
+ article = client.articles.get("cra", 13)
33
+ print(article.title, article.content)
34
+ ```
35
+
36
+ ## Authentication
37
+
38
+ The public API tier does not require authentication. Authenticated tiers provide higher rate limits:
39
+
40
+ ```python
41
+ client = Law4DevsClient(api_key="your-api-key")
42
+ ```
43
+
44
+ ## Resources
45
+
46
+ ### Frameworks
47
+
48
+ ```python
49
+ page = client.frameworks.list(page=1, per_page=10)
50
+ print(page.meta.total, page.meta.pages)
51
+
52
+ cra = client.frameworks.get("cra")
53
+
54
+ for fw in client.frameworks.iter():
55
+ print(fw.slug)
56
+ ```
57
+
58
+ ### Articles
59
+
60
+ ```python
61
+ page = client.articles.list("cra", per_page=20)
62
+ art = client.articles.get("cra", 13)
63
+ related = client.articles.related("cra", 13)
64
+
65
+ for art in client.articles.iter("cra"):
66
+ print(art.article_number, art.title)
67
+ ```
68
+
69
+ ### Recitals
70
+
71
+ ```python
72
+ page = client.recitals.list("cra")
73
+ recital = client.recitals.get("cra", 10)
74
+
75
+ for recital in client.recitals.iter("cra"):
76
+ print(recital.recital_number, recital.content[:80])
77
+ ```
78
+
79
+ ### Requirements
80
+
81
+ ```python
82
+ page = client.requirements.list()
83
+ page = client.requirements.list(framework_slug="cra")
84
+
85
+ for req in client.requirements.iter(framework_slug="cra"):
86
+ print(req.requirement_type, req.requirement_text[:60])
87
+ ```
88
+
89
+ ### Compliance Deadlines
90
+
91
+ ```python
92
+ page = client.compliance.deadlines()
93
+ page = client.compliance.deadlines(framework_slug="nis2")
94
+
95
+ for d in client.compliance.iter_deadlines(framework_slug="nis2"):
96
+ print(d.deadline_date, d.description)
97
+ ```
98
+
99
+ ### Tags
100
+
101
+ ```python
102
+ page = client.tags.list()
103
+ tag = client.tags.get("security")
104
+
105
+ for tag in client.tags.iter():
106
+ print(tag.slug, tag.name)
107
+ ```
108
+
109
+ ### Annexes
110
+
111
+ ```python
112
+ page = client.annexes.list("cra")
113
+ annex = client.annexes.get("cra", "I")
114
+
115
+ for annex in client.annexes.iter("cra"):
116
+ print(annex.annex_number, annex.title)
117
+ ```
118
+
119
+ ### Search
120
+
121
+ ```python
122
+ results = client.search.query("vulnerability reporting")
123
+ results = client.search.query("audit", framework="gdpr")
124
+ results = client.search.query("encryption", result_type="requirement")
125
+ ```
126
+
127
+ ## Auto-Pagination
128
+
129
+ All list resources support `iter()` which automatically fetches all pages:
130
+
131
+ ```python
132
+ all_articles = list(client.articles.iter("cra"))
133
+
134
+ for art in client.articles.iter("cra", per_page=50):
135
+ process(art)
136
+ ```
137
+
138
+ ## Error Handling
139
+
140
+ ```python
141
+ from law4devs import Law4DevsClient, NotFoundError, RateLimitError, Law4DevsError
142
+
143
+ client = Law4DevsClient()
144
+
145
+ try:
146
+ fw = client.frameworks.get("nonexistent")
147
+ except NotFoundError as e:
148
+ print(f"Not found: {e} (status {e.status_code})")
149
+ except RateLimitError:
150
+ print("Rate limited — slow down requests")
151
+ except Law4DevsError as e:
152
+ print(f"API error: {e}")
153
+ ```
154
+
155
+ ### Exception Hierarchy
156
+
157
+ | Exception | HTTP Status | Description |
158
+ |-----------|-------------|-------------|
159
+ | `Law4DevsError` | any | Base exception |
160
+ | `NotFoundError` | 404 | Resource not found |
161
+ | `ValidationError` | 400 | Invalid request parameters |
162
+ | `RateLimitError` | 429 | Rate limit exceeded |
163
+ | `ServerError` | 5xx | Server-side error |
164
+
165
+ ## Configuration
166
+
167
+ | Parameter | Default | Description |
168
+ |-----------|---------|-------------|
169
+ | `base_url` | `https://api.law4devs.eu/api/v1` | API base URL |
170
+ | `api_key` | `None` | API key for authenticated tiers |
171
+ | `timeout` | `30` | Request timeout in seconds |
172
+ | `max_retries` | `3` | Retries on 429/5xx with exponential backoff |
173
+
174
+ ## Available Frameworks
175
+
176
+ | Slug | Name | CELEX | Status |
177
+ |------|------|-------|--------|
178
+ | `cra` | Cyber Resilience Act | 32024R2847 | active |
179
+ | `nis2` | NIS2 Directive | 32022L2555 | active |
180
+ | `dora` | Digital Operational Resilience Act | 32022R2554 | active |
181
+ | `gdpr` | General Data Protection Regulation | 32016R0679 | active |
182
+ | `ai_act` | AI Act | 32024R1689 | active |
183
+ | `eidas` | eIDAS Regulation | 32014R0910 | active |
184
+ | `dsa` | Digital Services Act | 32022R2065 | active |
185
+ | `dma` | Digital Markets Act | 32022R1925 | active |
186
+ | `data_act` | Data Act | 32023R2854 | active |
187
+ | `dga` | Data Governance Act | 32022R0868 | active |
188
+ | `eidas2` | European Digital Identity Regulation | 32024R1183 | active |
189
+ | `cer` | Critical Entities Resilience Directive | 32022L2557 | active |
190
+ | `psd2` | Payment Services Directive 2 | 32015L2366 | active |
191
+ | `mica` | Markets in Crypto-Assets Regulation | 32023R1114 | active |
192
+ | `cybersecurity_act` | Cybersecurity Act | 32019R0881 | active |
193
+ | `eprivacy` | ePrivacy Directive | 32002L0058 | active |
194
+ | `red` | Radio Equipment Directive | 32014L0053 | active |
195
+ | `csrd` | Corporate Sustainability Reporting Dir. | 32022L2464 | active |
196
+ | `nis1` | NIS Directive (Original) | 32016L1148 | superseded |
197
+
198
+
199
+ ## License
200
+
201
+ MIT License. See [LICENSE](LICENSE) for details.
202
+
203
+ ## Links
204
+
205
+ - [Law4Devs API](https://law4devs.eu)
206
+ - [API Reference](https://docs.law4devs.eu)
207
+ - [PyPI](https://pypi.org/project/law4devs/)
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Law4Devs Python SDK — Compliance Report Example
4
+
5
+ Generates a compliance report for all active frameworks.
6
+
7
+ Usage:
8
+ python examples/compliance_report.py
9
+ """
10
+
11
+ import os
12
+ from law4devs import Law4DevsClient
13
+
14
+ BASE_URL = os.environ.get("LAW4DEVS_BASE_URL")
15
+ client = Law4DevsClient(base_url=BASE_URL) if BASE_URL else Law4DevsClient()
16
+
17
+
18
+ def generate_report():
19
+ print("=" * 60)
20
+ print("EU REGULATORY COMPLIANCE REPORT")
21
+ print("=" * 60)
22
+ print()
23
+
24
+ frameworks = [fw for fw in client.frameworks.iter() if fw.status == "active"]
25
+ print(f"Active frameworks: {len(frameworks)}")
26
+ print()
27
+
28
+ for fw in frameworks:
29
+ print(f"── {fw.name} ({fw.slug.upper()}) ──")
30
+ print(f" Articles: {fw.article_count}")
31
+
32
+ req_page = client.requirements.list(framework_slug=fw.slug, per_page=1)
33
+ print(f" Total requirements: {req_page.meta.total}")
34
+
35
+ deadlines_page = client.compliance.deadlines(framework_slug=fw.slug)
36
+ if deadlines_page.data:
37
+ print(" Deadlines:")
38
+ for d in sorted(deadlines_page.data, key=lambda x: x.deadline_date):
39
+ print(f" {d.deadline_date}: {d.description or d.deadline_type}")
40
+ else:
41
+ print(" Deadlines: none recorded")
42
+ print()
43
+
44
+ print("=" * 60)
45
+ print("Report complete.")
46
+
47
+
48
+ if __name__ == "__main__":
49
+ generate_report()
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Law4Devs Python SDK — Quick Start Example
4
+
5
+ Run against a live API:
6
+ python examples/quickstart.py
7
+
8
+ Or a local dev server:
9
+ LAW4DEVS_BASE_URL=http://localhost:5000/api/v1 python examples/quickstart.py
10
+ """
11
+
12
+ import os
13
+ from law4devs import Law4DevsClient
14
+
15
+ BASE_URL = os.environ.get("LAW4DEVS_BASE_URL")
16
+ client = Law4DevsClient(base_url=BASE_URL) if BASE_URL else Law4DevsClient()
17
+
18
+ # List all frameworks
19
+ print("=== EU Regulatory Frameworks ===")
20
+ page = client.frameworks.list()
21
+ print(f"Total frameworks: {page.meta.total}")
22
+ for fw in page:
23
+ status = " (superseded)" if fw.status == "superseded" else ""
24
+ print(f" [{fw.slug}] {fw.name}{status}")
25
+ print()
26
+
27
+ # Get framework detail
28
+ print("=== CRA Detail ===")
29
+ cra = client.frameworks.get("cra")
30
+ print(f"Name: {cra.name}")
31
+ print(f"Articles: {cra.article_count}")
32
+ print(f"Requirements: {cra.requirement_count}")
33
+ print(f"EUR-Lex URL: {cra.eurlex_url}")
34
+ print()
35
+
36
+ # Auto-paginate all articles
37
+ print("=== CRA Articles (auto-paginated) ===")
38
+ all_articles = list(client.articles.iter("cra"))
39
+ print(f"Fetched {len(all_articles)} articles")
40
+ for art in all_articles[:3]:
41
+ print(f" Article {art.article_number}: {art.title}")
42
+ if len(all_articles) > 3:
43
+ print(f" ... and {len(all_articles) - 3} more")
44
+ print()
45
+
46
+ # Compliance deadlines
47
+ print("=== CRA Compliance Deadlines ===")
48
+ deadlines = client.compliance.deadlines(framework_slug="cra")
49
+ for d in deadlines:
50
+ print(f" {d.deadline_date} [{d.deadline_type}] {d.description or ''}")
51
+ print()
52
+
53
+ # Search
54
+ print("=== Search: 'vulnerability' in CRA ===")
55
+ results = client.search.query("vulnerability", framework="cra")
56
+ print(f"Found {results.meta.total} results")
57
+ for r in results:
58
+ print(f" [{r.type}] {r.title or r.match_context[:60]}")
@@ -0,0 +1,48 @@
1
+ from ._version import __version__
2
+ from .client import Law4DevsClient
3
+ from .exceptions import (
4
+ Law4DevsError,
5
+ NotFoundError,
6
+ ValidationError,
7
+ RateLimitError,
8
+ ServerError,
9
+ )
10
+ from .models import (
11
+ Framework,
12
+ FrameworkDetail,
13
+ Article,
14
+ ArticleSummary,
15
+ ArticleParagraph,
16
+ Recital,
17
+ Requirement,
18
+ Tag,
19
+ ComplianceDeadline,
20
+ Annex,
21
+ AnnexSummary,
22
+ SearchResult,
23
+ )
24
+
25
+
26
+ __all__ = [
27
+ "Law4DevsClient",
28
+ "__version__",
29
+ # Exceptions
30
+ "Law4DevsError",
31
+ "NotFoundError",
32
+ "ValidationError",
33
+ "RateLimitError",
34
+ "ServerError",
35
+ # Models
36
+ "Framework",
37
+ "FrameworkDetail",
38
+ "Article",
39
+ "ArticleSummary",
40
+ "ArticleParagraph",
41
+ "Recital",
42
+ "Requirement",
43
+ "Tag",
44
+ "ComplianceDeadline",
45
+ "Annex",
46
+ "AnnexSummary",
47
+ "SearchResult",
48
+ ]