Cli2gui Index / Cli2gui / Tojson / Argparse2json
Auto-generated documentation for cli2gui.tojson.argparse2json module.
Show source in argparse2json.py:26
Class to represent an ArgparseGroup.
class ArgparseGroup(TypedDict): ...Show source in argparse2json.py:123
Generate json for an action and set the widget - used by the application.
def actionToJson(action: argparse.Action, widget: ItemType) -> Item: ...Show source in argparse2json.py:137
Create a radio group for a mutex group of arguments.
def buildRadioGroup(mutexGroup: _MutuallyExclusiveGroup) -> Item: ...Show source in argparse2json.py:181
Categorize the parser groups and arg_items.
def categorizeGroups(groups: list[ArgparseGroup]) -> list[Group]: ...Show source in argparse2json.py:151
Catergorise each action and generate json.
def categorizeItems(actions: list[argparse.Action]) -> Generator[Item, None, None]: ...Show source in argparse2json.py:55
Get the program name.
def chooseName(name: str, subparser: argparse.ArgumentParser) -> str: ...Show source in argparse2json.py:60
Check if any actions(a) are present in actions(b).
def containsActions(
actionA: list[argparse.Action], actionB: list[argparse.Action]
) -> set[argparse.Action]: ...Show source in argparse2json.py:208
Convert argparse to a dict.
parserargparse.ArgumentParser - argparse parser
ParserRep- dictionary representing parser object
def convert(parser: argparse.ArgumentParser) -> ParserRep: ...Show source in argparse2json.py:99
Recursively extract argument groups and associated actions from ParserGroup objects.
def extractRawGroups(actionGroup: argparse._ArgumentGroup) -> ArgparseGroup: ...Show source in argparse2json.py:111
Convert an action of type Path or argparse.FileType to an Item.
def fileActionToJson(action: argparse.Action, widget: ItemType) -> Item: ...Show source in argparse2json.py:50
Identify if the passed name is the default program name.
def isDefaultProgname(name: str, subparser: argparse.ArgumentParser) -> bool: ...Show source in argparse2json.py:34
Iterate over name, parser pairs.
def iterParsers(
parser: argparse.ArgumentParser,
) -> list[tuple[str, argparse.ArgumentParser]]: ...Show source in argparse2json.py:198
Reapply the mutex groups and then categorize them and the arg_items under the parser.
def process(parser: argparse.ArgumentParser) -> list[Group]: ...Show source in argparse2json.py:67
_argparse stores mutually exclusive groups independently. of all other groups. So, they must be manually re-combined with the groups/subgroups to which they were originally declared in order to have them appear in the correct location in the UI.
Order is attempted to be preserved by inserting the MutexGroup into the _actions list at the first occurrence of any item where the two groups intersect.
def reapplyMutexGroups(
mutexGroups: list[argparse._MutuallyExclusiveGroup], actionGroups: list[Any]
) -> list[Any]: ...Show source in argparse2json.py:193
Remove groups where group['arg_items'] is false.
def stripEmpty(groups: list[ArgparseGroup]) -> list[ArgparseGroup]: ...