A package for parsing Accept-Language tag received from (untrusted) client context.
Project description
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/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file acceptlang-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: acceptlang-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb3e39ae83c72c34f7d1ee6502aae7b928fa9add8b6c5efc9442a75696a7c494 |
|
MD5 | 971b6ef940e2c770c5f01b0cb764fc6b |
|
BLAKE2b-256 | 83d5582f1bddddc35c21062e1dd846f020bf605d1f396d5083d4546df5b278b3 |