From 0339811f93f09ec9182cf0a9973b2f2d69fa955e Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 16 May 2012 18:58:20 +0200 Subject: [PATCH] split a multi-pallet packlist into multiple single-pallet packlists --- split_multi.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 split_multi.py diff --git a/split_multi.py b/split_multi.py new file mode 100644 index 0000000..18d4ddb --- /dev/null +++ b/split_multi.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# +# Copyright 2012 Johannes 'josch' Schauer +# +# This file is part of Sisyphus. +# +# Sisyphus is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Sisyphus is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Sisyphus. If not, see . + +import ctypes, sys +from util import xmlfiletodict, get_packlist_dict, dicttoxmlfile, get_order_dict +import os + +if len(sys.argv) != 2: + print "usage:", sys.argv[0], "packlist.xml" + exit(1) + +packlist = xmlfiletodict(sys.argv[1]) + +pallets = packlist['Response']['PackList']['PackPallets']['PackPallet'] + + +if not isinstance(pallets, list): + sys.stderr.write("this is not a multi-pallet packlist\n") + exit(1) + +article_lists = [ pallet['Packages']['Package'] for pallet in pallets ] + +scores = list() +for i, (pallet, articles_to_pack) in enumerate(zip(pallets, article_lists)): + partial_packlist = get_packlist_dict(pallet, articles_to_pack) + dicttoxmlfile(partial_packlist, sys.argv[1]+"_"+str(i)+".xml") + partial_order = get_order_dict(pallet, articles_to_pack) + dicttoxmlfile(partial_order, sys.argv[1]+"_order_"+str(i)+".xml")