+0.9.1 UNRELEASED
+
+ * Update FSF address in headers. (Dan Callaghan, #868800)
+
+ * Support 'done' feature. (Jelmer Vernooij, #942563)
+
0.9.0 2011-01-30
Initial release.
self.reason = ''
+class PrematureEndOfStream(ParsingError):
+ """Raised when the 'done' feature was specified but missing."""
+
+ _fmt = (_LOCATION_FMT + "Stream end before 'done' command")
+
+ def __init__(self, lineno):
+ ParsingError.__init__(self, lineno)
+
+
class UnknownDateFormat(ImportError):
"""Raised when an unknown date format is given."""
self.user_mapper = user_mapper
# We auto-detect the date format when a date is first encountered
self.date_parser = None
+ self.features = {}
def warning(self, msg):
sys.stderr.write("warning line %d: %s\n" % (self.lineno, msg))
while True:
line = self.next_line()
if line is None:
+ if 'done' in self.features:
+ raise errors.PrematureEndOfStream(self.lineno)
break
elif len(line) == 0 or line.startswith('#'):
continue
value = self._path(parts[1])
else:
value = None
+ self.features[name] = value
return commands.FeatureCommand(name, value, lineno=self.lineno)
def _parse_file_modify(self, info):
self.assertEqual('Donald', cmd.more_authors[1][0])
self.assertEqual('donald@duck.org', cmd.more_authors[1][1])
+ def test_done_feature_missing_done(self):
+ s = StringIO.StringIO("""feature done
+""")
+ p = parser.ImportParser(s)
+ cmds = p.iter_commands()
+ self.assertEquals("feature", cmds.next().name)
+ self.assertRaises(errors.PrematureEndOfStream, cmds.next)
+
+ def test_done_with_feature(self):
+ s = StringIO.StringIO("""feature done
+done
+more data
+""")
+ p = parser.ImportParser(s)
+ cmds = p.iter_commands()
+ self.assertEquals("feature", cmds.next().name)
+ self.assertRaises(StopIteration, cmds.next)
+
+ def test_done_without_feature(self):
+ s = StringIO.StringIO("""done
+more data
+""")
+ p = parser.ImportParser(s)
+ cmds = p.iter_commands()
+ self.assertEquals([], list(cmds))
+
class TestStringParsing(testtools.TestCase):