Package lepl :: Package stream :: Module factory :: Class StreamFactory
[hide private]
[frames] | no frames]

Class StreamFactory

source code


Given a value (typically a sequence), generate a stream.
Instance Methods [hide private]
 
from_string(self, text, **kargs)
Provide a stream for the contents of the string.
source code
 
from_list(self, list_, **kargs)
Provide a stream for the contents of the list.
source code
 
from_sequence(self, sequence, **kargs)
Return a generic stream for any indexable sequence.
source code
 
from_iterable(self, iterable, **kargs)
Provide a stream for the contents of the iterable.
source code
 
from_file(self, file_, **kargs)
Provide a stream for the contents of the file.
source code
 
to_token(self, iterable, **kargs)
Create a stream for tokens.
source code
 
__call__(self, sequence, **kargs)
Auto-detect type and wrap appropriately.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

from_iterable(self, iterable, **kargs)

source code 
Provide a stream for the contents of the iterable. This assumes that each value from the iterable is a "line" which will, in turn, be passed to the stream factory.

from_file(self, file_, **kargs)

source code 

Provide a stream for the contents of the file.  There is no 
corresponding `from_path` because the opening and closing of the
path must be done outside the parsing (or the contents will become
unavailable), so use instead:
  with open(path) as f:
      parser.parse_file(f)
which will close the file after parsing.

to_token(self, iterable, **kargs)

source code 
Create a stream for tokens. The iterable is a source of (token_ids, sub_stream) tuples, where sub_stream will be matched within the token.