MCPcopy Create free account
hub / github.com/ActiveState/code / open

Function open

recipes/Python/521897_SingleUploadpy/recipe-521897.py:9–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7search = compile(r'([^\\/]+)$').search
8
9def open():
10 global next, last
11 try:
12 next = '--' + parse_header(env['CONTENT_TYPE'])[1]['boundary']
13 except:
14 raise IOError
15
16 last = next + '--'
17
18 filename = None
19 while not filename:
20 while True:
21 l = stdin.readline(65536)
22 if not l:
23 raise IOError
24
25 if l[:2] == '--':
26 sl = l.strip()
27 if sl == next:
28 break
29 if sl == last:
30 raise IOError
31
32 for i in xrange(10):
33 l = stdin.readline(65536).strip()
34 if not l:
35 break
36 try:
37 filename = parse_header(l.split(':', 1)[1])[1]['filename']
38 break
39 except:
40 continue
41
42 m = search(filename)
43 if not m:
44 raise IOError
45 filename = m.groups()[0]
46
47 while stdin.readline(65536).strip():
48 pass
49
50 def _readline():
51 el = ''
52 while True:
53 l = stdin.readline(65536)
54 if not l:
55 raise IOError
56
57 if l[:2] == '--' and el:
58 sl = l.strip()
59 if sl == next or sl == last:
60 break
61
62 ol, el = el, l[-2:] == '\r\n' and '\r\n' or (
63 l[-1] == '\n' and '\n' or '')
64
65 p = len(el)
66 if p == 0:

Callers 15

charge_boiteFunction · 0.50
recipe-546517.pyFile · 0.50
__init__Method · 0.50
download_othersFunction · 0.50
download_ucomics_dot_comFunction · 0.50
download_comics_dot_comFunction · 0.50
composeFunction · 0.50
digestFunction · 0.50
upperOpenFunction · 0.50
recipe-52228.pyFile · 0.50
md5_from_pathFunction · 0.50
mainFunction · 0.50

Calls 6

xrangeClass · 0.85
_readlineFunction · 0.85
searchFunction · 0.50
readlineMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45

Tested by 12

test_exit_cleanlyMethod · 0.40
test_exceptionMethod · 0.40
test_signalMethod · 0.40
test_appended_signalMethod · 0.40
test_kinterruptMethod · 0.40
test_systemexitMethod · 0.40
test_called_onceMethod · 0.40
test_cascadeMethod · 0.40
test_all_exit_sigsMethod · 0.40
test_as_decoMethod · 0.40
test_fileFunction · 0.40