|
4 | 4 | import time |
5 | 5 | import glob |
6 | 6 | from collections import defaultdict |
| 7 | +from datetime import datetime |
7 | 8 |
|
8 | 9 | import requests |
9 | 10 | import lxml.etree as ET |
@@ -393,12 +394,54 @@ def process_page(self, page_json): |
393 | 394 |
|
394 | 395 | def get_man_json_dump(self, lmt=True): |
395 | 396 | json_dump = {} |
396 | | - json_dump["id"] = f"bibl__{self.manifestation_id}" |
397 | | - json_dump["browser_url"] = f"{self.browser}{self.manifestation_folder}" |
| 397 | + json_dump['id'] = f"bibl__{self.manifestation_id}" |
| 398 | + json_dump['browser_url'] = f"{self.browser}{self.manifestation_folder}" |
398 | 399 | man_type = self.manifestation['data']['type'].replace('--', '/') |
399 | | - json_dump["url"] = f"{self.endpoint}{man_type}/{self.manifestation_id}" |
| 400 | + json_dump['url'] = f"{self.endpoint}{man_type}/{self.manifestation_id}" |
400 | 401 | json_dump['man_title'] = self.md__title |
401 | 402 | json_dump['signature'] = self.manifestation_signatur |
| 403 | + try: |
| 404 | + field_status = self.manifestation['data']['attributes']['field_status_umschrift'] |
| 405 | + if field_status == 2: |
| 406 | + field_name = "complete" |
| 407 | + field_status = str(field_status) |
| 408 | + elif field_status is None: |
| 409 | + field_name = "proposed" |
| 410 | + field_status = "0" |
| 411 | + else: |
| 412 | + field_name = "undefined" |
| 413 | + field_status = str(field_status) |
| 414 | + d = datetime.now() |
| 415 | + dt = f"{d.year}-{d.month}-{d.day}" |
| 416 | + json_dump['status'] = { |
| 417 | + "id": field_status, |
| 418 | + "name": field_name, |
| 419 | + "date": dt |
| 420 | + } |
| 421 | + except (KeyError, TypeError): |
| 422 | + json_dump['status'] = {} |
| 423 | + try: |
| 424 | + man_type_name = self.manifestation_typ['data']['attributes']['name'] |
| 425 | + man_type_id = self.manifestation_typ['data']['id'] |
| 426 | + man_type_type = self.manifestation_typ['data']['type'] |
| 427 | + json_dump['man_doc_type'] = { |
| 428 | + "id": man_type_id, |
| 429 | + "type": man_type_type, |
| 430 | + "name": man_type_name |
| 431 | + } |
| 432 | + except (KeyError, TypeError): |
| 433 | + json_dump['man_doc_type'] = {} |
| 434 | + try: |
| 435 | + doc_type_name = self.doc_component['data']['attributes']['name'] |
| 436 | + doc_type_id = self.doc_component['data']['id'] |
| 437 | + doc_type_type = self.doc_component['data']['type'] |
| 438 | + json_dump['doc_component'] = { |
| 439 | + "id": doc_type_id, |
| 440 | + "type": doc_type_type, |
| 441 | + "name": doc_type_name |
| 442 | + } |
| 443 | + except (KeyError, TypeError): |
| 444 | + json_dump['doc_component'] = {} |
402 | 445 | try: |
403 | 446 | json_dump['note_i'] = self.manifestation['data']['attributes']['field_anmerkung_intern_']['processed'] |
404 | 447 | except (KeyError, TypeError): |
@@ -990,6 +1033,8 @@ def __init__( |
990 | 1033 | self.sprache = self.get_fields_any('field_sprache') |
991 | 1034 | self.type = self.get_fields_any('field_publication_type') |
992 | 1035 | self.edition = self.get_fields_any('field_edition') |
| 1036 | + self.doc_component = self.get_fields_any('field_doc_component') |
| 1037 | + self.manifestation_typ = self.get_fields_any('field_manifestation_typ') |
993 | 1038 | # first level publication |
994 | 1039 | self.publication = self.get_fields_any('field_published_in') |
995 | 1040 | self.pub_publisher = self.get_fields_any_any('field_publisher', self.publication) |
|
0 commit comments