(key, typeName, attrName, builtin_docs)
| 56 | return (param['kind'] == 'POSITIONAL_ONLY' or param['kind'] == 'POSITIONAL_OR_KEYWORD') and 'default' not in param |
| 57 | |
| 58 | def 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 | |
| 91 | def processEntry(data, builtin_docs, sploot_nodes): |
no test coverage detected