mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
support tags: at the top of file to import; fix comment stripping
This commit is contained in:
parent
e3dd736460
commit
f4a35e9b03
1 changed files with 8 additions and 2 deletions
|
@ -75,9 +75,15 @@ class TextImporter(Importer):
|
|||
self.fileobj = open(self.file, "rbU")
|
||||
self.data = self.fileobj.read()
|
||||
self.data = self.data.lstrip(codecs.BOM_UTF8)
|
||||
self.data = re.sub("^ *#.*", "", self.data)
|
||||
self.data = [x for x in self.data.split("\n") if x]
|
||||
def sub(s):
|
||||
return re.sub(
|
||||
"^\#.*", "", re.sub(
|
||||
"^ +", "", s))
|
||||
self.data = [sub(x) for x in self.data.split("\n") if sub(x)]
|
||||
if self.data:
|
||||
if self.data[0].startswith("tags:"):
|
||||
self.tagsToAdd = self.data[0][5:]
|
||||
del self.data[0]
|
||||
self.updateDelimiter()
|
||||
if not self.dialect and not self.delimiter:
|
||||
raise ImportFormatError(
|
||||
|
|
Loading…
Reference in a new issue