pyekw - Polish eKW (Land Registry) Utilities
A Python library for working with Polish eKW (Elektroniczne Księgi Wieczyste) land registry numbers.
Features
- KW Number Validation: Validate complete KW numbers including court codes and check digits
- Check Digit Generation: Calculate correct check digits for court codes and register numbers
- Court Registry: Comprehensive database of Polish courts handling land registry matters
- Utility Functions: Normalize, extract, and analyze KW numbers from various sources
Installation
uv add "git+https://github.com/mhajder/pyekw.git"
Quick Start
from pyekw import KWValidator, CheckDigitGenerator, CourtRegistry, KWUtils
# Validate a KW number
validator = KWValidator()
is_valid, error = validator.validate_kw_number("WA4M/00123456/4")
print(f"Valid: {is_valid}") # True
# Generate check digit
generator = CheckDigitGenerator()
check_digit = generator.calculate_check_digit("WA4M", "00123456")
print(f"Check digit: {check_digit}") # 4
# Work with court registry
registry = CourtRegistry()
court_name = registry.get_court_name("WA4M")
print(f"Court: {court_name}") # WARSZAWA
# Utility functions
utils = KWUtils()
normalized = utils.normalize_kw_number(" wa4m / 00123456 / 4 ")
print(f"Normalized: {normalized}") # WA4M/00123456/4
API Documentation
KWValidator
Class for validating Polish KW numbers.
Methods:
-
validate_kw_number(kw_number: str) -> Tuple[bool, Optional[str]]
Validates a complete KW number.
Returns:(is_valid, error_message) -
parse_kw_number(kw_number: str) -> Tuple[str, str, str]
Parses a KW number into its components: court code, register number, check digit. -
validate_court_code(court_code: str) -> bool
Checks if the court code is valid. -
validate_check_digit(court_code: str, register_number: str, check_digit: str) -> bool
Validates the check digit for given court code and register number.
CheckDigitGenerator
Class for generating check digits and full KW numbers.
Methods:
-
calculate_check_digit(court_code: str, register_number: str) -> int
Calculates the check digit for a given court code and register number. -
generate_full_kw_number(court_code: str, register_number: str) -> str
Generates a complete KW number with the correct check digit.
CourtRegistry
Class for working with the court database.
Methods:
-
is_valid_court(court_code: str) -> bool
Checks if a court code exists in the registry. -
get_court_name(court_code: str) -> str
Returns the name of the court for a given code. -
search_courts(query: str) -> List[Dict]
Searches courts by name or code. -
get_all_courts() -> Dict[str, str]
Returns a dictionary of all court codes and names.
KWUtils
Utility class for working with KW numbers.
Methods:
-
normalize_kw_number(kw_number: str) -> str
Normalizes the format of a KW number. -
extract_kw_numbers(text: str) -> List[str]
Extracts all KW numbers from a given text. -
get_kw_info(kw_number: str) -> Dict
Returns detailed information about a KW number. -
generate_kw_number_variants(court_code: str, start_number: int, count: int) -> List[str]
Generates a series of KW numbers. -
validate_multiple_kw_numbers(kw_numbers: List[str]) -> List[Tuple[str, bool, Optional[str]]]
Validates multiple KW numbers at once. -
suggest_corrections(kw_number: str) -> List[str]
Suggests possible corrections for an invalid KW number.
Examples
You can find example usage of all main functions and classes in the examples/ directory.
examples/example_all_functions.py: Demonstrates validation, parsing, check digit generation, court registry operations, and utility functions.
To run the example:
python examples/example_all_functions.py
Feel free to explore and modify the example to fit your use case.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Metadata
Release files for pyekw 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyekw-0.2.0.tar.gz | 116.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyekw-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 133.8 kB
Release files / pyekw-0.2.0.tar.gz
| Download URL | pyekw-0.2.0.tar.gz |
|---|---|
| Size | 116.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f63cd609683dcf31fef0b06e7f2c3f2ec406a3512658f3c7ed870aa27473105
|
|
BLAKE2b-256 checksum How to use checksums |
debdd8c4a2b788796db60ba2486912072c074532c74f22a5c2af4cbd80a0433f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 18, 2025.
Transparency logRelease files / pyekw-0.2.0-py3-none-any.whl
| Download URL | pyekw-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cfdae8f779fde8937983f57e486bbeec4790cfb31d0a3197429e47453d03989
|
|
BLAKE2b-256 checksum How to use checksums |
a3c1f0280b0ce84391b0bbb3252450ff0100130a46e72b474ad0a751ccc8f293
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 18, 2025.
Transparency log