Internals

These classes are intended to be used by layout implementors.

class txf.layouts.DictReader(iterable[, fieldnames=None[, **config]])

A base record iterator class.

fieldnames

A tuple of the field names in the fixed schema being iterated over. If the field names were not specified in the constructor, then it will read them from the first row. If the row is a dictionary, the field names are extracted and the row itself is buffered. If the row is a tuple, it is presumed to contain the field names. If the row is a single value, that value is the single field name. If the iterable is empty, the field names are taken from the default_fieldnames member of the config.

line_num

The current line number.

next()

Reads the next set of values from the input iterator. If the values are a dict, the record is updated with the contents of the dictionary. If the values are a tuple, the record is constructed from the values and the ordered field names. Otherwise, the values are returned as the value for every field name. Missing field names are set to None.

class txf.layouts.BufferedAppend

Constructs an iterator that can buffer appends for iteration.

append(value)

Buffers the value for a call to next(). Multiple calls overwrite the value.

next()

Returns the buffered value, or raises StopIteration if nothing is buffered.

class txf.layouts.BufferedWrite

Constructs an iterator that can buffer writes for iteration.

write(string)

Buffers the string for a call to next(). Multiple calls append to the existing string.

next()

Returns the buffered string, or raises StopIteration if nothing is buffered.