Spaces:
Sleeping
Sleeping
Download samples/generate.py from brestok/vika-server: direct link, hf CLI and curl.
- Browser
- Download file 5.38 kB
-
https://huggingface.co/spaces/brestok/vika-server/resolve/main/samples/generate.py
- Command line
-
hf download hf://spaces/brestok/vika-server/samples/generate.py
-
curl -L -o generate.py https://huggingface.co/spaces/brestok/vika-server/resolve/main/samples/generate.py
5.38 kB
| """Build the sample packs under samples/. | |
| The layout is the one Goenee's own line list uses — headers on row 1, sheet | |
| "Loads", and the duplicated `Total Item Weight` column the report writer emits. | |
| Every figure in here is invented; only the goods codes are real. | |
| """ | |
| from pathlib import Path | |
| from openpyxl import Workbook | |
| OUT = Path(__file__).parent | |
| HEADERS = [ | |
| "HS Code", | |
| "Item Descr", | |
| "Total Item Weight", | |
| "Total Item Weight", | |
| "Item COO", | |
| "Pieces", | |
| "Colli type", | |
| "Tracking no", | |
| "Remarks (EAN", | |
| "Total Value (GBP)", | |
| "Y-code", | |
| ] | |
| # code, description, origin, weight, value, the answer a declarant wrote by hand | |
| APPAREL = [ | |
| ("62034231", "Men Jeans", "BD", 0.67, 54.20, "Y922"), | |
| ("62034231", "Men Jeans", "VN", 0.66, 81.30, "Y922"), | |
| ("62034235", "Men O 5 pockets", "BD", 0.46, 28.79, "Y922"), | |
| ("62034290", "Men Shorts", "BD", 0.38, 35.50, "Y922"), | |
| ("62034319", "Men O 5 pockets", "VN", 0.52, 47.90, "Y922"), | |
| ("62046231", "Wmn Jeans", "BD", 0.55, 62.40, "Y922"), | |
| ("62046239", "Wmn O 5 pockets", "TR", 0.49, 55.10, "Y922"), | |
| ("62033290", "Men Blazers", "TR", 0.81, 96.75, "Y922"), | |
| ("61101190", "Wmn Knits", "CN", 0.44, 41.20, "Y922"), | |
| ("61102091", "Men Sweats", "BD", 0.62, 49.99, "Y922"), | |
| ("61102099", "Wmn Sweats", "BD", 0.60, 49.99, "Y922"), | |
| ("61103091", "Men Knits", "VN", 0.58, 58.30, "Y922"), | |
| ("61142000", "Wmn Tops", "IN", 0.21, 22.45, "Y922"), | |
| ("62113290", "Men Jackets", "CN", 0.94, 110.00, "Y922"), | |
| ("62114290", "Wmn Jackets", "CN", 0.88, 104.50, "Y922"), | |
| # Dual-use sits on top of the fur control: two exemptions on one line. | |
| ("62013090", "Men Jackets", "CN", 0.91, 129.00, "Y901,Y922"), | |
| ("62014010", "Men Jackets", "VN", 0.95, 135.00, "Y901,Y922"), | |
| ("62024010", "Wmn Jackets", "CN", 0.86, 128.00, "Y901,Y922"), | |
| ("62113390", "Men Jackets", "CN", 0.90, 119.00, "Y901,Y922"), | |
| ("62114390", "Wmn Jumpsuit", "CN", 0.72, 98.60, "Y901,Y922"), | |
| # Y900 — a different exemption again. | |
| ("61059090", "Men Polo", "IN", 0.24, 26.40, "Y900"), | |
| ("61099020", "Men T-Shirts", "IN", 0.23, 19.95, "Y900"), | |
| ("64039996", "Men Boot", "PT", 1.35, 145.00, "Y900"), | |
| # Nothing at all goes in Box 44 for these. | |
| ("61091000", "Men T-Shirts", "BD", 0.25, 18.96, ""), | |
| ("61051000", "Men Polo", "IN", 0.27, 29.95, ""), | |
| ("61071100", "Men Underwear", "BD", 0.12, 14.95, ""), | |
| ("61159500", "Wmn Accessories", "CN", 0.09, 9.95, ""), | |
| ("62052000", "Men Overshirts", "TR", 0.41, 52.00, ""), | |
| ("62063000", "Wmn Shirts", "TR", 0.37, 48.50, ""), | |
| ("62121090", "Wmn Underwear", "CN", 0.08, 24.95, ""), | |
| ("64029190", "Men Sneaker", "VN", 1.10, 99.95, "Y922"), | |
| ("64029939", "Men Sandal", "VN", 0.65, 44.95, ""), | |
| # A required document, not just an exemption: CITES C400 plus two Y codes. | |
| ("65050030", "Men Accessories", "CN", 0.14, 19.95, "Y900,Y922"), | |
| ] | |
| ELECTRONICS = [ | |
| ("85287200", "LED television 55 inch", "CN", 14.80, 420.00), | |
| ("85287200", "LED television 43 inch", "CN", 9.60, 289.00), | |
| ("84714100", "Desktop computer", "CN", 7.40, 610.00), | |
| ("84713000", "Laptop 14 inch", "CN", 1.35, 780.00), | |
| ("85171300", "Smartphone", "CN", 0.21, 540.00), | |
| ("85258900", "Digital camera", "JP", 0.68, 690.00), | |
| ("22042189", "Red wine, bottled", "FR", 8.40, 96.00), | |
| ] | |
| PROBLEMS = [ | |
| ("620342", "Men Jeans, six digits only", "BD", 0.67, 54.20), | |
| ("99999999", "Code that does not exist", "BD", 0.40, 30.00), | |
| ("62021390", "Plausible but not declarable", "CN", 0.80, 88.00), | |
| ("6203 42 31", "Same code, spaced as on paper", "BD", 0.67, 54.20), | |
| ("09011100", "Coffee, NVWA chapter", "BR", 5.00, 60.00), | |
| ("0201 10 00", "Beef carcase, NVWA chapter", "AR", 12.50, 140.00), | |
| ("65050030", "Fur hat, chapter outside the release", "CN", 0.14, 19.95), | |
| ("", "No code at all", "CN", 0.30, 25.00), | |
| ] | |
| def tracking(index: int) -> str: | |
| return f"JJD00090000000{index:05d}" | |
| def ean(index: int) -> str: | |
| return f"87200000{index:05d}" | |
| def write(path: Path, rows: list[list]) -> None: | |
| workbook = Workbook() | |
| worksheet = workbook.active | |
| worksheet.title = "Loads" | |
| worksheet.append(HEADERS) | |
| for row in rows: | |
| worksheet.append(row) | |
| for column, width in zip("ABCDEFGHIJK", (12, 30, 18, 18, 10, 8, 11, 22, 16, 18, 12)): | |
| worksheet.column_dimensions[column].width = width | |
| workbook.save(path) | |
| print(f"{path.name:46} {len(rows):>3} rows") | |
| def main() -> None: | |
| OUT.mkdir(parents=True, exist_ok=True) | |
| apparel = [ | |
| [code, descr, weight, weight, coo, 1, "Parcel", tracking(i), ean(i), value, ycode] | |
| for i, (code, descr, coo, weight, value, ycode) in enumerate(APPAREL, start=1) | |
| ] | |
| write(OUT / "sample-goenee-export-apparel.xlsx", apparel) | |
| electronics = [ | |
| [code, descr, weight, weight, coo, 1, "Carton", tracking(200 + i), ean(200 + i), value, ""] | |
| for i, (code, descr, coo, weight, value) in enumerate(ELECTRONICS, start=1) | |
| ] | |
| write(OUT / "sample-goenee-export-electronics.xlsx", electronics) | |
| problems = [ | |
| [code, descr, weight, weight, coo, 1, "Parcel", tracking(400 + i), ean(400 + i), value, ""] | |
| for i, (code, descr, coo, weight, value) in enumerate(PROBLEMS, start=1) | |
| ] | |
| write(OUT / "sample-goenee-export-problems.xlsx", problems) | |
| if __name__ == "__main__": | |
| main() | |