diff --git a/anki/exporting.py b/anki/exporting.py index ce8002684..6e5dfb74f 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -14,6 +14,9 @@ class Exporter: self.col = col self.did = did + def doExport(self, path): + raise Exception("not implemented") + def exportInto(self, path): self._escapeCount = 0 file = open(path, "wb") diff --git a/anki/importing/base.py b/anki/importing/base.py index 31c2014af..49f063121 100644 --- a/anki/importing/base.py +++ b/anki/importing/base.py @@ -17,6 +17,7 @@ class Importer: self.log = [] self.col = col self.total = 0 + self.dst = None def run(self): pass diff --git a/anki/importing/mnemo.py b/anki/importing/mnemo.py index 7cd3251ed..f1be90e88 100644 --- a/anki/importing/mnemo.py +++ b/anki/importing/mnemo.py @@ -6,7 +6,7 @@ import time, re from anki.db import DB from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard from anki.stdmodels import addBasicModel, addClozeModel -from anki.lang import ngettext +from anki.lang import ngettext, _ class MnemosyneImporter(NoteImporter): @@ -29,6 +29,7 @@ select _id, id, key, value from facts f, data_for_fact d where f._id=d._fact_id"""): if id != curid: if note: + # pylint: disable=unsubscriptable-object notes[note['_id']] = note note = {'_id': _id} curid = id diff --git a/anki/importing/noteimp.py b/anki/importing/noteimp.py index 79d74999a..b4ef9a852 100644 --- a/anki/importing/noteimp.py +++ b/anki/importing/noteimp.py @@ -85,7 +85,7 @@ class NoteImporter(Importer): def foreignNotes(self): "Return a list of foreign notes for importing." - assert 0 + return [] def open(self): "Open file and ensure it's in the right format." diff --git a/anki/importing/supermemo_xml.py b/anki/importing/supermemo_xml.py index fcffee2f1..4eb66ee78 100644 --- a/anki/importing/supermemo_xml.py +++ b/anki/importing/supermemo_xml.py @@ -431,17 +431,17 @@ class SupermemoXmlImporter(NoteImporter): self.cntElm[-1][node.tagName]=self.cntBuf.pop() -if __name__ == '__main__': +#if __name__ == '__main__': # for testing you can start it standalone #file = u'/home/epcim/hg2g/dev/python/sm2anki/ADVENG2EXP.xxe.esc.zaloha_FINAL.xml' #file = u'/home/epcim/hg2g/dev/python/anki/libanki/tests/importing/supermemo/original_ENGLISHFORBEGGINERS_noOEM.xml' #file = u'/home/epcim/hg2g/dev/python/anki/libanki/tests/importing/supermemo/original_ENGLISHFORBEGGINERS_oem_1250.xml' - file = str(sys.argv[1]) - impo = SupermemoXmlImporter(Deck(),file) - impo.foreignCards() + #file = str(sys.argv[1]) + #impo = SupermemoXmlImporter(Deck(),file) + #impo.foreignCards() - sys.exit(1) + #sys.exit(1) # vim: ts=4 sts=2 ft=python diff --git a/anki/media.py b/anki/media.py index df1a5ee11..a2c33026a 100644 --- a/anki/media.py +++ b/anki/media.py @@ -15,6 +15,7 @@ from anki.utils import checksum, isWin, isMac, json from anki.db import DB, DBError from anki.consts import * from anki.latex import mungeQA +from anki.lang import _ class MediaManager: @@ -125,6 +126,7 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0); def _isFAT32(self): if not isWin: return + # pylint: disable=import-error import win32api, win32file try: name = win32file.GetVolumeNameForVolumeMountPoint(self._dir[:3]) diff --git a/anki/mpv.py b/anki/mpv.py index 93137386f..75460cc48 100644 --- a/anki/mpv.py +++ b/anki/mpv.py @@ -36,7 +36,7 @@ import threading import subprocess import inspect -from distutils.spawn import find_executable +from distutils.spawn import find_executable # pylint: disable=import-error,no-name-in-module from queue import Queue, Empty, Full @@ -57,6 +57,7 @@ class MPVTimeoutError(MPVError): from anki.utils import isWin if isWin: + # pylint: disable=import-error import win32file, win32pipe, pywintypes, winerror class MPVBase: @@ -438,6 +439,7 @@ class MPV(MPVBase): # Simulate an init event when the process and all callbacks have been # completely set up. if hasattr(self, "on_init"): + # pylint: disable=no-member self.on_init() # diff --git a/anki/sound.py b/anki/sound.py index 147fe606c..2934b04db 100644 --- a/anki/sound.py +++ b/anki/sound.py @@ -7,6 +7,7 @@ import re, sys, threading, time, subprocess, os, atexit import random from anki.hooks import addHook, runHook from anki.utils import tmpdir, isWin, isMac, isLin +from anki.lang import _ # Shared utils ########################################################################## @@ -68,6 +69,7 @@ if isWin: try: si.dwFlags |= subprocess.STARTF_USESHOWWINDOW except: + # pylint: disable=no-member # python2.7+ si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW else: @@ -145,6 +147,7 @@ def cleanupMPV(): # if anki crashes, an old mplayer instance may be left lying around, # which prevents renaming or deleting the profile def cleanupOldMplayerProcesses(): + # pylint: disable=import-error import psutil exeDir = os.path.dirname(os.path.abspath(sys.argv[0])) diff --git a/anki/utils.py b/anki/utils.py index 05cdf3126..4d50d25c2 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -330,6 +330,7 @@ def call(argv, wait=True, **kwargs): try: si.dwFlags |= subprocess.STARTF_USESHOWWINDOW except: + # pylint: disable=no-member si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW else: si = None diff --git a/aqt/importing.py b/aqt/importing.py index fb63bd029..57040cdaa 100644 --- a/aqt/importing.py +++ b/aqt/importing.py @@ -287,20 +287,20 @@ def onImport(mw): importFile(mw, file) def importFile(mw, file): - importer = None + importerClass = None done = False for i in importing.Importers: if done: break for mext in re.findall("[( ]?\*\.(.+?)[) ]", i[0]): if file.endswith("." + mext): - importer = i[1] + importerClass = i[1] done = True break - if not importer: + if not importerClass: # if no matches, assume TSV - importer = importing.Importers[0][1] - importer = importer(mw.col, file) + importerClass = importing.Importers[0][1] + importer = importerClass(mw.col, file) # need to show import dialog? if importer.needMapper: # make sure we can load the file first diff --git a/aqt/main.py b/aqt/main.py index 279e9f1d2..83e56c27b 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -29,7 +29,7 @@ import anki.mpv from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \ restoreState, getOnlyText, askUser, showText, tooltip, \ openHelp, openLink, checkInvalidFilename, getFile -import sip +from aqt.qt import sip class AnkiQt(QMainWindow): def __init__(self, app, profileManager, opts, args): @@ -462,6 +462,7 @@ from the profile screen.")) oldState = self.state or "dummy" cleanup = getattr(self, "_"+oldState+"Cleanup", None) if cleanup: + # pylint: disable=not-callable cleanup(state) self.clearStateShortcuts() self.state = state @@ -693,9 +694,6 @@ title="%s" %s>%s''' % ( self.setWindowState(self.windowState() & ~Qt.WindowMinimized) return True - def setStatus(self, text, timeout=3000): - self.form.statusbar.showMessage(text, timeout) - def setupStyle(self): buf = "" diff --git a/aqt/pinnedmodules.py b/aqt/pinnedmodules.py index 7ee387e44..b8d034b92 100644 --- a/aqt/pinnedmodules.py +++ b/aqt/pinnedmodules.py @@ -4,6 +4,8 @@ # this file is imported as part of the bundling process to ensure certain # modules are included in the distribution +# pylint: disable=import-error + # required by requests library import queue diff --git a/aqt/qt.py b/aqt/qt.py index 4936c300a..1b993dec0 100644 --- a/aqt/qt.py +++ b/aqt/qt.py @@ -19,8 +19,9 @@ try: except ImportError: import sip +from PyQt5.QtCore import pyqtRemoveInputHook # pylint: disable=no-name-in-module + def debug(): - from PyQt5.QtCore import pyqtRemoveInputHook from pdb import set_trace pyqtRemoveInputHook() set_trace() @@ -29,7 +30,6 @@ import sys, traceback if os.environ.get("DEBUG"): def info(type, value, tb): - from PyQt5.QtCore import pyqtRemoveInputHook for line in traceback.format_exception(type, value, tb): sys.stdout.write(line) pyqtRemoveInputHook() diff --git a/aqt/sync.py b/aqt/sync.py index cec2452be..17e76a0ca 100644 --- a/aqt/sync.py +++ b/aqt/sync.py @@ -284,10 +284,6 @@ fix the clock and try again.""")) Your collection is in an inconsistent state. Please run Tools>\ Check Database, then sync again.""")) - def badUserPass(self): - aqt.preferences.Preferences(self, self.pm.profile).dialog.tabWidget.\ - setCurrentIndex(1) - # Sync thread ######################################################################