lawpy 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.
@@ -0,0 +1,6 @@
1
+ # Lawpy API Configuration
2
+ # Copy this file to .env and fill in your API key
3
+
4
+ # Your email ID for Korean National Law Information Center API
5
+ # For example, if your email is user@example.com, set this to "user"
6
+ LAWPY_API_KEY=your-email-id
@@ -0,0 +1,95 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ test:
11
+ name: Test on Python ${{ matrix.python-version }}
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install uv
26
+ uses: astral-sh/setup-uv@v4
27
+ with:
28
+ version: "latest"
29
+
30
+ - name: Install dependencies
31
+ run: uv sync --extra dev
32
+
33
+ - name: Run tests
34
+ run: uv run pytest --cov=src/lawpy --cov-report=xml
35
+
36
+ - name: Upload coverage to Codecov
37
+ uses: codecov/codecov-action@v4
38
+ if: matrix.python-version == '3.12'
39
+ with:
40
+ token: ${{ secrets.CODECOV_TOKEN }}
41
+ files: ./coverage.xml
42
+ flags: unittests
43
+ name: codecov-umbrella
44
+
45
+ lint:
46
+ name: Lint
47
+ runs-on: ubuntu-latest
48
+
49
+ steps:
50
+ - uses: actions/checkout@v4
51
+
52
+ - name: Set up Python
53
+ uses: actions/setup-python@v5
54
+ with:
55
+ python-version: "3.12"
56
+
57
+ - name: Install uv
58
+ uses: astral-sh/setup-uv@v4
59
+ with:
60
+ version: "latest"
61
+
62
+ - name: Install dependencies
63
+ run: uv sync --extra dev
64
+
65
+ - name: Run ruff
66
+ run: uv run ruff check src/lawpy tests
67
+
68
+ - name: Run mypy
69
+ run: uv run mypy src/lawpy
70
+
71
+ build:
72
+ name: Build package
73
+ runs-on: ubuntu-latest
74
+
75
+ steps:
76
+ - uses: actions/checkout@v4
77
+
78
+ - name: Set up Python
79
+ uses: actions/setup-python@v5
80
+ with:
81
+ python-version: "3.12"
82
+
83
+ - name: Install uv
84
+ uses: astral-sh/setup-uv@v4
85
+ with:
86
+ version: "latest"
87
+
88
+ - name: Build package
89
+ run: uv build
90
+
91
+ - name: Upload artifacts
92
+ uses: actions/upload-artifact@v4
93
+ with:
94
+ name: dist
95
+ path: dist/
@@ -0,0 +1,101 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version_bump:
7
+ description: 'Version bump type (major, minor, patch)'
8
+ required: true
9
+ default: 'patch'
10
+ type: choice
11
+ options:
12
+ - major
13
+ - minor
14
+ - patch
15
+ push:
16
+ tags:
17
+ - "v*.*.*"
18
+
19
+ permissions:
20
+ contents: write
21
+ id-token: write # Required for trusted publishing
22
+
23
+ jobs:
24
+ bump-version:
25
+ name: Bump Version
26
+ runs-on: ubuntu-latest
27
+ if: github.event_name == 'workflow_dispatch'
28
+
29
+ steps:
30
+ - name: Checkout
31
+ uses: actions/checkout@v4
32
+ with:
33
+ fetch-depth: 0
34
+ token: ${{ secrets.GITHUB_TOKEN }}
35
+
36
+ - name: Set up Python
37
+ uses: actions/setup-python@v5
38
+ with:
39
+ python-version: "3.12"
40
+
41
+ - name: Install uv
42
+ uses: astral-sh/setup-uv@v4
43
+ with:
44
+ version: "latest"
45
+
46
+ - name: Install dependencies
47
+ run: uv sync --extra dev
48
+
49
+ - name: Configure Git
50
+ run: |
51
+ git config --global user.name "github-actions[bot]"
52
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
53
+
54
+ - name: Bump version
55
+ run: |
56
+ uv run bump-my-version ${{ github.event.inputs.version_bump }}
57
+
58
+ - name: Push changes
59
+ run: |
60
+ git push origin main
61
+ git push origin --tags
62
+
63
+ publish:
64
+ name: Publish to PyPI
65
+ runs-on: ubuntu-latest
66
+ if: github.event_name == 'push'
67
+
68
+ steps:
69
+ - name: Checkout
70
+ uses: actions/checkout@v4
71
+
72
+ - name: Set up Python
73
+ uses: actions/setup-python@v5
74
+ with:
75
+ python-version: "3.12"
76
+
77
+ - name: Install uv
78
+ uses: astral-sh/setup-uv@v4
79
+ with:
80
+ version: "latest"
81
+
82
+ - name: Build package
83
+ run: uv build
84
+
85
+ - name: Publish to PyPI
86
+ uses: pypa/gh-action-pypi-publish@release/v1
87
+
88
+ create-release:
89
+ name: Create GitHub Release
90
+ runs-on: ubuntu-latest
91
+ needs: publish
92
+ if: github.event_name == 'push'
93
+
94
+ steps:
95
+ - uses: actions/checkout@v4
96
+
97
+ - name: Create Release
98
+ uses: softprops/action-gh-release@v2
99
+ with:
100
+ generate_release_notes: true
101
+ files: dist/*
lawpy-0.1.0/.gitignore ADDED
@@ -0,0 +1,41 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Testing
13
+ .coverage
14
+ htmlcov/
15
+ .pytest_cache/
16
+
17
+ # Type checking
18
+ .mypy_cache/
19
+ .dmypy.json
20
+ dmypy.json
21
+
22
+ # IDEs
23
+ .vscode/
24
+ .idea/
25
+ *.swp
26
+ *.swo
27
+ *~
28
+
29
+ # OS
30
+ .DS_Store
31
+ Thumbs.db
32
+
33
+ # Project specific
34
+ .ruff_cache/
35
+
36
+ # Environment variables
37
+ .env
38
+
39
+ # Test scripts
40
+ temp_*.py
41
+ debug_*.py
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,25 @@
1
+ # Contributing to lawpy
2
+
3
+ Thank you for your interest in contributing! This guide outlines the process for submitting contributions to this project.
4
+
5
+ ## How to Contribute
6
+ 1. **Report Bugs**: Open an issue describing the bug and providing a reproduction script if possible.
7
+ 2. **Suggest Features**: Open an issue to discuss new features or improvements.
8
+ 3. **Submit Code**:
9
+ - Fork the repository and create a feature branch (`feat/your-feature`).
10
+ - Follow the technical standards defined in **[CONVENTIONS.md](./CONVENTIONS.md)**.
11
+ - Ensure all tests pass locally using `uv run pytest`.
12
+ - Submit a Pull Request (PR) to the `develop` branch.
13
+
14
+ ## Development Setup
15
+ We use `uv` for dependency management:
16
+ ```bash
17
+ uv sync --extra dev
18
+ uv run ruff check --fix
19
+ uv run mypy src/lawpy
20
+ ```
21
+
22
+ ## Pull Request Guidelines
23
+ - Keep PRs focused on a single change.
24
+ - Update documentation in `README.md` if your change affects public APIs.
25
+ - A maintainer will review your PR and provide feedback.
@@ -0,0 +1,19 @@
1
+ # Project Conventions
2
+
3
+ This document defines the core engineering standards and architectural rules for `lawpy`. These conventions must be strictly followed by all developers and AI agents to ensure code quality and system integrity.
4
+
5
+ ## 1. Engineering Standards
6
+ - **Data Modeling**: All data structures for public APIs must use **Pydantic (v2+)** models. Plain classes or dictionaries are prohibited for data interfaces.
7
+ - **Type Safety**: Full Python type hints are mandatory for all function signatures and public APIs.
8
+ - **Inheritance**: All country-specific law clients must inherit from `lawpy.client.LawClient` to maintain a unified HTTP client lifecycle.
9
+ - **Code Style**: We strictly adhere to `ruff` and `mypy` configurations as defined in `pyproject.toml`.
10
+
11
+ ## 2. File & Development Management
12
+ - **Test Organization**: Formal tests reside in `tests/` as `test_*.py`.
13
+ - **Scratchpads**: Use the `temp_*.py` prefix for local debugging or experiments. These are git-ignored and must never be committed.
14
+ - **Documentation**: All public methods must include Google-style docstrings.
15
+
16
+ ## 3. Governance & CI/CD
17
+ - **Branch Protection**: No direct pushes to `main` or `develop`. All changes require a Pull Request.
18
+ - **CI Enforcement**: Passing all CI checks (Tests, Lint, Type-check) is a non-negotiable prerequisite for merging.
19
+ - **Automated Releases**: Deployment to PyPI is strictly automated via GitHub Actions (OIDC) triggered by `v*.*.*` tags. Manual uploads are prohibited.
lawpy-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: lawpy
3
+ Version: 0.1.0
4
+ Summary: Universal law information API client library
5
+ Project-URL: Homepage, https://github.com/statpan/lawpy
6
+ Project-URL: Documentation, https://github.com/statpan/lawpy#readme
7
+ Project-URL: Repository, https://github.com/statpan/lawpy
8
+ Project-URL: Issues, https://github.com/statpan/lawpy/issues
9
+ Author-email: statpan <your-email@example.com>
10
+ License: MIT
11
+ Keywords: api,korea,law,legal,openapi
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.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: httpx>=0.27.0
23
+ Requires-Dist: pydantic>=2.7.0
24
+ Requires-Dist: xmltodict>=0.13.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: bump-my-version>=0.27.0; extra == 'dev'
27
+ Requires-Dist: mypy>=1.11.0; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
31
+ Requires-Dist: responses>=0.25.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
33
+ Requires-Dist: types-requests>=2.32.0; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # lawpy
37
+
38
+ Universal law information API client library.
39
+
40
+ ## Features
41
+
42
+ - **Multi-country support**: Access law APIs from multiple countries (currently Korea)
43
+ - **Simple interface**: Intuitive API design for easy integration
44
+ - **Type-safe**: Full type hints for better IDE support
45
+ - **Well-tested**: Comprehensive test coverage
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install lawpy
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### Korean Law API
56
+
57
+ Set your API key (email ID) as an environment variable:
58
+
59
+ ```bash
60
+ export LAWPY_API_KEY="your-email-id"
61
+ ```
62
+
63
+ Or pass it directly:
64
+
65
+ ```python
66
+ from lawpy import KoreanLawClient
67
+
68
+ # Using environment variable
69
+ client = KoreanLawClient()
70
+
71
+ # Or pass api_key directly
72
+ client = KoreanLawClient(api_key="your-api-key")
73
+ ```
74
+
75
+ #### Search for laws
76
+
77
+ ```python
78
+ laws = client.search_laws("민법", per_page=5)
79
+ for law in laws:
80
+ print(f"{law.law_name} (ID: {law.law_id})")
81
+ ```
82
+
83
+ #### Get detailed law information
84
+
85
+ ```python
86
+ law_detail = client.get_law_detail(law_id="001706")
87
+ print(f"Law: {law_detail.law_name_korean}")
88
+ print(f"Ministry: {law_detail.ministry}")
89
+ print(f"Promulgation Date: {law_detail.promulgation_date}")
90
+ print(f"Enforcement Date: {law_detail.enforcement_date}")
91
+
92
+ # Access articles
93
+ for article in law_detail.articles[:3]:
94
+ print(f"Article {article.number}: {article.title}")
95
+ for paragraph in article.paragraphs:
96
+ print(f" {paragraph.content}")
97
+ ```
98
+
99
+ #### Get specific article
100
+
101
+ ```python
102
+ law_detail = client.get_law_detail(law_id="001706", article_number=1)
103
+ ```
104
+
105
+ #### Get law by MST (master number)
106
+
107
+ ```python
108
+ law_detail = client.get_law_detail(mst=123456)
109
+ ```
110
+
111
+ #### Get original text
112
+
113
+ ```python
114
+ law_detail = client.get_law_detail(law_id="001706", language="ORI")
115
+ ```
116
+
117
+ #### Get current law list
118
+
119
+ ```python
120
+ laws = client.get_law_list(per_page=10)
121
+ for law in laws:
122
+ print(f"{law.law_name} (Effective: {law.enforcement_date})")
123
+ ```
124
+
125
+ #### Get law amendment history
126
+
127
+ ```python
128
+ history = client.get_law_history(query="민법", per_page=10)
129
+ for h in history:
130
+ print(f"{h.law_name} ({h.promulgation_date})")
131
+ ```
132
+
133
+ #### Get detailed law history
134
+
135
+ ```python
136
+ history_detail = client.get_law_history_detail(mst=9094)
137
+ print(history_detail) # Returns HTML text
138
+ ```
139
+
140
+ ## API Key
141
+
142
+ To use the Korean Law API, you need an API key:
143
+
144
+ 1. Visit [Korean Law Open API](https://open.law.go.kr/)
145
+ 2. Sign up and get your email ID as API key
146
+ 3. Set it as environment variable: `LAWPY_API_KEY`
147
+
148
+ ## Development
149
+
150
+ ```bash
151
+ # Clone repository
152
+ git clone https://github.com/statpan/lawpy.git
153
+ cd lawpy
154
+
155
+ # Install development dependencies
156
+ uv sync --extra dev
157
+
158
+ # Run tests
159
+ uv run pytest
160
+
161
+ # Run linting
162
+ uv run ruff check src/lawpy tests
163
+ uv run ruff format src/lawpy tests
164
+
165
+ # Type checking
166
+ uv run mypy src/lawpy
167
+
168
+ # Build package
169
+ uv build
170
+ ```
171
+
172
+ ## Project Structure
173
+
174
+ ```
175
+ lawpy/
176
+ ├── src/lawpy/
177
+ │ ├── __init__.py
178
+ │ ├── client.py # Base client class
179
+ │ ├── exceptions.py # Exception definitions
180
+ │ ├── models.py # Data models
181
+ │ └── kr/ # Korean API modules
182
+ │ ├── __init__.py
183
+ │ ├── base.py # Base class for Korean clients
184
+ │ ├── client.py # Integrated Korean client
185
+ │ ├── law.py # Law (법령) APIs
186
+ │ └── README.md # Korean API documentation
187
+ └── tests/
188
+ └── test_kr.py # Korean API tests
189
+ ```
190
+
191
+ ## Roadmap
192
+
193
+ - [ ] Add more countries (Japan, China, etc.)
194
+ - [ ] Implement all Korean Law API categories
195
+ - [ ] Add async support
196
+ - [ ] Add caching layer
197
+
198
+ ## Contributing
199
+
200
+ Contributions are welcome! Please feel free to submit a Pull Request.
201
+
202
+ ## License
203
+
204
+ MIT License - see [LICENSE](LICENSE) for details.
205
+
206
+ ## Links
207
+
208
+ - [GitHub Repository](https://github.com/statpan/lawpy)
209
+ - [PyPI Package](https://pypi.org/project/lawpy/)
210
+ - [Korean Law Open API Guide](https://open.law.go.kr/LSO/openApi/guideList.do)
lawpy-0.1.0/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # lawpy
2
+
3
+ Universal law information API client library.
4
+
5
+ ## Features
6
+
7
+ - **Multi-country support**: Access law APIs from multiple countries (currently Korea)
8
+ - **Simple interface**: Intuitive API design for easy integration
9
+ - **Type-safe**: Full type hints for better IDE support
10
+ - **Well-tested**: Comprehensive test coverage
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install lawpy
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ### Korean Law API
21
+
22
+ Set your API key (email ID) as an environment variable:
23
+
24
+ ```bash
25
+ export LAWPY_API_KEY="your-email-id"
26
+ ```
27
+
28
+ Or pass it directly:
29
+
30
+ ```python
31
+ from lawpy import KoreanLawClient
32
+
33
+ # Using environment variable
34
+ client = KoreanLawClient()
35
+
36
+ # Or pass api_key directly
37
+ client = KoreanLawClient(api_key="your-api-key")
38
+ ```
39
+
40
+ #### Search for laws
41
+
42
+ ```python
43
+ laws = client.search_laws("민법", per_page=5)
44
+ for law in laws:
45
+ print(f"{law.law_name} (ID: {law.law_id})")
46
+ ```
47
+
48
+ #### Get detailed law information
49
+
50
+ ```python
51
+ law_detail = client.get_law_detail(law_id="001706")
52
+ print(f"Law: {law_detail.law_name_korean}")
53
+ print(f"Ministry: {law_detail.ministry}")
54
+ print(f"Promulgation Date: {law_detail.promulgation_date}")
55
+ print(f"Enforcement Date: {law_detail.enforcement_date}")
56
+
57
+ # Access articles
58
+ for article in law_detail.articles[:3]:
59
+ print(f"Article {article.number}: {article.title}")
60
+ for paragraph in article.paragraphs:
61
+ print(f" {paragraph.content}")
62
+ ```
63
+
64
+ #### Get specific article
65
+
66
+ ```python
67
+ law_detail = client.get_law_detail(law_id="001706", article_number=1)
68
+ ```
69
+
70
+ #### Get law by MST (master number)
71
+
72
+ ```python
73
+ law_detail = client.get_law_detail(mst=123456)
74
+ ```
75
+
76
+ #### Get original text
77
+
78
+ ```python
79
+ law_detail = client.get_law_detail(law_id="001706", language="ORI")
80
+ ```
81
+
82
+ #### Get current law list
83
+
84
+ ```python
85
+ laws = client.get_law_list(per_page=10)
86
+ for law in laws:
87
+ print(f"{law.law_name} (Effective: {law.enforcement_date})")
88
+ ```
89
+
90
+ #### Get law amendment history
91
+
92
+ ```python
93
+ history = client.get_law_history(query="민법", per_page=10)
94
+ for h in history:
95
+ print(f"{h.law_name} ({h.promulgation_date})")
96
+ ```
97
+
98
+ #### Get detailed law history
99
+
100
+ ```python
101
+ history_detail = client.get_law_history_detail(mst=9094)
102
+ print(history_detail) # Returns HTML text
103
+ ```
104
+
105
+ ## API Key
106
+
107
+ To use the Korean Law API, you need an API key:
108
+
109
+ 1. Visit [Korean Law Open API](https://open.law.go.kr/)
110
+ 2. Sign up and get your email ID as API key
111
+ 3. Set it as environment variable: `LAWPY_API_KEY`
112
+
113
+ ## Development
114
+
115
+ ```bash
116
+ # Clone repository
117
+ git clone https://github.com/statpan/lawpy.git
118
+ cd lawpy
119
+
120
+ # Install development dependencies
121
+ uv sync --extra dev
122
+
123
+ # Run tests
124
+ uv run pytest
125
+
126
+ # Run linting
127
+ uv run ruff check src/lawpy tests
128
+ uv run ruff format src/lawpy tests
129
+
130
+ # Type checking
131
+ uv run mypy src/lawpy
132
+
133
+ # Build package
134
+ uv build
135
+ ```
136
+
137
+ ## Project Structure
138
+
139
+ ```
140
+ lawpy/
141
+ ├── src/lawpy/
142
+ │ ├── __init__.py
143
+ │ ├── client.py # Base client class
144
+ │ ├── exceptions.py # Exception definitions
145
+ │ ├── models.py # Data models
146
+ │ └── kr/ # Korean API modules
147
+ │ ├── __init__.py
148
+ │ ├── base.py # Base class for Korean clients
149
+ │ ├── client.py # Integrated Korean client
150
+ │ ├── law.py # Law (법령) APIs
151
+ │ └── README.md # Korean API documentation
152
+ └── tests/
153
+ └── test_kr.py # Korean API tests
154
+ ```
155
+
156
+ ## Roadmap
157
+
158
+ - [ ] Add more countries (Japan, China, etc.)
159
+ - [ ] Implement all Korean Law API categories
160
+ - [ ] Add async support
161
+ - [ ] Add caching layer
162
+
163
+ ## Contributing
164
+
165
+ Contributions are welcome! Please feel free to submit a Pull Request.
166
+
167
+ ## License
168
+
169
+ MIT License - see [LICENSE](LICENSE) for details.
170
+
171
+ ## Links
172
+
173
+ - [GitHub Repository](https://github.com/statpan/lawpy)
174
+ - [PyPI Package](https://pypi.org/project/lawpy/)
175
+ - [Korean Law Open API Guide](https://open.law.go.kr/LSO/openApi/guideList.do)