pyrio ===== .. py:module:: pyrio Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyrio/decorators/index /autoapi/pyrio/exceptions/index /autoapi/pyrio/iterators/index /autoapi/pyrio/streams/index /autoapi/pyrio/utils/index Classes ------- .. autoapisummary:: pyrio.Stream pyrio.FileStream pyrio.Optional pyrio.DictItem Package Contents ---------------- .. py:class:: Stream Bases: :py:obj:`pyrio.streams.BaseStream`, :py:obj:`pyrio.iterators.ItertoolsMixin` Abstraction over a sequence of elements supporting sequential aggregate operations .. py:method:: of(*iterable) :classmethod: Creates Stream from args .. py:method:: of_nullable(iterable) :classmethod: Creates Stream from args if iterable is not None; otherwise returns empty Stream .. py:method:: empty() :classmethod: Creates empty Stream .. py:method:: iterate(seed, operation, condition=None) :classmethod: Creates infinite ordered Stream .. py:method:: generate(supplier) :classmethod: Creates infinite unordered Stream with values generated by given supplier function .. py:method:: constant(element) :classmethod: Creates infinite Stream with given value .. py:method:: from_range(start, stop, step=1) :classmethod: Creates Stream from start (inclusive) to stop (exclusive) by an incremental step .. py:method:: take_nth(idx, default=None) Returns Optional with the nth element of the stream or a default value .. py:method:: all_equal(key=None) Returns True if all elements of the stream are equal to each other .. py:class:: FileStream(file_path) Bases: :py:obj:`pyrio.streams.BaseStream` Derived Stream class for querying files; maps file content to im-memory dict structures and vice versa .. py:method:: process(file_path, *, f_open_options=None, f_read_options=None, **kwargs) :classmethod: Creates Stream from a file with advanced 'reading' options passed by the user .. py:method:: _read_file(file_path, f_open_options=None, f_read_options=None, **kwargs) :classmethod: .. py:method:: _read_dsv(path, f_open_options, f_read_options) :staticmethod: .. py:method:: _read_mapping(path, f_open_options, f_read_options, **kwargs) :staticmethod: .. py:method:: _read_plain(path, f_open_options) :staticmethod: .. py:method:: 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 .. py:method:: _write_dsv(path, tmp_path, f_open_options, f_write_options, null_handler=None) .. py:method:: _write_mapping(path, tmp_path, f_open_options, f_write_options, null_handler=None, **kwargs) .. py:method:: _write_plain(path, tmp_path, f_open_options, f_write_options) .. py:method:: _get_file_path(file_path, read_mode=True) :staticmethod: .. py:method:: _prepare_file_paths(file_path) .. py:method:: _prepare_io_options(settings) :staticmethod: .. py:method:: _atomic_write(path, tmp_path, f_open_options) .. py:class:: Optional(element) Container object which may (or may not) contain a non-null value .. py:attribute:: _element .. py:method:: __str__() .. py:method:: empty() :staticmethod: Creates empty Optional .. py:method:: of(element) :staticmethod: Creates Optional describing given non-null value .. py:method:: of_nullable(element) :staticmethod: Returns an Optional describing the given value, if non-null, otherwise returns an empty Optional .. py:method:: get() If a value is present, returns the value, otherwise raises an Exception .. py:method:: is_present() Returns bool whether a value is present .. py:method:: is_empty() Returns bool whether the Optional is empty .. py:method:: if_present(action) Performs given action with the value if the Optional is not empty .. py:method:: if_present_or_else(action, empty_action) Performs given action with the value if the Optional is not empty, otherwise calls fallback 'empty_action' .. py:method:: or_else(value) Returns the value if present, or a provided argument otherwise. Safe alternative to get() method .. py:method:: or_else_get(supplier) Returns the value if present, or calls a 'supplier' function otherwise. Safe alternative to get() method .. py: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 .. py:class:: DictItem(key, value) Helper record class for mapping key-value pairs .. py:attribute:: _key .. py:attribute:: _value .. py:property:: key .. py:property:: value .. py:method:: _map(val) .. py:method:: __repr__() .. py:method:: __eq__(other) .. py:method:: __hash__()