tailhands also had the wrong regex. Corrected.

This commit is contained in:
Matt Turnbull 2009-04-02 21:20:41 +01:00
parent d81627da3f
commit b2ac60de82

View File

@ -112,7 +112,9 @@ class HandHistoryConverter():
def start(self): def start(self):
"""process a hand at a time from the input specified by in_path. """process a hand at a time from the input specified by in_path.
If in follow mode, wait for more data to turn up. If in follow mode, wait for more data to turn up.
Otherwise, finish at eof...""" Otherwise, finish at eof...
"""
starttime = time.time() starttime = time.time()
if not self.sanityCheck(): if not self.sanityCheck():
print "Cowardly refusing to continue after failed sanity check" print "Cowardly refusing to continue after failed sanity check"
@ -137,7 +139,11 @@ Otherwise, finish at eof..."""
def tailHands(self): def tailHands(self):
"""Generator of handTexts from a tailed file: """Generator of handTexts from a tailed file:
Tail the in_path file and yield handTexts separated by re_SplitHands""" Tail the in_path file and yield handTexts separated by re_SplitHands.
This requires a regex that greedily groups and matches the 'splitter' between hands,
which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
"""
if self.in_path == '-': raise StopIteration if self.in_path == '-': raise StopIteration
interval = 1.0 # seconds to sleep between reads for new data interval = 1.0 # seconds to sleep between reads for new data
fd = codecs.open(self.in_path,'r', self.codepage) fd = codecs.open(self.in_path,'r', self.codepage)
@ -161,7 +167,7 @@ Tail the in_path file and yield handTexts separated by re_SplitHands"""
else: else:
# yield hands # yield hands
data = data + newdata data = data + newdata
result = self.re_SplitHands.split(data) result = self.re_TailSplitHands.split(data)
result = iter(result) result = iter(result)
data = '' data = ''
# --x data (- is bit of splitter, x is paragraph) yield,...,keep # --x data (- is bit of splitter, x is paragraph) yield,...,keep