Merge lp:~paulliu/qr-tools/python3 into lp:qr-tools
- python3
- Merge into trunk
Proposed by
Ying-Chun Liu
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ramiro Algozino | ||||
Approved revision: | 33 | ||||
Merged at revision: | 33 | ||||
Proposed branch: | lp:~paulliu/qr-tools/python3 | ||||
Merge into: | lp:qr-tools | ||||
Diff against target: |
404 lines (+92/-91) 2 files modified
qrtools.py (+12/-12) qtqr.py (+80/-79) |
||||
To merge this branch: | bzr merge lp:~paulliu/qr-tools/python3 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ramiro Algozino | Approve | ||
Review via email: mp+372711@code.launchpad.net |
Commit message
Porting to python3
Description of the change
Python2 is end of life. We have to port this project to python3 so that we can continue using it.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'qrtools.py' | |||
2 | --- qrtools.py 2018-03-01 17:24:59 +0000 | |||
3 | +++ qrtools.py 2019-09-12 18:29:16 +0000 | |||
4 | @@ -1,4 +1,4 @@ | |||
6 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
7 | 2 | 2 | ||
8 | 3 | # Authors: | 3 | # Authors: |
9 | 4 | # David Green <david4dev@gmail.com> | 4 | # David Green <david4dev@gmail.com> |
10 | @@ -35,7 +35,7 @@ | |||
11 | 35 | import Image | 35 | import Image |
12 | 36 | import re | 36 | import re |
13 | 37 | from codecs import BOM_UTF8 | 37 | from codecs import BOM_UTF8 |
15 | 38 | from urlparse import urlparse, parse_qs | 38 | from urllib.parse import urlparse, parse_qs |
16 | 39 | 39 | ||
17 | 40 | def eprint(*args, **kwargs): | 40 | def eprint(*args, **kwargs): |
18 | 41 | print(*args, file=sys.stderr, **kwargs) | 41 | print(*args, file=sys.stderr, **kwargs) |
19 | @@ -170,7 +170,7 @@ | |||
20 | 170 | utf8_bytedata = None | 170 | utf8_bytedata = None |
21 | 171 | try: | 171 | try: |
22 | 172 | utf8_bytedata = self.data_to_string() | 172 | utf8_bytedata = self.data_to_string() |
24 | 173 | except QR.EncodeError, e: | 173 | except QR.EncodeError as e: |
25 | 174 | eprint(repr(e)) | 174 | eprint(repr(e)) |
26 | 175 | return 1 | 175 | return 1 |
27 | 176 | 176 | ||
28 | @@ -178,8 +178,8 @@ | |||
29 | 178 | command = [ | 178 | command = [ |
30 | 179 | 'qrencode', | 179 | 'qrencode', |
31 | 180 | '-o', self.filename, | 180 | '-o', self.filename, |
34 | 181 | '-s', unicode(self.pixel_size), | 181 | '-s', str(self.pixel_size), |
35 | 182 | '-m', unicode(self.margin_size), | 182 | '-m', str(self.margin_size), |
36 | 183 | '-l', self.level, | 183 | '-l', self.level, |
37 | 184 | '-t', ext, | 184 | '-t', ext, |
38 | 185 | self.data_to_string() | 185 | self.data_to_string() |
39 | @@ -188,8 +188,8 @@ | |||
40 | 188 | command = [ | 188 | command = [ |
41 | 189 | 'qrencode', | 189 | 'qrencode', |
42 | 190 | '-o', self.filename, | 190 | '-o', self.filename, |
45 | 191 | '-s', unicode(self.pixel_size), | 191 | '-s', str(self.pixel_size), |
46 | 192 | '-m', unicode(self.margin_size), | 192 | '-m', str(self.margin_size), |
47 | 193 | '-l', self.level, | 193 | '-l', self.level, |
48 | 194 | #'-t', ext, | 194 | #'-t', ext, |
49 | 195 | self.data_to_string() | 195 | self.data_to_string() |
50 | @@ -222,7 +222,7 @@ | |||
51 | 222 | # clean up | 222 | # clean up |
52 | 223 | del(image) | 223 | del(image) |
53 | 224 | #Assuming data is encoded in utf8 | 224 | #Assuming data is encoded in utf8 |
55 | 225 | self.data = symbol.data.decode(u'utf-8') | 225 | self.data = symbol.data |
56 | 226 | self.data_type = self.data_recognise() | 226 | self.data_type = self.data_recognise() |
57 | 227 | return True | 227 | return True |
58 | 228 | else: | 228 | else: |
59 | @@ -267,19 +267,19 @@ | |||
60 | 267 | #FIXME: Probably a future bug in newer versions. | 267 | #FIXME: Probably a future bug in newer versions. |
61 | 268 | #We should at least check if the binary is available. | 268 | #We should at least check if the binary is available. |
62 | 269 | p = subprocess.Popen(['qrencode','-V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 269 | p = subprocess.Popen(['qrencode','-V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
65 | 270 | version_text = p.communicate()[1] | 270 | version_text = p.communicate()[0] |
66 | 271 | version = re.search('version\s([\d.]*)',version_text) | 271 | version = re.search('version\s([\d.]*)',str(version_text)) |
67 | 272 | if version: | 272 | if version: |
68 | 273 | version_number = version.group(1) | 273 | version_number = version.group(1) |
69 | 274 | else: | 274 | else: |
70 | 275 | version_number = -1 | 275 | version_number = -1 |
72 | 276 | #print "Using qrencode version:", version_number | 276 | #print ("Using qrencode version:", version_number) |
73 | 277 | return version_number | 277 | return version_number |
74 | 278 | 278 | ||
75 | 279 | def get_qrencode_types(self): | 279 | def get_qrencode_types(self): |
76 | 280 | p = subprocess.Popen(['qrencode','-h'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 280 | p = subprocess.Popen(['qrencode','-h'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
77 | 281 | help_text = p.communicate()[1] | 281 | help_text = p.communicate()[1] |
79 | 282 | types_text = re.search('-t {([\w,]*)}', help_text) | 282 | types_text = re.search('-t {([\w,]*)}', str(help_text)) |
80 | 283 | if types_text: | 283 | if types_text: |
81 | 284 | types = types_text.group(1).split(',') | 284 | types = types_text.group(1).split(',') |
82 | 285 | #print "The following format types have been found!:", types | 285 | #print "The following format types have been found!:", types |
83 | 286 | 286 | ||
84 | === modified file 'qtqr.py' | |||
85 | --- qtqr.py 2018-06-04 01:50:55 +0000 | |||
86 | +++ qtqr.py 2019-09-12 18:29:16 +0000 | |||
87 | @@ -1,4 +1,4 @@ | |||
89 | 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python3 |
90 | 2 | #-*- encoding: utf-8 -*- | 2 | #-*- encoding: utf-8 -*- |
91 | 3 | 3 | ||
92 | 4 | """ | 4 | """ |
93 | @@ -16,7 +16,7 @@ | |||
94 | 16 | try: | 16 | try: |
95 | 17 | # import pynotify | 17 | # import pynotify |
96 | 18 | if not pynotify.init("QtQR"): | 18 | if not pynotify.init("QtQR"): |
98 | 19 | print "DEBUG: There was a problem initializing the pynotify module" | 19 | print ("DEBUG: There was a problem initializing the pynotify module") |
99 | 20 | NOTIFY = True | 20 | NOTIFY = True |
100 | 21 | except: | 21 | except: |
101 | 22 | NOTIFY = False | 22 | NOTIFY = False |
102 | @@ -43,17 +43,17 @@ | |||
103 | 43 | 43 | ||
104 | 44 | # Templates for creating QRCodes supported by qrtools | 44 | # Templates for creating QRCodes supported by qrtools |
105 | 45 | self.templates = { | 45 | self.templates = { |
117 | 46 | "text": unicode(self.tr("Text")), | 46 | "text": str(self.tr("Text")), |
118 | 47 | "url": unicode(self.tr("URL")), | 47 | "url": str(self.tr("URL")), |
119 | 48 | "bookmark": unicode(self.tr("Bookmark")), | 48 | "bookmark": str(self.tr("Bookmark")), |
120 | 49 | "emailmessage": unicode(self.tr("E-Mail")), | 49 | "emailmessage": str(self.tr("E-Mail")), |
121 | 50 | "telephone": unicode(self.tr("Telephone Number")), | 50 | "telephone": str(self.tr("Telephone Number")), |
122 | 51 | "phonebook": unicode(self.tr("Contact Information (PhoneBook)")), | 51 | "phonebook": str(self.tr("Contact Information (PhoneBook)")), |
123 | 52 | "sms": unicode(self.tr("SMS")), | 52 | "sms": str(self.tr("SMS")), |
124 | 53 | "mms": unicode(self.tr("MMS")), | 53 | "mms": str(self.tr("MMS")), |
125 | 54 | "geo": unicode(self.tr("Geolocalization")), | 54 | "geo": str(self.tr("Geolocalization")), |
126 | 55 | "wifi": unicode(self.tr("WiFi Network")), | 55 | "wifi": str(self.tr("WiFi Network")), |
127 | 56 | "sepa": unicode(self.tr("SEPA Single Payment")), | 56 | "sepa": str(self.tr("SEPA Single Payment")), |
128 | 57 | } | 57 | } |
129 | 58 | # With this we make the dict bidirectional | 58 | # With this we make the dict bidirectional |
130 | 59 | self.templates.update( dict((self.templates[k], k) for k in self.templates)) | 59 | self.templates.update( dict((self.templates[k], k) for k in self.templates)) |
131 | @@ -440,7 +440,7 @@ | |||
132 | 440 | self.smsBodyEdit.textChanged.connect(self.qrencode) | 440 | self.smsBodyEdit.textChanged.connect(self.qrencode) |
133 | 441 | self.smsBodyEdit.textChanged.connect( | 441 | self.smsBodyEdit.textChanged.connect( |
134 | 442 | lambda: self.smsCharCount.setText( | 442 | lambda: self.smsCharCount.setText( |
136 | 443 | unicode(self.tr("characters count: %s - %d message(s)")) % ( | 443 | str(self.tr("characters count: %s - %d message(s)")) % ( |
137 | 444 | len(self.smsBodyEdit.toPlainText()), | 444 | len(self.smsBodyEdit.toPlainText()), |
138 | 445 | ceil(len(self.smsBodyEdit.toPlainText()) / 160.0) | 445 | ceil(len(self.smsBodyEdit.toPlainText()) / 160.0) |
139 | 446 | ) | 446 | ) |
140 | @@ -508,35 +508,35 @@ | |||
141 | 508 | fileName = kargs.get('fileName') | 508 | fileName = kargs.get('fileName') |
142 | 509 | #Functions to get the correct data | 509 | #Functions to get the correct data |
143 | 510 | data_fields = { | 510 | data_fields = { |
157 | 511 | "text": unicode(self.textEdit.toPlainText()), | 511 | "text": str(self.textEdit.toPlainText()), |
158 | 512 | "url": unicode(self.urlEdit.text()), | 512 | "url": str(self.urlEdit.text()), |
159 | 513 | "bookmark": ( unicode(self.bookmarkTitleEdit.text()), unicode(self.bookmarkUrlEdit.text()) ), | 513 | "bookmark": ( str(self.bookmarkTitleEdit.text()), str(self.bookmarkUrlEdit.text()) ), |
160 | 514 | "email": unicode(self.emailEdit.text()), | 514 | "email": str(self.emailEdit.text()), |
161 | 515 | "emailmessage": ( unicode(self.emailEdit.text()), unicode(self.emailSubjectEdit.text()), unicode(self.emailBodyEdit.toPlainText()) ), | 515 | "emailmessage": ( str(self.emailEdit.text()), str(self.emailSubjectEdit.text()), str(self.emailBodyEdit.toPlainText()) ), |
162 | 516 | "telephone": unicode(self.telephoneEdit.text()), | 516 | "telephone": str(self.telephoneEdit.text()), |
163 | 517 | "phonebook": (('N',unicode(self.phonebookNameEdit.text())), | 517 | "phonebook": (('N',str(self.phonebookNameEdit.text())), |
164 | 518 | ('TEL', unicode(self.phonebookTelEdit.text())), | 518 | ('TEL', str(self.phonebookTelEdit.text())), |
165 | 519 | ('EMAIL',unicode(self.phonebookEMailEdit.text())), | 519 | ('EMAIL',str(self.phonebookEMailEdit.text())), |
166 | 520 | ('NOTE', unicode(self.phonebookNoteEdit.text())), | 520 | ('NOTE', str(self.phonebookNoteEdit.text())), |
167 | 521 | ('BDAY', unicode(self.phonebookBirthdayEdit.date().toString("yyyyMMdd")) if self.phonebookBirthdayLabel.isChecked() else ""), #YYYYMMDD | 521 | ('BDAY', str(self.phonebookBirthdayEdit.date().toString("yyyyMMdd")) if self.phonebookBirthdayLabel.isChecked() else ""), #YYYYMMDD |
168 | 522 | ('ADR', unicode(self.phonebookAddressEdit.text())), #The fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order. | 522 | ('ADR', str(self.phonebookAddressEdit.text())), #The fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order. |
169 | 523 | ('URL', unicode(self.phonebookUrlEdit.text())), | 523 | ('URL', str(self.phonebookUrlEdit.text())), |
170 | 524 | # ('NICKNAME', ''), | 524 | # ('NICKNAME', ''), |
171 | 525 | ), | 525 | ), |
182 | 526 | "sms": ( unicode(self.smsNumberEdit.text()), unicode(self.smsBodyEdit.toPlainText()) ), | 526 | "sms": ( str(self.smsNumberEdit.text()), str(self.smsBodyEdit.toPlainText()) ), |
183 | 527 | "mms": ( unicode(self.mmsNumberEdit.text()), unicode(self.mmsBodyEdit.toPlainText()) ), | 527 | "mms": ( str(self.mmsNumberEdit.text()), str(self.mmsBodyEdit.toPlainText()) ), |
184 | 528 | "geo": ( unicode(self.geoLatEdit.text()), unicode(self.geoLongEdit.text()) ), | 528 | "geo": ( str(self.geoLatEdit.text()), str(self.geoLongEdit.text()) ), |
185 | 529 | "wifi": ( unicode(self.wifiSSIDEdit.text()), (u"WEP",u"WPA",u"nopass")[self.wifiEncryptionType.currentIndex()], unicode(self.wifiPasswordEdit.text())), | 529 | "wifi": ( str(self.wifiSSIDEdit.text()), (u"WEP",u"WPA",u"nopass")[self.wifiEncryptionType.currentIndex()], str(self.wifiPasswordEdit.text())), |
186 | 530 | "sepa": (unicode(self.sepaNameEdit.text()), | 530 | "sepa": (str(self.sepaNameEdit.text()), |
187 | 531 | unicode(self.sepaAccountEdit.text()), | 531 | str(self.sepaAccountEdit.text()), |
188 | 532 | unicode(self.sepaBNCEdit.text()), | 532 | str(self.sepaBNCEdit.text()), |
189 | 533 | unicode(self.sepaAmountEdit.text()), | 533 | str(self.sepaAmountEdit.text()), |
190 | 534 | unicode(self.sepaReasonEdit.text()), | 534 | str(self.sepaReasonEdit.text()), |
191 | 535 | unicode(self.sepaCurrencyEdit.text()) | 535 | str(self.sepaCurrencyEdit.text()) |
192 | 536 | ), | 536 | ), |
193 | 537 | } | 537 | } |
194 | 538 | 538 | ||
196 | 539 | data_type = unicode(self.templates[unicode(self.selector.currentText())]) | 539 | data_type = str(self.templates[str(self.selector.currentText())]) |
197 | 540 | data = data_fields[data_type] | 540 | data = data_fields[data_type] |
198 | 541 | 541 | ||
199 | 542 | level = (u'L',u'M',u'Q',u'H') | 542 | level = (u'L',u'M',u'Q',u'H') |
200 | @@ -545,14 +545,14 @@ | |||
201 | 545 | if data_type == 'emailmessage' and data[1] == '' and data[2] == '': | 545 | if data_type == 'emailmessage' and data[1] == '' and data[2] == '': |
202 | 546 | data_type = 'email' | 546 | data_type = 'email' |
203 | 547 | data = data_fields[data_type] | 547 | data = data_fields[data_type] |
205 | 548 | qr = QR(pixel_size = unicode(self.pixelSize.value()), | 548 | qr = QR(pixel_size = str(self.pixelSize.value()), |
206 | 549 | data = data, | 549 | data = data, |
209 | 550 | level = unicode(level[self.ecLevel.currentIndex()]), | 550 | level = str(level[self.ecLevel.currentIndex()]), |
210 | 551 | margin_size = unicode(self.marginSize.value()), | 551 | margin_size = str(self.marginSize.value()), |
211 | 552 | data_type = data_type, | 552 | data_type = data_type, |
212 | 553 | ) | 553 | ) |
213 | 554 | error = 1 | 554 | error = 1 |
215 | 555 | if type(fileName) is not unicode: | 555 | if type(fileName) is not str: |
216 | 556 | error = qr.encode() | 556 | error = qr.encode() |
217 | 557 | else: | 557 | else: |
218 | 558 | error = qr.encode(fileName) | 558 | error = qr.encode(fileName) |
219 | @@ -563,12 +563,12 @@ | |||
220 | 563 | if NOTIFY: | 563 | if NOTIFY: |
221 | 564 | n = pynotify.Notification( | 564 | n = pynotify.Notification( |
222 | 565 | "QtQR", | 565 | "QtQR", |
224 | 566 | unicode(self.tr("ERROR: Something went wrong while trying to generate the QR Code.")), | 566 | str(self.tr("ERROR: Something went wrong while trying to generate the QR Code.")), |
225 | 567 | "qtqr" | 567 | "qtqr" |
226 | 568 | ) | 568 | ) |
227 | 569 | n.show() | 569 | n.show() |
228 | 570 | else: | 570 | else: |
230 | 571 | print "Something went wrong while trying to generate the QR Code" | 571 | print ("Something went wrong while trying to generate the QR Code") |
231 | 572 | qr.destroy() | 572 | qr.destroy() |
232 | 573 | else: | 573 | else: |
233 | 574 | self.saveButton.setEnabled(False) | 574 | self.saveButton.setEnabled(False) |
234 | @@ -596,19 +596,19 @@ | |||
235 | 596 | and not fn.lower().endswith(u".utf8") \ | 596 | and not fn.lower().endswith(u".utf8") \ |
236 | 597 | and not fn.lower().endswith(u".ansiutf8"): | 597 | and not fn.lower().endswith(u".ansiutf8"): |
237 | 598 | fn += u".png" | 598 | fn += u".png" |
239 | 599 | self.qrencode(fileName=unicode(fn)) | 599 | self.qrencode(fileName=str(fn)) |
240 | 600 | if NOTIFY: | 600 | if NOTIFY: |
241 | 601 | n = pynotify.Notification( | 601 | n = pynotify.Notification( |
244 | 602 | unicode(self.tr("Save QR Code")), | 602 | str(self.tr("Save QR Code")), |
245 | 603 | unicode(self.tr("QR Code succesfully saved to %s")) % fn, | 603 | str(self.tr("QR Code succesfully saved to %s")) % fn, |
246 | 604 | "qtqr" | 604 | "qtqr" |
247 | 605 | ) | 605 | ) |
248 | 606 | n.show() | 606 | n.show() |
249 | 607 | else: | 607 | else: |
250 | 608 | QtWidgets.QMessageBox.information( | 608 | QtWidgets.QMessageBox.information( |
251 | 609 | self, | 609 | self, |
254 | 610 | unicode(self.tr('Save QRCode')), | 610 | str(self.tr('Save QRCode')), |
255 | 611 | unicode(self.tr('QRCode succesfully saved to <b>%s</b>.')) % fn | 611 | str(self.tr('QRCode succesfully saved to <b>%s</b>.')) % fn |
256 | 612 | ) | 612 | ) |
257 | 613 | 613 | ||
258 | 614 | def decodeFile(self, fn=None): | 614 | def decodeFile(self, fn=None): |
259 | @@ -619,7 +619,7 @@ | |||
260 | 619 | filter=self.tr('Images (*.png *.jpg);; All Files (*.*)') | 619 | filter=self.tr('Images (*.png *.jpg);; All Files (*.*)') |
261 | 620 | ) | 620 | ) |
262 | 621 | if fn: | 621 | if fn: |
264 | 622 | fn = unicode(fn) | 622 | fn = str(fn) |
265 | 623 | else: | 623 | else: |
266 | 624 | return | 624 | return |
267 | 625 | if os.path.isfile(fn): | 625 | if os.path.isfile(fn): |
268 | @@ -638,7 +638,7 @@ | |||
269 | 638 | QtWidgets.QMessageBox.information( | 638 | QtWidgets.QMessageBox.information( |
270 | 639 | self, | 639 | self, |
271 | 640 | self.tr('Decode File'), | 640 | self.tr('Decode File'), |
273 | 641 | unicode(self.tr('No QRCode could be found in file: <b>%s</b>.')) % fn | 641 | str(self.tr('No QRCode could be found in file: <b>%s</b>.')) % fn |
274 | 642 | ) | 642 | ) |
275 | 643 | qr.destroy() | 643 | qr.destroy() |
276 | 644 | else: | 644 | else: |
277 | @@ -652,26 +652,26 @@ | |||
278 | 652 | 652 | ||
279 | 653 | def showInfo(self, qr): | 653 | def showInfo(self, qr): |
280 | 654 | dt = qr.data_type | 654 | dt = qr.data_type |
282 | 655 | print dt.encode(u"utf-8") + ':', | 655 | print (str(dt) + ':', end='') |
283 | 656 | data = qr.data_decode[dt](qr.data) | 656 | data = qr.data_decode[dt](qr.data) |
284 | 657 | if type(data) == tuple: | 657 | if type(data) == tuple: |
285 | 658 | for d in data: | 658 | for d in data: |
287 | 659 | print d.encode(u"utf-8") | 659 | print (d.encode(u"utf-8")) |
288 | 660 | elif type(data) == dict: | 660 | elif type(data) == dict: |
289 | 661 | # FIX-ME: Print the decoded symbols | 661 | # FIX-ME: Print the decoded symbols |
293 | 662 | print "Dict" | 662 | print ("Dict") |
294 | 663 | print data.keys() | 663 | print (data.keys()) |
295 | 664 | print data.values() | 664 | print (data.values()) |
296 | 665 | else: | 665 | else: |
298 | 666 | print data.encode(u"utf-8") | 666 | print (data.encode(u"utf-8")) |
299 | 667 | msg = { | 667 | msg = { |
307 | 668 | 'text': lambda : unicode(self.tr("QRCode contains the following text:\n\n%s")) % (data), | 668 | 'text': lambda : str(self.tr("QRCode contains the following text:\n\n%s")) % (data), |
308 | 669 | 'url': lambda : unicode(self.tr("QRCode contains the following url address:\n\n%s")) % (data), | 669 | 'url': lambda : str(self.tr("QRCode contains the following url address:\n\n%s")) % (data), |
309 | 670 | 'bookmark': lambda: unicode(self.tr("QRCode contains a bookmark:\n\nTitle: %s\nURL: %s")) % (data), | 670 | 'bookmark': lambda: str(self.tr("QRCode contains a bookmark:\n\nTitle: %s\nURL: %s")) % (data), |
310 | 671 | 'email': lambda : unicode(self.tr("QRCode contains the following e-mail address:\n\n%s")) % (data), | 671 | 'email': lambda : str(self.tr("QRCode contains the following e-mail address:\n\n%s")) % (data), |
311 | 672 | 'emailmessage': lambda : unicode(self.tr("QRCode contains an e-mail message:\n\nTo: %s\nSubject: %s\nMessage: %s")) % (data), | 672 | 'emailmessage': lambda : str(self.tr("QRCode contains an e-mail message:\n\nTo: %s\nSubject: %s\nMessage: %s")) % (data), |
312 | 673 | 'telephone': lambda : unicode(self.tr("QRCode contains a telephone number: ")) + (data), | 673 | 'telephone': lambda : str(self.tr("QRCode contains a telephone number: ")) + (data), |
313 | 674 | 'phonebook': lambda : unicode(self.tr("QRCode contains a phonebook entry:\n\nName: %s\nTel: %s\nE-Mail: %s\nNote: %s\nBirthday: %s\nAddress: %s\nURL: %s")) % | 674 | 'phonebook': lambda : str(self.tr("QRCode contains a phonebook entry:\n\nName: %s\nTel: %s\nE-Mail: %s\nNote: %s\nBirthday: %s\nAddress: %s\nURL: %s")) % |
314 | 675 | (data.get('N') or "", | 675 | (data.get('N') or "", |
315 | 676 | data.get('TEL') or "", | 676 | data.get('TEL') or "", |
316 | 677 | data.get('EMAIL') or "", | 677 | data.get('EMAIL') or "", |
317 | @@ -679,11 +679,11 @@ | |||
318 | 679 | QtCore.QDate.fromString(data.get('BDAY') or "",'yyyyMMdd').toString(), | 679 | QtCore.QDate.fromString(data.get('BDAY') or "",'yyyyMMdd').toString(), |
319 | 680 | data.get('ADR') or "", | 680 | data.get('ADR') or "", |
320 | 681 | data.get('URL') or ""), | 681 | data.get('URL') or ""), |
326 | 682 | 'sms': lambda : unicode(self.tr("QRCode contains the following SMS message:\n\nTo: %s\nMessage: %s")) % (data), | 682 | 'sms': lambda : str(self.tr("QRCode contains the following SMS message:\n\nTo: %s\nMessage: %s")) % (data), |
327 | 683 | 'mms': lambda : unicode(self.tr("QRCode contains the following MMS message:\n\nTo: %s\nMessage: %s")) % (data), | 683 | 'mms': lambda : str(self.tr("QRCode contains the following MMS message:\n\nTo: %s\nMessage: %s")) % (data), |
328 | 684 | 'geo': lambda : unicode(self.tr("QRCode contains the following coordinates:\n\nLatitude: %s\nLongitude:%s")) % (data), | 684 | 'geo': lambda : str(self.tr("QRCode contains the following coordinates:\n\nLatitude: %s\nLongitude:%s")) % (data), |
329 | 685 | 'wifi': lambda : unicode(self.tr("QRCode contains the following WiFi Network Configuration:\n\nSSID: %s\nEncryption Type: %s\nPassword: %s")) % (data), | 685 | 'wifi': lambda : str(self.tr("QRCode contains the following WiFi Network Configuration:\n\nSSID: %s\nEncryption Type: %s\nPassword: %s")) % (data), |
330 | 686 | 'sepa': lambda : unicode(self.tr("QRCode contains the following Single Payment Information:\n\nName: %s\nAccount: %s\nBNC: %s\nAmmount: %s\nReason: %s\nCurrency: %s\n")) % ( | 686 | 'sepa': lambda : str(self.tr("QRCode contains the following Single Payment Information:\n\nName: %s\nAccount: %s\nBNC: %s\nAmmount: %s\nReason: %s\nCurrency: %s\n")) % ( |
331 | 687 | data.get('name')[0] or '', | 687 | data.get('name')[0] or '', |
332 | 688 | data.get('account')[0] or '', | 688 | data.get('account')[0] or '', |
333 | 689 | data.get('bnc')[0] or '', | 689 | data.get('bnc')[0] or '', |
334 | @@ -743,7 +743,7 @@ | |||
335 | 743 | link = data[1] | 743 | link = data[1] |
336 | 744 | else: | 744 | else: |
337 | 745 | link = qr.data_decode[qr.data_type](qr.data) | 745 | link = qr.data_decode[qr.data_type](qr.data) |
339 | 746 | print u"Opening " + link | 746 | print (u"Opening " + link) |
340 | 747 | QtGui.QDesktopServices.openUrl(QtCore.QUrl(link)) | 747 | QtGui.QDesktopServices.openUrl(QtCore.QUrl(link)) |
341 | 748 | elif rsp == 0: | 748 | elif rsp == 0: |
342 | 749 | #Edit the code | 749 | #Edit the code |
343 | @@ -813,6 +813,7 @@ | |||
344 | 813 | self.tabs.setCurrentIndex(tabIndex) | 813 | self.tabs.setCurrentIndex(tabIndex) |
345 | 814 | 814 | ||
346 | 815 | def decodeWebcam(self): | 815 | def decodeWebcam(self): |
347 | 816 | device = None | ||
348 | 816 | vdDialog = VideoDevices() | 817 | vdDialog = VideoDevices() |
349 | 817 | if len(vdDialog.videoDevices) == 1: | 818 | if len(vdDialog.videoDevices) == 1: |
350 | 818 | device = vdDialog.videoDevices[0][1] | 819 | device = vdDialog.videoDevices[0][1] |
351 | @@ -837,7 +838,7 @@ | |||
352 | 837 | QtWidgets.QMessageBox.about( | 838 | QtWidgets.QMessageBox.about( |
353 | 838 | self, | 839 | self, |
354 | 839 | self.tr("About QtQR"), | 840 | self.tr("About QtQR"), |
356 | 840 | unicode(self.tr('<h1>QtQR %s</h1><p>A simple software for creating and decoding QR Codes that uses python-qrtools as backend. Both are part of the <a href="https://launchpad.net/qr-tools">QR Tools</a> project.</p><p></p><p>This is Free Software: GNU-GPLv3</p><p></p><p>Please visit our website for more information and to check out the code:<br /><a href="https://code.launchpad.net/qr-tools/">https://code.launchpad.net/qr-tools/</p><p>copyright © Ramiro Algozino <<a href="mailto:algozino@gmail.com">algozino@gmail.com</a>></p>')) % __version__, | 841 | str(self.tr('<h1>QtQR %s</h1><p>A simple software for creating and decoding QR Codes that uses python-qrtools as backend. Both are part of the <a href="https://launchpad.net/qr-tools">QR Tools</a> project.</p><p></p><p>This is Free Software: GNU-GPLv3</p><p></p><p>Please visit our website for more information and to check out the code:<br /><a href="https://code.launchpad.net/qr-tools/">https://code.launchpad.net/qr-tools/</p><p>copyright © Ramiro Algozino <<a href="mailto:algozino@gmail.com">algozino@gmail.com</a>></p>')) % __version__, |
357 | 841 | ) | 842 | ) |
358 | 842 | 843 | ||
359 | 843 | def dragEnterEvent(self, event): | 844 | def dragEnterEvent(self, event): |
360 | @@ -848,9 +849,9 @@ | |||
361 | 848 | for url in event.mimeData().urls(): | 849 | for url in event.mimeData().urls(): |
362 | 849 | fn = url.toLocalFile() | 850 | fn = url.toLocalFile() |
363 | 850 | if fn: | 851 | if fn: |
365 | 851 | self.decodeFile(unicode(fn)) | 852 | self.decodeFile(str(fn)) |
366 | 852 | else: | 853 | else: |
368 | 853 | print "DEBUG: Downloading dropped file from %s" % url.toString() | 854 | print ("DEBUG: Downloading dropped file from %s" % url.toString() ) |
369 | 854 | self.NetAccessMgr.get(QtNetwork.QNetworkRequest(url)) | 855 | self.NetAccessMgr.get(QtNetwork.QNetworkRequest(url)) |
370 | 855 | # FIX-ME: We should check if the download gets timeout. | 856 | # FIX-ME: We should check if the download gets timeout. |
371 | 856 | # and notify that we are downloading, the download could | 857 | # and notify that we are downloading, the download could |
372 | @@ -861,7 +862,7 @@ | |||
373 | 861 | 862 | ||
374 | 862 | 863 | ||
375 | 863 | def handleNetworkData(self, QNetReply): | 864 | def handleNetworkData(self, QNetReply): |
377 | 864 | print "DEBUG: Finished downloading file." | 865 | print ("DEBUG: Finished downloading file.") |
378 | 865 | tmpfn = '/tmp/qrtemp.png' | 866 | tmpfn = '/tmp/qrtemp.png' |
379 | 866 | fn = open(tmpfn,"w") | 867 | fn = open(tmpfn,"w") |
380 | 867 | fn.write(QNetReply.readAll()) | 868 | fn.write(QNetReply.readAll()) |
381 | @@ -869,10 +870,10 @@ | |||
382 | 869 | self.decodeFile(tmpfn) | 870 | self.decodeFile(tmpfn) |
383 | 870 | 871 | ||
384 | 871 | def toggleShowPassword(self, status): | 872 | def toggleShowPassword(self, status): |
389 | 872 | if status == 0: | 873 | if status == 0: |
390 | 873 | self.wifiPasswordEdit.setEchoMode(QtWidgets.QLineEdit.Password) | 874 | self.wifiPasswordEdit.setEchoMode(QtWidgets.QLineEdit.Password) |
391 | 874 | elif status == 2: | 875 | elif status == 2: |
392 | 875 | self.wifiPasswordEdit.setEchoMode(QtWidgets.QLineEdit.Normal) | 876 | self.wifiPasswordEdit.setEchoMode(QtWidgets.QLineEdit.Normal) |
393 | 876 | 877 | ||
394 | 877 | class VideoDevices(QtWidgets.QDialog): | 878 | class VideoDevices(QtWidgets.QDialog): |
395 | 878 | def __init__(self): | 879 | def __init__(self): |
396 | @@ -924,7 +925,7 @@ | |||
397 | 924 | app = QtWidgets.QApplication(sys.argv) | 925 | app = QtWidgets.QApplication(sys.argv) |
398 | 925 | # This is to make Qt use locale configuration; i.e. Standard Buttons | 926 | # This is to make Qt use locale configuration; i.e. Standard Buttons |
399 | 926 | # in your system's language. | 927 | # in your system's language. |
401 | 927 | locale = unicode(QtCore.QLocale.system().name()) | 928 | locale = str(QtCore.QLocale.system().name()) |
402 | 928 | translator=QtCore.QTranslator() | 929 | translator=QtCore.QTranslator() |
403 | 929 | # translator.load(os.path.join(os.path.abspath( | 930 | # translator.load(os.path.join(os.path.abspath( |
404 | 930 | # os.path.dirname(__file__)), | 931 | # os.path.dirname(__file__)), |
Lgtm. The packaging is pending yet though.
Thank you very much for your collaboration!