semvec/pypi-packages huggingface dataset:
cask 0.1.1
Injector-enabled Python application microframework
License: MIT

Cask
====

.. image:: https://travis-ci.org/jstasiak/cask.png?branch=master
   :alt: Build status
   :target: https://travis-ci.org/jstasiak/cask

*Cask* is Injector-enabled, Python application microframework modelled after Flask.

It's purpose is to make the amount of boilerplate you need to write when developing your application smaller. Here's a simple example:

.. code-block:: python

    >>> from cask import Cask
    >>> from injector import inject
    >>>
    >>> def configure(binder):
    ...     binder.bind(str, to='ABC')
    ...
    >>> @Cask.run_main(modules=[configure])
    ... @inject(s=str)
    ... def main(s):
    ...     print(s)
    ...
    ABC


``Cask.run_main`` (it works both as class and instance method, see below) does the ``if __name__ == '__main__'`` check for you. So this

.. code-block:: python

    >>> app = Cask()
    >>> @app.run_main
    ... def main():
    ...     print(111)
    ...
    111

is shorter version of

.. code-block:: python

    >>> app = Cask()
    >>> @app.main
    ... def main():
    ...     print(222)
    ...
    >>> if __name__ == '__main__':
    ...     app.run()
    ...
    222


Construction
------------

``Cask`` constructor and ``Cask.run_main`` class method accept the following optional keyword arguments:

* ``modules`` - iterable of Injector modules, defaults to empty sequence
* ``injector``- instance of Injector to configure and use, by default new instance will be created for you

Hooks
-----

``Cask`` instance provides the following decorators allowing you to register hooks (note that you can inject into registered functions):

* ``Cask.before_main`` - should expect no parameters, if non-None value is returned application execution main function won't be executed
* ``Cask.after_main`` - should expect single ``result`` parameter and return processed result (modified or not)
* ``Cask.exception_handler(ExceptionCLass)`` - will handle exception raised during the application execution, should expect single argument called ``e`` and containing exception value:

  .. code-block:: python

      >>> app = Cask()
      >>> @app.exception_handler(Exception)
      ... def handle(e):
      ...     print('got exception %s' % (e,))
      ...
      >>> @app.run_main
      ... def main():
      ...     raise Exception(123)
      ...
      got exception 123

* ``Cask.main`` - main function should expect no arguments and may return something


You can, of course, register more than one callable for hooks other than ``main``.

.. note:: Only first matching ``exception_handler`` hook will be called, if any.

Execution
---------

This is what happens when you run Cask-based application:

#. Injector is configured using provided ``modules``
#. ``before_main`` hooks are called
#. If ``before_main`` hooks didn't return value different than None, ``main`` hook is executed
#. ``after_main`` hooks are called


Copyright
---------

Copyright (C) 2013 Jakub Stasiak

This source code is licensed under MIT license, see LICENSE file for details.
django-analyze-sessions 0.1.1
Tools to analyze Django DB sessions
License: MIT

Django Session Space Analysis Tool
==================================

This is a Django management command (as in
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/)
that analyzes and reports on the size of sessions in the DB. It is
intended to make it easier to understand how much space session data
takes up.

Why?
----

I noticed that a relatively small number of sessions in my Django app
were consuming 50+KiB of data each, and wanted to understand why.
It isn't feasible or appealing to analyze large numbers of Django
sessions by hand, and I couldn't find any existing tools that did batch
analysis, so I wrote this tool.

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

Install the distribution from PyPI, e.g. ``pip install django-analyze-sessions``

Then, add ``analyze_sessions`` to INSTALLED_APPS in your Django project.

That's it. You can now run django-admin.py and confirm that the command
shows up.

Example Uses
------------

Break down the space usage of all sessions with more than 15KB of
session data:::

    django-admin.py analyze-sessions --bigger-than=15000
    Processed 2 sessions out of 5125 total sessions
    Average size was 16885.50 bytes
    Saw the following keys:
        foo (2 times, avg. size 15723.00 bytes)
        bar (2 times, avg. size 618.50 bytes)
        baz (2 times, avg. size 211.50 bytes)

Break down the space usage of all sessions whose keys are in the given
input file (useful for when you want to select sessions on more than
encoded size):::

    django-admin.py analyze-sessions --ids-from=/tmp/ids-to-check
    Processed 2 sessions out of 5125 total sessions
    Average size was 16885.50 bytes
    Saw the following keys:
        foo (2 times, avg. size 15723.00 bytes)
        bar (2 times, avg. size 618.50 bytes)
        baz (2 times, avg. size 211.50 bytes)

Known Issues and Bugs
---------------------

- The custom WHERE clause used to filter on session size may only work on MySQL (I don't have access to a Django installation on another DBMS, so I can't vouch for how well it'll work there).
- The tool could stand to be smarter about size abbreviations (e.g., by learning how to interpret 100KB, or abbreviating output)
- The packaging (such as it is) isn't very good.

Author
------

Kevan Carstensen <kevan@isnotajoke.com>