MCPcopy Create free account
hub / github.com/SplootCode/splootcode / get_entry_for_builtin_value

Function get_entry_for_builtin_value

python/generate_tray.py:16–52  ·  view source on GitHub ↗
(key, scopeName, builtin_docs)

Source from the content-addressed store, hash-verified

14
15
16def get_entry_for_builtin_value(key, scopeName, builtin_docs):
17 entry = {
18 'key': key
19 }
20 if scopeName in builtin_docs['values']:
21 scopeInfo = builtin_docs['values'][scopeName]
22 entry['abstract'] = scopeInfo['shortDoc']
23 entry['examples'] = []
24 if 'examples' in scopeInfo:
25 entry['examples'] = scopeInfo['examples']
26
27 if scopeInfo['isCallable']:
28 if 'parameters' not in scopeInfo:
29 print(scopeInfo)
30 params = []
31 else:
32 params = scopeInfo['parameters']
33 labels = [param['name'] for param in params if param['kind'] == 'POSITIONAL_ONLY' or param['kind'] == 'POSITIONAL_OR_KEYWORD']
34 required_count = len([param for param in params if is_required_param(param)])
35
36 # If there are optional args, but none are *required* then we need to make space for them.
37 if len(params) != 0 and required_count == 0:
38 required_count = 1
39
40 serNode = SplootNode('PYTHON_CALL_VARIABLE',
41 {
42 "arguments": [SplootNode('PY_ARG') for i in range(required_count)]
43 },
44 {"identifier": scopeName})
45 serNode['meta'] = {'params': labels}
46 entry['serializedNode'] = serNode
47 else:
48 serNode = SplootNode('PY_IDENTIFIER', {}, {"identifier": scopeName})
49 entry['serializedNode'] = serNode
50 else:
51 raise Exception(f'ScopeEntry {scopeName} not found')
52 return entry
53
54
55def is_required_param(param):

Callers 1

processEntryFunction · 0.85

Calls 2

SplootNodeFunction · 0.90
is_required_paramFunction · 0.85

Tested by

no test coverage detected