diff --git a/AnkiConnect.py b/AnkiConnect.py index 5290fbe..1afd0b9 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -23,6 +23,7 @@ import json import os.path import select import socket +import sys # @@ -42,25 +43,21 @@ NET_PORT = 8765 # General helpers # -try: +if sys.version_info[0] < 3: import urllib2 web = urllib2 -except ImportError: + + from PyQt4.QtCore import QTimer + from PyQt4.QtGui import QMessageBox +else: + unicode = str + from urllib import request web = request -try: - from PyQt4.QtCore import QTimer - from PyQt4.QtGui import QMessageBox -except ImportError: from PyQt5.QtCore import QTimer from PyQt5.QtWidgets import QMessageBox -try: - unicode -except: - unicode = str - # # Helpers