def do_pwd(args): if args: print 'usage: pwd' else: print mac.getcwd()
# Maintain a cache of listdir(), isdir(), isfile() or exists() outcomes. import mac import macpath # The cache. # Keys are absolute pathnames; # values are 0 (nothing), 1 (file) or [...] (dir). # cache = {} # Current working directory. # cwd = mac.getcwd() # Constants. # NONE = 0 FILE = 1 LISTTYPE = type([]) def _stat(name): name = macpath.cat(cwd, name) if cache.has_key(name): return cache[name] if macpath.isfile(name): cache[name] = FILE return FILE
def reset(): G.debug = 0 G.ps1 = '$ ' G.homedir = mac.getcwd() G.commands = mkcmdtab() G.aliases = {}
def ResetVariables(interp): interp.globals['ps1'] = '$ ' interp.globals['ps2'] = '> ' interp.globals['home'] = mac.getcwd()
def PwdCmd(interp, argv): if len(argv) > 1: raise UsageError, 'usage: pwd' else: return mac.getcwd()