This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

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.
Release History

Release History

1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
infrae.comethods-1.0.tar.gz (2.7 kB) Copy SHA256 Checksum SHA256 Source Nov 7, 2011

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting