openbases.main.validate package

Submodules

openbases.main.validate.helpers module

openbases.main.validate.helpers.load_criteria(self, criteria=None)[source]

load a criteria.yml file. If not specified, load (or reload) default provided by package.

criteria: a yml specification for criteria. If not provided, use
default at criteria/specification.yml. If you need help creating

a new criteria (that might be added to defaults) please open an issue

openbases.main.validate.helpers.update_environment(params=None, prefix='OPENBASESENV_')[source]

update environment will put any environment variables found in the params (dictionary) into the environment, expected to be found by the various functions. The variables must start with OPENBASESENV_

openbases.main.validate.helpers.validate_criteria(self, criteria=None, infile=None, params=None)[source]

validate an infile (or already loaded one) against criteria.

infile: an input specification file criteria: a loaded (json/dict) or criteria, or html/yml file

openbases.main.validate.helpers.validate_loads(infile)[source]

determine if a file can load without error. If yes, return manager. If not, return None.

infile: the input file to attempt loading with the YamlManager, can be yaml or front end matter in html.

Module contents

class openbases.main.validate.BasicValidator(infile)[source]

Bases: object

the basic validator doesn’t care about the input file extensions, and gives the user more freedom to write custom validators using it. We only validate that the file exists.

default_criteria = '/home/vanessa/Documents/Dropbox/Code/openbases/openbases-python/openbases/main/validate/criteria/dummy.yml'
load(infile)[source]

load an input file, meaning checking for the file’s existence. It’s up to the user (if desired) to load the file in their validation functions, or write a custom _load() function.

infile: the input file to load

load_criteria(criteria=None)

load a criteria.yml file. If not specified, load (or reload) default provided by package.

criteria: a yml specification for criteria. If not provided, use
default at criteria/specification.yml. If you need help creating

a new criteria (that might be added to defaults) please open an issue

params = {}
validate_criteria(criteria=None, infile=None, params=None)

validate an infile (or already loaded one) against criteria.

infile: an input specification file criteria: a loaded (json/dict) or criteria, or html/yml file

validate_exists(infile)[source]

determine filename of infile, validate that exists.

infile: the name of the specification / yaml file extensions: a list of valid extensions

class openbases.main.validate.PaperValidator(infile, bibfile=None)[source]

Bases: object

the spec validator can “sniff” a file based on extension, and validate the file based on the extension, or have one of the specific type validators (html, yaml) called directly. There are two steps.

Step 0. validates the file itself. Does it exist? Load without error? Step 1. validates the file against a criteria.yml, default is provided

default_criteria = '/home/vanessa/Documents/Dropbox/Code/openbases/openbases-python/openbases/main/validate/criteria/paper.yml'
folder = None
load(infile)[source]

load an input file, meaning checking for the file’s existence, that it has a default extension, and loading it into the “spec” via the YamlManager (that can handle frontmatter in a html or standard yml/yaml

infile: the input file to load

load_bib(bibfile, envar='OPENBASESENV_BIBFILE')[source]

load the bibfile, and derive from the paper file if it was loaded first. This means checking for the file’s existence, that it has a default extension, and loading it into the “spec”

infile: the input file to load

load_criteria(criteria=None)

load a criteria.yml file. If not specified, load (or reload) default provided by package.

criteria: a yml specification for criteria. If not provided, use
default at criteria/specification.yml. If you need help creating

a new criteria (that might be added to defaults) please open an issue

name = None
params = {}
validate_criteria(criteria=None, infile=None, params=None)

validate an infile (or already loaded one) against criteria.

infile: an input specification file criteria: a loaded (json/dict) or criteria, or html/yml file

validate_exists(infile, extensions=None)[source]

determine filename of infile based on Specification Name (and extension). If the extension doesn’t end in yml/yaml or html, it’s not valid (and note we will need to add support for reading json). If valid, return the filename. If not, return None.

infile: the name of the specification / yaml file extensions: a list of valid extensions