def rmdir(name): if not isdir(name): raise TclRuntimeError, (name, ': no such directory') try: mac.rmdir(name) except mac.error, msg: raise TclRuntimeError, (name, ': rmdir failed :', msg)
def lsfiles(names, dirname): names = names[:] # Make a copy so we can modify it for i in range(len(names)): name = names[i] if isdir(macpath.cat(dirname, name)): names[i] = ':' + name + ':' columnize(names)
def rmdir(name): if not isdir(name): print name, ': no such directory' return try: mac.rmdir(name) except mac.error, msg: print name, ': rmdir failed:', msg
def glob(pathname): if not has_magic(pathname): return [pathname] dirname, basename = macpath.split(pathname) if has_magic(dirname): if dirname[-1:] = ':': dirname = dirname[:-1] list = glob(dirname) else: list = [dirname] if not has_magic(basename): result = [] for dirname in list: if basename or macpath.isdir(dirname): name = macpath.cat(dirname, basename) if macpath.exists(name): result.append(name) else: result = [] for dirname in list: sublist = glob1(dirname, basename) for name in sublist: result.append(macpath.cat(dirname, name)) return result
def lsdir(dirname): if not isdir(dirname): print dirname, ': no such directory' return names = mac.listdir(dirname) lsfiles(names, dirname)
try: words = expandglobword(cmd) except glob_error, msg: print cmd, ': glob error :', msg return if len(words) > 1: columnize(words) return cmd = words[0] print cmd if isfile(cmd): if args: print cmd, ': file command expects no arguments' return do_page([cmd]) elif isdir(cmd): if args: print cmd, ': directory command expects no arguments' return do_cd([cmd]) else: print cmd, ': no such command, file or directory' glob_error = 'glob error' def expandgloblist(words): res = [] for word in words: if hasglobchar(word): res = res + expandglobword(word) else: