dbprocessing.inspector.inspector

class dbprocessing.inspector.inspector(filename, dbu, product, **kwargs)[source]

ABC for inspectors to be sure the user has implemented what is required

Provides utility routines common to many inspectors

__init__(filename, dbu, product, **kwargs)[source]
Parameters
filenamestr

Path to file to inspect.

dbuDButils

Open database connection.

productint

Product ID; verify if passed-in file is instance of this product.

kwargsdict

Keyword arguments passed through to inspect() (as a dict).

Methods

extract_YYYYMMDD()

go through the filename, extract first valid YYYYMMDD as a datetime

inspect(filename, kwargs)

Override this method to implement an inspector

Attributes

extract_YYYYMMDD()[source]

go through the filename, extract first valid YYYYMMDD as a datetime

Returns
datetime

First date found in filename, or None.

abstract inspect(filename, kwargs)[source]

Override this method to implement an inspector

If the input file is not a match for this product, nothing else should be updated.

If the input file is a match for the product, must update params dict of diskfile with the following keys, which map directly to columns of the file table in the database:

utc_file_date (date)

Characteristic date of the file. (utc_file_date)

utc_start time (datetime)

Timestamp of first record in the file. (utc_start_time)

utc_stop time (datetime)

Timestamp of last record in the file. (utc_stop_time)

version (Version)

Version of the file. (interface_version, quality_version, revision_version)

The following keys may be updated, but are optional:

check_date (datetime)

check_date

verbose_provenance (str)

verbose_provenance

quality_comment (str)

quality_comment

caveats (str)

caveats

met_start_time (int)

met_start_time

met_stop_time (int)

met_stop_time

quality_checked (bool)

quality_checked

process_keywords (str)

process_keywords

The inspector may use the non-private instance attributes of this class, including access to the database (although this should be done with care, as the inspector is called during active phases of processing). It is also expected that the inspector will open the file for reading; writing to the data file is highly discouraged at this point.

Parameters
filenamestr

Not used; use filename attribute instead.

kwargsdict

Keyword arguments provided in inspector.arguments.

Returns
any

None if the file passed in is not a match for the product, and anything else if it is.

code_name = None

Override this in child class, with the name of the inspector file (str)

dbu

Open database. (DButils)

filename

Full path to the file being inspected. (str)

basename

Filename (only, no directory) of the file being inspected. (str)

dirname

Full path to the directory containing the file. (str)

product

Product ID for which this inspector is being called. (int)

filenameformat

Format to match the filename. (str)

filenameregex

Regular expression that will match a valid filename, derived from filenameformat. (str)

diskfile

File metadata to populate. (Diskfile.Diskfile)


Release: 0.1.0 Doc generation date: Feb 10, 2022