-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbiblio.py
More file actions
1464 lines (1393 loc) · 36.9 KB
/
biblio.py
File metadata and controls
1464 lines (1393 loc) · 36.9 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Routines for displaying and updating the bibliography.
"""
# BUG We sometimes miss updates, why? I am sure we are sometimes missing
# deletions, but I haven't checked whether we are also missing new entries. Due
# to one-off error with versions no.? Or the isloation level in sqlite? Or just
# zotero itself? Other option: We should force a full bibliography update from
# time to time just in case, as we are doing for the catalog.
# For the conversion zotero->tei, this code is used:
# https://github.com/zotero/translators/blob/master/TEI.js
# The documentation for entry types and fields is at:
# https://www.zotero.org/support/kb/item_types_and_fields
import logging, unicodedata, html, re, time, sys, urllib, urllib.parse
import requests # pip install requests
from dharma import common, tree, languages
LIBRARY_ID = 1633743
MY_API_KEY = "ojTBU4SxEQ4L0OqUhFVyImjq"
# The headers "Backoff" and "Retry-After" tell us to wait n seconds before
# issuing the next request. Not sure what's the difference between these two,
# so choose the largest value.
def next_request_delay(r):
wait = 0
n = r.headers.get("Backoff", "")
if n.isdigit():
wait = max(wait, int(n))
n = r.headers.get("Retry-After", "")
if n.isdigit():
wait = max(wait, int(n))
return wait
# See https://www.zotero.org/support/dev/web_api/v3/syncing
#
# It's not quite clear from the documentation, but there is a global "version"
# counter that is incremented whenever the database is modified. Whenever a
# record is added/modified, its "version" key is set to the current global
# version, so that it's possible to detect items that have been added/modified
# since a given version.
#
# Note that items might be added or modified between the time this function is
# called and the time it returns. To address this, we save the global version
# number zotero gives us during the first call to its API. This version number
# is necessarily <= the version number zotero gives us during the last call to
# its API. If the version number does not change while we're updating things,
# all is well. Otherwise, we will need to fetch newly created and modified
# entries at a later point.
#
# The global version number is saved in the 'metadata' table.
def zotero_modified(latest_version, ret):
s = requests.Session()
s.headers["Zotero-API-Version"] = "3"
s.headers["Zotero-API-Key"] = MY_API_KEY
# The "since" param is not inclusive, this returns items whose version
# is > latest_version.
url = f"https://api.zotero.org/groups/{LIBRARY_ID}/items?since={latest_version}&includeTrashed=1"
logging.info(url)
r = s.get(url)
cutoff = 0
while True:
wait = next_request_delay(r)
if r.status_code != 200:
if wait < 1 or wait > 20:
# Will retry later.
logging.info(f"query failed with {r.status_code}, headers: {r.headers}")
logging.info(f"resetting biblio to {latest_version}")
cutoff = latest_version
break
new_version = int(r.headers["Last-Modified-Version"])
assert new_version >= latest_version
if not cutoff:
cutoff = new_version
logging.info(f"zotero new version: {cutoff}")
else:
assert new_version >= cutoff
entries = r.json()
assert isinstance(entries, list)
for entry in entries:
yield entry
next_page = re.search(r'<([^>]+)>;\s*rel="next"', r.headers.get("Link", ""))
if not next_page:
break
time.sleep(wait)
url = next_page.group(1)
logging.info(url)
r = s.get(url)
ret.append(cutoff)
def zotero_deleted(latest_version):
s = requests.Session()
s.headers["Zotero-API-Version"] = "3"
s.headers["Zotero-API-Key"] = MY_API_KEY
# Only a single page for this request.
url = f"https://api.zotero.org/groups/{LIBRARY_ID}/deleted?since={latest_version}"
logging.info(url)
r = s.get(url)
r.raise_for_status()
new_version = int(r.headers["Last-Modified-Version"])
assert new_version >= latest_version
return r.json().get("items", [])
def insert_entry(db, entry):
db.execute("delete from biblio where key = ?", (entry["key"],))
db.execute("""insert or replace into biblio_data(key, json)
values(?, ?)""", (entry["key"], entry))
# Zotero adds a .data.deleted=1 flag to entries marked as duplicates.
# The entry is not deleted until some trashbin is emptied.
# See https://github.com/erc-dharma/project-documentation/issues/311
# for details.
if entry["data"].get("deleted"):
return
short_title = entry["data"].get("shortTitle")
if not short_title:
return
sort_key = make_sort_key(entry["data"])
if not sort_key:
return
db.execute("""insert or replace into biblio(short_title, key, sort_key,
data) values(?, ?, ?, ?)""", (short_title, entry["key"],
sort_key, entry["data"]))
def update() -> bool:
"""Updates the bibliography. Returns a boolean indicating whether the
bibliography was modified."""
modified = False
db = common.db("texts")
(min_version,) = db.execute("""select value from metadata
where key = 'biblio_latest_version'""").fetchone()
if min_version <= 0:
min_version = 0
# Empty out the biblio, in case the version number has been
# changed manually and reset to 0.
db.execute("delete from biblio")
db.execute("delete from biblio_data")
modified = True
ret = []
for entry in zotero_modified(min_version, ret):
insert_entry(db, entry)
modified = True
assert len(ret) == 1
max_version = ret.pop()
for key in zotero_deleted(min_version):
db.execute("delete from biblio where key = ?", (key,))
db.execute("delete from biblio_data where key = ?", (key,))
modified = True
db.execute("""update metadata set value = ?
where key = 'biblio_latest_version'""", (max_version,))
db.execute("""replace into metadata
values('last_updated', strftime('%s', 'now'))""")
return modified
anonymous = "No name"
def multiple_pages(s):
return any(c in s for c in ",-\N{en dash}\N{em dash}")
class Writer(tree.Serializer):
def space(self):
text = self.top.text(space="preserve")
if text and not text[-1].isspace():
self.append(" ")
def period(self):
text = self.top.text()
j = len(text)
while j > 0:
j -= 1
c = text[j]
if c in ".?!":
return
if c.isalpha() or c.isdigit():
break
self.append(".")
# John Doe
def name_first_last(self, rec):
first, last = rec.get("firstName"), rec.get("lastName")
if first and last:
self.append(first)
self.space()
self.append(last)
elif last:
self.append(last)
elif first:
self.append(first)
self.space()
self.append(anonymous)
else:
self.append(rec.get("name") or anonymous)
# Doe, John
def name_last_first(self, rec):
first, last = rec.get("firstName"), rec.get("lastName")
if last and first:
self.append(last)
self.append(", ")
self.append(first)
elif last:
self.append(last)
elif first:
self.append(anonymous)
self.append(", ")
self.append(first)
else:
self.append(rec.get("name") or anonymous)
# Doe
def name_last(self, rec):
self.append(rec.get("lastName") or rec.get("name") or anonymous)
def front_creators(self, rec, skip_editors=False):
authors = []
for creator in rec["creators"]:
if creator["creatorType"] in ("bookAuthor", "editor"):
if skip_editors:
continue
elif creator["creatorType"] != "author":
continue
authors.append(creator)
if not authors:
self.append(anonymous)
for i, author in enumerate(authors):
if i == 0:
self.name_last_first(author)
continue
if i == len(authors) - 1:
self.append(" and ")
else:
self.append(", ")
self.name_first_last(author)
self.period()
def by_editors(self, rec):
self.back_creators(rec, use_authors=False, use_editors=True)
def by_authors(self, rec):
self.back_creators(rec, use_authors=True, use_editors=False)
def by_all_authors(self, rec):
self.back_creators(rec, use_authors=True, use_editors=True)
def back_creators(self, rec, use_authors=False, use_editors=True):
editors = []
authors = []
for creator in rec["creators"]:
if use_authors:
if creator["creatorType"] == "author":
authors.append(creator)
if use_editors:
if creator["creatorType"] == "editor":
editors.append(creator)
elif creator["creatorType"] == "bookAuthor":
authors.append(creator)
for creators, s in [(authors, "By"), (editors, "Edited by")]:
if not creators:
continue
self.space()
self.append(s)
self.space()
for i, creator in enumerate(creators):
if i == 0:
self.name_first_last(creator)
continue
if i == len(creators) - 1:
self.append(" and ")
else:
self.append(", ")
self.name_first_last(creator)
self.period()
def shorthand(self, rec):
self.append(rec["_shorthand"])
self.period()
def entry_front(self, rec, skip_editors=False):
if rec["_shorthand"]:
self.shorthand(rec)
else:
self.front_creators(rec, skip_editors)
self.date(rec)
def ref(self, rec):
authors = []
for creator in rec["creators"]:
if rec["itemType"] in ("bookSection", "journalArticle") and creator["creatorType"] in ("editor", "bookAuthor"):
continue
if creator["creatorType"] not in ("author", "editor", "bookAuthor"):
continue
authors.append(creator)
if len(authors) == 0:
self.append(anonymous)
elif len(authors) == 1:
self.name_last(authors[0])
elif len(authors) == 2:
self.name_last(authors[0])
self.space()
self.append("and")
self.space()
self.name_last(authors[1])
else:
self.name_last(authors[0])
self.space()
tag = tree.Tag("span", class_="italics")
tag.append("et al.")
self.append(tag)
self.space()
self.date(rec, end_field=False)
def date(self, rec, end_field=True, space=True):
buf = ""
orig_date = rec.get("_original_date")
if orig_date:
orig_date = orig_date.replace("-", "\N{en dash}")
buf += f"[{orig_date}] "
date = rec["date"]
if date:
date = date.replace("-", "\N{en dash}")
else:
date = "N.d."
buf += date
if space:
self.space()
self.append(buf)
if end_field:
self.period()
# Quoted title (for articles, etc.)
def quoted(self, title):
self.space()
if title:
self.append("“")
self.append(title)
self.period()
self.append("”")
else:
self.append("Untitled")
self.period()
# Title in italics (for books, etc.)
def italics(self, title):
self.space()
if title:
tag = tree.Tag("span", class_="italics")
tag.append(title)
self.append(tag)
else:
self.append("Untitled")
self.period()
def roman(self, title):
if not title:
return
self.space()
self.append(title)
self.period()
def blog_title(self, title):
if not title:
return
self.space()
tag = tree.Tag("span", class_="italics")
tag.append(title)
self.append(tag)
self.space()
self.append("(blog)")
self.period()
def volume_and_series(self, rec):
vol = rec.get("volume")
if vol:
self.space()
self.append("Vol.\N{nbsp}")
self.append(vol)
self.period()
# seriesText and seriesTitle are apparently deprecated.
series = rec.get("series")
if series:
self.space()
self.append(series)
n = rec.get("seriesNumber")
if n:
self.space()
self.append(n)
self.period()
n = rec.get("numberOfVolumes")
if n:
self.space()
self.append(n)
self.space()
self.append("vols.")
def entry_loc(self, loc):
if not loc:
return
first = True
sep = " "
for unit, val in loc:
self.append(sep)
sep = ", "
assert unit in cited_range_units
if unit != "mixed":
if unit == "page":
# TODO maybe not only for pages?
val = val.replace("-", "\N{en dash}")
# TODO not possible to tell unambiguously whether we have several units or not
if multiple_pages(val):
unit = common.numberize(unit, 2)
else:
unit = common.numberize(unit, 1)
if first:
unit = common.sentence_case(unit)
first = False
self.append(unit)
self.space()
if first:
val = common.sentence_case(val)
first = False
self.append(val)
self.period()
def loc(self, loc):
if not loc:
return
sep = " "
for unit, val in loc:
self.append(sep)
sep = ", "
assert unit in cited_range_units
if unit != "mixed":
if unit == "page":
# TODO maybe not only for pages?
val = val.replace("-", "\N{en dash}")
abbr_sg, abbr_pl = cited_range_units[unit]
# TODO not possible to tell unambiguously whether we have several units or not
if multiple_pages(val):
unit = abbr_pl
else:
unit = abbr_sg
self.append(unit)
self.append("\N{nbsp}")
self.append(val)
def pages(self, rec):
s = rec.get("pages")
if not s:
return
self.append(", ")
if multiple_pages(s):
self.append("pp.\N{nbsp}")
else:
self.append("p.\N{nbsp}")
s = s.replace("-", "\N{en dash}")
self.append(s)
def place_publisher_loc(self, rec):
self.space()
if (place := rec.get("place")):
self.append(place)
else:
self.append("No place")
if (publisher := rec.get("publisher")):
self.append(": ")
self.append(publisher)
if rec.get("_shorthand") and rec["date"]:
self.append(", ")
self.date(rec, end_field=False)
self.pages(rec)
self.period()
def edition(self, rec):
ed = rec["edition"]
if not ed:
return
self.space()
txt = ed.text()
if txt == "1":
self.append("1st edition")
elif txt == "2":
self.append("2nd edition")
elif txt == "3":
self.append("3rd edition")
elif txt.isdigit():
self.append(f"{txt}th edition")
else:
self.append(ed)
self.period()
def doi(self, rec):
doi = rec.get("DOI")
if not doi:
return
doi = urllib.parse.urlparse(doi).path.strip("/")
# All DOI start with "10.". We remove everything before that in the URI:
# https://doi.org/10.1163/22134379-9000164 -> 10.1163/22134379-9000164
# https://what.com/the/10.1163/22134379-9000164 -> 10.1163/22134379-9000164
while not doi.startswith("10."):
slash = doi.find("/")
if slash < 0:
return # invalid
doi = doi[slash + 1:]
self.space()
self.append("DOI:")
self.space()
tag = tree.Tag("link", href_=f"https://doi.org/{doi}")
tag.append(doi)
span = tree.Tag("span", class_="url")
span.append(tag)
self.append(span)
self.period()
def url_visible(self, urls):
self.space()
if len(urls) == 1:
self.append("URL:")
else:
self.append("URLs:")
self.space()
for i, url in enumerate(urls):
tag = tree.Tag("link", href=url)
tag.append(url)
span = tree.Tag("span", class_="url")
span.append(tag)
self.append(span)
if i < len(urls) - 1:
self.append("; ")
self.period()
def url_hidden(self, urls):
for url in urls:
tag = tree.Tag("link", href=url)
tag.append("[URL]")
self.space()
self.append(tag)
self.period()
def url(self, rec):
urls = [url.rstrip(";") for url in rec["url"].split()]
if not urls:
return
# I would rather show the full URL if needed to identify the
# record, in case people want to print it.
if rec["itemType"] in ("report", "webpage") and False:
self.url_visible(urls)
else:
self.url_hidden(urls)
def idents(self, rec):
self.doi(rec)
self.url(rec)
cited_range_units = {
"volume": ("vol.", "vols."),
"appendix": ("appendix", "appendices"),
"book": ("book", "books"),
"section": ("§", "§§"),
"page": ("p.", "pp."),
"item": ("№", "№"),
"figure": ("fig.", "figs."),
"plate": ("plate", "plates"),
"table": ("table", "tables"),
"note": ("n.", "nn."),
"part": ("part", "parts"),
"entry": ("s.v.", "s.vv.",),
"line": ("l.", "ll."),
"mixed": None,
}
creator_types = ["author", "editor", "bookAuthor"]
# journal article
"""
{
"DOI": "",
"ISSN": "",
"abstractNote": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"callNumber": "",
"collections": [
"LZ2UML25"
],
"creators": [
{
"creatorType": "author",
"firstName": "Yoshiaki",
"lastName": "ISHIZAWA"
}
],
"date": "1992",
"dateAdded": "2021-05-17T21:20:58Z",
"dateModified": "2023-06-29T05:35:15Z",
"extra": "tex.langue: English",
"issue": "",
"itemType": "journalArticle",
"journalAbbreviation": "",
"key": "25KCHJLX",
"language": "English",
"libraryCatalog": "",
"pages": "131-137",
"publicationTitle": "Renaissance Culturelle du Cambodge",
"relations": {},
"rights": "",
"series": "",
"seriesText": "",
"seriesTitle": "",
"shortTitle": "Ishizawa1992_05",
"tags": [
{
"tag": "Ishizawa1992_05"
}
],
"title": "Reports on the 7th Sophia University Survey Mission for the Study and Preservation of the Angkor Monuments: 1. Policy for the Sophia University Survey Mission for the Study and Preservation of the Angkor Monuments",
"url": "",
"version": 199174,
"volume": "7"
}
"""
def render_journal_article(rec, w):
w.entry_front(rec)
w.quoted(rec["title"])
print(w.tree.xml())
if rec["_shorthand"]:
w.by_authors(rec)
if rec["publicationTitle"] or rec["journalAbbreviation"]:
w.space()
abbr = rec["journalAbbreviation"]
name = rec["publicationTitle"]
# Use the abbreviated journal name if possible.
if abbr and name:
w.push(tree.Tag("span", class_="italics"))
w.append(name)
tip = w.pop().xml()
w.push(tree.Tag("span", class_="italics journal-abbr", tip=tip))
w.append(abbr)
w.join()
elif abbr:
w.push(tree.Tag("span", class_="italics"))
w.append(abbr)
w.join()
elif name:
w.push(tree.Tag("span", class_="italics"))
w.append(name)
w.join()
if rec["volume"]:
w.space()
w.append(rec["volume"])
if rec["issue"]:
w.space()
w.append("(")
w.append(rec["issue"])
w.append(")")
if rec["_shorthand"] and rec["date"]:
w.space()
w.append("(")
w.date(rec, end_field=False, space=False)
w.append(")")
w.pages(rec)
w.period()
w.idents(rec)
# book
"""
{
"ISBN": "",
"abstractNote": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"callNumber": "",
"collections": [
"IMXEGL2I"
],
"creators": [
{
"creatorType": "author",
"firstName": "Benjamin Lewis",
"lastName": "Rice"
},
{
"creatorType": "author",
"firstName": "R.",
"lastName": "Narasimhachar"
}
],
"date": "1923",
"dateAdded": "2023-04-25T13:03:22Z",
"dateModified": "2023-06-29T09:09:41Z",
"edition": "2",
"extra": "",
"itemType": "book",
"key": "XVCMZSKY",
"language": "",
"libraryCatalog": "",
"numPages": "",
"numberOfVolumes": "",
"place": "Bangalore",
"publisher": "Mysore Government Central Press",
"relations": {},
"rights": "",
"series": "Epigraphia Carnatica",
"seriesNumber": "2",
"shortTitle": "Rice+Narasimhachar1923",
"tags": [],
"title": "Inscriptions at Sravana Belgola (Revised Edition)",
"url": "",
"version": 199176,
"volume": ""
}
"""
def render_book(rec, w):
w.entry_front(rec)
w.italics(rec["title"])
if rec["_shorthand"]:
w.by_all_authors(rec)
w.edition(rec)
w.volume_and_series(rec)
w.place_publisher_loc(rec)
w.idents(rec)
# conference paper
"""
{
"DOI": "",
"ISBN": "",
"abstractNote": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"callNumber": "",
"collections": [
"D7CGVND8",
"ZKAMV4ZC"
],
"conferenceName": "Seminar Sejarah Nasional II, August 26th-29th 1970, Yogyakarta",
"creators": [
{
"creatorType": "author",
"firstName": "M. M.",
"lastName": "Sukarto K. Atmodjo"
}
],
"date": "1970",
"dateAdded": "2019-10-29T11:56:33Z",
"dateModified": "2023-09-08T03:48:04Z",
"extra": "",
"itemType": "conferencePaper",
"key": "3ZE7ICXR",
"language": "Indonesian",
"libraryCatalog": "",
"pages": "52",
"place": "Yogyakarta",
"proceedingsTitle": "",
"publisher": "",
"relations": {
"dc:replaces": "http://zotero.org/groups/1633743/items/PNXXJIQ6"
},
"rights": "",
"series": "",
"shortTitle": "SukartoKAtmodjo1970_01",
"tags": [
{
"tag": "SukartoAtmodjo1970_02"
}
],
"title": "Prasasti Buyan-Sanding-Tamblingan dari djaman Radja Jayapangus",
"url": "",
"version": 201774,
"volume": ""
}
"""
def render_conference_paper(rec, w):
w.entry_front(rec, skip_editors=True)
w.quoted(rec["title"])
if rec["_shorthand"]:
w.by_authors(rec)
if rec["proceedingsTitle"]:
w.space()
w.append("In: ")
w.italics(rec["proceedingsTitle"])
w.by_editors(rec)
w.volume_and_series(rec)
w.place_publisher_loc(rec)
w.idents(rec)
# report
"""
{
"abstractNote": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"callNumber": "",
"collections": [
"ZKAMV4ZC"
],
"creators": [
{
"creatorType": "author",
"name": "Goenawan A. Sambodo"
}
],
"date": "2018",
"dateAdded": "2021-03-16T08:35:08Z",
"dateModified": "2023-04-05T23:32:10Z",
"extra": "",
"institution": "",
"itemType": "report",
"key": "HCM2HCJB",
"language": "Indonesian",
"libraryCatalog": "",
"pages": "",
"place": "Yogyakarta",
"relations": {},
"reportNumber": "",
"reportType": "",
"rights": "",
"seriesTitle": "",
"shortTitle": "GoenawanASambodo2018_02",
"tags": [
{
"tag": "GoenawanASambodo2018_02"
}
],
"title": "Kajian Singkat Prasasti Śrī Rānāpati",
"url": "https://www.academia.edu/38202838/Kajian_singkat_prasasti_Sri_Ranapati_pdf",
"version": 196839
}
"""
def render_report(rec, w):
w.entry_front(rec)
w.quoted(rec["title"])
if rec["_shorthand"]:
w.by_authors(rec)
w.place_publisher_loc(rec)
w.idents(rec)
# book section
"""
{
"ISBN": "",
"abstractNote": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"bookTitle": "The Buddhist Monuments in Asia",
"callNumber": "",
"collections": [
"LZ2UML25"
],
"creators": [
{
"creatorType": "author",
"firstName": "Yoshiaki",
"lastName": "ISHIZAWA"
}
],
"date": "1988",
"dateAdded": "2021-05-18T07:41:32Z",
"dateModified": "2023-06-29T05:31:44Z",
"edition": "",
"extra": "tex.langue: English",
"itemType": "bookSection",
"key": "YZ9QVXWK",
"language": "",
"libraryCatalog": "",
"numberOfVolumes": "",
"pages": "231-258",
"place": "",
"publisher": "Institute of Asian Ethno-Forms and Culture",
"relations": {},
"rights": "",
"series": "",
"seriesNumber": "",
"shortTitle": "Ishizawa1988_02",
"tags": [
{
"tag": "Ishizawa1988_02"
}
],
"title": "Angkor Vat",
"url": "",
"version": 199160,
"volume": ""
}
"""
def render_book_section(rec, w):
w.entry_front(rec, skip_editors=True)
w.quoted(rec["title"])
if rec["_shorthand"]:
w.by_authors(rec)
if rec["bookTitle"]:
w.space()
w.append("In: ")
w.italics(rec["bookTitle"])
w.edition(rec)
w.by_editors(rec)
w.volume_and_series(rec)
w.place_publisher_loc(rec)
w.idents(rec)
# thesis
"""
{
"data": {
"abstractNote": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"callNumber": "",
"collections": [
"EBTHLX5L"
],
"creators": [
{
"creatorType": "author",
"name": "Aditia Gunawan"
}
],
"date": "2023",
"dateAdded": "2023-06-13T09:50:20Z",
"dateModified": "2023-06-27T22:58:46Z",
"extra": "",
"itemType": "thesis",
"key": "YGEQDXT2",
"language": "English",
"libraryCatalog": "",
"numPages": "",
"place": "Paris",
"relations": {},
"rights": "",
"shortTitle": "",
"tags": [],
"thesisType": "Doctoral Thesis",
"title": "Sundanese Religion in the 15th Century: A Philological Study based on the Śikṣā Guru, the Sasana Mahaguru, and the Siksa Kandaṅ Karǝsian",
"university": "École Pratique des Hautes Études, PSL University",
"url": "",
"version": 199074
}
"""
def render_thesis(rec, w):
w.entry_front(rec)
w.quoted(rec["title"])
if rec["_shorthand"]:
w.by_authors(rec)
w.space()
w.append(rec["thesisType"] or "Thesis")
if rec["university"]:
w.append(", ")
w.append(rec["university"])
w.period()
w.place_publisher_loc(rec)
w.idents(rec)
# web pages
"""
{
"abstractNote": "",
"accessDate": "",
"collections": [],
"creators": [
{
"creatorType": "author",
"firstName": "Philip N",
"lastName": "Jenner"
}
],
"date": "n.d.",
"dateAdded": "2023-10-20T07:50:06Z",
"dateModified": "2023-10-20T08:04:25Z",
"extra": "",
"itemType": "webpage",
"key": "Y6HD9LEE",
"language": "English",
"relations": {},
"rights": "",
"shortTitle": "",
"tags": [],
"title": "Analysis: pre-Angkor, Angkor and Middle Khmer Inscriptions",
"url": "http://sealang.net/oldkhmer/text.htm",
"version": 203590,
"websiteTitle": "",
"websiteType": ""
}
"""
def render_webpage(rec, w):
w.entry_front(rec)
if rec["title"]:
w.quoted(rec["title"])
if rec["_shorthand"]:
w.by_authors(rec)
if rec["_shorthand"] and rec["date"]:
w.date(rec)
if rec["websiteTitle"]:
w.roman(rec["websiteTitle"])
w.idents(rec)