The context Module
Utilities to create context and configuration objects
- class Cardinality(value)[source]
Cardinality of a configuration parameter: multiple or singular
- single = 'single'
- multiple = 'multiple'
- class Argument(name, help: str, type=<class 'str'>, aliases: ~typing.Optional[~typing.List] = None, default=None, cardinality: ~nsaph_utils.utils.context.Cardinality = Cardinality.single, valid_values=None, required=True)[source]
A wrapper class to describe a command-line arguments This is practically, a more rigid format for :func ArgumentParser.add_argument:
All arguments are passed to Argparser
- class Context(subclass, description=None, include_default: bool = True)[source]
Generic class allowing to build context and configuration objects and initialize them using command line arguments
Creates a new object
- Parameters
subclass¶ – A concrete class containing configuration information Configuration options must be defined as class memebers with names, starting with one ‘_’ characters and values be instances of :class Argument:
description¶ – Optional text to use as description. If not specified, then it is extracted from subclass documentation
- years
Year or list of years to download. For example, the following argument: -y 1992:1995 1998 1999 2011 2015:2017 will produce the following list: [1992,1993,1994,1995,1998,1999,2011,2015,2016,2017]
- compress
Specifies whether to use gzip compression for the result