My Python Software

I have written the following Python programs or modules which you can get for free under an Open Source license. A summary of the packages is listed below.

Most of the code was developed under OS/2 and FreeBSD (now on Gentoo Linux), but should run (perhaps with minor modifications) on all platforms which support Python. If such changes are necessary, please contact me, so I can include your patches in the regular versions. Please send me also your suggestions and comments.

See the bottom of the page for a version and download summary. There you can find also links to the documentation.

ftputil

The module ftputil is a high-level interface to the ftplib module. The FTPHost objects generated from it allow many operations similar to those of os and os.path. An example:

# download some files from the login directory
host = ftputil.FTPHost('ftp.domain.com', 'user', 'secret')
names = host.listdir(host.curdir)
for name in names:
    if host.path.isfile(name):
        host.download(name, name, 'b')  # remote, local, binary mode
# make a new directory and copy a remote file into it
host.mkdir('newdir')
source = host.file('index.html', 'r')  # file-like object
target = host.file('newdir/index.html', 'w')  # file-like object
host.copyfileobj(source, target)  # similar to shutil.copyfileobj
source.close()
target.close()

Also, there's host.stat to request size and modification time of a file. Even host.walk works. :-) But slow.

For more info and downloads go to the ftputil homepage.

irclogmerge

irclogmerge reads several IRC log files, merges them and writes them to one or more other files, sorted by the logged timestamps of the sessions. The program currently supports log files from ircII and mirc. (You may define a new class to support other formats. In this case, please send me your additions.) However, all fed IRC logfiles in each run have to be in the same format (i. e. were written by the same kind of client). As an example, I use irclogmerge to merge logfiles written by ircII on OS/2 and on Solaris.

The program also allows to split the resulting merged logfile month-wise. That means, each file will contain only IRC sessions from a distinct month.

Download irclogmerge (Python source code)

makepage

makepage allows you to create HTML pages from a description file (see the manpage and its description as an example) and a HTML format file. If you use the general markup of makepage to tag your section titles etc., all pages which use the same format file will have the same layout. So you can change the layout of several pages by modifying the format file and translate all page descriptions with makepage.

I know that HTML style sheets (not available in older WWW browsers) or server side includes (not available from all ISPs or only for more expensive accounts) offer a similar functionality, but makepage is useful if neither of the former is appropriate.

Because I now use Cheetah Template to maintain my website, I have stopped the further development of makepage. However, it may still be useful for you, since its usage is relatively simple. Moreover, you can use the Python code in your own programs.

Download makepage (zip format)

upload

The upload script uses files which contain lists of files to upload them to a given host. One of two given lists identifies files to be transferred in ASCII mode, the second mentions those to be uploaded in binary mode.

upload remembers the timestamp of the files it processes, so only changed files are transferred again in consecutive calls of the script. If neccessary, upload also creates directories on the remote host.

Note that upload doesn't use ftputil (see above), because I wrote that library much later and have only fixed bugs in upload since then.

Download upload (zip format)

Summary

Software Current version Online documentation Download
ftputil see the ftputil homepage
irclogmerge 1.0 see source file irclogmerge
makepage 0.8 makepage, text_areas makepage
upload 1.0.2 upload upload

URL of this page: http://www.sschwarzer.net/python/python_software.html