digiflow 3.4.0__tar.gz → 3.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {digiflow-3.4.0/src/digiflow.egg-info → digiflow-3.4.2}/PKG-INFO +1 -1
  2. {digiflow-3.4.0 → digiflow-3.4.2}/pyproject.toml +1 -1
  3. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/__init__.py +1 -0
  4. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/digiflow_io.py +4 -2
  5. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/digiflow_metadata.py +49 -43
  6. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/digiflow_validate.py +1 -4
  7. {digiflow-3.4.0 → digiflow-3.4.2/src/digiflow.egg-info}/PKG-INFO +1 -1
  8. {digiflow-3.4.0 → digiflow-3.4.2}/LICENCE +0 -0
  9. {digiflow-3.4.0 → digiflow-3.4.2}/MANIFEST.in +0 -0
  10. {digiflow-3.4.0 → digiflow-3.4.2}/README.md +0 -0
  11. {digiflow-3.4.0 → digiflow-3.4.2}/setup.cfg +0 -0
  12. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/digflow_identifier.py +0 -0
  13. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/digiflow_export.py +0 -0
  14. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/digiflow_generate.py +0 -0
  15. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/digilife.ini +0 -0
  16. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/sch/ddb_validierung_mets-mods-ap-digitalisierte-medien.sch +0 -0
  17. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/sch/ddb_validierung_mets-mods-ap-digitalisierte-zeitungen.sch +0 -0
  18. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/alto_4-2.xsd +0 -0
  19. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/mets_1-12.xsd +0 -0
  20. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/mix_2-0.xsd +0 -0
  21. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/mods_3-7.xsd +0 -0
  22. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/page_2019-07-15.xsd +0 -0
  23. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/xlink.xsd +0 -0
  24. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsd/xml.xsd +0 -0
  25. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsl/ddb_validierung_mets-mods-ap-digitalisierte-medien.xsl +0 -0
  26. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/resources/xsl/ddb_validierung_mets-mods-ap-digitalisierte-zeitungen.xsl +0 -0
  27. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow/schematron/schxslt-cli.jar +0 -0
  28. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow.egg-info/SOURCES.txt +0 -0
  29. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow.egg-info/dependency_links.txt +0 -0
  30. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow.egg-info/requires.txt +0 -0
  31. {digiflow-3.4.0 → digiflow-3.4.2}/src/digiflow.egg-info/top_level.txt +0 -0
  32. {digiflow-3.4.0 → digiflow-3.4.2}/tests/test_digiflow_generate.py +0 -0
  33. {digiflow-3.4.0 → digiflow-3.4.2}/tests/test_digiflow_identifier.py +0 -0
  34. {digiflow-3.4.0 → digiflow-3.4.2}/tests/test_digiflow_io.py +0 -0
  35. {digiflow-3.4.0 → digiflow-3.4.2}/tests/test_digiflow_metadata.py +0 -0
  36. {digiflow-3.4.0 → digiflow-3.4.2}/tests/test_digiflow_validate.py +0 -0
  37. {digiflow-3.4.0 → digiflow-3.4.2}/tests/test_export_saf.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digiflow
3
- Version: 3.4.0
3
+ Version: 3.4.2
4
4
  Summary: Father's Little Digitization Workflow Helper
5
5
  Author-email: Universitäts- und Landesbibliothek Sachsen-Anhalt <development@bibliothek.uni-halle.de>
6
6
  Project-URL: Homepage, https://github.com/ulb-sachsen-anhalt/digital-flow
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "digiflow"
7
- version = "3.4.0"
7
+ version = "3.4.2"
8
8
  description = "Father's Little Digitization Workflow Helper"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -19,6 +19,7 @@ from .digiflow_validate import (
19
19
  DIGIS_MULTIVOLUME,
20
20
  DIGIS_NEWSPAPER,
21
21
  REPORT_FILE_SCHEMATRON,
22
+ REPORT_FILE_XSLT,
22
23
  DigiflowDDBException,
23
24
  ddb_validation,
24
25
  ddb_validation_sch,
@@ -805,7 +805,7 @@ class OAILoader:
805
805
  if post_func and data:
806
806
  # divide METS from XML (OCR-ALTO)
807
807
  # in rather brute force fashion
808
- _snippet = data[:200]
808
+ _snippet = data[:512]
809
809
  # propably sanitize data, as it might originate
810
810
  # from test-data or *real* requests
811
811
  if not isinstance(_snippet, str):
@@ -1003,7 +1003,7 @@ def request_resource(url: str, path_local: Path, **kwargs):
1003
1003
 
1004
1004
  # catch other content types by MIMI sub_type
1005
1005
  # split "<application|image>/<sub_type>"
1006
- elif content_type.split('/')[-1] in ['image', 'jpeg', 'pdf']:
1006
+ elif content_type.split('/')[-1] in ['jpg', 'jpeg', 'pdf', 'png']:
1007
1007
  path_local = _sanitize_local_file_extension(
1008
1008
  path_local, content_type)
1009
1009
  if not isinstance(path_local, Path):
@@ -1028,6 +1028,8 @@ def _sanitize_local_file_extension(path_local, content_type):
1028
1028
  path_local += '.xml'
1029
1029
  elif 'jpeg' in content_type and not path_local.endswith('.jpg'):
1030
1030
  path_local += '.jpg'
1031
+ elif 'png' in content_type and not path_local.endswith('.png'):
1032
+ path_local += '.png'
1031
1033
  elif 'pdf' in content_type and not path_local.endswith('.pdf'):
1032
1034
  path_local += '.pdf'
1033
1035
  return path_local
@@ -41,22 +41,22 @@ ET.register_namespace('zvdd', 'http://zvdd.gdz-cms.de/')
41
41
 
42
42
 
43
43
  XMLNS = {
44
- 'alto' : 'http://www.loc.gov/standards/alto/ns-v4#',
45
- 'dc' : 'http://purl.org/dc/elements/1.1/',
46
- 'dv' : 'http://dfg-viewer.de/',
47
- 'epicur' : 'urn:nbn:de:1111-2004033116',
44
+ 'alto': 'http://www.loc.gov/standards/alto/ns-v4#',
45
+ 'dc': 'http://purl.org/dc/elements/1.1/',
46
+ 'dv': 'http://dfg-viewer.de/',
47
+ 'epicur': 'urn:nbn:de:1111-2004033116',
48
48
  'marcxml': 'http://www.loc.gov/MARC21/slim',
49
- 'goobi' : 'http://meta.goobi.org/v1.5.1/',
50
- 'mets' : 'http://www.loc.gov/METS/',
51
- 'mix' : 'http://www.loc.gov/mix/v20',
52
- 'mods' : 'http://www.loc.gov/mods/v3',
53
- 'oai' : 'http://www.openarchives.org/OAI/2.0/',
54
- 'oai_dc' : 'http://www.openarchives.org/OAI/2.0/oai_dc/',
55
- 'ulb' : 'https://bibliothek.uni-halle.de',
56
- 'vl' : 'http://visuallibrary.net/vl',
57
- 'vlz' : 'http://visuallibrary.net/vlz/1.0/',
58
- 'xlink' : 'http://www.w3.org/1999/xlink',
59
- 'zvdd' : 'http://zvdd.gdz-cms.de/',
49
+ 'goobi': 'http://meta.goobi.org/v1.5.1/',
50
+ 'mets': 'http://www.loc.gov/METS/',
51
+ 'mix': 'http://www.loc.gov/mix/v20',
52
+ 'mods': 'http://www.loc.gov/mods/v3',
53
+ 'oai': 'http://www.openarchives.org/OAI/2.0/',
54
+ 'oai_dc': 'http://www.openarchives.org/OAI/2.0/oai_dc/',
55
+ 'ulb': 'https://bibliothek.uni-halle.de',
56
+ 'vl': 'http://visuallibrary.net/vl',
57
+ 'vlz': 'http://visuallibrary.net/vlz/1.0/',
58
+ 'xlink': 'http://www.w3.org/1999/xlink',
59
+ 'zvdd': 'http://zvdd.gdz-cms.de/',
60
60
  }
61
61
 
62
62
  #
@@ -88,24 +88,23 @@ CONTENT_FILE_GROUPS = [
88
88
  ]
89
89
 
90
90
  # well grounded script root
91
- DIGIFLOW_METADATA_ROOT = os.path.dirname(os.path.abspath(__file__))
91
+ SRC_DIGIFLOW_RES = os.path.dirname(os.path.abspath(__file__))
92
92
 
93
93
  # schema validtion XSDs
94
- METS_1_12 = os.path.join(DIGIFLOW_METADATA_ROOT,
94
+ METS_1_12 = os.path.join(SRC_DIGIFLOW_RES,
95
95
  'resources', 'xsd', 'mets_1-12.xsd')
96
- MODS_3_7 = os.path.join(DIGIFLOW_METADATA_ROOT,
96
+ MODS_3_7 = os.path.join(SRC_DIGIFLOW_RES,
97
97
  'resources', 'xsd', 'mods_3-7.xsd')
98
- MIX_2_0 = os.path.join(DIGIFLOW_METADATA_ROOT,
98
+ MIX_2_0 = os.path.join(SRC_DIGIFLOW_RES,
99
99
  'resources', 'xsd', 'mix_2-0.xsd')
100
- ALTO_3_1 = os.path.join(DIGIFLOW_METADATA_ROOT,
100
+ ALTO_3_1 = os.path.join(SRC_DIGIFLOW_RES,
101
101
  'resources', 'xsd', 'alto_3-1.xsd')
102
- ALTO_4_2 = os.path.join(DIGIFLOW_METADATA_ROOT,
102
+ ALTO_4_2 = os.path.join(SRC_DIGIFLOW_RES,
103
103
  'resources', 'xsd', 'alto_4-2.xsd')
104
104
  XSD_MAPPINGS = {'mets:mets': [METS_1_12], 'mods:mods': [MODS_3_7], 'mix:mix': [
105
105
  MIX_2_0], 'alto': [ALTO_4_2]}
106
106
 
107
107
 
108
-
109
108
  def __is_schema_root(xml_tree, schema) -> bool:
110
109
  """
111
110
  Schema *might* be prefixed, like mets:mets, *or* not like ALTO-files
@@ -195,8 +194,8 @@ def pretty_xml(xml_root, preamble='<?xml version="1.0" encoding="UTF-8"?>'):
195
194
  """
196
195
  _as_string = ET.tostring(ET.ElementTree(xml_root), pretty_print=True, encoding='UTF-8')
197
196
  _pretty_parser = ET.XMLParser(resolve_entities=False,
198
- strip_cdata=False,
199
- remove_blank_text=True)
197
+ strip_cdata=False,
198
+ remove_blank_text=True)
200
199
  _root = ET.fromstring(_as_string, _pretty_parser)
201
200
  ET.cleanup_namespaces(_root, top_nsmap=XMLNS)
202
201
  _formatted = ET.tostring(_root, pretty_print=True, encoding='UTF-8').decode('UTF-8')
@@ -315,7 +314,7 @@ class MetsProcessor(XMLProcessor):
315
314
  parent = agent.getparent()
316
315
  parent.remove(agent)
317
316
 
318
- def contains_group(self, group:'str|List[str]') -> bool:
317
+ def contains_group(self, group: 'str|List[str]') -> bool:
319
318
  """Test if a certain fileGroup exists"""
320
319
 
321
320
  if isinstance(group, list):
@@ -382,15 +381,17 @@ class MetsReaderReport:
382
381
  PREFIX_VLS = 'md'
383
382
 
384
383
  NEWSPAPER_TYPES = ['issue', 'additional', 'year', 'newspaper']
384
+
385
+
385
386
  class MetsReader(MetsProcessor):
386
387
  """
387
388
  Read and try to make sense of METS/MODS Metadata which
388
389
  might be enclosed in OAI-PMH or as local file.
389
-
390
+
390
391
  Each METS-Record is considere to have at least
391
392
  * a primary descriptive Metadata section (prime_dmd), and
392
393
  * a structure Mapping, optionally marked with @TYPE=LOGICAL
393
-
394
+
394
395
  For Identifiers of primary descriptive Metadata sections (prime_dmd) holds
395
396
  * VLS-Records are prefixed 'md' and the ID is considered numeric
396
397
  * Kitodo2 Monographs are fixed to "DMDLOG_0000"
@@ -399,7 +400,7 @@ class MetsReader(MetsProcessor):
399
400
  * Kitodo3 objects use UUIDs
400
401
  """
401
402
 
402
- def __init__(self, path_mets, dmd_id:str=None):
403
+ def __init__(self, path_mets, dmd_id: str = None):
403
404
  super().__init__(path_mets)
404
405
  self._prime_type: Optional[str] = None
405
406
  self._prime_mods = None
@@ -438,9 +439,9 @@ class MetsReader(MetsProcessor):
438
439
  # if more MODS present
439
440
  # we are only interested in those with identifiers present
440
441
  primes = [d.get('ID')
441
- for d in dmd_candidates
442
- if len([m for m in d.iterdescendants() if 'identifier' in m.tag]) > 0
443
- ]
442
+ for d in dmd_candidates
443
+ if len([m for m in d.iterdescendants() if 'identifier' in m.tag]) > 0
444
+ ]
444
445
  if len(primes) == 1:
445
446
  self._prime_mods_id = primes[0]
446
447
  else:
@@ -495,7 +496,8 @@ class MetsReader(MetsProcessor):
495
496
  def _determine_prime_dmd(self):
496
497
  """Encapsulated recognition of primary DMD section"""
497
498
  _raw_id = self._prime_mods_id
498
- dmd_secs = self.tree.findall(f'.//mets:dmdSec[@ID="{_raw_id}"]/mets:mdWrap/mets:xmlData/mods:mods', XMLNS)
499
+ dmd_secs = self.tree.findall(
500
+ f'.//mets:dmdSec[@ID="{_raw_id}"]/mets:mdWrap/mets:xmlData/mods:mods', XMLNS)
499
501
  if len(dmd_secs) == 0:
500
502
  raise RuntimeError(f"invalid dmd_id {_raw_id}")
501
503
  # although this means invalid METS, rather check this, too
@@ -536,7 +538,7 @@ class MetsReader(MetsProcessor):
536
538
 
537
539
  def check(self):
538
540
  """Ensure certain invariants
539
-
541
+
540
542
  * each logical section is at least connected to a physical container
541
543
  if not, this means empty logical sections => DDB warning, Derivans death
542
544
 
@@ -550,7 +552,7 @@ class MetsReader(MetsProcessor):
550
552
 
551
553
  def _check_logical_interlinking(self):
552
554
  _log_ids = self.tree.xpath(f'.//mets:div[@DMDID="{self.dmd_id}"]/mets:div/@ID',
553
- namespaces=XMLNS)
555
+ namespaces=XMLNS)
554
556
  for _log_id in _log_ids:
555
557
  _links = self.tree.findall(f'.//mets:smLink[@{XLINK_FROM}="{_log_id}"]', XMLNS)
556
558
  if not _links:
@@ -595,7 +597,7 @@ class MetsReader(MetsProcessor):
595
597
  log_el = self.findall(xpath, get_all=False)
596
598
  if log_el is not None:
597
599
  log_type = log_el.attrib['TYPE']
598
- _mods_id:str = self._prime_mods_id
600
+ _mods_id: str = self._prime_mods_id
599
601
  if _mods_id.startswith('md'):
600
602
  _mods_id = _mods_id[2:]
601
603
  _line = [(_mods_id, log_type)]
@@ -682,15 +684,16 @@ class MetsReader(MetsProcessor):
682
684
  _mhdrs = self.xpath('//mets:metsHdr')
683
685
  if len(_mhdrs) == 1:
684
686
  _mhdr = _mhdrs[0]
685
- _repos = self.xpath('mets:agent[@OTHERTYPE="REPOSITORY"]/mets:name/text()',_mhdr)
687
+ _repos = self.xpath('mets:agent[@OTHERTYPE="REPOSITORY"]/mets:name/text()', _mhdr)
686
688
  _repo = _repos[0] if len(_repos) == 1 else MARK_AGENT_LEGACY.split(':', maxsplit=1)[0]
687
689
  # legacy migrated record found?
688
690
  _legacy_marks = self.xpath(f'//mets:note[contains(text(), "{MARK_AGENT_LEGACY}")]/text()')
689
691
  if len(_legacy_marks) == 1:
690
692
  _id = _legacy_marks[0]
691
693
  if ':' in _id:
692
- _legacy_ident = _id.rsplit(':',maxsplit=1)[1].strip()
693
- _legacy_ident = _legacy_ident[2:] if _legacy_ident.startswith('md') else _legacy_ident
694
+ _legacy_ident = _id.rsplit(':', maxsplit=1)[1].strip()
695
+ _legacy_ident = _legacy_ident[2:] if _legacy_ident.startswith(
696
+ 'md') else _legacy_ident
694
697
  _idents[_repo] = _legacy_ident
695
698
  else:
696
699
  _idents[_repo] = _id
@@ -699,11 +702,12 @@ class MetsReader(MetsProcessor):
699
702
  _id = _vls_marks[0][len(MARK_AGENT_VLID):].strip()
700
703
  _idents[_repo] = _id
701
704
  # legacy vls record which is not mapped by now?
702
- if _repo and ('digital' in _repo or 'menadoc' in _repo)and _repo not in _idents:
705
+ if _repo and ('digital' in _repo or 'menadoc' in _repo) and _repo not in _idents:
703
706
  _legacy_id = self.dmd_id[2:] if self.dmd_id.startswith('md') else self.dmd_id
704
707
  _idents[_repo] = _legacy_id
705
708
  # legacy kitodo2 source _without_ OAI envelope
706
- _creators = self.tree.xpath('//mets:agent[@OTHERTYPE="SOFTWARE" and @ROLE="CREATOR"]/mets:name', namespaces=XMLNS)
709
+ _creators = self.tree.xpath(
710
+ '//mets:agent[@OTHERTYPE="SOFTWARE" and @ROLE="CREATOR"]/mets:name', namespaces=XMLNS)
707
711
  if len(_creators) == 1 and 'kitodo-ugh' in _creators[0].text.lower():
708
712
  _idents[MARK_KITODO2] = None
709
713
  # kitodo3 metsDocumentID?
@@ -711,7 +715,8 @@ class MetsReader(MetsProcessor):
711
715
  if len(_doc_ids) == 1:
712
716
  _idents[MARK_KITODO3] = _doc_ids[0]
713
717
  # once migrated, now hosted at opendata
714
- _pres = self.tree.xpath('.//dv:presentation[contains(./text(), "://opendata")]/text()', namespaces=XMLNS)
718
+ _pres = self.tree.xpath(
719
+ './/dv:presentation[contains(./text(), "://opendata")]/text()', namespaces=XMLNS)
715
720
  if len(_pres) == 1 and 'simple-search' not in _pres[0]:
716
721
  _idents[_pres[0].split('/')[2]] = _pres[0]
717
722
  if self._report and len(self._report.system_identifiers) > 0:
@@ -735,11 +740,12 @@ class MetsReader(MetsProcessor):
735
740
  if _v in _transformed:
736
741
  raise RuntimeError(f"identifier category {_v} already in {_transformed}!")
737
742
  for k, v in _identifiers.items():
738
- _k = k.replace('/','.') if '/' in k else k
743
+ _k = k.replace('/', '.') if '/' in k else k
739
744
  if _opt.endswith('_'+_k):
740
745
  _transformed[_v] = v
741
746
  if len(_transformed) != len(_identifiers):
742
- raise RuntimeError(f"Identifier transformation missmatch: {_identifiers} != {_transformed}")
747
+ raise RuntimeError(
748
+ f"Identifier transformation missmatch: {_identifiers} != {_transformed}")
743
749
  return _transformed
744
750
 
745
751
  def get_language_information(self):
@@ -88,7 +88,7 @@ PATH_CLI = str(CLI_DIR / 'schxslt-cli.jar')
88
88
 
89
89
  # temporary report files
90
90
  REPORT_FILE_SCHEMATRON = 'report_schematron.xml'
91
- REPORT_FILE_XSLT = 'resport_xslt.xml'
91
+ REPORT_FILE_XSLT = 'report_xslt.xml'
92
92
 
93
93
  # which types require special treatment?
94
94
  # if these show up, switch validation logics
@@ -283,10 +283,7 @@ def _validate_and_store_result(path_mets, proc, path_template):
283
283
  _exec = xsltproc.compile_stylesheet(stylesheet_file=path_template)
284
284
  _doc_dir = os.path.dirname(path_mets)
285
285
  _path_tmp = os.path.join(_doc_dir, REPORT_FILE_XSLT)
286
- _doc_dir = os.path.dirname(path_mets)
287
- _path_tmp = os.path.join(_doc_dir, REPORT_FILE_XSLT)
288
286
  _exec.transform_to_file(source_file=path_mets,
289
- stylesheet_file=path_template,
290
287
  output_file=_path_tmp)
291
288
  except Exception as _exc:
292
289
  raise RuntimeError(_exc) from _exc
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: digiflow
3
- Version: 3.4.0
3
+ Version: 3.4.2
4
4
  Summary: Father's Little Digitization Workflow Helper
5
5
  Author-email: Universitäts- und Landesbibliothek Sachsen-Anhalt <development@bibliothek.uni-halle.de>
6
6
  Project-URL: Homepage, https://github.com/ulb-sachsen-anhalt/digital-flow
File without changes
File without changes
File without changes
File without changes