Lib for getting driver's information
Project description
inatroget
inatroget is a small Python library that automates logging into the INATRO portal in Mozambique and extracts the driver license details available on the authenticated dashboard. It is designed to be embedded in other Python projects that need structured access to this information.
Features
- Handles the complete login flow to the INATRO virtual desk.
- Normalizes server-side error responses into consistent error codes/messages.
- Persists session cookies to reuse across invocations (optional).
- Parses the INATRO dashboard HTML into a convenient Python dictionary.
Requirements
- Python 3.9+
- Network access to
https://balcaovirtual.inatro.gov.mz - Dependencies listed in
pyproject.toml/requirements.txt
Installation
pip install -r requirements.txt
# or, install the library in editable mode
pip install -e .
# or
pip install inatroget==0.1.0
If you prefer to rely solely on the packaged metadata, you can install directly from the project directory:
pip install .
Configuration
Create a .env file (or export environment variables) with:
COOKIES_FILE_NAME=inatro_cookies.pkl # optional override of the default path
All other settings (URLs, timeouts, formats) are encapsulated in inatroget.config.Config. Override them by subclassing Config if needed.
Usage
from inatroget.entry import do_login
result = do_login("12008630", "2003-10-28")
if result["success"]:
carta_info = result["data"]
print(f"Estado: {carta_info['estado_carta']}")
else:
print(f"[{result['code']}] {result['message']}")
The do_login helper returns a dictionary with:
success:Trueon success,Falseotherwisedata: parsed driver license information (only present on success)code,message: standardized error details whensuccessisFalse
Session cookies are stored using inatroget.cookies.save_cookies to the configured file path so that callers can reuse the session if desired.
Getting Raw HTML or Parsing Manually
import requests
from inatroget.get_info import get_carta_info_html, extract_carta_info
session = requests.Session()
# ensure you are already authenticated before calling this
html = get_carta_info_html(session)
parsed = extract_carta_info(html)
License
This project does not yet declare an explicit license. Please contact the author before redistributing or using it in production.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inatroget-0.1.0.tar.gz.
File metadata
- Download URL: inatroget-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8522247d8a89b94d7a6c79daaddddb6f832599e23c3160361c4c82c2f712b9ac
|
|
| MD5 |
240a21f9305891984ebc9d5d404f0810
|
|
| BLAKE2b-256 |
8970ae7b77ec0a9b1532d0d835b7ac5e858787046ffd457e83bdf4f84cc50046
|
File details
Details for the file inatroget-0.1.0-py3-none-any.whl.
File metadata
- Download URL: inatroget-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8197674b24b7a4b99b930db8b79982b3057a2a167055c603ed5ee8dfff4663de
|
|
| MD5 |
1169db6fe3d5d6247b64c1e2fdbe9115
|
|
| BLAKE2b-256 |
120e69f182a660decb757fc2f620c051445f5b113a5c510f25b7554d98f3e36c
|