def pagefile(name): if not isfile(name): print name, ': no such file' return LINES = 24 - 1 # For THINK C 3.0, make the path absolute: # if not macpath.isabs(name): # name = macpath.cat(mac.getcwd(), name) try: fp = open(name, 'r') except: print name, ': cannot open' return line = fp.readline() while line: for i in range(LINES): print line, line = fp.readline() if not line: break if line: try: more = raw_input('[more]') except (EOFError, KeyboardInterrupt): print break if string.strip(more)[:1] in ('q', 'Q'): break
def remove(name): if not isfile(name): print name, ': no such file' return try: mac.unlink(name) except mac.error, msg: print name, ': unlink failed:', msg
def pagefile(name): import string if not isfile(name): print name, ': no such file' return LINES = 24 - 1 # For THINK C 3.0, make the path absolute: # if not macpath.isabs(name): # name = macpath.cat(mac.getcwd(), name) try: fp = open(name, 'r') except RuntimeError, msg: raise TclRuntimeError, (name, ': open failed :', msg)
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 try: list = mac.listdir(name) except: cache[name] = NONE return NONE cache[name] = list if name[-1:] = ':': cache[name[:-1]] = list else: cache[name+':'] = list return list
return if hasglobchar(cmd): if args: print cmd, ': cannot glob pattern with arguments' return 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):
##################################################################### # GLOBALS ########################################################### ##################################################################### global newString # global oldString # global tempString # newString = '' # oldString = '' # tempString = '' # ##################################################################### # START ############################################################# ##################################################################### # check for correct command line structure if (len(argv) == 1) or (len(argv) == 2) or (isfile(argv[2]) == False): usage_message() sys.exit(1) else: if (len(argv) == 3): # assign filename to oldString oldString = argv[2] # check if '-c' was given on the command line if (argv[1] == '-c'): newString = lower_case(oldString) # check if '-s' was given elif (argv[1] == '-s'): newString = remove_spaces(oldString)