FOIA_Doc_Search / appendix.py
GodsDevProject's picture
Create appendix.py
a7ac4fd verified
raw
history blame
1.4 kB
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
import io
from datetime import datetime
def build_litigation_appendix(records):
buffer = io.BytesIO()
doc = SimpleDocTemplate(buffer)
styles = getSampleStyleSheet()
story = []
story.append(Paragraph("<b>Litigation Appendix</b>", styles["Title"]))
story.append(Spacer(1, 12))
story.append(Paragraph(
f"Generated: {datetime.utcnow().strftime('%B %d, %Y UTC')}",
styles["Normal"]
))
story.append(Spacer(1, 12))
exhibit_num = 1
for r in records:
exhibit = f"Exhibit A-{exhibit_num}"
story.append(Paragraph(f"<b>{exhibit}</b>", styles["Heading2"]))
story.append(Paragraph(f"<b>Agency:</b> {r['agency']}", styles["Normal"]))
story.append(Paragraph(f"<b>Title:</b> {r['title']}", styles["Normal"]))
story.append(Paragraph(f"<b>URL:</b> {r['url']}", styles["Normal"]))
story.append(Paragraph(
f"<b>Retrieved:</b> {r['timestamp']}",
styles["Normal"]
))
story.append(Spacer(1, 10))
exhibit_num += 1
story.append(Spacer(1, 20))
story.append(Paragraph(
"<i>All exhibits link to official FOIA electronic reading rooms.</i>",
styles["Italic"]
))
doc.build(story)
buffer.seek(0)
return buffer