fix some warnings
This commit is contained in:
parent
7755eb408c
commit
f6b2135129
@ -128,8 +128,10 @@ class DeckManager:
|
||||
# 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."
|
||||
if type is None:
|
||||
type = defaultDeck
|
||||
name = name.replace('"', '')
|
||||
name = unicodedata.normalize("NFC", name)
|
||||
for id, g in list(self.decks.items()):
|
||||
@ -353,8 +355,10 @@ class DeckManager:
|
||||
self.dconf[str(g['id'])] = g
|
||||
self.save()
|
||||
|
||||
def confId(self, name, cloneFrom=defaultConf):
|
||||
def confId(self, name, cloneFrom=None):
|
||||
"Create a new configuration and return id."
|
||||
if cloneFrom is None:
|
||||
type = defaultConf
|
||||
c = copy.deepcopy(cloneFrom)
|
||||
while 1:
|
||||
id = intTime(1000)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
class AnkiError(Exception):
|
||||
def __init__(self, type, **data):
|
||||
super().__init__()
|
||||
self.type = type
|
||||
self.data = data
|
||||
def __str__(self):
|
||||
@ -14,6 +15,7 @@ class AnkiError(Exception):
|
||||
|
||||
class DeckRenameError(Exception):
|
||||
def __init__(self, description):
|
||||
super().__init__()
|
||||
self.description = description
|
||||
def __str__(self):
|
||||
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.")
|
||||
|
||||
# prevent older clients from accessing
|
||||
# pylint: disable=unreachable
|
||||
self._addDummyCollection(z)
|
||||
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)
|
||||
state = dict(n=1)
|
||||
def repl(match):
|
||||
# pylint: disable=cell-var-from-loop
|
||||
# replace [...] with cloze refs
|
||||
res = ("{{c%d::%s}}" % (state['n'], match.group(1)))
|
||||
state['n'] += 1
|
||||
|
@ -140,7 +140,6 @@ def _errMsg(type, texpath):
|
||||
msg += "<small><pre>" + html.escape(log) + "</pre></small>"
|
||||
except:
|
||||
msg += _("Have you installed latex and dvipng/dvisvgm?")
|
||||
pass
|
||||
return msg
|
||||
|
||||
# setup q/a filter
|
||||
|
@ -1390,6 +1390,7 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
||||
random.shuffle(nids)
|
||||
for c, nid in enumerate(nids):
|
||||
due[nid] = start+c*step
|
||||
# pylint: disable=undefined-loop-variable
|
||||
high = start+c*step
|
||||
# shift?
|
||||
if shift:
|
||||
|
@ -1531,6 +1531,7 @@ usn=:usn,mod=:mod,factor=:fact where id=:id""",
|
||||
random.shuffle(nids)
|
||||
for c, nid in enumerate(nids):
|
||||
due[nid] = start+c*step
|
||||
# pylint: disable=undefined-loop-variable
|
||||
high = start+c*step
|
||||
# shift?
|
||||
if shift:
|
||||
|
@ -21,6 +21,7 @@ class CardStats:
|
||||
|
||||
def report(self):
|
||||
c = self.card
|
||||
# pylint: disable=unnecessary-lambda
|
||||
fmt = lambda x, **kwargs: fmtTimeSpan(x, short=True, **kwargs)
|
||||
self.txt = "<table width=100%>"
|
||||
self.addLine(_("Added"), self.date(c.id/1000))
|
||||
@ -809,8 +810,10 @@ from cards where did in %s""" % self._limit())
|
||||
# Tools
|
||||
######################################################################
|
||||
|
||||
def _graph(self, id, data, conf={},
|
||||
def _graph(self, id, data, conf=None,
|
||||
type="bars", ylabel=_("Cards"), timeTicks=True, ylabel2=""):
|
||||
if conf is None:
|
||||
conf = {}
|
||||
# display settings
|
||||
if type == "pie":
|
||||
conf['legend'] = {'container': "#%sLegend" % id, 'noColumns':2}
|
||||
|
@ -733,7 +733,8 @@ class MediaSyncer:
|
||||
need.append(fname)
|
||||
else:
|
||||
self.col.log("have same already")
|
||||
ldirty and self.col.media.markClean([fname])
|
||||
if ldirty:
|
||||
self.col.media.markClean([fname])
|
||||
elif lsum:
|
||||
# deleted remotely
|
||||
if not ldirty:
|
||||
@ -745,7 +746,8 @@ class MediaSyncer:
|
||||
else:
|
||||
# deleted both sides
|
||||
self.col.log("both sides deleted")
|
||||
ldirty and self.col.media.markClean([fname])
|
||||
if ldirty:
|
||||
self.col.media.markClean([fname])
|
||||
|
||||
self._downloadFiles(need)
|
||||
|
||||
|
@ -2,10 +2,6 @@
|
||||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# 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
|
||||
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.
|
||||
"""
|
||||
|
||||
from anki.utils import intTime, ids2str, json
|
||||
from anki.hooks import runHook
|
||||
import re
|
||||
|
||||
class TagManager:
|
||||
|
||||
# Registry save/load
|
||||
|
@ -360,7 +360,7 @@ def call(argv, wait=True, **kwargs):
|
||||
isMac = sys.platform.startswith("darwin")
|
||||
isWin = sys.platform.startswith("win32")
|
||||
isLin = not isMac and not isWin
|
||||
devMode = os.getenv("ANKIDEV", 0)
|
||||
devMode = os.getenv("ANKIDEV", "")
|
||||
|
||||
invalidFilenameChars = ":*?\"<>|"
|
||||
|
||||
|
@ -411,6 +411,7 @@ class Browser(QMainWindow):
|
||||
self.show()
|
||||
|
||||
def setupMenus(self):
|
||||
# pylint: disable=unnecessary-lambda
|
||||
# actions
|
||||
f = self.form
|
||||
f.previewButton.clicked.connect(self.onTogglePreview)
|
||||
@ -808,8 +809,8 @@ by clicking on one on the left."""))
|
||||
def __init__(self):
|
||||
QTreeWidget.__init__(self)
|
||||
self.itemClicked.connect(self.onTreeClick)
|
||||
self.itemExpanded.connect(lambda item: self.onTreeCollapse(item))
|
||||
self.itemCollapsed.connect(lambda item: self.onTreeCollapse(item))
|
||||
self.itemExpanded.connect(self.onTreeCollapse)
|
||||
self.itemCollapsed.connect(self.onTreeCollapse)
|
||||
|
||||
def keyPressEvent(self, evt):
|
||||
if evt.key() in (Qt.Key_Return, Qt.Key_Enter):
|
||||
|
@ -31,6 +31,7 @@ class EditCurrent(QDialog):
|
||||
self.mw.requireReset()
|
||||
self.show()
|
||||
# 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)
|
||||
|
||||
def onReset(self):
|
||||
|
@ -3,7 +3,6 @@
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import re
|
||||
import os
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import ctypes
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import warnings
|
||||
@ -126,7 +125,7 @@ class Editor:
|
||||
mime, _ = mimetypes.guess_type(path)
|
||||
with open(path, 'rb') as fp:
|
||||
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'))
|
||||
|
||||
|
||||
|
@ -23,7 +23,6 @@ import aqt.webview
|
||||
import aqt.toolbar
|
||||
import aqt.stats
|
||||
import aqt.mediasrv
|
||||
from aqt.utils import showWarning
|
||||
import anki.sound
|
||||
import anki.mpv
|
||||
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
||||
@ -1229,6 +1228,7 @@ will be lost. Continue?"""))
|
||||
pp = pprint.pprint
|
||||
self._captureOutput(True)
|
||||
try:
|
||||
# pylint: disable=exec-used
|
||||
exec(text)
|
||||
except:
|
||||
self._output += traceback.format_exc()
|
||||
|
@ -11,8 +11,10 @@ from anki.lang import _
|
||||
class StudyDeck(QDialog):
|
||||
def __init__(self, mw, names=None, accept=None, title=None,
|
||||
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)
|
||||
if buttons is None:
|
||||
buttons = []
|
||||
self.mw = mw
|
||||
self.form = aqt.forms.studydeck.Ui_Dialog()
|
||||
self.form.setupUi(self)
|
||||
|
@ -223,7 +223,11 @@ class AnkiWebView(QWebEngineView):
|
||||
return QColor("#ececec")
|
||||
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:
|
||||
widgetspec = "button { font-size: 12px; font-family:'Segoe UI'; }"
|
||||
fontspec = 'font-size:12px;font-family:"Segoe UI";'
|
||||
|
Loading…
Reference in New Issue
Block a user