Skip to main content

Python library for Iraqi vehicle plate normalization, parsing, validation, formatting, and comparison.

Project description

iraqi-plate

A Python library for parsing, normalizing, validating, formatting, and comparing Iraqi vehicle plate numbers.

It supports two acceptance modes:

  • strict
  • standard

It also supports legacy Arabic-letter input in standard mode, returning a canonical normalized value with a legacy warning.

Features

  • Normalize current Iraqi plate numbers into canonical form.
  • Parse structural input into explicit components.
  • Validate user input and return machine-readable issues.
  • Format canonical or parsed plates into canonical, display, or compact styles.
  • Compare two inputs by canonical identity.
  • Handle separator cleanup and Eastern Arabic digit folding.

Installation

pip install iraqi-plate

Quick start

from iraqi_plate import IraqiPlateService, PlateOptions, AcceptanceMode, FormatStyle

svc = IraqiPlateService()

result = svc.normalize_plate("A22153")
print(result.success)
print(result.canonical)

legacy = svc.normalize_plate("ا٢٢١٥٣")
print(legacy.success)
print(legacy.canonical)
print(legacy.warnings)

formatted = svc.format_plate("22A153", style=FormatStyle.DISPLAY)
print(formatted)

same = svc.equals("A22153", "22A153")
print(same)

strict_result = svc.validate_plate(
    "22-A-153",
    options=PlateOptions(mode=AcceptanceMode.STRICT),
)
print(strict_result.is_valid)

API

normalize_plate(input, options=None)

Returns NormalizeResult with:

  • success
  • canonical
  • plate
  • corrections
  • errors
  • warnings

parse_plate(input, options=None)

Returns ParseResult with structural parsing results.

validate_plate(input, options=None)

Returns ValidationResult with:

  • is_valid
  • plate
  • issues

format_plate(input_or_plate, style=FormatStyle.CANONICAL, options=None)

Supported styles:

  • canonical
  • display
  • compact

equals(a, b, options=None)

Compares two inputs by canonical identity.

Accepted formats

Strict mode

After cleanup, only canonical current format is accepted:

GGAN{1-5}

Where:

  • GG is between 11 and 29
  • A is a Latin uppercase letter
  • N is 1..5 ASCII digits

Standard mode

Accepted inputs include:

  • canonical current: 22A153
  • shorthand letter first: A22153
  • shorthand digit first: 22153A
  • legacy Arabic letter first: ا22153

Legacy inputs are accepted with a legacy_number warning and normalized into canonical identity like:

22ا153

Development

Create a virtual environment, install dev dependencies, then run:

python -m pip install -e .[dev]
pytest
python -m build

Project metadata

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iraqi_plate-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iraqi_plate-0.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file iraqi_plate-0.1.1.tar.gz.

File metadata

  • Download URL: iraqi_plate-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for iraqi_plate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ca42c0ddaa4f72569902577a7083d60d4d73c5dc50a9d05cb8dbdb06e42f702a
MD5 cfcf786e84965e19c2b7a72206466cb0
BLAKE2b-256 79f08c35d41305f31cfe2901087fcbe99b554bbd2a2787e16d3edb9dca3314a5

See more details on using hashes here.

File details

Details for the file iraqi_plate-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: iraqi_plate-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for iraqi_plate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42e23b702cfd93c4b3daae8c9f84cc71ba29329d4dfa6237bb3eb912f6db849b
MD5 5e487c4003545db32c8191f26b082991
BLAKE2b-256 bdef846e14a42c17d8586966dfc9dc7654b4f2765c39a60da35b6a3938cf06c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page