pyTooling.Attributes.ArgParse
Submodules
Exceptions
- ArgParseException: The exception is raised by pyTooling internal features.
Classes
- ArgParseAttribute: Base-class for all attributes to describe a- argparse-base command line argument parser.
- _HandlerMixin: A mixin-class that offers a class field for a reference to a handler method and a matching property.
- CommandLineArgument: Base-class for all Argument classes.
- CommandGroupAttribute: Experimental attribute to group sub-commands in groups for better readability in a- prog.py --helpcall.
- DefaultHandler: Marks a handler method as default handler. This method is called if no sub-command is given.
- CommandHandler: Marks a handler method as responsible for the given ‘command’. This constructs
- ArgParseHelperMixin: Mixin-class to implement an- argparse-base command line argument processor.
Exceptions
- exception pyTooling.Attributes.ArgParse.ArgParseException[source]
- Inheritance - classmethod __new__(*args, **kwargs)
 - __init__(*args, **kwargs)
 
Classes
- class pyTooling.Attributes.ArgParse.ArgParseAttribute[source]
- Base-class for all attributes to describe a - argparse-base command line argument parser.- Inheritance - classmethod GetAttributes(method, includeSubClasses=True)
- Returns attached attributes of this kind for a given method. 
 - classmethod GetClasses(scope=None, subclassOf=None)
- Return a generator for all classes, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
- subclassOf- when the item is a subclass of- subclassOf.
 
 - Parameters:
- scope ( - Union[- Type,- ModuleType,- None]) – Undocumented.
- subclassOf ( - Optional[- Type]) – An attribute class or tuple thereof, to filter for that attribute type or subtype.
 
- Return type:
- Returns:
- A sequence of classes where this attribute is attached to. 
 
 - classmethod GetFunctions(scope=None)
- Return a generator for all functions, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - classmethod GetMethods(scope=None)
- Return a generator for all methods, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - static _AppendAttribute(entity, attribute)
- Append an attribute to a language entity (class, method, function). - Hint - This method can be used in attribute groups to apply multiple attributes within - __call__method.- class GroupAttribute(Attribute): def __call__(self, entity: Entity) -> Entity: self._AppendAttribute(entity, SimpleAttribute(...)) self._AppendAttribute(entity, SimpleAttribute(...)) return entity 
 - __call__(entity)
- Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups. 
 - _classes: ClassVar[List[Any]] = []
- List of classes, this Attribute was attached to. 
 - _functions: ClassVar[List[Any]] = []
- List of functions, this Attribute was attached to. 
 - _methods: ClassVar[List[Any]] = []
- List of methods, this Attribute was attached to. 
 - _scope: ClassVar[AttributeScope] = 7
- Allowed language construct this attribute can be used with. 
 
- class pyTooling.Attributes.ArgParse._HandlerMixin[source]
- A mixin-class that offers a class field for a reference to a handler method and a matching property. - Inheritance 
- class pyTooling.Attributes.ArgParse.CommandLineArgument[source]
- Base-class for all Argument classes. - An argument instance can be converted via - AsArgumentto a single string value or a sequence of string values (tuple) usable e.g. with- subprocess.Popen. Each argument class implements at least one- patternparameter to specify how argument are formatted.- There are multiple derived formats supporting: - commands 
 →- Command
- simple names (flags) 
 →- Flag,- BooleanFlag
- simple values (vlaued flags) 
 →- StringArgument,- PathArgument
- names and values 
 →- ValuedFlag,- OptionalValuedFlag
- key-value pairs 
 →- NamedKeyValuePair
 - Inheritance - __init__(*args, **kwargs)[source]
- The constructor expects positional ( - *args) and/or named parameters (- **kwargs) which are passed without modification to- add_argument().
 - property Args: Tuple
- A tuple of additional positional parameters ( - *args) passed to the attribute. These additional parameters are passed without modification to- ArgumentParser.
 - property KWArgs: Dict
- A dictionary of additional named parameters ( - **kwargs) passed to the attribute. These additional parameters are passed without modification to- ArgumentParser.
 - classmethod GetAttributes(method, includeSubClasses=True)
- Returns attached attributes of this kind for a given method. 
 - classmethod GetClasses(scope=None, subclassOf=None)
- Return a generator for all classes, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
- subclassOf- when the item is a subclass of- subclassOf.
 
 - Parameters:
- scope ( - Union[- Type,- ModuleType,- None]) – Undocumented.
- subclassOf ( - Optional[- Type]) – An attribute class or tuple thereof, to filter for that attribute type or subtype.
 
- Return type:
- Returns:
- A sequence of classes where this attribute is attached to. 
 
 - classmethod GetFunctions(scope=None)
- Return a generator for all functions, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - classmethod GetMethods(scope=None)
- Return a generator for all methods, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - static _AppendAttribute(entity, attribute)
- Append an attribute to a language entity (class, method, function). - Hint - This method can be used in attribute groups to apply multiple attributes within - __call__method.- class GroupAttribute(Attribute): def __call__(self, entity: Entity) -> Entity: self._AppendAttribute(entity, SimpleAttribute(...)) self._AppendAttribute(entity, SimpleAttribute(...)) return entity 
 - __call__(entity)
- Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups. 
 - _classes: ClassVar[List[Any]] = []
- List of classes, this Attribute was attached to. 
 - _functions: ClassVar[List[Any]] = []
- List of functions, this Attribute was attached to. 
 - _methods: ClassVar[List[Any]] = []
- List of methods, this Attribute was attached to. 
 - _scope: ClassVar[AttributeScope] = 7
- Allowed language construct this attribute can be used with. 
 - _handler: Callable
- Reference to a method that is called to handle e.g. a sub-command. 
 
- class pyTooling.Attributes.ArgParse.CommandGroupAttribute[source]
- Experimental attribute to group sub-commands in groups for better readability in a - prog.py --helpcall.- Inheritance - __init__(groupName)[source]
- The constructor expects a ‘groupName’ which can be used to group sub-commands for better readability. - Parameters:
- groupName (str) 
- Return type:
- None 
 
 - classmethod GetAttributes(method, includeSubClasses=True)
- Returns attached attributes of this kind for a given method. 
 - classmethod GetClasses(scope=None, subclassOf=None)
- Return a generator for all classes, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
- subclassOf- when the item is a subclass of- subclassOf.
 
 - Parameters:
- scope ( - Union[- Type,- ModuleType,- None]) – Undocumented.
- subclassOf ( - Optional[- Type]) – An attribute class or tuple thereof, to filter for that attribute type or subtype.
 
- Return type:
- Returns:
- A sequence of classes where this attribute is attached to. 
 
 - classmethod GetFunctions(scope=None)
- Return a generator for all functions, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - classmethod GetMethods(scope=None)
- Return a generator for all methods, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - static _AppendAttribute(entity, attribute)
- Append an attribute to a language entity (class, method, function). - Hint - This method can be used in attribute groups to apply multiple attributes within - __call__method.- class GroupAttribute(Attribute): def __call__(self, entity: Entity) -> Entity: self._AppendAttribute(entity, SimpleAttribute(...)) self._AppendAttribute(entity, SimpleAttribute(...)) return entity 
 - __call__(entity)
- Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups. 
 - _classes: ClassVar[List[Any]] = []
- List of classes, this Attribute was attached to. 
 - _functions: ClassVar[List[Any]] = []
- List of functions, this Attribute was attached to. 
 - _methods: ClassVar[List[Any]] = []
- List of methods, this Attribute was attached to. 
 - _scope: ClassVar[AttributeScope] = 7
- Allowed language construct this attribute can be used with. 
 
- class pyTooling.Attributes.ArgParse.DefaultHandler[source]
- Marks a handler method as default handler. This method is called if no sub-command is given. - It’s an error, if more than one method is annotated with this attribute. - Inheritance - __call__(func)[source]
- Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups. 
 - classmethod GetAttributes(method, includeSubClasses=True)
- Returns attached attributes of this kind for a given method. 
 - classmethod GetClasses(scope=None, subclassOf=None)
- Return a generator for all classes, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
- subclassOf- when the item is a subclass of- subclassOf.
 
 - Parameters:
- scope ( - Union[- Type,- ModuleType,- None]) – Undocumented.
- subclassOf ( - Optional[- Type]) – An attribute class or tuple thereof, to filter for that attribute type or subtype.
 
- Return type:
- Returns:
- A sequence of classes where this attribute is attached to. 
 
 - classmethod GetFunctions(scope=None)
- Return a generator for all functions, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - classmethod GetMethods(scope=None)
- Return a generator for all methods, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - static _AppendAttribute(entity, attribute)
- Append an attribute to a language entity (class, method, function). - Hint - This method can be used in attribute groups to apply multiple attributes within - __call__method.- class GroupAttribute(Attribute): def __call__(self, entity: Entity) -> Entity: self._AppendAttribute(entity, SimpleAttribute(...)) self._AppendAttribute(entity, SimpleAttribute(...)) return entity 
 - _classes: ClassVar[List[Any]] = []
- List of classes, this Attribute was attached to. 
 - _functions: ClassVar[List[Any]] = []
- List of functions, this Attribute was attached to. 
 - _methods: ClassVar[List[Any]] = []
- List of methods, this Attribute was attached to. 
 - _scope: ClassVar[AttributeScope] = 7
- Allowed language construct this attribute can be used with. 
 - _handler: Callable
- Reference to a method that is called to handle e.g. a sub-command. 
 
- class pyTooling.Attributes.ArgParse.CommandHandler[source]
- Marks a handler method as responsible for the given ‘command’. This constructs a sub-command parser using - add_subparsers().- Inheritance - __init__(command, help='', **kwargs)[source]
- The constructor expects a ‘command’ and an optional list of named parameters (keyword arguments) which are passed without modification to - add_subparsers().
 - __call__(func)[source]
- Attributes get attached to an entity (function, class, method) and an index is updated at the attribute for reverse lookups. 
 - property Args: Tuple
- A tuple of additional positional parameters ( - *args) passed to the attribute. These additional parameters are passed without modification to- ArgumentParser.
 - property KWArgs: Dict
- A dictionary of additional named parameters ( - **kwargs) passed to the attribute. These additional parameters are passed without modification to- ArgumentParser.
 - classmethod GetAttributes(method, includeSubClasses=True)
- Returns attached attributes of this kind for a given method. 
 - classmethod GetClasses(scope=None, subclassOf=None)
- Return a generator for all classes, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
- subclassOf- when the item is a subclass of- subclassOf.
 
 - Parameters:
- scope ( - Union[- Type,- ModuleType,- None]) – Undocumented.
- subclassOf ( - Optional[- Type]) – An attribute class or tuple thereof, to filter for that attribute type or subtype.
 
- Return type:
- Returns:
- A sequence of classes where this attribute is attached to. 
 
 - classmethod GetFunctions(scope=None)
- Return a generator for all functions, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - classmethod GetMethods(scope=None)
- Return a generator for all methods, where this attribute is attached to. - The resulting item stream can be filtered by:
- scope- when the item is a nested class in scope- scope.
 
 
 - static _AppendAttribute(entity, attribute)
- Append an attribute to a language entity (class, method, function). - Hint - This method can be used in attribute groups to apply multiple attributes within - __call__method.- class GroupAttribute(Attribute): def __call__(self, entity: Entity) -> Entity: self._AppendAttribute(entity, SimpleAttribute(...)) self._AppendAttribute(entity, SimpleAttribute(...)) return entity 
 - _classes: ClassVar[List[Any]] = []
- List of classes, this Attribute was attached to. 
 - _functions: ClassVar[List[Any]] = []
- List of functions, this Attribute was attached to. 
 - _methods: ClassVar[List[Any]] = []
- List of methods, this Attribute was attached to. 
 - _scope: ClassVar[AttributeScope] = 7
- Allowed language construct this attribute can be used with. 
 - _handler: Callable
- Reference to a method that is called to handle e.g. a sub-command. 
 
- class pyTooling.Attributes.ArgParse.ArgParseHelperMixin[source]
- Mixin-class to implement an - argparse-base command line argument processor.- Inheritance - __init__(**kwargs)[source]
- The mixin-constructor expects an optional list of named parameters which are passed without modification to the - ArgumentParserconstructor.- Parameters:
- kwargs (Any) 
- Return type:
- None 
 
 - property MainParser: ArgumentParser
- Returns the main parser.