You can use dict to save the extension -> function:
funcMap = {".xc" : xc, ".x" : x}
Then you create a recursive function that takes one directory, gets a list of files in that directory, and determines the extension of each file:
def iterateDir(s): l = dir.list(s)
Now in this for loop, you need to determine if the entry is a file or directory, and do the right thing:
if isdir(entry): iterateDir(entry) elif ext in funcMap.keys(): funcMap[ext]()
This should work for what you want to do.
Disclaimer - cannot promise that all of this is truly Python. This is basically psuedocode with Python type syntax. You should be able to get an idea of ββwhat to do with it, though.
Matthew iselin
source share