File size: 1,399 Bytes
a7ac4fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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