{"id":"catalog-price-preflight","publisher":"WESWOO","engine":"Python 3","title":{"zh":"下载可复算输入与代码","en":"Download runnable inputs and code"},"routine":"catalog_preflight","python_source":"def catalog_preflight(data):\n    import csv,io\n    rows=list(csv.DictReader(io.StringIO(data['candidate'])))\n    known=set(data['option_values'])\n    seen=set()\n    for row in rows:\n        if row.get('Handle')!=data['handle']:\n            return 'check handle'\n        if 'Tags' in row and row['Tags']=='' and data['current_tags']:\n            return 'blank tag column'\n        size=row.get('Option1 Value')\n        if not size or size not in known or size in seen:\n            return 'check variant keys'\n        seen.add(size)\n    if seen!=known or not rows or rows[0].get('Option1 Name')!='Size':\n        return 'check variant keys'\n    return [[r['Option1 Value'],r['Variant Price']] for r in rows]\n","checks":[{"condition":"price only","input":{"handle":"classic-varsity-top","option_values":["Small","Medium","Large"],"current_tags":"women","candidate":"Handle,Title,Option1 Name,Option1 Value,Variant Price\r\nclassic-varsity-top,Classic Varsity Top,Size,Small,60\r\nclassic-varsity-top,,,Medium,65\r\nclassic-varsity-top,,,Large,60\r\n"},"expected":[["Small","60"],["Medium","65"],["Large","60"]],"observed":[["Small","60"],["Medium","65"],["Large","60"]]},{"condition":"tag","input":{"handle":"classic-varsity-top","option_values":["Small","Medium","Large"],"current_tags":"women","candidate":"Handle,Title,Option1 Name,Option1 Value,Variant Price,Tags\r\nclassic-varsity-top,Classic Varsity Top,Size,Small,60,\r\nclassic-varsity-top,,,Medium,65,\r\nclassic-varsity-top,,,Large,60,\r\n"},"expected":"blank tag column","observed":"blank tag column"},{"condition":"omit","input":{"handle":"classic-varsity-top","option_values":["Small","Medium","Large"],"current_tags":"women","candidate":"Handle,Title,Option1 Name,Option1 Value,Variant Price\r\nclassic-varsity-top,Classic Varsity Top,Size,Small,60\r\nclassic-varsity-top,,,Medium,65\r\n"},"expected":"check variant keys","observed":"check variant keys"},{"condition":"repeat","input":{"handle":"classic-varsity-top","option_values":["Small","Medium","Large"],"current_tags":"women","candidate":"Handle,Title,Option1 Name,Option1 Value,Variant Price\r\nclassic-varsity-top,Classic Varsity Top,Size,Small,60\r\nclassic-varsity-top,,,Small,65\r\nclassic-varsity-top,,,Large,60\r\n"},"expected":"check variant keys","observed":"check variant keys"}],"instructions":"Save python_source in a Python 3 module. Call the named routine with each check.input and compare with check.expected. Calendar case needs an IANA time-zone database.","reference_fixture":{"url":"https://github.com/shopifypartners/product-csvs/blob/045fb432d85dc59d558717208399176d62bf106d/apparel.csv","sha256":"90291acf9147ab2eeccb7ead518bb5b3dd8900f7285b8cea918403e732c451b3"}}