Proper check for trailing spaces.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 27 Mar 2016 22:55:59 +0300
changeset 400 aa03182d2e26
parent 399 a6a7036f3c6f
child 401 791994f95561
Proper check for trailing spaces.
py/gadict.py
--- a/py/gadict.py	Sun Mar 27 22:43:45 2016 +0300
+++ b/py/gadict.py	Sun Mar 27 22:55:59 2016 +0300
@@ -38,6 +38,8 @@
         self.eof = len(self.line) == 0
         if not self.eof:
             self.lineno += 1
+        if self.TRAILING_SPACES_RE.search(self.line):
+            raise ParseException("Traling spaces detected...\n")
 
     def parse(self, stream):
         self.lineno = 0
@@ -48,8 +50,6 @@
             while not self.eof:
                 self.parse_article()
         except ParseException as ex:
-            if self.TRAILING_SPACES_RE.match(self.line):
-                raise ParseException("Traling spaces detected...\n", self.lineno, self.line) from ex
             raise ParseException(ex.msg, self.lineno, self.line) from ex
         return self.dom
 
@@ -111,7 +111,7 @@
             if m is not None:
                 attrs.add(m.group(1))
                 continue
-            raise ParseException("""Line is not headword or translation or headword attribute...""")
+            raise ParseException("""Line is not a headword or translation or headword attribute...""")
         self.words[word] = (pron, attrs)
 
     def parse_translation(self):