pyrio
Submodules
Classes
Abstraction over a sequence of elements supporting sequential aggregate operations |
|
Derived Stream class for querying files; maps file content to im-memory dict structures and vice versa |
|
Container object which may (or may not) contain a non-null value |
|
Helper record class for mapping key-value pairs |
Package Contents
- class pyrio.Stream
Bases:
pyrio.streams.BaseStream,pyrio.iterators.ItertoolsMixinAbstraction over a sequence of elements supporting sequential aggregate operations
- classmethod of(*iterable)
Creates Stream from args
- classmethod of_nullable(iterable)
Creates Stream from args if iterable is not None; otherwise returns empty Stream
- classmethod empty()
Creates empty Stream
- classmethod iterate(seed, operation, condition=None)
Creates infinite ordered Stream
- classmethod generate(supplier)
Creates infinite unordered Stream with values generated by given supplier function
- classmethod constant(element)
Creates infinite Stream with given value
- classmethod from_range(start, stop, step=1)
Creates Stream from start (inclusive) to stop (exclusive) by an incremental step
- take_nth(idx, default=None)
Returns Optional with the nth element of the stream or a default value
- all_equal(key=None)
Returns True if all elements of the stream are equal to each other
- class pyrio.FileStream(file_path)
Bases:
pyrio.streams.BaseStreamDerived Stream class for querying files; maps file content to im-memory dict structures and vice versa
- classmethod process(file_path, *, f_open_options=None, f_read_options=None, **kwargs)
Creates Stream from a file with advanced ‘reading’ options passed by the user
- classmethod _read_file(file_path, f_open_options=None, f_read_options=None, **kwargs)
- static _read_dsv(path, f_open_options, f_read_options)
- static _read_mapping(path, f_open_options, f_read_options, **kwargs)
- static _read_plain(path, f_open_options)
- save(file_path=None, *, f_open_options=None, f_write_options=None, null_handler=None, **kwargs)
Writes Stream to a new file (or updates an existing one) with advanced ‘writing’ options passed by the user
- _write_dsv(path, tmp_path, f_open_options, f_write_options, null_handler=None)
- _write_mapping(path, tmp_path, f_open_options, f_write_options, null_handler=None, **kwargs)
- _write_plain(path, tmp_path, f_open_options, f_write_options)
- static _get_file_path(file_path, read_mode=True)
- _prepare_file_paths(file_path)
- static _prepare_io_options(settings)
- _atomic_write(path, tmp_path, f_open_options)
- class pyrio.Optional(element)
Container object which may (or may not) contain a non-null value
- _element
- __str__()
- static empty()
Creates empty Optional
- static of(element)
Creates Optional describing given non-null value
- static of_nullable(element)
Returns an Optional describing the given value, if non-null, otherwise returns an empty Optional
- get()
If a value is present, returns the value, otherwise raises an Exception
- is_present()
Returns bool whether a value is present
- is_empty()
Returns bool whether the Optional is empty
- if_present(action)
Performs given action with the value if the Optional is not empty
- if_present_or_else(action, empty_action)
Performs given action with the value if the Optional is not empty, otherwise calls fallback ‘empty_action’
- or_else(value)
Returns the value if present, or a provided argument otherwise. Safe alternative to get() method
- or_else_get(supplier)
Returns the value if present, or calls a ‘supplier’ function otherwise. Safe alternative to get() method
- or_else_raise(supplier=None)
Returns the value if present, otherwise throws an exception produced by the exception supplying function (if such is provided by the user) or NoSuchElementError