Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,7 +62,6 @@ def _find_first_valid_pair(logs: List[str]) -> Dict[str, Any]:
|
|
| 62 |
variants = vr.get("variants")
|
| 63 |
if isinstance(variants, list) and variants:
|
| 64 |
_log(logs, f"FOUND {len(variants)} variants")
|
| 65 |
-
_log(logs, f"Blueprint {bp_id} / Provider {p_id}: fetching print areas")
|
| 66 |
|
| 67 |
return {
|
| 68 |
"blueprint": bp,
|
|
@@ -74,10 +73,6 @@ def _find_first_valid_pair(logs: List[str]) -> Dict[str, Any]:
|
|
| 74 |
"GET",
|
| 75 |
f"/v1/catalog/blueprints/{bp_id}/print_providers/{p_id}/shipping.json",
|
| 76 |
),
|
| 77 |
-
"printAreas": _req(
|
| 78 |
-
"GET",
|
| 79 |
-
f"/v1/catalog/blueprints/{bp_id}/print_providers/{p_id}/print_areas.json",
|
| 80 |
-
),
|
| 81 |
}
|
| 82 |
|
| 83 |
raise RuntimeError("No blueprint/provider pair with variants found.")
|
|
@@ -127,7 +122,6 @@ def _build_product(blob: Dict[str, Any], currency: str, logs: List[str]) -> Dict
|
|
| 127 |
},
|
| 128 |
"description": description,
|
| 129 |
"variants": snapshot,
|
| 130 |
-
"printAreas": blob.get("printAreas"),
|
| 131 |
"raw": blob,
|
| 132 |
}
|
| 133 |
|
|
@@ -147,6 +141,13 @@ def run(currency: str) -> Generator[Tuple[str, str], None, None]:
|
|
| 147 |
_log(logs, f"SHOP_LIST {json.dumps(shops)}")
|
| 148 |
yield flush()
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
blob = _find_first_valid_pair(logs)
|
| 151 |
yield flush()
|
| 152 |
|
|
|
|
| 62 |
variants = vr.get("variants")
|
| 63 |
if isinstance(variants, list) and variants:
|
| 64 |
_log(logs, f"FOUND {len(variants)} variants")
|
|
|
|
| 65 |
|
| 66 |
return {
|
| 67 |
"blueprint": bp,
|
|
|
|
| 73 |
"GET",
|
| 74 |
f"/v1/catalog/blueprints/{bp_id}/print_providers/{p_id}/shipping.json",
|
| 75 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
raise RuntimeError("No blueprint/provider pair with variants found.")
|
|
|
|
| 122 |
},
|
| 123 |
"description": description,
|
| 124 |
"variants": snapshot,
|
|
|
|
| 125 |
"raw": blob,
|
| 126 |
}
|
| 127 |
|
|
|
|
| 141 |
_log(logs, f"SHOP_LIST {json.dumps(shops)}")
|
| 142 |
yield flush()
|
| 143 |
|
| 144 |
+
fd, path = tempfile.mkstemp(prefix="shops_", suffix=".json")
|
| 145 |
+
os.close(fd)
|
| 146 |
+
with open(path, "w", encoding="utf-8") as f:
|
| 147 |
+
json.dump(shops, f, indent=2)
|
| 148 |
+
_log(logs, f"SHOPS_JSON_WRITTEN {path}")
|
| 149 |
+
yield flush()
|
| 150 |
+
|
| 151 |
blob = _find_first_valid_pair(logs)
|
| 152 |
yield flush()
|
| 153 |
|