semvec/pypi-packages huggingface dataset:
cachelock 0.0.3
A simple look that uses the cache as acquirer
License: MIT
Keywords: lock cache once celery tasks single-execution

python-cachelock
================

[![Supported Versions](https://img.shields.io/pypi/pyversions/cachelock.svg)](https://pypi.python.org/pypi/cachelock)
[![Build Status](https://travis-ci.org/douglasfarinelli/python-cachelock.svg?branch=master)](https://travis-ci.org/douglasfarinelli/python-cachelock)
[![Coverage Status](https://coveralls.io/repos/github/douglasfarinelli/python-cachelock/badge.svg?branch=master)](https://coveralls.io/github/douglasfarinelli/python-cachelock?branch=master)
[![PyPI version](https://badge.fury.io/py/cachelock.svg)](https://pypi.python.org/pypi/cachelock)

The `cachelock` serves to ensure that your code block or function is executed one at a time using the cache as acquirer.

How to install:
===============

    pip install cachelock

or

    pipenv install cachelock
    
How to use
==========

You can use of two forms:

    - Use the `Lock` class to your blocks;
    - Or use the decorator `once` to block your functions or tasks;

With cachelock.Lock
===================

Arguments:

    with cachelock.Lock(
        key=...
        cache=...,
    ) ...

You should use the Lock class as with context:

    with cachelock.Lock(key='foo'):
        ...your code ...

If it is already locked, the LockError will be raised.

With cachelock.once
===================

Arguments:

    @cachelock.once(
        key=...
        cache=...,
        raises_if_lock=False
    )
    ...

With the decorator, you can guarantee the unique execution of some function. It also allows you to configure your key according to the arguments of the function.

    @celery.task
    @cachelock.once(key='foo-{arg_a}-{arg_b}')
    def func(arg_a, arg_b):
        pass

That way, if it is locked, the function quits silently. You can also ask `once` to raise `LockError`:

    @celery.task
    @cachelock.once(
        key='foo-{arg_a}-{arg_b}',
        raise_if_lock=True
    )
    def func(arg_a, arg_b):
        pass

Integrate with Django
=====================

The cachelock checks whether django is installed, and if so, it uses django's own cache as aquirer. And if you wish, you can modify the default cache with `DEFAULT_CACHELOCK_ALIAS` configuration through django settings. The value must be an alias of some existing cache, by default it uses `default`


*Remembering that by `default`, `cachelock` uses its own internal cache in memory if there is no integration with `django`.*

Customizing your own cache
==========================

To work it is necessary that the implementation of the cache has the `get`, `delete` and `set` methods. Ex.:

    class DummyCache:

        def set(self, key, value):
            pass

        def get(self, key, default=None):
            pass

        def delete(self, key):
            pass

    cache = DummyCache()

use: 

    @cachelock.once(key=..., cache=cache)
    
or
    
    with cachelock.Lock(key..., cache=cache) ...
django-template-tree 0.1.1
Generate diagrams showing relationships between templates in Django projects
License: MIT
Keywords: django_template_tree

=============================
django-template_tree
=============================

.. image:: https://badge.fury.io/py/django-template-tree.svg
    :target: https://badge.fury.io/py/django-template-tree

.. image:: https://travis-ci.org/paul-butcher/django_template_tree.svg?branch=master
    :target: https://travis-ci.org/paul-butcher/django_template_tree

.. image:: https://codecov.io/gh/paul-butcher/django_template_tree/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/paul-butcher/django_template_tree

Generate diagrams showing relationships between templates in Django projects

Documentation
-------------

The full documentation is at https://django_template_tree.readthedocs.io.

Quickstart
----------

Install django-template_tree::

    pip install django_template_tree

Add it to your `INSTALLED_APPS`:

.. code-block:: python

    INSTALLED_APPS = (
        ...
        'template_tree',
        ...
    )

Add django-template_tree's URL patterns:

.. code-block:: python

    from template_tree import urls as template_tree_urls
    from django import settings
    if settings.DEBUG:
        urlpatterns += [
            url(r'^__tt__/', include('template_tree.urls', namespace='template_tree')),
        ]

Features
--------

Displays a collapsible tree diagram showing the hierarchy of templates used by a Django application.

.. image:: _static/screenshot.png

Nodes can be collapsed and expanded, by clicking on them.

.. image:: _static/screenshot-collapsed.png

Apps can be filtered out of the tree, using the 'exclude_app' querystring parameter, thus:

http://localhost:8000/__tt__/?exclude_app=template_tree&exclude_app=admin

By default, admin is excluded, so
http://localhost:8000/__tt__/
is equivalent to
http://localhost:8000/__tt__/?exclude_app=admin

In order to show the admin app as well, you will need to 'unexclude' it thus:
http://localhost:8000/__tt__/?exclude_app=

Visiting the template_tree url, requesting an application/json response will return json data
compatible with d3 hierarchies, so you can roll your own diagrams.

Running Tests
-------------

Does the code actually work?

::

    source <YOURVIRTUALENV>/bin/activate
    (myenv) $ pip install tox
    (myenv) $ tox

Credits
-------

Tools used in rendering this package:

*  Cookiecutter_
*  `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
-------

0.1.0 (2018-01-06)
++++++++++++++++++

* First release on PyPI.