From 085d12aedb8e1d924a211e2a066e7d8d6a2f06d9 Mon Sep 17 00:00:00 2001 From: Jon Combe Date: Sun, 24 Feb 2019 07:43:51 +0000 Subject: [PATCH 1/2] Works with python3 --- pyshipping/binpack.py | 10 ++-- pyshipping/binpack_simple.py | 12 ++--- pyshipping/fortras/entl.py | 78 +++++++++++++++--------------- pyshipping/fortras/fortras_stat.py | 2 +- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/pyshipping/binpack.py b/pyshipping/binpack.py index fbb0637..7c807ae 100644 --- a/pyshipping/binpack.py +++ b/pyshipping/binpack.py @@ -8,7 +8,7 @@ """ -import binpack_simple +import pyshipping.binpack_simple def binpack(packages, bin=None, iterlimit=5000): @@ -32,16 +32,16 @@ def test(func): continue bins, rest = func(packages) if rest: - print "invalid data", rest, line + print("invalid data", rest, line) else: vorher += len(packages) nachher += len(bins) - print time.time() - start, - print vorher, nachher, float(nachher) / vorher * 100 + print(time.time() - start) + print(vorher, nachher, float(nachher) / vorher * 100) if __name__ == '__main__': - print "py", + print("py") test(binpack) diff --git a/pyshipping/binpack_simple.py b/pyshipping/binpack_simple.py index 89c4fdb..49a4bd5 100644 --- a/pyshipping/binpack_simple.py +++ b/pyshipping/binpack_simple.py @@ -95,7 +95,7 @@ def packlayer(bin, packages): def packbin(bin, packages): - packages.sort() + packages.sort(key=lambda x: x.volume) layers = [] contentheigth = 0 contentx = 0 @@ -121,7 +121,7 @@ def packbin(bin, packages): def packit(bin, originalpackages): packedbins = [] - packages = sorted(originalpackages) + packages = sorted(originalpackages, key=lambda x: x.volume) while packages: packagesinbin, (binx, biny, binz), rest = packbin(bin, packages) if not packagesinbin: @@ -139,7 +139,7 @@ def packit(bin, originalpackages): def product(*args, **kwds): # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111 - pools = map(tuple, args) * kwds.get('repeat', 1) + pools = list(map(tuple, args)) * kwds.get('repeat', 1) result = [[]] for pool in pools: result = [x + [y] for x in result for y in pool] @@ -222,12 +222,12 @@ def test(): continue bins, rest = binpack(packages) if rest: - print "invalid data", rest, line + print("invalid data", rest, line) else: vorher += len(packages) nachher += len(bins) - print time.time() - start, - print vorher, nachher, float(nachher) / vorher * 100 + print(time.time() - start) + print(vorher, nachher, float(nachher) / vorher * 100) if __name__ == '__main__': diff --git a/pyshipping/fortras/entl.py b/pyshipping/fortras/entl.py index 1c25964..ceb7eb6 100644 --- a/pyshipping/fortras/entl.py +++ b/pyshipping/fortras/entl.py @@ -38,7 +38,7 @@ class Entladebericht(object): # Gitterbox-Paletten-Entladung Empfangspartner kann 3/0 115 - 117 # Verkehrsart** kann 1 118 - 118 # Frei 9 119 - 127 - # Releasestand ‘5’ muss 1 128 - 128 + # Releasestand ���5’ muss 1 128 - 128 n_record_re = (r'N(?P[0-9 ]{18})(?P[0-9 ]{3})(?P[0-9 ]{16})' + r'(?P[0-9 ]{16})(?P..)' @@ -51,11 +51,11 @@ class Entladebericht(object): # Laufende Bordero-Position Versandpartner muss 3/0 020 - 022 # Sendungs-Nr. Versandpartner muss 16 023 - 038 # Sendungs-Nr. Empfangspartner muss 16 039 - 054 - # DifferenzartschluŸssel 1* muss 2 055 - 056 + # Differenzartschlu�ssel 1* muss 2 055 - 056 # Differenzanzahl 1 kann 4/0 057 - 060 # Verpackungsart 1** kann 2 061 - 062 # Text/Hinweis 1 kann 29 063 - 091 - # DifferenzartschluŸssel 2* kann 2 092 - 093 + # Differenzartschlu�ssel 2* kann 2 092 - 093 # Differenzanzahl 2 kann 4/0 094 - 097 # Verpackungsart 2** kann 2 098 - 099 # Text/Hinweis 2 kann 29 100 - 128 @@ -66,60 +66,60 @@ class Entladebericht(object): + r'(?P[0-9 ]{8})(?P