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
orPath
orlist
) – list of resources to be searched forsearch_id (
int
) – id of a searchrecursive (
bool
) – export metadata from all files in gns_path recursivelyoutfile (
str
orPath
orNone
) – Write the output into a file instead to the stdoutrestart_file (
str
orPath
orNone
) – set a restart file in which the processed metadata entries are listedschema (
str
orlist
orNone
) – import only metadata fields of listed schemata; if str: comma-separated list without spaceswrite_json_lines (
bool
= False) – write JSON-lines instead of JSONwrite_mode (
str
= None) – applies when ‘output’ is set; possible values: OVERWRITE, ERRORinstant_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