quran-text for Python
No dependencies, Python 3.9+. Ḥafṣ is bundled. Copy quran_text.py and
quran_text_data/ into your project, or pip install this directory.
from quran_text import Mushaf, AyahMap
m = Mushaf.hafs() # bundled Ḥafṣ
m.ayah(2, 255).text # plain words
m.ayah(2, 255).render(marks=True, ayah_marks=True) # with waqf marks and ٢٥٥
m.page(3).render(marks=True, ayah_marks=True, lines=True)
m.surah(112).ayahs # [Ayah(112:1), …]
m.juz(30).first_ayah.key # "78:1"
m.word(1, 4, 1).number # 11, the same word in every riwāyah
m.sajdat() # every āyah printed with ۩
m.search("مالك يوم الدين") # [Span(10, 13)]
w = Mushaf.load("data/mushaf/warsh.json") # another riwāyah
AyahMap.load("data/ayah-map.json").convert(2, 255, "warsh") # MappedAyah(2, 253, 'split', 254)
The font the text needs is bundled too: m.font.family names it and m.font.path
is the .ttf. For another riwāyah Mushaf.load(path) finds its font beside
data/fonts/.
Wrong numbers raise IndexError; a layer the file lacks (juz in Bazzī) raises
KeyError with the reason from the file. The full API is in
../README.md.
Test: python3 -m unittest lib/python/test_quran_text.py from the repo root.
Metadata
Release files for quran-text 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quran_text-0.1.0.tar.gz | 692.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quran_text-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / quran_text-0.1.0.tar.gz
| Download URL | quran_text-0.1.0.tar.gz |
|---|---|
| Size | 692.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f28a164e475569800e7596f660d05af9295e1c75cf3cb0fcd8895f649e4e74d
|
|
BLAKE2b-256 checksum How to use checksums |
7233927375c159d973c829ce5cb6b46686a43612901cd2000919ab3c2b9459a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / quran_text-0.1.0-py3-none-any.whl
| Download URL | quran_text-0.1.0-py3-none-any.whl |
|---|---|
| Size | 723.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b9a0c23ccabe6ff2a25732c7004af267ce2f10de3953fb6e27c37607891fe77
|
|
BLAKE2b-256 checksum How to use checksums |
28c97840d01810c9270992d4fd657ab74ba4d0ec0798b0ebcce3464fda154a3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|