CoolFace
Apppublic

GodsDevProject/FOIA_Doc_Search

sourceHugging Facemitupdated 8mo agoView on Hugging Face
1likes
appendix.py42 linesDownload Raw Back to root
1from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer2from reportlab.lib.styles import getSampleStyleSheet3import io4from datetime import datetime5 6def 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 = 121    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 += 133 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