A parsing library for the UK's MPAN energy standard
Project description
mpan
mpan
is a library to help you parse the UK energy industry's MPAN number format.
How it works
from mpan import InvalidMPANError, MPAN
mpan = MPAN("018011002012345678385")
print(mpan.core) # 2012345678385
print(mpan.identifier) # 12345678
print(mpan.is_short) # False
print(mpan.profile_class.description) # "Domestic unrestricted"
print(mpan.distributor.is_dno) # True
print(mpan.distributor.area) # "Southern England"
if mpan.is_valid:
print("Looks good to me!")
try:
mpan.check()
except InvalidMPANError:
print("This MPAN is broken")
There's also a shortcut if you just want validation:
from mpan import is_valid
if is_valid("<an MPAN string>"):
print("Looks good to me too!")
Installation
It's on PyPI:
$ pip install mpan
Requirements
This is a pure-python module with no external dependencies. However, you'll need to be running Python 3.8 or higher.
Development
Setting up a Local Development Environment
We're using Poetry, so if you want to make some
changes, you should install that and then just run poetry install
. This will
pull in all the development dependencies like pytest
, isort
, etc.
Deployment/Releases
To build, use Poetry:
$ poetry build
To publish a new release, use Poetry for that too:
$ poetry publish
Testing
When inside your virtualenv, just run:
$ pytest
External Documentation
This is based largely on the Wikipedia article on the MPAN standard. The validation code for example is cribbed right from there.
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
Built Distribution
File details
Details for the file mpan-1.0.1.tar.gz
.
File metadata
- Download URL: mpan-1.0.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/5.8.0-43-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 630c60927f282d486223ac6324806ca3bcf2dc323197dced5fa57df5e6e2a0b5 |
|
MD5 | 163486bae48ad1e0ac752d607d3c762e |
|
BLAKE2b-256 | 212cb1c1c470122d301149583c3259bea74cdaf9148380fa61c474becbecfeda |
File details
Details for the file mpan-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: mpan-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/5.8.0-43-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b05bdae4fd2b79bc70163758742dc627fc1d1fb8a387ca7bca9d434a2dc72c88 |
|
MD5 | f01e7205357e4467a7ada9f0281c705f |
|
BLAKE2b-256 | 7338d0d7ab3d4c0618796c9ceee4077b356d4eb12eef4a270c8612532a841d92 |