Python-3-anpassungen
Bernd Wurst

Bernd Wurst commited on 2018-07-06 07:32:24
Zeige 2 geänderte Dateien mit 7 Einfügungen und 10 Löschungen.

... ...
@@ -120,11 +120,8 @@ def address(canvas, lines):
120 120
 
121 121
 
122 122
 def InvoiceToPDF(iv, bankdata=True):
123
-    try:
124
-        from io import StringIO
125
-    except ImportError:
126
-        from io import StringIO
127
-    fd = StringIO()
123
+    from io import BytesIO
124
+    fd = BytesIO()
128 125
     canvas = Canvas.Canvas(fd, pagesize=A4)
129 126
 
130 127
     if iv.tender:
... ...
@@ -44,7 +44,7 @@ def InvoiceToText(iv, bankdata=True):
44 44
         ret.append('Volksbank Backnang, BLZ 602 911 20, Konto-Nr. 41512 006')
45 45
         ret.append('IBAN: DE91602911200041512006, BIC: GENODES1VBK')
46 46
 
47
-    return ('\n'.join(ret)).encode('utf-8')
47
+    return '\n'.join(ret)
48 48
 
49 49
 
50 50
 def InvoiceTableToText(invoiceTable):
... ...
@@ -105,13 +105,13 @@ def InvoiceTableToText(invoiceTable):
105 105
             sum += vat * vatdata[0]
106 106
         ret.append((u'Rechnungsbetrag: %11s' % format_price(sum)).rjust(72))
107 107
     ret.append('')
108
-    return ('\n'.join(ret)).encode('utf-8')
108
+    return '\n'.join(ret)
109 109
 
110 110
 
111 111
 def InvoiceTextToText(invoiceText):
112 112
     ret = []
113 113
     for par in invoiceText.paragraphs:
114
-        for str in split_to_width(par, 72):
115
-            ret.append(str)
114
+        for s in split_to_width(par, 72):
115
+            ret.append(s)
116 116
         ret.append('')
117
-    return ('\n'.join(ret)).encode('utf-8')
117
+    return '\n'.join(ret)
118 118