File:  [LON-CAPA] / doc / tutorial / Attic / converter-daemon.py
Revision 1.1: download - view: text, annotated - select for diffs
Mon Jun 3 05:15:58 2002 UTC (21 years, 11 months ago) by bowersj2
Branches: MAIN
CVS tags: version_0_4, stable_2002_july, STABLE, HEAD
Added in stuff, working on Numerical Response. Commiting from home so I
can get to it from school tommorow.

----------------------------------------------------------------------

"""Run this script in the background while you're working on the
tutorial. Every five seconds, it scans for .pngs, .jpgs, and ..gifs
that have not yet been coverted to encapsulated postscript. If it
finds one, it converts it to an encapsulated postscript file of
the same name.

Requires the Python Imaging Library, a very common python library."""

import Image
import os
import time
import string

extensionsToConvert = [ 'png', 'gif', 'jpg' ]

def stripSuffix(s):
    return s[:string.rfind(s, ".")]
def suffix(s):
    return s[string.rfind(s, ".")+1:]

while 1:
    filelist = os.listdir(".")

    epsDict = {}
    for f in filelist:
        if suffix(f) == "eps":
            epsDict[stripSuffix(f)] = 0

    for f in filelist:
        if suffix(f) in extensionsToConvert and \
           not epsDict.has_key(stripSuffix(f)):
            try:
                im = Image.open(f)
            except:
                print "failed:", f
            im.save(stripSuffix(f) + ".eps")
            print "Converted " + f

    time.sleep(5)


    
    
    
    
    
    

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>