1
+ from .Fragment import Fragment
2
+ from utils .flags import *
3
+ from utils .CustomLogging import CustomLogging
4
+ from python_compiler .engines .utils .types import get_python_type_str , ANY
5
+
6
+ def get_function_name (fragment ) -> str :
7
+ if not (function_name := fragment .get (ATTRIBUTE_FUNCTION_CALL_NAME )):
8
+ CustomLogging .critical (f"Fragment type function_call '{ ATTRIBUTE_FUNCTION_CALL_NAME } ' attribute does not exist" )
9
+ return function_name
10
+
11
+ def get_function_args (fragment ) -> dict :
12
+ if not (function_args := fragment .get (ATTRIBUTE_FUNCTION_ARGS )):
13
+ function_args = {}
14
+ return function_args
15
+
16
+ def get_function_kwargs (fragment ) -> dict :
17
+ if not (function_kwargs := fragment .get (ATTRIBUTE_FUNCTION_KWARGS )):
18
+ function_kwargs = {}
19
+ return function_kwargs
20
+
21
+ class FunctionCall (Fragment ):
22
+ name :str
23
+ args :dict
24
+ kwargs :dict
25
+ def __init__ (self , blueprint , * args , ** kwargs ) -> None :
26
+ super ().__init__ ( blueprint , * args , ** kwargs )
27
+ self .name = get_function_name (blueprint )
28
+ self .args = get_function_args (blueprint )
29
+ self .kwargs = get_function_kwargs (blueprint )
30
+ def inputs_compile (self ) -> str :
31
+ inputs = []
32
+ if self .args :
33
+ inputs = self .args
34
+
35
+ if self .kwargs :
36
+ inputs .extend ([ f"{ x } :{ self .kwargs [x ]} " for x in self .kwargs ])
37
+
38
+ inputs_build = ", " .join (inputs )
39
+ return inputs_build
40
+ def compile (self )-> str :
41
+ fragment_build = f"{ self .name } ({ self .inputs_compile ()} )"
42
+
43
+ return fragment_build
0 commit comments