devsamhan-arabic-bidi
مكتبة Python لعرض النص العربي صحيحاً في الطرفية — إعادة تشكيل الحروف، كشف الاتجاه، سجل عربي.
بدون أي تبعيات خارجية. متوافقة مع مواصفات devsamhan-arabic v1.0.0.
التثبيت
pip install devsamhan-arabic-bidi
from devsamhan_arabic_bidi import (
reshape, prepare_for_terminal, print_arabic,
detect_direction,
ArabicLogger, arabic_logger,
)
الاستخدام السريع
# إعادة تشكيل الحروف (الحروف المعزولة → أشكال السياق)
reshape('بيت') # → 'ﺑﻴﺖ'
# تجهيز النص للطرفية (تشكيل + إعادة ترتيب المقاطع)
prepare_for_terminal('مرحبا Hello') # → 'Hello ﻢﺭﻍﺻﺎ'
# طباعة مباشرة
print_arabic('مرحبا بالعالم')
# كشف الاتجاه
detect_direction('مرحبا') # → 'rtl'
detect_direction('Hello') # → 'ltr'
detect_direction('Hi مرحبا')# → 'mixed'
# سجل عربي
arabic_logger.info('تم التشغيل')
ArabicLogger(prefix='خادم', use_timestamp=True).error('فشل الاتصال')
الـ API
| الدالة | الوصف |
|---|---|
reshape(text, *, use_lam_alef_ligatures=False) |
تحويل الحروف إلى أشكال السياق. |
prepare_for_terminal(text, *, do_reshape=True, reorder=True, use_lam_alef_ligatures=False) |
تشكيل + إعادة ترتيب مقاطع النص لعرض صحيح في الطرفية. |
print_arabic(text, **kwargs) |
طباعة النص بعد التجهيز. |
detect_direction(text) |
يُعيد 'rtl' أو 'ltr' أو 'mixed'. |
arabic_logger |
نسخة جاهزة من ArabicLogger. |
ArabicLogger
ArabicLogger(
prefix=None, # يُضاف بين قوسين قبل المستوى
use_timestamp=False, # إضافة الطابع الزمني
do_reshape=True,
reorder=True,
use_lam_alef_ligatures=False,
)
تنسيق المخرجات: [yyyy-MM-dd HH:mm:ss][prefix][LEVEL] message
الفرق عن النسخة TypeScript
تستخدم هذه المكتبة نسبة الحروف العربية (U+0621–U+063A, U+0641–U+064A) مقسومةً على عدد المحارف غير المسافة (بدلاً من جميع محارف U+0600–U+06FF مقسومةً على الكل)، لتقرير إعادة ترتيب المقاطع.
مثال: 'رقم ١٢٣' لا يُعاد ترتيبه في Python (3 حروف / 6 غير-مسافة = 0.5، غير أكبر صراحةً من 0.5)، بينما يُعاد ترتيبه في TypeScript.
الترخيص
MIT — Devsamhan
Release files for devsamhan-arabic-bidi 1.0.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 | |
|---|---|---|---|
| devsamhan_arabic_bidi-1.0.0.tar.gz | 9.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| devsamhan_arabic_bidi-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.4 kB
Release files / devsamhan_arabic_bidi-1.0.0.tar.gz
| Download URL | devsamhan_arabic_bidi-1.0.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
555c398e267dfff012d9865c86d0883a9efb1bb5a1ef2eaf8f3897b37928fa9b
|
|
BLAKE2b-256 checksum How to use checksums |
499c63b3af3c15b39e286cf6931804118e7021858d1c4f3b34c6fa7ef9b4d8e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / devsamhan_arabic_bidi-1.0.0-py3-none-any.whl
| Download URL | devsamhan_arabic_bidi-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
117bf5129f41139baa8490a2335f4c60d36b21e020d1ccfe0cfa078221aa6358
|
|
BLAKE2b-256 checksum How to use checksums |
e9788f1c869499f0a40a3804753abe6e2b6cee07040cd5d66c533441289d1937
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|