creek.scrap.creek_layers

Wrapper interfaces

Inner-class

def intify(self, data):
    return tuple(map(int, data))
class D(Creek):
    # subclassing `CreekLayer` indicates that this class is a layering class
    # could also use decorator for this: Allowing simple injection of external classes
    class Lay(CreekLayer):
        # name indicates what kind of layer this is (i.e. where/how to apply it)
        def pre_iter(stream):
            next(stream)  # skip one

        @data_to_obj  # decorator to indicate what kind of layer this is (i.e. where/how to apply it
        def strip_and_split(data):  # function can be a method (first arg is instance) or static (data_to_obj figures it out)
            return data.strip().split(',')

        another_data_to_obj_layer = data_to_obj(intify)  # decorator can be used to inject function defined externally

Decorators

@lay(kind='pre_iter', func=func)
@lay.data_to_obj(func=func)
class D(Creek):
    pass

Fluid interfaces

D = (Creek
    .lay('pre_iter', func)
    .lay.data_to_obj(func)...
)

Backend

Use lists to stack layers.

Compile the layers to increase resource use.

Uncompile to increase debugibility.

class creek.scrap.creek_layers.CreekLayer(pre_iters: Iterable[Callable] = (), data_to_objs: Iterable[Callable] = (), post_iters: Iterable[Callable] = ())[source]