-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodels.py
More file actions
124 lines (95 loc) · 2.15 KB
/
models.py
File metadata and controls
124 lines (95 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""Types for cli2gui."""
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from enum import Enum
from typing import Any
SEP = "#%#"
@dataclass
class BuildSpec:
"""Representation for the BuildSpec."""
run_function: Callable[..., Any]
parser: str | ParserType
gui: str | GUIType
theme: str | list[str]
darkTheme: str | list[str]
image: str
program_name: str
program_description: str
max_args_shown: int
menu: str | dict[str, Any]
@dataclass
class Item:
"""Representation for an arg_item."""
type: ItemType
display_name: str
commands: list[str]
help: str
dest: str
default: Any
required: bool = False
choices: list[Any] = None
nargs: str = None
additional_properties: dict[str, Any] = None
class ItemType(Enum):
"""Enum of ItemTypes."""
RadioGroup = "RadioGroup"
Bool = "Bool"
File = "File"
FileWrite = "FileWrite"
Path = "Path"
Choice = "Choice"
Int = "Int"
Text = "Text"
Float = "Float"
List = "List"
Tuple = "Tuple"
DateTime = "DateTime"
@dataclass
class Group:
"""Representation for an argument group."""
name: str
arg_items: list[Item]
groups: list[Group] | list[Any]
@dataclass
class ParserRep:
"""Representation for a parser."""
parser_description: str
widgets: list[Group]
@dataclass
class FullBuildSpec:
"""Representation for the FullBuildSpec (BuildSpec + ParserRep)."""
run_function: Callable[..., Any]
parser: str
gui: str
theme: str | list[str]
darkTheme: str | list[str]
image: str
program_name: str
program_description: str
max_args_shown: int
menu: str | dict[str, Any]
parser_description: str
widgets: list[Group]
# Supported parser types
class ParserType(str, Enum):
"""Supported parser types.
"""
OPTPARSE = "optparse"
ARGPARSE = "argparse"
DEPHELL_ARGPARSE = "dephell_argparse"
DOCOPT = "docopt"
GETOPT = "getopt"
CLICK = "click"
CUSTOM = "input()" # this seems like a pretty poor pattern to use
# Supported gui types
class GUIType(str, Enum):
"""Supported gui types.
"""
PSG = "pysimplegui"
WEB = "pysimpleguiweb"
QT = "pysimpleguiqt"
FSG = "freesimplegui"
FSGWEB = "freesimpleguiweb"
FSGQT = "freesimpleguiqt"
DPG = "dearpygui"