From 90128cf2d5548c4b3892f010e6ae3b43a6cc68cf Mon Sep 17 00:00:00 2001 From: noobie Date: Wed, 19 Oct 2016 20:32:27 +0200 Subject: [PATCH 1/2] Fix the lambda function for changing the mapping of the fields The connect signal passes a bool to the given function by default, we need to ignore it. use underscore for the sake of idiomology --- aqt/importing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aqt/importing.py b/aqt/importing.py index 0bb5d2219..2ada664af 100644 --- a/aqt/importing.py +++ b/aqt/importing.py @@ -225,7 +225,7 @@ you can enter it here. Use \\t to represent tab."""), self.grid.addWidget(QLabel(text), num, 1) button = QPushButton(_("Change")) self.grid.addWidget(button, num, 2) - button.clicked.connect(lambda s=self,n=num: s.changeMappingNum(n)) + button.clicked.connect(lambda _, s=self,n=num: s.changeMappingNum(n)) def changeMappingNum(self, n): f = ChangeMap(self.mw, self.importer.model, self.mapping[n]).getField() From 1a665cc185400e231635d0d3149b5f391a382ac4 Mon Sep 17 00:00:00 2001 From: noobie Date: Thu, 20 Oct 2016 00:40:30 +0200 Subject: [PATCH 2/2] Suppress the BeautifulSoup filename warning Bs4 will raise a warning if the markup (field input) starts with '/'. Suppressing the warning is probably the easiest solution, as Bs4 will still process it (no disadvantages?). --- aqt/editor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index 7809b0409..d809f50ff 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -6,6 +6,7 @@ import os import urllib.request, urllib.error, urllib.parse import ctypes import urllib.request, urllib.parse, urllib.error +import warnings from anki.lang import _ from aqt.qt import * @@ -641,7 +642,9 @@ class Editor(object): html = form.textEdit.toPlainText() # filter html through beautifulsoup so we can strip out things like a # leading - html = str(BeautifulSoup(html, "html.parser")) + with warnings.catch_warnings() as w: + warnings.simplefilter('ignore', UserWarning) + html = str(BeautifulSoup(html, "html.parser")) self.note.fields[self.currentField] = html self.loadNote() # focus field so it's saved @@ -871,7 +874,9 @@ to a cloze type first, via Edit>Change Note Type.""")) ###################################################################### def _filterHTML(self, html, localize=False): - doc = BeautifulSoup(html, "html.parser") + with warnings.catch_warnings() as w: + warnings.simplefilter('ignore', UserWarning) + doc = BeautifulSoup(html, "html.parser") # remove implicit regular font style from outermost element if doc.span: try: