Spaces:
Sleeping
Sleeping
Create ingest/citations.py
Browse files- ingest/citations.py +16 -0
ingest/citations.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from reportlab.platypus import SimpleDocTemplate, Paragraph
|
| 2 |
+
from reportlab.lib.styles import getSampleStyleSheet
|
| 3 |
+
import tempfile
|
| 4 |
+
|
| 5 |
+
def bluebook_pdf(results):
|
| 6 |
+
styles = getSampleStyleSheet()
|
| 7 |
+
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")
|
| 8 |
+
doc = SimpleDocTemplate(tmp.name)
|
| 9 |
+
|
| 10 |
+
content = []
|
| 11 |
+
for r in results:
|
| 12 |
+
citation = f"{r['agency']}, {r['title']}, {r['url']}."
|
| 13 |
+
content.append(Paragraph(citation, styles["Normal"]))
|
| 14 |
+
|
| 15 |
+
doc.build(content)
|
| 16 |
+
return tmp.name
|