semvec/pypi-packages huggingface dataset:
infrae.comethods 1.0
Sugar around Python generators and context managers
License: BSD
Keywords: comethod generator context manager

================
infrae.comethods
================

This package provides an helper to write cofunction with the help of
Python generators. It provides a decorator that let you write the
following paradigm::

  from infrae.comethod import cofunction

  @cofunction
  def processor(**options):
      # Init code
      content = yield
      while content is not None:
           # Work on content, set result in result.
           content = yield result
      # Cleanup code


If you create more of those comethods you can nest them::

  import logging

  @cofunction
  def logger(parent **options):
      logger = logging.getLogger(options.get('name', 'default'))
      logger.info('Start')
      content = yield
      while content is not None:
           result = parent(content)
           logger.info('Processed {0}, got {1}'.format(content, result))
           content = yield result
      # Cleanup code
      logger.info('Done')


And you can use it like this::

   with processor() as process:
      with logger(process) as log:
         for item in generator():
             log(item)

Or alternatively::

   with processor() as process:
      with logger(process) as log:
         log.map(generator)


Where generator is a generator that yield values to work on. Of
course, you can do more interesting things after.

You can find the Mercurial code repository at:
https://hg.infrae.com/infrae.comethods/

Changes
=======

1.0 (2011/11/07)
----------------

* Initial version.
zeam.jsontemplate 0.1
Fanstatic packaging of json template
License: BSD
Keywords: fanstatic jsontemplate

zeam.jsontemplate
*****************

Introduction
============

This library packages a patched version of json template for
`fanstatic`_. This behaved exactly like the official version, except
it add an option ``undefined_callable`` that is a function that will
be called in case of an undefined value, to return the value to be
use.

.. _`fanstatic`: http://fanstatic.org

This requires integration between your web framework and ``fanstatic``,
and making sure that the original resources (shipped in the ``resources``
directory in ``zeam.jsontemplate``) are published to some URL.


How to use?
===========


You can import ``jsontemplate`` from ``zeam.jsontemplate`` and
``need`` it where you want these resources to be included on a page::

  >>> from zeam.jsontemplate import jsontemplate
  >>> jsontemplate.need()


CHANGES
*******

0.1 (2011/11/07)
================

- Initial release.