semvec/pypi-packages huggingface dataset:
chainz 0.14
Lightweight chaining functional methods for iterables
License: MIT
Keywords: iterable generators functional map filter reduce

Chainz
======

Chainz is a lightweight library to provide chaining, functional methods
to iterables.

To install: ``pip install chainz``

Basic example:

.. code:: python

    from chainz import Chain

    Chain(xrange(10))\
        .map(lambda x: x + 1)\
        .filter(lambda x: x % 2 == 0)\
        .omit(lambda x: x % 3 == 0)\
        .reduce(lambda x, y: x + y)
    # 30

Chain
-----

The fundamental class in ``chainz`` is ``Chain``, which accepts an
iterable as an argument to its constructor. It is itself an iterable,
just exposing the supplied iterable. It exposes functional methods like
``map``, ``filter``, and ``flatten``, which return the chain so as to be
chainable. These methods alter the chain; ``chain.map(f)`` is the same
as ``chain = chain.map(f)``.

Some methods, such as ``reduce`` and ``for_each``, are "sinks", in that
they consume the iterable. These methods do not return the chain, to
make it clear that once they are called, the chain is done.

All non-sink methods are lazy, so they don't result in any evaluation.
Only by using a sink method, or consuming the iterable in another way
(such as ``list(chain)`` or ``[x for x in chain]``), do you actually
evaluate the iterable.

You can think of ``Chain`` as a way to wrap ``itertools`` in a more
chainable fashion.

Errors
------

By default, a ``Chain`` will stop whenever there's an exception. Often
that is not what you want. When you are processing a long list of items
(something for which ``Chain`` was specifically created for), you just
want to note what went wrong, and move on to the next item. The method
``on_error`` allows just that. It takes a function
``f(exception, object)`` which itself takes two parameter. The first
parameter is the raised exception. The second parameter is the object
that caused the exception.

Example
~~~~~~~

.. code:: python

    def handle_error(exception, obj):
      print("%s caused exception: %s" % (obj, exception))

    def double(x):
      if x == 1:
        raise Exception('Bad')
      return x*2

    chain = Chain(xrange(3)).on_error(handle_error).map(double)
    list(chain)
    # "1 caused exception: Exception('Bad')"
    # [0, 2]

API
---

Please see the ``docs/`` directory for auto-generated (and thus
up-to-date) documentation. This is generated from the doc strings, so
introspection can also be helpful (eg, ``print Chain.reduce.__doc__``).
overdub 0.7
layered configuration aggregator
License: MIT
Keywords: configuration,layer,yaml

Overdub
=======

Load and merge nested configurations.


Usage
-----

Installation::

    python -m pip install overdub


With these structures::

    from overdub import MutableOverdub

    a = {'foo': 1, 'bar': {'baz': 2}, 'qux': {'one': 1}}
    b = {'foo': 3, 'bar': {'baz': 4}, 'qux': {'two': 2}}

Update::

    overdubbed = MutableOverdub(a)
    overdubbed.update(b)
    assert overdubbed.foo == 3
    assert overdubbed.bar.baz == 4
    assert overdubbed.qux == {'two': 2}


Merge::

    overdubbed = MutableOverdub(a)
    overdubbed.merge(b)
    assert overdubbed.foo == 3
    assert overdubbed.bar.baz == 4
    assert overdubbed.qux == {'one': 1, 'two': 2}


Rebase::

    overdubbed = MutableOverdub(a)
    overdubbed.rebase(b)
    assert overdubbed.foo == 1
    assert overdubbed.bar.baz == 2
    assert overdubbed.qux == {'one': 1, 'two': 2}


Unbound the data::

    overdubbed = MutableOverdub(a)
    assert isinstance(overdubbed, Overdub)
    naked = MutableOverdub(a)
    assert not isinstance(naked, Overdub)


Freeze configuration::

    overdubbed = overdubbed.frozen()


YAML files
----------

It can also read configuration from yaml files, for this install::

    python -m pip install overdub[yaml]

And then, merge all files::

    from overdub import yaml

    overdubbed = yaml.load_from_file('a.yml', b.yml')
    assert overdubbed.foo == 3
    assert overdubbed.bar.baz == 4
    assert overdubbed.qux == {'one': 1, 'two': 2}
aiohttp-rest 0.1.0
RESTful endpoints for aoihttp that bind directly to a model
License: MIT

aiohttp_rest
============

aiohttp_rest makes it easy to create RESTful aiohttp endpoints that bind directly to models with minimal modification.

Usage
-----

Create your model:

.. code-block:: python

  class Person:
      def __init__(self, name, age):
          self.name = name
          self.age = age

Create an aiohttp application that makes use of a ``aiohttp_rest.RestResource``:

.. code-block:: python

  from aiohttp.web import Application, run_app
  from aiohttp_rest import RestResource

  from person import Person


  people = {}

  app = Application()
  person_resource = RestResource('people', people, Person, ('name', 'age'), 'name')
  person_resource.register(app.router)

  run_app(app)

Interact with the API:

.. code-block:: bash

  http POST localhost:8000/people name=andrew age=24
  http localhost:8000/people/andrew
  http PUT localhost:8000/people/andrew/age age=25
  http DELETE localhost:8000/people/andrew

Several things are required by the ``RestResource`` to make all this work:

- A name for the resource, this will form the base of the URL.
- A factory method for the model, as seen above, this can simply be the init method for the model or something more complex.
- A collection to store the models, this should be a ``dict``-like object.
- A list of properties to expose to the API.
- A property to treat as the id for the collection. In the above example we used the name as the id, so that's what we used in our URLs to refer to a specific instance in the collection.

Installing
----------

.. code-block::

  git clone github.com/atbentley/aiohttp_rest
  cd aiohttp_rest
  python setup.py install

Tests
-----

.. code-block::

  pip install -r build-requirements.txt
  py.test tests

License
-------

MIT