2 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.
Wither
XML/HTML Generation DSL
Intro
Wither is a library designed to make XML generation under python as simple and as nicely formatted as python code.
Wither is implemented as a thin statless wrapper around etree.Element objects and works by making use of the ‘with’ keyword in python to build a nested tree of etree objects that can be processed with standard tools/techniques
by using python as a DSL you can automatically ensure that all tags are properly closed and also execute arbitrary python code to build things such as lists or to embed widgets
Example
>>> import lxml.usedoctest
>>> from wither import Node
>>> n = Node('html')
>>> with n.head as head:
... head.title == 'Wither README Example'
... head.link(href='http://code.pocketnix.org/wither', rel='homepage')
<...>
>>> with n.body as body:
... body.h1 == 'Welcome to the Wither README'
... with body.div as div:
... div.p == 'This is the example from the README file'
... div.p(style='color: red;') == 'Big Red Warning'
<...>
>>> print(n)
<html><head><title>Wither README Example</title><link
href="http://code.pocketnix.org/wither"
rel="homepage"/></head><body><h1>Welcome to the Wither README</h1><div><p>This
is the example from the README file</p><p style="color: red;">Big Red
Warning</p></div></body></html>
Features
Uses python as a DSL for XML Generation
Uses/Abuses python syntax to make node generation shorter and more visually appealing
Uses lxml for document generation
Possibility to fall back to built in etree implementations (XXX TODO: Write me)
Easy widget creation
Implicit verification of document correctness (python’s indentation means you cant forget to close a tag)
Dependencies
lxml - may be possible ot replace this with python’s inbuilt etree support
Installation
$ virtualenv env $ . env/bin/activate # pip install wither
Compatibility
Wither supports Python 2.7 and Python 3.2 and up as its supported python versions but may also work on earlier versions of python 3 and python 2.6. while these platforms are automatically tested to check for breakages these earlier versions are not officially supported and failing tests are for informational purposes only.
Motivations
Wither is very much a project that was written ‘because i can’. I have multiple python modules that abuse python syntax in interesting ways to do things like pattern matching of automatic retry of transactions for Databases that are all concise and visually appealing.
after seeing the ‘with’ statement and its use in python 2.6 with nesting for using multiple context generators (instead of python 2.7’s flattened version) i decided to see if i could use this to upgrade an existing XML generation program that used a similar concept with object.
the aim of this project is not to create a fast generator but create something that looks ‘right’ when included inline with python code and support dynamic features like a string template library would.
Futher Ideas
By using ‘yeild’ in strategic spots it may be possible to paritally render a template allowing one to send a prerendered ‘frame’ (or the head part of it at least) and then generate the body followed by the tail (of the frame) to the client thereby speeding up transmission of the first byte to the client and avoiding a dogpile of transmission at the end of the request. this should allow clients to render thier pages quicker as well as they have partial data with which they can start planning out the layout of the page
Metadata
Release files for wither 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Files added late
2 files were uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distributions (sdists)
| File | Size | Uploaded | |
|---|---|---|---|
| wither-1.1.zip | 11.0 kB | Details | |
| wither-1.1.tar.bz2 | 6.5 kB | Details |
Release files / wither-1.1.zip
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | wither-1.1.zip |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13af60971a6ebf42b7da7381361f5aa9febba81768b1ec206251254fe9425544
|
|
BLAKE2b-256 checksum How to use checksums |
7689dad559623664094f9760705e11025282df1f4f073225f2280fff1ad67b0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / wither-1.1.tar.bz2
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | wither-1.1.tar.bz2 |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0162443aa315f4078a534e9420b33bb424f343e157ceb665e514b7a52d01321
|
|
BLAKE2b-256 checksum How to use checksums |
51cb896b16140760d36c21712a5b77b36358e07af9fabd874d15a7964f32bb59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |