Spaces:
Runtime error
Runtime error
Update InitialMarkups.py
Browse files- InitialMarkups.py +9 -4
InitialMarkups.py
CHANGED
|
@@ -37,13 +37,18 @@ def filteredJsons(pdf_path,filteredjsonsfromrawan):
|
|
| 37 |
|
| 38 |
|
| 39 |
def changepdflinks(data_list_JSON, pdflink):
|
| 40 |
-
print('henaaaa weee')
|
| 41 |
|
| 42 |
-
# If the input is a JSON string, convert it to a Python list
|
| 43 |
if isinstance(data_list_JSON, str):
|
| 44 |
-
data_list_JSON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
elif not isinstance(data_list_JSON, list):
|
| 46 |
-
raise ValueError("Input must be
|
| 47 |
|
| 48 |
# Loop through all entries and update their NBSLink
|
| 49 |
for entry in data_list_JSON:
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
def changepdflinks(data_list_JSON, pdflink):
|
| 40 |
+
print('henaaaa weee',data_list_JSON)
|
| 41 |
|
|
|
|
| 42 |
if isinstance(data_list_JSON, str):
|
| 43 |
+
if data_list_JSON.strip().startswith('['):
|
| 44 |
+
try:
|
| 45 |
+
data_list_JSON = json.loads(data_list_JSON)
|
| 46 |
+
except json.JSONDecodeError:
|
| 47 |
+
raise ValueError(f"Invalid JSON string passed: {data_list_JSON[:200]}")
|
| 48 |
+
else:
|
| 49 |
+
raise ValueError(f"Expected JSON string but got something else: {data_list_JSON[:200]}")
|
| 50 |
elif not isinstance(data_list_JSON, list):
|
| 51 |
+
raise ValueError(f"Input must be JSON string or list, got {type(data_list_JSON)}")
|
| 52 |
|
| 53 |
# Loop through all entries and update their NBSLink
|
| 54 |
for entry in data_list_JSON:
|