(key, scopeName, builtin_docs)
| 14 | |
| 15 | |
| 16 | def 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 | |
| 55 | def is_required_param(param): |
no test coverage detected