summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya Naik2013-12-17 13:19:56 +0530
committerAditya Naik2013-12-17 13:19:56 +0530
commitf6eb04f42784cb5a093843654032c8bddd20f311 (patch)
tree35f420ea497744f91160be407bb65cae1e30e26e
added the module
-rw-r--r--paths.py33
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
+