| Total Complexity | 2 | 
| Total Lines | 32 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import ast  | 
            ||
| 2 | |||
| 3 | from fastest.code_assets.naive_case_detector import get_test_from_example_passage  | 
            ||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | def get_functions_from_node(node):  | 
            ||
| 8 |     return [{ | 
            ||
| 9 | 'name': n.name,  | 
            ||
| 10 | 'tests': get_test_from_example_passage(ast.get_docstring(n))  | 
            ||
| 11 | } for n in node.body if isinstance(n, ast.FunctionDef)]  | 
            ||
| 12 | |||
| 13 | |||
| 14 | def get_functions(page):  | 
            ||
| 15 | """  | 
            ||
| 16 | ------  | 
            ||
| 17 | examples:  | 
            ||
| 18 | @let  | 
            ||
| 19 | page = 'def f(): return 1'  | 
            ||
| 20 | @end  | 
            ||
| 21 | |||
| 22 |     1) get_functions(page) -> [{'name': 'f', 'tests': None}] | 
            ||
| 23 | ------  | 
            ||
| 24 | :param page:  | 
            ||
| 25 | :return:  | 
            ||
| 26 | """  | 
            ||
| 27 | node = ast.parse(page)  | 
            ||
| 28 | functions = get_functions_from_node(node)  | 
            ||
| 29 | classes = [n for n in node.body if isinstance(n, ast.ClassDef)]  | 
            ||
| 30 | methods = [get_functions_from_node(class_) for class_ in classes]  | 
            ||
| 31 | return functions + methods  | 
            ||
| 32 |