dquality.hdf

Please make sure the installation Pre-requisites are met.

This file contains verification functions related to the file structure. It reads configuration parameters “schema_type” and “schema” to determine first which kind of file verification is requested, and a schema that defines mandatory parameters. If any of the parameters is not configured, it is assumed no file structure verification is requested.

Functions:

init(config) This function initializes global variables.
report_items(list, text1, text2, logger) This function takes a list and strings.
verify(conf, file) This is the main function called when the structureverifier application starts.
structure(file, required_tags, logger) This method is used when a file of hdf type is given.
tags(file, required_tags, logger) This method is used when a file of hdf type is given.
dquality.hdf.init(config)[source]

This function initializes global variables. It gets values from the configuration file, evaluates and processes the values. If mandatory file or directory is missing, the script logs an error and exits.

Parameters:config (str) – configuration file name, including path
Returns:
  • logger (Logger) – logger instance
  • tags (dictionary) – a dictionary containing tag and attributes values read from the configured ‘schema’ file
dquality.hdf.report_items(list, text1, text2, logger)[source]

This function takes a list and strings. If the list is not empty it prints the two string parameters as a title, and prints formatted output for each item in a list.

Parameters:
  • list (list) – A list of items
  • text1 (str) – A title that will be printed if the list is not empty
  • text2 (str) – An optional part of title that will be printed if the list is not empty
  • logger (Logger) – a Logger instance
Returns:

None

dquality.hdf.verify(conf, file)[source]

This is the main function called when the structureverifier application starts. It reads the configuration file for “verification_type” to verify “hdf_structure” or “hdf_tags”.

Parameters:
  • conf (str) – configuration file name, including path
  • file (str) – File Name to verify including path
Returns:

boolean

dquality.hdf.tags(file, required_tags, logger)[source]

This method is used when a file of hdf type is given. All tags from the hdf file are added in the filetags list. Then the schema is evaluated for tags. With each tag discovered it checks whether there is matching tag in the filetags list. If a tag is missing, the function exits with False. Otherwise, it will return True.

Parameters:
  • file (str) – File Name including path
  • schema (str) – Schema file name
  • logger (Logger) – a Logger instance
Returns:

  • True if verified
  • False if not verified

dquality.hdf.structure(file, required_tags, logger)[source]

This method is used when a file of hdf type is given. All tags and array dimensions are verified against a schema. (see schemas/tags.json example file).

Parameters:
  • file (str) – File Name including path
  • schema (str) – Schema file name
  • logger (Logger) – a Logger instance
Returns:

None