dbprocessing.inspector

Support for inspectors, which determine product type for a given file.

To write an inspector, create a Python module (i.e. a .py file).

  • This file will need to import inspector and Version (since it must create a Version).

  • This file may import DBlogging to permit logging of its work.

  • This file must contain a single class

  • The class must be named Inspector and inherit from inspector.

  • The class must have a class member code_name with the name of the inspector file

  • The class must implement the inspect() method (see that documentation for details).

A inspector record must also then be created referencing the inspector file and with any necessary keywords.

See Also

Inspector examples

Functions

extract_Version(filename[, basename])

Go through the filename and pull out the first valid vX.Y.Z

extract_YYYYMM(filename)

Go through the filename and extract the first valid YYYYMM as a datetime

extract_YYYYMMDD(filename)

Go through the filename and extract the first valid YYYYMMDD as a datetime

valid_YYYYMMDD(inval)

Checks if input is valid YYYYMMDD

Classes

DefaultFields

Dict-like with defaults for the special fields used by DBformatter

DefaultFormatter()

Formatter that passes through any missing fields

inspector(filename, dbu, product, **kwargs)

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

dbprocessing.inspector.extract_Version(filename, basename=False)[source]

Go through the filename and pull out the first valid vX.Y.Z

Parameters
filenamestr

Filename to check for version

Returns
Version

First valid version found in filename. If basename, tuple of version (Version) and basename (str).

Other Parameters
basenamebool, default False

Include the basename after the version as well.

dbprocessing.inspector.extract_YYYYMM(filename)[source]

Go through the filename and extract the first valid YYYYMM as a datetime

Parameters
filenamestr

Filename to parse for a YYYYMMDD format

Returns
datetime

First day of first month found in filename, or None.

dbprocessing.inspector.extract_YYYYMMDD(filename)[source]

Go through the filename and extract the first valid YYYYMMDD as a datetime

Parameters
filenamestr

Filename to parse for a YYYYMMDD format

Returns
datetime

First date found in filename, or None.

dbprocessing.inspector.valid_YYYYMMDD(inval)[source]

Checks if input is valid YYYYMMDD

Parameters
invalstr

String to evaluate as possible YYYYMMDD

Returns
bool

True if valid YYYYMMDD.


Release: 0.1.0 Doc generation date: Feb 10, 2022