ATLAS Offline Software
Loading...
Searching...
No Matches
python.acmdlib Namespace Reference

Classes

class  Command
 classes ----------------------------------------------------------------— More...
class  Plugins

Functions

 command (*args, **kwargs)
 argument (*args, **kwargs)
 register (name, value)

Variables

str __doc__ = "a library to ease the writing of sub-command scripts"
str __author__ = "Sebastien Binet"
list __all__
str ACMD_GROUPNAME = 'acmdlib.commands'
 globals ----------------------------------------------------------------—
 ACMD_PARSER
 ACMD_SUBPARSERS

Function Documentation

◆ argument()

python.acmdlib.argument ( * args,
** kwargs )
Decorator to add an argument to a command.
Use the `mutual=True` keyword to specify that the argument should belong to a mutual exclusion group.

Definition at line 179 of file acmdlib.py.

179def argument(*args, **kwargs):
180 """Decorator to add an argument to a command.
181 Use the `mutual=True` keyword to specify that the argument should belong to a mutual exclusion group.
182 """
183 is_mutual = kwargs.pop('mutual', False)
184
185 def deco(fct):
186 if isinstance(fct, Command):
187 cmd = fct
188 if is_mutual:
189 if not hasattr(cmd, '_acmdlib_mutual_group'):
190 cmd._acmdlib_mutual_group = cmd.add_mutually_exclusive_group()
191 cmd._acmdlib_mutual_group.add_argument(*args, **kwargs)
192 else:
193 cmd.add_argument(*args, **kwargs)
194 else:
195 store_as = '_acmdlib_arguments_mutual' if is_mutual else '_acmdlib_arguments'
196 if not hasattr(fct, store_as):
197 setattr(fct, store_as, [])
198 getattr(fct, store_as).append((args, kwargs))
199 #print "===",args,kwargs,type(fct),fct
200 return fct
201 return deco
202

◆ command()

python.acmdlib.command ( * args,
** kwargs )
Decorator to declare that a function is a command.

Definition at line 170 of file acmdlib.py.

170def command(*args, **kwargs):
171 """Decorator to declare that a function is a command.
172 """
173 def deco(fct):
174 return Command(fct, **kwargs)
175 if args:
176 return deco(*args)
177 return deco
178

◆ register()

python.acmdlib.register ( name,
value )
Registers a plugin, given a name and value.

ex: register('check-file', 'PyUtils.CheckFileLib:fct')

Definition at line 203 of file acmdlib.py.

203def register(name, value):
204 """Registers a plugin, given a name and value.
205
206 ex: register('check-file', 'PyUtils.CheckFileLib:fct')
207 """
208
209 return Plugins.register(name, value)
#define register
Definition dictionary.h:21

Variable Documentation

◆ __all__

list python.acmdlib.__all__
private
Initial value:
1= [
2 'Command',
3 'command',
4 'argument',
5 'register',
6 ]

Definition at line 11 of file acmdlib.py.

◆ __author__

str python.acmdlib.__author__ = "Sebastien Binet"
private

Definition at line 9 of file acmdlib.py.

◆ __doc__

str python.acmdlib.__doc__ = "a library to ease the writing of sub-command scripts"
private

Definition at line 8 of file acmdlib.py.

◆ ACMD_GROUPNAME

str python.acmdlib.ACMD_GROUPNAME = 'acmdlib.commands'

globals ----------------------------------------------------------------—

Definition at line 24 of file acmdlib.py.

◆ ACMD_PARSER

python.acmdlib.ACMD_PARSER
Initial value:
1= argparse.ArgumentParser(
2 prog="acmd",
3 description="a general script interface with sub-commands",
4 )

Definition at line 28 of file acmdlib.py.

◆ ACMD_SUBPARSERS

python.acmdlib.ACMD_SUBPARSERS
Initial value:
1= ACMD_PARSER.add_subparsers(
2 dest='command',
3 title='commands',
4 metavar='COMMAND',
5 )

Definition at line 33 of file acmdlib.py.