semvec/pypi-packages huggingface dataset:
mutations 0.4.0
Encapsulate your business logic in command classes.
License: MIT
Keywords: business logic,django,fat models,thin models,input validation,commands,validation

# Mutations

[![pypi-version]][pypi]

Compose your business logic into commands that sanitize and validate input.

## Install

```bash
$ pip install mutations
```

## How it Works:

1. Subclass `mutations.Mutation`
2. Define your inputs.
3. Define an `execute` method in your command.
4. Run it, like this: `SimpleMutation.run(foo='bar')`

To learn more, see [this blog post](https://omarish.com/2018/02/17/mutations.html).

## Example

```python
import mutations

class UserSignup(mutations.Mutation):
    """Define the inputs to your mutation here. """
    email = mutations.fields.CharField(required=True)
    full_name = mutations.fields.CharField(required=True)
    send_welcome_email = mutations.fields.Boolean(required=False, default=True)

    def validate_email_address(self):
        """Custom validation for a field.

        If you encounter any validation errors and want to raise, you should
        raise mutation.ValidationError or some sublcass thereof. Otherwise, it
        assumes there were no problems.

        Any function beginning with `validate_` is assumed to be a validator
        function and will be run before the mutation can execute.
        """
        if not self.email.is_valid():
            raise mutations.ValidationError("email_not_valid", "Email is not valid.")

    def execute(self):
        """Executes the mutation.

        This method does the heavy lifting. You can call it by calling .run() on
        your mutation class.
        """
        user = User.objects.create(email=self.email, name=self.full_name)
        if self.send_welcome_email:
            EmailServer.deliver(recipient = self.email)
        return user
```

## Calling Commands

```python
>>> result = UserSignup.run(email=email, full_name="Bob Boblob")
>>> result.success
True
>>> result.return_value
<User id=...>
>>> result.errors

result = ...

```

```python
>>> result = UserSignup.run(email=None)
>>> result.success
False
>>> result.errors
mutations.ErrorDict({
  'email': ['email_not_valid']
})
>>> result.value
None
```

## Only Run Validations

```python
>>> result = UserSignup.validate(email=email, full_name="Bob Boblob")
>>> result.is_valid
True
```

## Testing

```bash
$ make tests
```

When you're ready to do a release, please make sure tests pass across both 2.7
and 3.6 by running tox:

```bash
$ tox
```

# Versioning

This project uses [Semantic Versioning][semver].

# Thanks

Thanks to Cypriss for the excellent Ruby [Mutations Gem][1]. I created this library because I was looking for something similar for Python.

[1]: https://github.com/cypriss/mutations
[semver]: https://semver.org/
[pypi-version]: https://img.shields.io/pypi/v/mutations.svg
[pypi]: https://pypi.org/project/mutations/
micropython-uPIL 0.0.0
Dummy uPIL module for MicroPython
License: MIT

This is a dummy implementation of a module for MicroPython standard library.
It contains zero or very little functionality, and primarily intended to
avoid import errors (using idea that even if an application imports a
module, it may be not using it onevery code path, so may work at least
partially). It is expected that more complete implementation of the module
will be provided later. Please help with the development if you are
interested in this module.
grovepi 1.0.4
Drivers for using the GrovePi+ in Python
License: MIT
Keywords: robot,grovepi,grovepi+,dexter industries,learning,education,iot,internet of things,prototyping

The GrovePi should no longer be installed with PIP. Instead, go with the following command:

.. code:: bash

  curl -kL dexterindustries.com/update_grovepi | bash

Or if you need to customize your installation, to be better suited for your requirements, check this GitHub `README <https://github.com/DexterInd/GrovePi/tree/master/Script>`_ for more information.

---

This is the python library for GrovePi+, which is an open source platform for connecting `Grove Sensors <https://www.dexterindustries.com/GrovePi/supported-sensors/>`_ to the Raspberry Pi.

Please visit:

   * Our `github repo folder <https://github.com/DexterInd/GrovePi/tree/master/Software/Python>`_ for using one of our many example programs.
   * Or our `official page <https://www.dexterindustries.com/grovepi/>`_ for more details about this platform.