1. Arne Babenhauserheide
  2. babtools-misc


Arne Babenhauserheide  committed 090af6c

get_all_files_in is now a generator.

  • Participants
  • Parent commits 949796c
  • Branches default

Comments (0)

Files changed (1)

File get_all_files.py

View file
 def get_all_files_in(dir): 
 	"""Return a list of all files in the given folder.
+	>>> [i for i in get_all_files_in("babtools_misc.egg-info")]
+	['babtools_misc.egg-info/PKG-INFO', 'babtools_misc.egg-info/dependency_links.txt', 'babtools_misc.egg-info/SOURCES.txt', 'babtools_misc.egg-info/top_level.txt']
 	@param dir: The path to a directory. 
 	@return: A list of all files.
 	#: The walker shows all files and dirs in all folders (generator)
 	walker = walk(dir)
 	#: The list of files to be
-	files = []
-	for dir, dirs, filenames in walker: 
-		files.extend([join(dir, filename) for filename in filenames])
-	return files
+	for dir, dirs, filenames in walker:
+		for filename in filenames: 
+			yield join(dir, filename)
+if __name__ == "__main__":
+	from doctest import testmod
+	testmod()