|
def | __init__ (self, jo_name=None, prog=None, print_caller_help=True, **kwargs) |
|
def | add_argument (self, *args, **kwargs) |
|
def | parse_args (self, args=None, namespace=None) |
|
def | parse_known_args (self, args=None, namespace=None) |
|
def | format_help (self) |
|
Parse user commandline arguments in a job option.
Definition at line 31 of file AthArgumentParser.py.
◆ __init__()
def python.AthArgumentParser.AthArgumentParser.__init__ |
( |
|
self, |
|
|
|
jo_name = None , |
|
|
|
prog = None , |
|
|
|
print_caller_help = True , |
|
|
** |
kwargs |
|
) |
| |
Create the parser
---------
Arguments
---------
jo_name:
The name of the calling job option, used to format the help
text. Will attempt to deduce it if possible
prog:
The start of the usage message, usually can be deduced
print_caller_help:
Whether or not to print the help text from the calling program
(usually athena)
All other keyword arguments are forwarded to the base class
constructor
Definition at line 34 of file AthArgumentParser.py.
34 def __init__(self, jo_name=None, prog=None, print_caller_help=True, **kwargs):
40 The name of the calling job option, used to format the help
41 text. Will attempt to deduce it if possible
43 The start of the usage message, usually can be deduced
45 Whether or not to print the help text from the calling program
48 All other keyword arguments are forwarded to the base class
58 for frame
in inspect.stack():
61 fname = inspect.getfile(frame[0])
64 script
for script
in opts.scripts
if fname.endswith(script)
71 jo_name =
"User job option"
72 prog =
"{0} {1} [{0} options] -".
format(os.path.basename(caller), jo_name)
75 caller_help, _ = Popen(
76 [caller,
"--help"], stdout=PIPE, stderr=PIPE
79 caller_help = caller_help.decode(
"utf-8")
80 if caller.endswith(
"athena.py"):
83 caller_help = caller_help.split(
"\n", 3)[3]
84 self.caller_help =
"{} options:\n{}".
format(
85 os.path.basename(caller), caller_help
89 super().
__init__(prog=prog, **kwargs)
93 help=
"Any remaining scripts to be run by athena after this job option. Mainly used to run the 'post' script on the grid.",
◆ add_argument()
def python.AthArgumentParser.AthArgumentParser.add_argument |
( |
|
self, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
Add a new argument
The difference between this and the base class is that it disallows
adding positional arguments which are reserved by athena for job
options. In particular, even if user code uses only one job option
(which is common) pathena will add more when running on the grid
Definition at line 96 of file AthArgumentParser.py.
96 def add_argument(self, *args, **kwargs):
97 """ Add a new argument
99 The difference between this and the base class is that it disallows
100 adding positional arguments which are reserved by athena for job
101 options. In particular, even if user code uses only one job option
102 (which is common) pathena will add more when running on the grid
104 if not args
or len(args)
and args[0][0]
not in self.prefix_chars:
106 "Positional arguments are not allowed! Defining them could mess up grid running!"
108 return super().add_argument(*args, **kwargs)
◆ format_help()
def python.AthArgumentParser.AthArgumentParser.format_help |
( |
|
self | ) |
|
Definition at line 126 of file AthArgumentParser.py.
126 def format_help(self):
127 text = super().format_help()
128 return "\n".
join([text, self.caller_help])
◆ parse_args()
def python.AthArgumentParser.AthArgumentParser.parse_args |
( |
|
self, |
|
|
|
args = None , |
|
|
|
namespace = None |
|
) |
| |
Override the base class to use the leftover athena argumnets by
default
Definition at line 110 of file AthArgumentParser.py.
110 def parse_args(self, args=None, namespace=None):
111 """ Override the base class to use the leftover athena argumnets by
115 args = opts.user_opts
◆ parse_known_args()
def python.AthArgumentParser.AthArgumentParser.parse_known_args |
( |
|
self, |
|
|
|
args = None , |
|
|
|
namespace = None |
|
) |
| |
Override the base class to use the leftover athena argumnets by
default
Definition at line 118 of file AthArgumentParser.py.
118 def parse_known_args(self, args=None, namespace=None):
119 """ Override the base class to use the leftover athena argumnets by
123 args = opts.user_opts
124 return super().parse_known_args(args, namespace)
◆ caller_help
python.AthArgumentParser.AthArgumentParser.caller_help |
The documentation for this class was generated from the following file: