make sure we don't chomp embedded newlines when clearing comments (#722)
This commit is contained in:
parent
3be7c998fc
commit
a525d3c32c
@ -32,14 +32,15 @@ class TextImporter(NoteImporter):
|
|||||||
for row in reader:
|
for row in reader:
|
||||||
row = [unicode(x, "utf-8") for x in row]
|
row = [unicode(x, "utf-8") for x in row]
|
||||||
if len(row) != self.numFields:
|
if len(row) != self.numFields:
|
||||||
log.append(_(
|
if row:
|
||||||
"'%(row)s' had %(num1)d fields, "
|
log.append(_(
|
||||||
"expected %(num2)d") % {
|
"'%(row)s' had %(num1)d fields, "
|
||||||
"row": u" ".join(row),
|
"expected %(num2)d") % {
|
||||||
"num1": len(row),
|
"row": u" ".join(row),
|
||||||
"num2": self.numFields,
|
"num1": len(row),
|
||||||
})
|
"num2": self.numFields,
|
||||||
ignored += 1
|
})
|
||||||
|
ignored += 1
|
||||||
continue
|
continue
|
||||||
note = self.noteFromFields(row)
|
note = self.noteFromFields(row)
|
||||||
notes.append(note)
|
notes.append(note)
|
||||||
@ -65,8 +66,8 @@ class TextImporter(NoteImporter):
|
|||||||
if self.data.startswith(codecs.BOM_UTF8):
|
if self.data.startswith(codecs.BOM_UTF8):
|
||||||
self.data = self.data[len(codecs.BOM_UTF8):]
|
self.data = self.data[len(codecs.BOM_UTF8):]
|
||||||
def sub(s):
|
def sub(s):
|
||||||
return re.sub("^\#.*", "", s)
|
return re.sub("^\#.*$", "__comment", s)
|
||||||
self.data = [sub(x)+"\n" for x in self.data.split("\n") if sub(x)]
|
self.data = [sub(x)+"\n" for x in self.data.split("\n") if sub(x) != "__comment"]
|
||||||
if self.data:
|
if self.data:
|
||||||
if self.data[0].startswith("tags:"):
|
if self.data[0].startswith("tags:"):
|
||||||
tags = unicode(self.data[0][5:], "utf8").strip()
|
tags = unicode(self.data[0][5:], "utf8").strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user