-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_array.py
More file actions
28 lines (20 loc) · 784 Bytes
/
Copy pathverify_array.py
File metadata and controls
28 lines (20 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import ast
try:
with open('canvasan.js', 'r') as f:
lines = f.readlines()
# Extract lines 166 to 235 (0-indexed: 165 to 235)
# Line 166 is index 165.
# Line 235 is index 234.
array_lines = lines[165:235]
# First line: "const art = [0, 0, ..."
# Remove "const art = "
array_lines[0] = array_lines[0].replace('const art = ', '')
full_array_str = "".join(array_lines)
# Python lists use [], same as JS arrays.
# Trailing comma is allowed in Python tuples/lists usually, but let's see.
# ast.literal_eval handles lists.
data = ast.literal_eval(full_array_str)
print("Successfully parsed array.")
print(f"Length: {len(data)}")
except Exception as e:
print(f"Error parsing array: {e}")