From f6eb04f42784cb5a093843654032c8bddd20f311 Mon Sep 17 00:00:00 2001 From: Aditya Naik Date: Tue, 17 Dec 2013 13:19:56 +0530 Subject: added the module --- paths.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 paths.py 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