9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
+
+
|
import storage
import os
import re
import tarfile
import glob
import time
import datetime
from http import HTTP
from gzip import open as gzopen
from settings import global_settings
__all__ = [
'parse_version',
'read_file',
'write_file',
'readlines_file',
'up',
'abspath',
'mktree',
'listdir',
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
+
+
+
+
+
+
+
+
|
'w2p_pack',
'w2p_unpack',
'w2p_pack_plugin',
'w2p_unpack_plugin',
'fix_newlines',
'make_fake_file_like_object',
]
def parse_version(version = "Version 1.99.0 (2011-09-19 08:23:26)"):
re_version = re.compile('[^\d]+ (\d+)\.(\d+)\.(\d+)\s*\((?P<datetime>.+?)\)\s*(?P<type>[a-z]+)?')
m = re_version.match(version)
a,b,c = int(m.group(1)),int(m.group(2)),int(m.group(3)),
s = m.group('type') or 'dev'
d = datetime.datetime.strptime(m.group('datetime'),'%Y-%m-%d %H:%M:%S')
return (a,b,c,d,s)
def read_file(filename, mode='r'):
"returns content from filename, making sure to close the file explicitly on exit."
f = open(filename, mode)
try:
return f.read()
finally:
|
380
381
382
383
384
385
386
387
|
390
391
392
393
394
395
396
397
398
399
|
+
+
|
def make_fake_file_like_object():
class LogFile(object):
def write(self, value):
pass
def close(self):
pass
return LogFile()
|