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.did = did
def doExport(self, path):
raise Exception("not implemented")
def exportInto(self, path):
self._escapeCount = 0
file = open(path, "wb")

View file

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

View file

@ -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

View file

@ -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."

View file

@ -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

View file

@ -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])

View file

@ -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()
#

View file

@ -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]))

View file

@ -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

View file

@ -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

View file

@ -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</button>''' % (
self.setWindowState(self.windowState() & ~Qt.WindowMinimized)
return True
def setStatus(self, text, timeout=3000):
self.form.statusbar.showMessage(text, timeout)
def setupStyle(self):
buf = ""

View file

@ -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

View file

@ -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()

View file

@ -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
######################################################################