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

This project provides a library which allows for very flexible and fast template renderings at the expense of security. It uses python code to generate variables which are then substituted in a string.Template.

Examples

Here’s a basic example:

from uftlib import UFTemplate

initial = """import datetime
def f(x):
    return x*x

def getnow():
    return str(datetime.datetime.now())

a = 0
b = 100
i = 0"""

oncycle = """a += 3
i += 1
s = f(i)
b += a
now = getnow()"""

template = """Now = ${now}
Render nr. ${i}
f(${i}) = ${s}
b = ${b}
We live in ${where}"""

tpl = UFTemplate(initial, oncycle, template, where="Indonezia")
for text in tpl.render_many(1):
    print(text)

We should get the following output:

Now = 2015-08-25 16:09:07.015948
Render nr. 1
f(1) = 1
b = 103
We live in Indonezia

We can reset the template to it’s initial state and obtain the same results:

tpl.reset()
for text in tpl.render_many(2):
    print(text)

You should get the following output:

Now = 2015-08-25 16:09:07.016970
Render nr. 1
f(1) = 1
b = 103
We live in Indonezia
Now = 2015-08-25 16:09:07.017298
Render nr. 2
f(2) = 4
b = 109
We live in Indonezia

Warning

You can put any kind of python code in the initial section, such as open and read web pages, connect to databases, read and parse other files, but this comes at the expense of security, as malitious code will be run on the same environment as the interpreter. This is a tradeoff which is not advantageous for all projects and needs, so use this library at your own expense.

Flexibility

The three required arguments (initial, oncycle and template) may be stored on a database and may be retrieved by multiple programs in the network, which parallelize and distribute the task. Most templating engines store some of the logic in the template and some of it in the code which calls the template render, leading to a big mess. Use uftlib to cut that corner.

Release History

Release History

0.2

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

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
uftlib-0.2.tar.gz (18.1 kB) Copy SHA256 Checksum SHA256 Source Apr 18, 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