schrodinger.application.desmond.starter.ui.cmdline module¶
Common command line arguments Lightweight framework for defining new command line arguments.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.desmond.starter.ui.cmdline.
Option
(name, default, help, dest)[source]¶ Bases:
tuple
-
name
: Union[str, List]¶ Alias for field number 0
-
default
: object¶ Alias for field number 1
-
help
: str¶ Alias for field number 2
-
dest
: Dict¶ Alias for field number 3
-
__contains__
(key, /)¶ Return key in self.
-
__len__
()¶ Return len(self).
-
count
(value, /)¶ Return number of occurrences of value.
-
index
(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
-
schrodinger.application.desmond.starter.ui.cmdline.
define_options
(parser: argparse.ArgumentParser, options: List[schrodinger.application.desmond.starter.ui.cmdline.Option])[source]¶ Define the options on a specified parser.
- Parameters
parser – Add options to this parser.
options – List of options in the format (name, default, help, dest).
-
schrodinger.application.desmond.starter.ui.cmdline.
get_common_options
() → List[schrodinger.application.desmond.starter.ui.cmdline.Option][source]¶ Return list of options common to all fep scripts.
-
schrodinger.application.desmond.starter.ui.cmdline.
suppress_options
(options: List[schrodinger.application.desmond.starter.ui.cmdline.Option], excluded: Set[str])[source]¶ Modify the options as specified by
excluded
by replacing the help text withargparse.SUPPRESS
, which will effectively hide the specified options in the command line. No effects if eitheroptions
orexcluded
is an empty container.
-
schrodinger.application.desmond.starter.ui.cmdline.
get_parser
(usage: str, options: List[schrodinger.application.desmond.starter.ui.cmdline.Option], add_help: bool = True, add_subhost: bool = True) → argparse.ArgumentParser[source]¶ Return a command-line parser with the given options.
- Parameters
usage – Usage to display if no arguments given.
options – List of options
add_help – Whether to add help flag to the parser
- Returns
Configured command-line parser
-
schrodinger.application.desmond.starter.ui.cmdline.
parse_known_options
(usage: str, options: List[schrodinger.application.desmond.starter.ui.cmdline.Option], argv: List[str], add_subhost: bool = True) → Tuple[argparse.Namespace, Optional[str]][source]¶ Parse and return the parsed options.
- Parameters
usage – Usage to display if no arguments given.
options – List of options in the format (name, default, help, destination).
argv – List of input arguments.
- Returns
(Known parsed options, unknown options)
- Raises
SystemExit – If no arguments given, show the usage and exit.
-
schrodinger.application.desmond.starter.ui.cmdline.
parse_options
(usage: str, options: List[schrodinger.application.desmond.starter.ui.cmdline.Option], argv: List[str], add_subhost: bool = True) → Tuple[argparse.Namespace, Optional[str]][source]¶ Parse and return the parsed options.
- Parameters
usage – Usage to display if no arguments given.
options – List of options in the format (name, default, help, dest).
argv – List of input arguments
add_subhost – Add the -SUBHOST option?
- Returns
Parsed options
- Raises
SystemExit – If no arguments given or if there is unknown arguments, show the usage and exit.
-
schrodinger.application.desmond.starter.ui.cmdline.
check_jobname
(jobname: str) → Optional[str][source]¶ Check whether the given job name contains problematic characters. It cannot start with a “-” or contain a “=”.
-
class
schrodinger.application.desmond.starter.ui.cmdline.
BaseArgs
(opt: argparse.Namespace)[source]¶ Bases:
object
Base class for arguments. A subclass of this class contains all the command-line arguments. The jobcontrol-related arguments, which are consumed by the toplevel script, are recovered.
-
__init__
(opt: argparse.Namespace)[source]¶ - Parameters
opt – Command line options with corresponding values.
-
copy_parser_attributes
(opt: argparse.ArgumentParser)[source]¶ Copy parser options (e.g: time, buffer, …) from
opt
toself
. Subclass needs to call this method in __init__
-
check_ppj
()[source]¶ Raise a warning if restarting and trying to set ppj.
- Raises
UserWarning – If ppj set for a restarted job.
-