diff options
author | Samuel Bronson <naesten@gmail.com> | 2009-07-18 19:09:23 -0400 |
---|---|---|
committer | Samuel Bronson <naesten@gmail.com> | 2009-07-18 19:09:23 -0400 |
commit | 407d5310faf029892f257adedf4706ef92c17e42 (patch) | |
tree | 1c6a4cd2bc9c550256e7d5cbebf45acb6581d202 | |
parent | 56c16165be3bbb85ae817ac1afdb04adac0875ff (diff) | |
download | python-fastimport-407d5310faf029892f257adedf4706ef92c17e42.tar.gz |
Implement here-document style input data.
Fixes bug #400960.
-rw-r--r-- | parser.py | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -88,7 +88,8 @@ The grammar is: # note: delim may be any string but must not contain lf. # data_line may contain any data but must not be exactly - # delim. + # delim. The lf after the final data_line is included in + # the data. delimited_data ::= 'data' sp '<<' delim lf (data_line lf)* delim lf; @@ -234,7 +235,16 @@ class LineBasedParser(object): :return: the bytes read up to but excluding the terminator. """ - raise NotImplementedError(self.read_until) + + lines = [] + term = terminator + '\n' + while True: + line = self.input.readline() + if line == term: + break + else: + lines.append(line) + return ''.join(lines) # Regular expression used for parsing. (Note: The spec states that the name |