Skip to main content

Deal with Spanish DNIs in a Pythonic way.

Project description

dni

Actions Status Documentation Status License: MIT PyPI Code style: black

Simple DNI class and operations to make your life easier with Spanish Ids.

Release: 0.2.0

>>> import dni

>>> dni.is_valid("27592354J")
True

>>> # Not a DNI
>>> dni.is_valid("ABC123XYZ")
False

>>> dni.compute_check_letter("27592354")
"J"

>>> some_dni = dni.DNI("27592354J")
>>> some_dni.number
"27592354"
>>> some_dni.check_letter
"J"

>>> some_dni.format(case="upper", separator="-")
"27592354-J"

>>> dni.DNI("27592354J") == dni.DNI("27592354-j")
True

>>> dni.text_contains_dni("El señor Forges, con DNI 12345678Z, sactamente.")
True

>>> dni.extract_dnis_from_text("Mi DNI no es 12543456-S, es el 65412354-D.")
[DNI('12543456S'), DNI('65412354D')]

>>> dni.DNI.random()
DNI("02448431N")

Install

$ pip install dni`

Features

  • Applies for Spanish DNI IDs.
  • Check validity of DNIs.
  • Get check letter for a DNI number.
  • Avoid primitive obsession with the DNI class. Get the components of the DNI, format it in different ways, check for equality.
  • Find and extract multiple DNIs from text.
  • Get detailed exceptions when a string has issues.
  • Generate random, valid DNIs.

Docs

  • For an extensive compilation of usage examples, check the quickstart in the docs.
  • You can also check the full API reference.

Misc

  • If you spot a bug or want to request a feature, feel free to open an issue in this repository.

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

dni-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file dni-0.2.0.tar.gz.

File metadata

  • Download URL: dni-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.9

File hashes

Hashes for dni-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8045f2c1b3853d8b0c6f6e8e36bd8b0ee9c458ba675786902ca6345a4f554aa7
MD5 a3d3224c8dcf2ccecd7f12d28d2a3234
BLAKE2b-256 7ff909c855e2819700724ceb3a7fe37706770324e9b7b9c18b96b20511cc333b

See more details on using hashes here.

Supported by

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