Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -75,12 +75,15 @@ def _load_palette(path="plotly_colorwheel.txt"):
|
|
| 75 |
if not line or line.startswith("#"):
|
| 76 |
continue
|
| 77 |
parts = [p.strip() for p in line.split(",")]
|
| 78 |
-
if len(parts) < 4:
|
| 79 |
-
continue
|
| 80 |
try:
|
| 81 |
idx = int(parts[0])
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
entries[idx] = hex_color
|
| 85 |
except ValueError:
|
| 86 |
continue
|
|
|
|
| 75 |
if not line or line.startswith("#"):
|
| 76 |
continue
|
| 77 |
parts = [p.strip() for p in line.split(",")]
|
|
|
|
|
|
|
| 78 |
try:
|
| 79 |
idx = int(parts[0])
|
| 80 |
+
# Support both formats:
|
| 81 |
+
# id, color, shade, hex (4 columns, hex at index 3)
|
| 82 |
+
# id, color_name, hex (3 columns, hex at index 2)
|
| 83 |
+
hex_color = next(
|
| 84 |
+
(p for p in reversed(parts) if p.startswith("#")), None
|
| 85 |
+
)
|
| 86 |
+
if hex_color:
|
| 87 |
entries[idx] = hex_color
|
| 88 |
except ValueError:
|
| 89 |
continue
|