-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfunction_lister.py
More file actions
30 lines (25 loc) · 919 Bytes
/
Copy pathfunction_lister.py
File metadata and controls
30 lines (25 loc) · 919 Bytes
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
import os
import traceback
from csvpath.matching.functions.function_factory import FunctionFactory
from .function_describer import FunctionDescriber
from .selecter import Selecter
from .const import Const
class FunctionLister:
def __init__(self, cli):
self._cli = cli
def list_functions(self) -> None:
FunctionFactory.load()
names = list(FunctionFactory.MY_FUNCTIONS.keys())
names.sort()
if None in names:
raise ValueError("None cannot be a key in functions")
cs = [(n, n) for n in names]
t = Selecter().ask(title="", values=cs, cancel_value="CANCEL")
self._cli.clear()
if t in [Const.CANCEL, Const.CANCEL2]:
return
f = FunctionFactory.get_function(
None, name=t, child=None, find_external_functions=False
)
FunctionDescriber.describe(f)
self._cli._return_to_cont()