Spaces:
Runtime error
Runtime error
Download tests/js_source_extract.py from sin10122484/aiplatform: direct link, hf CLI and curl.
- Browser
- Download file 562 Bytes
-
https://huggingface.co/spaces/sin10122484/aiplatform/resolve/main/tests/js_source_extract.py
- Command line
-
hf download hf://spaces/sin10122484/aiplatform/tests/js_source_extract.py
-
curl -L -o js_source_extract.py https://huggingface.co/spaces/sin10122484/aiplatform/resolve/main/tests/js_source_extract.py
562 Bytes
| def extract_function(js: str, name: str, prefix: str = "function") -> str: | |
| marker = f"{prefix} {name}(" | |
| start = js.find(marker) | |
| assert start >= 0, f"{name} function not found in static/panels.js" | |
| brace = js.find("{", start) | |
| assert brace >= 0, f"{name} opening brace not found" | |
| depth = 1 | |
| i = brace + 1 | |
| while i < len(js) and depth > 0: | |
| if js[i] == "{": | |
| depth += 1 | |
| elif js[i] == "}": | |
| depth -= 1 | |
| i += 1 | |
| assert depth == 0, f"{name} function braces unbalanced" | |
| return js[start:i] | |