diff options
| -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 + |
