semvec/pypi-packages huggingface dataset:
toolip 0.2
A collection of python utils for webapps.

# :tulip: toolip :tulip:

A collection of python utils for webapps

![Tests](https://github.com/SatelCreative/toolip/actions/workflows/tests.yml/badge.svg)

## Installation

```bash
pip install toolip
```

## Contributing

If you want to contribute a small change/feature, the best is to just create a PR with
your changes.
For bigger changes/features it's best to open an issue first and discuss it to agree
on the code organization and overall implementation before spending too much time on
the code, unless you want to keep it in your own forked repo.

### Setting up the development environment

We use the [python poetry](https://python-poetry.org/) package to manage this package.
Follow the official instructions to install poetry on your system then once you clone
this repository just just need to do the following to install the dependencies from
the development environment, as well as install `toolip` in
[editable mode](https://pip.pypa.io/en/stable/cli/pip_install/#install-editable):

```bash
poetry install
```

Then you can start monitoring the code for changes and run the test suite this way:

```bash
poetry shell
scripts/test_watch.sh
```

### Build and run documentation (lazydocs/mkdocs)

Documentation for this package is handled by `lazydocs` and so it needs a few steps to generate it locally.

Inside `poetry shell`:

```bash
lazydocs --overview-file="index.md" \
--src-base-url="https://github.com/SatelCreative/toolip/tree/main" \
--output-path="./docs/api-docs" \
--validate .

mkdocs build
mkdocs serve
```

The default URL is at `127.0.0.1:8000`.

## Maintenance

We use [poetry](https://python-poetry.org/) to manage the dependencies and
[flit](https://flit.readthedocs.io/en/latest/index.html) to build and publish to pypi
because unlike poetry it allows to set the metadata on pypi such as author or homepage.

### Howto publish

1. Change the version in the `pyproject.toml` and `toolip/__init__.py` files
   - you can use `poetry version XXXXX` to change `pyproject.toml`
2. Commit to git
3. Run `poetry build` to create the package folders in `/dist`
4. Run `flit publish` to publish to PyPI
5. Tag the release in git and push it to Github
etherunit 0.0.6
Etherium unit conversation and arithmetic library
Requires Python: >=3.6

# etherunit
Etherium unit conversation and arithmetic library

## Install
```sh
pip install -u etherunit
```

## Usage

```python
>>> from etherunit import Ether, Gwei, Wei, E
```
### Create a new quantity with units
You can create a new quatity like this
```python
>>> Ether(".05")
0.05 ether
>>> Gwei(".05")
0.05 gwei
>>> Wei("5")
5 wei
```
Or you can use the helper function E() to create a new quantity
```python
>>> E(".05 eth")
0.05 ether
>>> E(".05 gwei")
0.05 gwei
>>> E("5 wei")
5 wei
```
### Arithmetic operations
Different quatities can be added together without any problems
```python
>>> E(".05 eth") + E("2 gwei") == E("0.050000002 eth")
True
```
This also applies for subtraction
```python
>>> E(".05 eth") - E("2 gwei") == E("0.049999998 eth")
True
```
You can also multiply quanities with other integers
```python
>>> E(".05 eth") * 2
0.1 ether
```
... but not with other quatities
```python
>>> E(".05 eth") * E("2 gwei")  # type: ignore
AssertionError: 2 gwei is not an integer
```
You also can't multiply quatities with other integers, like floats. Why? Because it can result with fractional wei, which is not allowed
```python
>>> E(".05 eth") * 1.5
AssertionError: 1.5 is not an integer
```
You can divide quatities with other integers, the result is always a quatity
```python
>>> E(".05 eth") / 2
0.025 ether
```
And you can divide quatities with other quatities, the result is always an integer
```python
>>> E("10 eth") / E("3 eth")
3
```
You can find the remainder of a division with mod operator (%)
```python
>>> E("10 eth") % E("3 eth")
1 ether
```
You can also use divmod() to get both the quotient and the remainder
```python
>>> divmod(E("10 eth"), E("3 eth"))
(3, 1 ether)
```

### Conversion
You can convert a quatity to another quatity, though it's not necessary for arithmetic operations
```python
>>> E("10 eth").gwei
10000000000 gwei
>>> E("10 eth").wei
10000000000000000000 wei
>>> (E("10 eth") % E("3 eth")).wei
1000000000000000000 wei
>>> E("10 eth").wei.eth.eth.eth.eth.gwei.wei.wei.wei  # :D
10000000000000000000 wei
```
django-autodrp 1.0.0
Automatically set-up filters and permissions for Django's DRY Rest Permissions
Requires Python: >=3.5

# django-autodrp
Automatically set-up filters and permissions for Django's DRY Rest Permissions

# Quick Start
1. Run `pip install django-autodrp`
2. Add 'autodrp' to your INSTALLED_APPS in your settings below all the apps you wish to use AutoDRP for (failing to add django-autodrp after the apps that will use it will result in the autoconfiguration of AutoDRP not running).
```python
INSTALLED_APPS = [
  # Django apps / packages
  'all-django-apps',
  # Your apps
  'yourapp'
]
```

```python
INSTALLED_APPS = [
  # Django apps / packages
  'all-django-apps',
  # Your apps
  'yourapp',
  'autodrp', # <- Here
]
```
3. Add the following (or replace your already existing has_blank_permission functions) to any models you with to use AutoDRP for (either is optional):
```python
DRY_GLOBAL_PERMISSIONS = {
     ('read', 'write'): True
}

DRY_OBJECT_PERMISSIONS = {
     ('read', 'write'): True
}
```
Indicating `read` with a value of true is the same as:
```python
@staticmethod
def has_read_permission(request):
     return True
```

4. Import `AutoDRPFilter` via `from autodrp.filters import AutoDRPFilter`, and add it to your `filter_backends` on your viewset like so:
```python
from autodrp.filters import AutoDRPFilter

class ProjectViewSet(viewsets.ModelViewset):
  queryset = Project.objects.all()
  permission_classes = (DRYPermissions,)
  filter_backends = [AutoDRPFilter]
```
5. You now are using AutoDRP permissions and filters.

Consult the wiki for a definitive tutorial and explanation of AutoDRP.

# Motivation for this project
I've found DRY Rest Permissions to be a great asset but rather verbose. I hope to make working with DRY Rest Permissions easier by consolidating filter and permission functionality into a simple and terse feature.