Spaces:
Sleeping
Sleeping
Create appendix.py
Browse files- appendix.py +42 -0
appendix.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
| 2 |
+
from reportlab.lib.styles import getSampleStyleSheet
|
| 3 |
+
import io
|
| 4 |
+
from datetime import datetime
|
| 5 |
+
|
| 6 |
+
def build_litigation_appendix(records):
|
| 7 |
+
buffer = io.BytesIO()
|
| 8 |
+
doc = SimpleDocTemplate(buffer)
|
| 9 |
+
styles = getSampleStyleSheet()
|
| 10 |
+
story = []
|
| 11 |
+
|
| 12 |
+
story.append(Paragraph("<b>Litigation Appendix</b>", styles["Title"]))
|
| 13 |
+
story.append(Spacer(1, 12))
|
| 14 |
+
story.append(Paragraph(
|
| 15 |
+
f"Generated: {datetime.utcnow().strftime('%B %d, %Y UTC')}",
|
| 16 |
+
styles["Normal"]
|
| 17 |
+
))
|
| 18 |
+
story.append(Spacer(1, 12))
|
| 19 |
+
|
| 20 |
+
exhibit_num = 1
|
| 21 |
+
for r in records:
|
| 22 |
+
exhibit = f"Exhibit A-{exhibit_num}"
|
| 23 |
+
story.append(Paragraph(f"<b>{exhibit}</b>", styles["Heading2"]))
|
| 24 |
+
story.append(Paragraph(f"<b>Agency:</b> {r['agency']}", styles["Normal"]))
|
| 25 |
+
story.append(Paragraph(f"<b>Title:</b> {r['title']}", styles["Normal"]))
|
| 26 |
+
story.append(Paragraph(f"<b>URL:</b> {r['url']}", styles["Normal"]))
|
| 27 |
+
story.append(Paragraph(
|
| 28 |
+
f"<b>Retrieved:</b> {r['timestamp']}",
|
| 29 |
+
styles["Normal"]
|
| 30 |
+
))
|
| 31 |
+
story.append(Spacer(1, 10))
|
| 32 |
+
exhibit_num += 1
|
| 33 |
+
|
| 34 |
+
story.append(Spacer(1, 20))
|
| 35 |
+
story.append(Paragraph(
|
| 36 |
+
"<i>All exhibits link to official FOIA electronic reading rooms.</i>",
|
| 37 |
+
styles["Italic"]
|
| 38 |
+
))
|
| 39 |
+
|
| 40 |
+
doc.build(story)
|
| 41 |
+
buffer.seek(0)
|
| 42 |
+
return buffer
|