changeset 365:a04ce1e6ea54

Bugfix in common.misc.find_files
author Joseph Turian <turian@gmail.com>
date Thu, 03 Jul 2008 18:48:32 -0400
parents 417355f15282
children 54384b1eb2b9 b08ee9615b1b
files common/file.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/common/file.py	Thu Jul 03 17:52:26 2008 -0400
+++ b/common/file.py	Thu Jul 03 18:48:32 2008 -0400
@@ -1,4 +1,5 @@
 import gzip, bz2
+import os, os.path, sys
 
 def myopen(filename, mode="r", bufsize=-1):
     """
@@ -16,15 +17,16 @@
     Find all files in dir by recursively directory walking.
     @param shuffle: Randomly shuffle the files before returning them.
     """
-    files = []
+    all = []
+    assert os.path.isdir(dir)
     for root, dirs, files in os.walk(dir):
         #sys.stderr.write("Walking %s...\n" % root)
         for f in files:
-            files.append(os.path.join(root, f))
+            all.append(os.path.join(root, f))
     if shuffle:
         import random
-        random.shuffle(files)
-    return files
+        random.shuffle(all)
+    return all 
 
 def ensuredir(dir):
     """