The usual.
This commit is contained in:
parent
10912854a2
commit
e2ab1451cf
|
@ -6,7 +6,7 @@ and HEAD requests in a fairly straightforward manner.
|
|||
"""
|
||||
|
||||
|
||||
__version__ = "0.4"
|
||||
__version__ = "0.5"
|
||||
|
||||
|
||||
import os
|
||||
|
@ -99,6 +99,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
return None
|
||||
list.sort(lambda a, b: cmp(a.lower(), b.lower()))
|
||||
f = StringIO()
|
||||
f.write("<title>Directory listing for %s</title>\n" % self.path)
|
||||
f.write("<h2>Directory listing for %s</h2>\n" % self.path)
|
||||
f.write("<hr>\n<ul>\n")
|
||||
for name in list:
|
||||
|
@ -107,7 +108,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
# Append / for directories or @ for symbolic links
|
||||
if os.path.isdir(fullname):
|
||||
displayname = name + "/"
|
||||
linkname = name + os.sep
|
||||
linkname = name + "/"
|
||||
if os.path.islink(fullname):
|
||||
displayname = name + "@"
|
||||
# Note: a link to a directory displays with @ and links with /
|
||||
|
|
|
@ -17,7 +17,7 @@ MAXREPEAT = 65535
|
|||
SPECIAL_CHARS = ".\\[{()*+?^$|"
|
||||
REPEAT_CHARS = "*+?{"
|
||||
|
||||
DIGITS = tuple("012345689")
|
||||
DIGITS = tuple("0123456789")
|
||||
|
||||
OCTDIGITS = tuple("01234567")
|
||||
HEXDIGITS = tuple("0123456789abcdefABCDEF")
|
||||
|
@ -259,13 +259,12 @@ def _escape(source, escape, state):
|
|||
# hexadecimal escape
|
||||
while source.next in HEXDIGITS and len(escape) < 4:
|
||||
escape = escape + source.get()
|
||||
escape = escape[2:]
|
||||
if len(escape) != 2:
|
||||
raise error, "bogus escape: %s" % repr("\\" + escape)
|
||||
return LITERAL, int(escape, 16) & 0xff
|
||||
if len(escape) != 4:
|
||||
raise ValueError
|
||||
return LITERAL, int(escape[2:], 16) & 0xff
|
||||
elif escape[1:2] == "0":
|
||||
# octal escape
|
||||
while source.next in OCTDIGITS and len(escape) < 5:
|
||||
while source.next in OCTDIGITS and len(escape) < 4:
|
||||
escape = escape + source.get()
|
||||
return LITERAL, int(escape[1:], 8) & 0xff
|
||||
elif escape[1:2] in DIGITS:
|
||||
|
@ -273,7 +272,8 @@ def _escape(source, escape, state):
|
|||
here = source.tell()
|
||||
if source.next in DIGITS:
|
||||
escape = escape + source.get()
|
||||
if escape[2] in OCTDIGITS and source.next in OCTDIGITS:
|
||||
if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
|
||||
source.next in OCTDIGITS):
|
||||
# got three octal digits; this is an octal escape
|
||||
escape = escape + source.get()
|
||||
return LITERAL, int(escape[1:], 8) & 0xff
|
||||
|
@ -281,7 +281,7 @@ def _escape(source, escape, state):
|
|||
group = _group(escape, state.groups)
|
||||
if group:
|
||||
return GROUPREF, group
|
||||
raise error, "bogus escape: %s" % repr(escape)
|
||||
raise ValueError
|
||||
if len(escape) == 2:
|
||||
return LITERAL, ord(escape[1])
|
||||
except ValueError:
|
||||
|
|
|
@ -40,7 +40,7 @@ def test_both():
|
|||
assert m[0] == '3'
|
||||
print ' Contents of first 3 bytes:', repr(m[0:3])
|
||||
assert m[0:3] == '3\0\0'
|
||||
print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7]
|
||||
print ' Contents of second page:', repr(m[PAGESIZE-1 : PAGESIZE + 7])
|
||||
assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0'
|
||||
|
||||
m.flush()
|
||||
|
@ -119,4 +119,3 @@ def test_both():
|
|||
print ' Test passed'
|
||||
|
||||
test_both()
|
||||
|
||||
|
|
|
@ -28,16 +28,20 @@ def _test():
|
|||
print "Testing os module:"
|
||||
import popen2
|
||||
cmd = "cat"
|
||||
teststr = "abc\n"
|
||||
resultstr = teststr
|
||||
teststr = "ab cd\n"
|
||||
if os.name == "nt":
|
||||
cmd = "more"
|
||||
resultstr = "\n" + resultstr
|
||||
# "more" doesn't act the same way across Windows flavors,
|
||||
# sometimes adding an extra newline at the start or the
|
||||
# end. So we strip whitespace off both ends for comparison.
|
||||
expected = teststr.strip()
|
||||
print "testing popen2..."
|
||||
w, r = os.popen2(cmd)
|
||||
w.write(teststr)
|
||||
w.close()
|
||||
assert r.read() == resultstr
|
||||
got = r.read()
|
||||
if got.strip() != expected:
|
||||
raise ValueError("wrote %s read %s" % (`teststr`, `got`))
|
||||
print "testing popen3..."
|
||||
try:
|
||||
w, r, e = os.popen3([cmd])
|
||||
|
@ -45,11 +49,16 @@ def _test():
|
|||
w, r, e = os.popen3(cmd)
|
||||
w.write(teststr)
|
||||
w.close()
|
||||
assert r.read() == resultstr
|
||||
assert e.read() == ""
|
||||
got = r.read()
|
||||
if got.strip() != expected:
|
||||
raise ValueError("wrote %s read %s" % (`teststr`, `got`))
|
||||
got = e.read()
|
||||
if got:
|
||||
raise ValueError("unexected %s on stderr" % `got`)
|
||||
for inst in popen2._active[:]:
|
||||
inst.wait()
|
||||
assert not popen2._active
|
||||
if popen2._active:
|
||||
raise ValueError("_active not empty")
|
||||
print "All OK"
|
||||
|
||||
main()
|
||||
|
|
|
@ -183,9 +183,7 @@ register("grail", Grail)
|
|||
|
||||
class WindowsDefault:
|
||||
def open(self, url, new=0):
|
||||
import win32api, win32con
|
||||
win32api.ShellExecute(0, "open", url, None, ".",
|
||||
win32con.SW_SHOWNORMAL)
|
||||
self.junk = os.popen("start " + url)
|
||||
|
||||
def open_new(self, url):
|
||||
self.open(url)
|
||||
|
|
Loading…
Reference in New Issue