Sunday, February 26, 2012

A couple of new modules for messing about with objects

blueprint - a neat tool/library that allows data objects to be used as bases for new data objects. And other cool stuff. "Think of it as prototypal inheritance for Python! " I see a lot of potential in video games with procedural content.
objectifier - in a similar (messing about with objects) vein, here we create objects from dictionaries.

Sunday, February 12, 2012

reStructuredText to ...

Convert reStructuredText files to...

rst2blogger - HTML to post on blogger.com blogs. Hmm, thanks Doug :-)
rst2hatena - posts for Hatena's Diary service.
rst2marsedit - HTML that can be used with the MarsEdit blogging tool.
rst2atom - skip the whole "blog" thing and send your rst directly to XML ATOM 1.0 feed readers.
blohg - blog posts (stored in Mercurial.)

rst2beamer - the Beamer LaTeX document class for presentations.
slides - the Beamer LaTeX document class for presentations.
rst2odp - odp files for OpenOffice Impress. Probably nicer than using the GUI ;-)
rst2slides - an HTML5 slideshow.
bruce - an interactive OpenGL slideshow.
StarScream - a DHTML slideshow.
landslide - an HTML slideshow.

handcrank - a static website.
soho - a static website.
flask-rst - a static website.
rest2web - a static website.
cyrax - a static website.

sphinx - your project's documentation. And then some*.

rst2pdf - PDF using ReportLab.
rst2texinfo - texinfo (the official documentation format of the GNU project.)
rst2xamlXAML for WPF and Silverlight / Moonlight.
rstex - a more powerful version of the built-in LaTeX support docutils provides (inline math, equations, references, and raw latex.)
epubmakerEPUB.

restxml - XML using XSLT. Oh, yes.

Sorry if your tool isn't on this list. I tried :-)



* there's a whole other blog post listing Sphinx extensions... later... :-)

Wednesday, February 8, 2012

A couple of useful tools

logging_tree - introspect and display the logger tree inside the standard library's "logging" package. This could be an invaluable tool to discover what's really going on in your application's logging - and in particular perhaps why logging isn't working how you think it should.
hgtools - adds support for Mercurial in setuptools, both for the basics like listing the files under revision control (so find_packages and  include_package_data can do their work without needing explicit listings of files in MANIFEST.in) but also supporting pulling the version number from the repository tag so it doesn't have to be duplicated. The git equivalent appears to be setuptools-git (formerly known as gitlsfiles.)

Sunday, February 5, 2012

A few more random bits

localshop - "really, really alpha" but promising local PyPI mirror / private repository. Yes, another one. This one might just be the one to meet my specific requirements though...

pytagcloud - is one to watch: make tag clouds as PNG images or HTML. Usage is a bit fiddly at the moment and I couldn't replicate the results they got. I think the key is having a good tag (interesting word) extractor. This bit of code might come in handy when experimenting with it:
import re
from roundup.backends.indexer_common import STOPWORDS
import requests, collections, bs4
soup = requests.get('http://www.python.org/about/').text
text = bs4.BeautifulSoup(soup).find('div', id='content-body').get_text()
counts = collections.defaultdict(int)
for word in re.split('\W+', text):
    if word.upper() not in STOPWORDS and len(word)>2:
        counts[word.lower()] += 1
words = sorted((count, word) for word, count in counts.items())
tags = [(word, count) for count, word in words[-30:]]

from pytagcloud import make_tags, create_tag_image
create_tag_image(make_tags(tags), 'cloud.png')
Sadly it doesn't quite work for me. I suspect something might up up with my pygame/platform's TTF support. I also had to add a Font object cache to stop it blowing up on my system (git pull request submitted :-)

slumber - call web RESTful (HTTP) APIs from Python code. Supports JSON, and YAML (with pyyaml installed) and is built on top of the awesome requests. While looking at slumber I picked up this tip for validating and pretty-printing JSON:
$ echo '{"json":"obj"}' | python -m json.tool
{
    "json": "obj"
}

Thursday, February 2, 2012

Another small sampler to finish the week

OMG it's beautifulsoup4 - BeautifulSoup for Python 3! Beware: this release involves API changes, amongst other things.
heightfield is a neat toy that generates 256x256 heightfields using particle deposition.
pager - "page output to the screen, read keys and get console dimensions."

Wednesday, February 1, 2012

Another sampler

I do love a module that has a nice, simple purpose and a direct, to the point name :-)

rfc6266 - parse and generate Content-Disposition headers as per RFC 6266
walkdir  - making it easier to use os.walk() to walk directories with filtering, depth limiting, flattening and handling of symlink loops to boot!
times - "everything sucks about our mechanisms to represent absolute moments in time, but the least worst one of all is UTC." Indeed. In a style similar to the explicit bytes/unicode objects in Python 3 with encodings explicitly dealt with at input and output, this library encourages times to be UTC internally, with timezones only every dealt with at input and output time.

Tuesday, January 31, 2012

Some new packages that look interesting

d - "If you have a small project and want to quickly write some docs that don't look like ass." It uses Markdown, pygments and pyquery and keeps things simple. It has none of the capabilities, nor the complexities, of Sphinx.
success - "import success" (waiting for the module to be uploaded though ;-)
Airy - a new Web application development framework. "Contrast to most currently available frameworks, Airy doesn’t use the standard notion of HTTP requests and pages. Instead, it makes use of WebSockets and provides a set of tools to let you focus on the interface, not content delivery."
timerange - generates list of dates in various formats.
pbs - "PBS is a unique subprocess wrapper that maps your system programs to Python functions dynamically." An example given is:
from pbs import ifconfig
print ifconfig("eth0")