Anki/lib-python/anki/importing/base.py
Damien Elmes b23b6fbe35 move the separate components back into this monorepo
Earlier today I pushed a change that split this code up into multiple
repos, but that has proved to complicate things too much. So we're
back to a single repo, except the individual submodules are better
separated than they were before.

The README files need updating again; I will push them out soon.

Aside from splitting out the different modules, the sound code has
moved from from anki to aqt.
2020-01-02 19:43:19 +10:00

40 lines
1.1 KiB
Python

# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from typing import Any, List, Optional
from anki.collection import _Collection
from anki.utils import maxID
# Base importer
##########################################################################
class Importer:
needMapper = False
needDelimiter = False
dst: Optional[_Collection]
def __init__(self, col: _Collection, file: str) -> None:
self.file = file
self.log: List[str] = []
self.col = col
self.total = 0
self.dst = None
def run(self) -> None:
pass
# Timestamps
######################################################################
# It's too inefficient to check for existing ids on every object,
# and a previous import may have created timestamps in the future, so we
# need to make sure our starting point is safe.
def _prepareTS(self) -> None:
self._ts = maxID(self.dst.db)
def ts(self) -> Any:
self._ts += 1
return self._ts