# HG changeset patch # User Jeff Hammel # Date 1330721423 28800 # Node ID eb15c8321ad815b59ba08d3f25bed806e28adf21 # Parent ac592b097688aa81a31c9dcef66a5e9afc1e37b8 sort by default diff -r ac592b097688 -r eb15c8321ad8 fileserver/web.py --- a/fileserver/web.py Wed Feb 29 16:44:32 2012 -0800 +++ b/fileserver/web.py Fri Mar 02 12:50:23 2012 -0800 @@ -41,10 +41,11 @@ class DirectoryServer(object): - def __init__(self, directory): + def __init__(self, directory, sort=True): assert os.path.exists(directory), "'%s' does not exist" % directory assert os.path.isdir(directory), "'%s' is not a directory" % directory self.directory = self.normpath(directory) + self.sort = sort @staticmethod def normpath(path): @@ -65,6 +66,8 @@ """ parts = ['Simple Index'] listings = os.listdir(directory) + if self.sort: + listings.sort() listings = [(os.path.isdir(os.path.join(directory, entry)) and entry + '/' or entry, entry) for entry in listings] for link, entry in listings: