Spaces:
Sleeping
Sleeping
Create ingest/export.py
Browse files- ingest/export.py +7 -33
ingest/export.py
CHANGED
|
@@ -1,35 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
from reportlab.lib.pagesizes import LETTER
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def export_pdf_report(rows):
|
| 12 |
-
return "Transparency PDF generated"
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
def export_congressional_briefing(rows):
|
| 16 |
-
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")
|
| 17 |
-
doc = SimpleDocTemplate(tmp.name, pagesize=LETTER)
|
| 18 |
-
styles = getSampleStyleSheet()
|
| 19 |
-
|
| 20 |
-
content = [
|
| 21 |
-
Paragraph("Federal FOIA Intelligence Search", styles["Title"]),
|
| 22 |
-
Paragraph("Congressional Staff Briefing", styles["Heading2"]),
|
| 23 |
-
Paragraph("Public Electronic Reading Rooms Only", styles["Italic"]),
|
| 24 |
-
]
|
| 25 |
-
|
| 26 |
-
for r in rows:
|
| 27 |
-
content.append(
|
| 28 |
-
Paragraph(
|
| 29 |
-
f"<b>{r[1]}</b><br/>Agency: {r[0]}<br/>{r[2]}",
|
| 30 |
-
styles["Normal"],
|
| 31 |
-
)
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
doc.build(content)
|
| 35 |
-
return f"Congressional briefing generated: {tmp.name}"
|
|
|
|
| 1 |
+
import zipfile
|
| 2 |
+
import json
|
|
|
|
| 3 |
import tempfile
|
| 4 |
|
| 5 |
+
def export_zip(results):
|
| 6 |
+
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
|
| 7 |
+
with zipfile.ZipFile(tmp.name, "w") as z:
|
| 8 |
+
z.writestr("results.json", json.dumps(results, indent=2))
|
| 9 |
+
return tmp.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|