Skip to main content

مكتبة بايثون كاملة لصيغة DLoF (Document Loop Format) — قراءة، كتابة، تحقق، تجوّل في الحلقة، وحزم .dlofpkg/.dlofSeries/.dlofTemplate

Project description

dlof — مكتبة بايثون لصيغة DLoF

مكتبة بايثون كاملة لصيغة DLoF (Document Loop Format): صيغة XML مفتوحة لتخزين وربط المستندات في "حلقات" ذاتية الترابط (كل ملف يحمل بداخله إشارة إلى الملف التالي والسابق، دون فهرس مركزي).

مبنية بالكامل ومطابقة لمخطط dlof.xsd الرسمي (v1.0 + remoteSync + webPublish) ولمخطط dlof-template.xsd، وتم اختبارها والتحقق من صحتها مقابل كل أمثلة مستودع DLoF الرسمي.

المزايا

  • قراءة/كتابة كاملة لملفات .dlof (كل أنواع المحتوى: genericItem, qaItem, bookChapter, termDefinition, infoExplain, episodeItem) مع المرفقات (attachments)، القالب (template)، مجلد الوسائط (mediaFolder)، المزامنة الحيّة (remoteSync)، والنشر على الويب (webPublish بكل حقول SEO/OpenGraph).
  • التحقق من الصحة (validation) مقابل مخطط XSD الرسمي عبر lxml.
  • التجوّل في الحلقة (loop traversal): تتبّع next/previous عبر ملفات متعددة، بناء تسلسل كامل بدءاً من أي نقطة، اكتشاف الحلقات المغلقة، وفحص سلامة الروابط (اكتشاف الروابط المعلّقة).
  • حزم DLoF: قراءة وكتابة .dlofpkg (ملف مفرد + مرفقات)، .dlofSeries (سلسلة كاملة)، و.dlofTemplate (حزمة قالب تصميم، مع توليد Template.kt مرجعي تلقائياً).
  • امتداد الشخصيات (Yime): تحليل/بناء characters.dlof وقوائم الشخصيات والعلاقات بينها.
  • إعدادات السلسلة: تحليل وكتابة set.txt (مفتاح=قيمة) بواجهة مكتوبة النوع (SeriesSettings).
  • تصدير HTML: توليد صفحة ويب مستقلة من أي مستند .dlof، تستخدم القالب المرفق (أو المُسترد من مكتبة قوالب) وبيانات SEO/OpenGraph إن وُجدت.
  • واجهة سطر أوامر: dlof validate|info|chain|tohtml|check-loop.

التثبيت

pip install -e .

يتطلب Python 3.9+ و lxml.

البدء السريع

import dlof

# قراءة ملف .dlof
doc = dlof.load("ch01.dlof")
print(doc.metadata.title)
print(doc.main_content.text)          # bookChapter.text مثلاً

# التحقق من الصحة مقابل XSD الرسمي
errors = dlof.validator.validate_file("ch01.dlof")
assert not errors

# التجوّل عبر الحلقة كاملة بدءاً من أي نقطة فيها
for node in dlof.ordered_chain("ch02.dlof"):
    print(node.filename, "->", node.document.metadata.title)

# بناء مستند جديد وحفظه
new_doc = dlof.DocumentLoop(
    id="qa-001",
    metadata=dlof.Metadata(title="سؤال: ما عاصمة مصر؟", domain=dlof.Domain.EDUCATION),
    loop_links=dlof.LoopLinks(loop_root=True),
    content=[dlof.QAItem(question="ما عاصمة مصر؟", answer="القاهرة")],
)
dlof.save(new_doc, "qa-001.dlof")

# تصدير HTML
dlof.html_export.write_html(doc, "ch01.html")

راجع examples/build_qa_loop.py لمثال كامل لبناء حلقة تعليمية من عدة ملفات مترابطة من الصفر.

واجهة سطر الأوامر

python -m dlof validate path/to/file.dlof
python -m dlof info path/to/file.dlof
python -m dlof chain path/to/file.dlof        # يعرض الحلقة كاملة
python -m dlof tohtml path/to/file.dlof -o out.html
python -m dlof check-loop path/to/folder      # يفحص كل الروابط ضمن مجلد

بنية المكتبة

الوحدة الوصف
dlof.models Dataclasses تمثّل كل بنية DLoF (DocumentLoop, Metadata, LoopLinks, أنواع المحتوى، Attachment، Template، WebPublish...)
dlof.parser تحليل XML → نماذج (parse_file, parse_string)
dlof.writer نماذج → XML (to_string, write_file)
dlof.validator التحقق من الصحة مقابل XSD الرسمي
dlof.loop التجوّل في الحلقة (walk_next, walk_previous, ordered_chain, validate_loop_integrity)
dlof.packages .dlofpkg / .dlofSeries / .dlofTemplate + حلّ template ref
dlof.settings تحليل/كتابة set.txt
dlof.characters امتداد الشخصيات (Yime)
dlof.html_export تصدير HTML
dlof.cli واجهة سطر الأوامر

الاختبارات

DLOF_EXAMPLES_DIR=/path/to/dlof-repo/spec/examples \
    python -m unittest discover -s tests -v

تتحقق الاختبارات من كل أمثلة المستودع الرسمي (spec/examples/) — تحليل، تحقق من الصحة، إعادة الكتابة (round-trip)، التجوّل في الحلقات، الشخصيات، الحزم، والقوالب.

الترخيص

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dlof-1.0.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dlof-1.0.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file dlof-1.0.0.tar.gz.

File metadata

  • Download URL: dlof-1.0.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dlof-1.0.0.tar.gz
Algorithm Hash digest
SHA256 34fb57d96bf3e9623fdb64f679b8388bbc5cad9d04b0dbd97908ac92738976b3
MD5 e40afab91fb8bad8298e555f20679759
BLAKE2b-256 84106b26ab196ce5512379e654263b45dea547c54d0bb4918c6de6b5d69a329d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlof-1.0.0.tar.gz:

Publisher: publish.yml on vcgstudiosy-beep/pydlof

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dlof-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dlof-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dlof-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edca832971707ac3dad70e250032f5d519be7f8a72a5df779fe852fbc07dfde0
MD5 8d71675ac3190b4db5bae04178e350e5
BLAKE2b-256 ab04eaa35a37d14fc3587e293888e2398945b95911a107c2de60f6bf6de4b5f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlof-1.0.0-py3-none-any.whl:

Publisher: publish.yml on vcgstudiosy-beep/pydlof

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page