Handle invalid delimiters more gracefully

This commit is contained in:
luoliyan 2017-02-13 21:42:19 +09:30
parent 6df5ce71a0
commit 7002a2a4f8

View file

@ -112,6 +112,11 @@ you can enter it here. Use \\t to represent tab."""),
self, help="importing") or "\t" self, help="importing") or "\t"
str = str.replace("\\t", "\t") str = str.replace("\\t", "\t")
str = str.encode("ascii") str = str.encode("ascii")
if len(str) > 1:
showWarning(_(
"Multi-character separators are not supported. "
"Please enter one character only."))
return
self.hideMapping() self.hideMapping()
def updateDelim(): def updateDelim():
self.importer.delimiter = str self.importer.delimiter = str
@ -140,7 +145,7 @@ you can enter it here. Use \\t to represent tab."""),
d = repr(d) d = repr(d)
txt = _("Fields separated by: %s") % d txt = _("Fields separated by: %s") % d
self.frm.autoDetect.setText(txt) self.frm.autoDetect.setText(txt)
def accept(self): def accept(self):
self.importer.mapping = self.mapping self.importer.mapping = self.mapping
if not self.importer.mappingOk(): if not self.importer.mappingOk():