summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Bronson <naesten@gmail.com>2009-07-18 19:09:23 -0400
committerSamuel Bronson <naesten@gmail.com>2009-07-18 19:09:23 -0400
commit407d5310faf029892f257adedf4706ef92c17e42 (patch)
tree1c6a4cd2bc9c550256e7d5cbebf45acb6581d202
parent56c16165be3bbb85ae817ac1afdb04adac0875ff (diff)
downloadpython-fastimport-407d5310faf029892f257adedf4706ef92c17e42.tar.gz
Implement here-document style input data.
Fixes bug #400960.
-rw-r--r--parser.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/parser.py b/parser.py
index 4897fa0..b93fc9d 100644
--- a/parser.py
+++ b/parser.py
@@ -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