mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
normalize first field before comparing with local DB
https://forums.ankiweb.net/t/python-checksum-rust-checksum/8195/8
This commit is contained in:
parent
7472181aeb
commit
a90a6ab3cd
1 changed files with 3 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
# 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 html
|
import html
|
||||||
|
import unicodedata
|
||||||
from typing import Dict, List, Optional, Tuple, Union
|
from typing import Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from anki.collection import Collection
|
from anki.collection import Collection
|
||||||
|
@ -147,14 +148,14 @@ class NoteImporter(Importer):
|
||||||
n.fields[c] = n.fields[c].strip()
|
n.fields[c] = n.fields[c].strip()
|
||||||
if not self.allowHTML:
|
if not self.allowHTML:
|
||||||
n.fields[c] = n.fields[c].replace("\n", "<br>")
|
n.fields[c] = n.fields[c].replace("\n", "<br>")
|
||||||
fld0 = n.fields[fld0idx]
|
fld0 = unicodedata.normalize("NFC", n.fields[fld0idx])
|
||||||
csum = fieldChecksum(fld0)
|
|
||||||
# first field must exist
|
# first field must exist
|
||||||
if not fld0:
|
if not fld0:
|
||||||
self.log.append(
|
self.log.append(
|
||||||
self.col.tr(TR.IMPORTING_EMPTY_FIRST_FIELD, val=" ".join(n.fields))
|
self.col.tr(TR.IMPORTING_EMPTY_FIRST_FIELD, val=" ".join(n.fields))
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
csum = fieldChecksum(fld0)
|
||||||
# earlier in import?
|
# earlier in import?
|
||||||
if fld0 in firsts and self.importMode != ADD_MODE:
|
if fld0 in firsts and self.importMode != ADD_MODE:
|
||||||
# duplicates in source file; log and ignore
|
# duplicates in source file; log and ignore
|
||||||
|
|
Loading…
Reference in a new issue