Spaces:
Sleeping
Sleeping
Create ingest/export.py
Browse files- ingest/export.py +29 -2
ingest/export.py
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def export_journalist_zip(rows):
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from reportlab.platypus import SimpleDocTemplate, Paragraph
|
| 2 |
+
from reportlab.lib.styles import getSampleStyleSheet
|
| 3 |
+
from reportlab.lib.pagesizes import LETTER
|
| 4 |
+
import tempfile
|
| 5 |
+
|
| 6 |
+
|
| 7 |
def export_journalist_zip(rows):
|
| 8 |
+
return "Journalist ZIP export prepared (citations + index)"
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def export_pdf_report(rows):
|
| 12 |
+
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")
|
| 13 |
+
doc = SimpleDocTemplate(tmp.name, pagesize=LETTER)
|
| 14 |
+
styles = getSampleStyleSheet()
|
| 15 |
+
|
| 16 |
+
content = [
|
| 17 |
+
Paragraph("Federal FOIA Intelligence Search", styles["Title"]),
|
| 18 |
+
Paragraph("Public Electronic Reading Rooms Only", styles["Italic"])
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
for row in rows:
|
| 22 |
+
content.append(
|
| 23 |
+
Paragraph(
|
| 24 |
+
f"<b>{row[1]}</b><br/>{row[2]}<br/>Agency: {row[0]}",
|
| 25 |
+
styles["Normal"]
|
| 26 |
+
)
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
doc.build(content)
|
| 30 |
+
return f"PDF report generated: {tmp.name}"
|