Simple package for parsing Accept-Language tag.
This package can be used in the server environment to parse the Accept-Language header.
Test cases and code copied from Django source code enhanced with typing.
Purpose of this code is to be able to use a battle-tested Accept-Language parsing logic in Python code without need to install Django package.
Installation
You can install the package via pip:
pip install acceptlang
Usage
from acceptlang import parse_accept_lang_header
result = parse_accept_lang_header("en-us,en;q=0.5,de;q=0.3")
assert result == (('en-us', 1.0), ('en',0.5), ('de',0.3))
result = parse_accept_lang_header("en-us,*;q=0.5")
assert result == (('en-us', 1.0), ('*',0.5))
Check tests for more examples.
Local development
python3 -m venv venv
. venv/bin/activate
python3 -m pip install -r requirements.dev.txt
Build and publish
python3 -m build --wheel
twine check dist/**
twine upload dist/
Metadata
Release files for acceptlang 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| acceptlang-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for acceptlang-0.0.5-py3-none-any.whl |
Release files / acceptlang-0.0.5-py3-none-any.whl
| Download URL | acceptlang-0.0.5-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb3e39ae83c72c34f7d1ee6502aae7b928fa9add8b6c5efc9442a75696a7c494
|
|
BLAKE2b-256 checksum How to use checksums |
83d5582f1bddddc35c21062e1dd846f020bf605d1f396d5083d4546df5b278b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.6
|
Security for acceptlang 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.