import os.path __author__="bjschuma" __date__ ="$Dec 6, 2009 11:35:56 PM$" import os from message import write # Check if path is a directory def checkDir(path): path = os.path.expanduser(path) if checkPath(path) == True: return os.path.isdir(path) return False # Check if path exists def checkPath(path): path = os.path.expanduser(path) write("Checking if "+path+" exists", True) return os.path.exists(path) def expandPath(path): return os.path.expanduser(path) # Open a file def fopen(path,flags='r'): path = os.path.expanduser(path) # If we are reading a file, check that it exists if ('r' in flags) == True: exists = checkPath(path) if exists == False: write(path+" does not exist", True) return None return open(path, flags) # Return a listing of directory contents def ls(path): if checkDir(path) == False: return False return os.listdir(path) # Remove a file def rm(path): if checkPath(path)==False: write("File does not exist: "+path) return; os.remove(path)