semvec/pypi-packages huggingface dataset:
django-snippet-image 0.1.3
Django field for create snippet image for sharing in social networks.
License: MIT
Requires Python: >=3.5,<4.0
Keywords: django,sharing,images,social,networks,snippets

===========================
django-snippet-image
===========================

The python package provides a django field for automatic
generation of images for sharing in social networks.

django-snippet-image based on snippet-image_ package.

.. _snippet-image: https://github.com/acrius/snippet-image

Installation
-------------------------

`
pip3 install django-snippet-image
`

Example
-------------------------

Use SnippetImageField:

.. code-block:: python

    from django.db.models import (
        Model,
        CharField,
        ImageField,
    )
    from django_snippet_image import SnippetImageField


    class Statuses:
        DRAFT = 'draft'
        PUBLISH = 'publish'

        CHOICES = (
            (DRAFT, 'Draft'),
            (PUBLISH, 'Publish'),
        )


    class ExampleModel(Model):
        text = CharField(
            max_length=200,
            verbose_name='Text for snippet image',
        )
        background = ImageField(
            verbose_name='Background for snippet image',
            blank=True,
            null=True,
        )
        snippet_image_field = SnippetImageField(
            verbose_name='Example snippet image field',
            null=True,
        )
        status = CharField(
            max_length=20,
            choices=Statuses.CHOICES,
        )

        # Methods for collect data for snippet image.

        def get_snippet_image_text(self, snippet_type):
            return self.text if snippet_type == 'default' and self.text else ''

        def get_snippet_image_background(self, snippet_type):
            if snippet_type == 'default' and self.background:
                return self.background.path

        def snippet_image_should_be_created(self):
            return self.status == Statuses.PUBLISH

        class Meta:
            verbose_name = 'example object'
            verbose_name_plural = 'example objects'

And use in template:

.. code-block:: html

    <meta property="og:image" content="{{ instance.snippet_image_field.url }}" />

Read more on home page_.

.. _page: https://github.com/acrius/django-snippet-image
classmemo 1.0.2
Memoizer for classes
License: MIT

## Memoizer

### API

A `Memoizer` can be used as a factory for creating objects of a certain class.
It exposes a constructor and 2 methods

* `memoizer = Memoizer(SomeClass)`
* `memoizer.get(*args, **kwargs)`
    * If `memoizer` has never seen the given arguments, it creates `SomeClass(*args, **kwargs)` and returns it.
    * If `memoizer` has seen the given arguments before, it returns the same instance that it returned the last time.
* `memoizer.forget(*args, **kwargs)`
    * Makes `memoizer` forget that is has seen the given arguments.

### Usage

The original application was for a `MeasurementQueue` class that processes incoming sensor data from many sensors,
where the sensor ID's were not known ahead of time:

```python
queue_manager = Memoizer(MeasurementQueue)

for sensor_id, data in event_stream():
    queue = queue_manager.get(sensor_id)
    queue.push(data)
```

When the first measurement comes in for a given sensor_id, a new `MeasurementQueue` will be created and returned for
that sensor. On subsequent events with the same sensor ID, the same `MeasurementQueue` instance will be
used to process the data.

## Installation

`pip install classmemo`

The only dependencies are Python 3.6 and the frozendict package.

## Contributing

* Ensure the tests pass: `pytest .`
* Format the code with `black . -t py36`