silence some spurious errors and remove some unused code

This commit is contained in:
Damien Elmes 2019-03-04 11:22:40 +10:00
parent 10ab258501
commit 3721cc4604
14 changed files with 32 additions and 23 deletions

View file

@ -14,6 +14,9 @@ class Exporter:
self.col = col self.col = col
self.did = did self.did = did
def doExport(self, path):
raise Exception("not implemented")
def exportInto(self, path): def exportInto(self, path):
self._escapeCount = 0 self._escapeCount = 0
file = open(path, "wb") file = open(path, "wb")

View file

@ -17,6 +17,7 @@ class Importer:
self.log = [] self.log = []
self.col = col self.col = col
self.total = 0 self.total = 0
self.dst = None
def run(self): def run(self):
pass pass

View file

@ -6,7 +6,7 @@ import time, re
from anki.db import DB from anki.db import DB
from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard
from anki.stdmodels import addBasicModel, addClozeModel from anki.stdmodels import addBasicModel, addClozeModel
from anki.lang import ngettext from anki.lang import ngettext, _
class MnemosyneImporter(NoteImporter): 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"""): f._id=d._fact_id"""):
if id != curid: if id != curid:
if note: if note:
# pylint: disable=unsubscriptable-object
notes[note['_id']] = note notes[note['_id']] = note
note = {'_id': _id} note = {'_id': _id}
curid = id curid = id

View file

@ -85,7 +85,7 @@ class NoteImporter(Importer):
def foreignNotes(self): def foreignNotes(self):
"Return a list of foreign notes for importing." "Return a list of foreign notes for importing."
assert 0 return []
def open(self): def open(self):
"Open file and ensure it's in the right format." "Open file and ensure it's in the right format."

View file

@ -431,17 +431,17 @@ class SupermemoXmlImporter(NoteImporter):
self.cntElm[-1][node.tagName]=self.cntBuf.pop() self.cntElm[-1][node.tagName]=self.cntBuf.pop()
if __name__ == '__main__': #if __name__ == '__main__':
# for testing you can start it standalone # 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/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_noOEM.xml'
#file = u'/home/epcim/hg2g/dev/python/anki/libanki/tests/importing/supermemo/original_ENGLISHFORBEGGINERS_oem_1250.xml' #file = u'/home/epcim/hg2g/dev/python/anki/libanki/tests/importing/supermemo/original_ENGLISHFORBEGGINERS_oem_1250.xml'
file = str(sys.argv[1]) #file = str(sys.argv[1])
impo = SupermemoXmlImporter(Deck(),file) #impo = SupermemoXmlImporter(Deck(),file)
impo.foreignCards() #impo.foreignCards()
sys.exit(1) #sys.exit(1)
# vim: ts=4 sts=2 ft=python # vim: ts=4 sts=2 ft=python

View file

@ -15,6 +15,7 @@ from anki.utils import checksum, isWin, isMac, json
from anki.db import DB, DBError from anki.db import DB, DBError
from anki.consts import * from anki.consts import *
from anki.latex import mungeQA from anki.latex import mungeQA
from anki.lang import _
class MediaManager: class MediaManager:
@ -125,6 +126,7 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0);
def _isFAT32(self): def _isFAT32(self):
if not isWin: if not isWin:
return return
# pylint: disable=import-error
import win32api, win32file import win32api, win32file
try: try:
name = win32file.GetVolumeNameForVolumeMountPoint(self._dir[:3]) name = win32file.GetVolumeNameForVolumeMountPoint(self._dir[:3])

View file

@ -36,7 +36,7 @@ import threading
import subprocess import subprocess
import inspect 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 from queue import Queue, Empty, Full
@ -57,6 +57,7 @@ class MPVTimeoutError(MPVError):
from anki.utils import isWin from anki.utils import isWin
if isWin: if isWin:
# pylint: disable=import-error
import win32file, win32pipe, pywintypes, winerror import win32file, win32pipe, pywintypes, winerror
class MPVBase: class MPVBase:
@ -438,6 +439,7 @@ class MPV(MPVBase):
# Simulate an init event when the process and all callbacks have been # Simulate an init event when the process and all callbacks have been
# completely set up. # completely set up.
if hasattr(self, "on_init"): if hasattr(self, "on_init"):
# pylint: disable=no-member
self.on_init() self.on_init()
# #

View file

@ -7,6 +7,7 @@ import re, sys, threading, time, subprocess, os, atexit
import random import random
from anki.hooks import addHook, runHook from anki.hooks import addHook, runHook
from anki.utils import tmpdir, isWin, isMac, isLin from anki.utils import tmpdir, isWin, isMac, isLin
from anki.lang import _
# Shared utils # Shared utils
########################################################################## ##########################################################################
@ -68,6 +69,7 @@ if isWin:
try: try:
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
except: except:
# pylint: disable=no-member
# python2.7+ # python2.7+
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
else: else:
@ -145,6 +147,7 @@ def cleanupMPV():
# if anki crashes, an old mplayer instance may be left lying around, # if anki crashes, an old mplayer instance may be left lying around,
# which prevents renaming or deleting the profile # which prevents renaming or deleting the profile
def cleanupOldMplayerProcesses(): def cleanupOldMplayerProcesses():
# pylint: disable=import-error
import psutil import psutil
exeDir = os.path.dirname(os.path.abspath(sys.argv[0])) exeDir = os.path.dirname(os.path.abspath(sys.argv[0]))

View file

@ -330,6 +330,7 @@ def call(argv, wait=True, **kwargs):
try: try:
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
except: except:
# pylint: disable=no-member
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
else: else:
si = None si = None

View file

@ -287,20 +287,20 @@ def onImport(mw):
importFile(mw, file) importFile(mw, file)
def importFile(mw, file): def importFile(mw, file):
importer = None importerClass = None
done = False done = False
for i in importing.Importers: for i in importing.Importers:
if done: if done:
break break
for mext in re.findall("[( ]?\*\.(.+?)[) ]", i[0]): for mext in re.findall("[( ]?\*\.(.+?)[) ]", i[0]):
if file.endswith("." + mext): if file.endswith("." + mext):
importer = i[1] importerClass = i[1]
done = True done = True
break break
if not importer: if not importerClass:
# if no matches, assume TSV # if no matches, assume TSV
importer = importing.Importers[0][1] importerClass = importing.Importers[0][1]
importer = importer(mw.col, file) importer = importerClass(mw.col, file)
# need to show import dialog? # need to show import dialog?
if importer.needMapper: if importer.needMapper:
# make sure we can load the file first # make sure we can load the file first

View file

@ -29,7 +29,7 @@ import anki.mpv
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \ from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
restoreState, getOnlyText, askUser, showText, tooltip, \ restoreState, getOnlyText, askUser, showText, tooltip, \
openHelp, openLink, checkInvalidFilename, getFile openHelp, openLink, checkInvalidFilename, getFile
import sip from aqt.qt import sip
class AnkiQt(QMainWindow): class AnkiQt(QMainWindow):
def __init__(self, app, profileManager, opts, args): def __init__(self, app, profileManager, opts, args):
@ -462,6 +462,7 @@ from the profile screen."))
oldState = self.state or "dummy" oldState = self.state or "dummy"
cleanup = getattr(self, "_"+oldState+"Cleanup", None) cleanup = getattr(self, "_"+oldState+"Cleanup", None)
if cleanup: if cleanup:
# pylint: disable=not-callable
cleanup(state) cleanup(state)
self.clearStateShortcuts() self.clearStateShortcuts()
self.state = state self.state = state
@ -693,9 +694,6 @@ title="%s" %s>%s</button>''' % (
self.setWindowState(self.windowState() & ~Qt.WindowMinimized) self.setWindowState(self.windowState() & ~Qt.WindowMinimized)
return True return True
def setStatus(self, text, timeout=3000):
self.form.statusbar.showMessage(text, timeout)
def setupStyle(self): def setupStyle(self):
buf = "" buf = ""

View file

@ -4,6 +4,8 @@
# this file is imported as part of the bundling process to ensure certain # this file is imported as part of the bundling process to ensure certain
# modules are included in the distribution # modules are included in the distribution
# pylint: disable=import-error
# required by requests library # required by requests library
import queue import queue

View file

@ -19,8 +19,9 @@ try:
except ImportError: except ImportError:
import sip import sip
from PyQt5.QtCore import pyqtRemoveInputHook # pylint: disable=no-name-in-module
def debug(): def debug():
from PyQt5.QtCore import pyqtRemoveInputHook
from pdb import set_trace from pdb import set_trace
pyqtRemoveInputHook() pyqtRemoveInputHook()
set_trace() set_trace()
@ -29,7 +30,6 @@ import sys, traceback
if os.environ.get("DEBUG"): if os.environ.get("DEBUG"):
def info(type, value, tb): def info(type, value, tb):
from PyQt5.QtCore import pyqtRemoveInputHook
for line in traceback.format_exception(type, value, tb): for line in traceback.format_exception(type, value, tb):
sys.stdout.write(line) sys.stdout.write(line)
pyqtRemoveInputHook() pyqtRemoveInputHook()

View file

@ -284,10 +284,6 @@ fix the clock and try again."""))
Your collection is in an inconsistent state. Please run Tools>\ Your collection is in an inconsistent state. Please run Tools>\
Check Database, then sync again.""")) Check Database, then sync again."""))
def badUserPass(self):
aqt.preferences.Preferences(self, self.pm.profile).dialog.tabWidget.\
setCurrentIndex(1)
# Sync thread # Sync thread
###################################################################### ######################################################################