"""
import os
+import re
import mod_python
import urllib
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>CRE</title>
<style type="text/css">
-body { background: url('Bamboo2-jc.png') #80FF80; }
+body { background: url('Bamboo2.png') #80FF80; }
a { color: black; text-decoration: none; }
a:hover { color: black; text-decoration: underline; }
a:visited { color: black; text-decoration: underline; }
size /= 1024
return "%s Tio" % size
+def my_cmp(name1, name2):
+ m1 = re.match('[0-9]+', name1)
+ m2 = re.match('[0-9]+', name2)
+ if not m1 or not m2:
+ return cmp(name1, name2)
+ n1 = int(m1.group())
+ n2 = int(m2.group())
+ if n1 == n2:
+ return cmp(name1[m1.end():], name2[m2.end():])
+ return n1 - n2
+
def my_listdir(dir):
path = os.path.join(os.environ["PWD"], dir)
names = os.listdir(path)
dirs = [x for x in names if os.path.isdir(os.path.join(path, x))]
+ dirs.sort(cmp=my_cmp)
files = [x for x in names if os.path.isfile(os.path.join(path, x))]
+ files.sort(cmp=my_cmp)
return dirs, files
def my_getsize(file):
content = space + u"""<div id="l%s" class="%s"><ul>\n""" \
% (id_number, level == 0 and "visible" or "hidden")
id_number += 1
- for dir in sorted(dirs):
+ for dir in dirs:
content += space + u"""<li>"""
content += u"""<a href="javascript:void(0)" onclick="sw('l%s')">%s</a>""" \
% (id_number, dir.decode('utf-8'))
content += u"""</li>\n"""
content += dir_content(os.path.join(root, dir), level + 1)
if level > 0:
- for file in sorted(files):
+ for file in files:
content += space + u"""<li>"""
content += u"""<a href="%s">%s</a> <em>(%s)</em>""" \
% (urllib.quote(root+'/'+file), file.decode('utf-8'),