Added new symlink functions
[nil.git] / nil / directory.py
blob5439c5355238d3864d8d7857e1cb08d8e23a6bab
1 import os, nil.file
3 def get_list(path):
4 try:
5 entries = sorted(os.listdir(path))
6 except OSError:
7 return None
8 directories = []
9 files = []
10 for entry in entries:
11 current_path = os.path.join(path, entry)
12 if os.path.isdir(current_path):
13 directories.append(current_path)
14 else:
15 files.append(current_path)
16 return directories, files
18 def get_files_by_extension(path, extension):
19 result = get_list(path)
20 if result == None:
21 return None
22 directories, files = result
23 return filter(lambda path: nil.file.get_extension(path) == extension, files)