29 |
|
|
30 |
import os.path |
import os.path |
31 |
|
|
32 |
def _listdir(path, extensions, dirs=0): |
def listdir(path, extensions, dirs=0): |
33 |
""" |
""" |
34 |
Returns all directories and files with specific |
Returns all directories and files with specific |
35 |
extensions under path. Nonrecursive. |
extensions under path. Nonrecursive. |
38 |
and not f == 'CVS' and '#' not in f and '~' not in f] |
and not f == 'CVS' and '#' not in f and '~' not in f] |
39 |
|
|
40 |
files = [f for f in files if extensions.count(f.split('.')[-1]) > 0 \ |
files = [f for f in files if extensions.count(f.split('.')[-1]) > 0 \ |
41 |
or os.path.isdir(_slashify(path)+f)] |
or os.path.isdir(slashify(path)+f)] |
42 |
if not dirs: |
if not dirs: |
43 |
files = [f for f in files if os.path.isfile(_slashify(path)+f)] |
files = [f for f in files if os.path.isfile(slashify(path)+f)] |
44 |
return files |
return files |
45 |
|
|
46 |
def _slashify(path): |
def slashify(path): |
47 |
""" |
""" |
48 |
Add a trailing slash if not already there. |
Add a trailing slash if not already there. |
49 |
""" |
""" |