+
+# returns a list of tuples containing pathname and filename matching the given pattern
+# example-pattern: match all txt-files: ".*\.txt$"
+def crawlDirectory(directory, pattern):
+ expression = compile(pattern)
+ list = []
+ for root, dirs, files in walk(directory):
+ for file in files:
+ if expression.match(file) is not None:
+ list.append((root, file))
+ return list