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

Function get_entry_for_builtin_attr

python/generate_tray.py:58–88  ·  view source on GitHub ↗
(key, typeName, attrName, builtin_docs)

Source from the content-addressed store, hash-verified

56 return (param['kind'] == 'POSITIONAL_ONLY' or param['kind'] == 'POSITIONAL_OR_KEYWORD') and 'default' not in param
57
58def get_entry_for_builtin_attr(key, typeName, attrName, builtin_docs):
59 entry = {
60 'key': key
61 }
62
63 scopeInfo = builtin_docs['types'][typeName]['attributes'][attrName]
64 if scopeInfo['isCallable']:
65 if 'parameters' not in scopeInfo:
66 print(scopeInfo)
67 params = []
68 else:
69 params = scopeInfo['parameters']
70
71 labels = [param['name'] for param in params if param['kind'] == 'POSITIONAL_ONLY' or param['kind'] == 'POSITIONAL_OR_KEYWORD']
72 required_count = len([param for param in params if is_required_param(param)])
73
74 # If there are optional args, but none are *required* then we need to make space for them.
75 if len(params) != 0 and required_count == 0:
76 required_count = 1
77
78 serNode = SplootNode('PYTHON_CALL_MEMBER', {
79 "object": [],
80 "arguments": [SplootNode('PY_ARG') for i in range(required_count)]
81 }, {"member": attrName})
82 serNode['meta'] = {'params': labels, 'objectType': typeName}
83 entry['serializedNode'] = serNode
84 else:
85 raise Exception(f'Non-callable type attributes not yet supported: {key}')
86 entry['abstract'] = scopeInfo['shortDoc']
87 entry['examples'] = scopeInfo['examples']
88 return entry
89
90
91def processEntry(data, builtin_docs, sploot_nodes):

Callers 1

processEntryFunction · 0.85

Calls 2

SplootNodeFunction · 0.90
is_required_paramFunction · 0.85

Tested by

no test coverage detected