Loaders

Without the --loader command line option, shef.shef_parser simply outputs the parsed text in one of the formats described on the User Guide for Package shef-parser 1.10.0 page. With the --loader command line option, the format is:

--loader <loader_name><loader_options>

where:

  • <loader_name> is the name of the loader module without the _loader portion (e.g., abc for the module abc_loader)

  • <loader_options> is zero or more loader options, each in square brackets (e.g., [opt1][opt2])

An example would be run_shef_parser --loader abc[opt1][opt2]

Workflow Using a Loader

When using a loader, the following happens instead:

  1. The parser constructs a new loader object based on the loader name passed on the command line, passing 3 arguments:

    • the parser’s logger

    • the parser’s output object (used if unloading)

    • whether to append to the output object (used if unloading)

  2. The parser calls the loader’s set_options(...) method, passing the loader options specified on the command line

  3. If --unload is specified on the command line

    1. The parser calls the loader’s unload() method and exits

    If --unload is not specified on the command line

    1. For each SHEF value [1], the parser calls the loader’s set_shef_value(value_str: str) method [2], which then:

    • Uses the loader’s time_series_name property to compare the loader-specific time seies identifier of the SHEF value with that of the previous SHEF value (if any).

    • If there was a previous SHEF value and the time series identifier is different, calls the loader’s load_time_series() method. [3]

    • Appends the SHEF value into the loader’s _time_series variable

    1. Calls the loader’s done() method and exits. [4]