Arabic terminal reshaping and BiDi — devsamhan-arabic spec v1.0.0
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file devsamhan_arabic_bidi-1.0.0.tar.gz.
File metadata
- Download URL: devsamhan_arabic_bidi-1.0.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
555c398e267dfff012d9865c86d0883a9efb1bb5a1ef2eaf8f3897b37928fa9b
|
|
| MD5 |
5fc3bd4324737697bb934c6bca17db2e
|
|
| BLAKE2b-256 |
499c63b3af3c15b39e286cf6931804118e7021858d1c4f3b34c6fa7ef9b4d8e5
|
File details
Details for the file devsamhan_arabic_bidi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: devsamhan_arabic_bidi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
117bf5129f41139baa8490a2335f4c60d36b21e020d1ccfe0cfa078221aa6358
|
|
| MD5 |
afa6c5572186c2a5b119d8903fe84a11
|
|
| BLAKE2b-256 |
e9788f1c869499f0a40a3804753abe6e2b6cee07040cd5d66c533441289d1937
|