reportlab-styles
ما الذي تفعله
تشرح هذه المهارة كيفية استخدام أنماط الفقرات الجاهزة في مكتبة ReportLab لملفات PDF. وهي مناسبة لمن يبني مستندات PDF بـ Python ويواجه أخطاء في الأنماط.
متى تستخدمها
- ✓عندما يُطلق سكربت ReportLab خطأ KeyError على اسم نمط فقرة.
- ✓عندما أريد تنسيق العناوين والنص الأساسي دون إنشاء أسماء أنماط يدويًا.
- ✓عندما أبني تقرير PDF وأريد المظهر القياسي للأنماط النموذجية.
رابط المهارة
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reportlab-styles/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“يتعطل سكربت ReportLab الخاص بي بخطأ KeyError على النمط. أصلحه باستخدام الأنماط الجاهزة.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يحصل الوكيل على ورقة الأنماط النموذجية من ReportLab، ويستخدم أسماء الأنماط الموجودة مثل Title وHeading1 وNormal. ويتجنب إنشاء نمط جديد باسم موجود فيها.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
ReportLab Pre-Defined Styles Reference
Overview
ReportLab's reportlab.lib.styles.getSampleStyleSheet() provides a collection of pre-defined paragraph styles. Use these existing styles rather than redefining them to avoid KeyError exceptions.
Available Pre-Defined Styles
The standard stylesheet includes these commonly-used styles:
| Style Name | Purpose |
|---|---|
Normal |
Default body text |
Title |
Document title (large, bold) |
Heading1 |
Level 1 section heading |
Heading2 |
Level 2 section heading |
Heading3 |
Level 3 section heading |
Heading4 |
Level 4 section heading |
Heading5 |
Level 5 section heading |
Heading6 |
Level 6 section heading |
Bullet |
Bulleted list items |
Definition |
Definition list terms |
Italic |
Italicized text |
Code |
Monospace code text |
Correct Usage Pattern
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph
# Get the stylesheet
styles = getSampleStyleSheet()
# Use existing styles directly (CORRECT)
title = Paragraph("My Document Title", styles['Title'])
heading = Paragraph("Section Header", styles['Heading1'])
body = Paragraph("Regular text content", styles['Normal'])
Common Mistake to Avoid
# WRONG - Don't redefine existing style names
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
styles = getSampleStyleSheet()
# This will cause KeyError when you try to use 'Title' later
styles.add(ParagraphStyle(
name='Title', # Overwrites the pre-defined 'Title' style
fontSize=24,
# ... incomplete definition
))
# Later code expecting the full 'Title' style will fail
paragraph = Paragraph("Title Text", styles['Title']) # KeyError!
Best Practices
- Use existing styles as-is when they meet your needs
- Create new style names for custom styles (e.g.,
MyCustomTitle,CustomHeading) - Base custom styles on existing ones when you need modifications:
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
styles = getSampleStyleSheet()
# Create a NEW style with a unique name
custom_title = ParagraphStyle(
name='CustomTitle', # Unique name, doesn't conflict
parent=styles['Title'], # Base it on existing Title
fontSize=28,
spaceAfter=30
)
styles.add(custom_title)
# Now both styles are available
styles['Title'] # Original pre-defined style
styles['CustomTitle'] # Your custom variant
Quick Reference Checklist
- Import
getSampleStyleSheet()fromreportlab.lib.styles - Call
styles = getSampleStyleSheet()once at the start - Access styles via
styles['StyleName'](case-sensitive) - Do NOT add styles with names that already exist in the stylesheet
- Use unique names for any custom styles you create
- Common available styles:
Normal,Title,Heading1-6,Bullet,Code,Italic
الأسئلة الشائعة
ما الأنماط المدمجة؟
تذكر المهارة Normal وTitle وHeading1 إلى Heading6 وBullet وDefinition وItalic وCode.
ما سبب خطأ KeyError؟
تقول المهارة إن الخطأ ينتج عن إعادة تعريف اسم نمط موجود، والحل استخدام الاسم المدمج.
هل أحتاج إلى نمط جديد لتصميمي؟
تقترح المهارة استخدام الأنماط الموجودة أولًا، ثم إضافة أنماط جديدة بأسماء فريدة فقط.
التفاصيل
الوصف الأصلي من المؤلف
Use reportlab's pre-defined styles from getSampleStyleSheet() correctly
repo: HKUDS/AgentPilot
الشعبية
- نجوم GitHub
- 7.8k
- الترتيب
- #12970
- الترخيص
- MIT
- آخر تحديث
- 1/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
agentpilot
7.8kيساعد وكيلك على تحسين مشروع خطوة بخطوة، بتجهيز مهمة وتشغيل حلقة AgentPilot التي تقترح التغييرات وتختبرها وتقيّمها.
openspace
7.8kيساعد وكيلك على إعداد OpenSpace، وهو أداة تخزن مهارات الوكلاء وتسترجعها، وربطه بتطبيق الذكاء الاصطناعي عبر MCP.
rsi-arena
7.8kيساعد وكيلك على إعداد اختبارات معيارية مثل AIME وTerminal-Bench وتشغيلها، لمقارنة طرق التحسين المختلفة.
experiment-guide
7.8kيساعد وكيلك على تخطيط تجارب صغيرة وقراءة نتائجها وتسجيل ما يتعلمه أثناء التحقيق في طرق تحسين برنامج.
مهارات مشابهة
feishu-doc
394kيساعد وكيلك على قراءة مستندات Feishu السحابية وإنشائها وتعديلها، بما فيها النصوص والصور والجداول، باستخدام أداة المستندات.
feishu-drive
394kيتيح لوكيلك تصفح الملفات في مجلد سحابي على Feishu شاركته مع البوت، وتنظيمها، والتعليق عليها.
feishu-perm
394kيساعد وكيلك على معرفة من يستطيع الوصول إلى ملف Feishu وتغيير ذلك، مع اختيار أدنى صلاحية تلبي طلبك.