semvec/pypi-packages huggingface dataset:
chaingrep 0.0.6
Python bindings for the Chaingrep API
License: MIT
Keywords: chaingrep api blockchain

# Chaingrep Python Library

The Chaingrep Python library provides convenient access to the Chaingrep API from applications written in Python.

## Documentation
See the [Chaingrep docs](https://docs.chaingrep.com).

## Installation
You don't need this source code unless you want to modify the package. If you want to use the package, just run:

```
pip install chaingrep
```

Install from source with:
```
python setup.py install
```

## Requirements
- Python 3.6+

## Usage
The library needs to be instantiated with your Chaingrep API key. Here's are a few examples of how the library can be used:

```python
from chaingrep import Chaingrep
from datetime import datetime, timedelta

chaingrep = Chaingrep("<API_KEY>")

# Parse a transaction
transaction = chaingrep.transaction("0xc4fd8359894ad78b04a5cd784106bcf6c413db8372492e744433533abc848ac6").parse()

print(transaction.transaction_type)


# Parse an account's transactions
account_transactions = chaingrep.account("0xa4722f1b4B552951828e6A334C5724b34B19A327").parse_transactions()

for transaction in account_transactions:
    print(transaction.time.timeago)


# Query all interactions between an account and a contract in the past month
target_account = "0xa4722f1b4B552951828e6A334C5724b34B19A327" # Me
target_contract = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" # USDC

current_datetime = datetime.utcnow()
past_datetime = current_datetime - timedelta(days=30) # One month ago

# Construct the query
query = chaingrep.query()
query.query({
    "account": target_account,
    "contract": target_contract
})
query.timeframe(past_datetime, current_datetime)

# Return a count
interactions_count = query.count()

# Return results
interactions = query.execute()
```

## Handling exceptions
Unsuccessful requests raise exceptions. The class of the exception will reflect the sort of error that occurred, and the error message will provide more context. See [Exceptions](https://github.com/chaingrep/chaingrep-py/blob/main/chaingrep/exceptions.py) for more.

```python
from chaingrep import Chaingrep

chaingrep = Chaingrep("<API_KEY>")

transaction = chaingrep.transaction("not_a_valid_hash").parse()
# InvalidTransactionHashError: <error message>
```
django-nonrelated-inlines 0.2
Django admin inlines for unrelated models
License: MIT
Requires Python: >=3.6

# django-nonrelated-inlines

Django admin inlines for unrelated models

![CircleCI](https://img.shields.io/circleci/build/github/bhomnick/django-nonrelated-inlines)
![PyPI](https://img.shields.io/pypi/v/django-nonrelated-inlines)

## Getting started

This app allows you to create admin inlines for models that don't have an
explicit foreign key relationship.

To use, subclass your inline from either `NonrelatedStackedInline` or 
`NonrelatedTabularInline` and add `get_form_queryset` and `save_new_instance`
methods.

* `get_form_queryset(self, obj)` returns all objects that should be shown in
  the inline formset.
* `save_new_instance(self, parent, instance)` given a parent object and a new
  child object instance should associate the child object with the parent.

For example, let's assume we have `Customer` and `Invoice` models. `Invoice`
objects are associated with a `Customer` if they share the same email address.

```python
from nonrelated_inlines.admin import NonrelatedStackedInline


class CustomerInvoiceStackedInline(NonrelatedStackedInline):
    model = Invoice
    fields = [
        'id',
        'amount'
    ]

    def get_form_queryset(self, obj):
        return self.model.objects.filter(email=obj.email)

    def save_new_instance(self, parent, instance):
        instance.email = parent.email
```

When viewing an `Customer` instance, we fetch a queryset of all `Invoice`
instances sharing the same email address. Similarly, when saving a new `Invoice`
instance we make sure to set its email attribute to the same value as its parent
`Customer`.