diff options
| author | Aditya Naik | 2013-12-17 13:19:56 +0530 |
|---|---|---|
| committer | Aditya Naik | 2013-12-17 13:19:56 +0530 |
| commit | f6eb04f42784cb5a093843654032c8bddd20f311 (patch) | |
| tree | 35f420ea497744f91160be407bb65cae1e30e26e /paths.py | |
added the module
Diffstat (limited to 'paths.py')
| -rw-r--r-- | paths.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/paths.py b/paths.py new file mode 100644 index 0000000..f0c55e1 --- /dev/null +++ b/paths.py @@ -0,0 +1,33 @@ +"""A simple module for creating lists of abspath of files in a directory. + Also creates lists by isolating the files of the required extension.""" + +import re +import os +import sys + + +def listpaths(path): + """get a list of all files""" + global filedir + filedir=[] + filepath=os.listdir(path) + for filename in filepath: + filedir.append(os.path.join(os.path.abspath(path),filename)) + return filedir + + +def listreq(path,ext): + """this function will list all files in the specified path with the given extension""" + global filedir + filedir=[] + filepath=os.listdir(path) + for filename in filepath: + filedir.append(os.path.join(os.path.abspath(path),filename)) + i=0 + while i <len(filedir): + if filedir[i][-len(ext):]!=ext: + filedir.pop(i) + else: + i=i+1 + return filedir + |
