arapy 0.0.1__py3-none-any.whl

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/__init__.py ADDED
@@ -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
+ ]
arapy/_extras.py ADDED
@@ -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
arapy/_letters.py ADDED
@@ -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 = "۰۱۲۳۴۵۶۷۸۹"
arapy/errors.py ADDED
@@ -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
+ )
arapy/py.typed ADDED
File without changes
@@ -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
@@ -0,0 +1,9 @@
1
+ arapy/__init__.py,sha256=DyaRlBkzWhnf6qWl8Hwp3-Z-3G9XyaIBMQfoTgy6XdE,403
2
+ arapy/_extras.py,sha256=Qp9YdtnNoVSENqkJa-35lwqoZUrpTHwYesx2fvJMyJc,489
3
+ arapy/_letters.py,sha256=uFUNIkLMNd2xZl71f1NvS7UP_bm7lDu6YpRGk8NXtmc,661
4
+ arapy/errors.py,sha256=neQRmnN8JOuGtZRftvtBpjzKAdNMdwBtFJN-jofJEec,811
5
+ arapy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ arapy-0.0.1.dist-info/licenses/LICENSE,sha256=g_XQX9vngE0IGV358UPmNFt3BBiADx5Oajrl5LZLREo,1065
7
+ arapy-0.0.1.dist-info/WHEEL,sha256=3OmCxFA0ffBIsX4x0o8CdfSvZAOvO3mzEG8U_z5TvV4,80
8
+ arapy-0.0.1.dist-info/METADATA,sha256=FbilAAI1f1OpPZYB7oLvAFSVGR1WL5XB6X7Gp8-909M,2489
9
+ arapy-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.8
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.