Walker, FileSystem Ranger

As a way to learn a bit of GIO from the green pastures of Python, I threw together a functional programming replacement to Python's os.walk(). The WalkerTexasRanger class takes 3 functions. One for results, one to clear the results, and one when the walk is finished.

Lets look at how we use this.

import texas
import gtk

def onResult(walker, dirname, dirs, files):
    print dirname
    print 'dirs:', dirs
    print 'files:', files

# 3 funcs, onResult, onClear, onFinish
walker = texas.WalkerTexasRanger(onResult, None, lambda *a: gtk.main_quit())


You can get the module from here.

-- Christian Hergert 2008-09-22

Back to Index