Skip to main content

A module to operate with license plates and its patterns

Project description

License Plate Toolbox

Tests

This project provides a simple way to operate with license plates and its patterns.

Installation

To install the module, just run on the command line:

$ pip install plates

Module usage

For example, to get the number of possible plates with a given pattern:

from plates import *
combinations("CCCDDD") # 17576000

In the example above, the pattern given corresponds to 3 characters and 3 digits. ABC123 is a plate that matches with this pattern, then:

matches_pattern("CCCDDD", "ABC123") # True

The above pattern can be shortened as "3C3D", meaning 3 chars and 3 digits.

In general, every pattern can be shortened following the same pattern.

Some standard patterns are already given, and can be accessed through a dictionary:

# Spain's pattern
STD_PATTERNS["ES"] # "DDDDCCC"

# Denmark's pattern
STD_PATTERNS["DK"] # "CCDDDDD"

STD_PATTERNS.keys() will show all the patterns provided.

The keys to the dictionary are given by the ISO 3166-1 code for countries, with some exceptions, like when a number is appended to it, indicating that the country supports more than one pattern, or when a country is subdivided. For the latter, the ISO 3166-2 standard is used.

The next code snippet illustrates the idea with an example:

# Argentina's old pattern
STD_PATTERNS["AR-1"] # "CCCDDD"

# Argentina's new pattern
STD_PATTERNS["AR-2"] # "CCDDDCC"

# California pattern
STD_PATTERNS["US-CA"] # "DCCCDDD"

One can also look up for the ISO code of a country through the ISO_3166 dictionary, in case of not knowing the corresponding code assigned to the country. The key, if present, will be the name of the country uppercased, and the value can match with three posibilites:

  • A string corresponding to the ISO 3166-1 code to the country
  • A list corresponding to multiple codes used
  • A dictionary, whose keys are subdivions of the proper country, and the values being the ISO 3166-2 code to the state/subdivision of the country

Following with the examples from above:

# Codes associated to Argentina
ISO_3166["ARGENTINA"] # ["AR-1", "AR-2"]

# Codes associated to California
ISO_3166["USA"]["CALIFORNIA"] # "US-CA"

So one does not encounter the necessity to know the ISO 3166 codes.

Command line usage

The tools provided can be used directly through the command line, invoking the plates module and passing the function name with it's proper positional or keyword arguments. Here's an example:

$ python -m plates get_pattern AB5472D

will produce CCDDDDC as the result.

To get a list of all the available functions for the command line, call the module with the -lf or --list-functions flag, and it will print a list of supported functions with its arguments and respective types.

For help using the module via the command line, pass the -h or --help flag.

Some basics examples are:

$ python -m plates max_plate --pattern CCDDDC
$ python -m plates get_plate -p CCDDDC -i 168700
$ python -m plates get_plate_index -pl GA155RT

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

plates-1.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

plates-1.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file plates-1.1.0.tar.gz.

File metadata

  • Download URL: plates-1.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for plates-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a1c31c6c08006b0d5345f5195913cbe9e4df5bce2163f3951aa8ba0c32317e7c
MD5 a50948506a4fee044235131dfcf39d90
BLAKE2b-256 488f15314be44818a4fd6ff2767445f67e9fa5b022eaa05c58f0ed5860e8c169

See more details on using hashes here.

File details

Details for the file plates-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: plates-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for plates-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32f8d7329c0dc55c122a62317020b16338834cd0ea3ab5d5406f6b9f08021d90
MD5 986b86603c4f81c50d9f3a20a5df1d38
BLAKE2b-256 60adc8835440a688878489b187888e07dcc6d91d91839549a3719ef49733f7cd

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