golden hour
/opt/alt/python27/lib64/python2.7
⬆️ Go Up
Upload
File/Folder
Size
Actions
BaseHTTPServer.py
22.21 KB
Del
OK
BaseHTTPServer.pyc
21.47 KB
Del
OK
BaseHTTPServer.pyo
21.47 KB
Del
OK
Bastion.py
5.61 KB
Del
OK
Bastion.pyc
6.69 KB
Del
OK
Bastion.pyo
6.69 KB
Del
OK
CGIHTTPServer.py
12.78 KB
Del
OK
CGIHTTPServer.pyc
10.92 KB
Del
OK
CGIHTTPServer.pyo
10.92 KB
Del
OK
ConfigParser.py
27.1 KB
Del
OK
ConfigParser.pyc
25.37 KB
Del
OK
ConfigParser.pyo
25.37 KB
Del
OK
Cookie.py
25.92 KB
Del
OK
Cookie.pyc
22.61 KB
Del
OK
Cookie.pyo
22.61 KB
Del
OK
DocXMLRPCServer.py
10.52 KB
Del
OK
DocXMLRPCServer.pyc
10.2 KB
Del
OK
DocXMLRPCServer.pyo
10.09 KB
Del
OK
HTMLParser.py
16.77 KB
Del
OK
HTMLParser.pyc
13.81 KB
Del
OK
HTMLParser.pyo
13.51 KB
Del
OK
MimeWriter.py
6.33 KB
Del
OK
MimeWriter.pyc
7.31 KB
Del
OK
MimeWriter.pyo
7.31 KB
Del
OK
Queue.py
8.38 KB
Del
OK
Queue.pyc
9.56 KB
Del
OK
Queue.pyo
9.56 KB
Del
OK
SimpleHTTPServer.py
7.81 KB
Del
OK
SimpleHTTPServer.pyc
7.96 KB
Del
OK
SimpleHTTPServer.pyo
7.96 KB
Del
OK
SimpleXMLRPCServer.py
25.21 KB
Del
OK
SimpleXMLRPCServer.pyc
22.78 KB
Del
OK
SimpleXMLRPCServer.pyo
22.78 KB
Del
OK
SocketServer.py
23.39 KB
Del
OK
SocketServer.pyc
24.25 KB
Del
OK
SocketServer.pyo
24.25 KB
Del
OK
StringIO.py
10.41 KB
Del
OK
StringIO.pyc
11.45 KB
Del
OK
StringIO.pyo
11.45 KB
Del
OK
UserDict.py
6.89 KB
Del
OK
UserDict.pyc
10.05 KB
Del
OK
UserDict.pyo
10.05 KB
Del
OK
UserList.py
3.56 KB
Del
OK
UserList.pyc
6.85 KB
Del
OK
UserList.pyo
6.85 KB
Del
OK
UserString.py
9.47 KB
Del
OK
UserString.pyc
15.38 KB
Del
OK
UserString.pyo
15.38 KB
Del
OK
_LWPCookieJar.py
6.4 KB
Del
OK
_LWPCookieJar.pyc
5.38 KB
Del
OK
_LWPCookieJar.pyo
5.38 KB
Del
OK
_MozillaCookieJar.py
5.66 KB
Del
OK
_MozillaCookieJar.pyc
4.41 KB
Del
OK
_MozillaCookieJar.pyo
4.37 KB
Del
OK
__future__.py
4.28 KB
Del
OK
__future__.pyc
4.2 KB
Del
OK
__future__.pyo
4.2 KB
Del
OK
__phello__.foo.py
64 B
Del
OK
__phello__.foo.pyc
138 B
Del
OK
__phello__.foo.pyo
138 B
Del
OK
_abcoll.py
18.18 KB
Del
OK
_abcoll.pyc
26.4 KB
Del
OK
_abcoll.pyo
26.4 KB
Del
OK
_osx_support.py
18.65 KB
Del
OK
_osx_support.pyc
11.72 KB
Del
OK
_osx_support.pyo
11.72 KB
Del
OK
_pyio.py
68 KB
Del
OK
_pyio.pyc
65.41 KB
Del
OK
_pyio.pyo
65.41 KB
Del
OK
_strptime.py
20.24 KB
Del
OK
_strptime.pyc
15.07 KB
Del
OK
_strptime.pyo
15.07 KB
Del
OK
_sysconfigdata.py
18.9 KB
Del
OK
_sysconfigdata.pyc
22 KB
Del
OK
_sysconfigdata.pyo
22 KB
Del
OK
_threading_local.py
7.09 KB
Del
OK
_threading_local.pyc
6.34 KB
Del
OK
_threading_local.pyo
6.34 KB
Del
OK
_weakrefset.py
5.77 KB
Del
OK
_weakrefset.pyc
10.06 KB
Del
OK
_weakrefset.pyo
10.06 KB
Del
OK
abc.py
6.98 KB
Del
OK
abc.pyc
6.14 KB
Del
OK
abc.pyo
6.08 KB
Del
OK
aifc.py
33.77 KB
Del
OK
aifc.pyc
30.67 KB
Del
OK
aifc.pyo
30.67 KB
Del
OK
antigravity.py
60 B
Del
OK
antigravity.pyc
216 B
Del
OK
antigravity.pyo
216 B
Del
OK
anydbm.py
2.6 KB
Del
OK
anydbm.pyc
2.77 KB
Del
OK
anydbm.pyo
2.77 KB
Del
OK
argparse.py
87.14 KB
Del
OK
argparse.pyc
64.83 KB
Del
OK
argparse.pyo
64.67 KB
Del
OK
ast.py
11.53 KB
Del
OK
ast.pyc
12.94 KB
Del
OK
ast.pyo
12.94 KB
Del
OK
asynchat.py
11.31 KB
Del
OK
asynchat.pyc
8.98 KB
Del
OK
asynchat.pyo
8.98 KB
Del
OK
asyncore.py
20.45 KB
Del
OK
asyncore.pyc
19.2 KB
Del
OK
asyncore.pyo
19.2 KB
Del
OK
atexit.py
1.67 KB
Del
OK
atexit.pyc
2.23 KB
Del
OK
atexit.pyo
2.23 KB
Del
OK
audiodev.py
7.42 KB
Del
OK
audiodev.pyc
8.61 KB
Del
OK
audiodev.pyo
8.61 KB
Del
OK
base64.py
11.54 KB
Del
OK
base64.pyc
11.26 KB
Del
OK
base64.pyo
11.26 KB
Del
OK
bdb.py
21.21 KB
Del
OK
bdb.pyc
19.43 KB
Del
OK
bdb.pyo
19.43 KB
Del
OK
binhex.py
14.35 KB
Del
OK
binhex.pyc
15.75 KB
Del
OK
binhex.pyo
15.75 KB
Del
OK
bisect.py
2.53 KB
Del
OK
bisect.pyc
3.06 KB
Del
OK
bisect.pyo
3.06 KB
Del
OK
bsddb
-
Del
OK
cProfile.py
6.43 KB
Del
OK
cProfile.pyc
6.42 KB
Del
OK
cProfile.pyo
6.42 KB
Del
OK
calendar.py
22.84 KB
Del
OK
calendar.pyc
28.26 KB
Del
OK
calendar.pyo
28.26 KB
Del
OK
cgi.py
34.97 KB
Del
OK
cgi.pyc
33.24 KB
Del
OK
cgi.pyo
33.24 KB
Del
OK
cgitb.py
11.89 KB
Del
OK
cgitb.pyc
12.08 KB
Del
OK
cgitb.pyo
12.08 KB
Del
OK
chunk.py
5.29 KB
Del
OK
chunk.pyc
5.61 KB
Del
OK
chunk.pyo
5.61 KB
Del
OK
cmd.py
14.67 KB
Del
OK
cmd.pyc
13.98 KB
Del
OK
cmd.pyo
13.98 KB
Del
OK
code.py
9.95 KB
Del
OK
code.pyc
10.29 KB
Del
OK
code.pyo
10.29 KB
Del
OK
codecs.py
35.3 KB
Del
OK
codecs.pyc
37.15 KB
Del
OK
codecs.pyo
37.15 KB
Del
OK
codeop.py
5.86 KB
Del
OK
codeop.pyc
6.57 KB
Del
OK
codeop.pyo
6.57 KB
Del
OK
collections.py
27.15 KB
Del
OK
collections.pyc
26.21 KB
Del
OK
collections.pyo
26.16 KB
Del
OK
colorsys.py
3.6 KB
Del
OK
colorsys.pyc
4 KB
Del
OK
colorsys.pyo
4 KB
Del
OK
commands.py
2.49 KB
Del
OK
commands.pyc
2.49 KB
Del
OK
commands.pyo
2.49 KB
Del
OK
compileall.py
7.58 KB
Del
OK
compileall.pyc
6.93 KB
Del
OK
compileall.pyo
6.93 KB
Del
OK
compiler
-
Del
OK
config
-
Del
OK
contextlib.py
4.32 KB
Del
OK
contextlib.pyc
4.5 KB
Del
OK
contextlib.pyo
4.5 KB
Del
OK
cookielib.py
63.95 KB
Del
OK
cookielib.pyc
54.67 KB
Del
OK
cookielib.pyo
54.49 KB
Del
OK
copy.py
11.26 KB
Del
OK
copy.pyc
12.21 KB
Del
OK
copy.pyo
12.13 KB
Del
OK
copy_reg.py
6.81 KB
Del
OK
copy_reg.pyc
5.19 KB
Del
OK
copy_reg.pyo
5.14 KB
Del
OK
crypt.py
2.24 KB
Del
OK
crypt.pyc
2.95 KB
Del
OK
crypt.pyo
2.95 KB
Del
OK
csv.py
16.32 KB
Del
OK
csv.pyc
13.56 KB
Del
OK
csv.pyo
13.56 KB
Del
OK
ctypes
-
Del
OK
curses
-
Del
OK
dbhash.py
498 B
Del
OK
dbhash.pyc
744 B
Del
OK
dbhash.pyo
744 B
Del
OK
decimal.py
216.73 KB
Del
OK
decimal.pyc
171.36 KB
Del
OK
decimal.pyo
171.36 KB
Del
OK
difflib.py
80.4 KB
Del
OK
difflib.pyc
61.13 KB
Del
OK
difflib.pyo
61.08 KB
Del
OK
dircache.py
1.1 KB
Del
OK
dircache.pyc
1.59 KB
Del
OK
dircache.pyo
1.59 KB
Del
OK
dis.py
6.35 KB
Del
OK
dis.pyc
6.18 KB
Del
OK
dis.pyo
6.18 KB
Del
OK
distutils
-
Del
OK
doctest.py
102.63 KB
Del
OK
doctest.pyc
83.21 KB
Del
OK
doctest.pyo
82.93 KB
Del
OK
dumbdbm.py
8.93 KB
Del
OK
dumbdbm.pyc
6.83 KB
Del
OK
dumbdbm.pyo
6.83 KB
Del
OK
dummy_thread.py
4.31 KB
Del
OK
dummy_thread.pyc
5.46 KB
Del
OK
dummy_thread.pyo
5.46 KB
Del
OK
dummy_threading.py
2.74 KB
Del
OK
dummy_threading.pyc
1.27 KB
Del
OK
dummy_threading.pyo
1.27 KB
Del
OK
email
-
Del
OK
encodings
-
Del
OK
ensurepip
-
Del
OK
filecmp.py
9.36 KB
Del
OK
filecmp.pyc
9.65 KB
Del
OK
filecmp.pyo
9.65 KB
Del
OK
fileinput.py
13.42 KB
Del
OK
fileinput.pyc
14.54 KB
Del
OK
fileinput.pyo
14.54 KB
Del
OK
fnmatch.py
3.24 KB
Del
OK
fnmatch.pyc
3.61 KB
Del
OK
fnmatch.pyo
3.61 KB
Del
OK
formatter.py
14.56 KB
Del
OK
formatter.pyc
19.71 KB
Del
OK
formatter.pyo
19.71 KB
Del
OK
fpformat.py
4.62 KB
Del
OK
fpformat.pyc
4.69 KB
Del
OK
fpformat.pyo
4.69 KB
Del
OK
fractions.py
21.87 KB
Del
OK
fractions.pyc
19.74 KB
Del
OK
fractions.pyo
19.74 KB
Del
OK
ftplib.py
37.3 KB
Del
OK
ftplib.pyc
34.82 KB
Del
OK
ftplib.pyo
34.82 KB
Del
OK
functools.py
4.69 KB
Del
OK
functools.pyc
6.85 KB
Del
OK
functools.pyo
6.85 KB
Del
OK
genericpath.py
3.13 KB
Del
OK
genericpath.pyc
3.57 KB
Del
OK
genericpath.pyo
3.57 KB
Del
OK
getopt.py
7.15 KB
Del
OK
getopt.pyc
6.63 KB
Del
OK
getopt.pyo
6.58 KB
Del
OK
getpass.py
5.43 KB
Del
OK
getpass.pyc
4.72 KB
Del
OK
getpass.pyo
4.72 KB
Del
OK
gettext.py
22.13 KB
Del
OK
gettext.pyc
18.17 KB
Del
OK
gettext.pyo
18.17 KB
Del
OK
glob.py
3.04 KB
Del
OK
glob.pyc
2.98 KB
Del
OK
glob.pyo
2.98 KB
Del
OK
gzip.py
18.58 KB
Del
OK
gzip.pyc
15.26 KB
Del
OK
gzip.pyo
15.26 KB
Del
OK
hashlib.py
7.66 KB
Del
OK
hashlib.pyc
6.86 KB
Del
OK
hashlib.pyo
6.86 KB
Del
OK
heapq.py
17.87 KB
Del
OK
heapq.pyc
14.45 KB
Del
OK
heapq.pyo
14.45 KB
Del
OK
hmac.py
4.48 KB
Del
OK
hmac.pyc
4.56 KB
Del
OK
hmac.pyo
4.56 KB
Del
OK
hotshot
-
Del
OK
htmlentitydefs.py
17.63 KB
Del
OK
htmlentitydefs.pyc
6.23 KB
Del
OK
htmlentitydefs.pyo
6.23 KB
Del
OK
htmllib.py
12.57 KB
Del
OK
htmllib.pyc
20.99 KB
Del
OK
htmllib.pyo
20.99 KB
Del
OK
httplib.py
51.07 KB
Del
OK
httplib.pyc
37.88 KB
Del
OK
httplib.pyo
37.7 KB
Del
OK
idlelib
-
Del
OK
ihooks.py
18.54 KB
Del
OK
ihooks.pyc
21.75 KB
Del
OK
ihooks.pyo
21.75 KB
Del
OK
imaplib.py
47.23 KB
Del
OK
imaplib.pyc
45.19 KB
Del
OK
imaplib.pyo
42.49 KB
Del
OK
imghdr.py
3.46 KB
Del
OK
imghdr.pyc
4.93 KB
Del
OK
imghdr.pyo
4.93 KB
Del
OK
importlib
-
Del
OK
imputil.py
25.16 KB
Del
OK
imputil.pyc
15.74 KB
Del
OK
imputil.pyo
15.57 KB
Del
OK
inspect.py
42 KB
Del
OK
inspect.pyc
40.16 KB
Del
OK
inspect.pyo
40.16 KB
Del
OK
io.py
3.24 KB
Del
OK
io.pyc
3.57 KB
Del
OK
io.pyo
3.57 KB
Del
OK
json
-
Del
OK
keyword.py
1.96 KB
Del
OK
keyword.pyc
2.08 KB
Del
OK
keyword.pyo
2.08 KB
Del
OK
lib-dynload
-
Del
OK
lib2to3
-
Del
OK
linecache.py
3.93 KB
Del
OK
linecache.pyc
3.27 KB
Del
OK
linecache.pyo
3.27 KB
Del
OK
locale.py
100.42 KB
Del
OK
locale.pyc
55.69 KB
Del
OK
locale.pyo
55.69 KB
Del
OK
logging
-
Del
OK
macpath.py
6.14 KB
Del
OK
macpath.pyc
7.74 KB
Del
OK
macpath.pyo
7.74 KB
Del
OK
macurl2path.py
2.67 KB
Del
OK
macurl2path.pyc
2.24 KB
Del
OK
macurl2path.pyo
2.24 KB
Del
OK
mailbox.py
79.34 KB
Del
OK
mailbox.pyc
77.7 KB
Del
OK
mailbox.pyo
77.65 KB
Del
OK
mailcap.py
7.25 KB
Del
OK
mailcap.pyc
7.08 KB
Del
OK
mailcap.pyo
7.08 KB
Del
OK
markupbase.py
14.3 KB
Del
OK
markupbase.pyc
9.27 KB
Del
OK
markupbase.pyo
9.07 KB
Del
OK
md5.py
358 B
Del
OK
md5.pyc
391 B
Del
OK
md5.pyo
391 B
Del
OK
mhlib.py
32.65 KB
Del
OK
mhlib.pyc
33.98 KB
Del
OK
mhlib.pyo
33.98 KB
Del
OK
mimetools.py
7 KB
Del
OK
mimetools.pyc
8.26 KB
Del
OK
mimetools.pyo
8.26 KB
Del
OK
mimetypes.py
20.54 KB
Del
OK
mimetypes.pyc
18.3 KB
Del
OK
mimetypes.pyo
18.3 KB
Del
OK
mimify.py
14.68 KB
Del
OK
mimify.pyc
11.91 KB
Del
OK
mimify.pyo
11.91 KB
Del
OK
modulefinder.py
23.89 KB
Del
OK
modulefinder.pyc
19.12 KB
Del
OK
modulefinder.pyo
19.04 KB
Del
OK
multifile.py
4.71 KB
Del
OK
multifile.pyc
5.48 KB
Del
OK
multifile.pyo
5.44 KB
Del
OK
multiprocessing
-
Del
OK
mutex.py
1.83 KB
Del
OK
mutex.pyc
2.55 KB
Del
OK
mutex.pyo
2.55 KB
Del
OK
netrc.py
5.75 KB
Del
OK
netrc.pyc
4.72 KB
Del
OK
netrc.pyo
4.72 KB
Del
OK
new.py
610 B
Del
OK
new.pyc
875 B
Del
OK
new.pyo
875 B
Del
OK
nntplib.py
20.97 KB
Del
OK
nntplib.pyc
21.11 KB
Del
OK
nntplib.pyo
21.11 KB
Del
OK
ntpath.py
18.97 KB
Del
OK
ntpath.pyc
13.1 KB
Del
OK
ntpath.pyo
13.1 KB
Del
OK
nturl2path.py
2.36 KB
Del
OK
nturl2path.pyc
1.81 KB
Del
OK
nturl2path.pyo
1.81 KB
Del
OK
numbers.py
10.08 KB
Del
OK
numbers.pyc
14.47 KB
Del
OK
numbers.pyo
14.47 KB
Del
OK
opcode.py
5.35 KB
Del
OK
opcode.pyc
6.06 KB
Del
OK
opcode.pyo
6.06 KB
Del
OK
optparse.py
59.77 KB
Del
OK
optparse.pyc
54.41 KB
Del
OK
optparse.pyo
54.33 KB
Del
OK
os.py
25.3 KB
Del
OK
os.pyc
25.76 KB
Del
OK
os.pyo
25.76 KB
Del
OK
os2emxpath.py
4.53 KB
Del
OK
os2emxpath.pyc
4.53 KB
Del
OK
os2emxpath.pyo
4.53 KB
Del
OK
pdb.doc
7.73 KB
Del
OK
pdb.py
45.03 KB
Del
OK
pdb.pyc
44.09 KB
Del
OK
pdb.pyo
44.09 KB
Del
OK
pickle.py
44.42 KB
Del
OK
pickle.pyc
38.98 KB
Del
OK
pickle.pyo
38.79 KB
Del
OK
pickletools.py
72.78 KB
Del
OK
pickletools.pyc
56.1 KB
Del
OK
pickletools.pyo
55.26 KB
Del
OK
pipes.py
9.36 KB
Del
OK
pipes.pyc
9.29 KB
Del
OK
pipes.pyo
9.29 KB
Del
OK
pkgutil.py
19.77 KB
Del
OK
pkgutil.pyc
18.93 KB
Del
OK
pkgutil.pyo
18.93 KB
Del
OK
plat-linux2
-
Del
OK
platform.py
51.56 KB
Del
OK
platform.pyc
37.7 KB
Del
OK
platform.pyo
37.7 KB
Del
OK
plistlib.py
14.83 KB
Del
OK
plistlib.pyc
19.54 KB
Del
OK
plistlib.pyo
19.46 KB
Del
OK
popen2.py
8.22 KB
Del
OK
popen2.pyc
9.02 KB
Del
OK
popen2.pyo
8.98 KB
Del
OK
poplib.py
12.52 KB
Del
OK
poplib.pyc
13.45 KB
Del
OK
poplib.pyo
13.45 KB
Del
OK
posixfile.py
7.82 KB
Del
OK
posixfile.pyc
7.63 KB
Del
OK
posixfile.pyo
7.63 KB
Del
OK
posixpath.py
13.96 KB
Del
OK
posixpath.pyc
11.49 KB
Del
OK
posixpath.pyo
11.49 KB
Del
OK
pprint.py
11.5 KB
Del
OK
pprint.pyc
10.2 KB
Del
OK
pprint.pyo
10.02 KB
Del
OK
profile.py
22.26 KB
Del
OK
profile.pyc
16.57 KB
Del
OK
profile.pyo
16.32 KB
Del
OK
pstats.py
26.09 KB
Del
OK
pstats.pyc
25.19 KB
Del
OK
pstats.pyo
25.19 KB
Del
OK
pty.py
4.94 KB
Del
OK
pty.pyc
4.98 KB
Del
OK
pty.pyo
4.98 KB
Del
OK
py_compile.py
5.8 KB
Del
OK
py_compile.pyc
6.37 KB
Del
OK
py_compile.pyo
6.37 KB
Del
OK
pyclbr.py
13.07 KB
Del
OK
pyclbr.pyc
9.59 KB
Del
OK
pyclbr.pyo
9.59 KB
Del
OK
pydoc.py
93.43 KB
Del
OK
pydoc.pyc
92.69 KB
Del
OK
pydoc.pyo
92.63 KB
Del
OK
pydoc_data
-
Del
OK
quopri.py
6.81 KB
Del
OK
quopri.pyc
6.56 KB
Del
OK
quopri.pyo
6.56 KB
Del
OK
random.py
31.7 KB
Del
OK
random.pyc
25.65 KB
Del
OK
random.pyo
25.65 KB
Del
OK
re.py
13.11 KB
Del
OK
re.pyc
13.37 KB
Del
OK
re.pyo
13.37 KB
Del
OK
repr.py
4.2 KB
Del
OK
repr.pyc
5.47 KB
Del
OK
repr.pyo
5.47 KB
Del
OK
rexec.py
19.68 KB
Del
OK
rexec.pyc
24 KB
Del
OK
rexec.pyo
24 KB
Del
OK
rfc822.py
32.76 KB
Del
OK
rfc822.pyc
31.83 KB
Del
OK
rfc822.pyo
31.83 KB
Del
OK
rlcompleter.py
5.85 KB
Del
OK
rlcompleter.pyc
6.04 KB
Del
OK
rlcompleter.pyo
6.04 KB
Del
OK
robotparser.py
7.51 KB
Del
OK
robotparser.pyc
8.12 KB
Del
OK
robotparser.pyo
8.12 KB
Del
OK
runpy.py
10.82 KB
Del
OK
runpy.pyc
8.85 KB
Del
OK
runpy.pyo
8.85 KB
Del
OK
sched.py
4.97 KB
Del
OK
sched.pyc
4.99 KB
Del
OK
sched.pyo
4.99 KB
Del
OK
sets.py
18.6 KB
Del
OK
sets.pyc
17.21 KB
Del
OK
sets.pyo
17.21 KB
Del
OK
sgmllib.py
17.46 KB
Del
OK
sgmllib.pyc
15.67 KB
Del
OK
sgmllib.pyo
15.67 KB
Del
OK
sha.py
393 B
Del
OK
sha.pyc
434 B
Del
OK
sha.pyo
434 B
Del
OK
shelve.py
7.99 KB
Del
OK
shelve.pyc
10.36 KB
Del
OK
shelve.pyo
10.36 KB
Del
OK
shlex.py
10.9 KB
Del
OK
shlex.pyc
7.55 KB
Del
OK
shlex.pyo
7.55 KB
Del
OK
shutil.py
19.41 KB
Del
OK
shutil.pyc
19.19 KB
Del
OK
shutil.pyo
19.19 KB
Del
OK
site-packages
-
Del
OK
site.py
19.18 KB
Del
OK
site.pyc
19.35 KB
Del
OK
site.pyo
19.35 KB
Del
OK
smtpd.py
18.12 KB
Del
OK
smtpd.pyc
15.9 KB
Del
OK
smtpd.pyo
15.9 KB
Del
OK
smtplib.py
31.39 KB
Del
OK
smtplib.pyc
30.29 KB
Del
OK
smtplib.pyo
30.29 KB
Del
OK
sndhdr.py
5.83 KB
Del
OK
sndhdr.pyc
7.4 KB
Del
OK
sndhdr.pyo
7.4 KB
Del
OK
socket.py
20.13 KB
Del
OK
socket.pyc
16.15 KB
Del
OK
socket.pyo
16.07 KB
Del
OK
sqlite3
-
Del
OK
sre.py
384 B
Del
OK
sre.pyc
532 B
Del
OK
sre.pyo
532 B
Del
OK
sre_compile.py
19.36 KB
Del
OK
sre_compile.pyc
12.46 KB
Del
OK
sre_compile.pyo
12.3 KB
Del
OK
sre_constants.py
7.03 KB
Del
OK
sre_constants.pyc
6.11 KB
Del
OK
sre_constants.pyo
6.11 KB
Del
OK
sre_parse.py
29.98 KB
Del
OK
sre_parse.pyc
21.12 KB
Del
OK
sre_parse.pyo
21.12 KB
Del
OK
ssl.py
36.58 KB
Del
OK
ssl.pyc
32.24 KB
Del
OK
ssl.pyo
32.24 KB
Del
OK
stat.py
1.8 KB
Del
OK
stat.pyc
2.81 KB
Del
OK
stat.pyo
2.81 KB
Del
OK
statvfs.py
898 B
Del
OK
statvfs.pyc
633 B
Del
OK
statvfs.pyo
633 B
Del
OK
string.py
21.04 KB
Del
OK
string.pyc
20.63 KB
Del
OK
string.pyo
20.63 KB
Del
OK
stringold.py
12.16 KB
Del
OK
stringold.pyc
12.6 KB
Del
OK
stringold.pyo
12.6 KB
Del
OK
stringprep.py
13.21 KB
Del
OK
stringprep.pyc
14.4 KB
Del
OK
stringprep.pyo
14.33 KB
Del
OK
struct.py
82 B
Del
OK
struct.pyc
252 B
Del
OK
struct.pyo
252 B
Del
OK
subprocess.py
49.34 KB
Del
OK
subprocess.pyc
32.32 KB
Del
OK
subprocess.pyo
32.32 KB
Del
OK
sunau.py
16.82 KB
Del
OK
sunau.pyc
18.57 KB
Del
OK
sunau.pyo
18.57 KB
Del
OK
sunaudio.py
1.37 KB
Del
OK
sunaudio.pyc
2 KB
Del
OK
sunaudio.pyo
2 KB
Del
OK
symbol.py
2.02 KB
Del
OK
symbol.pyc
2.98 KB
Del
OK
symbol.pyo
2.98 KB
Del
OK
symtable.py
7.26 KB
Del
OK
symtable.pyc
12.14 KB
Del
OK
symtable.pyo
12.02 KB
Del
OK
sysconfig.py
22.32 KB
Del
OK
sysconfig.pyc
17.73 KB
Del
OK
sysconfig.pyo
17.73 KB
Del
OK
tabnanny.py
11.08 KB
Del
OK
tabnanny.pyc
8.31 KB
Del
OK
tabnanny.pyo
8.31 KB
Del
OK
tarfile.py
88.45 KB
Del
OK
tarfile.pyc
76.54 KB
Del
OK
tarfile.pyo
76.54 KB
Del
OK
telnetlib.py
26.4 KB
Del
OK
telnetlib.pyc
23.03 KB
Del
OK
telnetlib.pyo
23.03 KB
Del
OK
tempfile.py
19.09 KB
Del
OK
tempfile.pyc
20.55 KB
Del
OK
tempfile.pyo
20.55 KB
Del
OK
test
-
Del
OK
textwrap.py
16.88 KB
Del
OK
textwrap.pyc
11.99 KB
Del
OK
textwrap.pyo
11.9 KB
Del
OK
this.py
1002 B
Del
OK
this.pyc
1.2 KB
Del
OK
this.pyo
1.2 KB
Del
OK
threading.py
46.17 KB
Del
OK
threading.pyc
42.97 KB
Del
OK
threading.pyo
40.84 KB
Del
OK
timeit.py
12.5 KB
Del
OK
timeit.pyc
12.06 KB
Del
OK
timeit.pyo
12.06 KB
Del
OK
toaiff.py
3.07 KB
Del
OK
toaiff.pyc
3.08 KB
Del
OK
toaiff.pyo
3.08 KB
Del
OK
token.py
2.85 KB
Del
OK
token.pyc
3.79 KB
Del
OK
token.pyo
3.79 KB
Del
OK
tokenize.py
17.07 KB
Del
OK
tokenize.pyc
14.37 KB
Del
OK
tokenize.pyo
14.31 KB
Del
OK
trace.py
29.2 KB
Del
OK
trace.pyc
22.69 KB
Del
OK
trace.pyo
22.63 KB
Del
OK
traceback.py
11.02 KB
Del
OK
traceback.pyc
11.66 KB
Del
OK
traceback.pyo
11.66 KB
Del
OK
tty.py
879 B
Del
OK
tty.pyc
1.32 KB
Del
OK
tty.pyo
1.32 KB
Del
OK
types.py
2.04 KB
Del
OK
types.pyc
2.75 KB
Del
OK
types.pyo
2.75 KB
Del
OK
unittest
-
Del
OK
urllib.py
58.82 KB
Del
OK
urllib.pyc
51.35 KB
Del
OK
urllib.pyo
51.25 KB
Del
OK
urllib2.py
51.31 KB
Del
OK
urllib2.pyc
47.8 KB
Del
OK
urllib2.pyo
47.71 KB
Del
OK
urlparse.py
16.29 KB
Del
OK
urlparse.pyc
15.51 KB
Del
OK
urlparse.pyo
15.51 KB
Del
OK
user.py
1.59 KB
Del
OK
user.pyc
1.7 KB
Del
OK
user.pyo
1.7 KB
Del
OK
uu.py
6.55 KB
Del
OK
uu.pyc
4.35 KB
Del
OK
uu.pyo
4.35 KB
Del
OK
uuid.py
22.63 KB
Del
OK
uuid.pyc
23.22 KB
Del
OK
uuid.pyo
23.11 KB
Del
OK
warnings.py
14.48 KB
Del
OK
warnings.pyc
13.49 KB
Del
OK
warnings.pyo
12.71 KB
Del
OK
wave.py
18.15 KB
Del
OK
wave.pyc
20.19 KB
Del
OK
wave.pyo
20.05 KB
Del
OK
weakref.py
14.48 KB
Del
OK
weakref.pyc
16.73 KB
Del
OK
weakref.pyo
16.73 KB
Del
OK
webbrowser.py
22.2 KB
Del
OK
webbrowser.pyc
19.86 KB
Del
OK
webbrowser.pyo
19.81 KB
Del
OK
whichdb.py
3.31 KB
Del
OK
whichdb.pyc
2.21 KB
Del
OK
whichdb.pyo
2.21 KB
Del
OK
wsgiref
-
Del
OK
wsgiref.egg-info
187 B
Del
OK
xdrlib.py
5.93 KB
Del
OK
xdrlib.pyc
10.2 KB
Del
OK
xdrlib.pyo
10.2 KB
Del
OK
xml
-
Del
OK
xmllib.py
34.05 KB
Del
OK
xmllib.pyc
26.9 KB
Del
OK
xmllib.pyo
26.9 KB
Del
OK
xmlrpclib.py
50.91 KB
Del
OK
xmlrpclib.pyc
44.81 KB
Del
OK
xmlrpclib.pyo
44.63 KB
Del
OK
zipfile.py
58.08 KB
Del
OK
zipfile.pyc
41.92 KB
Del
OK
zipfile.pyo
41.92 KB
Del
OK
Edit: codecs.py
""" codecs -- Python Codec Registry, API and helpers. Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" import __builtin__, sys ### Registry and builtin stateless codec functions try: from _codecs import * except ImportError, why: raise SystemError('Failed to load the builtin codecs: %s' % why) __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", "BOM_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE", "BOM_UTF8", "BOM_UTF16", "BOM_UTF16_LE", "BOM_UTF16_BE", "BOM_UTF32", "BOM_UTF32_LE", "BOM_UTF32_BE", "CodecInfo", "Codec", "IncrementalEncoder", "IncrementalDecoder", "StreamReader", "StreamWriter", "StreamReaderWriter", "StreamRecoder", "getencoder", "getdecoder", "getincrementalencoder", "getincrementaldecoder", "getreader", "getwriter", "encode", "decode", "iterencode", "iterdecode", "strict_errors", "ignore_errors", "replace_errors", "xmlcharrefreplace_errors", "backslashreplace_errors", "register_error", "lookup_error"] ### Constants # # Byte Order Mark (BOM = ZERO WIDTH NO-BREAK SPACE = U+FEFF) # and its possible byte string values # for UTF8/UTF16/UTF32 output and little/big endian machines # # UTF-8 BOM_UTF8 = '\xef\xbb\xbf' # UTF-16, little endian BOM_LE = BOM_UTF16_LE = '\xff\xfe' # UTF-16, big endian BOM_BE = BOM_UTF16_BE = '\xfe\xff' # UTF-32, little endian BOM_UTF32_LE = '\xff\xfe\x00\x00' # UTF-32, big endian BOM_UTF32_BE = '\x00\x00\xfe\xff' if sys.byteorder == 'little': # UTF-16, native endianness BOM = BOM_UTF16 = BOM_UTF16_LE # UTF-32, native endianness BOM_UTF32 = BOM_UTF32_LE else: # UTF-16, native endianness BOM = BOM_UTF16 = BOM_UTF16_BE # UTF-32, native endianness BOM_UTF32 = BOM_UTF32_BE # Old broken names (don't use in new code) BOM32_LE = BOM_UTF16_LE BOM32_BE = BOM_UTF16_BE BOM64_LE = BOM_UTF32_LE BOM64_BE = BOM_UTF32_BE ### Codec base classes (defining the API) class CodecInfo(tuple): """Codec details when looking up the codec registry""" # Private API to allow Python to blacklist the known non-Unicode # codecs in the standard library. A more general mechanism to # reliably distinguish test encodings from other codecs will hopefully # be defined for Python 3.5 # # See http://bugs.python.org/issue19619 _is_text_encoding = True # Assume codecs are text encodings by default def __new__(cls, encode, decode, streamreader=None, streamwriter=None, incrementalencoder=None, incrementaldecoder=None, name=None, _is_text_encoding=None): self = tuple.__new__(cls, (encode, decode, streamreader, streamwriter)) self.name = name self.encode = encode self.decode = decode self.incrementalencoder = incrementalencoder self.incrementaldecoder = incrementaldecoder self.streamwriter = streamwriter self.streamreader = streamreader if _is_text_encoding is not None: self._is_text_encoding = _is_text_encoding return self def __repr__(self): return "<%s.%s object for encoding %s at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self)) class Codec: """ Defines the interface for stateless encoders/decoders. The .encode()/.decode() methods may use different error handling schemes by providing the errors argument. These string values are predefined: 'strict' - raise a ValueError error (or a subclass) 'ignore' - ignore the character and continue with the next 'replace' - replace with a suitable replacement character; Python will use the official U+FFFD REPLACEMENT CHARACTER for the builtin Unicode codecs on decoding and '?' on encoding. 'xmlcharrefreplace' - Replace with the appropriate XML character reference (only for encoding). 'backslashreplace' - Replace with backslashed escape sequences (only for encoding). The set of allowed values can be extended via register_error. """ def encode(self, input, errors='strict'): """ Encodes the object input and returns a tuple (output object, length consumed). errors defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamWriter for codecs which have to keep state in order to make encoding efficient. The encoder must be able to handle zero length input and return an empty object of the output object type in this situation. """ raise NotImplementedError def decode(self, input, errors='strict'): """ Decodes the object input and returns a tuple (output object, length consumed). input must be an object which provides the bf_getreadbuf buffer slot. Python strings, buffer objects and memory mapped files are examples of objects providing this slot. errors defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamReader for codecs which have to keep state in order to make decoding efficient. The decoder must be able to handle zero length input and return an empty object of the output object type in this situation. """ raise NotImplementedError class IncrementalEncoder(object): """ An IncrementalEncoder encodes an input in multiple steps. The input can be passed piece by piece to the encode() method. The IncrementalEncoder remembers the state of the Encoding process between calls to encode(). """ def __init__(self, errors='strict'): """ Creates an IncrementalEncoder instance. The IncrementalEncoder may use different error handling schemes by providing the errors keyword argument. See the module docstring for a list of possible values. """ self.errors = errors self.buffer = "" def encode(self, input, final=False): """ Encodes input and returns the resulting object. """ raise NotImplementedError def reset(self): """ Resets the encoder to the initial state. """ def getstate(self): """ Return the current state of the encoder. """ return 0 def setstate(self, state): """ Set the current state of the encoder. state must have been returned by getstate(). """ class BufferedIncrementalEncoder(IncrementalEncoder): """ This subclass of IncrementalEncoder can be used as the baseclass for an incremental encoder if the encoder must keep some of the output in a buffer between calls to encode(). """ def __init__(self, errors='strict'): IncrementalEncoder.__init__(self, errors) self.buffer = "" # unencoded input that is kept between calls to encode() def _buffer_encode(self, input, errors, final): # Overwrite this method in subclasses: It must encode input # and return an (output, length consumed) tuple raise NotImplementedError def encode(self, input, final=False): # encode input (taking the buffer into account) data = self.buffer + input (result, consumed) = self._buffer_encode(data, self.errors, final) # keep unencoded input until the next call self.buffer = data[consumed:] return result def reset(self): IncrementalEncoder.reset(self) self.buffer = "" def getstate(self): return self.buffer or 0 def setstate(self, state): self.buffer = state or "" class IncrementalDecoder(object): """ An IncrementalDecoder decodes an input in multiple steps. The input can be passed piece by piece to the decode() method. The IncrementalDecoder remembers the state of the decoding process between calls to decode(). """ def __init__(self, errors='strict'): """ Creates an IncrementalDecoder instance. The IncrementalDecoder may use different error handling schemes by providing the errors keyword argument. See the module docstring for a list of possible values. """ self.errors = errors def decode(self, input, final=False): """ Decodes input and returns the resulting object. """ raise NotImplementedError def reset(self): """ Resets the decoder to the initial state. """ def getstate(self): """ Return the current state of the decoder. This must be a (buffered_input, additional_state_info) tuple. buffered_input must be a bytes object containing bytes that were passed to decode() that have not yet been converted. additional_state_info must be a non-negative integer representing the state of the decoder WITHOUT yet having processed the contents of buffered_input. In the initial state and after reset(), getstate() must return (b"", 0). """ return (b"", 0) def setstate(self, state): """ Set the current state of the decoder. state must have been returned by getstate(). The effect of setstate((b"", 0)) must be equivalent to reset(). """ class BufferedIncrementalDecoder(IncrementalDecoder): """ This subclass of IncrementalDecoder can be used as the baseclass for an incremental decoder if the decoder must be able to handle incomplete byte sequences. """ def __init__(self, errors='strict'): IncrementalDecoder.__init__(self, errors) self.buffer = "" # undecoded input that is kept between calls to decode() def _buffer_decode(self, input, errors, final): # Overwrite this method in subclasses: It must decode input # and return an (output, length consumed) tuple raise NotImplementedError def decode(self, input, final=False): # decode input (taking the buffer into account) data = self.buffer + input (result, consumed) = self._buffer_decode(data, self.errors, final) # keep undecoded input until the next call self.buffer = data[consumed:] return result def reset(self): IncrementalDecoder.reset(self) self.buffer = "" def getstate(self): # additional state info is always 0 return (self.buffer, 0) def setstate(self, state): # ignore additional state info self.buffer = state[0] # # The StreamWriter and StreamReader class provide generic working # interfaces which can be used to implement new encoding submodules # very easily. See encodings/utf_8.py for an example on how this is # done. # class StreamWriter(Codec): def __init__(self, stream, errors='strict'): """ Creates a StreamWriter instance. stream must be a file-like object open for writing (binary) data. The StreamWriter may use different error handling schemes by providing the errors keyword argument. These parameters are predefined: 'strict' - raise a ValueError (or a subclass) 'ignore' - ignore the character and continue with the next 'replace'- replace with a suitable replacement character 'xmlcharrefreplace' - Replace with the appropriate XML character reference. 'backslashreplace' - Replace with backslashed escape sequences (only for encoding). The set of allowed parameter values can be extended via register_error. """ self.stream = stream self.errors = errors def write(self, object): """ Writes the object's contents encoded to self.stream. """ data, consumed = self.encode(object, self.errors) self.stream.write(data) def writelines(self, list): """ Writes the concatenated list of strings to the stream using .write(). """ self.write(''.join(list)) def reset(self): """ Flushes and resets the codec buffers used for keeping state. Calling this method should ensure that the data on the output is put into a clean state, that allows appending of new fresh data without having to rescan the whole stream to recover state. """ pass def seek(self, offset, whence=0): self.stream.seek(offset, whence) if whence == 0 and offset == 0: self.reset() def __getattr__(self, name, getattr=getattr): """ Inherit all other methods from the underlying stream. """ return getattr(self.stream, name) def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() ### class StreamReader(Codec): def __init__(self, stream, errors='strict'): """ Creates a StreamReader instance. stream must be a file-like object open for reading (binary) data. The StreamReader may use different error handling schemes by providing the errors keyword argument. These parameters are predefined: 'strict' - raise a ValueError (or a subclass) 'ignore' - ignore the character and continue with the next 'replace'- replace with a suitable replacement character; The set of allowed parameter values can be extended via register_error. """ self.stream = stream self.errors = errors self.bytebuffer = "" # For str->str decoding this will stay a str # For str->unicode decoding the first read will promote it to unicode self.charbuffer = "" self.linebuffer = None def decode(self, input, errors='strict'): raise NotImplementedError def read(self, size=-1, chars=-1, firstline=False): """ Decodes data from the stream self.stream and returns the resulting object. chars indicates the number of characters to read from the stream. read() will never return more than chars characters, but it might return less, if there are not enough characters available. size indicates the approximate maximum number of bytes to read from the stream for decoding purposes. The decoder can modify this setting as appropriate. The default value -1 indicates to read and decode as much as possible. size is intended to prevent having to decode huge files in one step. If firstline is true, and a UnicodeDecodeError happens after the first line terminator in the input only the first line will be returned, the rest of the input will be kept until the next call to read(). The method should use a greedy read strategy meaning that it should read as much data as is allowed within the definition of the encoding and the given size, e.g. if optional encoding endings or state markers are available on the stream, these should be read too. """ # If we have lines cached, first merge them back into characters if self.linebuffer: self.charbuffer = "".join(self.linebuffer) self.linebuffer = None if chars < 0: # For compatibility with other read() methods that take a # single argument chars = size # read until we get the required number of characters (if available) while True: # can the request be satisfied from the character buffer? if chars >= 0: if len(self.charbuffer) >= chars: break # we need more data if size < 0: newdata = self.stream.read() else: newdata = self.stream.read(size) # decode bytes (those remaining from the last call included) data = self.bytebuffer + newdata try: newchars, decodedbytes = self.decode(data, self.errors) except UnicodeDecodeError, exc: if firstline: newchars, decodedbytes = self.decode(data[:exc.start], self.errors) lines = newchars.splitlines(True) if len(lines)<=1: raise else: raise # keep undecoded bytes until the next call self.bytebuffer = data[decodedbytes:] # put new characters in the character buffer self.charbuffer += newchars # there was no data available if not newdata: break if chars < 0: # Return everything we've got result = self.charbuffer self.charbuffer = "" else: # Return the first chars characters result = self.charbuffer[:chars] self.charbuffer = self.charbuffer[chars:] return result def readline(self, size=None, keepends=True): """ Read one line from the input stream and return the decoded data. size, if given, is passed as size argument to the read() method. """ # If we have lines cached from an earlier read, return # them unconditionally if self.linebuffer: line = self.linebuffer[0] del self.linebuffer[0] if len(self.linebuffer) == 1: # revert to charbuffer mode; we might need more data # next time self.charbuffer = self.linebuffer[0] self.linebuffer = None if not keepends: line = line.splitlines(False)[0] return line readsize = size or 72 line = "" # If size is given, we call read() only once while True: data = self.read(readsize, firstline=True) if data: # If we're at a "\r" read one extra character (which might # be a "\n") to get a proper line ending. If the stream is # temporarily exhausted we return the wrong line ending. if data.endswith("\r"): data += self.read(size=1, chars=1) line += data lines = line.splitlines(True) if lines: if len(lines) > 1: # More than one line result; the first line is a full line # to return line = lines[0] del lines[0] if len(lines) > 1: # cache the remaining lines lines[-1] += self.charbuffer self.linebuffer = lines self.charbuffer = None else: # only one remaining line, put it back into charbuffer self.charbuffer = lines[0] + self.charbuffer if not keepends: line = line.splitlines(False)[0] break line0withend = lines[0] line0withoutend = lines[0].splitlines(False)[0] if line0withend != line0withoutend: # We really have a line end # Put the rest back together and keep it until the next call self.charbuffer = "".join(lines[1:]) + self.charbuffer if keepends: line = line0withend else: line = line0withoutend break # we didn't get anything or this was our only try if not data or size is not None: if line and not keepends: line = line.splitlines(False)[0] break if readsize<8000: readsize *= 2 return line def readlines(self, sizehint=None, keepends=True): """ Read all lines available on the input stream and return them as list of lines. Line breaks are implemented using the codec's decoder method and are included in the list entries. sizehint, if given, is ignored since there is no efficient way to finding the true end-of-line. """ data = self.read() return data.splitlines(keepends) def reset(self): """ Resets the codec buffers used for keeping state. Note that no stream repositioning should take place. This method is primarily intended to be able to recover from decoding errors. """ self.bytebuffer = "" self.charbuffer = u"" self.linebuffer = None def seek(self, offset, whence=0): """ Set the input stream's current position. Resets the codec buffers used for keeping state. """ self.stream.seek(offset, whence) self.reset() def next(self): """ Return the next decoded line from the input stream.""" line = self.readline() if line: return line raise StopIteration def __iter__(self): return self def __getattr__(self, name, getattr=getattr): """ Inherit all other methods from the underlying stream. """ return getattr(self.stream, name) def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() ### class StreamReaderWriter: """ StreamReaderWriter instances allow wrapping streams which work in both read and write modes. The design is such that one can use the factory functions returned by the codec.lookup() function to construct the instance. """ # Optional attributes set by the file wrappers below encoding = 'unknown' def __init__(self, stream, Reader, Writer, errors='strict'): """ Creates a StreamReaderWriter instance. stream must be a Stream-like object. Reader, Writer must be factory functions or classes providing the StreamReader, StreamWriter interface resp. Error handling is done in the same way as defined for the StreamWriter/Readers. """ self.stream = stream self.reader = Reader(stream, errors) self.writer = Writer(stream, errors) self.errors = errors def read(self, size=-1): return self.reader.read(size) def readline(self, size=None): return self.reader.readline(size) def readlines(self, sizehint=None): return self.reader.readlines(sizehint) def next(self): """ Return the next decoded line from the input stream.""" return self.reader.next() def __iter__(self): return self def write(self, data): return self.writer.write(data) def writelines(self, list): return self.writer.writelines(list) def reset(self): self.reader.reset() self.writer.reset() def seek(self, offset, whence=0): self.stream.seek(offset, whence) self.reader.reset() if whence == 0 and offset == 0: self.writer.reset() def __getattr__(self, name, getattr=getattr): """ Inherit all other methods from the underlying stream. """ return getattr(self.stream, name) # these are needed to make "with codecs.open(...)" work properly def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() ### class StreamRecoder: """ StreamRecoder instances provide a frontend - backend view of encoding data. They use the complete set of APIs returned by the codecs.lookup() function to implement their task. Data written to the stream is first decoded into an intermediate format (which is dependent on the given codec combination) and then written to the stream using an instance of the provided Writer class. In the other direction, data is read from the stream using a Reader instance and then return encoded data to the caller. """ # Optional attributes set by the file wrappers below data_encoding = 'unknown' file_encoding = 'unknown' def __init__(self, stream, encode, decode, Reader, Writer, errors='strict'): """ Creates a StreamRecoder instance which implements a two-way conversion: encode and decode work on the frontend (the input to .read() and output of .write()) while Reader and Writer work on the backend (reading and writing to the stream). You can use these objects to do transparent direct recodings from e.g. latin-1 to utf-8 and back. stream must be a file-like object. encode, decode must adhere to the Codec interface, Reader, Writer must be factory functions or classes providing the StreamReader, StreamWriter interface resp. encode and decode are needed for the frontend translation, Reader and Writer for the backend translation. Unicode is used as intermediate encoding. Error handling is done in the same way as defined for the StreamWriter/Readers. """ self.stream = stream self.encode = encode self.decode = decode self.reader = Reader(stream, errors) self.writer = Writer(stream, errors) self.errors = errors def read(self, size=-1): data = self.reader.read(size) data, bytesencoded = self.encode(data, self.errors) return data def readline(self, size=None): if size is None: data = self.reader.readline() else: data = self.reader.readline(size) data, bytesencoded = self.encode(data, self.errors) return data def readlines(self, sizehint=None): data = self.reader.read() data, bytesencoded = self.encode(data, self.errors) return data.splitlines(1) def next(self): """ Return the next decoded line from the input stream.""" data = self.reader.next() data, bytesencoded = self.encode(data, self.errors) return data def __iter__(self): return self def write(self, data): data, bytesdecoded = self.decode(data, self.errors) return self.writer.write(data) def writelines(self, list): data = ''.join(list) data, bytesdecoded = self.decode(data, self.errors) return self.writer.write(data) def reset(self): self.reader.reset() self.writer.reset() def __getattr__(self, name, getattr=getattr): """ Inherit all other methods from the underlying stream. """ return getattr(self.stream, name) def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() ### Shortcuts def open(filename, mode='rb', encoding=None, errors='strict', buffering=1): """ Open an encoded file using the given mode and return a wrapped version providing transparent encoding/decoding. Note: The wrapped version will only accept the object format defined by the codecs, i.e. Unicode objects for most builtin codecs. Output is also codec dependent and will usually be Unicode as well. Files are always opened in binary mode, even if no binary mode was specified. This is done to avoid data loss due to encodings using 8-bit values. The default file mode is 'rb' meaning to open the file in binary read mode. encoding specifies the encoding which is to be used for the file. errors may be given to define the error handling. It defaults to 'strict' which causes ValueErrors to be raised in case an encoding error occurs. buffering has the same meaning as for the builtin open() API. It defaults to line buffered. The returned wrapped file object provides an extra attribute .encoding which allows querying the used encoding. This attribute is only available if an encoding was specified as parameter. """ if encoding is not None: if 'U' in mode: # No automatic conversion of '\n' is done on reading and writing mode = mode.strip().replace('U', '') if mode[:1] not in set('rwa'): mode = 'r' + mode if 'b' not in mode: # Force opening of the file in binary mode mode = mode + 'b' file = __builtin__.open(filename, mode, buffering) if encoding is None: return file info = lookup(encoding) srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors) # Add attributes to simplify introspection srw.encoding = encoding return srw def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'): """ Return a wrapped version of file which provides transparent encoding translation. Strings written to the wrapped file are interpreted according to the given data_encoding and then written to the original file as string using file_encoding. The intermediate encoding will usually be Unicode but depends on the specified codecs. Strings are read from the file using file_encoding and then passed back to the caller as string using data_encoding. If file_encoding is not given, it defaults to data_encoding. errors may be given to define the error handling. It defaults to 'strict' which causes ValueErrors to be raised in case an encoding error occurs. The returned wrapped file object provides two extra attributes .data_encoding and .file_encoding which reflect the given parameters of the same name. The attributes can be used for introspection by Python programs. """ if file_encoding is None: file_encoding = data_encoding data_info = lookup(data_encoding) file_info = lookup(file_encoding) sr = StreamRecoder(file, data_info.encode, data_info.decode, file_info.streamreader, file_info.streamwriter, errors) # Add attributes to simplify introspection sr.data_encoding = data_encoding sr.file_encoding = file_encoding return sr ### Helpers for codec lookup def getencoder(encoding): """ Lookup up the codec for the given encoding and return its encoder function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding).encode def getdecoder(encoding): """ Lookup up the codec for the given encoding and return its decoder function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding).decode def getincrementalencoder(encoding): """ Lookup up the codec for the given encoding and return its IncrementalEncoder class or factory function. Raises a LookupError in case the encoding cannot be found or the codecs doesn't provide an incremental encoder. """ encoder = lookup(encoding).incrementalencoder if encoder is None: raise LookupError(encoding) return encoder def getincrementaldecoder(encoding): """ Lookup up the codec for the given encoding and return its IncrementalDecoder class or factory function. Raises a LookupError in case the encoding cannot be found or the codecs doesn't provide an incremental decoder. """ decoder = lookup(encoding).incrementaldecoder if decoder is None: raise LookupError(encoding) return decoder def getreader(encoding): """ Lookup up the codec for the given encoding and return its StreamReader class or factory function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding).streamreader def getwriter(encoding): """ Lookup up the codec for the given encoding and return its StreamWriter class or factory function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding).streamwriter def iterencode(iterator, encoding, errors='strict', **kwargs): """ Encoding iterator. Encodes the input strings from the iterator using an IncrementalEncoder. errors and kwargs are passed through to the IncrementalEncoder constructor. """ encoder = getincrementalencoder(encoding)(errors, **kwargs) for input in iterator: output = encoder.encode(input) if output: yield output output = encoder.encode("", True) if output: yield output def iterdecode(iterator, encoding, errors='strict', **kwargs): """ Decoding iterator. Decodes the input strings from the iterator using an IncrementalDecoder. errors and kwargs are passed through to the IncrementalDecoder constructor. """ decoder = getincrementaldecoder(encoding)(errors, **kwargs) for input in iterator: output = decoder.decode(input) if output: yield output output = decoder.decode("", True) if output: yield output ### Helpers for charmap-based codecs def make_identity_dict(rng): """ make_identity_dict(rng) -> dict Return a dictionary where elements of the rng sequence are mapped to themselves. """ res = {} for i in rng: res[i]=i return res def make_encoding_map(decoding_map): """ Creates an encoding map from a decoding map. If a target mapping in the decoding map occurs multiple times, then that target is mapped to None (undefined mapping), causing an exception when encountered by the charmap codec during translation. One example where this happens is cp875.py which decodes multiple character to \\u001a. """ m = {} for k,v in decoding_map.items(): if not v in m: m[v] = k else: m[v] = None return m ### error handlers try: strict_errors = lookup_error("strict") ignore_errors = lookup_error("ignore") replace_errors = lookup_error("replace") xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") backslashreplace_errors = lookup_error("backslashreplace") except LookupError: # In --disable-unicode builds, these error handler are missing strict_errors = None ignore_errors = None replace_errors = None xmlcharrefreplace_errors = None backslashreplace_errors = None # Tell modulefinder that using codecs probably needs the encodings # package _false = 0 if _false: import encodings ### Tests if __name__ == '__main__': # Make stdout translate Latin-1 output into UTF-8 output sys.stdout = EncodedFile(sys.stdout, 'latin-1', 'utf-8') # Have stdin translate Latin-1 input into UTF-8 input sys.stdin = EncodedFile(sys.stdin, 'utf-8', 'latin-1')
Save