arapy 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arapy-0.0.1/LICENSE +21 -0
- arapy-0.0.1/PKG-INFO +62 -0
- arapy-0.0.1/README.md +32 -0
- arapy-0.0.1/pyproject.toml +89 -0
- arapy-0.0.1/pyproject.toml.orig +64 -0
- arapy-0.0.1/src/arapy/__init__.py +22 -0
- arapy-0.0.1/src/arapy/_extras.py +17 -0
- arapy-0.0.1/src/arapy/_letters.py +20 -0
- arapy-0.0.1/src/arapy/errors.py +29 -0
- arapy-0.0.1/src/arapy/py.typed +0 -0
arapy-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 aaltatan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
arapy-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arapy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Strongly typed Arabic text, number and date tools: tafqeet, digits, normalization, sorting, ordinals, dates and shaping.
|
|
5
|
+
Keywords: arabic,tafqeet,hijri,numbers,normalization
|
|
6
|
+
Author: aaltatan
|
|
7
|
+
Author-email: aaltatan <a.altatan@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Natural Language :: Arabic
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Dist: hijridate ; extra == 'hijri'
|
|
20
|
+
Requires-Dist: arabic-reshaper ; extra == 'shape'
|
|
21
|
+
Requires-Dist: python-bidi ; extra == 'shape'
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Project-URL: Homepage, https://github.com/aaltatan/arapy
|
|
24
|
+
Project-URL: Repository, https://github.com/aaltatan/arapy
|
|
25
|
+
Project-URL: Issues, https://github.com/aaltatan/arapy/issues
|
|
26
|
+
Project-URL: Changelog, https://github.com/aaltatan/arapy/blob/main/CHANGELOG.md
|
|
27
|
+
Provides-Extra: hijri
|
|
28
|
+
Provides-Extra: shape
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# arapy
|
|
32
|
+
|
|
33
|
+
Strongly typed Arabic text, number and date tools for Python: amounts in words (تفقيط), Arabic and
|
|
34
|
+
Persian digits, text normalization, alphabetical sorting, ordinals, Gregorian and Hijri dates, and
|
|
35
|
+
shaping for images and PDFs.
|
|
36
|
+
|
|
37
|
+
> **Status: pre-alpha.** This release reserves the name. The modules land phase by phase, and the
|
|
38
|
+
> first usable release will be 0.1.0.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install arapy # core, zero dependencies
|
|
42
|
+
pip install "arapy[hijri]" # Hijri dates
|
|
43
|
+
pip install "arapy[shape]" # reshaping and bidi for drawing Arabic text
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
<div dir="rtl">
|
|
49
|
+
|
|
50
|
+
## arapy بالعربية
|
|
51
|
+
|
|
52
|
+
مكتبة بايثون بأنواع صارمة لمعالجة النصوص والأرقام والتواريخ العربية: تفقيط المبالغ، والأرقام
|
|
53
|
+
العربية والفارسية، وتوحيد النصوص، والترتيب الأبجدي، والأعداد الترتيبية، والتاريخان الميلادي
|
|
54
|
+
والهجري، وتشكيل الحروف لرسمها في الصور وملفات PDF.
|
|
55
|
+
|
|
56
|
+
> **الحالة: نسخة أولية.** هذا الإصدار يحجز الاسم فقط، وأول إصدار قابل للاستخدام سيكون 0.1.0.
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
arapy-0.0.1/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# arapy
|
|
2
|
+
|
|
3
|
+
Strongly typed Arabic text, number and date tools for Python: amounts in words (تفقيط), Arabic and
|
|
4
|
+
Persian digits, text normalization, alphabetical sorting, ordinals, Gregorian and Hijri dates, and
|
|
5
|
+
shaping for images and PDFs.
|
|
6
|
+
|
|
7
|
+
> **Status: pre-alpha.** This release reserves the name. The modules land phase by phase, and the
|
|
8
|
+
> first usable release will be 0.1.0.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install arapy # core, zero dependencies
|
|
12
|
+
pip install "arapy[hijri]" # Hijri dates
|
|
13
|
+
pip install "arapy[shape]" # reshaping and bidi for drawing Arabic text
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div dir="rtl">
|
|
19
|
+
|
|
20
|
+
## arapy بالعربية
|
|
21
|
+
|
|
22
|
+
مكتبة بايثون بأنواع صارمة لمعالجة النصوص والأرقام والتواريخ العربية: تفقيط المبالغ، والأرقام
|
|
23
|
+
العربية والفارسية، وتوحيد النصوص، والترتيب الأبجدي، والأعداد الترتيبية، والتاريخان الميلادي
|
|
24
|
+
والهجري، وتشكيل الحروف لرسمها في الصور وملفات PDF.
|
|
25
|
+
|
|
26
|
+
> **الحالة: نسخة أولية.** هذا الإصدار يحجز الاسم فقط، وأول إصدار قابل للاستخدام سيكون 0.1.0.
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "arapy"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Strongly typed Arabic text, number and date tools: tafqeet, digits, normalization, sorting, ordinals, dates and shaping."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
dependencies = []
|
|
10
|
+
keywords = [
|
|
11
|
+
"arabic",
|
|
12
|
+
"tafqeet",
|
|
13
|
+
"hijri",
|
|
14
|
+
"numbers",
|
|
15
|
+
"normalization",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Topic :: Text Processing :: Linguistic",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Natural Language :: Arabic",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[[project.authors]]
|
|
30
|
+
name = "aaltatan"
|
|
31
|
+
email = "a.altatan@gmail.com"
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/aaltatan/arapy"
|
|
35
|
+
Repository = "https://github.com/aaltatan/arapy"
|
|
36
|
+
Issues = "https://github.com/aaltatan/arapy/issues"
|
|
37
|
+
Changelog = "https://github.com/aaltatan/arapy/blob/main/CHANGELOG.md"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
hijri = ["hijridate"]
|
|
41
|
+
shape = [
|
|
42
|
+
"arabic-reshaper",
|
|
43
|
+
"python-bidi",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"ruff",
|
|
49
|
+
"mypy",
|
|
50
|
+
"pytest",
|
|
51
|
+
"hypothesis",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[build-system]
|
|
55
|
+
requires = ["uv_build>=0.13.8,<0.14.0"]
|
|
56
|
+
build-backend = "uv_build"
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 100
|
|
60
|
+
target-version = "py312"
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = [
|
|
64
|
+
"E",
|
|
65
|
+
"W",
|
|
66
|
+
"F",
|
|
67
|
+
"I",
|
|
68
|
+
"UP",
|
|
69
|
+
"B",
|
|
70
|
+
"SIM",
|
|
71
|
+
"RUF",
|
|
72
|
+
]
|
|
73
|
+
ignore = [
|
|
74
|
+
"RUF001",
|
|
75
|
+
"RUF002",
|
|
76
|
+
"RUF003",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.mypy]
|
|
80
|
+
strict = true
|
|
81
|
+
python_version = "3.12"
|
|
82
|
+
files = ["src"]
|
|
83
|
+
|
|
84
|
+
[tool.pytest.ini_options]
|
|
85
|
+
testpaths = ["tests"]
|
|
86
|
+
addopts = [
|
|
87
|
+
"--strict-markers",
|
|
88
|
+
"--import-mode=importlib",
|
|
89
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "arapy"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Strongly typed Arabic text, number and date tools: tafqeet, digits, normalization, sorting, ordinals, dates and shaping."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "aaltatan", email = "a.altatan@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
license = "MIT"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
dependencies = []
|
|
13
|
+
keywords = ["arabic", "tafqeet", "hijri", "numbers", "normalization"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Topic :: Text Processing :: Linguistic",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Natural Language :: Arabic",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/aaltatan/arapy"
|
|
28
|
+
Repository = "https://github.com/aaltatan/arapy"
|
|
29
|
+
Issues = "https://github.com/aaltatan/arapy/issues"
|
|
30
|
+
Changelog = "https://github.com/aaltatan/arapy/blob/main/CHANGELOG.md"
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
hijri = ["hijridate"]
|
|
34
|
+
shape = ["arabic-reshaper", "python-bidi"]
|
|
35
|
+
|
|
36
|
+
[dependency-groups]
|
|
37
|
+
dev = [
|
|
38
|
+
"ruff",
|
|
39
|
+
"mypy",
|
|
40
|
+
"pytest",
|
|
41
|
+
"hypothesis",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[build-system]
|
|
45
|
+
requires = ["uv_build>=0.13.8,<0.14.0"]
|
|
46
|
+
build-backend = "uv_build"
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
line-length = 100
|
|
50
|
+
target-version = "py312"
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
select = ["E", "W", "F", "I", "UP", "B", "SIM", "RUF"]
|
|
54
|
+
# Arabic text everywhere: confusable-character checks are noise here.
|
|
55
|
+
ignore = ["RUF001", "RUF002", "RUF003"]
|
|
56
|
+
|
|
57
|
+
[tool.mypy]
|
|
58
|
+
strict = true
|
|
59
|
+
python_version = "3.12"
|
|
60
|
+
files = ["src"]
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
addopts = ["--strict-markers", "--import-mode=importlib"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Strongly typed Arabic text, number and date tools."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import version
|
|
4
|
+
|
|
5
|
+
from arapy.errors import (
|
|
6
|
+
ArapyError,
|
|
7
|
+
InvalidNumberError,
|
|
8
|
+
MissingExtraError,
|
|
9
|
+
OutOfRangeError,
|
|
10
|
+
ParseError,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__version__ = version("arapy")
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"ArapyError",
|
|
17
|
+
"InvalidNumberError",
|
|
18
|
+
"MissingExtraError",
|
|
19
|
+
"OutOfRangeError",
|
|
20
|
+
"ParseError",
|
|
21
|
+
"__version__",
|
|
22
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Lazy imports for optional extras."""
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
from types import ModuleType
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from arapy.errors import MissingExtraError
|
|
8
|
+
|
|
9
|
+
type Extra = Literal["hijri", "shape"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def require(extra: Extra, module: str) -> ModuleType:
|
|
13
|
+
"""Import `module`, or raise `MissingExtraError` naming the extra that provides it."""
|
|
14
|
+
try:
|
|
15
|
+
return import_module(module)
|
|
16
|
+
except ImportError as err:
|
|
17
|
+
raise MissingExtraError(extra) from err
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Arabic letter constants and character classes shared across modules."""
|
|
2
|
+
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
5
|
+
ALEF: Final = "ا" # ا
|
|
6
|
+
ALEF_HAMZA_ABOVE: Final = "أ" # أ
|
|
7
|
+
ALEF_HAMZA_BELOW: Final = "إ" # إ
|
|
8
|
+
ALEF_MADDA: Final = "آ" # آ
|
|
9
|
+
ALEF_WASLA: Final = "ٱ" # ٱ
|
|
10
|
+
ALEF_FORMS: Final = frozenset({ALEF_HAMZA_ABOVE, ALEF_HAMZA_BELOW, ALEF_MADDA, ALEF_WASLA})
|
|
11
|
+
|
|
12
|
+
TATWEEL: Final = "ـ" # ـ
|
|
13
|
+
|
|
14
|
+
# Fathatan … sukun (U+064B–U+0652).
|
|
15
|
+
TASHKEEL: Final = frozenset(chr(c) for c in range(0x064B, 0x0653))
|
|
16
|
+
|
|
17
|
+
# Index i holds the digit with value i.
|
|
18
|
+
LATIN_DIGITS: Final = "0123456789"
|
|
19
|
+
ARABIC_DIGITS: Final = "٠١٢٣٤٥٦٧٨٩"
|
|
20
|
+
PERSIAN_DIGITS: Final = "۰۱۲۳۴۵۶۷۸۹"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Exception hierarchy. Every error raised by arapy subclasses `ArapyError`."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ArapyError(Exception):
|
|
5
|
+
"""Base class for all arapy errors."""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InvalidNumberError(ArapyError, ValueError):
|
|
9
|
+
"""A value cannot be read as a number."""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class OutOfRangeError(ArapyError, ValueError):
|
|
13
|
+
"""A number is outside the supported range."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ParseError(ArapyError, ValueError):
|
|
17
|
+
"""Text does not match the expected format."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MissingExtraError(ArapyError, ImportError):
|
|
21
|
+
"""An optional extra is needed but not installed."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, extra: str) -> None:
|
|
24
|
+
self.extra = extra
|
|
25
|
+
|
|
26
|
+
super().__init__(
|
|
27
|
+
f"This feature needs the '{extra}' extra. "
|
|
28
|
+
f'Install it with: `pip install "arapy[{extra}]"` or `uv add arapy[{extra}]`'
|
|
29
|
+
)
|
|
File without changes
|