All pastes #828379 Raw Edit

Unnamed

public python v1 · immutable
#828379 ·published 2007-12-22 12:23 UTC
rendered paste body
#!/usr/bin/pythonimport osclass Crawler:    def __init__(self, name_checker):        self.checker = name_checker    def walk(self, dir):        result = []        for path, dirs, files in os.walk(dir):            for dir in dirs:                print 'DIR: ', os.path.join(path,dir)            for file in files:                #print file                f = os.path.join(path, file)                if self.checker(f):                    result.append(f)                print '\t',f        print "-------------- problems -------------------"        for f in result:            print fclass Checker:    def __init__(self):        pass    def check(self, abs_name):        dir = ''        file = ''        if os.path.isdir(abs_name):            dir = os.path.dirname(abs_name)        elif os.path.isfile(abs_name):            dir = os.path.dirname(abs_name)            file = os.path.basename(abs_name)        for c in file:            if c in [0x88, 0xe76169 , 0xe47265, 0xf66e656e, 0xf6696e74,  ]:                return True            else:                return Falseif __name__ == "__main__":    c = Checker()    t = Crawler(c.check)    t.walk('/srv')# vim: ts=4 sw=4