fix some warnings
This commit is contained in:
parent
7755eb408c
commit
f6b2135129
@ -128,8 +128,10 @@ class DeckManager:
|
|||||||
# Deck save/load
|
# Deck save/load
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
def id(self, name, create=True, type=defaultDeck):
|
def id(self, name, create=True, type=None):
|
||||||
"Add a deck with NAME. Reuse deck if already exists. Return id as int."
|
"Add a deck with NAME. Reuse deck if already exists. Return id as int."
|
||||||
|
if type is None:
|
||||||
|
type = defaultDeck
|
||||||
name = name.replace('"', '')
|
name = name.replace('"', '')
|
||||||
name = unicodedata.normalize("NFC", name)
|
name = unicodedata.normalize("NFC", name)
|
||||||
for id, g in list(self.decks.items()):
|
for id, g in list(self.decks.items()):
|
||||||
@ -353,8 +355,10 @@ class DeckManager:
|
|||||||
self.dconf[str(g['id'])] = g
|
self.dconf[str(g['id'])] = g
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def confId(self, name, cloneFrom=defaultConf):
|
def confId(self, name, cloneFrom=None):
|
||||||
"Create a new configuration and return id."
|
"Create a new configuration and return id."
|
||||||
|
if cloneFrom is None:
|
||||||
|
type = defaultConf
|
||||||
c = copy.deepcopy(cloneFrom)
|
c = copy.deepcopy(cloneFrom)
|
||||||
while 1:
|
while 1:
|
||||||
id = intTime(1000)
|
id = intTime(1000)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
class AnkiError(Exception):
|
class AnkiError(Exception):
|
||||||
def __init__(self, type, **data):
|
def __init__(self, type, **data):
|
||||||
|
super().__init__()
|
||||||
self.type = type
|
self.type = type
|
||||||
self.data = data
|
self.data = data
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -14,6 +15,7 @@ class AnkiError(Exception):
|
|||||||
|
|
||||||
class DeckRenameError(Exception):
|
class DeckRenameError(Exception):
|
||||||
def __init__(self, description):
|
def __init__(self, description):
|
||||||
|
super().__init__()
|
||||||
self.description = description
|
self.description = description
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Couldn't rename deck: " + self.description
|
return "Couldn't rename deck: " + self.description
|
||||||
|
@ -277,6 +277,7 @@ class AnkiPackageExporter(AnkiExporter):
|
|||||||
raise Exception("Please switch to the normal scheduler before exporting a single deck with scheduling information.")
|
raise Exception("Please switch to the normal scheduler before exporting a single deck with scheduling information.")
|
||||||
|
|
||||||
# prevent older clients from accessing
|
# prevent older clients from accessing
|
||||||
|
# pylint: disable=unreachable
|
||||||
self._addDummyCollection(z)
|
self._addDummyCollection(z)
|
||||||
z.write(colfile, "collection.anki21")
|
z.write(colfile, "collection.anki21")
|
||||||
|
|
||||||
|
@ -173,6 +173,7 @@ acq_reps+ret_reps, lapses, card_type_id from cards"""):
|
|||||||
fld = re.sub("\r?\n", "<br>", fld)
|
fld = re.sub("\r?\n", "<br>", fld)
|
||||||
state = dict(n=1)
|
state = dict(n=1)
|
||||||
def repl(match):
|
def repl(match):
|
||||||
|
# pylint: disable=cell-var-from-loop
|
||||||
# replace [...] with cloze refs
|
# replace [...] with cloze refs
|
||||||
res = ("{{c%d::%s}}" % (state['n'], match.group(1)))
|
res = ("{{c%d::%s}}" % (state['n'], match.group(1)))
|
||||||
state['n'] += 1
|
state['n'] += 1
|
||||||
|
@ -140,7 +140,6 @@ def _errMsg(type, texpath):
|
|||||||
msg += "<small><pre>" + html.escape(log) + "</pre></small>"
|
msg += "<small><pre>" + html.escape(log) + "</pre></small>"
|
||||||
except:
|
except:
|
||||||
msg += _("Have you installed latex and dvipng/dvisvgm?")
|
msg += _("Have you installed latex and dvipng/dvisvgm?")
|
||||||
pass
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
# setup q/a filter
|
# setup q/a filter
|
||||||
|
@ -1390,6 +1390,7 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
|||||||
random.shuffle(nids)
|
random.shuffle(nids)
|
||||||
for c, nid in enumerate(nids):
|
for c, nid in enumerate(nids):
|
||||||
due[nid] = start+c*step
|
due[nid] = start+c*step
|
||||||
|
# pylint: disable=undefined-loop-variable
|
||||||
high = start+c*step
|
high = start+c*step
|
||||||
# shift?
|
# shift?
|
||||||
if shift:
|
if shift:
|
||||||
|
@ -1531,6 +1531,7 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
|||||||
random.shuffle(nids)
|
random.shuffle(nids)
|
||||||
for c, nid in enumerate(nids):
|
for c, nid in enumerate(nids):
|
||||||
due[nid] = start+c*step
|
due[nid] = start+c*step
|
||||||
|
# pylint: disable=undefined-loop-variable
|
||||||
high = start+c*step
|
high = start+c*step
|
||||||
# shift?
|
# shift?
|
||||||
if shift:
|
if shift:
|
||||||
|
@ -21,6 +21,7 @@ class CardStats:
|
|||||||
|
|
||||||
def report(self):
|
def report(self):
|
||||||
c = self.card
|
c = self.card
|
||||||
|
# pylint: disable=unnecessary-lambda
|
||||||
fmt = lambda x, **kwargs: fmtTimeSpan(x, short=True, **kwargs)
|
fmt = lambda x, **kwargs: fmtTimeSpan(x, short=True, **kwargs)
|
||||||
self.txt = "<table width=100%>"
|
self.txt = "<table width=100%>"
|
||||||
self.addLine(_("Added"), self.date(c.id/1000))
|
self.addLine(_("Added"), self.date(c.id/1000))
|
||||||
@ -809,8 +810,10 @@ from cards where did in %s""" % self._limit())
|
|||||||
# Tools
|
# Tools
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def _graph(self, id, data, conf={},
|
def _graph(self, id, data, conf=None,
|
||||||
type="bars", ylabel=_("Cards"), timeTicks=True, ylabel2=""):
|
type="bars", ylabel=_("Cards"), timeTicks=True, ylabel2=""):
|
||||||
|
if conf is None:
|
||||||
|
conf = {}
|
||||||
# display settings
|
# display settings
|
||||||
if type == "pie":
|
if type == "pie":
|
||||||
conf['legend'] = {'container': "#%sLegend" % id, 'noColumns':2}
|
conf['legend'] = {'container': "#%sLegend" % id, 'noColumns':2}
|
||||||
|
@ -733,7 +733,8 @@ class MediaSyncer:
|
|||||||
need.append(fname)
|
need.append(fname)
|
||||||
else:
|
else:
|
||||||
self.col.log("have same already")
|
self.col.log("have same already")
|
||||||
ldirty and self.col.media.markClean([fname])
|
if ldirty:
|
||||||
|
self.col.media.markClean([fname])
|
||||||
elif lsum:
|
elif lsum:
|
||||||
# deleted remotely
|
# deleted remotely
|
||||||
if not ldirty:
|
if not ldirty:
|
||||||
@ -745,7 +746,8 @@ class MediaSyncer:
|
|||||||
else:
|
else:
|
||||||
# deleted both sides
|
# deleted both sides
|
||||||
self.col.log("both sides deleted")
|
self.col.log("both sides deleted")
|
||||||
ldirty and self.col.media.markClean([fname])
|
if ldirty:
|
||||||
|
self.col.media.markClean([fname])
|
||||||
|
|
||||||
self._downloadFiles(need)
|
self._downloadFiles(need)
|
||||||
|
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from anki.utils import intTime, ids2str, json
|
|
||||||
from anki.hooks import runHook
|
|
||||||
import re
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Anki maintains a cache of used tags so it can quickly present a list of tags
|
Anki maintains a cache of used tags so it can quickly present a list of tags
|
||||||
for autocomplete and in the browser. For efficiency, deletions are not
|
for autocomplete and in the browser. For efficiency, deletions are not
|
||||||
@ -14,6 +10,10 @@ tracked, so unused tags can only be removed from the list with a DB check.
|
|||||||
This module manages the tag cache and tags for notes.
|
This module manages the tag cache and tags for notes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from anki.utils import intTime, ids2str, json
|
||||||
|
from anki.hooks import runHook
|
||||||
|
import re
|
||||||
|
|
||||||
class TagManager:
|
class TagManager:
|
||||||
|
|
||||||
# Registry save/load
|
# Registry save/load
|
||||||
|
@ -360,7 +360,7 @@ def call(argv, wait=True, **kwargs):
|
|||||||
isMac = sys.platform.startswith("darwin")
|
isMac = sys.platform.startswith("darwin")
|
||||||
isWin = sys.platform.startswith("win32")
|
isWin = sys.platform.startswith("win32")
|
||||||
isLin = not isMac and not isWin
|
isLin = not isMac and not isWin
|
||||||
devMode = os.getenv("ANKIDEV", 0)
|
devMode = os.getenv("ANKIDEV", "")
|
||||||
|
|
||||||
invalidFilenameChars = ":*?\"<>|"
|
invalidFilenameChars = ":*?\"<>|"
|
||||||
|
|
||||||
|
@ -411,6 +411,7 @@ class Browser(QMainWindow):
|
|||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def setupMenus(self):
|
def setupMenus(self):
|
||||||
|
# pylint: disable=unnecessary-lambda
|
||||||
# actions
|
# actions
|
||||||
f = self.form
|
f = self.form
|
||||||
f.previewButton.clicked.connect(self.onTogglePreview)
|
f.previewButton.clicked.connect(self.onTogglePreview)
|
||||||
@ -808,8 +809,8 @@ by clicking on one on the left."""))
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
QTreeWidget.__init__(self)
|
QTreeWidget.__init__(self)
|
||||||
self.itemClicked.connect(self.onTreeClick)
|
self.itemClicked.connect(self.onTreeClick)
|
||||||
self.itemExpanded.connect(lambda item: self.onTreeCollapse(item))
|
self.itemExpanded.connect(self.onTreeCollapse)
|
||||||
self.itemCollapsed.connect(lambda item: self.onTreeCollapse(item))
|
self.itemCollapsed.connect(self.onTreeCollapse)
|
||||||
|
|
||||||
def keyPressEvent(self, evt):
|
def keyPressEvent(self, evt):
|
||||||
if evt.key() in (Qt.Key_Return, Qt.Key_Enter):
|
if evt.key() in (Qt.Key_Return, Qt.Key_Enter):
|
||||||
|
@ -31,6 +31,7 @@ class EditCurrent(QDialog):
|
|||||||
self.mw.requireReset()
|
self.mw.requireReset()
|
||||||
self.show()
|
self.show()
|
||||||
# reset focus after open, taking care not to retain webview
|
# reset focus after open, taking care not to retain webview
|
||||||
|
# pylint: disable=unnecessary-lambda
|
||||||
self.mw.progress.timer(100, lambda: self.editor.web.setFocus(), False)
|
self.mw.progress.timer(100, lambda: self.editor.web.setFocus(), False)
|
||||||
|
|
||||||
def onReset(self):
|
def onReset(self):
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import urllib.request, urllib.error, urllib.parse
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import urllib.request, urllib.parse, urllib.error
|
import urllib.request, urllib.parse, urllib.error
|
||||||
import warnings
|
import warnings
|
||||||
@ -126,7 +125,7 @@ class Editor:
|
|||||||
mime, _ = mimetypes.guess_type(path)
|
mime, _ = mimetypes.guess_type(path)
|
||||||
with open(path, 'rb') as fp:
|
with open(path, 'rb') as fp:
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
data64 = b''.join(base64.encodestring(data).splitlines())
|
data64 = b''.join(base64.encodebytes(data).splitlines())
|
||||||
return 'data:%s;base64,%s' % (mime, data64.decode('ascii'))
|
return 'data:%s;base64,%s' % (mime, data64.decode('ascii'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import aqt.webview
|
|||||||
import aqt.toolbar
|
import aqt.toolbar
|
||||||
import aqt.stats
|
import aqt.stats
|
||||||
import aqt.mediasrv
|
import aqt.mediasrv
|
||||||
from aqt.utils import showWarning
|
|
||||||
import anki.sound
|
import anki.sound
|
||||||
import anki.mpv
|
import anki.mpv
|
||||||
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
||||||
@ -1229,6 +1228,7 @@ will be lost. Continue?"""))
|
|||||||
pp = pprint.pprint
|
pp = pprint.pprint
|
||||||
self._captureOutput(True)
|
self._captureOutput(True)
|
||||||
try:
|
try:
|
||||||
|
# pylint: disable=exec-used
|
||||||
exec(text)
|
exec(text)
|
||||||
except:
|
except:
|
||||||
self._output += traceback.format_exc()
|
self._output += traceback.format_exc()
|
||||||
|
@ -11,8 +11,10 @@ from anki.lang import _
|
|||||||
class StudyDeck(QDialog):
|
class StudyDeck(QDialog):
|
||||||
def __init__(self, mw, names=None, accept=None, title=None,
|
def __init__(self, mw, names=None, accept=None, title=None,
|
||||||
help="studydeck", current=None, cancel=True,
|
help="studydeck", current=None, cancel=True,
|
||||||
parent=None, dyn=False, buttons=[], geomKey="default"):
|
parent=None, dyn=False, buttons=None, geomKey="default"):
|
||||||
QDialog.__init__(self, parent or mw)
|
QDialog.__init__(self, parent or mw)
|
||||||
|
if buttons is None:
|
||||||
|
buttons = []
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.form = aqt.forms.studydeck.Ui_Dialog()
|
self.form = aqt.forms.studydeck.Ui_Dialog()
|
||||||
self.form.setupUi(self)
|
self.form.setupUi(self)
|
||||||
|
@ -223,7 +223,11 @@ class AnkiWebView(QWebEngineView):
|
|||||||
return QColor("#ececec")
|
return QColor("#ececec")
|
||||||
return self.style().standardPalette().color(QPalette.Window)
|
return self.style().standardPalette().color(QPalette.Window)
|
||||||
|
|
||||||
def stdHtml(self, body, css=[], js=["jquery.js"], head=""):
|
def stdHtml(self, body, css=None, js=None, head=""):
|
||||||
|
if css is None:
|
||||||
|
css = []
|
||||||
|
if js is None:
|
||||||
|
js = ["jquery.js"]
|
||||||
if isWin:
|
if isWin:
|
||||||
widgetspec = "button { font-size: 12px; font-family:'Segoe UI'; }"
|
widgetspec = "button { font-size: 12px; font-family:'Segoe UI'; }"
|
||||||
fontspec = 'font-size:12px;font-family:"Segoe UI";'
|
fontspec = 'font-size:12px;font-family:"Segoe UI";'
|
||||||
|
Loading…
Reference in New Issue
Block a user