예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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
예제 #8
0
def lsdir(dirname):
       if not isdir(dirname):
               print dirname, ': no such directory'
               return
       names = mac.listdir(dirname)
       lsfiles(names, dirname)
예제 #9
0
               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: