Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2ab145

Browse files
committed
The usual.
1 parent 1091285 commit e2ab145

5 files changed

Lines changed: 30 additions & 23 deletions

File tree

Lib/dos-8x3/simpleht.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88

9-
__version__ = "0.4"
9+
__version__ = "0.5"
1010

1111

1212
import os
@@ -99,6 +99,7 @@ def list_directory(self, path):
9999
return None
100100
list.sort(lambda a, b: cmp(a.lower(), b.lower()))
101101
f = StringIO()
102+
f.write("<title>Directory listing for %s</title>\n" % self.path)
102103
f.write("<h2>Directory listing for %s</h2>\n" % self.path)
103104
f.write("<hr>\n<ul>\n")
104105
for name in list:
@@ -107,7 +108,7 @@ def list_directory(self, path):
107108
# Append / for directories or @ for symbolic links
108109
if os.path.isdir(fullname):
109110
displayname = name + "/"
110-
linkname = name + os.sep
111+
linkname = name + "/"
111112
if os.path.islink(fullname):
112113
displayname = name + "@"
113114
# Note: a link to a directory displays with @ and links with /

Lib/dos-8x3/sre_pars.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
MAXREPEAT = 65535
1616

1717
SPECIAL_CHARS = ".\\[{()*+?^$|"
18-
REPEAT_CHARS = "*+?{"
18+
REPEAT_CHARS = "*+?{"
1919

20-
DIGITS = tuple("012345689")
20+
DIGITS = tuple("0123456789")
2121

2222
OCTDIGITS = tuple("01234567")
2323
HEXDIGITS = tuple("0123456789abcdefABCDEF")
@@ -259,29 +259,29 @@ def _escape(source, escape, state):
259259
# hexadecimal escape
260260
while source.next in HEXDIGITS and len(escape) < 4:
261261
escape = escape + source.get()
262-
escape = escape[2:]
263-
if len(escape) != 2:
264-
raise error, "bogus escape: %s" % repr("\\" + escape)
265-
return LITERAL, int(escape, 16) & 0xff
262+
if len(escape) != 4:
263+
raise ValueError
264+
return LITERAL, int(escape[2:], 16) & 0xff
266265
elif escape[1:2] == "0":
267266
# octal escape
268-
while source.next in OCTDIGITS and len(escape) < 5:
267+
while source.next in OCTDIGITS and len(escape) < 4:
269268
escape = escape + source.get()
270269
return LITERAL, int(escape[1:], 8) & 0xff
271270
elif escape[1:2] in DIGITS:
272271
# octal escape *or* decimal group reference (sigh)
273272
here = source.tell()
274273
if source.next in DIGITS:
275274
escape = escape + source.get()
276-
if escape[2] in OCTDIGITS and source.next in OCTDIGITS:
275+
if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
276+
source.next in OCTDIGITS):
277277
# got three octal digits; this is an octal escape
278278
escape = escape + source.get()
279279
return LITERAL, int(escape[1:], 8) & 0xff
280280
# got at least one decimal digit; this is a group reference
281281
group = _group(escape, state.groups)
282282
if group:
283283
return GROUPREF, group
284-
raise error, "bogus escape: %s" % repr(escape)
284+
raise ValueError
285285
if len(escape) == 2:
286286
return LITERAL, ord(escape[1])
287287
except ValueError:

Lib/dos-8x3/test_mma.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_both():
4040
assert m[0] == '3'
4141
print ' Contents of first 3 bytes:', repr(m[0:3])
4242
assert m[0:3] == '3\0\0'
43-
print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7]
43+
print ' Contents of second page:', repr(m[PAGESIZE-1 : PAGESIZE + 7])
4444
assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0'
4545

4646
m.flush()
@@ -119,4 +119,3 @@ def test_both():
119119
print ' Test passed'
120120

121121
test_both()
122-

Lib/dos-8x3/test_pop.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,37 @@ def _test():
2828
print "Testing os module:"
2929
import popen2
3030
cmd = "cat"
31-
teststr = "abc\n"
32-
resultstr = teststr
31+
teststr = "ab cd\n"
3332
if os.name == "nt":
3433
cmd = "more"
35-
resultstr = "\n" + resultstr
34+
# "more" doesn't act the same way across Windows flavors,
35+
# sometimes adding an extra newline at the start or the
36+
# end. So we strip whitespace off both ends for comparison.
37+
expected = teststr.strip()
3638
print "testing popen2..."
3739
w, r = os.popen2(cmd)
3840
w.write(teststr)
3941
w.close()
40-
assert r.read() == resultstr
42+
got = r.read()
43+
if got.strip() != expected:
44+
raise ValueError("wrote %s read %s" % (`teststr`, `got`))
4145
print "testing popen3..."
4246
try:
4347
w, r, e = os.popen3([cmd])
4448
except:
4549
w, r, e = os.popen3(cmd)
4650
w.write(teststr)
4751
w.close()
48-
assert r.read() == resultstr
49-
assert e.read() == ""
52+
got = r.read()
53+
if got.strip() != expected:
54+
raise ValueError("wrote %s read %s" % (`teststr`, `got`))
55+
got = e.read()
56+
if got:
57+
raise ValueError("unexected %s on stderr" % `got`)
5058
for inst in popen2._active[:]:
5159
inst.wait()
52-
assert not popen2._active
60+
if popen2._active:
61+
raise ValueError("_active not empty")
5362
print "All OK"
5463

5564
main()

Lib/dos-8x3/webbrows.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ def open_new(self, url):
183183

184184
class WindowsDefault:
185185
def open(self, url, new=0):
186-
import win32api, win32con
187-
win32api.ShellExecute(0, "open", url, None, ".",
188-
win32con.SW_SHOWNORMAL)
186+
self.junk = os.popen("start " + url)
189187

190188
def open_new(self, url):
191189
self.open(url)

0 commit comments

Comments
 (0)