| |
---|
| | import sys |
---|
| | |
---|
| | # Version info |
---|
| | |
---|
| | VERSION = "$Id: tdir,v 1.52 2001/06/24 00:54:18 tundra Exp $" |
---|
| | VERSION = "$Id: tdir,v 1.53 2001/06/24 01:29:15 tundra Exp $" |
---|
| | |
---|
| | |
---|
| | # Booleans |
---|
| | |
---|
| |
---|
| | PAD = " " # Padding character |
---|
| | SEP = "." # Filename "extension" separator |
---|
| | TRUNC = "^" # Character indicating name truncation |
---|
| | |
---|
| | # Misc. |
---|
| | # Defaults |
---|
| | |
---|
| | RECURSE = FALSE # No recursion is the default |
---|
| | |
---|
| | RECURSE = FALSE # No recursion |
---|
| | SHOWDIR = TRUE # Show directories in listing |
---|
| | SHOWFILE = TRUE # Show files in listing |
---|
| | TREE = FALSE # Don't just show the directory tree |
---|
| | |
---|
| | def OrderByExtension(list): |
---|
| | ExtList = {} |
---|
| | ExtList[""] = [] # List of files with no extension |
---|
| |
---|
| | sys.stdout.write("\n\n") |
---|
| | |
---|
| | |
---|
| | def DisplayOutput(dir, DirList, FileList): |
---|
| | sys.stdout.write(dir.replace("\\", "/") + ":" + "\n\n") |
---|
| | sys.stdout.write(dir.replace("\\", "/") + ":" + "\n") |
---|
| | if not TREE: |
---|
| | sys.stdout.write("\n") |
---|
| | if len(DirList) > 0: |
---|
| | DirList.sort() |
---|
| | OutputColumns(DirList, TRUE) |
---|
| | if len(FileList) > 0: |
---|
| |
---|
| | def BuildFileList (args, dir, files): |
---|
| | DirList = [] |
---|
| | FileList = [] |
---|
| | for x in files: |
---|
| | if os.path.isdir(dir + "/" + x): |
---|
| | if os.path.isdir(dir + "/" + x) and SHOWDIR: |
---|
| | DirList.append(x) |
---|
| | else: |
---|
| | elif SHOWFILE: |
---|
| | FileList.append(x) |
---|
| | DisplayOutput(dir, DirList, FileList) |
---|
| | |
---|
| | |
---|
| | def Usage(): |
---|
| | sys.stdout.write("tdir - Copyright (c) 2001, TundraWare Inc., All Rights Reserved. \n\n") |
---|
| | sys.stdout.write(" usage: tdir [-Rhv] [-c #] [-s c] [-w #] [dir...] where,\n\n") |
---|
| | sys.stdout.write(" usage: tdir [-Rdfhtv] [-c #] [-s c] [-w #] [dir...] where,\n\n") |
---|
| | sys.stdout.write(" -R Recur down each named directory tree\n") |
---|
| | sys.stdout.write(" -c # Column width\n") |
---|
| | sys.stdout.write(" -d Do not display directories in output\n") |
---|
| | sys.stdout.write(" -f Do not display files in output\n") |
---|
| | sys.stdout.write(" -h Display this help information\n") |
---|
| | sys.stdout.write(" -s c Separator character\n") |
---|
| | sys.stdout.write(" -t Display only the directory tree - same as -Rdf\n") |
---|
| | sys.stdout.write(" -v Display tdir version information\n") |
---|
| | sys.stdout.write(" -s c Separator character\n") |
---|
| | sys.stdout.write(" -w # Width of output\n") |
---|
| | sys.stdout.write(" dir... List of directories to display. Defaults to ./\n") |
---|
| | |
---|
| | |
---|
| | # Program entry and command line processing |
---|
| | |
---|
| | try: |
---|
| | opts, args = getopt.getopt(sys.argv[1:], '-Rc:hs:vw:') |
---|
| | opts, args = getopt.getopt(sys.argv[1:], '-Rc:dfhs:tvw:') |
---|
| | except getopt.GetoptError: |
---|
| | Usage() |
---|
| | sys.exit(2) |
---|
| | |
---|
| |
---|
| | if opt == "-R": |
---|
| | RECURSE = TRUE |
---|
| | if opt == "-c": |
---|
| | COLWIDTH = int(val) |
---|
| | if opt == "-d": |
---|
| | SHOWDIR = FALSE |
---|
| | if opt == "-f": |
---|
| | SHOWFILE = FALSE |
---|
| | if opt == "-h": |
---|
| | Usage() |
---|
| | sys.exit(0) |
---|
| | if opt == "-s": |
---|
| | SEP = val[0] |
---|
| | if opt == "-t": |
---|
| | RECURSE = TRUE |
---|
| | SHOWDIR = FALSE |
---|
| | SHOWFILE = FALSE |
---|
| | TREE = TRUE |
---|
| | if opt == "-v": |
---|
| | sys.stdout.write(VERSION + "\n") |
---|
| | sys.exit(0) |
---|
| | if opt == "-w": |
---|
| |
---|
| | |