Changed display of sort by extension in several ways:
Separator character now appears at the beginning of the extension.
'dot files' (with a leading separator character) are now shown as
having no extension.
Extensions are now enclosed in parens instead of curly braces for
better readability.
1 parent 9839e48 commit a8e79b594f7d8a5336c578c6803c47c83386fc3f
@tundra tundra authored on 21 Jul 2001
Showing 1 changed file
View
32
tdir
import sys
 
# Version info
 
VERSION = "$Id: tdir,v 1.65 2001/07/21 20:10:06 tundra Exp $"
VERSION = "$Id: tdir,v 1.66 2001/07/21 20:38:29 tundra Exp $"
 
 
# Booleans
 
 
def OrderByExtension(list):
ExtList = {}
ExtList[""] = [] # List of files with no extension
 
for x in list:
y = x.rfind(SEP)
if y != -1: # File has extension
ext = x[y+1:]
if not y: # Handle special case of 'dot file' type files
ext = ""
name = x
elif y != -1: # File has extension
ext = x[y:]
name = x[:y]
if not ExtList.has_key(ext):
ExtList[ext]= []
ExtList[ext].append(name)
else: # File has no extension
ExtList[""].append(x)
ext = ""
name = x
ExtList[ext].append(name)
return ExtList
 
 
def OutputColumns(list, ISDIRLIST):
for x in Ext:
FileList = ExtList[x]
if len(FileList) > 0:
FileList.sort()
if x == "":
sep = x
else:
sep = SEP
sys.stdout.write("{" + sep + x + "}\n")
sys.stdout.write("(" + x + ")\n")
OutputColumns(FileList, FALSE)
 
else:
FileList.sort()