query
validate_input
validate_input(prompt: str, response: Iterable[str]) -> str
Following a provided prompt, validate that the user input is a valid response then return the response outcome
Parameters:
-
prompt
(str
) –The desired prompt
-
response
(Iterable[str]
) –The response values to accept as keys and the resulting data to return as values
Returns: The data matching the chosen response key
Source code in symdesign/utils/query.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
validate_type
validate_type(value: Any, dtype: Callable = str) -> bool
Provide a user prompt to ensure the user input is what is desired
Returns:
-
bool
–A True value indicates the user wants to proceed. False indicates we should get input again.
Source code in symdesign/utils/query.py
39 40 41 42 43 44 45 46 47 48 49 50 |
|
boolean_choice
boolean_choice() -> bool
Retrieve user input from a boolean confirmation prompt "Please specify [y/n] Input: " to control program flow
Returns:
-
bool
–A True value indicates the user wants to proceed. False indicates they do not
Source code in symdesign/utils/query.py
53 54 55 56 57 58 59 60 61 62 63 |
|
verify_choice
verify_choice() -> bool
Provide a verification prompt (If this is correct, indicate y, if not n, and you can re-input) to ensure a prior input was desired
Returns:
-
bool
–A True value indicates the user wants to proceed. False indicates we should get input again.
Source code in symdesign/utils/query.py
66 67 68 69 70 71 72 73 74 75 76 77 |
|
connection_exception_handler
connection_exception_handler(url: str, max_attempts: int = 2) -> Response | None
Wrap requests GET commands in an exception handler which attempts to aqcuire the data multiple times if the connection is refused due to a high volume of requests
Parameters:
-
url
(str
) –The url to GET information from
-
max_attempts
(int
, default:2
) –The number of queries that should be attempts without successful return
Returns: The json formatted response to the url GET or None
Source code in symdesign/utils/query.py
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 125 126 127 |
|
format_input
format_input(prompt: str) -> str
Format the builtin input() using program specific formatting
Parameters:
-
prompt
(str
) –The desired prompt
Returns: The input
Source code in symdesign/utils/query.py
130 131 132 133 134 135 136 137 138 |
|
confirm_input_action
confirm_input_action(input_message: str) -> bool
Given a prompt, query the user to verify their input is desired
Parameters:
-
input_message
(str
) –A message specifying the program will take a course of action upon user consent
Returns: True if the user wants to proceed with the described input_message otherwise False
Source code in symdesign/utils/query.py
141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
validate_input_return_response_value
validate_input_return_response_value(prompt: str, response: dict[str, Any]) -> Any
Following a provided prompt, validate that the user input is a valid response then return the response outcome
Parameters:
-
prompt
(str
) –The desired prompt
-
response
(dict[str, Any]
) –The response values to accept as keys and the resulting data to return as values
Returns: The data matching the chosen response key
Source code in symdesign/utils/query.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|