This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

An implementation of lazy strings. Can be used in combination with gettext for the translation of web apps.

It’s less beautiful than speaklater (an other implementation of lazy strings), but I wanted lazy strings that work even if a single thread interleaves the processing of many http requests (this happens with async frameworks).

postpone doesn’t rely on a global state. And it doesn’t use the thread.local() trick that speaklater uses either.

Example of use:

>>> from postpone import evalr, LazyString as _

>>> translations = {
        "Order {item}.": "Commander {item}.",
        "Take a nap": "Faire une sieste",
        "Stare at the wall for %s minutes.": "Fixer le mur pendant %s minutes." ,
        "a new pillow": "un nouvel oreiller"
    }

>>> tasklist = [
        _("Order {item}.").format(item = _("a new pillow")),
        _("Take a nap") + '!',
        _("Stare at the wall for %s minutes.") % 30
    ]

>>> evalr(tasklist, translations.get)
['Commander un nouvel oreiller.', 'Faire une sieste!', 'Fixer le mur pendant 30 minutes.']

evalr walks python dictionaries, lists, tuples or sets and apply a function to all the strings wrapped inside a LazyString object.

To apply a function to the strings inside a single expression, you can use the eval method:

>>> s = _("Take a nap") + '!'

>>> s.eval(str.upper)
'TAKE A NAP!'

>>> s.eval(translations.get)
'Faire une sieste!'

Or, again, the evalr function

>>> evalr(_("a new pillow").capitalize(), translations.get)
'Un nouvel oreiller'

For most projects containing more than a few strings or languages, you’ll probably want to use the gettext module to supply you with a translation function.

import gettext
translation = gettext.translation("myproject", "./locale", ["fr"])
translated_tasklist = evalr(tasklist, translation.ugettext)

GitHub repo: https://github.com/leforestier/postpone

Release History

Release History

0.1.1

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

0.1.0

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

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
postpone-0.1.1.tar.gz (2.7 kB) Copy SHA256 Checksum SHA256 Source Feb 5, 2016
postpone-0.1.1.zip (4.6 kB) Copy SHA256 Checksum SHA256 Source Feb 5, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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