bilby_pipe.bilbyargparser
argument parser for bilby_pipe, adapted from configargparse.ArgParser.
Classes
str(object='') -> str |
|
The main entry point for command-line parsing |
|
Based on a simplified subset of INI and YAML formats. Here is the |
Module Contents
- class bilby_pipe.bilbyargparser.HyphenStr[source]
Bases:
str
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- class bilby_pipe.bilbyargparser.BilbyArgParser(*args, **kwargs)[source]
Bases:
configargparse.ArgParser
The main entry point for command-line parsing
- parse_known_args(args=None, namespace=None, config_file_contents=None, env_vars=os.environ, **kwargs)[source]
Supports all the same args as the ArgumentParser.parse_args(..), as well as the following additional args.
- Parameters:
- args: None, str, List[str]
List of strings to parse. The default is taken from sys.argv Can also be a string “-x -y bla”
- namespace: argparse.Namespace
The Namespace object that will be returned by parse_args().
- config_file_contents: None
Present because inherited from abstract method. The config_file_contents are read from the config_file passed in the args.
- env_vars: dict
Dictionary of environment variables
- Returns:
- namespace: argparse.Namespace
An object to take the attributes parsed.
- unknown_args: List[str]
List of the args unrecognised by the parser
- _preprocess_config_file_contents(args)[source]
Reads config file into string and formats it for ArgParser
- Parameters:
- args: None, list, str
The input args to be parsed. Creates config_file_content only if one of the args is a config_file
- Returns:
- file_contents: str
The content of the config files, correctly formatted
- file_contents: None
If no config file specified
- _preprocess_args(args)[source]
Processes args into correct format for ArgParser
- Parameters:
- args: None, list, str
The input args to be parsed.
- Returns:
- normalized_args: List[string]
args list normalised to “–key value”
- write_to_file(filename, args=None, overwrite=False, include_description=False, exclude_default=False, comment=None)[source]
- class bilby_pipe.bilbyargparser.BilbyConfigFileParser[source]
Bases:
configargparse.DefaultConfigFileParser
Based on a simplified subset of INI and YAML formats. Here is the supported syntax
# this is a comment ; this is also a comment (.ini style) --- # lines that start with --- are ignored (yaml style) ------------------- [section] # .ini-style section names are treated as comments # how to specify a key-value pair (all of these are equivalent): name value # key is case sensitive: "Name" isn't "name" name = value # (.ini style) (white space is ignored, so name = value same as name=value) name: value # (yaml style) --name value # (argparse style) # how to set a flag arg (eg. arg which has action="store_true") --name name name = True # "True" and "true" are the same # how to specify a list arg (eg. arg which has action="append") fruit = [apple, orange, lemon] indexes = [1, 12, 35 , 40]