import base 

class Line(base.AbstractProvider):
    
    def next(self):
        while True:
            line = self.stream.readline()
            if not line:
                raise EOFError()

            line.strip()
            if len(line) > 0:
                break

        return [[w] for w in line.split()]


# TODO: this must be done in another way...
class Multiline(base.AbstractProvider):
    def __init__(self, stream):
        raise NotImplementedError()

    def __init__(self, stream, sentence_breaks, value_break = None, skip = 0):
        super(Multiline, self).__init__(stream)
        self.sentence_breaks = sentence_breaks
        self.value_break = value_break
        self.skip = skip

    def open(self):
        super(Multiline, self).open()
        while self.skip > 0:
            self.stream.readline()
            self.skip -= 1
        

    def next(self):
        rows = []

        # skip lines containing a separator
        while True:
            line = self.stream.readline()
            if not line:
                raise EOFError()

            line = line.strip()
            if line not in self.sentence_breaks:
                break

       
        while True:
            rows.append(line.split(self.value_break))

            line = self.stream.readline()
            if not line:
                break

            line = line.strip()
            if line in self.sentence_breaks:
                break

        return rows
