... Python software
... ... License
... German texts
... ... Einführung
... ... Workshop Python
... ... Perl und Python
My Python Software
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.
The module ftputil is a high-level interface to the
# 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 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 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)
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)
URL of this page: http://www.sschwarzer.net/python/python_software.html