Skip to content

Latest commit

 

History

History
292 lines (163 loc) · 5.82 KB

File metadata and controls

292 lines (163 loc) · 5.82 KB

Argparse2json

Cli2gui Index / Cli2gui / Tojson / Argparse2json

Auto-generated documentation for cli2gui.tojson.argparse2json module.

ArgparseGroup

Show source in argparse2json.py:26

Class to represent an ArgparseGroup.

Signature

class ArgparseGroup(TypedDict): ...

actionToJson

Show source in argparse2json.py:123

Generate json for an action and set the widget - used by the application.

Signature

def actionToJson(action: argparse.Action, widget: ItemType) -> Item: ...

See also

buildRadioGroup

Show source in argparse2json.py:137

Create a radio group for a mutex group of arguments.

Signature

def buildRadioGroup(mutexGroup: _MutuallyExclusiveGroup) -> Item: ...

See also

categorizeGroups

Show source in argparse2json.py:181

Categorize the parser groups and arg_items.

Signature

def categorizeGroups(groups: list[ArgparseGroup]) -> list[Group]: ...

See also

categorizeItems

Show source in argparse2json.py:151

Catergorise each action and generate json.

Signature

def categorizeItems(actions: list[argparse.Action]) -> Generator[Item, None, None]: ...

See also

chooseName

Show source in argparse2json.py:55

Get the program name.

Signature

def chooseName(name: str, subparser: argparse.ArgumentParser) -> str: ...

containsActions

Show source in argparse2json.py:60

Check if any actions(a) are present in actions(b).

Signature

def containsActions(
    actionA: list[argparse.Action], actionB: list[argparse.Action]
) -> set[argparse.Action]: ...

convert

Show source in argparse2json.py:208

Convert argparse to a dict.

Arguments


  • parser argparse.ArgumentParser - argparse parser

Returns


  • ParserRep - dictionary representing parser object

Signature

def convert(parser: argparse.ArgumentParser) -> ParserRep: ...

See also

extractRawGroups

Show source in argparse2json.py:99

Recursively extract argument groups and associated actions from ParserGroup objects.

Signature

def extractRawGroups(actionGroup: argparse._ArgumentGroup) -> ArgparseGroup: ...

See also

fileActionToJson

Show source in argparse2json.py:111

Convert an action of type Path or argparse.FileType to an Item.

Signature

def fileActionToJson(action: argparse.Action, widget: ItemType) -> Item: ...

See also

isDefaultProgname

Show source in argparse2json.py:50

Identify if the passed name is the default program name.

Signature

def isDefaultProgname(name: str, subparser: argparse.ArgumentParser) -> bool: ...

iterParsers

Show source in argparse2json.py:34

Iterate over name, parser pairs.

Signature

def iterParsers(
    parser: argparse.ArgumentParser,
) -> list[tuple[str, argparse.ArgumentParser]]: ...

process

Show source in argparse2json.py:198

Reapply the mutex groups and then categorize them and the arg_items under the parser.

Signature

def process(parser: argparse.ArgumentParser) -> list[Group]: ...

See also

reapplyMutexGroups

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.

Signature

def reapplyMutexGroups(
    mutexGroups: list[argparse._MutuallyExclusiveGroup], actionGroups: list[Any]
) -> list[Any]: ...

stripEmpty

Show source in argparse2json.py:193

Remove groups where group['arg_items'] is false.

Signature

def stripEmpty(groups: list[ArgparseGroup]) -> list[ArgparseGroup]: ...

See also