pyslk.hsm2json

Contents

pyslk.hsm2json#

pyslk.hsm2json(resources: str | Path | list | None = None, search_id: int = -1, recursive: bool = False, outfile: str | Path | None = None, restart_file: str | Path | None = None, schema: str | list | None = None, write_json_lines: bool = False, write_mode: str | None = None, instant_metadata_record_output: bool = False, print_hidden: bool = False) dict[str, Union[dict, list, NoneType]]#

Extract metadata from HSM file(s) and return them in JSON structure

Parameters:
  • resources (str or Path or list) – list of resources to be searched for

  • search_id (int) – id of a search

  • recursive (bool) – export metadata from all files in gns_path recursively

  • outfile (str or Path or None) – Write the output into a file instead to the stdout

  • restart_file (str or Path or None) – set a restart file in which the processed metadata entries are listed

  • schema (str or list or None) – import only metadata fields of listed schemata; if str: comma-separated list without spaces

  • write_json_lines (bool = False) – write JSON-lines instead of JSON

  • write_mode (str = None) – applies when ‘output’ is set; possible values: OVERWRITE, ERROR

  • instant_metadata_record_output (bool) – False (default): read metadata of all files and write/print out afterward; True: write/print each metadata record after it has been read (requires ‘write_json_lines’)

  • print_hidden (bool) – print read-only not-searchable metadata fields (sidecar file) [default: False]

Returns:

dictionary with keys ‘header’ (summary report), ‘metadata’ (actual metadata) and ‘file’ (JSON file); either ‘metadata’ or ‘file’ is none depending on the value of input argument ‘outfile’

Return type:

dict