The Voidspace Python Archive

Finished Projects and Unmaintained Code

Weirdness on Discworld

This page has the archive of finished projects and unmaintained code. Contained here are code snippets, modules and CGI scripts that are likely to be useful to someone - but that I don't use myself any more [1]. Everything here works (possibly within limitations) - but isn't going to get developed any further by me. I will still respond to bug reports though - and probably fix them Smile .


Remote Directory Sync Utility

Version 1.0.0 13th June 2004

DirWatcher is an offline directory sync tool - a remote directory sync utility. It's useful where you maintain identical directory structures on two machines. For example when working on projects both at home and at work. DirWatcher can profile a directory. When you reprofile, it can summarise all the changes into a single zipfile. From that zipfile it can implement all the changes on the other computer.

DirWatcher Home Page and Download Links

Ordered Dictionary

Keeping Things in Order

Version 0.2.2 25th November 2006

This module contains a class called OrderedDict. It is written by Nicola Larosa in collaboration with Michael Foord. The ordered dictionary is a dictionary like object (actually a subclass of the normal dictionary data-type) that keeps keys in insertion order.

This means it has all the normal dictionary methods. Methods that would normally return values in an arbitrary order are now ordered. You can alter the order through the setkeys method.

Because these dictionaries are ordered, they also have several sequence methods. These include index, insert, reverse, and sort.

Additionally, there is a class called SequenceOrderedDict. This has custom sequence objects that replace the keys, values, and items methods. They are callable - so they behave exactly the methods. You can also manipulate them directly as sequences.

Download links :

This version of the ordered dictionary replaces the previous version which was actually a sorted dictionary. This one is better.


Logging and Control for sys.stdout and sys.stderr

Version 3.0.0 28th August 2006

StandOut is a simple way of adding varying levels of verbosity to your program and to allow logging to a file: using just the normal print command.

You set a verbosity level (or your user can, from the command line for example), and only messages with a priority greater than that setting are displayed. You can set the general priority levels, or specify an explicit priority for individual messages.

You can set the threshold level for the log file to be the same, or different. Very easy to use and saves having seperate code to maintain a log or determine message priority.

It will divert sys.stdout and / or stderr and can log them both to the same file.

See the StandOut Homepage.

Download it here :


Textmacros for docutils

The textmacros module is a part of Firedrop2. It is also very useful for any program that generates HTML output - like docutils.

This module lets you easily add smilies, Python source colouring, acronyms, and more, to docutils.

See the textmacros homepage.

HTML Scraper

A Simple HTML Parser

Version 1.3.0 6th September 2004

Scraper is a class to parse HTML files. It contains methods to process the 'data portions' of an HTML page, and also the tags. These can be overridden to implement your own HTML processing methods in a subclass. This class does most of what HTMLParser.HTMLParser does - except without choking on bad HTML. It uses the regular expression and a chunk of logic from (standard Python distribution).

It is most useful when you want to modify a part of a page - and guarantee that the rest of the html will be unmodified by your parser.

Download it here :

linky Local Link Checker

Check Your Website for Invalid Links and Image Tags

Version 0.1.1 16th February 2005

This program is almost a recipe, but it can be very useful, so I've included it here. It was written for a friend of mine (Aidan Ashby) to check the links on his website. The problem is that when you test your website on windows, with case insensitive filenames, it can appear to work fine. When you upload it to a Linux server, mistaken capital letters become broken links and missing images.

linky is meant to be used in conjunction with a server like Xitami acting as localhost. linky will then crawl your site, checking all your local links. It can also compare the URLs in your links and img tags to the files on your hard drive. It will warn you of any case errors, that just link checking would miss. As a bonus it will also let you know about any apparently unused files saved in your web folders. This can help you find unnecessary image files etc.

All the heavy lifting of parsing the pages for links and image tags is done by Beautiful Soup. You'll need this in order to use linky. Beautiful Soup makes parsing HTML like this sooooooo easy. If you have my StandOut module, it can be used for logging the output to a file. linky doesn't check external links, but it would be very easy to modify. There's no reason why it shouldn't work online.

Download it here :

The zip has StandOut and BeautifulSoup included.


See the World Through the Eyes of Google

Version 0.1.7 26th August 2005

This is a simple implementation of a proxy server that fetches web pages from the google cache. It's based on SimpleHTTPServer and lets you explore the internet from your browser, using the google cache. See the world how google sees it. Alternatively, it's retro internet - no CSS, no javascript, no images, this is back to the days of MOSAIC !

To use, run this script and then set your browser proxy settings to localhost:9080. I've tested it on Windows XP with Python 2.3 and Firefox/IE and also had reports of it working with Opera/Firefox on Linux. It needs the module (and a google license key). Some useful suggestions and fixes were given by 'vegetax' on comp.lang.python, and Lee Joramo at the Python Cookbook.

Download it here : (5k)


How Well Ranked is Your Website ?

Version 0.1.0 18th April 2005

googlerank is another small recipe that uses the google api. You give it a domain (by setting a variable), and then a set of search terms via stdin. It then does google searches until a result from your domain is found (so long as it is within the first 200 results - 20 searches). This tells you how far down the list your site appears for given search terms. This is a useful tool for working with website design - it's also very interesting.

It produces results that look like :

For the search term "python cookies" :
Out of an estimated 176000 results.
Your website came at position "7".
For the search term "cyberpunk" :
Out of an estimated 298000 results.
Your website came at position "154".

Download it here : (5k)


Case Insensitive Dictionary, List, and Sort

Version 2.2.0 21st February 2005

A module that provides two classes, and a function, for dealing with dictionaries and lists in a case insensitive way. caselessDict is a dictionary with case insensitive keys and methods. caselessList is a list like object with all the list methods, many of which are case insensitive. cSort is a function for sorting strings in a caseless way. (Which is also used as the sort method for caselessList). Full docs included in the source code. caselessDict and caselessList are subclasses of built-in types and so require Python 2.2 +, cSort isn't and therefore doesn't.

Download it here :


Functions for Lists, Quotes and CSVs

Version 1.4.0 28th August 2005

This module provides functions for turning lists into strings - and back again. It properly handles quoting and unquoting of elements and can even parse recursive lists. Because a CSV (comma separated value) file is basically a list: the module includes functions for easily reading and writing CSVs.

Read all about it at the listquote homepage.

Download it here :


Split and Recombine Large Files

Version 1.0.0 28th May 2004

This is a piece of code that has been written many times by many people - but dammit python makes this kind of hacking fun !! Anyway - I had a 132meg file to take home and my biggest memory card was 128mb. The splitter class will chop files into chunks of definable size, and automatically join them together when given the filename of the first chunk. I haven't done a front end - but you can use it from any interactive python prompt. (I recommend IPython). Full docs in the source code as usual.

from splitter import Splitter
splitter = Splitter()

Download it here :

This recipe uses the marvellous Path Module by Jason Orendorff. (included in the zip file)


Intelligent Include Directive for Python

Version 1.0.0 13th August 2004

A recursive include directive - with other nifty features.

  • incdir command to tell it where to fetch includes from
  • will replace 'from module import... commands'
  • will remove stuff below if __name__ == "__main__" lines in included modules
python infilename outfilename
## INCLUDE filename
## INCDIR 'path name'

Browse the docs here.

This program allows you to include scripts into other scripts. It is written to make it easier to distribute scripts as single files: but maintain them as seperate modules.

Download it here :


Wordlist for Naming Python Projects

Version 1.0.0 7th October 2004

Slightly tongue in cheek, this isn't code at all. It's three lists of English words containing 'py' - intended to be helpful to those choosing names for python projects. The word lists were produced from an initial file of about 8 Mega Bytes. Words selected all contain 'py', single words or hyphenated words, but no compound words.

  • pywordlist.txt All words containg 'py' 23kb - 1946 words
  • pywordlist2.txt All words starting or ending in 'py' 16kb - 1406 words
  • pywordlist3.txt All words starting or ending in 'py'and less than 10 chars long 5kb - 658 words.

Download it here :


Date and Password Stamping

Version 1.1.5 13th September 2004

A pure python module for combining data using a 'binary interleave' - two pieces of data are woven together a bit at a time, making them unrecognisable in the process. Another function reverses the process. A table encoding can be used to turn the resulting binary string into an ascii string. Useful for encoding passwords/timestamping into cookies or html form fields. This provides a simple mechanism for secure, time limited, logins when writing CGIs. Because the password (or more likely the SHA hash) is timestamped, even if extracted it can only be used for a very limited time.

The binary interleave functions can be used for combining, 'watermarking', or timestamping any data. The binary to ascii function like the binascii module - but the mapping is user definable.

Browse the docs here.

Download it here :

FSDM and Filestruct

Objects for Representing and Comparing File Structures

Version 1.0.4 05th July 2004

This module is written for Dirwatcher, which is an offline directory sync utility. I wrote it because I work on various projects at home and at work. My home computer is not online. This means I often have to copy folders between work and home. Some of these folders get quite sizeable and it would be nice to just transfer the new/modified files, plus a list of any changes...

filestruct is a module for describing file structures and changes to file structures; using a basic markup - that I call FSDM.

This could also form the basis of (for example) an incremental archive, a version control system etc. In fact anything where changes to a file system need to be monitored, or described and changes stored. also works as a command line tool for copying and restoring changes - but for a more convenient, cross-platform GUI see Dirwatcher.

Download it here :


Functions for Date Handling

Version 1.0.2 31st Jan 2004

This is a set of functions for dealing with dates - written for a little tool called Victory Days. They are particularly useful for dealing with appointments - e.g. the second Tuesday in March etc...

The functions will tell you what day of the week a date is, work out the 'Julian day number' of a date (and the reverse), add days (or weeks, months etc) to a date, tell you the number of days between two dates, and format a datestring etc. Full correction for leap years and much more. Browse a list of the functions here, and their usage.

Download it here :


Most of this module is obsolete - either use the datetime module or the wrapper module dateutil.

This module is included here because it's still used by a couple of my modules and programs and I can't be bothered to refactor. Very Happy

It might be worth noting that there is a version [2] of datetime that is compatible with Python 2.2 included as part of SnakeSQL.

HTTP Test Script

Understanding HTTP Headers, Cookies, and Authentication

Version 1.3.1 10th January 2005

This is a CGI that I created as I was gaining a basic understanding of the http protocol. Given a url (from an html form) it will attempt to fetch that webpage. It displays all the headers that the server sends, details of any errors, and can even do basic authentication.

If cookielib or ClientCookie are available then it will save and handle cookies. Will also show you the raw HTML of the first part of the content fetched. This can be useful for debugging in various situations, or just as an illustration of aspects of CGI and http.

Download it here :

Check it out at :

Random Link

Teleport Out of Here

Version 1.0.0 21st January 2004

Version 2.0.0 5th February 2005

This is the first CGI I ever wrote. It's very basic but, it's a script that is asked for regularly. When this CGI is activated it diverts the browser to a location randomly chosen from a list stored on the server. Just a fun diversion for a website - guaranteed no serious use possible.

Version 1 sends a redirect header to a url randomly selected from a list (supplied as a file). With this version the user doesn't know where they will end up when they select the link.

Download it here :

The zip file has a linkfile with a selection of URLs to jump to.

Jump to a random location with : The randlink Portal

Version 2 sends a little piece of javascript with a randomly chosen URL already inserted. The advantage of this over normal Javascript 'random link' scripts is that the choice is made server side, the client doesn't have to download the whole list of URLs. It can also insert a relevant title for the url.

Download it here :

The zip file has a linkfile with a selection of URLs and Titles.

Randomly selected link, by :

Victory Days

A Tool for Calculating Victory Days

Version 1.0.0 6th Feb 2004

In the Jesus Fellowship Church we celebrate seven 'Victories' - moments of spiritual significance for the people who join us. The Seven Victories are :

  1. Conversion
  2. Baptism
  3. Making Covenant - Joining the Church
  4. Brotherhood - 3 months after making covenant
  5. Discipleship - 6 months after making covenant
  6. Endurance - 9 months after making covenant
  7. Fruitfulness - 12 months after making covenant

We celebrate these victories in agape, our Tuesday night 'family meal'. The challenge of course is working out which Tuesday is closest to 3, 6, 9, and 12 months after making covenant ! Victory Day Software does it all for us, with a nice Tkinter front end. It uses the dateutils module to work out the dates.

Victory Day Software Home Page


Separate Building and Testing

Version 1.1.1 22nd September 2005

Often when writing CGIs (or even just editing my website), the folder I edit in is different from the folder I need the files in to test. This script will automagically copy files and directories from one place to another.

You can specify multiple sets of files and directories to copy. It requires Pythonutils 0.2.2.

Download it here :

[1]Some of them I do use, but I consider them finished, and am unlikely to put any more work into them.
[2]Almost complete.

For buying techie books, science fiction, computer hardware or the latest gadgets: visit The Voidspace Amazon Store.

Hosted by Webfaction

Return to Top

Page rendered with rest2web the Site Builder

Last edited Tue Aug 2 00:51:34 2011.