repo_name
stringlengths 6
100
| path
stringlengths 4
294
| copies
stringclasses 981
values | size
stringlengths 4
6
| content
stringlengths 606
896k
| license
stringclasses 15
values | input_ids
listlengths 1.02k
1.02k
| labels
listlengths 1.02k
1.02k
| attention_mask
listlengths 1.02k
1.02k
|
|---|---|---|---|---|---|---|---|---|
psawaya/Mental-Ginger
|
django/utils/numberformat.py
|
290
|
1632
|
from django.conf import settings
from django.utils.safestring import mark_safe
def format(number, decimal_sep, decimal_pos, grouping=0, thousand_sep=''):
"""
Gets a number (as a number or string), and returns it as a string,
using formats definied as arguments:
* decimal_sep: Decimal separator symbol (for example ".")
* decimal_pos: Number of decimal positions
* grouping: Number of digits in every group limited by thousand separator
* thousand_sep: Thousand separator symbol (for example ",")
"""
use_grouping = settings.USE_L10N and \
settings.USE_THOUSAND_SEPARATOR and grouping
# Make the common case fast:
if isinstance(number, int) and not use_grouping and not decimal_pos:
return mark_safe(unicode(number))
# sign
if float(number) < 0:
sign = '-'
else:
sign = ''
str_number = unicode(number)
if str_number[0] == '-':
str_number = str_number[1:]
# decimal part
if '.' in str_number:
int_part, dec_part = str_number.split('.')
if decimal_pos:
dec_part = dec_part[:decimal_pos]
else:
int_part, dec_part = str_number, ''
if decimal_pos:
dec_part = dec_part + ('0' * (decimal_pos - len(dec_part)))
if dec_part: dec_part = decimal_sep + dec_part
# grouping
if use_grouping:
int_part_gd = ''
for cnt, digit in enumerate(int_part[::-1]):
if cnt and not cnt % grouping:
int_part_gd += thousand_sep
int_part_gd += digit
int_part = int_part_gd[::-1]
return sign + int_part + dec_part
|
bsd-3-clause
|
[
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
421,
199,
318,
1475,
8,
1955,
12,
6107,
63,
4127,
12,
6107,
63,
1712,
12,
17786,
29,
16,
12,
294,
1785,
460,
63,
4127,
9280,
272,
408,
272,
14509,
282,
1329,
334,
305,
282,
1329,
503,
1059,
395,
436,
2529,
652,
465,
282,
1059,
12,
272,
1808,
6752,
347,
2730,
379,
465,
2368,
26,
339,
627,
6107,
63,
4127,
26,
6345,
9432,
5272,
334,
509,
2893,
298,
2685,
272,
627,
6107,
63,
1712,
26,
4860,
402,
6107,
12266,
272,
627,
17786,
26,
4860,
402,
7576,
315,
4036,
1572,
13988,
701,
294,
1785,
460,
9432,
272,
627,
294,
1785,
460,
63,
4127,
26,
18049,
527,
460,
9432,
5272,
334,
509,
2893,
3872,
531,
339,
408,
272,
675,
63,
22390,
275,
2202,
14,
4701,
63,
44,
709,
46,
436,
971,
267,
2202,
14,
4701,
63,
28714,
63,
15828,
436,
17786,
272,
327,
4155,
314,
2863,
1930,
7377,
26,
272,
340,
1228,
8,
1955,
12,
1109,
9,
436,
440,
675,
63,
22390,
436,
440,
6107,
63,
1712,
26,
267,
372,
2216,
63,
3489,
8,
2975,
8,
1955,
430,
272,
327,
2070,
272,
340,
2069,
8,
1955,
9,
665,
378,
26,
267,
2070,
275,
10791,
272,
587,
26,
267,
2070,
275,
2125,
272,
620,
63,
1955,
275,
2649,
8,
1955,
9,
272,
340,
620,
63,
1955,
59,
16,
61,
508,
20905,
267,
620,
63,
1955,
275,
620,
63,
1955,
59,
17,
2938,
272,
327,
6107,
1777,
272,
340,
7815,
315,
620,
63,
1955,
26,
267,
1109,
63,
2064,
12,
9700,
63,
2064,
275,
620,
63,
1955,
14,
1294,
7563,
267,
340,
6107,
63,
1712,
26,
288,
9700,
63,
2064,
275,
9700,
63,
2064,
1491,
6355,
63,
1712,
61,
272,
587,
26,
267,
1109,
63,
2064,
12,
9700,
63,
2064,
275,
620,
63,
1955,
12,
2125,
272,
340,
6107,
63,
1712,
26,
267,
9700,
63,
2064,
275,
9700,
63,
2064,
435,
661,
16,
7,
627,
334,
6355,
63,
1712,
446,
822,
8,
7778,
63,
2064,
1724,
272,
340,
9700,
63,
2064,
26,
9700,
63,
2064,
275,
6107,
63,
4127,
435,
9700,
63,
2064,
272,
327,
17786,
272,
340,
675,
63,
22390,
26,
267,
1109,
63,
2064,
63,
7136,
275,
2125,
267,
367,
12703,
12,
10964,
315,
3874,
8,
442,
63,
2064,
14172,
17,
4682,
288,
340,
12703,
436,
440,
12703,
450,
17786,
26,
355,
1109,
63,
2064,
63,
7136,
847,
294,
1785,
460,
63,
4127,
288,
1109,
63,
2064,
63,
7136,
847,
10964,
267,
1109,
63,
2064,
275,
1109,
63,
2064,
63,
7136,
14172,
17,
61,
272,
372,
2070,
435,
1109,
63,
2064,
435,
9700,
63,
2064,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
421,
199,
318,
1475,
8,
1955,
12,
6107,
63,
4127,
12,
6107,
63,
1712,
12,
17786,
29,
16,
12,
294,
1785,
460,
63,
4127,
9280,
272,
408,
272,
14509,
282,
1329,
334,
305,
282,
1329,
503,
1059,
395,
436,
2529,
652,
465,
282,
1059,
12,
272,
1808,
6752,
347,
2730,
379,
465,
2368,
26,
339,
627,
6107,
63,
4127,
26,
6345,
9432,
5272,
334,
509,
2893,
298,
2685,
272,
627,
6107,
63,
1712,
26,
4860,
402,
6107,
12266,
272,
627,
17786,
26,
4860,
402,
7576,
315,
4036,
1572,
13988,
701,
294,
1785,
460,
9432,
272,
627,
294,
1785,
460,
63,
4127,
26,
18049,
527,
460,
9432,
5272,
334,
509,
2893,
3872,
531,
339,
408,
272,
675,
63,
22390,
275,
2202,
14,
4701,
63,
44,
709,
46,
436,
971,
267,
2202,
14,
4701,
63,
28714,
63,
15828,
436,
17786,
272,
327,
4155,
314,
2863,
1930,
7377,
26,
272,
340,
1228,
8,
1955,
12,
1109,
9,
436,
440,
675,
63,
22390,
436,
440,
6107,
63,
1712,
26,
267,
372,
2216,
63,
3489,
8,
2975,
8,
1955,
430,
272,
327,
2070,
272,
340,
2069,
8,
1955,
9,
665,
378,
26,
267,
2070,
275,
10791,
272,
587,
26,
267,
2070,
275,
2125,
272,
620,
63,
1955,
275,
2649,
8,
1955,
9,
272,
340,
620,
63,
1955,
59,
16,
61,
508,
20905,
267,
620,
63,
1955,
275,
620,
63,
1955,
59,
17,
2938,
272,
327,
6107,
1777,
272,
340,
7815,
315,
620,
63,
1955,
26,
267,
1109,
63,
2064,
12,
9700,
63,
2064,
275,
620,
63,
1955,
14,
1294,
7563,
267,
340,
6107,
63,
1712,
26,
288,
9700,
63,
2064,
275,
9700,
63,
2064,
1491,
6355,
63,
1712,
61,
272,
587,
26,
267,
1109,
63,
2064,
12,
9700,
63,
2064,
275,
620,
63,
1955,
12,
2125,
272,
340,
6107,
63,
1712,
26,
267,
9700,
63,
2064,
275,
9700,
63,
2064,
435,
661,
16,
7,
627,
334,
6355,
63,
1712,
446,
822,
8,
7778,
63,
2064,
1724,
272,
340,
9700,
63,
2064,
26,
9700,
63,
2064,
275,
6107,
63,
4127,
435,
9700,
63,
2064,
272,
327,
17786,
272,
340,
675,
63,
22390,
26,
267,
1109,
63,
2064,
63,
7136,
275,
2125,
267,
367,
12703,
12,
10964,
315,
3874,
8,
442,
63,
2064,
14172,
17,
4682,
288,
340,
12703,
436,
440,
12703,
450,
17786,
26,
355,
1109,
63,
2064,
63,
7136,
847,
294,
1785,
460,
63,
4127,
288,
1109,
63,
2064,
63,
7136,
847,
10964,
267,
1109,
63,
2064,
275,
1109,
63,
2064,
63,
7136,
14172,
17,
61,
272,
372,
2070,
435,
1109,
63,
2064,
435,
9700,
63,
2064,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
santisiri/popego
|
envs/ALPHA-POPEGO/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/plugins/isolate.py
|
1
|
3674
|
"""Use the isolation plugin with --with-isolation or the
NOSE_WITH_ISOLATION environment variable to clean sys.modules after
each test module is loaded and executed.
The isolation module is in effect similar to wrapping the following
functions around the import and execution of each test module::
def setup(module):
module._mods = sys.modules.copy()
def teardown(module):
to_del = [ m for m in sys.modules.keys() if m not in
module._mods ]
for mod in to_del:
del sys.modules[mod]
sys.modules.update(module._mods)
Isolation works only during lazy loading. In normal use, this is only
during discovery of modules within a directory, where the process of
importing, loading tests and running tests from each module is
encapsulated in a single loadTestsFromName call. This plugin
implements loadTestsFromNames to force the same lazy-loading there,
which allows isolation to work in directed mode as well as discovery,
at the cost of some efficiency: lazy-loading names forces full context
setup and teardown to run for each name, defeating the grouping that
is normally used to ensure that context setup and teardown are run the
fewest possible times for a given set of names.
PLEASE NOTE that this plugin should not be used in conjunction with
other plugins that assume that modules once imported will stay
imported; for instance, it may cause very odd results when used with
the coverage plugin.
"""
import logging
import sys
from nose.plugins import Plugin
log = logging.getLogger('nose.plugins.isolation')
class IsolationPlugin(Plugin):
"""
Activate the isolation plugin to isolate changes to external
modules to a single test module or package. The isolation plugin
resets the contents of sys.modules after each test module or
package runs to its state before the test. PLEASE NOTE that this
plugin should not be used with the coverage plugin in any other case
where module reloading may produce undesirable side-effects.
"""
score = 10 # I want to be last
name = 'isolation'
def configure(self, options, conf):
Plugin.configure(self, options, conf)
self._mod_stack = []
def beforeContext(self):
"""Copy sys.modules onto my mod stack
"""
mods = sys.modules.copy()
self._mod_stack.append(mods)
def afterContext(self):
"""Pop my mod stack and restore sys.modules to the state
it was in when mod stack was pushed.
"""
mods = self._mod_stack.pop()
to_del = [ m for m in sys.modules.keys() if m not in mods ]
if to_del:
log.debug('removing sys modules entries: %s', to_del)
for mod in to_del:
del sys.modules[mod]
sys.modules.update(mods)
def loadTestsFromNames(self, names, module=None):
"""Create a lazy suite that calls beforeContext and afterContext
around each name. The side-effect of this is that full context
fixtures will be set up and torn down around each test named.
"""
# Fast path for when we don't care
if not names or len(names) == 1:
return
loader = self.loader
plugins = self.conf.plugins
def lazy():
for name in names:
plugins.beforeContext()
yield loader.loadTestsFromName(name, module=module)
plugins.afterContext()
return (loader.suiteClass(lazy), [])
def prepareTestLoader(self, loader):
"""Get handle on test loader so we can use it in loadTestsFromNames.
"""
self.loader = loader
|
bsd-3-clause
|
[
624,
6119,
314,
30567,
3589,
543,
1553,
1045,
13,
20808,
503,
314,
199,
2826,
899,
63,
9139,
63,
1311,
2228,
2594,
3734,
1750,
370,
3633,
984,
14,
3112,
2410,
199,
10885,
511,
859,
365,
6511,
436,
7934,
14,
199,
199,
1918,
30567,
859,
365,
315,
7763,
8545,
370,
19696,
314,
2569,
199,
5777,
6818,
314,
492,
436,
6451,
402,
1924,
511,
859,
447,
339,
347,
3272,
8,
578,
304,
267,
859,
423,
19709,
275,
984,
14,
3112,
14,
1574,
342,
2286,
347,
17558,
8,
578,
304,
267,
370,
63,
2264,
275,
359,
333,
367,
333,
315,
984,
14,
3112,
14,
1612,
342,
340,
333,
440,
315,
673,
859,
423,
19709,
1622,
267,
367,
3413,
315,
370,
63,
2264,
26,
288,
2150,
984,
14,
3112,
59,
1494,
61,
267,
984,
14,
3112,
14,
873,
8,
578,
423,
19709,
9,
199,
199,
1831,
10410,
5419,
1454,
5309,
9617,
8697,
14,
1010,
3293,
675,
12,
642,
365,
1454,
199,
27868,
13172,
402,
4621,
4453,
282,
2082,
12,
2382,
314,
2112,
402,
199,
646,
316,
12,
8697,
2295,
436,
3879,
2295,
687,
1924,
859,
365,
199,
287,
12029,
8097,
315,
282,
2849,
2248,
11519,
985,
1240,
14,
961,
3589,
199,
24900,
2248,
11519,
5866,
370,
3542,
314,
2011,
9617,
13,
8786,
2337,
12,
199,
6777,
6127,
30567,
370,
1736,
315,
23667,
818,
465,
5521,
465,
13172,
12,
199,
292,
314,
7918,
402,
2005,
25978,
26,
9617,
13,
8786,
1561,
25983,
2615,
1067,
199,
2758,
436,
17558,
370,
1255,
367,
1924,
536,
12,
347,
69,
1958,
314,
17786,
626,
199,
374,
12252,
1202,
370,
4868,
626,
1067,
3272,
436,
17558,
787,
1255,
314,
199,
70,
546,
597,
3962,
5431,
367,
282,
1627,
663,
402,
1561,
14,
199,
199,
48,
17177,
6944,
626,
642,
3589,
1077,
440,
506,
1202,
315,
22888,
543,
199,
1848,
8963,
626,
5534,
626,
4621,
5403,
8439,
911,
25578,
199,
17932,
27,
367,
1256,
12,
652,
1443,
7675,
7437,
16699,
2058,
1380,
1202,
543,
199,
1589,
11745,
3589,
14,
199,
624,
199,
199,
646,
2050,
199,
646,
984,
199,
199,
504,
11354,
14,
5265,
492,
11349,
421,
199,
793,
275,
2050,
14,
5572,
360,
21085,
14,
5265,
14,
20808,
358,
199,
199,
533,
6596,
10410,
5061,
8,
5061,
304,
272,
408,
272,
21904,
2409,
314,
30567,
3589,
370,
365,
16288,
4493,
370,
5957,
272,
4621,
370,
282,
2849,
511,
859,
503,
2559,
14,
710,
30567,
3589,
272,
295,
2193,
314,
4072,
402,
984,
14,
3112,
2410,
1924,
511,
859,
503,
272,
2559,
7858,
370,
2399,
1174,
2544,
314,
511,
14,
510,
17177,
6944,
626,
642,
272,
3589,
1077,
440,
506,
1202,
543,
314,
11745,
3589,
315,
1263,
1163,
1930,
272,
2382,
859,
295,
8786,
1443,
7389,
625,
271,
338,
6842,
5366,
13,
27626,
14,
272,
408,
272,
5396,
275,
1616,
327,
473,
2934,
370,
506,
2061,
272,
536,
275,
283,
20808,
7,
339,
347,
7908,
8,
277,
12,
1511,
12,
3743,
304,
267,
11349,
14,
6472,
8,
277,
12,
1511,
12,
3743,
9,
267,
291,
423,
1494,
63,
2340,
275,
942,
339,
347,
2544,
2998,
8,
277,
304,
267,
408,
5116,
984,
14,
3112,
14602,
3002,
3413,
3464,
267,
408,
267,
24496,
275,
984,
14,
3112,
14,
1574,
342,
267,
291,
423,
1494,
63,
2340,
14,
740,
8,
19709,
9,
339,
347,
2410,
2998,
8,
277,
304,
267,
408,
9606,
3002,
3413,
3464,
436,
9066,
984,
14,
3112,
370,
314,
1174,
267,
652,
1990,
315,
1380,
3413,
3464,
1990,
22319,
14,
267,
408,
267,
24496,
275,
291,
423,
1494,
63,
2340,
14,
1935,
342,
267,
370,
63,
2264,
275,
359,
333,
367,
333,
315,
984,
14,
3112,
14,
1612,
342,
340,
333,
440,
315,
24496,
1622,
267,
340,
370,
63,
2264,
26,
288,
943,
14,
1757,
360,
264,
7665,
984,
4621,
4811,
26,
450,
83,
297,
370,
63,
2264,
9,
288,
367,
3413,
315,
370,
63,
2264,
26,
355,
2150,
984,
14,
3112,
59,
1494,
61,
267,
984,
14,
3112,
14,
873,
8,
19709,
9,
339,
347,
2248,
11519,
5866,
8,
277,
12,
1561,
12,
859,
29,
403,
304,
267,
408,
2499,
282,
9617,
5241,
626,
4882,
2544,
2998,
436,
2410,
2998,
267,
6818,
1924,
536,
14,
710,
5366,
13,
5881,
402,
642,
365,
626,
2615,
1067,
267,
15188,
911,
506,
663,
1536,
436,
307,
6161,
3224,
6818,
1924,
511,
4310,
14,
267,
408,
267,
327,
22613,
931,
367,
1380,
781,
2793,
1133,
10296,
267,
340,
440,
1561,
503,
822,
8,
1247,
9,
508,
413,
26,
288,
372,
4960,
5077,
275,
291,
14,
3422,
267,
8963,
275,
291,
14,
2190,
14,
5265,
267,
347,
9617,
837,
288,
367,
536,
315,
1561,
26,
355,
8963,
14,
5182,
2998,
342,
355,
1995,
5077,
14,
25998,
8,
354,
12,
859,
29,
578,
9,
355,
8963,
14,
4399,
2998,
342,
267,
372,
334,
3422,
14,
27216,
8,
6395,
395,
3073,
339,
347,
9275,
15824,
8,
277,
12,
5077,
304,
267,
408,
1002,
2429,
641,
511,
5077,
880,
781,
883,
675,
652,
315,
2248,
11519,
5866,
14,
267,
408,
267,
291,
14,
3422,
275,
5077,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
6119,
314,
30567,
3589,
543,
1553,
1045,
13,
20808,
503,
314,
199,
2826,
899,
63,
9139,
63,
1311,
2228,
2594,
3734,
1750,
370,
3633,
984,
14,
3112,
2410,
199,
10885,
511,
859,
365,
6511,
436,
7934,
14,
199,
199,
1918,
30567,
859,
365,
315,
7763,
8545,
370,
19696,
314,
2569,
199,
5777,
6818,
314,
492,
436,
6451,
402,
1924,
511,
859,
447,
339,
347,
3272,
8,
578,
304,
267,
859,
423,
19709,
275,
984,
14,
3112,
14,
1574,
342,
2286,
347,
17558,
8,
578,
304,
267,
370,
63,
2264,
275,
359,
333,
367,
333,
315,
984,
14,
3112,
14,
1612,
342,
340,
333,
440,
315,
673,
859,
423,
19709,
1622,
267,
367,
3413,
315,
370,
63,
2264,
26,
288,
2150,
984,
14,
3112,
59,
1494,
61,
267,
984,
14,
3112,
14,
873,
8,
578,
423,
19709,
9,
199,
199,
1831,
10410,
5419,
1454,
5309,
9617,
8697,
14,
1010,
3293,
675,
12,
642,
365,
1454,
199,
27868,
13172,
402,
4621,
4453,
282,
2082,
12,
2382,
314,
2112,
402,
199,
646,
316,
12,
8697,
2295,
436,
3879,
2295,
687,
1924,
859,
365,
199,
287,
12029,
8097,
315,
282,
2849,
2248,
11519,
985,
1240,
14,
961,
3589,
199,
24900,
2248,
11519,
5866,
370,
3542,
314,
2011,
9617,
13,
8786,
2337,
12,
199,
6777,
6127,
30567,
370,
1736,
315,
23667,
818,
465,
5521,
465,
13172,
12,
199,
292,
314,
7918,
402,
2005,
25978,
26,
9617,
13,
8786,
1561,
25983,
2615,
1067,
199,
2758,
436,
17558,
370,
1255,
367,
1924,
536,
12,
347,
69,
1958,
314,
17786,
626,
199,
374,
12252,
1202,
370,
4868,
626,
1067,
3272,
436,
17558,
787,
1255,
314,
199,
70,
546,
597,
3962,
5431,
367,
282,
1627,
663,
402,
1561,
14,
199,
199,
48,
17177,
6944,
626,
642,
3589,
1077,
440,
506,
1202,
315,
22888,
543,
199,
1848,
8963,
626,
5534,
626,
4621,
5403,
8439,
911,
25578,
199,
17932,
27,
367,
1256,
12,
652,
1443,
7675,
7437,
16699,
2058,
1380,
1202,
543,
199,
1589,
11745,
3589,
14,
199,
624,
199,
199,
646,
2050,
199,
646,
984,
199,
199,
504,
11354,
14,
5265,
492,
11349,
421,
199,
793,
275,
2050,
14,
5572,
360,
21085,
14,
5265,
14,
20808,
358,
199,
199,
533,
6596,
10410,
5061,
8,
5061,
304,
272,
408,
272,
21904,
2409,
314,
30567,
3589,
370,
365,
16288,
4493,
370,
5957,
272,
4621,
370,
282,
2849,
511,
859,
503,
2559,
14,
710,
30567,
3589,
272,
295,
2193,
314,
4072,
402,
984,
14,
3112,
2410,
1924,
511,
859,
503,
272,
2559,
7858,
370,
2399,
1174,
2544,
314,
511,
14,
510,
17177,
6944,
626,
642,
272,
3589,
1077,
440,
506,
1202,
543,
314,
11745,
3589,
315,
1263,
1163,
1930,
272,
2382,
859,
295,
8786,
1443,
7389,
625,
271,
338,
6842,
5366,
13,
27626,
14,
272,
408,
272,
5396,
275,
1616,
327,
473,
2934,
370,
506,
2061,
272,
536,
275,
283,
20808,
7,
339,
347,
7908,
8,
277,
12,
1511,
12,
3743,
304,
267,
11349,
14,
6472,
8,
277,
12,
1511,
12,
3743,
9,
267,
291,
423,
1494,
63,
2340,
275,
942,
339,
347,
2544,
2998,
8,
277,
304,
267,
408,
5116,
984,
14,
3112,
14602,
3002,
3413,
3464,
267,
408,
267,
24496,
275,
984,
14,
3112,
14,
1574,
342,
267,
291,
423,
1494,
63,
2340,
14,
740,
8,
19709,
9,
339,
347,
2410,
2998,
8,
277,
304,
267,
408,
9606,
3002,
3413,
3464,
436,
9066,
984,
14,
3112,
370,
314,
1174,
267,
652,
1990,
315,
1380,
3413,
3464,
1990,
22319,
14,
267,
408,
267,
24496,
275,
291,
423,
1494,
63,
2340,
14,
1935,
342,
267,
370,
63,
2264,
275,
359,
333,
367,
333,
315,
984,
14,
3112,
14,
1612,
342,
340,
333,
440,
315,
24496,
1622,
267,
340,
370,
63,
2264,
26,
288,
943,
14,
1757,
360,
264,
7665,
984,
4621,
4811,
26,
450,
83,
297,
370,
63,
2264,
9,
288,
367,
3413,
315,
370,
63,
2264,
26,
355,
2150,
984,
14,
3112,
59,
1494,
61,
267,
984,
14,
3112,
14,
873,
8,
19709,
9,
339,
347,
2248,
11519,
5866,
8,
277,
12,
1561,
12,
859,
29,
403,
304,
267,
408,
2499,
282,
9617,
5241,
626,
4882,
2544,
2998,
436,
2410,
2998,
267,
6818,
1924,
536,
14,
710,
5366,
13,
5881,
402,
642,
365,
626,
2615,
1067,
267,
15188,
911,
506,
663,
1536,
436,
307,
6161,
3224,
6818,
1924,
511,
4310,
14,
267,
408,
267,
327,
22613,
931,
367,
1380,
781,
2793,
1133,
10296,
267,
340,
440,
1561,
503,
822,
8,
1247,
9,
508,
413,
26,
288,
372,
4960,
5077,
275,
291,
14,
3422,
267,
8963,
275,
291,
14,
2190,
14,
5265,
267,
347,
9617,
837,
288,
367,
536,
315,
1561,
26,
355,
8963,
14,
5182,
2998,
342,
355,
1995,
5077,
14,
25998,
8,
354,
12,
859,
29,
578,
9,
355,
8963,
14,
4399,
2998,
342,
267,
372,
334,
3422,
14,
27216,
8,
6395,
395,
3073,
339,
347,
9275,
15824,
8,
277,
12,
5077,
304,
267,
408,
1002,
2429,
641,
511,
5077,
880,
781,
883,
675,
652,
315,
2248,
11519,
5866,
14,
267,
408,
267,
291,
14,
3422,
275,
5077,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nedlowe/amaas-core-sdk-python
|
amaascore/asset_managers/relationship.py
|
3
|
1737
|
from __future__ import absolute_import, division, print_function, unicode_literals
from amaascore.core.amaas_model import AMaaSModel
from amaascore.asset_managers.enums import RELATIONSHIP_TYPES
class Relationship(AMaaSModel):
def __init__(self, asset_manager_id, related_id, relationship_id, relationship_type, client_id,
relationship_status='Pending', *args, **kwargs):
"""
:param asset_manager_id: The ID of the Asset Manager who owns this relationship
:param related_id: The ID of the Asset Manager to whom this relationship connects
:param relationship_id: An ID for this relationship
:param relationship_type: The type of relationship between these Asset Managers
:param client_id: The client_id that owns this relationship
:param relationship_status: The status of the relationship
:param args:
:param kwargs:
"""
self.asset_manager_id = asset_manager_id
self.related_id = related_id
self.relationship_id = relationship_id
self.relationship_status = relationship_status
self.relationship_type = relationship_type
self.client_id = client_id
super(Relationship, self).__init__(*args, **kwargs)
@property
def relationship_type(self):
if hasattr(self, '_relationship_type'):
return self._relationship_type
@relationship_type.setter
def relationship_type(self, relationship_type):
if relationship_type:
if relationship_type not in RELATIONSHIP_TYPES:
raise ValueError("Invalid Relationship Type: %s" % relationship_type)
else:
self._relationship_type= relationship_type
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
504,
282,
391,
305,
1018,
14,
1018,
14,
14541,
305,
63,
1238,
492,
24343,
2158,
51,
1685,
199,
504,
282,
391,
305,
1018,
14,
6562,
63,
16259,
14,
19921,
492,
820,
2901,
2594,
3234,
1772,
63,
7893,
421,
199,
533,
23230,
3319,
8,
1156,
2158,
51,
1685,
304,
339,
347,
636,
826,
721,
277,
12,
8977,
63,
2609,
63,
344,
12,
4048,
63,
344,
12,
8931,
63,
344,
12,
221,
8931,
63,
466,
12,
1890,
63,
344,
12,
326,
8931,
63,
1205,
534,
15960,
297,
627,
589,
12,
1011,
958,
304,
267,
408,
398,
520,
635,
8977,
63,
2609,
63,
344,
26,
710,
2870,
402,
314,
25670,
13537,
3963,
22182,
561,
642,
8931,
267,
520,
635,
4048,
63,
344,
26,
710,
2870,
402,
314,
25670,
13537,
370,
12676,
642,
8931,
4907,
83,
267,
520,
635,
8931,
63,
344,
26,
1626,
2870,
367,
642,
8931,
267,
520,
635,
8931,
63,
466,
26,
710,
730,
402,
8931,
3382,
3520,
25670,
4688,
10246,
267,
520,
635,
1890,
63,
344,
26,
710,
1890,
63,
344,
626,
22182,
561,
642,
8931,
267,
520,
635,
8931,
63,
1205,
26,
710,
2004,
402,
314,
8931,
267,
520,
635,
1249,
26,
267,
520,
635,
2074,
26,
267,
408,
267,
291,
14,
6562,
63,
2609,
63,
344,
275,
8977,
63,
2609,
63,
344,
267,
291,
14,
2407,
63,
344,
275,
4048,
63,
344,
267,
291,
14,
11704,
63,
344,
275,
8931,
63,
344,
267,
291,
14,
11704,
63,
1205,
275,
8931,
63,
1205,
267,
291,
14,
11704,
63,
466,
275,
8931,
63,
466,
267,
291,
14,
1258,
63,
344,
275,
1890,
63,
344,
267,
1613,
8,
21096,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
768,
1829,
272,
347,
8931,
63,
466,
8,
277,
304,
267,
340,
2688,
8,
277,
12,
2513,
11704,
63,
466,
735,
288,
372,
291,
423,
11704,
63,
466,
339,
768,
11704,
63,
466,
14,
8345,
272,
347,
8931,
63,
466,
8,
277,
12,
8931,
63,
466,
304,
267,
340,
8931,
63,
466,
26,
288,
340,
8931,
63,
466,
440,
315,
820,
2901,
2594,
3234,
1772,
63,
7893,
26,
355,
746,
1722,
480,
3364,
23230,
3319,
2434,
26,
450,
83,
2,
450,
8931,
63,
466,
9,
288,
587,
26,
355,
291,
423,
11704,
63,
466,
29,
8931,
63,
466,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
504,
282,
391,
305,
1018,
14,
1018,
14,
14541,
305,
63,
1238,
492,
24343,
2158,
51,
1685,
199,
504,
282,
391,
305,
1018,
14,
6562,
63,
16259,
14,
19921,
492,
820,
2901,
2594,
3234,
1772,
63,
7893,
421,
199,
533,
23230,
3319,
8,
1156,
2158,
51,
1685,
304,
339,
347,
636,
826,
721,
277,
12,
8977,
63,
2609,
63,
344,
12,
4048,
63,
344,
12,
8931,
63,
344,
12,
221,
8931,
63,
466,
12,
1890,
63,
344,
12,
326,
8931,
63,
1205,
534,
15960,
297,
627,
589,
12,
1011,
958,
304,
267,
408,
398,
520,
635,
8977,
63,
2609,
63,
344,
26,
710,
2870,
402,
314,
25670,
13537,
3963,
22182,
561,
642,
8931,
267,
520,
635,
4048,
63,
344,
26,
710,
2870,
402,
314,
25670,
13537,
370,
12676,
642,
8931,
4907,
83,
267,
520,
635,
8931,
63,
344,
26,
1626,
2870,
367,
642,
8931,
267,
520,
635,
8931,
63,
466,
26,
710,
730,
402,
8931,
3382,
3520,
25670,
4688,
10246,
267,
520,
635,
1890,
63,
344,
26,
710,
1890,
63,
344,
626,
22182,
561,
642,
8931,
267,
520,
635,
8931,
63,
1205,
26,
710,
2004,
402,
314,
8931,
267,
520,
635,
1249,
26,
267,
520,
635,
2074,
26,
267,
408,
267,
291,
14,
6562,
63,
2609,
63,
344,
275,
8977,
63,
2609,
63,
344,
267,
291,
14,
2407,
63,
344,
275,
4048,
63,
344,
267,
291,
14,
11704,
63,
344,
275,
8931,
63,
344,
267,
291,
14,
11704,
63,
1205,
275,
8931,
63,
1205,
267,
291,
14,
11704,
63,
466,
275,
8931,
63,
466,
267,
291,
14,
1258,
63,
344,
275,
1890,
63,
344,
267,
1613,
8,
21096,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
768,
1829,
272,
347,
8931,
63,
466,
8,
277,
304,
267,
340,
2688,
8,
277,
12,
2513,
11704,
63,
466,
735,
288,
372,
291,
423,
11704,
63,
466,
339,
768,
11704,
63,
466,
14,
8345,
272,
347,
8931,
63,
466,
8,
277,
12,
8931,
63,
466,
304,
267,
340,
8931,
63,
466,
26,
288,
340,
8931,
63,
466,
440,
315,
820,
2901,
2594,
3234,
1772,
63,
7893,
26,
355,
746,
1722,
480,
3364,
23230,
3319,
2434,
26,
450,
83,
2,
450,
8931,
63,
466,
9,
288,
587,
26,
355,
291,
423,
11704,
63,
466,
29,
8931,
63,
466,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
2014c2g9/c2g9
|
w2/static/Brython2.0.0-20140209-164925/Lib/functools.py
|
730
|
13596
|
"""functools.py - Tools for working with functions and callable objects
"""
# Python module wrapper for _functools C module
# to allow utilities written in Python to be added
# to the functools module.
# Written by Nick Coghlan <ncoghlan at gmail.com>
# and Raymond Hettinger <python at rcn.com>
# Copyright (C) 2006-2010 Python Software Foundation.
# See C source code for _functools credits/copyright
__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES',
'total_ordering', 'cmp_to_key', 'lru_cache', 'reduce', 'partial']
from _functools import partial, reduce
from collections import namedtuple
try:
from _thread import RLock
except:
class RLock:
'Dummy reentrant lock for builds without threads'
def __enter__(self): pass
def __exit__(self, exctype, excinst, exctb): pass
################################################################################
### update_wrapper() and wraps() decorator
################################################################################
# update_wrapper() and wraps() are tools to help write
# wrapper functions that can handle naive introspection
WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__qualname__', '__doc__',
'__annotations__')
WRAPPER_UPDATES = ('__dict__',)
def update_wrapper(wrapper,
wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):
"""Update a wrapper function to look like the wrapped function
wrapper is the function to be updated
wrapped is the original function
assigned is a tuple naming the attributes assigned directly
from the wrapped function to the wrapper function (defaults to
functools.WRAPPER_ASSIGNMENTS)
updated is a tuple naming the attributes of the wrapper that
are updated with the corresponding attribute from the wrapped
function (defaults to functools.WRAPPER_UPDATES)
"""
wrapper.__wrapped__ = wrapped
for attr in assigned:
try:
value = getattr(wrapped, attr)
except AttributeError:
pass
else:
setattr(wrapper, attr, value)
for attr in updated:
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
# Return the wrapper so this can be used as a decorator via partial()
return wrapper
def wraps(wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):
"""Decorator factory to apply update_wrapper() to a wrapper function
Returns a decorator that invokes update_wrapper() with the decorated
function as the wrapper argument and the arguments to wraps() as the
remaining arguments. Default arguments are as for update_wrapper().
This is a convenience function to simplify applying partial() to
update_wrapper().
"""
return partial(update_wrapper, wrapped=wrapped,
assigned=assigned, updated=updated)
################################################################################
### total_ordering class decorator
################################################################################
def total_ordering(cls):
"""Class decorator that fills in missing ordering methods"""
convert = {
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
('__le__', lambda self, other: self < other or self == other),
('__ge__', lambda self, other: not self < other)],
'__le__': [('__ge__', lambda self, other: not self <= other or self == other),
('__lt__', lambda self, other: self <= other and not self == other),
('__gt__', lambda self, other: not self <= other)],
'__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
('__ge__', lambda self, other: self > other or self == other),
('__le__', lambda self, other: not self > other)],
'__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
('__gt__', lambda self, other: self >= other and not self == other),
('__lt__', lambda self, other: not self >= other)]
}
# Find user-defined comparisons (not those inherited from object).
roots = [op for op in convert if getattr(cls, op, None) is not getattr(object, op, None)]
if not roots:
raise ValueError('must define at least one ordering operation: < > <= >=')
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
for opname, opfunc in convert[root]:
if opname not in roots:
opfunc.__name__ = opname
opfunc.__doc__ = getattr(int, opname).__doc__
setattr(cls, opname, opfunc)
return cls
################################################################################
### cmp_to_key() function converter
################################################################################
def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
class K(object):
__slots__ = ['obj']
def __init__(self, obj):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
def __gt__(self, other):
return mycmp(self.obj, other.obj) > 0
def __eq__(self, other):
return mycmp(self.obj, other.obj) == 0
def __le__(self, other):
return mycmp(self.obj, other.obj) <= 0
def __ge__(self, other):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
__hash__ = None
return K
try:
from _functools import cmp_to_key
except ImportError:
pass
################################################################################
### LRU Cache function decorator
################################################################################
_CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"])
class _HashedSeq(list):
""" This class guarantees that hash() will be called no more than once
per element. This is important because the lru_cache() will hash
the key multiple times on a cache miss.
"""
__slots__ = 'hashvalue'
def __init__(self, tup, hash=hash):
self[:] = tup
self.hashvalue = hash(tup)
def __hash__(self):
return self.hashvalue
def _make_key(args, kwds, typed,
kwd_mark = (object(),),
fasttypes = {int, str, frozenset, type(None)},
sorted=sorted, tuple=tuple, type=type, len=len):
"""Make a cache key from optionally typed positional and keyword arguments
The key is constructed in a way that is flat as possible rather than
as a nested structure that would take more memory.
If there is only a single argument and its data type is known to cache
its hash value, then that argument is returned without a wrapper. This
saves space and improves lookup speed.
"""
key = args
if kwds:
sorted_items = sorted(kwds.items())
key += kwd_mark
for item in sorted_items:
key += item
if typed:
key += tuple(type(v) for v in args)
if kwds:
key += tuple(type(v) for k, v in sorted_items)
elif len(key) == 1 and type(key[0]) in fasttypes:
return key[0]
return _HashedSeq(key)
def lru_cache(maxsize=128, typed=False):
"""Least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
If *typed* is True, arguments of different types will be cached separately.
For example, f(3.0) and f(3) will be treated as distinct calls with
distinct results.
Arguments to the cached function must be hashable.
View the cache statistics named tuple (hits, misses, maxsize, currsize)
with f.cache_info(). Clear the cache and statistics with f.cache_clear().
Access the underlying function with f.__wrapped__.
See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
"""
# Users should only access the lru_cache through its public API:
# cache_info, cache_clear, and f.__wrapped__
# The internals of the lru_cache are encapsulated for thread safety and
# to allow the implementation to change (including a possible C version).
# Constants shared by all lru cache instances:
sentinel = object() # unique object used to signal cache misses
make_key = _make_key # build a key from the function arguments
PREV, NEXT, KEY, RESULT = 0, 1, 2, 3 # names for the link fields
def decorating_function(user_function):
cache = {}
hits = misses = 0
full = False
cache_get = cache.get # bound method to lookup a key or return None
lock = RLock() # because linkedlist updates aren't threadsafe
root = [] # root of the circular doubly linked list
root[:] = [root, root, None, None] # initialize by pointing to self
if maxsize == 0:
def wrapper(*args, **kwds):
# No caching -- just a statistics update after a successful call
nonlocal misses
result = user_function(*args, **kwds)
misses += 1
return result
elif maxsize is None:
def wrapper(*args, **kwds):
# Simple caching without ordering or size limit
nonlocal hits, misses
key = make_key(args, kwds, typed)
result = cache_get(key, sentinel)
if result is not sentinel:
hits += 1
return result
result = user_function(*args, **kwds)
cache[key] = result
misses += 1
return result
else:
def wrapper(*args, **kwds):
# Size limited caching that tracks accesses by recency
nonlocal root, hits, misses, full
key = make_key(args, kwds, typed)
with lock:
link = cache_get(key)
if link is not None:
# Move the link to the front of the circular queue
link_prev, link_next, _key, result = link
link_prev[NEXT] = link_next
link_next[PREV] = link_prev
last = root[PREV]
last[NEXT] = root[PREV] = link
link[PREV] = last
link[NEXT] = root
hits += 1
return result
result = user_function(*args, **kwds)
with lock:
if key in cache:
# Getting here means that this same key was added to the
# cache while the lock was released. Since the link
# update is already done, we need only return the
# computed result and update the count of misses.
pass
elif full:
# Use the old root to store the new key and result.
oldroot = root
oldroot[KEY] = key
oldroot[RESULT] = result
# Empty the oldest link and make it the new root.
# Keep a reference to the old key and old result to
# prevent their ref counts from going to zero during the
# update. That will prevent potentially arbitrary object
# clean-up code (i.e. __del__) from running while we're
# still adjusting the links.
root = oldroot[NEXT]
oldkey = root[KEY]
oldresult = root[RESULT]
root[KEY] = root[RESULT] = None
# Now update the cache dictionary.
del cache[oldkey]
# Save the potentially reentrant cache[key] assignment
# for last, after the root and links have been put in
# a consistent state.
cache[key] = oldroot
else:
# Put result in a new link at the front of the queue.
last = root[PREV]
link = [last, root, key, result]
last[NEXT] = root[PREV] = cache[key] = link
full = (len(cache) >= maxsize)
misses += 1
return result
def cache_info():
"""Report cache statistics"""
with lock:
return _CacheInfo(hits, misses, maxsize, len(cache))
def cache_clear():
"""Clear the cache and cache statistics"""
nonlocal hits, misses, full
with lock:
cache.clear()
root[:] = [root, root, None, None]
hits = misses = 0
full = False
wrapper.cache_info = cache_info
wrapper.cache_clear = cache_clear
return update_wrapper(wrapper, user_function)
return decorating_function
|
gpl-2.0
|
[
624,
17869,
14,
647,
446,
23228,
367,
6449,
543,
3423,
436,
4550,
2251,
199,
624,
199,
3,
2018,
859,
4975,
367,
485,
17869,
445,
859,
199,
3,
370,
2040,
15841,
5313,
315,
2018,
370,
506,
3483,
199,
3,
370,
314,
9143,
859,
14,
199,
3,
27694,
701,
653,
2000,
445,
974,
72,
1502,
665,
78,
331,
3561,
1502,
737,
29712,
14,
957,
30,
199,
3,
436,
30703,
2106,
68,
869,
386,
1337,
281,
665,
1548,
737,
4819,
78,
14,
957,
30,
199,
3,
257,
1898,
334,
35,
9,
8315,
13,
6542,
2018,
2290,
2752,
14,
199,
3,
1666,
445,
1350,
1233,
367,
485,
17869,
2837,
15256,
15,
7307,
199,
199,
363,
452,
363,
275,
788,
873,
63,
5029,
297,
283,
13582,
297,
283,
23824,
4227,
63,
23680,
20967,
297,
283,
23824,
4227,
63,
23612,
654,
297,
1779,
283,
2923,
63,
7128,
297,
283,
5730,
63,
475,
63,
498,
297,
283,
25003,
63,
1637,
297,
283,
5270,
297,
283,
6672,
418,
199,
199,
504,
485,
17869,
492,
7417,
12,
7114,
199,
504,
5055,
492,
12863,
199,
893,
26,
272,
687,
485,
2671,
492,
820,
6432,
199,
2590,
26,
272,
1021,
820,
6432,
26,
267,
283,
11324,
295,
18626,
867,
4650,
367,
14723,
1928,
7183,
7,
267,
347,
636,
4200,
721,
277,
304,
986,
267,
347,
636,
2224,
721,
277,
12,
444,
3667,
12,
3178,
3615,
12,
444,
319,
66,
304,
986,
421,
199,
13289,
199,
5680,
1678,
63,
5029,
342,
436,
14018,
342,
7531,
199,
13289,
199,
199,
3,
1678,
63,
5029,
342,
436,
14018,
342,
787,
7249,
370,
1720,
2218,
199,
3,
4975,
3423,
626,
883,
2429,
19995,
1109,
14254,
199,
199,
23824,
4227,
63,
23680,
20967,
275,
25038,
578,
7500,
2560,
354,
7500,
2560,
537,
354,
7500,
2560,
1301,
7500,
2432,
2560,
11270,
13766,
199,
23824,
4227,
63,
23612,
654,
275,
25038,
807,
7500,
9,
199,
318,
1678,
63,
5029,
8,
5029,
12,
673,
8072,
12,
673,
7943,
275,
16573,
1282,
4227,
63,
23680,
20967,
12,
673,
4588,
275,
16573,
1282,
4227,
63,
23612,
654,
304,
272,
408,
4152,
282,
4975,
805,
370,
3648,
2839,
314,
8072,
805,
10817,
4975,
365,
314,
805,
370,
506,
4588,
2126,
8072,
365,
314,
3379,
805,
2126,
7943,
365,
282,
2008,
19720,
314,
3004,
7943,
5370,
2126,
687,
314,
8072,
805,
370,
314,
4975,
805,
334,
4322,
370,
2126,
9143,
14,
23824,
4227,
63,
23680,
20967,
9,
2126,
4588,
365,
282,
2008,
19720,
314,
3004,
402,
314,
4975,
626,
2126,
787,
4588,
543,
314,
5226,
2225,
687,
314,
8072,
2126,
805,
334,
4322,
370,
9143,
14,
23824,
4227,
63,
23612,
654,
9,
272,
408,
272,
4975,
855,
9130,
363,
275,
8072,
272,
367,
1921,
315,
7943,
26,
267,
862,
26,
288,
574,
275,
2519,
8,
9130,
12,
1921,
9,
267,
871,
4281,
26,
288,
986,
267,
587,
26,
288,
5371,
8,
5029,
12,
1921,
12,
574,
9,
272,
367,
1921,
315,
4588,
26,
267,
2519,
8,
5029,
12,
1921,
680,
873,
8,
5675,
8,
9130,
12,
1921,
12,
17003,
272,
327,
1432,
314,
4975,
880,
642,
883,
506,
1202,
465,
282,
7531,
4799,
7417,
342,
272,
372,
4975,
199,
199,
318,
14018,
8,
9130,
12,
881,
7943,
275,
16573,
1282,
4227,
63,
23680,
20967,
12,
881,
4588,
275,
16573,
1282,
4227,
63,
23612,
654,
304,
272,
408,
14946,
6434,
370,
4838,
1678,
63,
5029,
342,
370,
282,
4975,
805,
10817,
1803,
282,
7531,
626,
29761,
1678,
63,
5029,
342,
543,
314,
16225,
2126,
805,
465,
314,
4975,
1423,
436,
314,
2368,
370,
14018,
342,
465,
314,
2126,
7971,
2368,
14,
3758,
2368,
787,
465,
367,
1678,
63,
5029,
1252,
2126,
961,
365,
282,
16777,
805,
370,
15037,
18876,
7417,
342,
370,
2126,
1678,
63,
5029,
1252,
272,
408,
272,
372,
7417,
8,
873,
63,
5029,
12,
8072,
29,
9130,
12,
673,
7943,
29,
12941,
12,
4588,
29,
5334,
9,
421,
199,
13289,
199,
5680,
3141,
63,
7128,
1021,
7531,
199,
13289,
199,
199,
318,
3141,
63,
7128,
8,
1886,
304,
272,
408,
2543,
7531,
626,
1794,
478,
315,
4124,
7794,
3102,
624,
272,
3957,
275,
469,
267,
2560,
4116,
3706,
4274,
363,
3308,
7500,
2400,
291,
12,
1163,
26,
440,
334,
277,
665,
1163,
503,
291,
508,
1163,
1826,
673,
25038,
274,
7500,
2400,
291,
12,
1163,
26,
291,
665,
1163,
503,
291,
508,
1163,
395,
673,
25038,
303,
7500,
2400,
291,
12,
1163,
26,
440,
291,
665,
1163,
4360,
267,
2560,
274,
3706,
4274,
363,
303,
7500,
2400,
291,
12,
1163,
26,
440,
291,
2695,
1163,
503,
291,
508,
1163,
395,
673,
25038,
4116,
7500,
2400,
291,
12,
1163,
26,
291,
2695,
1163,
436,
440,
291,
508,
1163,
395,
673,
25038,
3308,
7500,
2400,
291,
12,
1163,
26,
440,
291,
2695,
1163,
4360,
267,
2560,
3308,
3706,
4274,
363,
4116,
7500,
2400,
291,
12,
1163,
26,
440,
334,
277,
690,
1163,
503,
291,
508,
1163,
1826,
673,
25038,
303,
7500,
2400,
291,
12,
1163,
26,
291,
690,
1163,
503,
291,
508,
1163,
395,
673,
25038,
274,
7500,
2400,
291,
12,
1163,
26,
440,
291,
690,
1163,
4360,
267,
2560,
303,
3706,
4274,
363,
274,
7500,
2400,
291,
12,
1163,
26,
334,
1397,
291,
2356,
1163,
9,
503,
291,
508,
1163,
395,
673,
25038,
3308,
7500,
2400,
291,
12,
1163,
26,
291,
2356,
1163,
436,
440,
291,
508,
1163,
395,
673,
25038,
4116,
7500,
2400,
291,
12,
1163,
26,
440,
291,
2356,
1163,
1874,
272,
789,
272,
327,
6668,
922,
13,
4037,
20448,
334,
1397,
5204,
12623,
687,
909,
680,
272,
14361,
275,
359,
411,
367,
1687,
315,
3957,
340,
2519,
8,
1886,
12,
1687,
12,
488,
9,
365,
440,
2519,
8,
785,
12,
1687,
12,
488,
1874,
272,
340,
440,
14361,
26,
267,
746,
1722,
360,
7790,
5627,
737,
5210,
1373,
7794,
3439,
26,
665,
690,
2695,
2356,
358,
272,
1738,
275,
1390,
8,
12065,
9,
755,
327,
16602,
636,
4116,
363,
370,
636,
274,
363,
370,
636,
3308,
363,
370,
636,
303,
363,
272,
367,
1687,
354,
12,
1687,
1532,
315,
3957,
59,
1231,
2189,
267,
340,
1687,
354,
440,
315,
14361,
26,
288,
1687,
1532,
855,
354,
363,
275,
1687,
354,
288,
1687,
1532,
855,
1301,
363,
275,
2519,
8,
442,
12,
1687,
354
] |
[
17869,
14,
647,
446,
23228,
367,
6449,
543,
3423,
436,
4550,
2251,
199,
624,
199,
3,
2018,
859,
4975,
367,
485,
17869,
445,
859,
199,
3,
370,
2040,
15841,
5313,
315,
2018,
370,
506,
3483,
199,
3,
370,
314,
9143,
859,
14,
199,
3,
27694,
701,
653,
2000,
445,
974,
72,
1502,
665,
78,
331,
3561,
1502,
737,
29712,
14,
957,
30,
199,
3,
436,
30703,
2106,
68,
869,
386,
1337,
281,
665,
1548,
737,
4819,
78,
14,
957,
30,
199,
3,
257,
1898,
334,
35,
9,
8315,
13,
6542,
2018,
2290,
2752,
14,
199,
3,
1666,
445,
1350,
1233,
367,
485,
17869,
2837,
15256,
15,
7307,
199,
199,
363,
452,
363,
275,
788,
873,
63,
5029,
297,
283,
13582,
297,
283,
23824,
4227,
63,
23680,
20967,
297,
283,
23824,
4227,
63,
23612,
654,
297,
1779,
283,
2923,
63,
7128,
297,
283,
5730,
63,
475,
63,
498,
297,
283,
25003,
63,
1637,
297,
283,
5270,
297,
283,
6672,
418,
199,
199,
504,
485,
17869,
492,
7417,
12,
7114,
199,
504,
5055,
492,
12863,
199,
893,
26,
272,
687,
485,
2671,
492,
820,
6432,
199,
2590,
26,
272,
1021,
820,
6432,
26,
267,
283,
11324,
295,
18626,
867,
4650,
367,
14723,
1928,
7183,
7,
267,
347,
636,
4200,
721,
277,
304,
986,
267,
347,
636,
2224,
721,
277,
12,
444,
3667,
12,
3178,
3615,
12,
444,
319,
66,
304,
986,
421,
199,
13289,
199,
5680,
1678,
63,
5029,
342,
436,
14018,
342,
7531,
199,
13289,
199,
199,
3,
1678,
63,
5029,
342,
436,
14018,
342,
787,
7249,
370,
1720,
2218,
199,
3,
4975,
3423,
626,
883,
2429,
19995,
1109,
14254,
199,
199,
23824,
4227,
63,
23680,
20967,
275,
25038,
578,
7500,
2560,
354,
7500,
2560,
537,
354,
7500,
2560,
1301,
7500,
2432,
2560,
11270,
13766,
199,
23824,
4227,
63,
23612,
654,
275,
25038,
807,
7500,
9,
199,
318,
1678,
63,
5029,
8,
5029,
12,
673,
8072,
12,
673,
7943,
275,
16573,
1282,
4227,
63,
23680,
20967,
12,
673,
4588,
275,
16573,
1282,
4227,
63,
23612,
654,
304,
272,
408,
4152,
282,
4975,
805,
370,
3648,
2839,
314,
8072,
805,
10817,
4975,
365,
314,
805,
370,
506,
4588,
2126,
8072,
365,
314,
3379,
805,
2126,
7943,
365,
282,
2008,
19720,
314,
3004,
7943,
5370,
2126,
687,
314,
8072,
805,
370,
314,
4975,
805,
334,
4322,
370,
2126,
9143,
14,
23824,
4227,
63,
23680,
20967,
9,
2126,
4588,
365,
282,
2008,
19720,
314,
3004,
402,
314,
4975,
626,
2126,
787,
4588,
543,
314,
5226,
2225,
687,
314,
8072,
2126,
805,
334,
4322,
370,
9143,
14,
23824,
4227,
63,
23612,
654,
9,
272,
408,
272,
4975,
855,
9130,
363,
275,
8072,
272,
367,
1921,
315,
7943,
26,
267,
862,
26,
288,
574,
275,
2519,
8,
9130,
12,
1921,
9,
267,
871,
4281,
26,
288,
986,
267,
587,
26,
288,
5371,
8,
5029,
12,
1921,
12,
574,
9,
272,
367,
1921,
315,
4588,
26,
267,
2519,
8,
5029,
12,
1921,
680,
873,
8,
5675,
8,
9130,
12,
1921,
12,
17003,
272,
327,
1432,
314,
4975,
880,
642,
883,
506,
1202,
465,
282,
7531,
4799,
7417,
342,
272,
372,
4975,
199,
199,
318,
14018,
8,
9130,
12,
881,
7943,
275,
16573,
1282,
4227,
63,
23680,
20967,
12,
881,
4588,
275,
16573,
1282,
4227,
63,
23612,
654,
304,
272,
408,
14946,
6434,
370,
4838,
1678,
63,
5029,
342,
370,
282,
4975,
805,
10817,
1803,
282,
7531,
626,
29761,
1678,
63,
5029,
342,
543,
314,
16225,
2126,
805,
465,
314,
4975,
1423,
436,
314,
2368,
370,
14018,
342,
465,
314,
2126,
7971,
2368,
14,
3758,
2368,
787,
465,
367,
1678,
63,
5029,
1252,
2126,
961,
365,
282,
16777,
805,
370,
15037,
18876,
7417,
342,
370,
2126,
1678,
63,
5029,
1252,
272,
408,
272,
372,
7417,
8,
873,
63,
5029,
12,
8072,
29,
9130,
12,
673,
7943,
29,
12941,
12,
4588,
29,
5334,
9,
421,
199,
13289,
199,
5680,
3141,
63,
7128,
1021,
7531,
199,
13289,
199,
199,
318,
3141,
63,
7128,
8,
1886,
304,
272,
408,
2543,
7531,
626,
1794,
478,
315,
4124,
7794,
3102,
624,
272,
3957,
275,
469,
267,
2560,
4116,
3706,
4274,
363,
3308,
7500,
2400,
291,
12,
1163,
26,
440,
334,
277,
665,
1163,
503,
291,
508,
1163,
1826,
673,
25038,
274,
7500,
2400,
291,
12,
1163,
26,
291,
665,
1163,
503,
291,
508,
1163,
395,
673,
25038,
303,
7500,
2400,
291,
12,
1163,
26,
440,
291,
665,
1163,
4360,
267,
2560,
274,
3706,
4274,
363,
303,
7500,
2400,
291,
12,
1163,
26,
440,
291,
2695,
1163,
503,
291,
508,
1163,
395,
673,
25038,
4116,
7500,
2400,
291,
12,
1163,
26,
291,
2695,
1163,
436,
440,
291,
508,
1163,
395,
673,
25038,
3308,
7500,
2400,
291,
12,
1163,
26,
440,
291,
2695,
1163,
4360,
267,
2560,
3308,
3706,
4274,
363,
4116,
7500,
2400,
291,
12,
1163,
26,
440,
334,
277,
690,
1163,
503,
291,
508,
1163,
1826,
673,
25038,
303,
7500,
2400,
291,
12,
1163,
26,
291,
690,
1163,
503,
291,
508,
1163,
395,
673,
25038,
274,
7500,
2400,
291,
12,
1163,
26,
440,
291,
690,
1163,
4360,
267,
2560,
303,
3706,
4274,
363,
274,
7500,
2400,
291,
12,
1163,
26,
334,
1397,
291,
2356,
1163,
9,
503,
291,
508,
1163,
395,
673,
25038,
3308,
7500,
2400,
291,
12,
1163,
26,
291,
2356,
1163,
436,
440,
291,
508,
1163,
395,
673,
25038,
4116,
7500,
2400,
291,
12,
1163,
26,
440,
291,
2356,
1163,
1874,
272,
789,
272,
327,
6668,
922,
13,
4037,
20448,
334,
1397,
5204,
12623,
687,
909,
680,
272,
14361,
275,
359,
411,
367,
1687,
315,
3957,
340,
2519,
8,
1886,
12,
1687,
12,
488,
9,
365,
440,
2519,
8,
785,
12,
1687,
12,
488,
1874,
272,
340,
440,
14361,
26,
267,
746,
1722,
360,
7790,
5627,
737,
5210,
1373,
7794,
3439,
26,
665,
690,
2695,
2356,
358,
272,
1738,
275,
1390,
8,
12065,
9,
755,
327,
16602,
636,
4116,
363,
370,
636,
274,
363,
370,
636,
3308,
363,
370,
636,
303,
363,
272,
367,
1687,
354,
12,
1687,
1532,
315,
3957,
59,
1231,
2189,
267,
340,
1687,
354,
440,
315,
14361,
26,
288,
1687,
1532,
855,
354,
363,
275,
1687,
354,
288,
1687,
1532,
855,
1301,
363,
275,
2519,
8,
442,
12,
1687,
354,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
edx/edx-platform
|
openedx/core/djangoapps/user_authn/signals.py
|
3
|
1507
|
"""
Signals for user_authn
"""
from typing import Any, Dict, Optional, Tuple
from common.djangoapps.student.models import UserProfile
from common.djangoapps.track import segment
def user_fields_changed(
user=None,
table=None,
changed_fields: Optional[Dict[str, Tuple[Any, Any]]] = None,
**_kwargs,
):
"""
Update a collection of user profile fields in segment when they change in the database
Args:
user: The user object for the user being changed
table: The name of the table being updated
changed_fields: A mapping from changed field name to old and new values.
"""
fields = {field: new_value for (field, (old_value, new_value)) in changed_fields.items()}
# This mirrors the logic in ./views/register.py:_track_user_registration
if table == 'auth_userprofile':
if 'gender' in fields and fields['gender']:
fields['gender'] = dict(UserProfile.GENDER_CHOICES)[fields['gender']]
if 'country' in fields:
fields['country'] = str(fields['country'])
if 'level_of_education' in fields and fields['level_of_education']:
fields['education'] = dict(UserProfile.LEVEL_OF_EDUCATION_CHOICES)[fields['level_of_education']]
if 'year_of_birth' in fields:
fields['yearOfBirth'] = fields.pop('year_of_birth')
if 'mailing_address' in fields:
fields['address'] = fields.pop('mailing_address')
segment.identify(
user.id,
fields
)
|
agpl-3.0
|
[
624,
199,
28536,
367,
922,
63,
1178,
78,
199,
624,
199,
199,
504,
14090,
492,
6184,
12,
7448,
12,
4879,
12,
11634,
199,
199,
504,
2863,
14,
16432,
14,
5500,
14,
992,
492,
19037,
199,
504,
2863,
14,
16432,
14,
3885,
492,
8135,
421,
199,
318,
922,
63,
955,
63,
2489,
8,
272,
922,
29,
403,
12,
272,
1817,
29,
403,
12,
272,
2896,
63,
955,
26,
4879,
59,
2141,
59,
495,
12,
11634,
59,
9874,
12,
6184,
20737,
275,
488,
12,
272,
29666,
958,
12,
199,
304,
272,
408,
272,
6162,
282,
3245,
402,
922,
4690,
1504,
315,
8135,
1380,
2985,
1570,
315,
314,
3050,
339,
3033,
26,
267,
922,
26,
710,
922,
909,
367,
314,
922,
3769,
2896,
267,
1817,
26,
710,
536,
402,
314,
1817,
3769,
4588,
267,
2896,
63,
955,
26,
437,
4412,
687,
2896,
901,
536,
370,
2269,
436,
892,
1338,
14,
272,
408,
339,
1504,
275,
469,
698,
26,
892,
63,
585,
367,
334,
698,
12,
334,
1753,
63,
585,
12,
892,
63,
585,
430,
315,
2896,
63,
955,
14,
1744,
12737,
272,
327,
961,
15216,
83,
314,
9661,
315,
16605,
4196,
15,
2683,
14,
647,
22003,
3885,
63,
751,
63,
8054,
272,
340,
1817,
508,
283,
1178,
63,
25784,
356,
267,
340,
283,
15791,
7,
315,
1504,
436,
1504,
459,
15791,
2565,
288,
1504,
459,
15791,
418,
275,
1211,
8,
23544,
14,
39,
21951,
63,
16236,
2788,
955,
459,
15791,
6538,
267,
340,
283,
6063,
7,
315,
1504,
26,
288,
1504,
459,
6063,
418,
275,
620,
8,
955,
459,
6063,
1105,
267,
340,
283,
1896,
63,
1618,
63,
379,
30500,
7,
315,
1504,
436,
1504,
459,
1896,
63,
1618,
63,
379,
30500,
2565,
288,
1504,
459,
379,
30500,
418,
275,
1211,
8,
23544,
14,
11817,
63,
3359,
63,
1149,
13371,
2594,
63,
16236,
2788,
955,
459,
1896,
63,
1618,
63,
379,
30500,
6538,
267,
340,
283,
3403,
63,
1618,
63,
10907,
7,
315,
1504,
26,
288,
1504,
459,
3403,
3466,
29229,
418,
275,
1504,
14,
1935,
360,
3403,
63,
1618,
63,
10907,
358,
267,
340,
283,
22989,
63,
1562,
7,
315,
1504,
26,
288,
1504,
459,
1562,
418,
275,
1504,
14,
1935,
360,
22989,
63,
1562,
358,
339,
8135,
14,
22232,
8,
267,
922,
14,
344,
12,
267,
1504,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
28536,
367,
922,
63,
1178,
78,
199,
624,
199,
199,
504,
14090,
492,
6184,
12,
7448,
12,
4879,
12,
11634,
199,
199,
504,
2863,
14,
16432,
14,
5500,
14,
992,
492,
19037,
199,
504,
2863,
14,
16432,
14,
3885,
492,
8135,
421,
199,
318,
922,
63,
955,
63,
2489,
8,
272,
922,
29,
403,
12,
272,
1817,
29,
403,
12,
272,
2896,
63,
955,
26,
4879,
59,
2141,
59,
495,
12,
11634,
59,
9874,
12,
6184,
20737,
275,
488,
12,
272,
29666,
958,
12,
199,
304,
272,
408,
272,
6162,
282,
3245,
402,
922,
4690,
1504,
315,
8135,
1380,
2985,
1570,
315,
314,
3050,
339,
3033,
26,
267,
922,
26,
710,
922,
909,
367,
314,
922,
3769,
2896,
267,
1817,
26,
710,
536,
402,
314,
1817,
3769,
4588,
267,
2896,
63,
955,
26,
437,
4412,
687,
2896,
901,
536,
370,
2269,
436,
892,
1338,
14,
272,
408,
339,
1504,
275,
469,
698,
26,
892,
63,
585,
367,
334,
698,
12,
334,
1753,
63,
585,
12,
892,
63,
585,
430,
315,
2896,
63,
955,
14,
1744,
12737,
272,
327,
961,
15216,
83,
314,
9661,
315,
16605,
4196,
15,
2683,
14,
647,
22003,
3885,
63,
751,
63,
8054,
272,
340,
1817,
508,
283,
1178,
63,
25784,
356,
267,
340,
283,
15791,
7,
315,
1504,
436,
1504,
459,
15791,
2565,
288,
1504,
459,
15791,
418,
275,
1211,
8,
23544,
14,
39,
21951,
63,
16236,
2788,
955,
459,
15791,
6538,
267,
340,
283,
6063,
7,
315,
1504,
26,
288,
1504,
459,
6063,
418,
275,
620,
8,
955,
459,
6063,
1105,
267,
340,
283,
1896,
63,
1618,
63,
379,
30500,
7,
315,
1504,
436,
1504,
459,
1896,
63,
1618,
63,
379,
30500,
2565,
288,
1504,
459,
379,
30500,
418,
275,
1211,
8,
23544,
14,
11817,
63,
3359,
63,
1149,
13371,
2594,
63,
16236,
2788,
955,
459,
1896,
63,
1618,
63,
379,
30500,
6538,
267,
340,
283,
3403,
63,
1618,
63,
10907,
7,
315,
1504,
26,
288,
1504,
459,
3403,
3466,
29229,
418,
275,
1504,
14,
1935,
360,
3403,
63,
1618,
63,
10907,
358,
267,
340,
283,
22989,
63,
1562,
7,
315,
1504,
26,
288,
1504,
459,
1562,
418,
275,
1504,
14,
1935,
360,
22989,
63,
1562,
358,
339,
8135,
14,
22232,
8,
267,
922,
14,
344,
12,
267,
1504,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
solin319/incubator-mxnet
|
example/speech_recognition/stt_metric.py
|
43
|
8010
|
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import mxnet as mx
import numpy as np
from label_util import LabelUtil
from log_util import LogUtil
def check_label_shapes(labels, preds, shape=0):
"""Check to see if the two arrays are the same size."""
if shape == 0:
label_shape, pred_shape = len(labels), len(preds)
else:
label_shape, pred_shape = labels.shape, preds.shape
if label_shape != pred_shape:
raise ValueError("Shape of labels {} does not match shape of "
"predictions {}".format(label_shape, pred_shape))
class STTMetric(mx.metric.EvalMetric):
def __init__(self, batch_size, num_gpu, is_epoch_end=False, is_logging=True):
super(STTMetric, self).__init__('STTMetric')
self.batch_size = batch_size
self.num_gpu = num_gpu
self.total_n_label = 0
self.total_l_dist = 0
self.is_epoch_end = is_epoch_end
self.total_ctc_loss = 0.
self.batch_loss = 0.
self.is_logging = is_logging
def update(self, labels, preds):
check_label_shapes(labels, preds)
if self.is_logging:
log = LogUtil().getlogger()
labelUtil = LabelUtil.getInstance()
self.batch_loss = 0.
for label, pred in zip(labels, preds):
label = label.asnumpy()
pred = pred.asnumpy()
seq_length = len(pred) / int(int(self.batch_size) / int(self.num_gpu))
for i in range(int(int(self.batch_size) / int(self.num_gpu))):
l = remove_blank(label[i])
p = []
for k in range(int(seq_length)):
p.append(np.argmax(pred[k * int(int(self.batch_size) / int(self.num_gpu)) + i]))
p = pred_best(p)
l_distance = levenshtein_distance(l, p)
self.total_n_label += len(l)
self.total_l_dist += l_distance
this_cer = float(l_distance) / float(len(l))
if self.is_logging:
log.info("label: %s " % (labelUtil.convert_num_to_word(l)))
log.info("pred : %s , cer: %f (distance: %d/ label length: %d)" % (
labelUtil.convert_num_to_word(p), this_cer, l_distance, len(l)))
self.num_inst += 1
self.sum_metric += this_cer
if self.is_epoch_end:
loss = ctc_loss(l, pred, i, int(seq_length), int(self.batch_size), int(self.num_gpu))
self.batch_loss += loss
if self.is_logging:
log.info("loss: %f " % loss)
self.total_ctc_loss += self.batch_loss
def get_batch_loss(self):
return self.batch_loss
def get_name_value(self):
total_cer = float(self.total_l_dist) / float(self.total_n_label)
return total_cer, self.total_n_label, self.total_l_dist, self.total_ctc_loss
def reset(self):
self.total_n_label = 0
self.total_l_dist = 0
self.num_inst = 0
self.sum_metric = 0.0
self.total_ctc_loss = 0.0
def pred_best(p):
ret = []
p1 = [0] + p
for i in range(len(p)):
c1 = p1[i]
c2 = p1[i + 1]
if c2 == 0 or c2 == c1:
continue
ret.append(c2)
return ret
def remove_blank(l):
ret = []
for i in range(l.size):
if l[i] == 0:
break
ret.append(l[i])
return ret
def remove_space(l):
labelUtil = LabelUtil.getInstance()
ret = []
for i in range(len(l)):
if l[i] != labelUtil.get_space_index():
ret.append(l[i])
return ret
def ctc_loss(label, prob, remainder, seq_length, batch_size, num_gpu=1, big_num=1e10):
label_ = [0, 0]
prob[prob < 1 / big_num] = 1 / big_num
log_prob = np.log(prob)
l = len(label)
for i in range(l):
label_.append(int(label[i]))
label_.append(0)
l_ = 2 * l + 1
a = np.full((seq_length, l_ + 1), -big_num)
a[0][1] = log_prob[remainder][0]
a[0][2] = log_prob[remainder][label_[2]]
for i in range(1, seq_length):
row = i * int(batch_size / num_gpu) + remainder
a[i][1] = a[i - 1][1] + log_prob[row][0]
a[i][2] = np.logaddexp(a[i - 1][2], a[i - 1][1]) + log_prob[row][label_[2]]
for j in range(3, l_ + 1):
a[i][j] = np.logaddexp(a[i - 1][j], a[i - 1][j - 1])
if label_[j] != 0 and label_[j] != label_[j - 2]:
a[i][j] = np.logaddexp(a[i][j], a[i - 1][j - 2])
a[i][j] += log_prob[row][label_[j]]
return -np.logaddexp(a[seq_length - 1][l_], a[seq_length - 1][l_ - 1])
# label is done with remove_blank
# pred is got from pred_best
def levenshtein_distance(label, pred):
n_label = len(label) + 1
n_pred = len(pred) + 1
if (label == pred):
return 0
if (len(label) == 0):
return len(pred)
if (len(pred) == 0):
return len(label)
v0 = [i for i in range(n_label)]
v1 = [0 for i in range(n_label)]
for i in range(len(pred)):
v1[0] = i + 1
for j in range(len(label)):
cost = 0 if label[j] == pred[i] else 1
v1[j + 1] = min(v1[j] + 1, v0[j + 1] + 1, v0[j] + cost)
for j in range(n_label):
v0[j] = v1[j]
return v1[len(label)]
def char_match_1way(char_label, char_pred, criteria, n_whole_label):
n_label = len(char_label)
n_pred = len(char_pred)
pred_pos = 0
accuracy = 0.
next_accu = 0.
n_matched = 0.
next_n_matched = 0.
for i_index in range(n_label):
tail_label = n_label - 1 - i_index
c_label = char_label[i_index]
for j_index in range(pred_pos, n_pred):
tail_pred = n_pred - 1 - j_index
c_pred = char_pred[j_index]
if tail_label < tail_pred * criteria or tail_pred < tail_label * criteria:
break
if c_label == c_pred:
n_matched += 1.0
pred_pos = j_index + 1
break
accuracy = n_matched / n_whole_label
if n_label > 0.7 * n_whole_label:
next_label = char_label[1:]
next_accu, next_n_matched = char_match_1way(next_label, char_pred, criteria, n_whole_label)
if next_accu > accuracy:
accuracy = next_accu
n_matched = next_n_matched
return accuracy, n_matched
def char_match_2way(label, pred):
criterias = [0.98, 0.96, 0.93, 0.9, 0.85, 0.8, 0.7]
r_pred = pred[::-1]
r_label = label[::-1]
n_whole_label = len(remove_space(label))
val1_max = 0.
val2_max = 0.
val1_max_matched = 0.
val2_max_matched = 0.
for criteria in criterias:
val1, val1_matched = char_match_1way(label, pred, criteria, n_whole_label)
val2, val2_matched = char_match_1way(r_label, r_pred, criteria, n_whole_label)
if val1 > val1_max:
val1_max = val1
val1_max_matched = val1_matched
if val2 > val2_max:
val2_max = val2
val2_max_matched = val2_matched
val = val1_max if val1_max > val2_max else val2_max
val_matched = val1_max_matched if val1_max > val2_max else val2_max_matched
return val, val_matched, n_whole_label
|
apache-2.0
|
[
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
646,
8728,
846,
465,
8728,
199,
646,
2680,
465,
980,
199,
199,
504,
1768,
63,
1974,
492,
10354,
9562,
199,
504,
943,
63,
1974,
492,
5297,
9562,
421,
199,
318,
1104,
63,
1302,
63,
9069,
8,
3512,
12,
24960,
12,
2215,
29,
16,
304,
272,
408,
1799,
370,
1937,
340,
314,
2877,
6572,
787,
314,
2011,
1568,
1041,
339,
340,
2215,
508,
378,
26,
267,
1768,
63,
1392,
12,
8869,
63,
1392,
275,
822,
8,
3512,
395,
822,
8,
28296,
9,
272,
587,
26,
267,
1768,
63,
1392,
12,
8869,
63,
1392,
275,
3628,
14,
1392,
12,
24960,
14,
1392,
339,
340,
1768,
63,
1392,
1137,
8869,
63,
1392,
26,
267,
746,
1722,
480,
7238,
402,
3628,
1052,
1630,
440,
1336,
2215,
402,
298,
586,
298,
9869,
8352,
908,
8,
1302,
63,
1392,
12,
8869,
63,
1392,
430,
421,
199,
533,
428,
1481,
11119,
8,
9457,
14,
5165,
14,
10006,
11119,
304,
272,
347,
636,
826,
721,
277,
12,
3522,
63,
890,
12,
1967,
63,
6477,
12,
365,
63,
7367,
63,
500,
29,
797,
12,
365,
63,
4806,
29,
549,
304,
267,
1613,
8,
840,
52,
11119,
12,
291,
2843,
826,
19734,
840,
52,
11119,
358,
398,
291,
14,
2912,
63,
890,
275,
3522,
63,
890,
267,
291,
14,
1507,
63,
6477,
275,
1967,
63,
6477,
267,
291,
14,
2923,
63,
78,
63,
1302,
275,
378,
267,
291,
14,
2923,
63,
76,
63,
2686,
275,
378,
267,
291,
14,
374,
63,
7367,
63,
500,
275,
365,
63,
7367,
63,
500,
267,
291,
14,
2923,
63,
319,
67,
63,
4358,
275,
378,
14,
267,
291,
14,
2912,
63,
4358,
275,
378,
14,
267,
291,
14,
374,
63,
4806,
275,
365,
63,
4806,
272,
347,
1678,
8,
277,
12,
3628,
12,
24960,
304,
267,
1104,
63,
1302,
63,
9069,
8,
3512,
12,
24960,
9,
267,
340,
291,
14,
374,
63,
4806,
26,
288,
943,
275,
5297,
9562,
1252,
362,
2921,
342,
288,
1768,
9562,
275,
10354,
9562,
14,
29964,
342,
267,
291,
14,
2912,
63,
4358,
275,
378,
14,
398,
367,
1768,
12,
8869,
315,
3482,
8,
3512,
12,
24960,
304,
288,
1768,
275,
1768,
14,
32204,
342,
288,
8869,
275,
8869,
14,
32204,
342,
953,
5412,
63,
1267,
275,
822,
8,
5991,
9,
1182,
1109,
8,
442,
8,
277,
14,
2912,
63,
890,
9,
1182,
1109,
8,
277,
14,
1507,
63,
6477,
430,
953,
367,
284,
315,
1425,
8,
442,
8,
442,
8,
277,
14,
2912,
63,
890,
9,
1182,
1109,
8,
277,
14,
1507,
63,
6477,
15206,
355,
634,
275,
2813,
63,
2500,
8,
1302,
59,
73,
566,
355,
299,
275,
942,
355,
367,
1022,
315,
1425,
8,
442,
8,
3610,
63,
1267,
2298,
490,
299,
14,
740,
8,
1590,
14,
16383,
8,
5991,
59,
75,
627,
1109,
8,
442,
8,
277,
14,
2912,
63,
890,
9,
1182,
1109,
8,
277,
14,
1507,
63,
6477,
430,
435,
284,
2459,
355,
299,
275,
8869,
63,
7010,
8,
80,
9,
2234,
634,
63,
5590,
275,
1026,
1856,
609,
15859,
63,
5590,
8,
76,
12,
299,
9,
355,
291,
14,
2923,
63,
78,
63,
1302,
847,
822,
8,
76,
9,
355,
291,
14,
2923,
63,
76,
63,
2686,
847,
634,
63,
5590,
355,
642,
63,
2247,
275,
2069,
8,
76,
63,
5590,
9,
1182,
2069,
8,
552,
8,
76,
430,
355,
340,
291,
14,
374,
63,
4806,
26,
490,
943,
14,
815,
480,
1302,
26,
450,
83,
298,
450,
334,
1302,
9562,
14,
3916,
63,
1507,
63,
475,
63,
1027,
8,
76,
1724,
490,
943,
14,
815,
480,
5991,
520,
450,
83,
2360,
3361,
26,
450,
70,
334,
5590,
26,
450,
68,
15,
1768,
2582,
26,
450,
68,
2924,
450,
334,
717,
1768,
9562,
14,
3916,
63,
1507,
63,
475,
63,
1027,
8,
80,
395,
642,
63,
2247,
12,
634,
63,
5590,
12,
822,
8,
76,
1724,
355,
291,
14,
1507,
63,
3615,
847,
413,
355,
291,
14,
1838,
63,
5165,
847,
642,
63,
2247,
355,
340,
291,
14,
374,
63,
7367,
63,
500,
26,
490,
5621,
275,
286,
3641,
63,
4358,
8,
76,
12,
8869,
12,
284,
12,
1109,
8,
3610,
63,
1267,
395,
1109,
8,
277,
14,
2912,
63,
890,
395,
1109,
8,
277,
14,
1507,
63,
6477,
430,
490,
291,
14,
2912,
63,
4358,
847,
5621,
490,
340,
291,
14,
374,
63,
4806,
26,
717,
943,
14,
815,
480,
4358,
26,
450,
70,
298,
450,
5621,
9,
267,
291,
14,
2923,
63,
319,
67,
63,
4358,
847,
291,
14,
2912,
63,
4358,
272,
347,
664,
63,
2912,
63,
4358,
8,
277,
304,
267,
372,
291,
14,
2912,
63,
4358,
272,
347,
664,
63,
354,
63,
585,
8,
277,
304,
267,
3141,
63,
2247,
275,
2069,
8,
277,
14,
2923,
63,
76,
63,
2686,
9,
1182,
2069,
8,
277,
14,
2923,
63,
78,
63,
1302,
9,
398,
372,
3141,
63,
2247,
12,
291,
14,
2923,
63,
78,
63,
1302,
12,
291,
14,
2923,
63,
76,
63,
2686,
12,
291,
14,
2923,
63,
319,
67,
63,
4358,
339,
347,
5305,
8,
277,
304,
267,
291,
14,
2923,
63,
78,
63,
1302,
275,
378,
267
] |
[
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
199,
3,
503,
1655,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
199,
3,
1854,
543,
642,
1736,
367,
4722,
2556,
199,
3,
12602,
4248,
12715,
14,
221,
710,
14857,
12378,
642,
570,
199,
3,
370,
1265,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
199,
3,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
199,
3,
543,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
257,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
199,
3,
2032,
1854,
1334,
314,
844,
365,
1854,
641,
376,
199,
3,
298,
1179,
2281,
2,
4207,
12,
2428,
2990,
1549,
4217,
1634,
1821,
199,
3,
3826,
12,
1902,
4056,
503,
2478,
14,
221,
1666,
314,
844,
367,
314,
199,
3,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
646,
8728,
846,
465,
8728,
199,
646,
2680,
465,
980,
199,
199,
504,
1768,
63,
1974,
492,
10354,
9562,
199,
504,
943,
63,
1974,
492,
5297,
9562,
421,
199,
318,
1104,
63,
1302,
63,
9069,
8,
3512,
12,
24960,
12,
2215,
29,
16,
304,
272,
408,
1799,
370,
1937,
340,
314,
2877,
6572,
787,
314,
2011,
1568,
1041,
339,
340,
2215,
508,
378,
26,
267,
1768,
63,
1392,
12,
8869,
63,
1392,
275,
822,
8,
3512,
395,
822,
8,
28296,
9,
272,
587,
26,
267,
1768,
63,
1392,
12,
8869,
63,
1392,
275,
3628,
14,
1392,
12,
24960,
14,
1392,
339,
340,
1768,
63,
1392,
1137,
8869,
63,
1392,
26,
267,
746,
1722,
480,
7238,
402,
3628,
1052,
1630,
440,
1336,
2215,
402,
298,
586,
298,
9869,
8352,
908,
8,
1302,
63,
1392,
12,
8869,
63,
1392,
430,
421,
199,
533,
428,
1481,
11119,
8,
9457,
14,
5165,
14,
10006,
11119,
304,
272,
347,
636,
826,
721,
277,
12,
3522,
63,
890,
12,
1967,
63,
6477,
12,
365,
63,
7367,
63,
500,
29,
797,
12,
365,
63,
4806,
29,
549,
304,
267,
1613,
8,
840,
52,
11119,
12,
291,
2843,
826,
19734,
840,
52,
11119,
358,
398,
291,
14,
2912,
63,
890,
275,
3522,
63,
890,
267,
291,
14,
1507,
63,
6477,
275,
1967,
63,
6477,
267,
291,
14,
2923,
63,
78,
63,
1302,
275,
378,
267,
291,
14,
2923,
63,
76,
63,
2686,
275,
378,
267,
291,
14,
374,
63,
7367,
63,
500,
275,
365,
63,
7367,
63,
500,
267,
291,
14,
2923,
63,
319,
67,
63,
4358,
275,
378,
14,
267,
291,
14,
2912,
63,
4358,
275,
378,
14,
267,
291,
14,
374,
63,
4806,
275,
365,
63,
4806,
272,
347,
1678,
8,
277,
12,
3628,
12,
24960,
304,
267,
1104,
63,
1302,
63,
9069,
8,
3512,
12,
24960,
9,
267,
340,
291,
14,
374,
63,
4806,
26,
288,
943,
275,
5297,
9562,
1252,
362,
2921,
342,
288,
1768,
9562,
275,
10354,
9562,
14,
29964,
342,
267,
291,
14,
2912,
63,
4358,
275,
378,
14,
398,
367,
1768,
12,
8869,
315,
3482,
8,
3512,
12,
24960,
304,
288,
1768,
275,
1768,
14,
32204,
342,
288,
8869,
275,
8869,
14,
32204,
342,
953,
5412,
63,
1267,
275,
822,
8,
5991,
9,
1182,
1109,
8,
442,
8,
277,
14,
2912,
63,
890,
9,
1182,
1109,
8,
277,
14,
1507,
63,
6477,
430,
953,
367,
284,
315,
1425,
8,
442,
8,
442,
8,
277,
14,
2912,
63,
890,
9,
1182,
1109,
8,
277,
14,
1507,
63,
6477,
15206,
355,
634,
275,
2813,
63,
2500,
8,
1302,
59,
73,
566,
355,
299,
275,
942,
355,
367,
1022,
315,
1425,
8,
442,
8,
3610,
63,
1267,
2298,
490,
299,
14,
740,
8,
1590,
14,
16383,
8,
5991,
59,
75,
627,
1109,
8,
442,
8,
277,
14,
2912,
63,
890,
9,
1182,
1109,
8,
277,
14,
1507,
63,
6477,
430,
435,
284,
2459,
355,
299,
275,
8869,
63,
7010,
8,
80,
9,
2234,
634,
63,
5590,
275,
1026,
1856,
609,
15859,
63,
5590,
8,
76,
12,
299,
9,
355,
291,
14,
2923,
63,
78,
63,
1302,
847,
822,
8,
76,
9,
355,
291,
14,
2923,
63,
76,
63,
2686,
847,
634,
63,
5590,
355,
642,
63,
2247,
275,
2069,
8,
76,
63,
5590,
9,
1182,
2069,
8,
552,
8,
76,
430,
355,
340,
291,
14,
374,
63,
4806,
26,
490,
943,
14,
815,
480,
1302,
26,
450,
83,
298,
450,
334,
1302,
9562,
14,
3916,
63,
1507,
63,
475,
63,
1027,
8,
76,
1724,
490,
943,
14,
815,
480,
5991,
520,
450,
83,
2360,
3361,
26,
450,
70,
334,
5590,
26,
450,
68,
15,
1768,
2582,
26,
450,
68,
2924,
450,
334,
717,
1768,
9562,
14,
3916,
63,
1507,
63,
475,
63,
1027,
8,
80,
395,
642,
63,
2247,
12,
634,
63,
5590,
12,
822,
8,
76,
1724,
355,
291,
14,
1507,
63,
3615,
847,
413,
355,
291,
14,
1838,
63,
5165,
847,
642,
63,
2247,
355,
340,
291,
14,
374,
63,
7367,
63,
500,
26,
490,
5621,
275,
286,
3641,
63,
4358,
8,
76,
12,
8869,
12,
284,
12,
1109,
8,
3610,
63,
1267,
395,
1109,
8,
277,
14,
2912,
63,
890,
395,
1109,
8,
277,
14,
1507,
63,
6477,
430,
490,
291,
14,
2912,
63,
4358,
847,
5621,
490,
340,
291,
14,
374,
63,
4806,
26,
717,
943,
14,
815,
480,
4358,
26,
450,
70,
298,
450,
5621,
9,
267,
291,
14,
2923,
63,
319,
67,
63,
4358,
847,
291,
14,
2912,
63,
4358,
272,
347,
664,
63,
2912,
63,
4358,
8,
277,
304,
267,
372,
291,
14,
2912,
63,
4358,
272,
347,
664,
63,
354,
63,
585,
8,
277,
304,
267,
3141,
63,
2247,
275,
2069,
8,
277,
14,
2923,
63,
76,
63,
2686,
9,
1182,
2069,
8,
277,
14,
2923,
63,
78,
63,
1302,
9,
398,
372,
3141,
63,
2247,
12,
291,
14,
2923,
63,
78,
63,
1302,
12,
291,
14,
2923,
63,
76,
63,
2686,
12,
291,
14,
2923,
63,
319,
67,
63,
4358,
339,
347,
5305,
8,
277,
304,
267,
291,
14,
2923,
63,
78,
63,
1302,
275,
378,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
plumgrid/plumgrid-nova
|
nova/tests/cells/fakes.py
|
45
|
7018
|
# Copyright (c) 2012 Rackspace Hosting
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Fakes For Cells tests.
"""
from oslo.config import cfg
from nova.cells import driver
from nova.cells import manager as cells_manager
from nova.cells import state as cells_state
from nova.cells import utils as cells_utils
import nova.db
from nova.db import base
from nova import exception
CONF = cfg.CONF
CONF.import_opt('name', 'nova.cells.opts', group='cells')
# Fake Cell Hierarchy
FAKE_TOP_LEVEL_CELL_NAME = 'api-cell'
FAKE_CELL_LAYOUT = [{'child-cell1': []},
{'child-cell2': [{'grandchild-cell1': []}]},
{'child-cell3': [{'grandchild-cell2': []},
{'grandchild-cell3': []}]},
{'child-cell4': []}]
# build_cell_stub_infos() below will take the above layout and create
# a fake view of the DB from the perspective of each of the cells.
# For each cell, a CellStubInfo will be created with this info.
CELL_NAME_TO_STUB_INFO = {}
class FakeDBApi(object):
"""Cells uses a different DB in each cell. This means in order to
stub out things differently per cell, I need to create a fake DBApi
object that is instantiated by each fake cell.
"""
def __init__(self, cell_db_entries):
self.cell_db_entries = cell_db_entries
def __getattr__(self, key):
return getattr(nova.db, key)
def cell_get_all(self, ctxt):
return self.cell_db_entries
def compute_node_get_all(self, ctxt):
return []
def instance_get_all_by_filters(self, ctxt, *args, **kwargs):
return []
def instance_get_by_uuid(self, ctxt, instance_uuid):
raise exception.InstanceNotFound(instance_id=instance_uuid)
class FakeCellsDriver(driver.BaseCellsDriver):
pass
class FakeCellState(cells_state.CellState):
def send_message(self, message):
message_runner = get_message_runner(self.name)
orig_ctxt = message.ctxt
json_message = message.to_json()
message = message_runner.message_from_json(json_message)
# Restore this so we can use mox and verify same context
message.ctxt = orig_ctxt
message.process()
class FakeCellStateManager(cells_state.CellStateManagerDB):
def __init__(self, *args, **kwargs):
super(FakeCellStateManager, self).__init__(*args,
cell_state_cls=FakeCellState, **kwargs)
class FakeCellsManager(cells_manager.CellsManager):
def __init__(self, *args, **kwargs):
super(FakeCellsManager, self).__init__(*args,
cell_state_manager=FakeCellStateManager,
**kwargs)
class CellStubInfo(object):
def __init__(self, test_case, cell_name, db_entries):
self.test_case = test_case
self.cell_name = cell_name
self.db_entries = db_entries
def fake_base_init(_self, *args, **kwargs):
_self.db = FakeDBApi(db_entries)
test_case.stubs.Set(base.Base, '__init__', fake_base_init)
self.cells_manager = FakeCellsManager()
# Fix the cell name, as it normally uses CONF.cells.name
msg_runner = self.cells_manager.msg_runner
msg_runner.our_name = self.cell_name
self.cells_manager.state_manager.my_cell_state.name = self.cell_name
def _build_cell_transport_url(cur_db_id):
username = 'username%s' % cur_db_id
password = 'password%s' % cur_db_id
hostname = 'rpc_host%s' % cur_db_id
port = 3090 + cur_db_id
virtual_host = 'rpc_vhost%s' % cur_db_id
return 'rabbit://%s:%s@%s:%s/%s' % (username, password, hostname, port,
virtual_host)
def _build_cell_stub_info(test_case, our_name, parent_path, children):
cell_db_entries = []
cur_db_id = 1
sep_char = cells_utils.PATH_CELL_SEP
if parent_path:
cell_db_entries.append(
dict(id=cur_db_id,
name=parent_path.split(sep_char)[-1],
is_parent=True,
transport_url=_build_cell_transport_url(cur_db_id)))
cur_db_id += 1
our_path = parent_path + sep_char + our_name
else:
our_path = our_name
for child in children:
for child_name, grandchildren in child.items():
_build_cell_stub_info(test_case, child_name, our_path,
grandchildren)
cell_entry = dict(id=cur_db_id,
name=child_name,
transport_url=_build_cell_transport_url(
cur_db_id),
is_parent=False)
cell_db_entries.append(cell_entry)
cur_db_id += 1
stub_info = CellStubInfo(test_case, our_name, cell_db_entries)
CELL_NAME_TO_STUB_INFO[our_name] = stub_info
def _build_cell_stub_infos(test_case):
_build_cell_stub_info(test_case, FAKE_TOP_LEVEL_CELL_NAME, '',
FAKE_CELL_LAYOUT)
def init(test_case):
global CELL_NAME_TO_STUB_INFO
test_case.flags(driver='nova.tests.cells.fakes.FakeCellsDriver',
group='cells')
CELL_NAME_TO_STUB_INFO = {}
_build_cell_stub_infos(test_case)
def _get_cell_stub_info(cell_name):
return CELL_NAME_TO_STUB_INFO[cell_name]
def get_state_manager(cell_name):
return _get_cell_stub_info(cell_name).cells_manager.state_manager
def get_cell_state(cur_cell_name, tgt_cell_name):
state_manager = get_state_manager(cur_cell_name)
cell = state_manager.child_cells.get(tgt_cell_name)
if cell is None:
cell = state_manager.parent_cells.get(tgt_cell_name)
return cell
def get_cells_manager(cell_name):
return _get_cell_stub_info(cell_name).cells_manager
def get_message_runner(cell_name):
return _get_cell_stub_info(cell_name).cells_manager.msg_runner
def stub_tgt_method(test_case, cell_name, method_name, method):
msg_runner = get_message_runner(cell_name)
tgt_msg_methods = msg_runner.methods_by_type['targeted']
setattr(tgt_msg_methods, method_name, method)
def stub_bcast_method(test_case, cell_name, method_name, method):
msg_runner = get_message_runner(cell_name)
tgt_msg_methods = msg_runner.methods_by_type['broadcast']
setattr(tgt_msg_methods, method_name, method)
def stub_bcast_methods(test_case, method_name, method):
for cell_name in CELL_NAME_TO_STUB_INFO.keys():
stub_bcast_method(test_case, cell_name, method_name, method)
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6029,
32679,
10891,
316,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
624,
199,
38,
4364,
2104,
445,
6840,
2295,
14,
199,
624,
199,
199,
504,
11258,
14,
888,
492,
4810,
199,
199,
504,
5913,
14,
9041,
492,
5253,
199,
504,
5913,
14,
9041,
492,
5256,
465,
10106,
63,
2609,
199,
504,
5913,
14,
9041,
492,
1174,
465,
10106,
63,
929,
199,
504,
5913,
14,
9041,
492,
3778,
465,
10106,
63,
1208,
199,
646,
5913,
14,
697,
199,
504,
5913,
14,
697,
492,
1300,
199,
504,
5913,
492,
1919,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
646,
63,
2992,
360,
354,
297,
283,
6765,
14,
9041,
14,
3291,
297,
1572,
534,
9041,
358,
421,
199,
3,
7777,
24834,
869,
8641,
199,
14623,
63,
11422,
63,
11817,
63,
26474,
63,
2339,
275,
283,
1246,
13,
3890,
7,
199,
14623,
63,
26474,
63,
16897,
1877,
275,
9016,
1739,
13,
3890,
17,
356,
28657,
490,
791,
1739,
13,
3890,
18,
356,
9016,
22655,
1739,
13,
3890,
17,
356,
942,
11049,
1386,
490,
791,
1739,
13,
3890,
19,
356,
9016,
22655,
1739,
13,
3890,
18,
356,
28657,
3660,
791,
22655,
1739,
13,
3890,
19,
356,
942,
11049,
1386,
490,
791,
1739,
13,
3890,
20,
356,
942,
11049,
199,
199,
3,
1900,
63,
3890,
63,
5811,
63,
14195,
342,
5084,
911,
5452,
314,
3432,
7054,
436,
1218,
199,
3,
282,
4026,
2455,
402,
314,
6249,
687,
314,
1126,
16657,
402,
1924,
402,
314,
10106,
14,
199,
3,
2104,
1924,
4917,
12,
282,
24834,
8067,
2354,
911,
506,
2737,
543,
642,
2256,
14,
199,
26474,
63,
2339,
63,
2566,
63,
840,
2533,
63,
4531,
275,
1052,
421,
199,
533,
7777,
2846,
7394,
8,
785,
304,
272,
408,
16852,
4440,
282,
3365,
6249,
315,
1924,
4917,
14,
221,
961,
4910,
315,
1865,
370,
272,
10098,
734,
7645,
23142,
1126,
4917,
12,
473,
1929,
370,
1218,
282,
4026,
577,
4134,
1038,
272,
909,
626,
365,
17544,
701,
1924,
4026,
4917,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
4917,
63,
697,
63,
3189,
304,
267,
291,
14,
3890,
63,
697,
63,
3189,
275,
4917,
63,
697,
63,
3189,
339,
347,
636,
5675,
721,
277,
12,
790,
304,
267,
372,
2519,
8,
6765,
14,
697,
12,
790,
9,
339,
347,
4917,
63,
362,
63,
452,
8,
277,
12,
11216,
304,
267,
372,
291,
14,
3890,
63,
697,
63,
3189,
339,
347,
4526,
63,
932,
63,
362,
63,
452,
8,
277,
12,
11216,
304,
267,
372,
942,
339,
347,
1256,
63,
362,
63,
452,
63,
991,
63,
4273,
8,
277,
12,
11216,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
942,
339,
347,
1256,
63,
362,
63,
991,
63,
2580,
8,
277,
12,
11216,
12,
1256,
63,
2580,
304,
267,
746,
1919,
14,
3244,
4667,
8,
842,
63,
344,
29,
842,
63,
2580,
9,
421,
199,
533,
7777,
16852,
6158,
8,
3090,
14,
1563,
16852,
6158,
304,
272,
986,
421,
199,
533,
7777,
8108,
2223,
8,
9041,
63,
929,
14,
8108,
2223,
304,
272,
347,
3222,
63,
1188,
8,
277,
12,
1245,
304,
267,
1245,
63,
5933,
275,
664,
63,
1188,
63,
5933,
8,
277,
14,
354,
9,
267,
2306,
63,
6725,
275,
1245,
14,
6725,
267,
2022,
63,
1188,
275,
1245,
14,
475,
63,
1001,
342,
267,
1245,
275,
1245,
63,
5933,
14,
1188,
63,
504,
63,
1001,
8,
1001,
63,
1188,
9,
267,
327,
22379,
642,
880,
781,
883,
675,
18610,
436,
4911,
2011,
1067,
267,
1245,
14,
6725,
275,
2306,
63,
6725,
267,
1245,
14,
1412,
342,
421,
199,
533,
7777,
8108,
2223,
2988,
8,
9041,
63,
929,
14,
8108,
2223,
2988,
2846,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
8249,
8108,
2223,
2988,
12,
291,
2843,
826,
9308,
589,
12,
355,
4917,
63,
929,
63,
1886,
29,
8249,
8108,
2223,
12,
1011,
958,
9,
421,
199,
533,
7777,
16852,
2988,
8,
9041,
63,
2609,
14,
16852,
2988,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
8249,
16852,
2988,
12,
291,
2843,
826,
9308,
589,
12,
355,
4917,
63,
929,
63,
2609,
29,
8249,
8108,
2223,
2988,
12,
355,
1011,
958,
9,
421,
199,
533,
24834,
8067,
2354,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
2546,
12,
4917,
63,
354,
12,
1592,
63,
3189,
304,
267,
291,
14,
396,
63,
2546,
275,
511,
63,
2546,
267,
291,
14,
3890,
63,
354,
275,
4917,
63,
354,
267,
291,
14,
697,
63,
3189,
275,
1592,
63,
3189,
398,
347,
4026,
63,
1095,
63,
826,
1547,
277,
12,
627,
589,
12,
1011,
958,
304,
288,
485,
277,
14,
697,
275,
7777,
2846,
7394,
8,
697,
63,
3189,
9,
398,
511,
63,
2546,
14,
8957,
14,
1084,
8,
1095,
14,
1563,
12,
2560,
826,
7500,
4026,
63,
1095,
63,
826,
9,
267,
291,
14,
9041,
63,
2609,
275,
7777,
16852,
2988,
342,
267,
327,
14811,
314,
4917,
536,
12,
465,
652,
12252,
4440,
6392,
14,
9041,
14,
354,
267,
1499,
63,
5933,
275,
291,
14,
9041,
63,
2609,
14,
1328,
63,
5933,
267,
1499,
63,
5933,
14,
567,
63,
354,
275,
291,
14,
3890,
63,
354,
267,
291,
14,
9041,
63,
2609,
14,
929,
63,
2609,
14,
1662,
63,
3890,
63,
929
] |
[
1898,
334,
67,
9,
6029,
32679,
10891,
316,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
259,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
259,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
259,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
260,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
259,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
259,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
259,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
259,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
259,
1334,
314,
844,
14,
199,
624,
199,
38,
4364,
2104,
445,
6840,
2295,
14,
199,
624,
199,
199,
504,
11258,
14,
888,
492,
4810,
199,
199,
504,
5913,
14,
9041,
492,
5253,
199,
504,
5913,
14,
9041,
492,
5256,
465,
10106,
63,
2609,
199,
504,
5913,
14,
9041,
492,
1174,
465,
10106,
63,
929,
199,
504,
5913,
14,
9041,
492,
3778,
465,
10106,
63,
1208,
199,
646,
5913,
14,
697,
199,
504,
5913,
14,
697,
492,
1300,
199,
504,
5913,
492,
1919,
199,
199,
3103,
275,
4810,
14,
3103,
199,
3103,
14,
646,
63,
2992,
360,
354,
297,
283,
6765,
14,
9041,
14,
3291,
297,
1572,
534,
9041,
358,
421,
199,
3,
7777,
24834,
869,
8641,
199,
14623,
63,
11422,
63,
11817,
63,
26474,
63,
2339,
275,
283,
1246,
13,
3890,
7,
199,
14623,
63,
26474,
63,
16897,
1877,
275,
9016,
1739,
13,
3890,
17,
356,
28657,
490,
791,
1739,
13,
3890,
18,
356,
9016,
22655,
1739,
13,
3890,
17,
356,
942,
11049,
1386,
490,
791,
1739,
13,
3890,
19,
356,
9016,
22655,
1739,
13,
3890,
18,
356,
28657,
3660,
791,
22655,
1739,
13,
3890,
19,
356,
942,
11049,
1386,
490,
791,
1739,
13,
3890,
20,
356,
942,
11049,
199,
199,
3,
1900,
63,
3890,
63,
5811,
63,
14195,
342,
5084,
911,
5452,
314,
3432,
7054,
436,
1218,
199,
3,
282,
4026,
2455,
402,
314,
6249,
687,
314,
1126,
16657,
402,
1924,
402,
314,
10106,
14,
199,
3,
2104,
1924,
4917,
12,
282,
24834,
8067,
2354,
911,
506,
2737,
543,
642,
2256,
14,
199,
26474,
63,
2339,
63,
2566,
63,
840,
2533,
63,
4531,
275,
1052,
421,
199,
533,
7777,
2846,
7394,
8,
785,
304,
272,
408,
16852,
4440,
282,
3365,
6249,
315,
1924,
4917,
14,
221,
961,
4910,
315,
1865,
370,
272,
10098,
734,
7645,
23142,
1126,
4917,
12,
473,
1929,
370,
1218,
282,
4026,
577,
4134,
1038,
272,
909,
626,
365,
17544,
701,
1924,
4026,
4917,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
4917,
63,
697,
63,
3189,
304,
267,
291,
14,
3890,
63,
697,
63,
3189,
275,
4917,
63,
697,
63,
3189,
339,
347,
636,
5675,
721,
277,
12,
790,
304,
267,
372,
2519,
8,
6765,
14,
697,
12,
790,
9,
339,
347,
4917,
63,
362,
63,
452,
8,
277,
12,
11216,
304,
267,
372,
291,
14,
3890,
63,
697,
63,
3189,
339,
347,
4526,
63,
932,
63,
362,
63,
452,
8,
277,
12,
11216,
304,
267,
372,
942,
339,
347,
1256,
63,
362,
63,
452,
63,
991,
63,
4273,
8,
277,
12,
11216,
12,
627,
589,
12,
1011,
958,
304,
267,
372,
942,
339,
347,
1256,
63,
362,
63,
991,
63,
2580,
8,
277,
12,
11216,
12,
1256,
63,
2580,
304,
267,
746,
1919,
14,
3244,
4667,
8,
842,
63,
344,
29,
842,
63,
2580,
9,
421,
199,
533,
7777,
16852,
6158,
8,
3090,
14,
1563,
16852,
6158,
304,
272,
986,
421,
199,
533,
7777,
8108,
2223,
8,
9041,
63,
929,
14,
8108,
2223,
304,
272,
347,
3222,
63,
1188,
8,
277,
12,
1245,
304,
267,
1245,
63,
5933,
275,
664,
63,
1188,
63,
5933,
8,
277,
14,
354,
9,
267,
2306,
63,
6725,
275,
1245,
14,
6725,
267,
2022,
63,
1188,
275,
1245,
14,
475,
63,
1001,
342,
267,
1245,
275,
1245,
63,
5933,
14,
1188,
63,
504,
63,
1001,
8,
1001,
63,
1188,
9,
267,
327,
22379,
642,
880,
781,
883,
675,
18610,
436,
4911,
2011,
1067,
267,
1245,
14,
6725,
275,
2306,
63,
6725,
267,
1245,
14,
1412,
342,
421,
199,
533,
7777,
8108,
2223,
2988,
8,
9041,
63,
929,
14,
8108,
2223,
2988,
2846,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
8249,
8108,
2223,
2988,
12,
291,
2843,
826,
9308,
589,
12,
355,
4917,
63,
929,
63,
1886,
29,
8249,
8108,
2223,
12,
1011,
958,
9,
421,
199,
533,
7777,
16852,
2988,
8,
9041,
63,
2609,
14,
16852,
2988,
304,
272,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
8249,
16852,
2988,
12,
291,
2843,
826,
9308,
589,
12,
355,
4917,
63,
929,
63,
2609,
29,
8249,
8108,
2223,
2988,
12,
355,
1011,
958,
9,
421,
199,
533,
24834,
8067,
2354,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
2546,
12,
4917,
63,
354,
12,
1592,
63,
3189,
304,
267,
291,
14,
396,
63,
2546,
275,
511,
63,
2546,
267,
291,
14,
3890,
63,
354,
275,
4917,
63,
354,
267,
291,
14,
697,
63,
3189,
275,
1592,
63,
3189,
398,
347,
4026,
63,
1095,
63,
826,
1547,
277,
12,
627,
589,
12,
1011,
958,
304,
288,
485,
277,
14,
697,
275,
7777,
2846,
7394,
8,
697,
63,
3189,
9,
398,
511,
63,
2546,
14,
8957,
14,
1084,
8,
1095,
14,
1563,
12,
2560,
826,
7500,
4026,
63,
1095,
63,
826,
9,
267,
291,
14,
9041,
63,
2609,
275,
7777,
16852,
2988,
342,
267,
327,
14811,
314,
4917,
536,
12,
465,
652,
12252,
4440,
6392,
14,
9041,
14,
354,
267,
1499,
63,
5933,
275,
291,
14,
9041,
63,
2609,
14,
1328,
63,
5933,
267,
1499,
63,
5933,
14,
567,
63,
354,
275,
291,
14,
3890,
63,
354,
267,
291,
14,
9041,
63,
2609,
14,
929,
63,
2609,
14,
1662,
63,
3890,
63,
929,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
graik/labhamster
|
labhamster/admin.py
|
1
|
12409
|
## Copyright 2016 - 2018 Raik Gruenberg
## This file is part of the LabHamster project (https://github.com/graik/labhamster).
## LabHamster is released under the MIT open source license, which you can find
## along with this project (LICENSE) or at <https://opensource.org/licenses/MIT>.
from __future__ import unicode_literals
from labhamster.models import *
from django.contrib import admin
import django.forms
from django.http import HttpResponse
import django.utils.html as html
import customforms
def export_csv(request, queryset, fields):
"""
Helper method for Admin make_csv action. Exports selected objects as
CSV file.
fields - OrderedDict of name / field pairs, see Product.make_csv for example
"""
import csv
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=orders.csv'
writer = csv.writer(response)
writer.writerow(fields.keys())
for o in queryset:
columns = []
for name,value in fields.items():
try:
columns.append( eval('o.%s'%value) )
except:
columns.append("") ## capture 'None' fields
columns = [ c.encode('utf-8') if type(c) is unicode else c \
for c in columns]
writer.writerow( columns )
return response
class RequestFormAdmin(admin.ModelAdmin):
"""
ModelAdmin that adds a 'request' field to the form generated by the Admin.
This e.g. allows to extract the user ID during the creation of the form.
"""
def get_form(self, request, obj=None, **kwargs):
"""
Assign request variable to form
http://stackoverflow.com/questions/1057252/how-do-i-access-the-request-object-or-any-other-variable-in-a-forms-clean-met
(last answer, much simpler than Django 1.6 version)
"""
form = super(RequestFormAdmin, self).get_form(request, obj=obj, **kwargs)
form.request = request
return form
class GrantAdmin(admin.ModelAdmin):
ordering = ('name',)
admin.site.register(Grant, GrantAdmin)
class CategoryAdmin(admin.ModelAdmin):
ordering = ('name',)
admin.site.register(Category, CategoryAdmin)
class VendorAdmin(admin.ModelAdmin):
fieldsets = ((None, {'fields': (('name',),
('link', 'login', 'password'),)}),
('Contact', {'fields' : (('contact',),
('email','phone'),)})
)
list_display = ('name', 'link', 'login', 'password')
ordering = ('name',)
search_fields = ('name', 'contact')
admin.site.register(Vendor, VendorAdmin)
class ProductAdmin(admin.ModelAdmin):
fieldsets = ((None, {'fields': (('name', 'category'),
('vendor', 'catalog'),
('manufacturer', 'manufacturer_catalog'),
'link',
('status', 'shelflife'),
'comment',
'location')}),)
list_display = ('name', 'show_vendor', 'category', 'show_catalog',
'status')
list_filter = ('status', 'category', 'vendor')
ordering = ('name',)
search_fields = ('name', 'comment', 'catalog', 'location', 'vendor__name',
'manufacturer__name', 'manufacturer_catalog')
save_as = True
actions = ['make_ok',
'make_low',
'make_out',
'make_deprecated',
'make_csv']
## reduce size of Description text field.
formfield_overrides = {
models.TextField: {'widget': django.forms.Textarea(
attrs={'rows': 4,
'cols': 80})},
}
def make_ok(self, request, queryset):
n = queryset.update(status='ok')
self.message_user(request, '%i products were updated' % n)
make_ok.short_description = 'Mark selected entries as in stock'
def make_low(self, request, queryset):
n = queryset.update(status='low')
self.message_user(request, '%i products were updated' % n)
make_low.short_description = 'Mark selected entries as running low'
def make_out(self, request, queryset):
n = queryset.update(status='out')
self.message_user(request, '%i products were updated' % n)
make_out.short_description = 'Mark selected entries as out of stock'
def make_deprecated(self, request, queryset):
n = queryset.update(status='deprecated')
self.message_user(request, '%i products were updated' % n)
make_deprecated.short_description = 'Mark selected entries as deprecated'
def make_csv(self, request, queryset):
from collections import OrderedDict
fields = OrderedDict( [('Name', 'name'),
('Vendor', 'vendor.name'),
('Vendor Catalog','catalog'),
('Manufacturer', 'manufacturer.name'),
('Manufacturer Catalog', 'manufacturer_catalog'),
('Category','category.name'),
('Shelf_life','shelflife'),
('Status','status'),
('Location','location'),
('Link','link'),
('Comment','comment')])
return export_csv( request, queryset, fields)
make_csv.short_description = 'Export products as CSV'
## note: this currently breaks the selection of products from the
## order form "lense" button
def show_name(self, o):
"""truncate product name to less than 40 char"""
from django.utils.safestring import SafeUnicode
return html.format_html(
'<a href="{url}" title="{comment}">{name}</a>',
url=o.get_absolute_url(),
name=T.truncate(o.name, 40),
comment=SafeUnicode(o.comment))
show_name.short_description = 'Name'
show_name.admin_order_field = 'name'
def show_vendor(self, o):
"""Display in table: Vendor (Manufacturer)"""
r = o.vendor.name
if o.manufacturer:
r += '<br>(%s)' % o.manufacturer.name
return html.format_html(r)
show_vendor.admin_order_field = 'vendor'
show_vendor.short_description = 'Vendor'
def show_catalog(self, o):
return T.truncate(o.catalog, 15)
show_catalog.short_description = 'Catalog'
show_catalog.admin_order_field = 'catalog'
admin.site.register(Product, ProductAdmin)
class OrderAdmin(RequestFormAdmin):
form = customforms.OrderForm
raw_id_fields = ('product',)
fieldsets = ((None,
{'fields': (('status', 'is_urgent', 'product',),
('created_by', 'ordered_by', 'date_ordered',
'date_received'))}),
('Details', {'fields': (('unit_size', 'quantity'),
('price', 'po_number'),
('grant', 'grant_category'),
'comment')}))
radio_fields = {'grant': admin.VERTICAL,
'grant_category': admin.VERTICAL}
list_display = ('show_title', 'Status', 'show_urgent',
'show_quantity', 'show_price',
'requested', 'show_requestedby', 'ordered',
'received', 'show_comment',)
list_filter = ('status',
'product__category__name', 'grant', 'created_by', 'product__vendor__name',)
ordering = ('-date_created', 'product', '-date_ordered') #, 'price')
search_fields = ('comment', 'grant__name', 'grant__grant_id', 'product__name',
'product__vendor__name')
save_as = True
date_hierarchy = 'date_created'
actions = ['make_ordered', 'make_received', 'make_cancelled', 'make_csv']
def show_title(self, o):
"""truncate product name + supplier to less than 40 char"""
n = T.truncate(o.product.name, 40)
v = o.product.vendor.name
r = html.format_html('<a href="{}">{}', o.get_absolute_url(), n)
r += '<br>' if len(n) + len(v) > 37 else ' '
r += html.format_html('[{}]</a>',v)
return html.mark_safe(r)
show_title.short_description = 'Product'
def show_comment(self, obj):
"""
@return: str; truncated comment with full comment mouse-over
"""
if not obj.comment:
return ''
if len(obj.comment) < 30:
return obj.comment
r = obj.comment[:28]
r = '<a title="%s">%s</a>' % (obj.comment, T.truncate(obj.comment, 30))
return r
show_comment.short_description = 'comment'
show_comment.allow_tags = True
def show_price(self, o):
"""Workaround for bug in djmoney -- MoneyField confuses Admin formatting"""
if not o.price:
return ''
return o.price
show_price.admin_order_field = 'price'
show_price.short_description = 'Unit price'
def show_urgent(self, o):
"""Show exclamation mark if order is urgent"""
if not o.is_urgent:
return ''
return html.format_html(
'<big>❗</big>')
show_urgent.admin_order_field = 'is_urgent'
show_urgent.short_description = '!'
def show_requestedby(self,o):
return o.created_by
show_requestedby.admin_order_field = 'created_by'
show_requestedby.short_description = 'By'
def show_quantity(self, o):
return o.quantity
show_quantity.short_description = 'Q'
def make_ordered(self, request, queryset):
"""
Mark several orders as 'ordered'
see: https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/
"""
import datetime
n = queryset.update(status='ordered', ordered_by=request.user,
date_ordered=datetime.datetime.now())
self.message_user(request, '%i orders were updated' % n)
make_ordered.short_description = 'Mark selected entries as ordered'
def make_received(self, request, queryset):
import datetime
n = queryset.update(date_received=datetime.datetime.now(),
status='received')
i = 0
for order in queryset:
order.product.status = 'ok'
order.product.save()
i += 1
self.message_user(request,
'%i orders were updated and %i products set to "in stock"'\
% (n, i))
make_received.short_description= 'Mark as received (and update product status)'
def make_cancelled(self, request, queryset):
import datetime
n = queryset.update(date_received=None, date_ordered=None,
status='cancelled')
self.message_user(request, '%i orders were set to cancelled' % n)
make_cancelled.short_description = 'Mark selected entries as cancelled'
def make_csv(self, request, queryset):
"""
Export selected orders as CSV file
"""
from collections import OrderedDict
fields = OrderedDict( [('Product', 'product.name'),
('Quantity', 'quantity'),
('Price','price'),
('Vendor','product.vendor.name'),
('Catalog','product.catalog'),
('PO Number', 'po_number'),
('Requested','date_created'),
('Requested by','created_by.username'),
('Ordered','date_ordered'),
('Ordered by','ordered_by.username'),
('Received','date_received'),
('Status','status'),
('Urgent','is_urgent'),
('Comment','comment')])
return export_csv(request, queryset, fields)
make_csv.short_description = 'Export orders as CSV'
admin.site.register(Order, OrderAdmin)
|
mit
|
[
309,
1898,
7800,
446,
14894,
3898,
3258,
598,
6558,
287,
14630,
199,
199,
309,
961,
570,
365,
1777,
402,
314,
16871,
40,
455,
11652,
2199,
334,
2859,
921,
5031,
14,
957,
15,
926,
3258,
15,
5561,
10670,
11652,
680,
221,
199,
309,
16871,
40,
455,
11652,
365,
14286,
1334,
314,
10697,
1551,
1350,
4190,
12,
1314,
1265,
883,
2342,
199,
309,
3180,
543,
642,
2199,
334,
3961,
9,
503,
737,
665,
2859,
921,
16374,
14,
1308,
15,
2383,
15,
13965,
10827,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
19888,
10670,
11652,
14,
992,
492,
627,
199,
504,
1639,
14,
2828,
492,
4628,
199,
646,
1639,
14,
3351,
199,
504,
1639,
14,
1014,
492,
6183,
199,
646,
1639,
14,
1208,
14,
1360,
465,
3517,
199,
199,
646,
3537,
3351,
199,
199,
318,
4843,
63,
4737,
8,
1069,
12,
7594,
12,
1504,
304,
272,
408,
272,
11642,
1083,
367,
9516,
1852,
63,
4737,
1595,
14,
1316,
5203,
4895,
2251,
465,
5591,
14689,
570,
14,
272,
1504,
446,
8773,
402,
536,
1182,
901,
6342,
12,
1937,
12705,
14,
1875,
63,
4737,
367,
2893,
272,
408,
272,
492,
7392,
339,
1177,
275,
6183,
8,
1317,
63,
466,
534,
505,
15,
4737,
358,
272,
1177,
459,
2714,
13,
15954,
418,
275,
283,
8905,
27,
1788,
29,
14387,
14,
4737,
7,
2286,
7060,
275,
7392,
14,
5491,
8,
1310,
9,
272,
7060,
14,
22686,
8,
955,
14,
1612,
1012,
339,
367,
312,
315,
7594,
26,
267,
4362,
275,
942,
267,
367,
536,
12,
585,
315,
1504,
14,
1744,
837,
288,
862,
26,
355,
4362,
14,
740,
8,
3468,
360,
79,
4111,
83,
5956,
585,
9,
776,
288,
871,
26,
355,
4362,
14,
740,
10804,
221,
925,
12296,
283,
403,
7,
1504,
398,
4362,
275,
359,
286,
14,
2143,
360,
1624,
13,
24,
358,
340,
730,
8,
67,
9,
365,
2649,
587,
286,
971,
490,
367,
286,
315,
4362,
61,
10631,
7060,
14,
22686,
8,
4362,
776,
339,
372,
1177,
16872,
199,
533,
4784,
2821,
4880,
8,
2113,
14,
12976,
304,
272,
408,
272,
30093,
626,
9584,
282,
283,
1069,
7,
901,
370,
314,
1824,
4046,
701,
314,
9516,
14,
272,
961,
325,
14,
71,
14,
6127,
370,
5536,
314,
922,
2870,
5309,
314,
7143,
402,
314,
1824,
14,
272,
408,
339,
347,
664,
63,
964,
8,
277,
12,
1056,
12,
1559,
29,
403,
12,
1011,
958,
304,
267,
408,
267,
16927,
1056,
1750,
370,
1824,
267,
1455,
921,
23153,
14,
957,
15,
16069,
15,
709,
1641,
6390,
15,
1917,
13,
1117,
13,
73,
13,
2732,
13,
1589,
13,
1069,
13,
785,
13,
269,
13,
1629,
13,
1848,
13,
1975,
13,
262,
13,
65,
13,
3351,
13,
3118,
13,
10207,
267,
334,
2019,
6385,
12,
8298,
28293,
2419,
5634,
413,
14,
22,
1015,
9,
267,
408,
267,
1824,
275,
1613,
8,
2017,
2821,
4880,
12,
291,
680,
362,
63,
964,
8,
1069,
12,
1559,
29,
1113,
12,
1011,
958,
9,
267,
1824,
14,
1069,
275,
1056,
267,
372,
1824,
259,
421,
199,
533,
598,
17633,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
199,
199,
2113,
14,
2124,
14,
2683,
8,
39,
17633,
12,
598,
17633,
4880,
9,
199,
199,
533,
13573,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
199,
199,
2113,
14,
2124,
14,
2683,
8,
7841,
12,
13573,
4880,
9,
421,
199,
533,
812,
7454,
4880,
8,
2113,
14,
12976,
304,
339,
901,
2193,
275,
3666,
403,
12,
791,
955,
356,
13636,
354,
5529,
2511,
661,
1073,
297,
283,
2886,
297,
283,
2060,
659,
6769,
395,
326,
661,
14499,
297,
791,
955,
7,
520,
13636,
7811,
5529,
5101,
661,
2123,
1673,
9339,
659,
11466,
326,
776,
2378,
769,
63,
2918,
275,
661,
354,
297,
283,
1073,
297,
283,
2886,
297,
283,
2060,
358,
339,
7794,
275,
661,
354,
9538,
272,
2754,
63,
955,
275,
661,
354,
297,
283,
7811,
358,
199,
199,
2113,
14,
2124,
14,
2683,
8,
27111,
12,
812,
7454,
4880,
9,
199,
199,
533,
12705,
4880,
8,
2113,
14,
12976,
304,
272,
901,
2193,
275,
3666,
403,
12,
791,
955,
356,
13636,
354,
297,
283,
3710,
659,
2511,
661,
9884,
297,
283,
7959,
659,
221,
2511,
661,
32214,
297,
283,
32214,
63,
7959,
659,
2511,
283,
1073,
297,
2511,
661,
1205,
297,
283,
19195,
276,
13602,
659,
2511,
283,
3349,
297,
2511,
283,
1985,
358,
8688,
9,
2286,
769,
63,
2918,
275,
661,
354,
297,
283,
2384,
63,
9884,
297,
283,
3710,
297,
283,
2384,
63,
7959,
297,
2151,
283,
1205,
358,
272,
769,
63,
1541,
275,
661,
1205,
297,
283,
3710,
297,
283,
9884,
358,
339,
7794,
275,
661,
354,
9538,
272,
2754,
63,
955,
275,
661,
354,
297,
283,
3349,
297,
283,
7959,
297,
283,
1985,
297,
283,
9884,
363,
354,
297,
2151,
283,
32214,
363,
354,
297,
283,
32214,
63,
7959,
358,
339,
3354,
63,
305,
275,
715,
339,
5445,
275,
788,
1875,
63,
745,
297,
2049,
283,
1875,
63,
674,
297,
2049,
283,
1875,
63,
548,
297,
2049,
283,
1875,
63,
6667,
297,
2049,
283,
1875,
63,
4737,
418,
339,
925,
7114,
1568,
402,
11994,
1318,
901,
14,
272,
21388,
63,
12867,
275,
469,
267,
1709,
14,
6254,
26,
791,
3440,
356,
1639,
14,
3351,
14,
1872,
6789,
8,
288,
3290,
3713,
3838,
356,
841,
12,
673,
283,
4574,
356,
5939,
1552,
1386,
272,
789,
258,
339,
347,
1852,
63,
745,
8,
277,
12,
1056,
12,
7594,
304,
267,
302,
275,
7594,
14,
873,
8,
1205,
534,
745,
358,
267,
291,
14,
1188,
63,
751,
8,
1069,
12,
1543,
73,
7585,
4898,
4588,
7,
450,
302,
9,
339,
1852,
63,
745,
14,
3612,
63,
1802,
275,
283,
6470,
4895,
4811,
465,
315,
10952,
7,
339,
347,
1852,
63,
674,
8,
277,
12,
1056,
12,
7594,
304,
267,
302,
275,
7594,
14,
873,
8,
1205,
534,
674,
358,
267,
291,
14,
1188,
63,
751,
8,
1069,
12,
1543,
73,
7585,
4898,
4588,
7,
450,
302,
9,
339,
1852,
63,
674,
14,
3612,
63,
1802,
275,
283,
6470,
4895,
4811,
465,
3879,
6465,
7,
339,
347,
1852,
63,
548,
8,
277,
12,
1056,
12,
7594,
304,
267,
302,
275,
7594
] |
[
1898,
7800,
446,
14894,
3898,
3258,
598,
6558,
287,
14630,
199,
199,
309,
961,
570,
365,
1777,
402,
314,
16871,
40,
455,
11652,
2199,
334,
2859,
921,
5031,
14,
957,
15,
926,
3258,
15,
5561,
10670,
11652,
680,
221,
199,
309,
16871,
40,
455,
11652,
365,
14286,
1334,
314,
10697,
1551,
1350,
4190,
12,
1314,
1265,
883,
2342,
199,
309,
3180,
543,
642,
2199,
334,
3961,
9,
503,
737,
665,
2859,
921,
16374,
14,
1308,
15,
2383,
15,
13965,
10827,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
19888,
10670,
11652,
14,
992,
492,
627,
199,
504,
1639,
14,
2828,
492,
4628,
199,
646,
1639,
14,
3351,
199,
504,
1639,
14,
1014,
492,
6183,
199,
646,
1639,
14,
1208,
14,
1360,
465,
3517,
199,
199,
646,
3537,
3351,
199,
199,
318,
4843,
63,
4737,
8,
1069,
12,
7594,
12,
1504,
304,
272,
408,
272,
11642,
1083,
367,
9516,
1852,
63,
4737,
1595,
14,
1316,
5203,
4895,
2251,
465,
5591,
14689,
570,
14,
272,
1504,
446,
8773,
402,
536,
1182,
901,
6342,
12,
1937,
12705,
14,
1875,
63,
4737,
367,
2893,
272,
408,
272,
492,
7392,
339,
1177,
275,
6183,
8,
1317,
63,
466,
534,
505,
15,
4737,
358,
272,
1177,
459,
2714,
13,
15954,
418,
275,
283,
8905,
27,
1788,
29,
14387,
14,
4737,
7,
2286,
7060,
275,
7392,
14,
5491,
8,
1310,
9,
272,
7060,
14,
22686,
8,
955,
14,
1612,
1012,
339,
367,
312,
315,
7594,
26,
267,
4362,
275,
942,
267,
367,
536,
12,
585,
315,
1504,
14,
1744,
837,
288,
862,
26,
355,
4362,
14,
740,
8,
3468,
360,
79,
4111,
83,
5956,
585,
9,
776,
288,
871,
26,
355,
4362,
14,
740,
10804,
221,
925,
12296,
283,
403,
7,
1504,
398,
4362,
275,
359,
286,
14,
2143,
360,
1624,
13,
24,
358,
340,
730,
8,
67,
9,
365,
2649,
587,
286,
971,
490,
367,
286,
315,
4362,
61,
10631,
7060,
14,
22686,
8,
4362,
776,
339,
372,
1177,
16872,
199,
533,
4784,
2821,
4880,
8,
2113,
14,
12976,
304,
272,
408,
272,
30093,
626,
9584,
282,
283,
1069,
7,
901,
370,
314,
1824,
4046,
701,
314,
9516,
14,
272,
961,
325,
14,
71,
14,
6127,
370,
5536,
314,
922,
2870,
5309,
314,
7143,
402,
314,
1824,
14,
272,
408,
339,
347,
664,
63,
964,
8,
277,
12,
1056,
12,
1559,
29,
403,
12,
1011,
958,
304,
267,
408,
267,
16927,
1056,
1750,
370,
1824,
267,
1455,
921,
23153,
14,
957,
15,
16069,
15,
709,
1641,
6390,
15,
1917,
13,
1117,
13,
73,
13,
2732,
13,
1589,
13,
1069,
13,
785,
13,
269,
13,
1629,
13,
1848,
13,
1975,
13,
262,
13,
65,
13,
3351,
13,
3118,
13,
10207,
267,
334,
2019,
6385,
12,
8298,
28293,
2419,
5634,
413,
14,
22,
1015,
9,
267,
408,
267,
1824,
275,
1613,
8,
2017,
2821,
4880,
12,
291,
680,
362,
63,
964,
8,
1069,
12,
1559,
29,
1113,
12,
1011,
958,
9,
267,
1824,
14,
1069,
275,
1056,
267,
372,
1824,
259,
421,
199,
533,
598,
17633,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
199,
199,
2113,
14,
2124,
14,
2683,
8,
39,
17633,
12,
598,
17633,
4880,
9,
199,
199,
533,
13573,
4880,
8,
2113,
14,
12976,
304,
272,
7794,
275,
661,
354,
9538,
199,
199,
2113,
14,
2124,
14,
2683,
8,
7841,
12,
13573,
4880,
9,
421,
199,
533,
812,
7454,
4880,
8,
2113,
14,
12976,
304,
339,
901,
2193,
275,
3666,
403,
12,
791,
955,
356,
13636,
354,
5529,
2511,
661,
1073,
297,
283,
2886,
297,
283,
2060,
659,
6769,
395,
326,
661,
14499,
297,
791,
955,
7,
520,
13636,
7811,
5529,
5101,
661,
2123,
1673,
9339,
659,
11466,
326,
776,
2378,
769,
63,
2918,
275,
661,
354,
297,
283,
1073,
297,
283,
2886,
297,
283,
2060,
358,
339,
7794,
275,
661,
354,
9538,
272,
2754,
63,
955,
275,
661,
354,
297,
283,
7811,
358,
199,
199,
2113,
14,
2124,
14,
2683,
8,
27111,
12,
812,
7454,
4880,
9,
199,
199,
533,
12705,
4880,
8,
2113,
14,
12976,
304,
272,
901,
2193,
275,
3666,
403,
12,
791,
955,
356,
13636,
354,
297,
283,
3710,
659,
2511,
661,
9884,
297,
283,
7959,
659,
221,
2511,
661,
32214,
297,
283,
32214,
63,
7959,
659,
2511,
283,
1073,
297,
2511,
661,
1205,
297,
283,
19195,
276,
13602,
659,
2511,
283,
3349,
297,
2511,
283,
1985,
358,
8688,
9,
2286,
769,
63,
2918,
275,
661,
354,
297,
283,
2384,
63,
9884,
297,
283,
3710,
297,
283,
2384,
63,
7959,
297,
2151,
283,
1205,
358,
272,
769,
63,
1541,
275,
661,
1205,
297,
283,
3710,
297,
283,
9884,
358,
339,
7794,
275,
661,
354,
9538,
272,
2754,
63,
955,
275,
661,
354,
297,
283,
3349,
297,
283,
7959,
297,
283,
1985,
297,
283,
9884,
363,
354,
297,
2151,
283,
32214,
363,
354,
297,
283,
32214,
63,
7959,
358,
339,
3354,
63,
305,
275,
715,
339,
5445,
275,
788,
1875,
63,
745,
297,
2049,
283,
1875,
63,
674,
297,
2049,
283,
1875,
63,
548,
297,
2049,
283,
1875,
63,
6667,
297,
2049,
283,
1875,
63,
4737,
418,
339,
925,
7114,
1568,
402,
11994,
1318,
901,
14,
272,
21388,
63,
12867,
275,
469,
267,
1709,
14,
6254,
26,
791,
3440,
356,
1639,
14,
3351,
14,
1872,
6789,
8,
288,
3290,
3713,
3838,
356,
841,
12,
673,
283,
4574,
356,
5939,
1552,
1386,
272,
789,
258,
339,
347,
1852,
63,
745,
8,
277,
12,
1056,
12,
7594,
304,
267,
302,
275,
7594,
14,
873,
8,
1205,
534,
745,
358,
267,
291,
14,
1188,
63,
751,
8,
1069,
12,
1543,
73,
7585,
4898,
4588,
7,
450,
302,
9,
339,
1852,
63,
745,
14,
3612,
63,
1802,
275,
283,
6470,
4895,
4811,
465,
315,
10952,
7,
339,
347,
1852,
63,
674,
8,
277,
12,
1056,
12,
7594,
304,
267,
302,
275,
7594,
14,
873,
8,
1205,
534,
674,
358,
267,
291,
14,
1188,
63,
751,
8,
1069,
12,
1543,
73,
7585,
4898,
4588,
7,
450,
302,
9,
339,
1852,
63,
674,
14,
3612,
63,
1802,
275,
283,
6470,
4895,
4811,
465,
3879,
6465,
7,
339,
347,
1852,
63,
548,
8,
277,
12,
1056,
12,
7594,
304,
267,
302,
275,
7594,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
fdudatamining/framework
|
tests/draw/test_simple.py
|
1
|
1233
|
import numpy as np
import pandas as pd
from unittest import TestCase
from framework import draw
X = np.array([1, 2, 3, 4, 5])
class TestSimplePlots(TestCase):
def test_kinds(self):
self.assertIsNotNone(draw.draw_kinds)
def test_line(self):
draw.draw(clear=True, kind='line', x=X, y=X)
draw.draw(clear=True, kind='line', y=X)
def test_scatter(self):
draw.draw(clear=True, kind='scatter', x=X, y=X)
draw.draw(clear=True, kind='scatter', y=X)
def test_stem(self):
draw.draw(clear=True, kind='stem', x=X, y=X)
draw.draw(clear=True, kind='stem', y=X)
def test_errorbar(self):
draw.draw(clear=True, kind='errorbar', x=X, y=X, xerr=X, yerr=X)
draw.draw(clear=True, kind='errorbar', y=X, yerr=X)
def test_boxplot(self):
draw.draw(clear=True, kind='boxplot', x=X)
def test_barplot(self):
draw.draw(clear=True, kind='barplot', x=X, y=X, width=1)
draw.draw(clear=True, kind='barplot', x=X, y=X)
draw.draw(clear=True, kind='barplot', y=X)
def test_contour(self):
draw.draw(clear=True, kind='contour', z=[[1, 2, 3], [4, 5, 6], [7, 8, 9]])
def test_hist(self):
draw.draw(clear=True, kind='hist', x=X, bins=2)
draw.draw(clear=True, kind='hist', x=X)
|
gpl-2.0
|
[
646,
2680,
465,
980,
199,
646,
10634,
465,
6454,
199,
504,
2882,
492,
7640,
199,
504,
10059,
492,
5954,
199,
199,
56,
275,
980,
14,
1144,
779,
17,
12,
499,
12,
650,
12,
841,
12,
959,
566,
199,
199,
533,
1379,
3184,
48,
4555,
8,
1746,
304,
523,
347,
511,
63,
5091,
83,
8,
277,
304,
272,
291,
14,
10389,
8,
5485,
14,
5485,
63,
5091,
83,
9,
819,
347,
511,
63,
604,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
604,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
604,
297,
612,
29,
56,
9,
12244,
347,
511,
63,
13512,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
13512,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
13512,
297,
612,
29,
56,
9,
819,
347,
511,
63,
18446,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
18446,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
18446,
297,
612,
29,
56,
9,
819,
347,
511,
63,
705,
1700,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
705,
1700,
297,
671,
29,
56,
12,
612,
29,
56,
12,
671,
1508,
29,
56,
12,
612,
1508,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
705,
1700,
297,
612,
29,
56,
12,
612,
1508,
29,
56,
9,
819,
347,
511,
63,
1977,
2798,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1977,
2798,
297,
671,
29,
56,
9,
12244,
347,
511,
63,
1700,
2798,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1700,
2798,
297,
671,
29,
56,
12,
612,
29,
56,
12,
3462,
29,
17,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1700,
2798,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1700,
2798,
297,
612,
29,
56,
9,
819,
347,
511,
63,
17798,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
17798,
297,
1315,
16025,
17,
12,
499,
12,
650,
467,
359,
20,
12,
959,
12,
1227,
467,
359,
23,
12,
1695,
12,
1749,
3934,
12244,
347,
511,
63,
11141,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
11141,
297,
671,
29,
56,
12,
13341,
29,
18,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
11141,
297,
671,
29,
56,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2680,
465,
980,
199,
646,
10634,
465,
6454,
199,
504,
2882,
492,
7640,
199,
504,
10059,
492,
5954,
199,
199,
56,
275,
980,
14,
1144,
779,
17,
12,
499,
12,
650,
12,
841,
12,
959,
566,
199,
199,
533,
1379,
3184,
48,
4555,
8,
1746,
304,
523,
347,
511,
63,
5091,
83,
8,
277,
304,
272,
291,
14,
10389,
8,
5485,
14,
5485,
63,
5091,
83,
9,
819,
347,
511,
63,
604,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
604,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
604,
297,
612,
29,
56,
9,
12244,
347,
511,
63,
13512,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
13512,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
13512,
297,
612,
29,
56,
9,
819,
347,
511,
63,
18446,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
18446,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
18446,
297,
612,
29,
56,
9,
819,
347,
511,
63,
705,
1700,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
705,
1700,
297,
671,
29,
56,
12,
612,
29,
56,
12,
671,
1508,
29,
56,
12,
612,
1508,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
705,
1700,
297,
612,
29,
56,
12,
612,
1508,
29,
56,
9,
819,
347,
511,
63,
1977,
2798,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1977,
2798,
297,
671,
29,
56,
9,
12244,
347,
511,
63,
1700,
2798,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1700,
2798,
297,
671,
29,
56,
12,
612,
29,
56,
12,
3462,
29,
17,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1700,
2798,
297,
671,
29,
56,
12,
612,
29,
56,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
1700,
2798,
297,
612,
29,
56,
9,
819,
347,
511,
63,
17798,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
17798,
297,
1315,
16025,
17,
12,
499,
12,
650,
467,
359,
20,
12,
959,
12,
1227,
467,
359,
23,
12,
1695,
12,
1749,
3934,
12244,
347,
511,
63,
11141,
8,
277,
304,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
11141,
297,
671,
29,
56,
12,
13341,
29,
18,
9,
272,
5954,
14,
5485,
8,
3584,
29,
549,
12,
4928,
534,
11141,
297,
671,
29,
56,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nielsbuwen/ilastik
|
ilastik/applets/splitBodyCarving/bodySplitInfoWidget.py
|
4
|
16852
|
###############################################################################
# ilastik: interactive learning and segmentation toolkit
#
# Copyright (C) 2011-2014, the ilastik developers
# <team@ilastik.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# In addition, as a special exception, the copyright holders of
# ilastik give you permission to combine ilastik with applets,
# workflows and plugins which are not covered under the GNU
# General Public License.
#
# See the LICENSE file for details. License information is also available
# on the ilastik web site at:
# http://ilastik.org/license.html
###############################################################################
import sys
import os
from functools import partial
from PyQt4 import uic
from PyQt4.QtCore import Qt, pyqtSignal
from PyQt4.QtGui import QWidget, QFileDialog, QMessageBox, QTreeWidgetItem, QTableWidgetItem, \
QPushButton, QTableView, QHeaderView, QIcon, QProgressBar
from volumina.utility import encode_from_qstring, decode_to_qstring
from ilastik.shell.gui.iconMgr import ilastikIcons
from ilastik.utility import log_exception
from opParseAnnotations import OpParseAnnotations
import logging
logger = logging.getLogger(__name__)
class BodyProgressBar(QProgressBar):
def __init__(self, *args, **kwargs):
super( BodyProgressBar, self ).__init__(*args, **kwargs)
self._text = ""
def setText(self, text):
self._text = text
def text(self):
return self._text
class BodyTreeColumns():
ID = 0
Button1 = 1
Button2 = 2
class AnnotationTableColumns():
Body = 0
Coordinates = 1
Comment = 2
class BodySplitInfoWidget( QWidget ):
navigationRequested = pyqtSignal(object) # (3d coordinate tuple)
def __init__(self, parent, opSplitBodyCarving):
# We don't pass parent to the QWidget because we want the window to be top-level
super( BodySplitInfoWidget, self ).__init__()
self.opSplitBodyCarving = opSplitBodyCarving
self._bodyTreeParentItems = {} # This is easier to maintain than using setData/find
self._annotation_filepath = None
if self.opSplitBodyCarving.AnnotationFilepath.ready():
self._annotation_filepath = self.opSplitBodyCarving.AnnotationFilepath.value
self._annotations = {} # coordinate : Annotation
self._ravelerLabels = set()
self._initUi()
if self._annotation_filepath is not None:
self._loadAnnotationFile( self._annotation_filepath )
self.refreshButton.setEnabled( self._annotation_filepath is not None )
def _initUi(self):
# Load the ui file into this class (find it in our own directory)
localDir = os.path.split(__file__)[0]
uiFilePath = os.path.join( localDir, 'bodySplitInfoWidget.ui' )
uic.loadUi(uiFilePath, self)
self.setWindowTitle("Body Split Info")
self.bodyTreeWidget.setHeaderLabels( ['Body ID', 'Progress', ''] )
self.bodyTreeWidget.header().setResizeMode( QHeaderView.ResizeToContents )
self.bodyTreeWidget.header().setStretchLastSection(False)
self.bodyTreeWidget.itemDoubleClicked.connect( self._handleBodyTreeDoubleClick )
self.bodyTreeWidget.setExpandsOnDoubleClick(False) # We want to use double-click for auto-navigation
self.annotationTableWidget.setColumnCount(3)
self._initAnnotationTableHeader()
self.annotationTableWidget.itemDoubleClicked.connect( self._handleAnnotationDoubleClick )
self.annotationTableWidget.setSelectionBehavior( QTableView.SelectRows )
self.annotationTableWidget.horizontalHeader().setResizeMode( QHeaderView.ResizeToContents )
self.loadSplitAnnoationFileButton.pressed.connect( self._loadNewAnnotationFile )
self.loadSplitAnnoationFileButton.setIcon( QIcon(ilastikIcons.Open) )
self.refreshButton.pressed.connect( self._refreshAnnotations )
self.refreshButton.setIcon( QIcon(ilastikIcons.Refresh) )
def _loadNewAnnotationFile(self):
"""
Ask the user for a new annotation filepath, and then load it.
"""
navDir = ""
if self._annotation_filepath is not None:
navDir = os.path.split( self._annotation_filepath )[0]
selected_file = QFileDialog.getOpenFileName(self,
"Load Split Annotation File",
navDir,
"JSON files (*.json)",
options=QFileDialog.DontUseNativeDialog)
self.refreshButton.setEnabled( not selected_file.isNull() )
if selected_file.isNull():
return
self._loadAnnotationFile( encode_from_qstring( selected_file ) )
def _loadAnnotationFile(self, annotation_filepath):
"""
Load the annotation file using the path stored in our member variable.
"""
try:
# Configure operator
self.opSplitBodyCarving.AnnotationFilepath.setValue( annotation_filepath )
# Requesting annotations triggers parse.
self._annotations = self.opSplitBodyCarving.Annotations.value
self._ravelerLabels = self.opSplitBodyCarving.AnnotationBodyIds.value
# Update gui
self._reloadInfoWidgets()
self.annotationFilepathEdit.setText( decode_to_qstring(annotation_filepath) )
except OpParseAnnotations.AnnotationParsingException as ex :
if ex.original_exc is not None:
log_exception( logger, exc_info=( type(ex.original_exc), ex.original_exc, sys.exc_info[2]) )
else:
log_exception( logger )
QMessageBox.critical(self,
"Failed to parse",
ex.msg + "\n\nSee console output for details." )
self._annotations = None
self._ravelerLabels = None
self.annotationFilepathEdit.setText("")
except:
msg = "Wasn't able to parse your bookmark file. See console output for details."
QMessageBox.critical(self, "Failed to parse", msg )
log_exception( logger, msg )
self._annotations = None
self._ravelerLabels = None
self.annotationFilepathEdit.setText("")
def _refreshAnnotations(self):
if self.opSplitBodyCarving.AnnotationFilepath.ready():
# Disconnect, then refresh.
annotation_filepath = self.opSplitBodyCarving.AnnotationFilepath.value
self.opSplitBodyCarving.AnnotationFilepath.disconnect()
self._loadAnnotationFile( annotation_filepath )
def _handleAnnotationDoubleClick(self, item):
coord3d, ravelerLabel = item.data(Qt.UserRole).toPyObject()
self._selectAnnotation(coord3d, ravelerLabel)
# Highlight the appropriate row in the body list as a convenience
bodyItem = self._bodyTreeParentItems[ravelerLabel]
self.bodyTreeWidget.setCurrentItem( bodyItem )
def _handleBodyTreeDoubleClick(self, item, column):
if item in self._bodyTreeParentItems.values():
selectedLabel = item.data(0, Qt.UserRole).toPyObject()
# Find the first split point for this body
for coord3d, annotation in self._annotations.items():
if selectedLabel == annotation.ravelerLabel:
# Find a row to auto-select in the annotation table
for row in range( self.annotationTableWidget.rowCount() ):
if selectedLabel == self.annotationTableWidget.itemAt(row, 0).data(Qt.UserRole).toPyObject()[1]:
self.annotationTableWidget.selectRow( row )
break
self._selectAnnotation(coord3d, selectedLabel)
break
def _selectAnnotation(self, coord3d, ravelerLabel):
# Switch raveler labels if necessary.
if self.opSplitBodyCarving.CurrentRavelerLabel.value != ravelerLabel:
# Don't switch bodies if the user hasn't saved the current fragment
currentFragmentName = self.opSplitBodyCarving.CurrentEditingFragment.value
if currentFragmentName != "":
QMessageBox.warning(self,
"Unsaved Fragment",
"Please save or delete the fragment you are editing ({}) "\
"before moving on to a different raveler body.".format( currentFragmentName ) )
return
else:
self.opSplitBodyCarving.CurrentRavelerLabel.setValue( ravelerLabel )
self.navigationRequested.emit( coord3d )
self._reloadBodyTree()
def _reloadInfoWidgets(self):
self._reloadBodyTree()
self._reloadAnnotationTable()
def _reloadBodyTree(self):
self.bodyTreeWidget.clear()
self._bodyTreeParentItems = {}
currentEditingRavelerLabel = self.opSplitBodyCarving.CurrentRavelerLabel.value
currentEditingFragmentName = self.opSplitBodyCarving.CurrentEditingFragment.value
for ravelerLabel in sorted( self._ravelerLabels ):
fragmentNames = self.opSplitBodyCarving.getFragmentNames(ravelerLabel)
# For this raveler label, how many fragments do we have and how many do we expect?
# Count the number of annotations with this label.
num_splits = reduce( lambda count, ann: count + (ann.ravelerLabel == ravelerLabel),
self._annotations.values(),
0 )
num_expected = num_splits + 1
num_fragments = len(fragmentNames)
# Parent row for the raveler body
progressText = "({}/{})".format( num_fragments, num_expected )
bodyItem = QTreeWidgetItem( ["{}".format(ravelerLabel),
progressText,
""] )
bodyItem.setData( 0, Qt.UserRole, ravelerLabel )
self._bodyTreeParentItems[ravelerLabel] = bodyItem
self.bodyTreeWidget.invisibleRootItem().addChild(bodyItem)
progressBar = BodyProgressBar(self)
progressBar.setMaximum( num_expected )
progressBar.setValue( min( num_fragments, num_expected ) )
progressBar.setText( progressText )
self.bodyTreeWidget.setItemWidget( bodyItem, BodyTreeColumns.Button1, progressBar )
if currentEditingFragmentName == "" and currentEditingRavelerLabel == ravelerLabel:
selectButton = QPushButton( "New Fragment" )
selectButton.pressed.connect( partial( self._startNewFragment, ravelerLabel ) )
selectButton.setIcon( QIcon(ilastikIcons.AddSel) )
self.bodyTreeWidget.setItemWidget( bodyItem, BodyTreeColumns.Button2, selectButton )
bodyItem.setExpanded(True)
# Child rows for each fragment
fragmentItem = None
for fragmentName in fragmentNames:
fragmentItem = QTreeWidgetItem( [fragmentName, "", ""] )
bodyItem.addChild( fragmentItem )
# Add 'edit' and 'delete' buttons to the LAST fragment item
if fragmentItem is not None and ravelerLabel == currentEditingRavelerLabel:
assert fragmentName is not None
if currentEditingFragmentName == fragmentName:
saveButton = QPushButton( "Save" )
saveButton.pressed.connect( partial( self._saveFragment, fragmentName ) )
saveButton.setIcon( QIcon(ilastikIcons.Save) )
self.bodyTreeWidget.setItemWidget( fragmentItem, BodyTreeColumns.Button1, saveButton )
elif currentEditingFragmentName == "":
editButton = QPushButton( "Edit" )
editButton.pressed.connect( partial( self._editFragment, fragmentName ) )
editButton.setIcon( QIcon(ilastikIcons.Edit) )
self.bodyTreeWidget.setItemWidget( fragmentItem, BodyTreeColumns.Button1, editButton )
if currentEditingFragmentName == "" or currentEditingFragmentName == fragmentName:
deleteButton = QPushButton( "Delete" )
deleteButton.pressed.connect( partial( self._deleteFragment, fragmentName ) )
deleteButton.setIcon( QIcon(ilastikIcons.RemSel) )
self.bodyTreeWidget.setItemWidget( fragmentItem, BodyTreeColumns.Button2, deleteButton )
def _initAnnotationTableHeader(self):
self.annotationTableWidget.setHorizontalHeaderLabels( ['Original Body', 'Coordinates', 'Comment'] )
self.annotationTableWidget.horizontalHeaderItem(AnnotationTableColumns.Comment).setTextAlignment(Qt.AlignLeft)
def _reloadAnnotationTable(self):
self.annotationTableWidget.clear()
self.annotationTableWidget.setRowCount( len(self._annotations) )
self._initAnnotationTableHeader()
# Flip the key/value of the annotation list so we can sort them by label
annotations = self._annotations.items()
annotations = map( lambda (coord3d, (label,comment)): (label, coord3d, comment), annotations )
annotations = sorted( annotations )
for row, (ravelerLabel, coord3d, comment) in enumerate( annotations ):
coordItem = QTableWidgetItem( "{}".format( coord3d ) )
labelItem = QTableWidgetItem( "{}".format( ravelerLabel ) )
commentItem = QTableWidgetItem( comment )
coordItem.setData( Qt.UserRole, ( coord3d, ravelerLabel ) )
labelItem.setData( Qt.UserRole, ( coord3d, ravelerLabel ) )
commentItem.setData( Qt.UserRole, ( coord3d, ravelerLabel ) )
self.annotationTableWidget.setItem( row, AnnotationTableColumns.Coordinates, coordItem )
self.annotationTableWidget.setItem( row, AnnotationTableColumns.Body, labelItem )
self.annotationTableWidget.setItem( row, AnnotationTableColumns.Comment, commentItem )
def _startNewFragment(self, ravelerLabel):
self.opSplitBodyCarving.CurrentRavelerLabel.setValue( ravelerLabel )
fragmentName = self._getNextAvailableFragmentName( ravelerLabel )
self.opSplitBodyCarving.CurrentEditingFragment.setValue( fragmentName )
# Refresh the entire table.
self._reloadBodyTree()
def _getNextAvailableFragmentName(self, ravelerLabel):
fragmentNames = self.opSplitBodyCarving.getFragmentNames(ravelerLabel)
if len(fragmentNames) == 0:
return "{}.A".format( ravelerLabel )
# Find the last name and increment the fragment letter
# e.g. 4321.B --> 4321.C
fragmentNames = sorted(fragmentNames)
assert len(fragmentNames) < 25, "Need to refine fragment naming scheme. The current scheme only supports up to 26 fragments."
letter = fragmentNames[-1][-1]
nextLetter = chr( ord(letter)+1 )
return "{}.{}".format( ravelerLabel, nextLetter )
def _editFragment(self, fragmentName):
self.opSplitBodyCarving.CurrentEditingFragment.setValue( fragmentName )
self.opSplitBodyCarving.loadObject( fragmentName )
self._reloadBodyTree()
def _deleteFragment(self, fragmentName):
# This might be the "current object" that we're deleting.
# That's okay.
if self.opSplitBodyCarving.CurrentEditingFragment.value == fragmentName:
self.opSplitBodyCarving.CurrentEditingFragment.setValue( "" )
# Attempt to delete the object.
if not self.opSplitBodyCarving.deleteObject( fragmentName ):
# If it wasn't there, then we still need to delete the seeds
self.opSplitBodyCarving.clearCurrentLabeling()
self._reloadBodyTree()
def _saveFragment(self, fragmentName):
self.opSplitBodyCarving.CurrentEditingFragment.setValue( "" )
self.opSplitBodyCarving.saveObjectAs( fragmentName )
# After save, there is no longer a "current object"
self._reloadBodyTree()
|
gpl-3.0
|
[
11490,
199,
3,
257,
284,
2019,
3258,
26,
12777,
9328,
436,
27315,
4744,
6065,
199,
3,
199,
3,
755,
1898,
334,
35,
9,
7760,
13,
7280,
12,
314,
284,
2019,
3258,
19782,
199,
3,
13293,
665,
5969,
32,
382,
1810,
3258,
14,
1308,
30,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1010,
10234,
12,
465,
282,
4539,
1919,
12,
314,
4248,
31976,
402,
199,
3,
284,
2019,
3258,
8120,
1265,
4983,
370,
13323,
284,
2019,
3258,
543,
1145,
16537,
12,
199,
3,
10431,
83,
436,
8963,
1314,
787,
440,
24295,
1334,
314,
1664,
199,
3,
1696,
1684,
844,
14,
199,
3,
199,
3,
1666,
314,
5113,
570,
367,
2436,
14,
844,
2556,
365,
2597,
2808,
199,
3,
641,
314,
284,
2019,
3258,
3330,
4770,
737,
26,
199,
3,
1057,
257,
1455,
921,
382,
1810,
3258,
14,
1308,
15,
1682,
14,
1360,
199,
11490,
199,
646,
984,
199,
646,
747,
199,
504,
9143,
492,
7417,
199,
199,
504,
14084,
20,
492,
399,
530,
199,
504,
14084,
20,
14,
10901,
492,
3959,
12,
27149,
11274,
199,
504,
14084,
20,
14,
10604,
492,
1413,
3339,
12,
1413,
25213,
12,
25159,
12,
1413,
3987,
29035,
12,
1413,
3186,
29035,
12,
971,
717,
1413,
20083,
12,
1413,
3186,
2768,
12,
1413,
2567,
2768,
12,
1413,
8954,
12,
1413,
11504,
5281,
199,
199,
504,
5236,
453,
13765,
14,
16877,
492,
3752,
63,
504,
63,
81,
875,
12,
4849,
63,
475,
63,
81,
875,
199,
504,
284,
2019,
3258,
14,
5641,
14,
5885,
14,
4677,
20752,
492,
284,
2019,
3258,
41,
8704,
199,
504,
284,
2019,
3258,
14,
16877,
492,
943,
63,
1971,
199,
199,
504,
1687,
4003,
21761,
1298,
492,
9319,
4003,
21761,
1298,
199,
199,
646,
2050,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
533,
29665,
11504,
5281,
8,
49,
11504,
5281,
304,
2286,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
29665,
11504,
5281,
12,
291,
221,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
505,
275,
3087,
2286,
347,
663,
1872,
8,
277,
12,
1318,
304,
267,
291,
423,
505,
275,
1318,
2286,
347,
1318,
8,
277,
304,
267,
372,
291,
423,
505,
199,
199,
533,
29665,
3987,
15086,
837,
272,
2870,
275,
378,
272,
16005,
17,
275,
413,
272,
16005,
18,
275,
499,
199,
199,
533,
30793,
3186,
15086,
837,
272,
29665,
275,
378,
272,
25334,
2335,
275,
413,
272,
6819,
275,
499,
199,
199,
533,
29665,
8862,
2354,
3339,
8,
1413,
3339,
3461,
2286,
19191,
17935,
275,
27149,
11274,
8,
785,
9,
327,
334,
19,
68,
10021,
2008,
9,
2286,
347,
636,
826,
721,
277,
12,
1676,
12,
1687,
8862,
8173,
16034,
4007,
304,
267,
327,
2136,
2793,
1133,
986,
1676,
370,
314,
1413,
3339,
2952,
781,
2934,
314,
4353,
370,
506,
2746,
13,
1896,
267,
1613,
8,
29665,
8862,
2354,
3339,
12,
291,
221,
2843,
826,
4533,
4960,
291,
14,
411,
8862,
8173,
16034,
4007,
275,
1687,
8862,
8173,
16034,
4007,
267,
291,
423,
2030,
3987,
6652,
7412,
275,
1052,
327,
961,
365,
14905,
370,
11075,
2419,
1808,
663,
1451,
15,
1623,
2728,
291,
423,
9340,
63,
7218,
275,
488,
267,
340,
291,
14,
411,
8862,
8173,
16034,
4007,
14,
16768,
1173,
515,
14,
2179,
837,
288,
291,
423,
9340,
63,
7218,
275,
291,
14,
411,
8862,
8173,
16034,
4007,
14,
16768,
1173,
515,
14,
585,
267,
291,
423,
11270,
275,
1052,
327,
10021,
520,
30793,
267,
291,
423,
345,
432,
1435,
14016,
275,
663,
342,
2728,
291,
423,
826,
18203,
342,
2728,
340,
291,
423,
9340,
63,
7218,
365,
440,
488,
26,
288,
291,
423,
912,
16768,
1173,
8,
291,
423,
9340,
63,
7218,
776,
267,
291,
14,
6635,
4259,
14,
14329,
8,
291,
423,
9340,
63,
7218,
365,
440,
488,
776,
2378,
347,
485,
826,
18203,
8,
277,
304,
267,
327,
7190,
314,
8574,
570,
1901,
642,
1021,
334,
1623,
652,
315,
4154,
5705,
2082,
9,
267,
2257,
3567,
275,
747,
14,
515,
14,
1294,
3460,
493,
363,
2788,
16,
61,
267,
8574,
14225,
275,
747,
14,
515,
14,
904,
8,
2257,
3567,
12,
283,
2030,
8862,
2354,
3339,
14,
1907,
7,
776,
267,
399,
530,
14,
912,
18203,
8,
1907,
14225,
12,
291,
9,
2728,
291,
14,
30601,
480,
8173,
11740,
10332,
531,
2728,
291,
14,
2030,
3987,
3339,
14,
409,
2567,
14016,
8,
788,
8173,
2870,
297,
283,
11504,
297,
28696,
776,
267,
291,
14,
2030,
3987,
3339,
14,
1291,
1252,
409,
24559,
1385,
8,
1413,
2567,
2768,
14,
24559,
1378,
11383,
776,
267,
291,
14,
2030,
3987,
3339,
14,
1291,
1252,
409,
21537,
6090,
8660,
8,
797,
9,
267,
291,
14,
2030,
3987,
3339,
14,
1053,
7281,
31483,
14,
2242,
8,
291,
423,
2479,
8173,
3987,
7281,
12040,
776,
267,
291,
14,
2030,
3987,
3339,
14,
409,
4527,
5915,
3314,
7281,
12040,
8,
797,
9,
327,
2136,
2934,
370,
675,
4270,
13,
4891,
367,
2599,
13,
24148,
30712,
291,
14,
9340,
3186,
3339,
14,
409,
4547,
2353,
8,
19,
9,
267,
291,
423,
826,
16768,
3186,
2567,
342,
267,
291,
14,
9340,
3186,
3339,
14,
1053,
7281,
31483,
14,
2242,
8,
291,
423,
2479,
16768,
7281,
12040,
776,
267,
291,
14,
9340,
3186,
3339,
14,
409,
7713,
25361,
8,
1413,
3186,
2768,
14,
5446,
13405,
776,
267,
291,
14,
9340,
3186,
3339,
14,
11392,
2567,
1252,
409,
24559,
1385,
8,
1413,
2567,
2768,
14,
24559,
1378,
11383,
776,
2728,
291,
14,
912,
8862,
2493,
889,
425,
1173,
4259,
14,
30455,
14,
2242,
8,
291,
423,
912,
4665,
16768,
1173,
776,
267,
291,
14,
912,
8862,
2493,
889,
425,
1173,
4259,
14,
27668,
8,
1413,
8954,
8,
382,
1810,
3258,
41,
8704,
14,
4299,
9,
776,
398,
291,
14,
6635,
4259,
14,
30455,
14,
2242,
8,
291,
423,
6635,
21761,
1298,
776,
267,
291,
14,
6635,
4259,
14,
27668,
8
] |
[
199,
3,
257,
284,
2019,
3258,
26,
12777,
9328,
436,
27315,
4744,
6065,
199,
3,
199,
3,
755,
1898,
334,
35,
9,
7760,
13,
7280,
12,
314,
284,
2019,
3258,
19782,
199,
3,
13293,
665,
5969,
32,
382,
1810,
3258,
14,
1308,
30,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1010,
10234,
12,
465,
282,
4539,
1919,
12,
314,
4248,
31976,
402,
199,
3,
284,
2019,
3258,
8120,
1265,
4983,
370,
13323,
284,
2019,
3258,
543,
1145,
16537,
12,
199,
3,
10431,
83,
436,
8963,
1314,
787,
440,
24295,
1334,
314,
1664,
199,
3,
1696,
1684,
844,
14,
199,
3,
199,
3,
1666,
314,
5113,
570,
367,
2436,
14,
844,
2556,
365,
2597,
2808,
199,
3,
641,
314,
284,
2019,
3258,
3330,
4770,
737,
26,
199,
3,
1057,
257,
1455,
921,
382,
1810,
3258,
14,
1308,
15,
1682,
14,
1360,
199,
11490,
199,
646,
984,
199,
646,
747,
199,
504,
9143,
492,
7417,
199,
199,
504,
14084,
20,
492,
399,
530,
199,
504,
14084,
20,
14,
10901,
492,
3959,
12,
27149,
11274,
199,
504,
14084,
20,
14,
10604,
492,
1413,
3339,
12,
1413,
25213,
12,
25159,
12,
1413,
3987,
29035,
12,
1413,
3186,
29035,
12,
971,
717,
1413,
20083,
12,
1413,
3186,
2768,
12,
1413,
2567,
2768,
12,
1413,
8954,
12,
1413,
11504,
5281,
199,
199,
504,
5236,
453,
13765,
14,
16877,
492,
3752,
63,
504,
63,
81,
875,
12,
4849,
63,
475,
63,
81,
875,
199,
504,
284,
2019,
3258,
14,
5641,
14,
5885,
14,
4677,
20752,
492,
284,
2019,
3258,
41,
8704,
199,
504,
284,
2019,
3258,
14,
16877,
492,
943,
63,
1971,
199,
199,
504,
1687,
4003,
21761,
1298,
492,
9319,
4003,
21761,
1298,
199,
199,
646,
2050,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
533,
29665,
11504,
5281,
8,
49,
11504,
5281,
304,
2286,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
29665,
11504,
5281,
12,
291,
221,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
423,
505,
275,
3087,
2286,
347,
663,
1872,
8,
277,
12,
1318,
304,
267,
291,
423,
505,
275,
1318,
2286,
347,
1318,
8,
277,
304,
267,
372,
291,
423,
505,
199,
199,
533,
29665,
3987,
15086,
837,
272,
2870,
275,
378,
272,
16005,
17,
275,
413,
272,
16005,
18,
275,
499,
199,
199,
533,
30793,
3186,
15086,
837,
272,
29665,
275,
378,
272,
25334,
2335,
275,
413,
272,
6819,
275,
499,
199,
199,
533,
29665,
8862,
2354,
3339,
8,
1413,
3339,
3461,
2286,
19191,
17935,
275,
27149,
11274,
8,
785,
9,
327,
334,
19,
68,
10021,
2008,
9,
2286,
347,
636,
826,
721,
277,
12,
1676,
12,
1687,
8862,
8173,
16034,
4007,
304,
267,
327,
2136,
2793,
1133,
986,
1676,
370,
314,
1413,
3339,
2952,
781,
2934,
314,
4353,
370,
506,
2746,
13,
1896,
267,
1613,
8,
29665,
8862,
2354,
3339,
12,
291,
221,
2843,
826,
4533,
4960,
291,
14,
411,
8862,
8173,
16034,
4007,
275,
1687,
8862,
8173,
16034,
4007,
267,
291,
423,
2030,
3987,
6652,
7412,
275,
1052,
327,
961,
365,
14905,
370,
11075,
2419,
1808,
663,
1451,
15,
1623,
2728,
291,
423,
9340,
63,
7218,
275,
488,
267,
340,
291,
14,
411,
8862,
8173,
16034,
4007,
14,
16768,
1173,
515,
14,
2179,
837,
288,
291,
423,
9340,
63,
7218,
275,
291,
14,
411,
8862,
8173,
16034,
4007,
14,
16768,
1173,
515,
14,
585,
267,
291,
423,
11270,
275,
1052,
327,
10021,
520,
30793,
267,
291,
423,
345,
432,
1435,
14016,
275,
663,
342,
2728,
291,
423,
826,
18203,
342,
2728,
340,
291,
423,
9340,
63,
7218,
365,
440,
488,
26,
288,
291,
423,
912,
16768,
1173,
8,
291,
423,
9340,
63,
7218,
776,
267,
291,
14,
6635,
4259,
14,
14329,
8,
291,
423,
9340,
63,
7218,
365,
440,
488,
776,
2378,
347,
485,
826,
18203,
8,
277,
304,
267,
327,
7190,
314,
8574,
570,
1901,
642,
1021,
334,
1623,
652,
315,
4154,
5705,
2082,
9,
267,
2257,
3567,
275,
747,
14,
515,
14,
1294,
3460,
493,
363,
2788,
16,
61,
267,
8574,
14225,
275,
747,
14,
515,
14,
904,
8,
2257,
3567,
12,
283,
2030,
8862,
2354,
3339,
14,
1907,
7,
776,
267,
399,
530,
14,
912,
18203,
8,
1907,
14225,
12,
291,
9,
2728,
291,
14,
30601,
480,
8173,
11740,
10332,
531,
2728,
291,
14,
2030,
3987,
3339,
14,
409,
2567,
14016,
8,
788,
8173,
2870,
297,
283,
11504,
297,
28696,
776,
267,
291,
14,
2030,
3987,
3339,
14,
1291,
1252,
409,
24559,
1385,
8,
1413,
2567,
2768,
14,
24559,
1378,
11383,
776,
267,
291,
14,
2030,
3987,
3339,
14,
1291,
1252,
409,
21537,
6090,
8660,
8,
797,
9,
267,
291,
14,
2030,
3987,
3339,
14,
1053,
7281,
31483,
14,
2242,
8,
291,
423,
2479,
8173,
3987,
7281,
12040,
776,
267,
291,
14,
2030,
3987,
3339,
14,
409,
4527,
5915,
3314,
7281,
12040,
8,
797,
9,
327,
2136,
2934,
370,
675,
4270,
13,
4891,
367,
2599,
13,
24148,
30712,
291,
14,
9340,
3186,
3339,
14,
409,
4547,
2353,
8,
19,
9,
267,
291,
423,
826,
16768,
3186,
2567,
342,
267,
291,
14,
9340,
3186,
3339,
14,
1053,
7281,
31483,
14,
2242,
8,
291,
423,
2479,
16768,
7281,
12040,
776,
267,
291,
14,
9340,
3186,
3339,
14,
409,
7713,
25361,
8,
1413,
3186,
2768,
14,
5446,
13405,
776,
267,
291,
14,
9340,
3186,
3339,
14,
11392,
2567,
1252,
409,
24559,
1385,
8,
1413,
2567,
2768,
14,
24559,
1378,
11383,
776,
2728,
291,
14,
912,
8862,
2493,
889,
425,
1173,
4259,
14,
30455,
14,
2242,
8,
291,
423,
912,
4665,
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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
scizen9/kpy
|
SEDM/Extract.py
|
2
|
12501
|
# Code by Nick Konidaris
# (c) 2014
#
# nick.konidaris@gmail.com
# For the SED Machine Spectrograph
#
import IO
import numpy as np
import scipy as sp
import pylab as pl
import scipy.signal
import scipy.spatial
from scipy.interpolate import interp1d
from SEDM import Flexure as FF
reload (IO)
def lambda_to_dlambda(lam):
"""Extraploate dlambda of array"""
dlam = np.diff(lam)
ok = np.isfinite(dlam)
xx = np.arange(len(dlam))
try:
dlamf = np.poly1d(np.polyfit(xx[ok],
dlam[ok],
4))
except:
import pdb
pdb.set_trace()
dlam = dlamf( np.arange(len(lam)))
return dlam
def segmap_to_kdtree(SegMap, positions=('OnSkyX','OnSkyY'),
signal_field='SpexSpecFit'):
"""Creates a segmentation map KD Tree
Args:
SegMap: The segmentation map
positions: The position of the trace in either arcsec ('OnSkyX',
'OnSkyY') or pixels ('MeanX', 'MeanY')
Returns a scipy.spatial.KDTree
"""
data = []
oks = []
for i in xrange(len(SegMap)):
seg = SegMap[i][0]
x = seg[positions[0]][0][0]
y = seg[positions[1]][0][0]
if np.isfinite(x) and np.isfinite(y):
oks.append(i)
data.append( (x,y ))
kt = scipy.spatial.KDTree(np.array(data))
return kt, oks
def spectra_in_annulus(KT, SegMap, X, Y, small=200, large=300, ixmap=None,
pixel_shift=0):
"""Queries the KD tree for points within the annulus, returns the spectra.
Args:
KT: The KD tree. This can be created in segmap_to_kdtree
SegMap: The segmentation map
X,Y: The X/Y position of the spectrum to extract
small,large: The near and far distances of the annulus
ixmap: The map of KT.data to SegMap
pixel_shift: For flexure correction, the number of pixels to shift
the wavelength solution
Returns a list of (Wavelength, Spectra). E.g.:
[ [array(365 .. 1000) , array( 50 .. 63)] ,
[array(366 .. 1001) , array( 53 .. 61)] ,
]
"""
near = set(KT.query_ball_point( (X, Y), small/2))
far = set(KT.query_ball_point( (X, Y), large/2))
if ixmap is None: ixmap = range(len(SegMap))
in_annulus = far.difference(near)
results = []
for index in in_annulus:
ix = ixmap[index]
try: lam = SegMap[ix]['WaveCalib'][0][0][:]
except: continue
lam = FF.shift_pixels(lam, pixel_shift)
results.append( [lam,
SegMap[ix]['SpexSpecFit'][0][0],
ix])
return results
def sky_median(KT, SegMap, X=2, Y=10, distance=7, ixmap=None, pixel_shift=0):
"""Generates a median spectrum estimating the "sky".
Args:
KT: The KD tree. This can be created in segmap_to_kdtree
SegMap: The segmentation map
X,Y: The X/Y position of the spectrum to extract. Default is middle.
distance: Distance to the spaxel in pixels. Default is 900
pixel_shift: For flexure correction, the number of pixels to shift
the wavelength solution
Returns:
{'wave_nm': wavelength of sky spectrum,
'spec_adu', the median sky spectrum,
'all_spec': and a matrix of spectra,
'num_spec': The number of spectra}
"""
specs = spectra_near_position(KT, SegMap, X, Y, distance, ixmap=None,
pixel_shift=pixel_shift)
return interp_and_sum_spectra(specs)
def spectra_near_position(KT, SegMap, X, Y, distance=2, ixmap=None,
pixel_shift = 0):
"""Queries the KD tree for points near the source, returns the spectra.
Args:
KT: The KD tree. This can be created in segmap_to_kdtree
SegMap: The segmentation map
X,Y: The X/Y position of the spectrum to extract
distance: Distance to the spaxel in pixels. Default is 100
ixmap: The mapping of index from KT.data to SegMap
pixel_shift: For flexure correction, the number of pixels to shift
the wavelength solution
Returns a list of (Wavelength, Spectra, SegMap index). E.g.:
[ [array(365 .. 1000) , array( 50 .. 63)] ,
[array(366 .. 1001) , array( 53 .. 61)] ,
]
"""
print "query in ", distance/2
ixs = KT.query_ball_point( (X, Y), distance/2)
if ixmap is None:
ixmap = range(len(SegMap))
results = []
for index in ixs:
ix = ixmap[index]
if len(SegMap[ix]['WaveCalib'][0]) == 0:
continue
lam = SegMap[ix]['WaveCalib'][0][0][:]
lam = FF.shift_pixels(lam, pixel_shift)
results.append( [lam,
SegMap[ix]['SpexSpecFit'][0][0],
ix])
return results
def interp_and_sum_spectra(specs, sky_spec = None, onto=None):
"""Sums and interpolates spectra to a common grid.
The result of spectra_near_pixel are interpolated to a common grid and summed.
If a sky spectrum is provided it is subtracted off of each spectrum.
Args:
specs: List of spectra. Each spectrum is a (wavelength, flux) tuple.
sky_spec: (Wave, Spec) of sky spectrum to be subtracted off
onto: The wavelengths on which to interpolate the spectrum
Returns:
{'wave_nm': wavelength, # in nm
'spec_adu': spectrum, # in adu
'num_spec': total # of spectra participating
'all_spec': array of [nwave, nspec] interpolated onto same grid
'segments': array of [nspec] segment numbers}
"""
# for now, assume the first spectrum has a good wavelength range
# TODO: challenge assumption in comment above
wave = specs[0][0][::-1]
spec = specs[0][1][::-1]
minw = np.nanmin(wave)
maxw = np.nanmax(wave)
# For debugging purposes, get rid of the dlam part
_use_dlam = True
if onto is not None:
# Interpolate onto a specified grid
specfun = interp1d(wave, spec, bounds_error=False, fill_value=0)
spec = specfun(onto)
wave = onto[:]
all = np.zeros((len(wave) , len(specs)))
if sky_spec is not None:
sky_wave, sky_spec = sky_spec
if _use_dlam: dlamsky = lambda_to_dlambda(sky_wave)
else: dlamsky = 1.0
skyf = interp1d(sky_wave, sky_spec/dlamsky,
bounds_error=False, fill_value=0.0)
nspec = np.ones(len(spec), dtype=np.int)
for i in xrange(1, len(specs)):
lam = specs[i][0][::-1]
ss = specs[i][1][::-1]
if _use_dlam:
dlam = lambda_to_dlambda(lam)
dlamf = interp1d(lam, dlam, bounds_error=False,
fill_value=0.0)
else:
dlam = 1.0
dlamf = lambda x: 1.0
ok = np.isfinite(lam) & np.isfinite(ss) & \
(lam > minw) & (lam < maxw)
if not np.any(ok):
print "passing"
continue
interp_fun = interp1d(lam[ok], ss[ok], bounds_error=False,
fill_value = np.nan)
if sky_spec is None:
the_spec = interp_fun(wave)
else:
the_spec = interp_fun(wave) - skyf(wave)*dlamf(wave)
all[:,i] = the_spec
ok2 = np.isfinite(the_spec)
nspec[ok2] += 1
return {'wave_nm': wave,
'spec_adu': np.nansum(all, axis=1),
'num_spec': len(spec),
'all_spec': all}
def segmap_to_img(SegMap, sky_spec=None, minl=500, maxl=750,
signal_field='SpexSpecFit', positions=('OnSkyX', 'OnSkyY')):
"""Take seg.Mean[XY] and return an image of the Segmentation Map.
Creates a tesselated hexagon image of the segmentation map.
Args:
seg: The segmentation map
sky_spec: A 2-tuple of (Wavelength, Spectrum) representing the night
sky spectrum per spaxel. If none does nothing, if set subtracts
from the spectrum before summing.
minl/maxl: The minimum and maximum wavelength over which to take
the median
signal_field: String containing the field to extract signal from
defaults to SpexSpecFit, could also be SpexSpecCenter
positions: The position of the trace in either arcsec ('OnSkyX',
'OnSkyY') or pixels ('MeanX', 'MeanY')
Returns:
A three-tuple of numpy array. Format is (X positions, Y positions, Values)
Values represent median value of the spectrum between minl and maxl
"""
_use_dlam = True
Xs = []
Ys = []
Values = []
if sky_spec is not None:
print "Subtracting sky in creating image"
sky_wave, sky_spec = sky_spec
if _use_dlam: dlamsky = lambda_to_dlambda(sky_wave)
else: dlamsky = 1
skyf = interp1d(sky_wave, sky_spec/dlamsky, bounds_error=False,
fill_value=0.0)
if _use_dlam:
dlamskyf = interp1d(sky_wave, dlamsky, bounds_error=False,
fill_value=0.0)
else:
dlamskyf = lambda x: 1.0
minw = np.nanmin(sky_wave)
maxw = np.nanmax(sky_wave)
for i in xrange(len(SegMap)):
seg = SegMap[i][0]
if len(seg['WaveCalib']) == 0:
Xs.append(seg[positions[0]][0][0])
Ys.append(seg[positions[1]][0][0])
Values.append(np.nan)
continue
wave = seg['WaveCalib'][0][::-1]
spec = seg[signal_field][0][::-1]
if len(wave) < 10:
Xs.append(seg[positions[0]][0][0])
Ys.append(seg[positions[1]][0][0])
Values.append(np.nan)
continue
roi = (wave > minl) & (wave < maxl)
Xs.append(seg[positions[0]][0][0])
Ys.append(seg[positions[1]][0][0])
if sky_spec is None:
Values.append(np.sum(spec[roi]))
else:
try:
ok = np.isfinite(wave) & np.isfinite(spec) & \
(wave > minw) & (wave < maxw) & (wave > minl) & \
(wave < maxl)
except:
import pdb
pdb.set_trace()
if not np.any(ok):
Values.append(np.sum(skyf(wave)))
continue
if _use_dlam: dlam = lambda_to_dlambda(wave)
else: dlam = 1.0
local_sky = skyf(wave) * dlamskyf(wave)
#local_sky = skyf(wave[ok])
Values.append(np.median(spec[ok] - local_sky[ok]))
Xs,Ys,Values = map(np.array, (Xs, Ys, Values))
return (Xs, Ys, Values)
def cub_to_img(cub):
shp = cub["Cube"].shape
skys = med_spec(cub)
img = np.zeros((shp[1], shp[2]))
for i in xrange(shp[1]):
for j in xrange(shp[2]):
ms = sp.signal.medfilt(cub["Cube"][:,i,j], 3)
ms = cub["Cube"][:,i,j]
img[i,j] = np.sum(ms - skys)
return img
def go(fname):
cub = IO.load_cube(fname)
img = cub_to_img(cub)
return img
def med_spec(cub):
shp = cub["Cube"].shape
AllSpec = np.zeros((shp[0], shp[1] * shp[2]))
cnt = 0
for i in xrange(shp[1]):
for j in xrange(shp[2]):
s = cub["Cube"][:,i,j]
if np.any(np.isfinite(s)):
AllSpec[:, cnt] = cub["Cube"][:,i,j]
cnt += 1
ms = np.median(AllSpec[:,0:cnt],axis=1)
print cnt
return ms
def avg_spec(cub):
shp = cub["Cube"].shape
Spec = np.zeros(shp[0])
Nok = np.zeros(shp[0])
for i in xrange(shp[1]):
for j in xrange(shp[2]):
s = cub["Cube"][:,i,j]
ok = np.where(np.isfinite(s))
Spec[ok] += s[ok]
Nok[ok] += 1
pl.plot(Spec/Nok)
return Spec/Nok
def extract(cub, x, y, aper=[5,8,12]):
x,y = map(np.round, [x,y])
shp = cub["Cube"].shape
XX, YY = np.meshgrid(np.arange(shp[1]), np.arange(shp[2]))
d = np.sqrt(((XX-x)**2 + (YY-y)**2))
obj = np.where(d <= aper[0])
sky = np.where((aper[1] <= d) & (d <= aper[2]))
Object = np.zeros(shp[0])
Sky = np.zeros(shp[0])
Nobj = len(obj[0])
Nsky = len(sky[0])
for i in xrange(Nobj):
x,y = obj[0][i],obj[1][i]
Object += cub["Cube"][:,x,y]
for i in xrange(Nsky):
x,y = sky[0][i],sky[1][i]
Sky += cub["Cube"][:,x,y]
print Nsky, Nobj
pl.figure(3)
pl.clf()
pl.plot(Object - Sky/Nsky*Nobj)
|
gpl-2.0
|
[
3,
5495,
701,
653,
2000,
1804,
265,
344,
4663,
199,
3,
334,
67,
9,
6927,
199,
3,
199,
3,
14900,
14,
75,
265,
344,
4663,
32,
6799,
14,
957,
199,
3,
2104,
314,
428,
1149,
18722,
428,
1764,
293,
2180,
199,
3,
199,
199,
646,
5004,
199,
646,
2680,
465,
980,
199,
646,
7026,
465,
2249,
199,
646,
19199,
465,
1620,
199,
199,
646,
7026,
14,
4653,
199,
646,
7026,
14,
11679,
199,
504,
7026,
14,
21294,
492,
23716,
17,
68,
199,
199,
504,
428,
1149,
45,
492,
481,
3113,
608,
465,
25046,
199,
199,
9233,
334,
2090,
9,
199,
199,
318,
2400,
63,
475,
63,
68,
2734,
8,
17984,
304,
272,
408,
4942,
1330,
320,
323,
366,
2734,
402,
1625,
624,
339,
366,
17984,
275,
980,
14,
3028,
8,
17984,
9,
272,
4112,
275,
980,
14,
30276,
8,
68,
17984,
9,
272,
19379,
275,
980,
14,
5605,
8,
552,
8,
68,
17984,
430,
272,
862,
26,
267,
366,
416,
11821,
275,
980,
14,
6023,
17,
68,
8,
1590,
14,
6023,
3269,
8,
2154,
59,
745,
467,
1816,
366,
17984,
59,
745,
467,
1816,
841,
430,
272,
871,
26,
267,
492,
10543,
267,
10543,
14,
409,
63,
3446,
342,
339,
366,
17984,
275,
366,
416,
11821,
8,
980,
14,
5605,
8,
552,
8,
17984,
1724,
339,
372,
366,
17984,
4388,
199,
318,
8812,
1130,
63,
475,
63,
25606,
2350,
8,
19689,
2956,
12,
12266,
7782,
3314,
51,
10562,
56,
1673,
3314,
51,
10562,
57,
659,
267,
4673,
63,
698,
534,
51,
16531,
5307,
13776,
735,
272,
408,
10607,
282,
27315,
2341,
31368,
12178,
339,
3033,
26,
267,
3240,
71,
2956,
26,
710,
27315,
2341,
267,
12266,
26,
710,
3421,
402,
314,
3307,
315,
1902,
14972,
3321,
661,
3314,
51,
10562,
56,
297,
288,
283,
3314,
51,
10562,
57,
358,
503,
11094,
661,
14825,
56,
297,
283,
14825,
57,
358,
339,
1803,
282,
7026,
14,
11679,
14,
13368,
3987,
272,
408,
272,
666,
275,
942,
272,
4112,
83,
275,
942,
272,
367,
284,
315,
4945,
8,
552,
8,
19689,
2956,
2298,
267,
8812,
275,
3240,
71,
2956,
59,
73,
1527,
16,
61,
398,
671,
275,
8812,
59,
12658,
59,
16,
22235,
16,
1527,
16,
61,
267,
612,
275,
8812,
59,
12658,
59,
17,
22235,
16,
1527,
16,
61,
398,
340,
980,
14,
30276,
8,
88,
9,
436,
980,
14,
30276,
8,
89,
304,
288,
4112,
83,
14,
740,
8,
73,
9,
288,
666,
14,
740,
8,
334,
88,
12,
89,
5082,
2378,
1022,
84,
275,
7026,
14,
11679,
14,
13368,
3987,
8,
1590,
14,
1144,
8,
576,
430,
272,
372,
1022,
84,
12,
4112,
83,
199,
199,
318,
30900,
345,
63,
262,
63,
1189,
15909,
8,
12362,
12,
3240,
71,
2956,
12,
1323,
12,
1488,
12,
7425,
29,
1840,
12,
7031,
29,
5863,
12,
20593,
1130,
29,
403,
12,
717,
7148,
63,
4723,
29,
16,
304,
272,
408,
13611,
314,
31368,
3123,
367,
4501,
4453,
314,
21172,
15909,
12,
2529,
314,
30900,
345,
14,
339,
3033,
26,
267,
1804,
52,
26,
710,
31368,
3123,
14,
961,
883,
506,
2737,
315,
8812,
1130,
63,
475,
63,
25606,
2350,
267,
3240,
71,
2956,
26,
710,
27315,
2341,
267,
1323,
12,
57,
26,
710,
1323,
15,
57,
3421,
402,
314,
20645,
370,
5536,
267,
7425,
12,
9629,
26,
710,
17429,
436,
12474,
15108,
402,
314,
21172,
15909,
267,
20593,
1130,
26,
710,
2341,
402,
1804,
52,
14,
576,
370,
3240,
71,
2956,
267,
7148,
63,
4723,
26,
2104,
20758,
608,
21940,
12,
314,
1329,
402,
11094,
370,
7706,
288,
314,
12204,
1267,
8744,
339,
1803,
282,
769,
402,
334,
21393,
1267,
12,
428,
1764,
345,
680,
662,
14,
71,
16781,
267,
359,
257,
359,
1144,
8,
12664,
2508,
5198,
9,
2360,
1625,
8,
5238,
2508,
13668,
1874,
2360,
288,
359,
1144,
8,
11065,
2508,
2948,
17,
9,
2360,
1625,
8,
13564,
2508,
17017,
1874,
2360,
288,
1622,
339,
408,
272,
17429,
275,
663,
8,
12362,
14,
1131,
63,
8571,
63,
1403,
8,
334,
56,
12,
1488,
395,
7425,
15,
18,
430,
272,
12474,
275,
663,
8,
12362,
14,
1131,
63,
8571,
63,
1403,
8,
334,
56,
12,
1488,
395,
7031,
15,
18,
430,
339,
340,
20593,
1130,
365,
488,
26,
20593,
1130,
275,
1425,
8,
552,
8,
19689,
2956,
430,
339,
315,
63,
1189,
15909,
275,
12474,
14,
9196,
8,
21078,
9,
272,
2058,
275,
942,
272,
367,
1478,
315,
315,
63,
1189,
15909,
26,
267,
20593,
275,
20593,
1130,
59,
1080,
61,
267,
862,
26,
25917,
275,
3240,
71,
2956,
59,
1148,
2733,
21393,
26015,
3488,
16,
1527,
16,
61,
5873,
267,
871,
26,
1980,
267,
25917,
275,
25046,
14,
4723,
63,
15727,
8,
17984,
12,
7148,
63,
4723,
9,
267,
2058,
14,
740,
8,
359,
17984,
12,
717,
3240,
71,
2956,
59,
1148,
2733,
51,
16531,
5307,
13776,
3488,
16,
1527,
16,
467,
717,
20593,
566,
339,
372,
2058,
4388,
199,
318,
2386,
89,
63,
13106,
8,
12362,
12,
3240,
71,
2956,
12,
1323,
29,
18,
12,
1488,
29,
709,
12,
6033,
29,
23,
12,
20593,
1130,
29,
403,
12,
7148,
63,
4723,
29,
16,
304,
272,
408,
20551,
282,
17312,
20645,
4347,
3969,
316,
314,
298,
12267,
1674,
339,
3033,
26,
267,
1804,
52,
26,
710,
31368,
3123,
14,
961,
883,
506,
2737,
315,
8812,
1130,
63,
475,
63,
25606,
2350,
267,
3240,
71,
2956,
26,
710,
27315,
2341,
267,
1323,
12,
57,
26,
710,
1323,
15,
57,
3421,
402,
314,
20645,
370,
5536,
14,
3758,
365,
12180,
14,
267,
6033,
26,
21892,
370,
314,
5844,
31418,
315,
11094,
14,
3758,
365,
27151,
267,
7148,
63,
4723,
26,
2104,
20758,
608,
21940,
12,
314,
1329,
402,
11094,
370,
7706,
288,
314,
12204,
1267,
8744,
339,
1803,
26,
267,
791,
10024,
63,
10756,
356,
12204,
1267,
402,
2386,
89,
20645,
12,
7205,
283,
1650,
63,
350,
85,
297,
314,
17312,
2386,
89,
20645,
12,
7205,
283,
452,
63,
1650,
356,
436,
282,
3634,
402,
30900,
345,
12,
288,
283,
1507,
63,
1650,
356,
710,
1329,
402,
30900,
345,
93,
339,
408,
339,
15941,
275,
30900,
345,
63,
21078,
63,
3124,
8,
12362,
12,
3240,
71,
2956,
12,
1323,
12,
1488,
12,
6033,
12,
20593,
1130,
29
] |
[
5495,
701,
653,
2000,
1804,
265,
344,
4663,
199,
3,
334,
67,
9,
6927,
199,
3,
199,
3,
14900,
14,
75,
265,
344,
4663,
32,
6799,
14,
957,
199,
3,
2104,
314,
428,
1149,
18722,
428,
1764,
293,
2180,
199,
3,
199,
199,
646,
5004,
199,
646,
2680,
465,
980,
199,
646,
7026,
465,
2249,
199,
646,
19199,
465,
1620,
199,
199,
646,
7026,
14,
4653,
199,
646,
7026,
14,
11679,
199,
504,
7026,
14,
21294,
492,
23716,
17,
68,
199,
199,
504,
428,
1149,
45,
492,
481,
3113,
608,
465,
25046,
199,
199,
9233,
334,
2090,
9,
199,
199,
318,
2400,
63,
475,
63,
68,
2734,
8,
17984,
304,
272,
408,
4942,
1330,
320,
323,
366,
2734,
402,
1625,
624,
339,
366,
17984,
275,
980,
14,
3028,
8,
17984,
9,
272,
4112,
275,
980,
14,
30276,
8,
68,
17984,
9,
272,
19379,
275,
980,
14,
5605,
8,
552,
8,
68,
17984,
430,
272,
862,
26,
267,
366,
416,
11821,
275,
980,
14,
6023,
17,
68,
8,
1590,
14,
6023,
3269,
8,
2154,
59,
745,
467,
1816,
366,
17984,
59,
745,
467,
1816,
841,
430,
272,
871,
26,
267,
492,
10543,
267,
10543,
14,
409,
63,
3446,
342,
339,
366,
17984,
275,
366,
416,
11821,
8,
980,
14,
5605,
8,
552,
8,
17984,
1724,
339,
372,
366,
17984,
4388,
199,
318,
8812,
1130,
63,
475,
63,
25606,
2350,
8,
19689,
2956,
12,
12266,
7782,
3314,
51,
10562,
56,
1673,
3314,
51,
10562,
57,
659,
267,
4673,
63,
698,
534,
51,
16531,
5307,
13776,
735,
272,
408,
10607,
282,
27315,
2341,
31368,
12178,
339,
3033,
26,
267,
3240,
71,
2956,
26,
710,
27315,
2341,
267,
12266,
26,
710,
3421,
402,
314,
3307,
315,
1902,
14972,
3321,
661,
3314,
51,
10562,
56,
297,
288,
283,
3314,
51,
10562,
57,
358,
503,
11094,
661,
14825,
56,
297,
283,
14825,
57,
358,
339,
1803,
282,
7026,
14,
11679,
14,
13368,
3987,
272,
408,
272,
666,
275,
942,
272,
4112,
83,
275,
942,
272,
367,
284,
315,
4945,
8,
552,
8,
19689,
2956,
2298,
267,
8812,
275,
3240,
71,
2956,
59,
73,
1527,
16,
61,
398,
671,
275,
8812,
59,
12658,
59,
16,
22235,
16,
1527,
16,
61,
267,
612,
275,
8812,
59,
12658,
59,
17,
22235,
16,
1527,
16,
61,
398,
340,
980,
14,
30276,
8,
88,
9,
436,
980,
14,
30276,
8,
89,
304,
288,
4112,
83,
14,
740,
8,
73,
9,
288,
666,
14,
740,
8,
334,
88,
12,
89,
5082,
2378,
1022,
84,
275,
7026,
14,
11679,
14,
13368,
3987,
8,
1590,
14,
1144,
8,
576,
430,
272,
372,
1022,
84,
12,
4112,
83,
199,
199,
318,
30900,
345,
63,
262,
63,
1189,
15909,
8,
12362,
12,
3240,
71,
2956,
12,
1323,
12,
1488,
12,
7425,
29,
1840,
12,
7031,
29,
5863,
12,
20593,
1130,
29,
403,
12,
717,
7148,
63,
4723,
29,
16,
304,
272,
408,
13611,
314,
31368,
3123,
367,
4501,
4453,
314,
21172,
15909,
12,
2529,
314,
30900,
345,
14,
339,
3033,
26,
267,
1804,
52,
26,
710,
31368,
3123,
14,
961,
883,
506,
2737,
315,
8812,
1130,
63,
475,
63,
25606,
2350,
267,
3240,
71,
2956,
26,
710,
27315,
2341,
267,
1323,
12,
57,
26,
710,
1323,
15,
57,
3421,
402,
314,
20645,
370,
5536,
267,
7425,
12,
9629,
26,
710,
17429,
436,
12474,
15108,
402,
314,
21172,
15909,
267,
20593,
1130,
26,
710,
2341,
402,
1804,
52,
14,
576,
370,
3240,
71,
2956,
267,
7148,
63,
4723,
26,
2104,
20758,
608,
21940,
12,
314,
1329,
402,
11094,
370,
7706,
288,
314,
12204,
1267,
8744,
339,
1803,
282,
769,
402,
334,
21393,
1267,
12,
428,
1764,
345,
680,
662,
14,
71,
16781,
267,
359,
257,
359,
1144,
8,
12664,
2508,
5198,
9,
2360,
1625,
8,
5238,
2508,
13668,
1874,
2360,
288,
359,
1144,
8,
11065,
2508,
2948,
17,
9,
2360,
1625,
8,
13564,
2508,
17017,
1874,
2360,
288,
1622,
339,
408,
272,
17429,
275,
663,
8,
12362,
14,
1131,
63,
8571,
63,
1403,
8,
334,
56,
12,
1488,
395,
7425,
15,
18,
430,
272,
12474,
275,
663,
8,
12362,
14,
1131,
63,
8571,
63,
1403,
8,
334,
56,
12,
1488,
395,
7031,
15,
18,
430,
339,
340,
20593,
1130,
365,
488,
26,
20593,
1130,
275,
1425,
8,
552,
8,
19689,
2956,
430,
339,
315,
63,
1189,
15909,
275,
12474,
14,
9196,
8,
21078,
9,
272,
2058,
275,
942,
272,
367,
1478,
315,
315,
63,
1189,
15909,
26,
267,
20593,
275,
20593,
1130,
59,
1080,
61,
267,
862,
26,
25917,
275,
3240,
71,
2956,
59,
1148,
2733,
21393,
26015,
3488,
16,
1527,
16,
61,
5873,
267,
871,
26,
1980,
267,
25917,
275,
25046,
14,
4723,
63,
15727,
8,
17984,
12,
7148,
63,
4723,
9,
267,
2058,
14,
740,
8,
359,
17984,
12,
717,
3240,
71,
2956,
59,
1148,
2733,
51,
16531,
5307,
13776,
3488,
16,
1527,
16,
467,
717,
20593,
566,
339,
372,
2058,
4388,
199,
318,
2386,
89,
63,
13106,
8,
12362,
12,
3240,
71,
2956,
12,
1323,
29,
18,
12,
1488,
29,
709,
12,
6033,
29,
23,
12,
20593,
1130,
29,
403,
12,
7148,
63,
4723,
29,
16,
304,
272,
408,
20551,
282,
17312,
20645,
4347,
3969,
316,
314,
298,
12267,
1674,
339,
3033,
26,
267,
1804,
52,
26,
710,
31368,
3123,
14,
961,
883,
506,
2737,
315,
8812,
1130,
63,
475,
63,
25606,
2350,
267,
3240,
71,
2956,
26,
710,
27315,
2341,
267,
1323,
12,
57,
26,
710,
1323,
15,
57,
3421,
402,
314,
20645,
370,
5536,
14,
3758,
365,
12180,
14,
267,
6033,
26,
21892,
370,
314,
5844,
31418,
315,
11094,
14,
3758,
365,
27151,
267,
7148,
63,
4723,
26,
2104,
20758,
608,
21940,
12,
314,
1329,
402,
11094,
370,
7706,
288,
314,
12204,
1267,
8744,
339,
1803,
26,
267,
791,
10024,
63,
10756,
356,
12204,
1267,
402,
2386,
89,
20645,
12,
7205,
283,
1650,
63,
350,
85,
297,
314,
17312,
2386,
89,
20645,
12,
7205,
283,
452,
63,
1650,
356,
436,
282,
3634,
402,
30900,
345,
12,
288,
283,
1507,
63,
1650,
356,
710,
1329,
402,
30900,
345,
93,
339,
408,
339,
15941,
275,
30900,
345,
63,
21078,
63,
3124,
8,
12362,
12,
3240,
71,
2956,
12,
1323,
12,
1488,
12,
6033,
12,
20593,
1130,
29,
0
] |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1
] |
wa3l/mailr
|
email_model.py
|
1
|
1590
|
from flask.ext.sqlalchemy import SQLAlchemy
import html2text as convert
import time
db = SQLAlchemy()
class Email(db.Model):
"""
Email model
Store emails going through the app in a database.
"""
id = db.Column(db.Integer, primary_key=True)
to_email = db.Column(db.String(254))
to_name = db.Column(db.String(256))
from_email = db.Column(db.String(254))
from_name = db.Column(db.String(256))
subject = db.Column(db.String(78))
html = db.Column(db.UnicodeText)
text = db.Column(db.UnicodeText)
service = db.Column(db.String(10))
deliverytime = db.Column(db.BigInteger)
def __init__(self, data):
self.to_email = data['to']
self.to_name = data['to_name']
self.from_email = data['from']
self.from_name = data['from_name']
self.subject = data['subject']
self.html = data['body']
self.text = convert.html2text(data['body'])
self.service = data['service'] if data.has_key('service') else None
if data.has_key('deliverytime'):
self.deliverytime = int(data['deliverytime'])
else:
self.deliverytime = int(time.time())
def __str__(self):
return str({
'to': self.to_email,
'from': self.from_email,
'to_name': self.to_name,
'from_name': self.from_name,
'subject': self.subject,
'text': self.text,
'html': self.html,
'service': self.service,
'deliverytime': str(self.deliverytime)
})
def __repr__(self):
return str(self)
|
mit
|
[
504,
7209,
14,
832,
14,
14536,
492,
14303,
199,
646,
3517,
18,
505,
465,
3957,
199,
646,
900,
199,
199,
697,
275,
14303,
342,
199,
199,
533,
11426,
8,
697,
14,
1685,
304,
523,
408,
523,
11426,
1402,
523,
13874,
14931,
9995,
4012,
314,
1145,
315,
282,
3050,
14,
523,
408,
523,
1305,
3698,
275,
1592,
14,
4547,
8,
697,
14,
2674,
12,
5062,
63,
498,
29,
549,
9,
523,
370,
63,
2123,
258,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
8306,
430,
523,
370,
63,
354,
420,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
3912,
430,
523,
687,
63,
2123,
257,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
8306,
430,
523,
687,
63,
354,
259,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
3912,
430,
523,
5420,
420,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
2277,
430,
523,
3517,
260,
275,
1592,
14,
4547,
8,
697,
14,
7087,
1872,
9,
523,
1318,
260,
275,
1592,
14,
4547,
8,
697,
14,
7087,
1872,
9,
523,
2435,
420,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
709,
430,
523,
18719,
521,
275,
1592,
14,
4547,
8,
697,
14,
7279,
2674,
9,
8330,
347,
636,
826,
721,
277,
12,
666,
304,
272,
291,
14,
475,
63,
2123,
257,
275,
666,
459,
475,
418,
272,
291,
14,
475,
63,
354,
259,
275,
666,
459,
475,
63,
354,
418,
272,
291,
14,
504,
63,
2123,
275,
666,
459,
504,
418,
272,
291,
14,
504,
63,
354,
221,
275,
666,
459,
504,
63,
354,
418,
272,
291,
14,
5875,
259,
275,
666,
459,
5875,
418,
272,
291,
14,
1360,
755,
275,
666,
459,
2030,
418,
272,
291,
14,
505,
755,
275,
3957,
14,
1360,
18,
505,
8,
576,
459,
2030,
1105,
272,
291,
14,
1364,
259,
275,
666,
459,
1364,
418,
340,
666,
14,
1989,
63,
498,
360,
1364,
358,
587,
488,
272,
340,
666,
14,
1989,
63,
498,
360,
14564,
521,
735,
489,
291,
14,
14564,
521,
275,
1109,
8,
576,
459,
14564,
521,
1105,
272,
587,
26,
489,
291,
14,
14564,
521,
275,
1109,
8,
521,
14,
521,
1012,
8330,
347,
636,
495,
721,
277,
304,
272,
372,
620,
2561,
489,
283,
475,
356,
3698,
291,
14,
475,
63,
2123,
12,
489,
283,
504,
356,
260,
291,
14,
504,
63,
2123,
12,
489,
283,
475,
63,
354,
356,
420,
291,
14,
475,
63,
354,
12,
489,
283,
504,
63,
354,
356,
259,
291,
14,
504,
63,
354,
12,
489,
283,
5875,
356,
420,
291,
14,
5875,
12,
489,
283,
505,
356,
260,
291,
14,
505,
12,
489,
283,
1360,
356,
260,
291,
14,
1360,
12,
489,
283,
1364,
356,
258,
291,
14,
1364,
12,
489,
283,
14564,
521,
356,
620,
8,
277,
14,
14564,
521,
9,
272,
3828,
8330,
347,
636,
2722,
721,
277,
304,
272,
372,
620,
8,
277,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
7209,
14,
832,
14,
14536,
492,
14303,
199,
646,
3517,
18,
505,
465,
3957,
199,
646,
900,
199,
199,
697,
275,
14303,
342,
199,
199,
533,
11426,
8,
697,
14,
1685,
304,
523,
408,
523,
11426,
1402,
523,
13874,
14931,
9995,
4012,
314,
1145,
315,
282,
3050,
14,
523,
408,
523,
1305,
3698,
275,
1592,
14,
4547,
8,
697,
14,
2674,
12,
5062,
63,
498,
29,
549,
9,
523,
370,
63,
2123,
258,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
8306,
430,
523,
370,
63,
354,
420,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
3912,
430,
523,
687,
63,
2123,
257,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
8306,
430,
523,
687,
63,
354,
259,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
3912,
430,
523,
5420,
420,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
2277,
430,
523,
3517,
260,
275,
1592,
14,
4547,
8,
697,
14,
7087,
1872,
9,
523,
1318,
260,
275,
1592,
14,
4547,
8,
697,
14,
7087,
1872,
9,
523,
2435,
420,
275,
1592,
14,
4547,
8,
697,
14,
1558,
8,
709,
430,
523,
18719,
521,
275,
1592,
14,
4547,
8,
697,
14,
7279,
2674,
9,
8330,
347,
636,
826,
721,
277,
12,
666,
304,
272,
291,
14,
475,
63,
2123,
257,
275,
666,
459,
475,
418,
272,
291,
14,
475,
63,
354,
259,
275,
666,
459,
475,
63,
354,
418,
272,
291,
14,
504,
63,
2123,
275,
666,
459,
504,
418,
272,
291,
14,
504,
63,
354,
221,
275,
666,
459,
504,
63,
354,
418,
272,
291,
14,
5875,
259,
275,
666,
459,
5875,
418,
272,
291,
14,
1360,
755,
275,
666,
459,
2030,
418,
272,
291,
14,
505,
755,
275,
3957,
14,
1360,
18,
505,
8,
576,
459,
2030,
1105,
272,
291,
14,
1364,
259,
275,
666,
459,
1364,
418,
340,
666,
14,
1989,
63,
498,
360,
1364,
358,
587,
488,
272,
340,
666,
14,
1989,
63,
498,
360,
14564,
521,
735,
489,
291,
14,
14564,
521,
275,
1109,
8,
576,
459,
14564,
521,
1105,
272,
587,
26,
489,
291,
14,
14564,
521,
275,
1109,
8,
521,
14,
521,
1012,
8330,
347,
636,
495,
721,
277,
304,
272,
372,
620,
2561,
489,
283,
475,
356,
3698,
291,
14,
475,
63,
2123,
12,
489,
283,
504,
356,
260,
291,
14,
504,
63,
2123,
12,
489,
283,
475,
63,
354,
356,
420,
291,
14,
475,
63,
354,
12,
489,
283,
504,
63,
354,
356,
259,
291,
14,
504,
63,
354,
12,
489,
283,
5875,
356,
420,
291,
14,
5875,
12,
489,
283,
505,
356,
260,
291,
14,
505,
12,
489,
283,
1360,
356,
260,
291,
14,
1360,
12,
489,
283,
1364,
356,
258,
291,
14,
1364,
12,
489,
283,
14564,
521,
356,
620,
8,
277,
14,
14564,
521,
9,
272,
3828,
8330,
347,
636,
2722,
721,
277,
304,
272,
372,
620,
8,
277,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
manveru0/FeaCore_Phoenix_S3
|
tools/perf/scripts/python/sctop.py
|
11180
|
1924
|
# system call top
# (c) 2010, Tom Zanussi <tzanussi@gmail.com>
# Licensed under the terms of the GNU GPL License version 2
#
# Periodically displays system-wide system call totals, broken down by
# syscall. If a [comm] arg is specified, only syscalls called by
# [comm] are displayed. If an [interval] arg is specified, the display
# will be refreshed every [interval] seconds. The default interval is
# 3 seconds.
import os, sys, thread, time
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from Core import *
from Util import *
usage = "perf script -s sctop.py [comm] [interval]\n";
for_comm = None
default_interval = 3
interval = default_interval
if len(sys.argv) > 3:
sys.exit(usage)
if len(sys.argv) > 2:
for_comm = sys.argv[1]
interval = int(sys.argv[2])
elif len(sys.argv) > 1:
try:
interval = int(sys.argv[1])
except ValueError:
for_comm = sys.argv[1]
interval = default_interval
syscalls = autodict()
def trace_begin():
thread.start_new_thread(print_syscall_totals, (interval,))
pass
def raw_syscalls__sys_enter(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
id, args):
if for_comm is not None:
if common_comm != for_comm:
return
try:
syscalls[id] += 1
except TypeError:
syscalls[id] = 1
def print_syscall_totals(interval):
while 1:
clear_term()
if for_comm is not None:
print "\nsyscall events for %s:\n\n" % (for_comm),
else:
print "\nsyscall events:\n\n",
print "%-40s %10s\n" % ("event", "count"),
print "%-40s %10s\n" % ("----------------------------------------", \
"----------"),
for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \
reverse = True):
try:
print "%-40s %10d\n" % (syscall_name(id), val),
except TypeError:
pass
syscalls.clear()
time.sleep(interval)
|
gpl-2.0
|
[
3,
2656,
1240,
2746,
199,
3,
334,
67,
9,
7129,
12,
21644,
29385,
665,
29453,
32,
6799,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
3492,
11273,
1183,
17561,
2656,
13,
13062,
2656,
1240,
23576,
12,
10529,
3224,
701,
199,
3,
18901,
14,
221,
982,
282,
359,
1404,
61,
1680,
365,
2013,
12,
1454,
19473,
2797,
701,
199,
3,
359,
1404,
61,
787,
9080,
14,
982,
376,
359,
4284,
61,
1680,
365,
2013,
12,
314,
2929,
199,
3,
911,
506,
9236,
379,
4036,
359,
4284,
61,
4696,
14,
221,
710,
849,
6252,
365,
199,
3,
650,
4696,
14,
199,
199,
646,
747,
12,
984,
12,
2462,
12,
900,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
21248,
492,
627,
199,
199,
3807,
275,
298,
9452,
2884,
446,
83,
308,
319,
411,
14,
647,
359,
1404,
61,
359,
4284,
7272,
78,
11436,
199,
199,
509,
63,
1404,
275,
488,
199,
885,
63,
4284,
275,
650,
199,
4284,
275,
849,
63,
4284,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
650,
26,
199,
198,
1274,
14,
2224,
8,
3807,
9,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
499,
26,
199,
198,
509,
63,
1404,
275,
984,
14,
3020,
59,
17,
61,
199,
198,
4284,
275,
1109,
8,
1274,
14,
3020,
59,
18,
566,
199,
4164,
822,
8,
1274,
14,
3020,
9,
690,
413,
26,
199,
198,
893,
26,
507,
198,
4284,
275,
1109,
8,
1274,
14,
3020,
59,
17,
566,
199,
198,
2590,
1722,
26,
507,
198,
509,
63,
1404,
275,
984,
14,
3020,
59,
17,
61,
507,
198,
4284,
275,
849,
63,
4284,
199,
199,
14507,
275,
27477,
342,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
2671,
14,
928,
63,
1222,
63,
2671,
8,
1361,
63,
19444,
63,
17552,
12,
334,
4284,
4641,
199,
198,
1529,
199,
199,
318,
3066,
63,
14507,
363,
1274,
63,
4200,
8,
1430,
63,
354,
12,
1067,
12,
2863,
63,
3541,
12,
199,
198,
2330,
63,
4855,
12,
2863,
63,
9618,
12,
2863,
63,
3150,
12,
2863,
63,
1404,
12,
199,
198,
344,
12,
1249,
304,
199,
198,
692,
367,
63,
1404,
365,
440,
488,
26,
507,
198,
692,
2863,
63,
1404,
1137,
367,
63,
1404,
26,
686,
198,
1107,
199,
198,
893,
26,
507,
198,
14507,
59,
344,
61,
847,
413,
199,
198,
2590,
3146,
26,
507,
198,
14507,
59,
344,
61,
275,
413,
199,
199,
318,
870,
63,
19444,
63,
17552,
8,
4284,
304,
199,
198,
6710,
413,
26,
507,
198,
3584,
63,
5125,
342,
507,
198,
692,
367,
63,
1404,
365,
440,
488,
26,
686,
198,
1361,
1867,
26605,
4474,
367,
450,
83,
3427,
78,
60,
78,
2,
450,
334,
509,
63,
1404,
395,
507,
198,
2836,
26,
686,
198,
1361,
1867,
26605,
4474,
3427,
78,
60,
78,
401,
2742,
198,
1361,
18301,
2167,
83,
221,
450,
709,
83,
60,
78,
2,
450,
1689,
1430,
401,
298,
835,
1288,
507,
198,
1361,
18301,
2167,
83,
221,
450,
709,
83,
60,
78,
2,
450,
1689,
32111,
401,
971,
5264,
298,
9460,
1288,
2742,
198,
509,
1305,
12,
1139,
315,
3355,
8,
14507,
14,
4611,
1062,
790,
275,
2400,
8,
75,
12,
373,
304,
334,
86,
12,
1022,
395,
971,
4671,
420,
3837,
275,
715,
304,
686,
198,
893,
26,
1585,
198,
1361,
18301,
2167,
83,
221,
450,
709,
68,
60,
78,
2,
450,
334,
19444,
63,
354,
8,
344,
395,
1139,
395,
686,
198,
2590,
3146,
26,
1585,
198,
1529,
507,
198,
14507,
14,
3584,
342,
507,
198,
521,
14,
4532,
8,
4284,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2656,
1240,
2746,
199,
3,
334,
67,
9,
7129,
12,
21644,
29385,
665,
29453,
32,
6799,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
3492,
11273,
1183,
17561,
2656,
13,
13062,
2656,
1240,
23576,
12,
10529,
3224,
701,
199,
3,
18901,
14,
221,
982,
282,
359,
1404,
61,
1680,
365,
2013,
12,
1454,
19473,
2797,
701,
199,
3,
359,
1404,
61,
787,
9080,
14,
982,
376,
359,
4284,
61,
1680,
365,
2013,
12,
314,
2929,
199,
3,
911,
506,
9236,
379,
4036,
359,
4284,
61,
4696,
14,
221,
710,
849,
6252,
365,
199,
3,
650,
4696,
14,
199,
199,
646,
747,
12,
984,
12,
2462,
12,
900,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
21248,
492,
627,
199,
199,
3807,
275,
298,
9452,
2884,
446,
83,
308,
319,
411,
14,
647,
359,
1404,
61,
359,
4284,
7272,
78,
11436,
199,
199,
509,
63,
1404,
275,
488,
199,
885,
63,
4284,
275,
650,
199,
4284,
275,
849,
63,
4284,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
650,
26,
199,
198,
1274,
14,
2224,
8,
3807,
9,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
499,
26,
199,
198,
509,
63,
1404,
275,
984,
14,
3020,
59,
17,
61,
199,
198,
4284,
275,
1109,
8,
1274,
14,
3020,
59,
18,
566,
199,
4164,
822,
8,
1274,
14,
3020,
9,
690,
413,
26,
199,
198,
893,
26,
507,
198,
4284,
275,
1109,
8,
1274,
14,
3020,
59,
17,
566,
199,
198,
2590,
1722,
26,
507,
198,
509,
63,
1404,
275,
984,
14,
3020,
59,
17,
61,
507,
198,
4284,
275,
849,
63,
4284,
199,
199,
14507,
275,
27477,
342,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
2671,
14,
928,
63,
1222,
63,
2671,
8,
1361,
63,
19444,
63,
17552,
12,
334,
4284,
4641,
199,
198,
1529,
199,
199,
318,
3066,
63,
14507,
363,
1274,
63,
4200,
8,
1430,
63,
354,
12,
1067,
12,
2863,
63,
3541,
12,
199,
198,
2330,
63,
4855,
12,
2863,
63,
9618,
12,
2863,
63,
3150,
12,
2863,
63,
1404,
12,
199,
198,
344,
12,
1249,
304,
199,
198,
692,
367,
63,
1404,
365,
440,
488,
26,
507,
198,
692,
2863,
63,
1404,
1137,
367,
63,
1404,
26,
686,
198,
1107,
199,
198,
893,
26,
507,
198,
14507,
59,
344,
61,
847,
413,
199,
198,
2590,
3146,
26,
507,
198,
14507,
59,
344,
61,
275,
413,
199,
199,
318,
870,
63,
19444,
63,
17552,
8,
4284,
304,
199,
198,
6710,
413,
26,
507,
198,
3584,
63,
5125,
342,
507,
198,
692,
367,
63,
1404,
365,
440,
488,
26,
686,
198,
1361,
1867,
26605,
4474,
367,
450,
83,
3427,
78,
60,
78,
2,
450,
334,
509,
63,
1404,
395,
507,
198,
2836,
26,
686,
198,
1361,
1867,
26605,
4474,
3427,
78,
60,
78,
401,
2742,
198,
1361,
18301,
2167,
83,
221,
450,
709,
83,
60,
78,
2,
450,
1689,
1430,
401,
298,
835,
1288,
507,
198,
1361,
18301,
2167,
83,
221,
450,
709,
83,
60,
78,
2,
450,
1689,
32111,
401,
971,
5264,
298,
9460,
1288,
2742,
198,
509,
1305,
12,
1139,
315,
3355,
8,
14507,
14,
4611,
1062,
790,
275,
2400,
8,
75,
12,
373,
304,
334,
86,
12,
1022,
395,
971,
4671,
420,
3837,
275,
715,
304,
686,
198,
893,
26,
1585,
198,
1361,
18301,
2167,
83,
221,
450,
709,
68,
60,
78,
2,
450,
334,
19444,
63,
354,
8,
344,
395,
1139,
395,
686,
198,
2590,
3146,
26,
1585,
198,
1529,
507,
198,
14507,
14,
3584,
342,
507,
198,
521,
14,
4532,
8,
4284,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ragnarstroberg/imsrg
|
src/pybind11/tests/test_call_policies.py
|
4
|
5118
|
import pytest
def test_keep_alive_argument(capture):
from pybind11_tests import Parent, Child, ConstructorStats
n_inst = ConstructorStats.detail_reg_inst()
with capture:
p = Parent()
assert capture == "Allocating parent."
with capture:
p.addChild(Child())
assert ConstructorStats.detail_reg_inst() == n_inst + 1
assert capture == """
Allocating child.
Releasing child.
"""
with capture:
del p
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == "Releasing parent."
with capture:
p = Parent()
assert capture == "Allocating parent."
with capture:
p.addChildKeepAlive(Child())
assert ConstructorStats.detail_reg_inst() == n_inst + 2
assert capture == "Allocating child."
with capture:
del p
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == """
Releasing parent.
Releasing child.
"""
def test_keep_alive_return_value(capture):
from pybind11_tests import Parent, ConstructorStats
n_inst = ConstructorStats.detail_reg_inst()
with capture:
p = Parent()
assert capture == "Allocating parent."
with capture:
p.returnChild()
assert ConstructorStats.detail_reg_inst() == n_inst + 1
assert capture == """
Allocating child.
Releasing child.
"""
with capture:
del p
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == "Releasing parent."
with capture:
p = Parent()
assert capture == "Allocating parent."
with capture:
p.returnChildKeepAlive()
assert ConstructorStats.detail_reg_inst() == n_inst + 2
assert capture == "Allocating child."
with capture:
del p
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == """
Releasing parent.
Releasing child.
"""
# https://bitbucket.org/pypy/pypy/issues/2447
@pytest.unsupported_on_pypy
def test_alive_gc(capture):
from pybind11_tests import ParentGC, Child, ConstructorStats
n_inst = ConstructorStats.detail_reg_inst()
p = ParentGC()
p.addChildKeepAlive(Child())
assert ConstructorStats.detail_reg_inst() == n_inst + 2
lst = [p]
lst.append(lst) # creates a circular reference
with capture:
del p, lst
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == """
Releasing parent.
Releasing child.
"""
def test_alive_gc_derived(capture):
from pybind11_tests import Parent, Child, ConstructorStats
class Derived(Parent):
pass
n_inst = ConstructorStats.detail_reg_inst()
p = Derived()
p.addChildKeepAlive(Child())
assert ConstructorStats.detail_reg_inst() == n_inst + 2
lst = [p]
lst.append(lst) # creates a circular reference
with capture:
del p, lst
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == """
Releasing parent.
Releasing child.
"""
def test_alive_gc_multi_derived(capture):
from pybind11_tests import Parent, Child, ConstructorStats
class Derived(Parent, Child):
pass
n_inst = ConstructorStats.detail_reg_inst()
p = Derived()
p.addChildKeepAlive(Child())
# +3 rather than +2 because Derived corresponds to two registered instances
assert ConstructorStats.detail_reg_inst() == n_inst + 3
lst = [p]
lst.append(lst) # creates a circular reference
with capture:
del p, lst
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == """
Releasing parent.
Releasing child.
"""
def test_return_none(capture):
from pybind11_tests import Parent, ConstructorStats
n_inst = ConstructorStats.detail_reg_inst()
with capture:
p = Parent()
assert capture == "Allocating parent."
with capture:
p.returnNullChildKeepAliveChild()
assert ConstructorStats.detail_reg_inst() == n_inst + 1
assert capture == ""
with capture:
del p
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == "Releasing parent."
with capture:
p = Parent()
assert capture == "Allocating parent."
with capture:
p.returnNullChildKeepAliveParent()
assert ConstructorStats.detail_reg_inst() == n_inst + 1
assert capture == ""
with capture:
del p
assert ConstructorStats.detail_reg_inst() == n_inst
assert capture == "Releasing parent."
def test_call_guard():
from pybind11_tests import call_policies
assert call_policies.unguarded_call() == "unguarded"
assert call_policies.guarded_call() == "guarded"
assert call_policies.multiple_guards_correct_order() == "guarded & guarded"
assert call_policies.multiple_guards_wrong_order() == "unguarded & guarded"
if hasattr(call_policies, "with_gil"):
assert call_policies.with_gil() == "GIL held"
assert call_policies.without_gil() == "GIL released"
|
gpl-2.0
|
[
646,
4613,
421,
199,
318,
511,
63,
3250,
63,
9631,
63,
2094,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
12988,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
23897,
8,
3493,
1012,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
413,
272,
702,
12296,
508,
408,
267,
4580,
2102,
1958,
1982,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
298,
497,
274,
11571,
1676,
2122,
339,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1982,
2122,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
3250,
63,
9631,
63,
1107,
63,
585,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
1107,
3493,
342,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
413,
272,
702,
12296,
508,
408,
267,
4580,
2102,
1958,
1982,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
298,
497,
274,
11571,
1676,
2122,
339,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
1107,
3493,
18567,
23692,
342,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1982,
2122,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
3,
4178,
921,
25668,
14,
1308,
15,
20233,
15,
20233,
15,
10115,
15,
1194,
2417,
199,
32,
4462,
14,
15267,
63,
265,
63,
20233,
199,
318,
511,
63,
9631,
63,
9493,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
7484,
12,
12988,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
299,
275,
16396,
7484,
342,
272,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
272,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
9877,
275,
359,
80,
61,
272,
9877,
14,
740,
8,
6916,
9,
257,
327,
8491,
282,
15032,
3659,
272,
543,
12296,
26,
267,
2150,
299,
12,
9877,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
9631,
63,
9493,
63,
19588,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
12988,
12,
20297,
8257,
339,
1021,
27731,
8,
6652,
304,
267,
986,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
299,
275,
27731,
342,
272,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
272,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
9877,
275,
359,
80,
61,
272,
9877,
14,
740,
8,
6916,
9,
257,
327,
8491,
282,
15032,
3659,
272,
543,
12296,
26,
267,
2150,
299,
12,
9877,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
9631,
63,
9493,
63,
3029,
63,
19588,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
12988,
12,
20297,
8257,
339,
1021,
27731,
8,
6652,
12,
12988,
304,
267,
986,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
299,
275,
27731,
342,
272,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
272,
327,
435,
19,
7830,
2419,
435,
18,
2952,
27731,
13718,
370,
2877,
7264,
4454,
272,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
650,
272,
9877,
275,
359,
80,
61,
272,
9877,
14,
740,
8,
6916,
9,
257,
327,
8491,
282,
15032,
3659,
272,
543,
12296,
26,
267,
2150,
299,
12,
9877,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
1107,
63,
3592,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
1107,
8849,
3493,
18567,
23692,
3493,
342,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63
] |
[
4613,
421,
199,
318,
511,
63,
3250,
63,
9631,
63,
2094,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
12988,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
23897,
8,
3493,
1012,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
413,
272,
702,
12296,
508,
408,
267,
4580,
2102,
1958,
1982,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
298,
497,
274,
11571,
1676,
2122,
339,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1982,
2122,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
3250,
63,
9631,
63,
1107,
63,
585,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
1107,
3493,
342,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
413,
272,
702,
12296,
508,
408,
267,
4580,
2102,
1958,
1982,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
298,
497,
274,
11571,
1676,
2122,
339,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
1107,
3493,
18567,
23692,
342,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1982,
2122,
272,
543,
12296,
26,
267,
2150,
299,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
3,
4178,
921,
25668,
14,
1308,
15,
20233,
15,
20233,
15,
10115,
15,
1194,
2417,
199,
32,
4462,
14,
15267,
63,
265,
63,
20233,
199,
318,
511,
63,
9631,
63,
9493,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
7484,
12,
12988,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
299,
275,
16396,
7484,
342,
272,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
272,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
9877,
275,
359,
80,
61,
272,
9877,
14,
740,
8,
6916,
9,
257,
327,
8491,
282,
15032,
3659,
272,
543,
12296,
26,
267,
2150,
299,
12,
9877,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
9631,
63,
9493,
63,
19588,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
12988,
12,
20297,
8257,
339,
1021,
27731,
8,
6652,
304,
267,
986,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
299,
275,
27731,
342,
272,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
272,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
499,
272,
9877,
275,
359,
80,
61,
272,
9877,
14,
740,
8,
6916,
9,
257,
327,
8491,
282,
15032,
3659,
272,
543,
12296,
26,
267,
2150,
299,
12,
9877,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
9631,
63,
9493,
63,
3029,
63,
19588,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
12988,
12,
20297,
8257,
339,
1021,
27731,
8,
6652,
12,
12988,
304,
267,
986,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
299,
275,
27731,
342,
272,
299,
14,
23897,
18567,
23692,
8,
3493,
1012,
272,
327,
435,
19,
7830,
2419,
435,
18,
2952,
27731,
13718,
370,
2877,
7264,
4454,
272,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
435,
650,
272,
9877,
275,
359,
80,
61,
272,
9877,
14,
740,
8,
6916,
9,
257,
327,
8491,
282,
15032,
3659,
272,
543,
12296,
26,
267,
2150,
299,
12,
9877,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
3615,
272,
702,
12296,
508,
408,
267,
799,
274,
11571,
1676,
14,
267,
799,
274,
11571,
1982,
14,
272,
408,
421,
199,
318,
511,
63,
1107,
63,
3592,
8,
12685,
304,
272,
687,
1134,
3409,
845,
63,
2219,
492,
16396,
12,
20297,
8257,
339,
302,
63,
3615,
275,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
272,
543,
12296,
26,
267,
299,
275,
16396,
342,
272,
702,
12296,
508,
298,
2439,
2102,
1958,
1676,
2122,
272,
543,
12296,
26,
267,
299,
14,
1107,
8849,
3493,
18567,
23692,
3493,
342,
267,
702,
20297,
8257,
14,
5506,
63,
1135,
63,
3615,
342,
508,
302,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ronaldsantos63/Gera_SPED_SysPDV
|
resources_rc.py
|
1
|
125636
|
# -*- coding: utf-8 -*-
# Resource object code
#
# Created: ter 29. set 21:52:13 2015
# by: The Resource Compiler for PyQt (Qt v4.8.4)
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore
qt_resource_data = "\
\x00\x00\x01\x57\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x09\x08\x06\x00\x00\x00\xe0\x91\x06\x10\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\
\x01\x95\x2b\x0e\x1b\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\
\x25\x00\x00\x80\x83\x00\x00\xf9\xff\x00\x00\x80\xe9\x00\x00\x75\
\x30\x00\x00\xea\x60\x00\x00\x3a\x98\x00\x00\x17\x6f\x92\x5f\xc5\
\x46\x00\x00\x00\xdd\x49\x44\x41\x54\x78\xda\x5c\x8e\xb1\x4e\x84\
\x40\x18\x84\x67\xef\x4c\x2c\xc8\xd9\x2c\x0d\x58\x50\x1b\x0b\xc3\
\xfa\x24\x77\xbd\x0d\x85\x4f\x40\x0b\xbb\xcb\x3b\xd0\x68\x41\x72\
\xc5\xd2\x28\x4f\x02\xcf\xb1\x97\x40\x61\xd4\xc2\xc4\x62\x2c\xbc\
\x4d\xd0\x49\xfe\xbf\xf8\x32\xff\x3f\x23\x48\xc2\x5a\x3b\x00\x80\
\xd6\xfa\x80\xb3\xac\xb5\x03\x49\x18\x63\x0e\x5b\x21\xc4\x90\xe7\
\xf9\x3e\x49\x92\x9b\xbe\xef\xef\xca\xb2\x7c\xf5\xde\xbf\x04\xe6\
\x9c\xbb\xbd\x20\xf9\x19\xae\x95\x52\xfb\x2c\xcb\xbe\xa5\x94\x01\
\x81\xe4\x9b\x38\xbf\x3c\x2a\xa5\x1e\xf0\x4f\xe3\x38\x3e\x37\x4d\
\xf3\x28\x48\x02\x00\xba\xae\x7b\x97\x52\xee\x82\x61\x59\x96\x8f\
\xa2\x28\xae\x00\x60\x03\x00\xc6\x98\xe3\xda\x00\x00\x71\x1c\xef\
\xb4\xd6\x4f\x00\xb0\x05\xf0\x27\x6a\x9e\x67\x44\x51\x04\x00\x48\
\xd3\xf4\xde\x39\x77\xbd\x21\xf9\xb5\xea\x70\x6a\xdb\xf6\x72\x9a\
\xa6\xd3\xaa\xf8\xef\xaa\xeb\xda\x57\x55\xe5\x49\x22\xcc\x9a\xfd\
\x0c\x00\x24\xab\x6e\xfa\x96\x21\xfc\xb8\x00\x00\x00\x00\x49\x45\
\x4e\x44\xae\x42\x60\x82\
\x00\x00\x03\xf0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x07\x00\x00\x00\x05\x08\x04\x00\x00\x00\x23\x93\x3e\x53\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x03\x18\x69\x43\x43\x50\x50\x68\x6f\
\x74\x6f\x73\x68\x6f\x70\x20\x49\x43\x43\x20\x70\x72\x6f\x66\x69\
\x6c\x65\x00\x00\x78\xda\x63\x60\x60\x9e\xe0\xe8\xe2\xe4\xca\x24\
\xc0\xc0\x50\x50\x54\x52\xe4\x1e\xe4\x18\x19\x11\x19\xa5\xc0\x7e\
\x9e\x81\x8d\x81\x99\x81\x81\x81\x81\x81\x21\x31\xb9\xb8\xc0\x31\
\x20\xc0\x87\x81\x81\x81\x21\x2f\x3f\x2f\x95\x01\x15\x30\x32\x30\
\x7c\xbb\xc6\xc0\xc8\xc0\xc0\xc0\x70\x59\xd7\xd1\xc5\xc9\x95\x81\
\x34\xc0\x9a\x5c\x50\x54\xc2\xc0\xc0\x70\x80\x81\x81\xc1\x28\x25\
\xb5\x38\x99\x81\x81\xe1\x0b\x03\x03\x43\x7a\x79\x49\x41\x09\x03\
\x03\x63\x0c\x03\x03\x83\x48\x52\x76\x41\x09\x03\x03\x63\x01\x03\
\x03\x83\x48\x76\x48\x90\x33\x03\x03\x63\x0b\x03\x03\x13\x4f\x49\
\x6a\x45\x09\x03\x03\x03\x83\x73\x7e\x41\x65\x51\x66\x7a\x46\x89\
\x82\xa1\xa5\xa5\xa5\x82\x63\x4a\x7e\x52\xaa\x42\x70\x65\x71\x49\
\x6a\x6e\xb1\x82\x67\x5e\x72\x7e\x51\x41\x7e\x51\x62\x49\x6a\x0a\
\x03\x03\x03\xd4\x0e\x06\x06\x06\x06\x5e\x97\xfc\x12\x05\xf7\xc4\
\xcc\x3c\x05\x23\x03\x55\x06\x2a\x83\x88\xc8\x28\x05\x08\x0b\x11\
\x3e\x08\x31\x04\x48\x2e\x2d\x2a\x83\x07\x25\x03\x83\x00\x83\x02\
\x83\x01\x83\x03\x43\x00\x43\x22\x43\x3d\xc3\x02\x86\xa3\x0c\x6f\
\x18\xc5\x19\x5d\x18\x4b\x19\x57\x30\xde\x63\x12\x63\x0a\x62\x9a\
\xc0\x74\x81\x59\x98\x39\x92\x79\x21\xf3\x1b\x16\x4b\x96\x0e\x96\
\x5b\xac\x7a\xac\xad\xac\xf7\xd8\x2c\xd9\xa6\xb1\x7d\x63\x0f\x67\
\xdf\xcd\xa1\xc4\xd1\xc5\xf1\x85\x33\x91\xf3\x02\x97\x23\xd7\x16\
\x6e\x4d\xee\x05\x3c\x52\x3c\x53\x79\x85\x78\x27\xf1\x09\xf3\x4d\
\xe3\x97\xe1\x5f\x2c\xa0\x23\xb0\x43\xd0\x55\xf0\x8a\x50\xaa\xd0\
\x0f\xe1\x5e\x11\x15\x91\xbd\xa2\xe1\xa2\x5f\xc4\x26\x89\x1b\x89\
\x5f\x91\xa8\x90\x94\x93\x3c\x26\x95\x2f\x2d\x2d\x7d\x42\xa6\x4c\
\x56\x5d\xf6\x96\x5c\x9f\xbc\x8b\xfc\x1f\x85\xad\x8a\x85\x4a\x7a\
\x4a\x6f\x95\xd7\xaa\x14\xa8\x9a\xa8\xfe\x54\x3b\xa8\xde\xa5\x11\
\xaa\xa9\xa4\xf9\x41\xeb\x80\xf6\x24\x9d\x54\x5d\x2b\x3d\x41\xbd\
\x57\xfa\x47\x0c\x16\x18\xd6\x1a\xc5\x18\xdb\x9a\xc8\x9b\x32\x9b\
\xbe\x34\xbb\x60\xbe\xd3\x62\x89\xe5\x04\xab\x3a\xeb\x5c\x9b\x38\
\xdb\x40\x3b\x57\x7b\x6b\x07\x63\x47\x1d\x27\x35\x67\x25\x17\x05\
\x57\x79\x37\x05\x77\x65\x0f\x75\x4f\x5d\x2f\x13\x6f\x1b\x1f\x77\
\xdf\x60\xbf\x04\xff\xfc\x80\xfa\xc0\x89\x41\x4b\x83\x77\x85\x5c\
\x0c\x7d\x19\xce\x14\x21\x17\x69\x15\x15\x11\x5d\x11\x33\x33\x76\
\x4f\xdc\x83\x04\xb6\x44\xdd\xa4\xb0\xe4\x86\x94\x35\xa9\x37\xd3\
\x39\x32\x2c\x32\x33\xb3\xe6\x66\x5f\xcc\x65\xcf\xb3\xcf\xaf\x28\
\xd8\x54\xf8\xae\x58\xbb\x24\xab\x74\x55\xd9\x9b\x0a\xfd\xca\x92\
\xaa\x5d\x35\x8c\xb5\x5e\x75\x53\xeb\x1f\x36\xea\x35\xd5\x34\x9f\
\x6d\x95\x6b\x2b\x6c\x3f\xda\x29\xdd\x55\xd4\x7d\xba\x57\xb5\xaf\
\xb1\xff\xee\x44\x9b\x49\xb3\x27\xff\x9d\x1a\x3f\xed\xf0\x0c\x8d\
\x99\xfd\xb3\xbe\xcf\x49\x98\x7b\x7a\xbe\xf9\x82\xa5\x8b\x44\x16\
\xb7\x2e\xf9\xb6\x2c\x73\xf9\xbd\x95\x21\xab\x4e\xaf\x71\x59\xbb\
\x6f\xbd\xe5\x86\x6d\x9b\x4c\x36\x6f\xd9\x6a\xb2\x6d\xfb\x0e\xab\
\x9d\xfb\x77\xbb\xee\x39\xbb\x2f\x6c\xff\x83\x83\x39\x87\x7e\x1e\
\x69\x3f\x26\x7e\x7c\xc5\x49\xeb\x53\xe7\xce\x24\x9f\xfd\x75\x7e\
\xd2\x45\xed\x4b\x47\xaf\x24\x5e\xfd\x77\x7d\xce\x4d\x9b\x5b\x77\
\xef\xd4\xdf\x53\xbe\x7f\xe2\x61\xde\x63\xb1\x27\xfb\x9f\x65\xbe\
\x10\x79\x79\xf0\x75\xfe\x5b\xf9\x77\x17\x3e\x34\x7d\x32\xfd\xfc\
\xea\xeb\x82\xef\xe1\x3f\x05\x7e\x9d\xfa\xd3\xfa\xcf\xf1\xff\x7f\
\x00\x0d\x00\x0f\x34\xfa\x96\xf1\x5d\x00\x00\x00\x20\x63\x48\x52\
\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\x00\x00\xf9\xff\x00\x00\x80\
\xe9\x00\x00\x75\x30\x00\x00\xea\x60\x00\x00\x3a\x98\x00\x00\x17\
\x6f\x92\x5f\xc5\x46\x00\x00\x00\x52\x49\x44\x41\x54\x78\xda\x62\
\x58\xf5\xe9\xca\x3f\x18\x5c\xfe\x9e\x21\xd3\xff\xc4\x8f\xab\xbf\
\xaf\xfe\xbe\xfa\xfb\xd0\x97\x68\x63\x86\xff\x0c\x85\x6b\xf7\x7e\
\xdc\xfb\x71\xf3\x87\xcc\xbc\xff\x0c\x0c\xff\x19\x18\x98\x73\xce\
\xce\xbd\x1f\x39\xff\x3f\xc3\x7f\x06\x86\xff\x0c\xff\x19\x14\xdd\
\x2c\xb6\xfe\x67\xf8\xcf\xf0\x9f\x01\x30\x00\x6a\x5f\x2c\x67\x74\
\xda\xec\xfb\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x0b\x15\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x06\x08\x06\x00\x00\x00\xe0\xcc\xef\x48\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x0a\x4f\x69\x43\x43\x50\x50\x68\x6f\
\x74\x6f\x73\x68\x6f\x70\x20\x49\x43\x43\x20\x70\x72\x6f\x66\x69\
\x6c\x65\x00\x00\x78\xda\x9d\x53\x67\x54\x53\xe9\x16\x3d\xf7\xde\
\xf4\x42\x4b\x88\x80\x94\x4b\x6f\x52\x15\x08\x20\x52\x42\x8b\x80\
\x14\x91\x26\x2a\x21\x09\x10\x4a\x88\x21\xa1\xd9\x15\x51\xc1\x11\
\x45\x45\x04\x1b\xc8\xa0\x88\x03\x8e\x8e\x80\x8c\x15\x51\x2c\x0c\
\x8a\x0a\xd8\x07\xe4\x21\xa2\x8e\x83\xa3\x88\x8a\xca\xfb\xe1\x7b\
\xa3\x6b\xd6\xbc\xf7\xe6\xcd\xfe\xb5\xd7\x3e\xe7\xac\xf3\x9d\xb3\
\xcf\x07\xc0\x08\x0c\x96\x48\x33\x51\x35\x80\x0c\xa9\x42\x1e\x11\
\xe0\x83\xc7\xc4\xc6\xe1\xe4\x2e\x40\x81\x0a\x24\x70\x00\x10\x08\
\xb3\x64\x21\x73\xfd\x23\x01\x00\xf8\x7e\x3c\x3c\x2b\x22\xc0\x07\
\xbe\x00\x01\x78\xd3\x0b\x08\x00\xc0\x4d\x9b\xc0\x30\x1c\x87\xff\
\x0f\xea\x42\x99\x5c\x01\x80\x84\x01\xc0\x74\x91\x38\x4b\x08\x80\
\x14\x00\x40\x7a\x8e\x42\xa6\x00\x40\x46\x01\x80\x9d\x98\x26\x53\
\x00\xa0\x04\x00\x60\xcb\x63\x62\xe3\x00\x50\x2d\x00\x60\x27\x7f\
\xe6\xd3\x00\x80\x9d\xf8\x99\x7b\x01\x00\x5b\x94\x21\x15\x01\xa0\
\x91\x00\x20\x13\x65\x88\x44\x00\x68\x3b\x00\xac\xcf\x56\x8a\x45\
\x00\x58\x30\x00\x14\x66\x4b\xc4\x39\x00\xd8\x2d\x00\x30\x49\x57\
\x66\x48\x00\xb0\xb7\x00\xc0\xce\x10\x0b\xb2\x00\x08\x0c\x00\x30\
\x51\x88\x85\x29\x00\x04\x7b\x00\x60\xc8\x23\x23\x78\x00\x84\x99\
\x00\x14\x46\xf2\x57\x3c\xf1\x2b\xae\x10\xe7\x2a\x00\x00\x78\x99\
\xb2\x3c\xb9\x24\x39\x45\x81\x5b\x08\x2d\x71\x07\x57\x57\x2e\x1e\
\x28\xce\x49\x17\x2b\x14\x36\x61\x02\x61\x9a\x40\x2e\xc2\x79\x99\
\x19\x32\x81\x34\x0f\xe0\xf3\xcc\x00\x00\xa0\x91\x15\x11\xe0\x83\
\xf3\xfd\x78\xce\x0e\xae\xce\xce\x36\x8e\xb6\x0e\x5f\x2d\xea\xbf\
\x06\xff\x22\x62\x62\xe3\xfe\xe5\xcf\xab\x70\x40\x00\x00\xe1\x74\
\x7e\xd1\xfe\x2c\x2f\xb3\x1a\x80\x3b\x06\x80\x6d\xfe\xa2\x25\xee\
\x04\x68\x5e\x0b\xa0\x75\xf7\x8b\x66\xb2\x0f\x40\xb5\x00\xa0\xe9\
\xda\x57\xf3\x70\xf8\x7e\x3c\x3c\x45\xa1\x90\xb9\xd9\xd9\xe5\xe4\
\xe4\xd8\x4a\xc4\x42\x5b\x61\xca\x57\x7d\xfe\x67\xc2\x5f\xc0\x57\
\xfd\x6c\xf9\x7e\x3c\xfc\xf7\xf5\xe0\xbe\xe2\x24\x81\x32\x5d\x81\
\x47\x04\xf8\xe0\xc2\xcc\xf4\x4c\xa5\x1c\xcf\x92\x09\x84\x62\xdc\
\xe6\x8f\x47\xfc\xb7\x0b\xff\xfc\x1d\xd3\x22\xc4\x49\x62\xb9\x58\
\x2a\x14\xe3\x51\x12\x71\x8e\x44\x9a\x8c\xf3\x32\xa5\x22\x89\x42\
\x92\x29\xc5\x25\xd2\xff\x64\xe2\xdf\x2c\xfb\x03\x3e\xdf\x35\x00\
\xb0\x6a\x3e\x01\x7b\x91\x2d\xa8\x5d\x63\x03\xf6\x4b\x27\x10\x58\
\x74\xc0\xe2\xf7\x00\x00\xf2\xbb\x6f\xc1\xd4\x28\x08\x03\x80\x68\
\x83\xe1\xcf\x77\xff\xef\x3f\xfd\x47\xa0\x25\x00\x80\x66\x49\x92\
\x71\x00\x00\x5e\x44\x24\x2e\x54\xca\xb3\x3f\xc7\x08\x00\x00\x44\
\xa0\x81\x2a\xb0\x41\x1b\xf4\xc1\x18\x2c\xc0\x06\x1c\xc1\x05\xdc\
\xc1\x0b\xfc\x60\x36\x84\x42\x24\xc4\xc2\x42\x10\x42\x0a\x64\x80\
\x1c\x72\x60\x29\xac\x82\x42\x28\x86\xcd\xb0\x1d\x2a\x60\x2f\xd4\
\x40\x1d\x34\xc0\x51\x68\x86\x93\x70\x0e\x2e\xc2\x55\xb8\x0e\x3d\
\x70\x0f\xfa\x61\x08\x9e\xc1\x28\xbc\x81\x09\x04\x41\xc8\x08\x13\
\x61\x21\xda\x88\x01\x62\x8a\x58\x23\x8e\x08\x17\x99\x85\xf8\x21\
\xc1\x48\x04\x12\x8b\x24\x20\xc9\x88\x14\x51\x22\x4b\x91\x35\x48\
\x31\x52\x8a\x54\x20\x55\x48\x1d\xf2\x3d\x72\x02\x39\x87\x5c\x46\
\xba\x91\x3b\xc8\x00\x32\x82\xfc\x86\xbc\x47\x31\x94\x81\xb2\x51\
\x3d\xd4\x0c\xb5\x43\xb9\xa8\x37\x1a\x84\x46\xa2\x0b\xd0\x64\x74\
\x31\x9a\x8f\x16\xa0\x9b\xd0\x72\xb4\x1a\x3d\x8c\x36\xa1\xe7\xd0\
\xab\x68\x0f\xda\x8f\x3e\x43\xc7\x30\xc0\xe8\x18\x07\x33\xc4\x6c\
\x30\x2e\xc6\xc3\x42\xb1\x38\x2c\x09\x93\x63\xcb\xb1\x22\xac\x0c\
\xab\xc6\x1a\xb0\x56\xac\x03\xbb\x89\xf5\x63\xcf\xb1\x77\x04\x12\
\x81\x45\xc0\x09\x36\x04\x77\x42\x20\x61\x1e\x41\x48\x58\x4c\x58\
\x4e\xd8\x48\xa8\x20\x1c\x24\x34\x11\xda\x09\x37\x09\x03\x84\x51\
\xc2\x27\x22\x93\xa8\x4b\xb4\x26\xba\x11\xf9\xc4\x18\x62\x32\x31\
\x87\x58\x48\x2c\x23\xd6\x12\x8f\x13\x2f\x10\x7b\x88\x43\xc4\x37\
\x24\x12\x89\x43\x32\x27\xb9\x90\x02\x49\xb1\xa4\x54\xd2\x12\xd2\
\x46\xd2\x6e\x52\x23\xe9\x2c\xa9\x9b\x34\x48\x1a\x23\x93\xc9\xda\
\x64\x6b\xb2\x07\x39\x94\x2c\x20\x2b\xc8\x85\xe4\x9d\xe4\xc3\xe4\
\x33\xe4\x1b\xe4\x21\xf2\x5b\x0a\x9d\x62\x40\x71\xa4\xf8\x53\xe2\
\x28\x52\xca\x6a\x4a\x19\xe5\x10\xe5\x34\xe5\x06\x65\x98\x32\x41\
\x55\xa3\x9a\x52\xdd\xa8\xa1\x54\x11\x35\x8f\x5a\x42\xad\xa1\xb6\
\x52\xaf\x51\x87\xa8\x13\x34\x75\x9a\x39\xcd\x83\x16\x49\x4b\xa5\
\xad\xa2\x95\xd3\x1a\x68\x17\x68\xf7\x69\xaf\xe8\x74\xba\x11\xdd\
\x95\x1e\x4e\x97\xd0\x57\xd2\xcb\xe9\x47\xe8\x97\xe8\x03\xf4\x77\
\x0c\x0d\x86\x15\x83\xc7\x88\x67\x28\x19\x9b\x18\x07\x18\x67\x19\
\x77\x18\xaf\x98\x4c\xa6\x19\xd3\x8b\x19\xc7\x54\x30\x37\x31\xeb\
\x98\xe7\x99\x0f\x99\x6f\x55\x58\x2a\xb6\x2a\x7c\x15\x91\xca\x0a\
\x95\x4a\x95\x26\x95\x1b\x2a\x2f\x54\xa9\xaa\xa6\xaa\xde\xaa\x0b\
\x55\xf3\x55\xcb\x54\x8f\xa9\x5e\x53\x7d\xae\x46\x55\x33\x53\xe3\
\xa9\x09\xd4\x96\xab\x55\xaa\x9d\x50\xeb\x53\x1b\x53\x67\xa9\x3b\
\xa8\x87\xaa\x67\xa8\x6f\x54\x3f\xa4\x7e\x59\xfd\x89\x06\x59\xc3\
\x4c\xc3\x4f\x43\xa4\x51\xa0\xb1\x5f\xe3\xbc\xc6\x20\x0b\x63\x19\
\xb3\x78\x2c\x21\x6b\x0d\xab\x86\x75\x81\x35\xc4\x26\xb1\xcd\xd9\
\x7c\x76\x2a\xbb\x98\xfd\x1d\xbb\x8b\x3d\xaa\xa9\xa1\x39\x43\x33\
\x4a\x33\x57\xb3\x52\xf3\x94\x66\x3f\x07\xe3\x98\x71\xf8\x9c\x74\
\x4e\x09\xe7\x28\xa7\x97\xf3\x7e\x8a\xde\x14\xef\x29\xe2\x29\x1b\
\xa6\x34\x4c\xb9\x31\x65\x5c\x6b\xaa\x96\x97\x96\x58\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d\x07\x0d\
\x87\xd9\x0e\xab\x1d\x5a\x1d\x7e\x73\xb4\x72\x14\x3a\x56\x3a\xde\
\x9a\xce\x9c\xee\x3f\x7d\xc5\xf4\x96\xe9\x2f\x67\x58\xcf\x10\xcf\
\xd8\x33\xe3\xb6\x13\xcb\x29\xc4\x69\x9d\x53\x9b\xd3\x47\x67\x17\
\x67\xb9\x73\x83\xf3\x88\x8b\x89\x4b\x82\xcb\x2e\x97\x3e\x2e\x9b\
\x1b\xc6\xdd\xc8\xbd\xe4\x4a\x74\xf5\x71\x5d\xe1\x7a\xd2\xf5\x9d\
\x9b\xb3\x9b\xc2\xed\xa8\xdb\xaf\xee\x36\xee\x69\xee\x87\xdc\x9f\
\xcc\x34\x9f\x29\x9e\x59\x33\x73\xd0\xc3\xc8\x43\xe0\x51\xe5\xd1\
\x3f\x0b\x9f\x95\x30\x6b\xdf\xac\x7e\x4f\x43\x4f\x81\x67\xb5\xe7\
\x23\x2f\x63\x2f\x91\x57\xad\xd7\xb0\xb7\xa5\x77\xaa\xf7\x61\xef\
\x17\x3e\xf6\x3e\x72\x9f\xe3\x3e\xe3\x3c\x37\xde\x32\xde\x59\x5f\
\xcc\x37\xc0\xb7\xc8\xb7\xcb\x4f\xc3\x6f\x9e\x5f\x85\xdf\x43\x7f\
\x23\xff\x64\xff\x7a\xff\xd1\x00\xa7\x80\x25\x01\x67\x03\x89\x81\
\x41\x81\x5b\x02\xfb\xf8\x7a\x7c\x21\xbf\x8e\x3f\x3a\xdb\x65\xf6\
\xb2\xd9\xed\x41\x8c\xa0\xb9\x41\x15\x41\x8f\x82\xad\x82\xe5\xc1\
\xad\x21\x68\xc8\xec\x90\xad\x21\xf7\xe7\x98\xce\x91\xce\x69\x0e\
\x85\x50\x7e\xe8\xd6\xd0\x07\x61\xe6\x61\x8b\xc3\x7e\x0c\x27\x85\
\x87\x85\x57\x86\x3f\x8e\x70\x88\x58\x1a\xd1\x31\x97\x35\x77\xd1\
\xdc\x43\x73\xdf\x44\xfa\x44\x96\x44\xde\x9b\x67\x31\x4f\x39\xaf\
\x2d\x4a\x35\x2a\x3e\xaa\x2e\x6a\x3c\xda\x37\xba\x34\xba\x3f\xc6\
\x2e\x66\x59\xcc\xd5\x58\x9d\x58\x49\x6c\x4b\x1c\x39\x2e\x2a\xae\
\x36\x6e\x6c\xbe\xdf\xfc\xed\xf3\x87\xe2\x9d\xe2\x0b\xe3\x7b\x17\
\x98\x2f\xc8\x5d\x70\x79\xa1\xce\xc2\xf4\x85\xa7\x16\xa9\x2e\x12\
\x2c\x3a\x96\x40\x4c\x88\x4e\x38\x94\xf0\x41\x10\x2a\xa8\x16\x8c\
\x25\xf2\x13\x77\x25\x8e\x0a\x79\xc2\x1d\xc2\x67\x22\x2f\xd1\x36\
\xd1\x88\xd8\x43\x5c\x2a\x1e\x4e\xf2\x48\x2a\x4d\x7a\x92\xec\x91\
\xbc\x35\x79\x24\xc5\x33\xa5\x2c\xe5\xb9\x84\x27\xa9\x90\xbc\x4c\
\x0d\x4c\xdd\x9b\x3a\x9e\x16\x9a\x76\x20\x6d\x32\x3d\x3a\xbd\x31\
\x83\x92\x91\x90\x71\x42\xaa\x21\x4d\x93\xb6\x67\xea\x67\xe6\x66\
\x76\xcb\xac\x65\x85\xb2\xfe\xc5\x6e\x8b\xb7\x2f\x1e\x95\x07\xc9\
\x6b\xb3\x90\xac\x05\x59\x2d\x0a\xb6\x42\xa6\xe8\x54\x5a\x28\xd7\
\x2a\x07\xb2\x67\x65\x57\x66\xbf\xcd\x89\xca\x39\x96\xab\x9e\x2b\
\xcd\xed\xcc\xb3\xca\xdb\x90\x37\x9c\xef\x9f\xff\xed\x12\xc2\x12\
\xe1\x92\xb6\xa5\x86\x4b\x57\x2d\x1d\x58\xe6\xbd\xac\x6a\x39\xb2\
\x3c\x71\x79\xdb\x0a\xe3\x15\x05\x2b\x86\x56\x06\xac\x3c\xb8\x8a\
\xb6\x2a\x6d\xd5\x4f\xab\xed\x57\x97\xae\x7e\xbd\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ff\x68\xf9\xb1\xf5\x53\xd0\
\xa7\xfb\x93\x19\x93\x93\xff\x04\x03\x98\xf3\xfc\x63\x33\x2d\xdb\
\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x7a\x25\x00\x00\x80\x83\
\x00\x00\xf9\xff\x00\x00\x80\xe9\x00\x00\x75\x30\x00\x00\xea\x60\
\x00\x00\x3a\x98\x00\x00\x17\x6f\x92\x5f\xc5\x46\x00\x00\x00\x40\
\x49\x44\x41\x54\x78\xda\x5c\x8c\x31\x11\x00\x30\x08\xc4\x42\x2d\
\x20\x03\xfc\x2b\x61\x45\x02\x1a\xe8\x54\xae\x6d\xc6\xcf\x7d\xc4\
\xcc\x1a\x20\x22\x84\x8b\x05\x90\x99\xa8\x6a\xdf\x42\xba\x7b\xc6\
\xaa\x92\x47\x1c\xdc\x7d\xb2\x8b\x8f\x93\x7d\x1e\xc0\x64\xf7\x00\
\xf5\x9f\x1d\xd3\x02\x88\xef\xaf\x00\x00\x00\x00\x49\x45\x4e\x44\
\xae\x42\x60\x82\
\x00\x00\x03\xac\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x03\x29\x49\x44\
\x41\x54\x58\x85\xed\x95\x4f\x68\x5c\x55\x14\xc6\x7f\xe7\x65\x88\
\x64\xda\xc6\xbd\xa9\x94\x48\x57\xb6\x91\x3a\x28\xae\xd3\x4d\xc5\
\x0a\x4d\x40\x66\x63\xda\x37\x2f\x25\xcd\x46\x07\xd1\x24\x8e\xae\
\xb2\x50\xa8\x49\xdd\x64\x99\xc2\xbc\x19\xd3\x6e\x9e\x20\x53\xc1\
\xe2\x9f\x85\x75\x1b\xfc\xd3\xa4\x15\x91\x52\x4a\x70\x4a\xd7\x25\
\x33\x24\xcd\xe0\xfb\x5c\xbc\x37\x4d\x90\xbc\x37\x1d\xe9\xce\xf9\
\x56\xf7\xcf\x77\xce\xfd\xee\x39\xe7\x9e\x0b\x3d\xf4\xf0\x7f\x87\
\x75\x43\x0e\x82\xa0\x7f\xab\xd1\x18\x97\xd9\x98\x41\x0e\x18\x8a\
\xb7\xea\x98\xfd\x2a\xa8\x65\xb3\xd9\x5a\x3e\x9f\xdf\x79\xea\x02\
\xaa\xe5\xf2\x5b\x98\x2d\x00\xc3\x06\xb7\x04\x37\x64\x56\x07\x70\
\xc2\x70\x08\xb3\x51\xc1\x08\x70\xd7\x60\xee\x9c\xe7\x7d\xf5\x54\
\x04\x04\x41\xd0\xb7\xd5\x6c\x2e\x00\xef\x1b\x7c\x6b\x61\x58\x3a\
\x7b\xfe\xfc\xda\x7e\x5c\xdf\xf7\x4f\x38\x70\x11\x38\x05\x2c\xde\
\xdb\xd8\x28\xcd\xcf\xcf\x87\x69\xfe\x33\x9d\x04\xc4\x87\xbf\x27\
\x69\xd6\x9d\x9c\xbc\x94\xc6\xf5\x3c\xef\x26\xf0\x7a\xd5\xf7\x67\
\x81\x8b\xc3\x47\x8e\x00\xcc\xa5\xd9\xa4\x46\x20\x0e\xfb\x97\x66\
\x36\x73\xae\x50\xf8\x1c\x60\x69\x69\xe9\x99\xc1\xc1\xc1\x69\x93\
\xde\x26\x0a\x39\x26\xad\xcb\xec\xea\xc3\xcd\xcd\xe5\x62\xb1\xf8\
\x08\xa0\x52\xa9\xcc\x99\xf4\x99\x03\xe3\x67\x3d\xaf\xd6\xb5\x80\
\x20\x08\xfa\xb7\x9b\xcd\x3f\x24\xfd\xe9\x4e\x4e\xbe\x01\x70\xe5\
\xf2\xe5\xc3\x61\x26\x73\x3d\xce\x75\x08\x38\x31\x3d\x1a\x9b\xad\
\xf7\xb5\x5a\xa7\x27\xa6\xa6\xea\x00\x15\xdf\xff\xde\xcc\x86\x07\
\xb2\xd9\x63\x49\x85\xe9\xec\xb7\x08\xb0\xd5\x68\x8c\x0b\x5e\x70\
\xa4\x8f\xda\x37\x0f\x33\x99\xeb\x32\x3b\xbe\x8f\x6d\x7b\x3c\xf2\
\x77\x26\xf3\x4d\x10\x04\xfd\x00\xe6\x38\x1f\x22\x1d\xdd\x6e\x36\
\xcf\x24\x9d\x93\x28\x40\x66\x63\xc0\x5a\xbb\xe0\x9e\x3d\x74\xe8\
\x82\x60\x04\x29\x39\x6d\xd1\xde\x4b\x5b\x8d\xc6\x05\x00\xd7\x75\
\x7f\xc3\xec\x36\xd0\xbd\x00\x83\x9c\x49\x3f\xed\x59\x9a\x20\x0a\
\x75\x3a\xa4\xd0\x22\x6e\x7b\xfe\xa3\xe0\x95\xae\x05\x60\xf6\x5c\
\xfb\x9d\xc7\x38\x96\xca\xdf\xb5\x73\x14\x71\xdb\xb8\x8f\xd9\x50\
\x12\x3d\xd5\xa1\xcc\xba\xea\x94\xfb\xea\x01\x43\x4a\x8c\x5c\xb2\
\x00\xe9\x81\x49\x87\xf7\xac\xfc\xce\x13\xa6\x40\x70\xfb\xf1\x34\
\xba\xfd\x83\xee\x05\x98\xfd\x8c\xd9\xe8\x9e\x95\x2b\xa9\xfc\x5d\
\x3b\xc7\xe0\xea\xae\x1e\x9d\x04\x56\xbb\x16\x20\xa8\x21\x1d\xf7\
\x7d\xff\x04\xc0\xc3\xcd\xcd\x65\xcc\xd6\x31\x53\xca\xe1\x02\x6e\
\x0e\x1c\x3c\xb8\x0c\xb0\x52\x2e\xe7\x0c\x5e\x44\xfa\xba\x6b\x01\
\xd9\x6c\xb6\x06\xdc\x8d\x7b\x3b\xc5\x62\xf1\x51\x5f\xab\x75\x1a\
\xb8\x15\x53\x76\xd3\xd1\xce\xb1\xb4\x86\xe3\xbc\x99\xcf\xe7\x77\
\x24\x59\x18\x7d\x5e\x77\xb6\x5b\xad\x6b\x5d\x0b\xc8\xe7\xf3\x3b\
\x38\xce\x2c\x70\x2a\xee\xed\x4c\x4c\x4d\xd5\x07\xb2\xd9\x57\x91\
\xde\x95\xb4\x0a\x34\x81\xa6\x60\xd5\xcc\xde\x19\x38\x70\xe0\x35\
\xd7\x75\xef\x03\x54\x7d\xbf\x04\x9c\x94\xd9\xcc\xf4\xf4\x74\x2b\
\xe9\x9c\x8e\x55\x5e\xf5\xfd\x05\xe0\x03\xa0\xe4\x7a\xde\x62\x27\
\xbe\x24\xab\xfa\x7e\xc9\xcc\x3e\x01\x16\x5d\xcf\x2b\xa5\xf1\x3b\
\x16\xd5\xbd\x8d\x8d\x92\xa4\x4b\xc0\x42\xd5\xf7\xbf\xab\x56\xab\
\x2f\x27\x71\x57\xca\xe5\xdc\x17\x95\xca\x0f\x66\xf6\x29\xd1\x77\
\xfc\x71\x27\xff\x4f\xfc\xce\x57\x7c\x7f\x2c\x34\x5b\x44\x3a\x1a\
\xb7\xd7\x1b\x82\xbf\x62\x27\xcf\x23\x8d\x12\x35\xa0\x3b\x32\x9b\
\x29\x14\x0a\x89\x85\xf7\x9f\x04\xc0\xe3\x1f\xf2\x8c\x60\x0c\xc8\
\x61\x16\xf5\x09\xa9\x6e\xf0\x8b\xa4\xda\x76\xab\x75\x2d\x2d\xe7\
\x3d\xf4\xd0\xc3\xbf\xf1\x0f\x78\xe5\x4e\xf2\x11\xe4\x69\x42\x00\
\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x02\x4a\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\
\xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdf\x04\x19\x10\x14\x1a\x38\xc7\x37\xd0\x00\x00\x00\x1d\x69\x54\
\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x00\x00\x00\x00\x43\x72\
\x65\x61\x74\x65\x64\x20\x77\x69\x74\x68\x20\x47\x49\x4d\x50\x64\
\x2e\x65\x07\x00\x00\x01\xae\x49\x44\x41\x54\x78\xda\xed\x9b\x49\
\x92\xc3\x20\x0c\x45\x23\x5d\xdc\xf6\xc9\xd3\xbb\xae\x54\x06\x26\
\xe9\x7f\x09\x8c\xd6\x5d\x32\xef\x21\x68\x20\xf0\x78\xec\xd8\xb1\
\xe3\xce\x21\xcc\x8f\x9d\xe7\xf9\x6c\xfc\x3b\x59\x42\x40\x2b\x70\
\xa4\x10\xc9\x0a\xcd\x92\x21\xb3\x80\xa3\x44\xc8\x8c\xf0\x9e\x12\
\x64\x46\x70\x4f\x11\x32\x3b\xbc\x55\x82\xcc\x0e\x6e\x15\x21\x2b\
\xc1\x8f\x48\x90\xd5\xe0\x7b\x25\xe8\x5e\x0a\x2f\xd8\xfb\x3d\x55\
\x20\x56\xf8\xe3\x38\xfe\x73\x5c\xd7\x45\x11\xf5\xfa\xcd\xda\x77\
\x6b\x12\xd4\xbb\x61\xef\x8d\x43\xc3\x5b\x43\x11\xa5\x8f\x92\x30\
\x92\xb7\xc6\xa0\xa8\x71\xef\x2d\xc1\x92\xaf\xc4\x62\x1e\x02\xa5\
\xf1\xe7\x25\xa1\x94\xc7\x3a\xef\x88\x57\xef\xa3\x1a\xe9\x99\xf7\
\xdb\x84\xe8\x36\x09\x22\x2a\x01\xd9\xf3\x90\xff\x02\x9e\x12\x18\
\xf0\x5f\x87\x80\xc7\xa2\xc7\xda\x78\x24\xfc\xfb\x30\x80\x2c\x85\
\x2d\x95\xc0\xea\x79\xf8\x5e\x60\x44\x02\x1b\x1e\xbe\x19\xea\x91\
\x10\x01\xff\x31\x07\xa0\x36\x3d\x35\x38\x36\xfc\xeb\x3c\x40\xd9\
\x0e\x8f\xce\x09\x8c\xcd\x15\xed\x3c\xa0\x17\x86\xb5\xb3\xa4\x1e\
\x88\xb4\x42\xb1\xe0\xe9\x02\x5a\xe0\x98\xf0\x21\x02\x2c\xeb\x80\
\xe9\x05\xb4\xc2\x31\x25\x68\x36\x78\xb6\x04\x8d\x86\x67\x9c\x27\
\x84\x0a\x68\x81\x8f\x94\x00\xd9\x0d\x8e\xf6\x3c\x63\x51\x44\xd9\
\x0d\x8e\xc2\x44\x54\x82\x66\x1a\xf3\x11\x12\x34\x13\x7c\x84\x04\
\xb7\x43\x51\xc4\x18\xf6\xce\x07\x3d\x14\x45\x4c\x60\x8c\x4a\xd0\
\xac\xf0\x2c\x09\x52\x28\x97\x67\x34\xbc\xe7\x77\x7e\xfd\x48\x1a\
\x72\x26\x98\x21\x5f\x55\x80\xe5\xe6\x15\xaa\xb1\xa3\x79\x4b\x2c\
\x9a\xbd\xe7\xd1\xf9\xcd\x17\x24\xb2\x47\xad\x92\xf7\x15\x99\x8e\
\x64\xfb\x96\xd8\x8a\xb1\x2f\x4a\x0e\x24\xbf\xef\x55\xd9\xcc\x22\
\x68\x97\xa5\x33\x4a\x08\xb9\x2e\x9f\x45\x82\xf5\xd1\xc4\x7e\x32\
\x03\x68\xd8\x3d\x1f\x4d\x21\x65\x4c\xf5\x6c\xce\x43\x08\xf3\xe1\
\xe4\x8e\xbb\xc7\x1f\xfe\x88\x5a\xe2\xcd\xef\x1c\x49\x00\x00\x00\
\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xac\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x07\x00\x00\x00\x3f\x08\x06\x00\x00\x00\x2c\x7b\xd2\x13\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xb3\x00\x79\x00\x79\xdc\xdd\
\x53\xfc\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdf\x04\x19\x10\x2e\x14\xfa\xd6\xc4\xae\x00\x00\x00\x39\x49\x44\
\x41\x54\x38\xcb\x63\x60\x20\x06\xc4\xc7\xc7\x33\xc4\xc7\xc7\xa3\
\x88\x31\x61\x53\x84\x53\x12\xaf\xce\x91\x28\xc9\x82\xc4\xfe\x8f\
\xc4\x66\x1c\x0d\xa1\x51\xc9\x51\xc9\x51\x49\x7c\x05\x06\xe3\x68\
\x08\x91\x2a\x49\x3e\x00\x00\x88\x4b\x04\xd3\x39\x2e\x90\x3f\x00\
\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xb6\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x18\x00\x00\x00\x11\x08\x06\x00\x00\x00\xc7\x78\x6c\x30\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\
\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\
\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\
\x0b\x2c\x0d\x1f\x43\xaa\xe1\x00\x00\x00\x36\x49\x44\x41\x54\x38\
\xcb\x63\x60\x20\x01\x2c\x5a\xb4\xe8\xff\xa2\x45\x8b\xfe\x93\xa2\
\x87\x89\x81\xc6\x60\xd4\x82\x11\x60\x01\x23\xa9\xc9\x74\xd0\xf9\
\x80\x85\x1c\x4d\x71\x71\x71\x8c\xa3\xa9\x68\xd4\x82\x61\x64\x01\
\x00\x31\xb5\x09\xec\x1f\x4b\xb4\x15\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x02\x42\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xb3\x00\x79\x00\x79\xdc\xdd\
\x53\xfc\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdf\x04\x19\x10\x17\x3b\x5f\x83\x74\x4d\x00\x00\x00\x1d\x69\x54\
\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x00\x00\x00\x00\x43\x72\
\x65\x61\x74\x65\x64\x20\x77\x69\x74\x68\x20\x47\x49\x4d\x50\x64\
\x2e\x65\x07\x00\x00\x01\xa6\x49\x44\x41\x54\x78\xda\xed\x9b\xdb\
\x0e\xc3\x20\x0c\x43\x9b\x68\xff\xdd\xf6\xcb\xb7\xb7\x69\x9a\x76\
\x49\x4b\xec\x98\x42\x5e\x37\x51\x7c\x70\x28\x85\xb0\x2c\x33\x66\
\xcc\x18\x39\x8c\xf9\xb0\x6d\xdb\xee\xc1\xff\xd9\x25\x00\x44\x05\
\x57\x02\x31\x55\xd1\x2c\x18\xd6\x8b\x70\x14\x08\xeb\x51\x7c\x26\
\x04\xeb\x51\x78\x26\x08\xeb\x5d\x7c\x2b\x04\xeb\x5d\x78\x2b\x08\
\xbb\x92\xf8\x33\x10\xec\x6a\xe2\x8f\x42\xb8\x55\x76\x72\x5d\xd7\
\x67\x27\xf7\x7d\x2f\x01\x6c\x55\xa3\xff\x2a\x1e\x05\x21\xe2\x02\
\x53\x11\x5f\x05\xc1\x2b\x6d\x7f\xe6\x77\x6a\x0a\x64\x8f\xfe\x11\
\x71\x99\x4e\xf8\xe5\x02\x53\x14\xcf\x84\xe0\xd5\xb6\xff\x25\x92\
\x91\x0e\x86\x1e\xfd\xa8\x78\xc6\xc4\xf8\xc9\x05\xae\x32\xf2\x55\
\x4e\x70\x25\xdb\x57\x40\x30\x84\xfd\x5b\xed\x8c\x4c\x87\xf7\x34\
\x70\x85\x91\xaf\x74\x82\xab\x89\x67\x43\x70\x45\xf1\x4c\x08\x96\
\x91\xff\xe8\x57\x58\x76\xfb\xaf\xf3\x80\x2b\x8e\x3c\xd3\x09\xae\
\x2e\x1e\x0d\xc1\x7b\x10\x8f\x84\xe0\xcc\x4e\x2a\xb6\x4f\x5d\x07\
\x28\xb6\xef\x6a\x39\xc9\x4e\x3b\x57\xcb\x49\xf6\x9c\xe3\xc8\x9c\
\xcc\x82\x80\x9c\x70\x53\xe6\x00\x24\x04\xf4\xdb\x26\xf5\x6b\x30\
\xbb\xb3\x08\xf1\xd0\xaf\xc1\x4c\x27\xb0\xd6\x19\xd4\x75\x40\x14\
\x02\x73\x91\x05\xd9\x11\x6a\x81\xc0\x5e\x61\x42\x37\x45\x8f\x8a\
\x41\x8b\xa7\x6f\x8a\x1e\x71\x42\xc5\xb7\x05\x1c\x40\x14\x42\x95\
\xf8\xaf\x29\x90\x99\x06\x2d\xeb\x81\xcb\x9c\x0c\x9d\x11\xc3\xaa\
\x17\xa0\x1e\x8e\x46\x9d\xc0\x3c\x22\xa7\x1f\x8f\xff\x13\xc7\xae\
\x14\x29\x29\x90\xf8\xe6\x04\x84\xf8\x7f\x05\x12\x65\x25\x32\xef\
\x10\x2a\xc4\x87\x01\x20\x21\xa0\x22\x5a\x25\xe6\xcb\xe0\x31\x0b\
\x25\x4f\x34\x3e\x6e\xa9\xac\x32\x08\x5a\xb1\xb4\x22\x84\x92\x72\
\x79\x15\x08\xad\x97\x26\xe6\x95\x19\x40\xc7\xc6\xbc\x34\x85\x84\
\xd1\xd5\xb5\xb9\x0c\x20\xcc\x8b\x93\x33\x46\x8f\x07\x53\x21\x72\
\xe7\x17\x36\x2b\x63\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x02\xd8\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x02\x55\x49\x44\
\x41\x54\x58\x85\xed\x95\x4d\x4f\x53\x51\x10\x86\x9f\xb9\x1a\x12\
\xef\x4f\x10\x0d\xc1\xb0\x12\x4d\xb0\xf1\x0f\xc0\x06\xe3\x06\x48\
\x4c\x77\xd0\x0f\x16\x6c\x8d\x01\x2c\xae\x58\x68\x82\x05\xff\xc2\
\x3d\xad\xec\xae\x89\x16\x57\x7e\x2c\xc4\xad\xf1\x8b\x68\x62\x0c\
\x21\xa4\xb1\x86\x3f\xd0\x86\x86\x26\x7d\x5d\xb4\x21\xc6\x70\x5b\
\x2e\xb0\xb3\xef\x76\xe6\xcc\x3c\x67\xce\x99\x19\xe8\xa9\xa7\xff\
\x5d\x16\xc7\x39\x0c\xc3\xbe\xfd\x6a\x75\x4a\x66\x93\x06\x09\xa0\
\xbf\x6d\xaa\x60\xf6\x59\x50\xf2\x7d\xbf\x94\x4c\x26\x0f\xce\x1c\
\xa0\x18\x04\x77\x30\xcb\x03\x83\x06\xdf\x04\x9b\x32\xab\x00\x78\
\xcd\x66\x3f\x66\xa3\x82\xeb\xc0\x8e\xc1\xe2\x4c\x26\xf3\xfc\x4c\
\x00\xc2\x30\x3c\xb7\x5f\xab\xe5\x81\x7b\x06\xaf\xac\xd9\xcc\x4d\
\xcf\xce\x6e\x1d\xe5\xeb\x9c\x1b\xf1\x60\x05\x18\x07\x56\x77\xcb\
\xe5\xdc\xf2\xf2\x72\xb3\x53\xfc\xf3\xdd\x00\xda\xc9\xef\x4a\x5a\
\x48\x65\xb3\x6b\x9d\x7c\x33\x99\xcc\x57\xe0\x56\xd1\xb9\x05\x60\
\x65\x70\x60\x00\x60\xb1\xd3\x99\x8e\x15\x68\x97\xfd\x99\x99\xcd\
\xcf\xa4\xd3\x4f\xba\xc1\xfe\xad\x42\xa1\xb0\x68\xd2\x63\x0f\xa6\
\xa6\x33\x99\x52\x6c\x80\x30\x0c\xfb\xea\xb5\xda\x0f\x49\x3f\x53\
\xd9\xec\xed\x38\xc9\x0f\x21\x9c\x7b\x63\x66\x83\x17\x7c\x7f\x38\
\xea\x63\x7a\x51\x87\xf7\xab\xd5\x29\xc1\x15\x4f\x5a\x3a\x49\x72\
\x00\xf3\xbc\xfb\x48\x43\xf5\x5a\x6d\x22\xca\x27\x12\x40\x66\x93\
\xc0\x56\xd4\x87\x3b\x8e\x52\xa9\xd4\x17\xcc\xbe\x03\xf1\x01\x0c\
\x12\x26\xbd\x3f\x69\xf2\x43\x49\xef\x04\x37\xa3\xcc\xd1\x5d\x60\
\x76\x51\x50\x39\x35\x00\xfc\xc6\xac\x3f\xca\x18\x59\x01\x00\x99\
\xc5\x9a\x94\x47\xc9\xc0\x90\x22\x67\x41\x34\x80\xb4\x67\xd2\xa5\
\xd3\x02\xa8\x75\xfb\xbd\x28\x7b\xa7\x27\xf8\x08\x8c\x9e\x1a\x40\
\x1a\x33\xf8\x10\x65\x8f\xee\x02\x28\x21\x5d\x73\xce\x8d\x9c\x34\
\xf9\x7a\x10\x24\x0c\xae\x22\xbd\x8c\x0d\xe0\xfb\x7e\x09\xd8\x69\
\xcf\xf6\xd8\x92\x64\xcd\xd6\xf2\xda\xae\x37\x1a\x1b\xb1\x01\x92\
\xc9\xe4\x01\x9e\xb7\x00\x8c\xb7\x67\x7b\x2c\x15\x9d\xcb\x01\x63\
\x32\x9b\x9f\x9b\x9b\x6b\xc4\x06\x00\x48\xa5\x52\x2f\x80\x55\x60\
\xe5\xb8\x10\x92\xac\x10\x04\x4b\x66\xf6\x10\xc8\xa7\xd3\xe9\xc8\
\xf2\x77\x05\x00\xd8\x2d\x97\x73\x92\xd6\x80\x7c\xd1\xb9\xd7\xc5\
\x62\xf1\x46\x94\xef\x7a\x10\x24\x9e\x16\x0a\x6f\xcd\xec\x11\xad\
\x75\xfc\xa0\x5b\xfc\x63\xf7\xf9\xba\x73\x93\x4d\xb3\x55\xa4\xa1\
\xf6\x78\xdd\x14\xfc\x6a\x07\xb9\x8c\x34\x0a\x0c\x03\xdb\x32\x9b\
\xef\x76\xf3\xd8\x00\x70\xb8\x21\x27\x04\x93\x40\x02\xb3\xd6\x9c\
\x90\x2a\x06\x9f\x24\x95\xea\x8d\xc6\x46\xa7\x37\xef\xa9\xa7\x9e\
\xfe\xd5\x1f\x3e\xd4\xef\x44\x0d\xbc\xff\x65\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\x9f\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x06\x08\x04\x00\x00\x00\xbb\xce\x7c\x4e\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x08\x14\x1f\xf9\
\x23\xd9\x0b\x00\x00\x00\x23\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x0d\xe6\x7c\x80\xb1\x18\x91\x05\x52\x04\xe0\x42\x08\x15\x29\x02\
\x0c\x0c\x8c\xc8\x02\x08\x95\x68\x00\x00\xac\xac\x07\x90\x4e\x65\
\x34\xac\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\xd0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x4d\x49\x44\
\x41\x54\x58\x85\xed\xd7\x4d\x4e\xc2\x40\x18\xc6\xf1\xff\x5b\x08\
\x08\xea\x01\xd0\x2b\x88\x09\x5b\xcf\x21\xbb\xca\xd8\x1a\x49\xe0\
\x3e\x62\x42\x42\x69\x49\x97\x78\x0c\xd7\x84\x70\x07\x71\xef\x07\
\x02\x81\xd7\x85\xd4\x10\xc0\xdd\x10\x13\xed\xb3\x9b\xc9\x9b\x79\
\x7e\x93\x6e\x3a\xf0\xdf\x23\x9b\x6b\xcf\x98\x6b\xa0\x01\x94\x81\
\x03\x4b\x3d\x1f\xc0\x48\x44\x5a\x41\x18\x46\x80\xee\x02\x88\x67\
\x4c\x08\xd4\x80\x29\x30\x00\x5e\x2d\x01\x8e\x80\x0a\x90\x07\xba\
\xdd\x28\xba\x49\x10\xdf\x00\xcf\x18\x0f\x08\x04\x1e\xb3\x8b\x45\
\xb5\x1d\xc7\x63\x4b\xe5\x00\xd4\x5d\xb7\x34\x77\x9c\x3e\x22\x17\
\x02\x26\x88\xa2\x1e\x80\xb3\x36\xd3\x00\xa6\x4b\x91\x4b\xdb\xe5\
\x00\xed\x38\x1e\x4b\x36\x5b\x05\x66\x2a\xd2\x4c\xf6\xd7\x01\x67\
\xc0\x20\x0c\xc3\x67\xdb\xe5\x49\x82\x20\x78\x42\x64\x80\x6a\x79\
\x17\xa0\x80\xea\xfb\xbe\xca\xbf\xb3\x5c\xbe\x01\xc5\x5d\x80\x5f\
\x49\x0a\x48\x01\x29\x20\x05\xa4\x80\x14\x90\x02\x52\xc0\x3a\x60\
\x82\x48\xf1\xc7\x49\x6b\x8d\xce\x21\x30\xd9\x02\x28\x8c\x80\x4a\
\xdd\x75\x4b\xfb\xea\xae\xd5\x6a\xa7\xa8\x56\x80\xe1\x16\xc0\x11\
\xb9\x07\xf2\xf3\x4c\xe6\xc1\xf7\xfd\x93\x7d\x94\x67\x44\xfa\x40\
\x4e\x45\x5a\xc9\xfe\xe6\xc3\xa4\x03\x78\xc0\x6c\xf5\xf7\xfa\x62\
\xa5\x5d\xe4\x78\x75\xf3\x9c\x42\x27\x8c\xa2\x5b\x36\x1f\x26\xc9\
\xa8\x6f\xcc\x95\x8a\x34\x51\x3d\x07\x0a\x56\x00\x5f\xdf\x7c\x88\
\xea\x5d\xb7\xd7\x8b\x2d\x9d\xf9\x47\xf2\x09\x3e\x70\x64\x41\x95\
\x87\xdf\x69\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xc3\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\
\xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdc\x0b\x07\x09\x2e\x37\xff\x44\xe8\xf0\x00\x00\x00\x1d\x69\x54\
\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x00\x00\x00\x00\x43\x72\
\x65\x61\x74\x65\x64\x20\x77\x69\x74\x68\x20\x47\x49\x4d\x50\x64\
\x2e\x65\x07\x00\x00\x00\x27\x49\x44\x41\x54\x78\xda\xed\xc1\x01\
\x0d\x00\x00\x00\xc2\xa0\xf7\x4f\x6d\x0e\x37\xa0\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x77\x03\x40\x40\
\x00\x01\xaf\x7a\x0e\xe8\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\
\x60\x82\
\x00\x00\x01\xd0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x4d\x49\x44\
\x41\x54\x58\x85\xed\x97\x3b\x4e\xc3\x40\x14\x00\xe7\x45\x51\xc2\
\xf7\x00\x81\x2b\x00\x52\xee\x42\xca\x8d\xed\x58\x14\x70\x1f\x42\
\x65\x99\x8d\x29\xc3\x1d\x68\xa8\xa3\x28\x77\x20\xf4\x7c\x42\x3e\
\xf2\xa3\x70\x8c\x8c\x4c\xb9\x16\x12\x78\x2a\x5b\x5a\x79\x66\x25\
\x17\xef\xc1\x7f\x47\x8a\x2f\xaa\x2a\x36\x8e\xfd\x86\xc8\xa5\xc2\
\x29\xb0\xe3\xc8\xf3\x21\x30\x03\x86\xc6\xf7\xad\x88\x68\x29\x40\
\x55\x25\x89\xe3\x5b\x15\xe9\x03\x4b\x60\x82\xc8\xab\x13\xbd\xea\
\x01\xd0\x05\xda\x88\xc4\x7d\xcf\x0b\xf3\x88\x66\x7e\xc6\xc6\xb1\
\x2f\x99\xfc\xb1\xd1\x6c\xf6\x8c\x31\x73\x27\xf2\x2d\x49\x92\x74\
\xd2\xcd\x66\x8c\x6a\x60\xad\x7d\x00\x46\x00\x8d\xfc\x40\x43\xe4\
\x12\x58\xa6\x70\xee\x5a\x0e\x60\x8c\x99\x6f\xd2\xb4\x07\xac\x44\
\xf5\xea\xcb\x9b\x3f\x28\x9c\x00\x93\x20\x08\x9e\x5d\xcb\x73\xc2\
\x30\x7c\x02\x26\x64\xff\xd7\xf7\x00\x60\x17\x78\xaf\x4a\x5e\xe0\
\x0d\xd8\xfb\x29\xe0\x57\xa8\x03\xea\x80\x3a\xa0\x0e\xa8\x03\xea\
\x80\x3a\xa0\x0e\x28\x06\x2c\x28\x4c\x2a\x15\xb2\xbf\x75\x95\x02\
\x66\x40\x37\x49\x92\x4e\x55\x66\x6b\xed\x31\xd9\x78\x3e\x2d\x05\
\x08\xdc\x00\xed\x74\xbd\xbe\x8f\xa2\xe8\xa8\x12\x79\x9a\x8e\x81\
\x96\xc0\xb0\xe0\xcd\x50\x55\x19\x59\x1b\xa1\x1a\x00\x2b\xb2\xc5\
\xe4\xc5\x89\x5d\xf5\x90\xec\xe6\x2d\x85\xc8\xf3\xfd\x8b\x7c\x31\
\x29\xaf\x66\xd6\x9a\xed\xdc\x7e\x46\x36\x29\xbb\x60\x01\x4c\x51\
\xbd\xf6\x06\x83\x3b\x47\xdf\xfc\x23\x7c\x02\x90\xc4\x75\x30\xa3\
\x38\xd1\xd4\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xef\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x51\x00\x00\x00\x3a\x08\x06\x00\x00\x00\xc8\xbc\xb5\xaf\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\
\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\
\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\
\x0b\x2a\x32\xff\x7f\x20\x5a\x00\x00\x00\x6f\x49\x44\x41\x54\x78\
\xda\xed\xd0\xb1\x0d\x00\x30\x08\x03\x41\xc8\xa0\x0c\xc7\xa2\x49\
\xcf\x04\x28\xba\x2f\x5d\x59\x97\xb1\xb4\xee\xbe\x73\xab\xaa\xdc\
\xf8\xf5\x84\x20\x42\x84\x28\x88\x10\x21\x42\x14\x44\x88\x10\x21\
\x0a\x22\x44\x88\x10\x05\x11\x22\x44\x88\x82\x08\x11\x22\x44\x41\
\x84\x08\x51\x10\x21\x42\x84\x28\x88\x10\x21\x42\x14\x44\x88\x10\
\x21\x0a\x22\x44\x88\x10\x05\x11\x22\x44\x88\x82\x08\x11\x22\x44\
\x41\x84\x08\x51\x10\x21\x42\xfc\xaa\x07\x12\x55\x04\x74\x56\x9e\
\x9e\x54\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x02\x56\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\
\xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdf\x04\x19\x10\x14\x2d\x80\x7a\x92\xdf\x00\x00\x00\x1d\x69\x54\
\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x00\x00\x00\x00\x43\x72\
\x65\x61\x74\x65\x64\x20\x77\x69\x74\x68\x20\x47\x49\x4d\x50\x64\
\x2e\x65\x07\x00\x00\x01\xba\x49\x44\x41\x54\x78\xda\xed\x9b\x5b\
\x92\x02\x21\x0c\x45\x4d\x16\xa6\x1b\xd0\xd5\x8e\x1b\xd0\x8d\xe9\
\x9f\x65\x39\xda\x3c\x92\x7b\x13\x68\xf2\x3d\x95\xe6\x1c\x1e\x43\
\x10\x0e\x87\x15\x2b\x56\xec\x39\x84\xf9\xb1\xbf\xe3\xf1\x51\xf3\
\x77\x97\xfb\x5d\xa6\x10\x50\x0b\x1c\x29\x44\xb2\x42\xb3\x64\xc8\
\x28\xe0\x28\x11\x32\x22\xbc\xa7\x04\x19\x11\xdc\x53\x84\x8c\x0e\
\x6f\x95\x20\xa3\x83\x5b\x45\xc8\x4c\xf0\x3d\x12\x64\x36\xf8\x56\
\x09\xba\xb6\xc2\x13\xf6\x7e\xcb\x28\x10\x2b\xfc\xf9\x76\x7b\xe5\
\xb8\x9e\x4e\x14\x51\xef\xdf\x2c\x7d\xb7\x24\x41\xbd\x1b\xf6\xd9\
\x38\x34\xbc\x35\x14\x31\xf4\x51\x12\x7a\xf2\x96\x18\x14\x35\xef\
\xbd\x25\x58\xf2\x6d\xb1\x98\xa7\xc0\xd6\xfc\xf3\x92\xb0\x95\xc7\
\xba\xee\x88\x57\xef\xa3\x1a\xe9\x99\xf7\xdb\x82\xe8\xb6\x08\x22\
\x46\x02\xb2\xe7\x21\xff\x05\x3c\x25\x30\xe0\xbf\x4e\x01\x8f\x4d\
\x8f\xb5\xf1\x48\xf8\xcf\x69\x00\xd9\x0a\x5b\x46\x02\xab\xe7\xe1\
\xb5\x40\x8f\x04\x36\x3c\xbc\x18\x6a\x91\x10\x01\xff\x6f\x0d\x40\
\x15\x3d\x25\x38\x36\xfc\xfb\x3a\x40\x29\x87\x7b\xd7\x04\x46\x71\
\x45\x3b\x0f\x68\x85\x61\x55\x96\xd4\x03\x91\x5a\x28\x16\x3c\x5d\
\x40\x0d\x1c\x13\x3e\x44\x80\x65\x1f\x30\xbc\x80\x5a\x38\xa6\x04\
\xcd\x06\xcf\x96\xa0\xd1\xf0\x8c\xf3\x84\x50\x01\x35\xf0\x91\x12\
\x20\xd5\x60\x6f\xcf\x33\x36\x45\x94\x6a\xb0\x17\x26\x62\x24\x68\
\xa6\x39\x1f\x21\x41\x33\xc1\x47\x48\x70\x3b\x14\x45\xcc\x61\xef\
\x7c\xd0\x43\x51\xc4\x02\xc6\x18\x09\x9a\x15\x9e\x25\xe1\x67\x82\
\xda\x69\xc0\xaa\xe7\xad\xdf\xf9\xf5\x23\x69\xc8\x99\x60\x86\x7c\
\x45\x01\x96\x9b\x57\xa8\xc6\xf6\xe6\xdd\x62\xd1\xec\x3d\x8f\xce\
\x6f\xbe\x20\x91\x3d\x4a\x23\x79\x5d\x91\xa9\x4d\xb6\x6e\x89\x4d\
\x1a\xeb\xa2\x64\x6b\xf2\x5d\x5f\x95\xcd\x2c\x82\x76\x59\x3a\xa3\
\x84\x90\xeb\xf2\x59\x24\x58\x1f\x4d\xac\x27\x33\xde\x0d\xdb\xed\
\xa3\x29\xa4\x8c\xa1\x9e\xcd\x79\x08\x61\x3e\x9c\x5c\xb1\xf7\x78\
\x02\x51\xa0\x5a\x91\x77\xd2\x02\x23\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x01\xec\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x69\x49\x44\
\x41\x54\x58\x85\xed\x97\x3b\x4e\xc3\x40\x10\x86\xbf\xb1\xa2\x84\
\xe7\x01\x02\x57\x00\xa4\xdc\x85\x94\x8e\xed\x44\x14\x70\x1f\x42\
\x65\x2d\x1b\x53\x86\x3b\xd0\x50\x47\x51\xee\x40\xe8\x79\x84\x3c\
\xe4\xa1\x70\x8c\x8c\x2c\x25\x05\x36\x05\xf8\xaf\x76\xb5\x23\x7f\
\x9f\xad\x95\x3c\x03\xff\x3d\x92\xdd\xa8\xaa\x58\x63\x7c\x47\xe4\
\x52\xe1\x14\xd8\x29\x88\xf3\x21\x30\x01\xfa\xae\xef\x5b\x11\xd1\
\x9c\x80\xaa\x4a\x64\xcc\xad\x8a\x74\x80\x39\x30\x42\xe4\xb5\x10\
\xbc\xea\x01\xd0\x02\x1a\x88\x98\x8e\xe7\xf5\x52\x89\x5a\x5a\x63\
\x8d\xf1\x25\x81\x3f\x3a\xb5\x5a\xdb\x75\xdd\x69\x21\xf0\x75\xa2\
\x28\x6a\xc6\xab\xd5\x10\xd5\xc0\x5a\xfb\x00\x0c\x00\x9c\xb4\xc0\
\x11\xb9\x04\xe6\x31\x9c\x17\x0d\x07\x70\x5d\x77\xba\x8a\xe3\x36\
\xb0\x10\xd5\xab\x2f\x6e\xba\x50\x38\x01\x46\x41\x10\x3c\x17\x0d\
\x4f\xd3\xeb\xf5\x9e\x80\x11\xc9\xfd\xfa\x2e\x00\xec\x02\xef\x65\
\xc1\x33\x79\x03\xf6\xd2\x4d\x6d\x43\x21\x00\xd6\x18\xdd\x56\xb3\
\x29\x5e\x10\xc8\xa6\x73\x67\xd3\xe1\x6f\xa4\x12\xa8\x04\x2a\x81\
\x4a\xa0\x12\xa8\x04\x2a\x81\xad\xfd\xc0\xb6\xff\xf9\x4f\x93\xfd\
\x02\x33\x32\x9d\x4a\x89\xd9\x5f\xb3\x72\x02\x13\xa0\x15\x45\x51\
\xb3\x2c\xb2\xb5\xf6\x98\xa4\x3d\x1f\xe7\x04\x04\x6e\x80\x46\xbc\
\x5c\xde\x87\x61\x78\x54\x0a\x3c\x8e\x87\x40\x5d\xa0\x9f\xe1\x26\
\x51\x55\x19\x58\x1b\xa2\x1a\x00\x0b\x92\xc1\xe4\xa5\x10\xba\xea\
\x21\xc9\x9b\xd7\x15\x42\xcf\xf7\x2f\xd2\xc1\x24\x3f\x9a\x59\xeb\
\xae\xfb\xf6\x33\x92\x4e\xb9\x88\xcc\x80\x31\xaa\xd7\x5e\xb7\x7b\
\x57\xd0\x33\xff\x48\x3e\x01\xac\x18\x7a\x56\x83\xd7\xe8\x6e\x00\
\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xa6\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x09\x08\x04\x00\x00\x00\xbb\x93\x95\x16\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x14\x1d\x00\xb0\
\xd5\x35\xa3\x00\x00\x00\x2a\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x06\xfe\x9f\x67\x60\x60\x42\x30\xa1\x1c\x08\x93\x81\x81\x09\xc1\
\x64\x60\x60\x62\x60\x60\x34\x44\xe2\x20\x73\x19\x90\x8d\x40\x02\
\x00\x64\x40\x09\x75\x86\xb3\xad\x9c\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x00\x96\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x06\x08\x04\x00\x00\x00\xbb\xce\x7c\x4e\
\x00\x00\x00\x02\x62\x4b\x47\x44\x00\xd3\xb5\x57\xa0\x5c\x00\x00\
\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\
\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x0b\x07\x0c\
\x0d\x1b\x75\xfe\x31\x99\x00\x00\x00\x27\x49\x44\x41\x54\x08\xd7\
\x65\x8c\xb1\x0d\x00\x00\x08\x83\xe0\xff\xa3\x75\x70\xb1\xca\xd4\
\x90\x50\x78\x08\x55\x21\x14\xb6\x54\x70\xe6\x48\x8d\x87\xcc\x0f\
\x0d\xe0\xf0\x08\x02\x34\xe2\x2b\xa7\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x00\xa0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x09\x08\x04\x00\x00\x00\xbb\x93\x95\x16\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x14\x1c\x1f\x24\
\xc6\x09\x17\x00\x00\x00\x24\x49\x44\x41\x54\x08\xd7\x63\x60\x40\
\x05\xff\xcf\xc3\x58\x4c\xc8\x5c\x26\x64\x59\x26\x64\xc5\x70\x0e\
\xa3\x21\x9c\xc3\x68\x88\x61\x1a\x0a\x00\x00\x6d\x84\x09\x75\x37\
\x9e\xd9\x23\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xa5\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x06\x08\x04\x00\x00\x00\xbb\xce\x7c\x4e\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\x9c\x53\x34\xfc\x5d\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x0b\x02\x04\x6d\
\x98\x1b\x69\x00\x00\x00\x29\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x00\x8c\x0c\x0c\xff\xcf\xa3\x08\x18\x32\x32\x30\x20\x0b\x32\x1a\
\x32\x30\x30\x42\x98\x10\x41\x46\x43\x14\x13\x50\xb5\xa3\x01\x00\
\xd6\x10\x07\xd2\x2f\x48\xdf\x4a\x00\x00\x00\x00\x49\x45\x4e\x44\
\xae\x42\x60\x82\
\x00\x00\x00\xbb\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x3f\x00\x00\x00\x07\x08\x06\x00\x00\x00\xbf\x76\x95\x1f\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\
\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\
\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\
\x09\x35\x2b\x55\xca\x52\x6a\x00\x00\x00\x3b\x49\x44\x41\x54\x38\
\xcb\x63\x60\x18\x05\x23\x13\x30\x12\xa3\xa8\xbe\x7d\x2a\x25\x76\
\xfc\xa7\x97\x3b\xd1\xc1\xaa\xa5\x73\x18\xae\x5f\x39\x8f\x53\x9e\
\x69\x34\xe6\x09\x00\x4d\x1d\xc3\x21\x19\xf3\x0c\x0c\x0c\x78\x63\
\x7e\x14\x8c\x54\x00\x00\x69\x64\x0b\x05\xfd\x6b\x58\xca\x00\x00\
\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xe4\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x36\x00\x00\x00\x0a\x08\x06\x00\x00\x00\xff\xfd\xad\x0b\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x06\x62\x4b\x47\x44\x00\x7f\x00\x87\x00\x95\xe6\xde\xa6\xaf\x00\
\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\
\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\
\x09\x2a\x2b\x98\x90\x5c\xf4\x00\x00\x00\x64\x49\x44\x41\x54\x48\
\xc7\x63\xfc\xcf\x30\x3c\x01\x0b\xa5\x06\x34\xb4\x4f\x85\x87\xcd\
\xaa\xa5\x73\x18\xae\x5d\x39\xcf\x48\x2b\x35\x14\x79\xcc\xd8\xc8\
\x88\x24\x03\x7c\x89\xd0\x4f\x2d\x35\x84\xc0\xd9\x73\xe7\xe0\x6c\
\x26\x86\x91\x92\x14\x91\x7d\x4d\x54\x52\x0c\x4d\x26\xa8\x9f\x5a\
\x6a\x46\x93\xe2\x68\x52\x1c\x82\x49\x91\x91\xd2\x7a\x4c\x4b\xc7\
\x10\xc5\x08\x6c\xc5\x34\xb5\xd4\xd0\xd5\x63\x83\x15\x00\x00\x7a\
\x30\x4a\x09\x71\xea\x2d\x6e\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
\x42\x60\x82\
\x00\x00\x00\xe0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x51\x00\x00\x00\x3a\x08\x06\x00\x00\x00\xc8\xbc\xb5\xaf\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\
\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\
\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\
\x0b\x29\x1c\x08\x84\x7e\x56\x00\x00\x00\x60\x49\x44\x41\x54\x78\
\xda\xed\xd9\xb1\x0d\x00\x20\x08\x00\x41\x71\x50\x86\x63\x51\xed\
\x8d\x85\x25\x89\x77\xa5\x15\xf9\x48\x45\x8c\xa6\xaa\x6a\x9d\x6f\
\x99\x19\x1d\x67\x9d\x03\x11\x45\x14\x11\x11\x45\x14\x51\x44\x44\
\x14\x51\x44\x11\x11\x51\x44\x11\x45\x44\x44\x11\x45\x14\x11\x11\
\x45\x14\xf1\x5b\xd1\x75\xb0\xdb\xdd\xd9\x4f\xb4\xce\x88\x28\x22\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcf\x36\xce\x69\x07\x1e\xe9\
\x39\x55\x40\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x02\xf8\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x02\x75\x49\x44\
\x41\x54\x58\x85\xed\x96\xcd\x4e\x13\x51\x18\x86\x9f\xaf\x15\xd2\
\x32\x78\x03\x56\x4d\x69\x58\x89\xa6\x3f\xf1\x06\x20\x26\x1a\x37\
\x94\x84\xd9\xb6\x33\xc4\x0b\x30\x46\x10\x34\x51\x16\x2e\x48\xd1\
\xb8\x72\x43\xb4\x74\xd8\x92\x98\xe2\xca\xb8\x11\x37\x2c\x8c\xda\
\x36\x12\xc0\x10\x40\x03\x86\x0b\xc0\x54\xa3\x71\x3e\x17\xb4\xd1\
\x44\xa6\x65\x0a\x3b\xfb\x6c\xbf\xf7\x9c\xf7\x49\xe6\xcc\x99\x81\
\x36\x6d\xfe\x77\xc4\x4f\xd8\x34\xcd\xce\xee\x70\x78\x48\x44\xd2\
\x40\x4a\x21\x02\x80\xea\x0e\x22\xef\x05\x8a\x7b\xd5\x6a\x71\x7e\
\x7e\xfe\xc7\xb1\x0b\xd8\x99\xcc\xb0\x8a\xe4\x04\x7a\x80\x0f\xa2\
\xba\xa8\x22\x3b\xb5\x71\x04\xe8\x07\x2e\x00\x1b\x2a\x32\x56\x28\
\x14\x9e\x1d\x8b\x80\x69\x9a\xc1\x93\x86\x91\x53\xd5\x1b\x02\x2f\
\x08\x06\xc7\xf3\xf9\x7c\xe5\xa0\xac\x65\x59\x09\x81\x29\x54\x2f\
\xab\xea\x74\x34\x16\x1b\x9f\x9c\x9c\x74\x1b\xed\x7f\xa2\x99\x40\
\xad\xfc\x3a\x30\x9a\x77\x9c\x07\x8d\xb2\x85\x42\xa1\x0c\x5c\x19\
\xb1\xac\x51\x60\xea\xd3\xe6\x26\xc0\x58\xa3\x35\xc1\x46\x43\x3b\
\x93\x19\x06\x1e\x09\x8c\xce\x3a\xce\xc3\x66\xb2\x75\x4a\xe5\xf2\
\x52\x32\x91\xf8\x2e\x22\xf7\x12\xc9\x64\xa5\x5c\x2e\xaf\x79\x65\
\x3d\x1f\x81\x69\x9a\x9d\xdd\x5d\x5d\xab\xc0\xc7\x59\xc7\xb9\x7a\
\xd8\xf2\xbf\xb1\xb3\xd9\x97\x40\xcf\xd7\x6a\xb5\xcf\xeb\x60\x06\
\xbc\x16\x77\x87\xc3\x43\x40\x4c\x82\xc1\x89\x56\xca\x01\x02\xaa\
\xb7\x80\x5e\xc3\x30\x06\x3d\x33\x5e\x03\x11\x49\xa3\x5a\xf1\x3a\
\x70\x87\xe1\xe9\xdc\x5c\x09\x58\x46\xd5\xbf\x00\x90\x42\xe4\x75\
\xab\xe5\x75\x44\xf5\x95\xa8\x5e\xf4\x2d\xa0\x70\x4a\xfe\xbc\xe7\
\x2d\xe3\xc2\x17\x44\x22\xbe\x05\x00\x54\xd5\xd7\x4d\x79\x60\x41\
\x20\x20\xfb\x1e\xfe\x05\x76\x45\xf5\xf4\x51\x05\x54\x35\x82\xea\
\x6e\x2b\x02\x6f\x55\xa4\xff\xa8\x02\xc0\x80\xc0\x1b\xdf\x02\x02\
\x45\xe0\xbc\x65\x59\x89\x56\x9b\x6d\xdb\x4e\x01\xe7\x14\x9e\xfb\
\x16\xd8\xab\x56\x8b\xc0\x86\xc0\x54\x8b\xfd\x22\xae\x9b\x03\xd6\
\x3b\x42\xa1\x05\xaf\x90\xe7\x55\xbc\xb2\xb2\xf2\x2b\x15\x8f\x6f\
\x03\x77\x52\xc9\x64\xb5\x54\x2e\x2f\xf9\x69\xb7\xb3\xd9\x09\xe0\
\x9a\xc0\xc8\x93\x7c\x7e\xd5\xb7\x00\x40\xa9\x52\x59\x4b\xc4\xe3\
\x06\x70\x37\x95\x4c\x7e\x3b\xa4\x84\xd4\xca\xef\x8b\xc8\x74\xde\
\x71\x1e\x37\x0a\x37\xfd\x1a\x46\x63\xb1\xf1\xcf\x5b\x5b\xaa\xaa\
\x39\x2b\x9b\xbd\x14\x54\x1d\xaf\xdd\x70\xff\x60\xdb\x76\x4a\x5c\
\x37\xa7\x30\x20\x22\xb9\xb3\xd1\xe8\xed\xa6\xb6\xcd\x02\x75\x2c\
\xcb\x4a\x8b\xea\x34\xd0\x0b\x2c\x03\x8b\xc0\x76\x6d\x7c\x86\xfd\
\x1f\x92\x3e\x60\x5d\xe0\x66\xde\x71\x3c\x0f\x5e\x4b\x02\xb0\xff\
\x85\x34\x0c\x63\x50\x5c\x37\x8d\x48\x0a\xa8\xdf\x13\x3b\x0a\xef\
\x44\xb5\xd8\x11\x0a\x2d\xcc\xcc\xcc\xfc\xf4\xb3\x6f\x9b\x36\xff\
\x37\xbf\x01\x4a\x37\xdd\xdd\x8c\xf1\x82\x6a\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\x93\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x09\x08\x04\x00\x00\x00\xbb\x93\x95\x16\
\x00\x00\x00\x02\x62\x4b\x47\x44\x00\xd3\xb5\x57\xa0\x5c\x00\x00\
\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\
\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x0b\x07\x0c\
\x0c\x2b\x4a\x3c\x30\x74\x00\x00\x00\x24\x49\x44\x41\x54\x08\xd7\
\x63\x60\x40\x05\xff\xff\xc3\x58\x4c\xc8\x5c\x26\x64\x59\x26\x64\
\xc5\x70\x0e\x23\x23\x9c\xc3\xc8\x88\x61\x1a\x0a\x00\x00\x9e\x14\
\x0a\x05\x2b\xca\xe5\x75\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\
\x60\x82\
\x00\x00\x00\xa6\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x06\x08\x04\x00\x00\x00\xbb\xce\x7c\x4e\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\x9c\x53\x34\xfc\x5d\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x0b\x1b\x0e\x16\
\x4d\x5b\x6f\x00\x00\x00\x2a\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x00\x8c\x0c\x0c\x73\x3e\x20\x0b\xa4\x08\x30\x32\x30\x20\x0b\xa6\
\x08\x30\x30\x30\x42\x98\x10\xc1\x14\x01\x14\x13\x50\xb5\xa3\x01\
\x00\xc6\xb9\x07\x90\x5d\x66\x1f\x83\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x00\x81\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x10\x00\x00\x00\x10\x01\x03\x00\x00\x00\x25\x3d\x6d\x22\
\x00\x00\x00\x06\x50\x4c\x54\x45\x00\x00\x00\xae\xae\xae\x77\x6b\
\xd6\x2d\x00\x00\x00\x01\x74\x52\x4e\x53\x00\x40\xe6\xd8\x66\x00\
\x00\x00\x29\x49\x44\x41\x54\x78\x5e\x05\xc0\xb1\x0d\x00\x20\x08\
\x04\xc0\xc3\x58\xd8\xfe\x0a\xcc\xc2\x70\x8c\x6d\x28\x0e\x97\x47\
\x68\x86\x55\x71\xda\x1d\x6f\x25\xba\xcd\xd8\xfd\x35\x0a\x04\x1b\
\xd6\xd9\x1a\x92\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\
\x00\x00\x00\xdc\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x10\x00\x00\x00\x40\x08\x06\x00\x00\x00\x13\x7d\xf7\x96\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xb3\x00\x79\x00\x79\xdc\xdd\
\x53\xfc\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdf\x04\x19\x10\x2d\x19\xaf\x4a\xeb\xd0\x00\x00\x00\x1d\x69\x54\
\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x00\x00\x00\x00\x43\x72\
\x65\x61\x74\x65\x64\x20\x77\x69\x74\x68\x20\x47\x49\x4d\x50\x64\
\x2e\x65\x07\x00\x00\x00\x40\x49\x44\x41\x54\x58\xc3\xed\xce\x31\
\x0a\x00\x20\x0c\x03\x40\xf5\xa3\x7d\x5b\x5f\xaa\x53\xc1\xc9\xc5\
\x45\xe4\x32\x05\x1a\x8e\xb6\x76\x99\x5e\x25\x22\x66\xf5\xcc\xec\
\xfb\xe8\x74\x1b\xb7\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\xf0\x36\xf0\x41\x16\x0b\x42\x08\x78\x15\x57\x44\xa2\x00\
\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\xe3\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x60\x49\x44\
\x41\x54\x58\x85\xed\xd7\x3b\x4e\x42\x61\x10\x86\xe1\x77\x40\x45\
\xbc\x2c\x00\xdd\x82\x98\x90\x00\x46\x05\x57\x21\xa5\x17\x62\x2c\
\xb0\x43\x12\x5d\x83\x0d\xd8\x88\x15\xde\x62\x89\x7b\x30\x39\x60\
\x14\x49\x4e\x08\x7b\x10\x7b\x2f\x08\x08\x63\xa1\x87\x40\xa0\x3c\
\xc4\x44\xcf\xd7\xfd\x53\xfc\xdf\x53\xce\xc0\x7f\x8f\xf4\xbd\x54\
\x25\x92\x79\xd8\x16\x95\x04\x82\x1f\x98\xb4\xa9\xe7\x03\xa5\x0a\
\x92\x35\xf6\x43\x97\x88\xe8\x20\x40\x55\xd6\x8e\x4b\x17\xaa\x6c\
\x02\x0d\x01\x53\xd1\x57\x3b\xda\x05\x99\x51\x08\x00\x1e\x90\x73\
\x23\x19\xda\xb1\x10\x5d\x40\x24\x7d\x1f\x17\xe4\x0c\xb4\x88\x8c\
\xc5\x8c\x64\xb0\x66\x47\xb9\x95\x68\xa6\xec\x43\xdb\x79\x60\x45\
\x95\xad\x42\x6a\xe9\x0a\xc0\xd5\x55\xaa\x24\x80\x86\xfb\xd3\xb5\
\x6e\x77\x39\x80\x91\x0c\xd6\x3a\xad\x56\x0c\x68\x8a\xb0\x67\xcd\
\xbb\x00\x84\x05\x01\xf3\xf6\x20\xfc\x6c\x77\xb9\x95\xe2\x61\xe4\
\x09\x30\x01\xff\x20\x00\xbc\x0a\xef\xa3\x2a\xef\xc9\x1b\x30\x35\
\x0c\xf0\x2b\x71\x00\x0e\xc0\x01\x38\x00\x07\xe0\x00\x1c\x80\x03\
\xe8\x05\xd4\xa5\x67\x53\x19\x61\xa6\x81\xfa\x10\x80\x56\x15\x02\
\xd1\x4c\xd9\x37\xaa\xe6\xe5\xf4\xdd\x3c\x10\x10\xa8\x0c\x02\xd4\
\x75\x0a\x78\xd0\xf6\xcd\xea\x51\x61\x6e\x14\xe5\xe3\xb8\xf3\xc0\
\x44\x47\x34\x6b\xcd\xfb\x0e\x93\x68\xe6\x31\x07\x1a\x07\x9a\x80\
\x09\xfa\x62\x4f\xbd\xcc\xf2\x7d\x98\x4c\x28\xe4\x0a\xc9\xf0\xee\
\xc0\x61\x62\x21\x22\xe9\xd2\xc6\xcf\xde\xbe\x08\x78\xed\x01\x50\
\x17\xa8\xa8\xca\x89\x91\x0a\x5f\xdb\xf4\xe7\x1f\xc9\x17\xa4\x29\
\x70\x23\xfc\x8b\x13\x87\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\
\x60\x82\
\x00\x00\x02\x56\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\
\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\
\xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\
\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\
\xdf\x04\x19\x10\x15\x00\xdc\xbe\xff\xeb\x00\x00\x00\x1d\x69\x54\
\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x00\x00\x00\x00\x43\x72\
\x65\x61\x74\x65\x64\x20\x77\x69\x74\x68\x20\x47\x49\x4d\x50\x64\
\x2e\x65\x07\x00\x00\x01\xba\x49\x44\x41\x54\x78\xda\xed\x9b\x5b\
\x92\x02\x21\x0c\x45\x4d\xd6\x37\x2e\x48\x17\xa0\x0b\xd2\xfd\xe9\
\x9f\x65\x39\xda\x3c\x92\x7b\x13\x68\xf2\x3d\x95\xe6\x1c\x1e\x43\
\x10\x0e\x87\x15\x2b\x56\xec\x39\x84\xf9\xb1\xdb\xe9\xf4\xa8\xf9\
\xbb\xe3\xf5\x2a\x53\x08\xa8\x05\x8e\x14\x22\x59\xa1\x59\x32\x64\
\x14\x70\x94\x08\x19\x11\xde\x53\x82\x8c\x08\xee\x29\x42\x46\x87\
\xb7\x4a\x90\xd1\xc1\xad\x22\x64\x26\xf8\x1e\x09\x32\x1b\x7c\xab\
\x04\x5d\x5b\xe1\x09\x7b\xbf\x65\x14\x88\x15\xfe\xef\x72\x79\xe5\
\xb8\x9f\xcf\x14\x51\xef\xdf\x2c\x7d\xb7\x24\x41\xbd\x1b\xf6\xd9\
\x38\x34\xbc\x35\x14\x31\xf4\x51\x12\x7a\xf2\x96\x18\x14\x35\xef\
\xbd\x25\x58\xf2\x6d\xb1\x98\xa7\xc0\xd6\xfc\xf3\x92\xb0\x95\xc7\
\xba\xee\x88\x57\xef\xa3\x1a\xe9\x99\xf7\xdb\x82\xe8\xb6\x08\x22\
\x46\x02\xb2\xe7\x21\xff\x05\x3c\x25\x30\xe0\xbf\x4e\x01\x8f\x4d\
\x8f\xb5\xf1\x48\xf8\xcf\x69\x00\xd9\x0a\x5b\x46\x02\xab\xe7\xe1\
\xb5\x40\x8f\x04\x36\x3c\xbc\x18\x6a\x91\x10\x01\xff\x6f\x0d\x40\
\x15\x3d\x25\x38\x36\xfc\xfb\x3a\x40\x29\x87\x7b\xd7\x04\x46\x71\
\x45\x3b\x0f\x68\x85\x61\x55\x96\xd4\x03\x91\x5a\x28\x16\x3c\x5d\
\x40\x0d\x1c\x13\x3e\x44\x80\x65\x1f\x30\xbc\x80\x5a\x38\xa6\x04\
\xcd\x06\xcf\x96\xa0\xd1\xf0\x8c\xf3\x84\x50\x01\x35\xf0\x91\x12\
\x20\xd5\x60\x6f\xcf\x33\x36\x45\x94\x6a\xb0\x17\x26\x62\x24\x68\
\xa6\x39\x1f\x21\x41\x33\xc1\x47\x48\x70\x3b\x14\x45\xcc\x61\xef\
\x7c\xd0\x43\x51\xc4\x02\xc6\x18\x09\x9a\x15\x9e\x25\xe1\x67\x82\
\xda\x69\xc0\xaa\xe7\xad\xdf\xf9\xf5\x23\x69\xc8\x99\x60\x86\x7c\
\x45\x01\x96\x9b\x57\xa8\xc6\xf6\xe6\xdd\x62\xd1\xec\x3d\x8f\xce\
\x6f\xbe\x20\x91\x3d\x4a\x23\x79\x5d\x91\xa9\x4d\xb6\x6e\x89\x4d\
\x1a\xeb\xa2\x64\x6b\xf2\x5d\x5f\x95\xcd\x2c\x82\x76\x59\x3a\xa3\
\x84\x90\xeb\xf2\x59\x24\x58\x1f\x4d\xac\x27\x33\xde\x0d\xdb\xed\
\xa3\x29\xa4\x8c\xa1\x9e\xcd\x79\x08\x61\x3e\x9c\x5c\xb1\xf7\x78\
\x02\x47\xb0\x5b\x07\x3a\x44\x3e\x01\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x00\xa0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x09\x08\x04\x00\x00\x00\xbb\x93\x95\x16\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x14\x1f\x0d\xfc\
\x52\x2b\x9c\x00\x00\x00\x24\x49\x44\x41\x54\x08\xd7\x63\x60\x40\
\x05\x73\x3e\xc0\x58\x4c\xc8\x5c\x26\x64\x59\x26\x64\xc5\x70\x4e\
\x8a\x00\x9c\x93\x22\x80\x61\x1a\x0a\x00\x00\x29\x95\x08\xaf\x88\
\xac\xba\x34\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x03\xcc\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x03\x49\x49\x44\
\x41\x54\x58\x85\xed\x96\xcd\x6b\x5c\x55\x18\xc6\x7f\xcf\x9d\x99\
\x98\xe9\x64\x16\xd2\x9d\xa9\x92\x0e\xa1\x0b\xd3\xd8\x76\xf0\x1f\
\x68\x11\x14\x2b\x34\x81\xde\x55\xca\xcc\xbd\xa5\x54\x5c\x04\x44\
\x6d\x3a\xd5\x4d\x16\x2e\xe2\x44\x57\xb3\x1b\xea\x78\xa7\x18\xb2\
\x08\xc8\x54\xb0\x88\x1b\xeb\xc6\x85\x68\xf3\x55\x53\xa4\xb4\x55\
\x9a\x52\x70\x25\x99\x30\xa5\x36\xb9\xaf\x8b\xf9\x68\xc1\xcc\x0c\
\x53\xba\x6b\x9e\xdd\x39\xe7\x39\xef\xfb\xbb\xef\x7d\xef\x39\x17\
\x76\xb5\xab\xe7\x5d\xea\xc5\xec\xba\x6e\xdf\x40\x3c\x3e\x2e\x69\
\x0c\x48\x1b\x0c\x02\x60\xb6\x8e\x74\x4d\x50\xa9\xd6\x6a\x95\x85\
\x85\x85\x7f\x9f\x39\x80\x9f\xc9\x9c\x34\x29\x2f\xd8\x0f\xac\xca\
\xec\xaa\x49\xeb\x8d\xe5\x41\xe0\x28\x30\x0a\xdc\x32\x69\x2a\x08\
\x82\x6f\x9e\x09\x80\xeb\xba\x91\x64\x22\x91\x37\xb3\x0f\x04\xdf\
\x13\x89\xe4\x4a\xa5\xd2\xf2\x4e\x5e\xcf\xf3\x0e\x0b\x66\x30\x7b\
\xd3\xcc\x66\x87\x52\xa9\xdc\xf4\xf4\x74\xd8\x29\x7e\xb4\x1b\x40\
\x23\xf9\xfb\xc0\xb9\x52\xb9\xfc\x79\x27\x6f\x10\x04\x4b\xc0\x5b\
\xa7\x3d\xef\x1c\x30\xf3\xe7\xed\xdb\x00\x53\x9d\xf6\x74\xac\x80\
\x9f\xc9\x9c\x44\x5a\x10\x7c\x54\x2a\x97\xbf\x00\x98\x9c\x9c\x7c\
\x61\x73\x63\xe3\x5d\x83\x09\xd5\x4b\x0e\x66\x2b\xe6\x38\x73\xc9\
\x64\xb2\x58\x28\x14\x1e\x02\xf8\xd9\xec\x14\xf0\x99\x49\xe3\x41\
\x10\x54\x7a\x06\x70\x5d\xb7\x6f\x60\xcf\x9e\x1b\xc0\x1f\x5f\x95\
\xcb\x6f\x03\x9c\x99\x98\xd8\xb7\x1d\x8b\x5d\xc1\x6c\x14\x08\x01\
\xa7\x61\x0f\x01\x47\xb0\xe2\x6c\x6d\x1d\xbf\x38\x37\xb7\xde\x80\
\xf8\x01\xd8\xbf\x59\xab\x8d\xb4\x6b\x4c\x67\xa7\x49\x80\x81\x78\
\x7c\x1c\x48\x29\x12\xb9\xd0\x7c\xf2\xed\x58\xec\x8a\x99\x1d\xdc\
\x61\xaf\xd3\xa0\x18\x0d\xa3\xd1\xef\x5c\xd7\xed\x03\x70\xcc\xce\
\x03\xc3\x89\x44\xe2\x44\xbb\x3c\x6d\x01\x24\x8d\x61\xb6\xdc\x6c\
\xb8\x6a\xb5\x7a\x16\xb3\x51\x75\xa8\x9a\x40\x06\xaf\x0d\xc4\xe3\
\x67\x01\xbe\xbc\x74\x69\x11\xb8\x8e\x59\xef\x00\x40\x1a\xe9\xa7\
\xd6\xc8\xec\x14\xf5\x52\x77\x96\x14\x02\xa7\x5a\x43\xb3\x1f\x65\
\xf6\x7a\xcf\x00\x06\x2f\xe9\xf1\x77\x8e\x60\xa4\x0b\x70\x13\xd4\
\x91\x34\xd2\x1c\x86\x70\x0f\x69\xb0\x67\x80\x7a\x2c\xeb\xe9\xa4\
\xdc\x31\x81\xe3\x88\x0e\x95\xeb\x04\x70\x5f\x66\xfb\x5a\x30\xf0\
\x7b\xa7\x40\x2d\x49\x61\x08\xd7\x5b\xfb\xcc\x06\x31\xbb\xff\x34\
\x00\xbf\x9a\x74\xf4\x89\xc0\x5f\x77\xf1\x37\x33\x3a\x32\x9b\x7b\
\x62\xe6\x98\xe0\x97\x9e\x01\x04\x15\xe0\xa0\xe7\x79\x87\x01\x92\
\xc9\x64\x51\xb0\x62\x60\x6d\x73\x83\x21\x2d\x6d\x3e\x78\x50\x04\
\xf0\x7d\x3f\x0d\xbc\x6a\xf0\x6d\xcf\x00\xd5\x5a\xad\x02\xdc\x12\
\xcc\x00\x14\x0a\x85\x87\xce\xd6\xd6\x71\x07\x56\x1b\x96\xc7\xaf\
\xa3\xde\xf9\x48\x5a\xde\x0e\xc3\x77\x1a\x87\x8e\x14\x86\x79\xe0\
\x66\xac\xbf\xff\x72\xbb\x3c\x91\x76\x0b\x6b\x6b\x6b\xdb\xe9\x43\
\x87\xee\x02\x9f\xa4\x8f\x1c\xa9\x2d\x2e\x2d\xfd\x7c\x6d\x75\x75\
\x63\xf8\xc0\x81\x52\x5f\x34\xfa\xb7\x49\x7b\x05\x2f\x02\x8f\x0c\
\x16\x1d\x98\xd9\xac\xd5\xde\x9b\x9f\x9f\xff\x07\xc0\xcf\x66\x2f\
\x00\x67\x04\xa7\x2f\x96\x4a\x37\xda\xe5\xe9\xda\xe5\x5e\x26\x93\
\x97\xf4\xa1\xa4\x5c\x29\x08\x66\xbb\xf9\x01\xf9\xd9\x6c\x0e\xf8\
\x54\xd2\x6c\x29\x08\x72\x9d\xcc\x5d\x6f\xc3\xa1\x54\x2a\xf7\xd7\
\x9d\x3b\x66\x66\x79\x2f\x9b\x7d\x23\x62\x96\x6b\x9c\x70\xff\x93\
\xef\xfb\x69\x85\x61\xde\xe0\x98\xa4\xfc\x2b\x43\x43\x1f\x77\xa5\
\xed\x66\x68\xca\xf3\xbc\x31\x99\xcd\x02\xc3\xd4\x3f\xb3\xab\xc0\
\xdd\xc6\xf2\xcb\xd4\x7f\x48\x46\x80\x9b\x8d\xdb\xb3\x6d\xe3\x3d\
\x15\x00\xd4\x6f\xc8\x44\x22\x71\x42\x61\x38\x86\x94\x06\x9a\xe7\
\xc4\xba\xc1\x6f\x32\xab\xc4\xfa\xfb\x2f\x17\x8b\xc5\x47\xbd\xc4\
\xdd\xd5\xae\x9e\x6f\xfd\x07\xb0\xd0\x3c\xea\x1c\xa0\xa5\x5f\x00\
\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xa6\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x06\x08\x04\x00\x00\x00\xbb\xce\x7c\x4e\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x08\x15\x3b\xdc\
\x3b\x0c\x9b\x00\x00\x00\x2a\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x00\x8c\x0c\x0c\x73\x3e\x20\x0b\xa4\x08\x30\x32\x30\x20\x0b\xa6\
\x08\x30\x30\x30\x42\x98\x10\xc1\x14\x01\x14\x13\x50\xb5\xa3\x01\
\x00\xc6\xb9\x07\x90\x5d\x66\x1f\x83\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x00\xa0\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x09\x08\x04\x00\x00\x00\xbb\x93\x95\x16\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\x9c\x53\x34\xfc\x5d\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x0b\x1b\x29\xb3\
\x47\xee\x04\x00\x00\x00\x24\x49\x44\x41\x54\x08\xd7\x63\x60\x40\
\x05\x73\x3e\xc0\x58\x4c\xc8\x5c\x26\x64\x59\x26\x64\xc5\x70\x4e\
\x8a\x00\x9c\x93\x22\x80\x61\x1a\x0a\x00\x00\x29\x95\x08\xaf\x88\
\xac\xba\x34\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\xed\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x6a\x49\x44\
\x41\x54\x58\x85\xed\x97\xcb\x4e\xc2\x40\x14\x86\xbf\x43\x08\x78\
\x7d\x00\xf4\x15\xd4\x84\x77\x91\x65\x69\x0b\x71\xa1\xef\x23\xae\
\x9a\x71\xa8\x4b\x7c\x07\x37\xae\x09\xe1\x1d\xc4\xbd\x17\xe4\x92\
\x1e\x17\xa5\xa6\x06\xd8\x98\x21\x18\xed\xbf\x9a\x76\x26\xfd\xbe\
\x4e\xa6\xcd\x39\xf0\xdf\x23\xf9\x0b\x55\x15\x6b\x4c\x50\x12\xb9\
\x54\x38\x05\x76\x1c\x71\x3e\x04\x86\x40\xc7\x0b\x02\x2b\x22\xba\
\x24\xa0\xaa\x12\x1b\x73\xab\x22\x4d\x60\x02\xf4\x11\x79\x75\x82\
\x57\x3d\x00\xea\x40\x15\x11\xd3\xf4\xfd\x76\x26\x51\xce\xd6\x58\
\x63\x02\x49\xe1\x8f\xa5\x72\xb9\xe1\x79\xde\xc8\x09\x7c\x91\x38\
\x8e\x6b\xc9\x7c\xde\x43\x35\xb4\xd6\x3e\x00\x5d\x80\x52\xb6\xa0\
\x24\x72\x09\x4c\x12\x38\x77\x0d\x07\xf0\x3c\x6f\x34\x4f\x92\x06\
\x30\x15\xd5\xab\x2f\x6e\x36\x50\x38\x01\xfa\x61\x18\x3e\xbb\x86\
\x67\x69\xb7\xdb\x4f\x40\x9f\xf4\x7c\x7d\x17\x00\x76\x81\xf7\x4d\
\xc1\x73\x79\x03\xf6\x56\x09\x6c\x25\x85\xc0\xd6\x05\xca\xeb\x26\
\xac\x31\xba\x6e\xee\x27\xf1\xc3\x50\x56\xdd\xdf\xfa\x0e\x14\x02\
\x85\x40\x21\xb0\xf6\x3f\xb0\xee\xbb\x75\x9d\xad\xef\x40\x21\xf0\
\xab\x04\xc6\xe4\x2a\x95\x0d\x66\x7f\xc1\x5a\x12\x18\x02\xf5\x38\
\x8e\x6b\x9b\x22\x5b\x6b\x8f\x49\xcb\xf3\xc1\x92\x80\xc0\x0d\x50\
\x4d\x66\xb3\xfb\x28\x8a\x8e\x36\x02\x4f\x92\x1e\x50\x11\xe8\xe4\
\xb8\x69\x54\x55\xba\xd6\x46\xa8\x86\xc0\x94\xb4\x31\x79\x71\x42\
\x57\x3d\x24\x7d\xf3\x8a\x42\xe4\x07\xc1\x45\xd6\x98\x2c\xb7\x66\
\xd6\x7a\x8b\xba\xfd\x8c\xb4\x52\x76\x91\x31\x30\x40\xf5\xda\x6f\
\xb5\xee\x1c\x3d\xf3\x8f\xe4\x13\xfb\x36\x7a\x56\x11\xde\xcf\xd8\
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x00\xa6\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x06\x00\x00\x00\x09\x08\x04\x00\x00\x00\xbb\x93\x95\x16\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x14\x1f\x20\xb9\
\x8d\x77\xe9\x00\x00\x00\x2a\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x06\xe6\x7c\x60\x60\x60\x42\x30\xa1\x1c\x08\x93\x81\x81\x09\xc1\
\x64\x60\x60\x62\x60\x48\x11\x40\xe2\x20\x73\x19\x90\x8d\x40\x02\
\x00\x23\xed\x08\xaf\x64\x9f\x0f\x15\x00\x00\x00\x00\x49\x45\x4e\
\x44\xae\x42\x60\x82\
\x00\x00\x02\xd4\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x02\x51\x49\x44\
\x41\x54\x58\x85\xed\x96\x41\x4b\x54\x51\x14\xc7\x7f\xe7\x8d\xb8\
\xd0\x26\x30\x77\x69\x84\xe1\xaa\x29\x90\x41\xc7\x92\x5e\xa0\x1b\
\xa1\x8d\x0a\xf5\x19\x5a\x3b\x33\xda\xd8\x6a\x16\x41\x36\x83\xf3\
\xbe\x87\x41\x8d\xad\xc2\x4d\xf6\x14\xf4\x0d\x99\x48\x0e\x11\xe2\
\xaa\x11\xdb\x18\x34\xa8\x0b\xc3\x77\x5a\xcc\x48\x10\xf3\x74\xee\
\xe8\xae\xf9\x6f\xef\x39\xfc\x7f\xf7\xdc\x7b\xcf\x3d\xd0\x54\x53\
\xff\xbb\xc4\x24\x38\x92\x2e\xb6\x76\x86\x0f\x27\x54\x18\x07\x8d\
\x02\x5d\xd5\xa5\x12\xca\x67\x11\xc9\xef\x97\xdb\xf3\xc5\x74\xe4\
\xf8\xd2\x01\x6c\x67\xed\x31\x2a\x19\xa0\x07\xe4\x0b\xaa\x4b\x58\
\x94\x00\x44\xb5\x4b\xb1\x86\x41\xef\x22\xec\x08\x32\xed\x4e\xc6\
\xde\x5c\x0a\xc0\x93\xf9\xf9\xd0\x8f\xdd\x9b\x19\x94\x38\xf0\x5e\
\x95\xd4\x4a\x62\x70\xb3\x56\xec\x90\x53\xe8\x0b\xf9\x3a\x8b\x30\
\x0a\x64\x97\xcb\xb1\x14\x69\xf1\xeb\xdd\x64\x4d\xd9\x8e\x37\x67\
\xe7\xbc\x93\x87\xce\x5a\xb2\xee\x9c\x9c\x37\x65\xe7\xbc\x13\x3b\
\xe7\x65\xce\x8b\x3d\xb3\x02\xd5\xb2\xbf\x16\x24\xe9\xc6\x63\x73\
\xf5\x02\x54\x72\xbd\x69\x94\x57\x08\x13\xcb\x93\x83\x79\x63\x80\
\x48\xba\xd8\x7a\xed\xea\xc1\x57\x41\xbf\xb9\xf1\x7b\x8f\x4c\xcc\
\x4f\xf5\xc0\x29\x2c\x8a\x6a\xcf\xcf\xf2\x95\x48\xd0\xc5\xb4\x82\
\x92\x3b\xc3\x87\x13\xc0\x2d\x5f\x65\xa6\x11\x73\x00\xcb\x97\x67\
\x40\x6f\x47\xf8\x60\x2c\x30\x26\x68\xa1\xf2\xd4\xd8\x0c\xba\x70\
\xf5\xc8\x4d\x0c\x6c\xa8\xb2\x25\x60\x0e\x00\x1a\x15\xf4\x63\xa3\
\xe6\xa7\x12\xf8\x80\xd0\xdf\x00\x00\xd7\x15\x29\x5d\x14\x40\x61\
\x97\xbf\x0d\xcb\x08\x00\xc4\xac\x53\xd6\x34\x10\x11\x20\xb0\x17\
\x9c\x05\xb0\x87\x4f\xf7\x45\x01\x14\xed\x02\xf6\xcc\x01\x94\x4f\
\x0a\xc3\x17\x05\x00\x46\x80\x82\x31\x80\x88\xe4\x45\xb8\x33\xe4\
\x14\xfa\x1a\x75\xb6\x9d\xd5\x28\x70\x1b\xd1\x77\xc6\x00\xfb\xe5\
\xf6\x3c\xc2\x4e\xc8\xd7\xd9\x86\xdc\x55\x05\xb5\x32\xc0\xf6\x51\
\x5b\xcb\x82\x31\x40\x31\x1d\x39\x56\x65\x0a\x61\xd4\xce\x79\x53\
\xa6\xfe\x76\xce\x4b\x01\x23\xa2\x7e\x72\xfd\x69\xff\x6f\x63\x00\
\x80\x95\xf8\xe0\x5b\x20\x0b\xcc\xd6\x0d\xa1\x2a\xf6\xdc\xda\x0c\
\x22\x2f\x44\xc8\xb8\x89\xfb\x81\xe5\x87\x7a\xe6\x81\xb4\x5a\x76\
\xb8\xf0\x12\x61\x1a\x58\x14\xb5\x52\x6e\x62\x60\xa3\x56\xa8\xed\
\xac\x46\xab\x65\x1f\x11\x21\xe3\xfe\x8a\x3d\x3f\xef\x3b\x36\x18\
\x48\xbc\x71\x94\x2c\xd0\xab\xca\x96\x08\x4b\x08\xdf\x01\x50\x6e\
\x50\x79\x31\x11\x60\x5b\xd4\x4f\x9e\xb7\x73\x63\x00\xa8\xfc\x90\
\x1d\xe1\x83\x31\xaa\x23\x99\x20\xdd\x15\x7f\x2d\x89\xca\x3a\x96\
\xe6\x8f\xda\x5a\x16\xce\x3a\xf3\xa6\x9a\x6a\xea\x5f\xfd\x01\xd3\
\x1c\xd9\x7f\x5e\xb9\x33\xcd\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
\x42\x60\x82\
\x00\x00\x02\x00\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x7d\x49\x44\
\x41\x54\x58\x85\xed\x97\x3b\x4e\x02\x51\x14\x86\xbf\x83\x28\x3e\
\x17\xa0\x6e\x41\x4d\x48\x78\x44\x9d\x71\x15\x5a\xfa\x8a\xb1\xd0\
\x0e\x48\x74\x0d\x36\x60\xa3\x56\x3e\x63\xa9\x7b\x30\x19\x34\x82\
\x24\x84\xb8\x07\xb5\xf7\x81\x82\x70\x2c\x74\x08\x04\xc3\x14\xce\
\x58\xe8\x7c\xdd\xbd\xe7\xe6\xfe\x5f\x6e\x73\xcf\x81\xff\x8e\xb4\
\xac\x54\xc5\xc8\xe4\x96\x44\x65\x0d\x61\x1c\xe8\x75\x29\xe7\x15\
\xe5\x16\x64\xd7\x4a\x46\x8f\x11\xd1\x76\x01\x55\x99\xd9\xce\x1f\
\xa9\xb2\x00\xbc\x09\x14\x15\x7d\x72\x23\x5d\x90\x41\x85\x30\x10\
\x02\x39\xb4\x12\xd1\x15\x5b\xa2\x21\x60\xa4\xaf\x97\x05\x39\x00\
\xbd\x44\x82\x73\x56\x22\x72\xef\x46\xb8\x8d\x99\x29\x0c\xa3\xb5\
\x33\x60\x4a\x95\xc5\x6c\x2a\x7e\x02\x10\x68\x58\xaa\xac\x01\x6f\
\x5d\xef\x81\x59\xb7\xc3\x01\xac\x44\xe4\xbe\x5e\xad\xce\x01\x15\
\x11\xd6\xed\xfd\x86\x00\xc2\x98\x40\xf1\x62\x23\xf6\xe0\x76\xb8\
\xcd\xe5\xa6\x71\x07\x14\x81\xf1\x76\x01\xe8\x53\x78\xf1\x2a\xbc\
\x89\x67\xa0\xdf\x5e\x04\x9d\x4e\x9b\xe9\x9c\x3a\x9d\xe9\x84\x95\
\x8c\x4b\xa7\x7a\xa0\x53\xf1\x37\xf0\x05\x7c\x01\x5f\xc0\x17\xf0\
\x05\x7c\x01\x5f\xc0\xb1\x1f\x70\xfa\xcf\x7f\x4a\xf3\x0b\x94\xa5\
\xa9\x53\xf1\x90\x01\xa0\xfc\x8d\x80\xde\x2a\x84\xcd\x4c\x61\xd8\
\xab\xe4\xc9\xf4\xd5\x28\x10\x16\x28\xb5\x0b\x68\x60\x0f\x08\xa1\
\xb5\xf3\xe9\xad\xec\x88\x17\xe1\xdd\x74\x9d\x01\x3d\x75\xd1\x5d\
\x7b\xbf\x65\x30\x31\x33\x37\xfb\xa0\xcb\x40\x05\x28\x82\x3e\xba\
\x13\x2f\x43\x7c\x0e\x26\x3d\x0a\xfb\xd9\x44\x6c\xb5\x6d\x30\xb1\
\x25\x8c\x74\x7e\xfe\xab\x6f\x9f\x00\xfa\xdc\x11\xa0\x2c\x50\x52\
\x95\x1d\x2b\x15\x3b\x75\xe9\xce\x3f\xc2\x07\xd1\xbc\x75\x94\xcf\
\xbc\x8d\xf9\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x03\xa5\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x03\x22\x49\x44\
\x41\x54\x58\x85\xed\x96\x4d\x6c\x54\x55\x14\xc7\x7f\xe7\x0d\xa9\
\x09\xcc\x90\x50\x76\xb6\xc6\x60\x60\xe3\xa3\x86\x34\xf4\xc3\xc6\
\x67\xa4\x1b\xa2\x98\x40\x13\x5d\xc9\x1a\x36\xda\x84\x7e\x59\x5c\
\xcd\xce\x3a\xa4\x33\x09\xcb\xae\x65\x83\x89\x19\x4c\x04\xc3\xc6\
\x3a\x98\xb4\x6f\x22\x62\x4b\x27\xc6\x34\xac\x9c\x06\x37\x94\x74\
\x98\x92\x50\x3a\xef\xef\xe2\x4d\xa7\x35\x99\xe9\xcc\x43\x76\xf4\
\xbf\xba\xe7\xbd\x73\xef\xf9\xdd\x73\xee\x17\xec\x69\x4f\xaf\xba\
\x2c\x8a\xb3\x9b\x2c\xb4\x1d\x4e\xac\x0f\xc9\x38\x07\xea\x06\x3a\
\xaa\xbf\x8a\x88\xdf\xcd\x2c\xfb\xa8\x74\x20\x5b\x48\xba\x1b\x2f\
\x1d\xc0\xcb\xcc\x7f\x82\x2c\x05\x1c\x01\xbb\x8f\x34\x8b\x43\x11\
\xc0\xa4\x0e\xe1\x9c\x02\x75\x61\x3c\x30\x6c\x22\x77\xa9\xf7\xfb\
\x97\x02\xf0\xe9\xf5\xeb\xb1\x7f\x56\xde\x4c\x21\x46\x80\x9f\x24\
\x26\x7f\x1d\xed\x5b\xa8\xe7\x3b\x90\xc9\x9f\x88\x05\x9a\xc2\x38\
\x0d\x5c\xb9\x53\xea\x9d\x24\x69\x41\xab\x93\xac\x2b\x2f\xe3\x4f\
\x7b\x69\xbf\xf2\x7e\x66\x7e\xac\xe5\x3e\x69\x7f\xdc\x4b\xfb\x15\
\x2f\xed\xa7\x9a\xf9\xee\x9a\x81\x6a\xda\xbf\x33\x6c\x2c\x37\xd2\
\x3b\x0d\xf0\xe1\xd5\xe5\xd7\x9e\x3c\x7f\x7c\xd1\xe0\x33\x59\xd0\
\x15\x0e\x62\x8b\x18\xd7\xe2\xb1\xf6\x99\x5b\xc3\xc7\x9e\x55\xc1\
\x27\x10\xdf\x60\x0c\xdd\xb9\xd4\x97\x8d\x0c\xe0\x26\x0b\x6d\xed\
\x07\xcb\x7f\x1a\xfa\x2b\x37\xd2\xff\x11\xc0\x07\x57\xe7\x3b\x2b\
\x9b\xce\x4d\x50\x17\x58\x00\x72\xaa\xc3\x84\x6d\x63\x31\x16\xd3\
\x99\xd9\xe1\xfe\x22\xc0\x7b\x99\xfc\x6d\x93\x8e\xac\x96\xe2\x6e\
\xa3\x85\xe9\x34\x02\x38\x9c\x58\x1f\x02\xde\x0a\x64\x97\xb7\x66\
\x5e\xd9\x74\x6e\x62\x3a\x1e\x7a\x68\x47\xdf\x5a\xbb\xab\xb2\xc9\
\x8f\x6e\xb2\xd0\x06\xe0\x04\xf6\x25\x70\xf4\x50\xa2\x7c\xb6\x51\
\x9c\x86\x00\xe1\x56\x63\x61\x6b\xc1\x95\x2b\xab\x17\x40\x5d\x68\
\x97\xb2\x09\x03\x7b\xa7\xfd\x60\xf9\x02\x40\x6e\xb4\xe7\x9e\xc4\
\x92\x41\x74\x00\x50\xb7\xa1\x5f\x6a\x66\x60\xe7\xc3\x54\xef\x2e\
\x41\x00\x9c\xdf\xb2\x0d\x7e\xc6\x38\xf9\x02\x00\xbc\x2e\xac\x58\
\xb3\x4c\xee\x7f\xd3\x5e\x5f\x06\x0e\xc8\xdd\x01\xb4\xc2\xf6\x81\
\x15\x09\x00\x2c\xda\x49\x59\x37\x80\x99\x11\x66\x25\x32\xc0\x43\
\x02\x3a\x6b\x96\xac\xd0\x6a\x09\x24\x96\xb6\x6d\x75\x00\x0f\xa3\
\x03\x88\xdf\x04\xa7\xb6\x3d\xf5\x6d\xab\x25\x30\xb3\x6b\x3b\x3e\
\x0d\x02\xf9\xc8\x00\x66\x96\x35\xe3\xf8\x40\x26\x7f\x02\x20\x1e\
\x6b\x9f\xc1\x58\xc4\xd0\x2e\xd1\x25\xe3\x8f\xd5\x52\x7c\x06\xc0\
\xcb\xcc\x75\x03\x6f\x63\xfa\x21\x32\xc0\xa3\xd2\x81\x2c\xc6\x83\
\x58\xa0\x29\x80\x5b\xc3\xc7\x9e\xc5\x62\x3a\x03\xdc\xaf\x46\xab\
\x95\xa3\xba\xf2\x11\x2c\x54\x54\xf9\xb8\x90\x74\x37\x90\x0c\x39\
\x29\x60\xf9\xe9\xfe\x7d\x37\x22\x03\x14\x92\xee\x86\xc4\x38\xc6\
\x69\x2f\xed\x8f\x03\xcc\x0e\xf7\x17\x57\xd7\xe2\x3d\xc0\x17\x52\
\x90\x07\xd6\x81\x75\xa4\xbc\x99\x3e\x7f\xbc\x16\xef\x9b\x1b\x19\
\x58\x01\xf0\xd2\xfe\x24\x30\x68\x0a\xc6\xee\x5e\x3c\xf9\xbc\x51\
\x9c\xa6\xf2\xd2\x7e\xaa\x7a\xb1\x8c\xb7\xd4\x41\x32\x6f\x7a\xfe\
\x72\x78\x81\xf9\x53\xcd\xdc\x9b\x6f\xb3\xa4\x1c\x2f\x91\xff\x1a\
\x63\x02\xb8\x6d\x72\x26\x73\xa3\x3d\xf7\xea\xc2\x66\xe6\xba\xab\
\x69\x1f\x34\x23\x95\x5b\xeb\xfd\xaa\xd9\x75\x1c\xe1\x41\xe2\x9f\
\x43\x5c\x01\x8e\x4a\x2c\x99\x31\x8b\xf1\x37\x00\xe2\x0d\xc2\x1d\
\xe3\x02\xcb\xa6\x60\x2c\x37\xfa\x6e\xc3\x85\xf7\x42\x00\x10\xde\
\x90\x87\x12\xe5\xb3\x54\x9f\x64\x86\x75\x86\xf1\x55\x34\xd9\x5d\
\x1c\x65\x9f\xee\xdf\x77\xe3\x7f\xd5\x7c\x4f\x7b\x7a\xe5\xf4\x2f\
\x95\x3f\x47\xac\x6d\xe5\x30\x73\x00\x00\x00\x00\x49\x45\x4e\x44\
\xae\x42\x60\x82\
\x00\x00\x02\x02\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x7f\x49\x44\
\x41\x54\x58\x85\xed\x97\xcb\x4a\x42\x51\x14\x86\xbf\x65\xa5\xd9\
\xe5\x01\xac\x57\xc8\x40\x28\xa3\xd2\x9e\x22\x87\xdd\x88\x06\x36\
\x33\xa1\x9e\xa1\x89\x36\xa9\x46\x5d\x69\x58\xef\x10\x1c\x8d\xb4\
\x40\xa2\x77\xc8\xe6\x5d\xac\x2c\x57\x83\x3a\xa2\x1c\xcf\x24\xb6\
\x18\x75\xfe\xd9\x5e\x1b\xf6\xf7\xb1\x60\x6f\xf6\x82\xff\x1e\x69\
\x5a\xa9\x4a\x2c\x5b\x58\x14\x95\x24\x42\x18\xe8\x35\xc4\x79\x41\
\xb9\x05\xd9\xb1\xd6\xc6\x8f\x10\x51\xa7\x80\xaa\xcc\x6c\x15\x0f\
\x55\x99\x07\x5e\x05\x4a\x8a\x3e\x9a\xa0\x0b\x32\xa0\x10\x01\x02\
\x20\x07\x56\x6a\x7c\xd9\x96\xa8\x0b\xc4\x32\x97\x4b\x82\xec\x83\
\xe6\x91\xee\x84\x95\x1a\x2b\x9b\x80\xdb\x89\x67\xaf\x43\xe8\xc7\
\x29\x30\xa5\xca\x42\x2e\x3d\x71\x0c\xe0\xab\x5b\xaa\x24\x81\xd7\
\xae\x77\xdf\xac\x69\x38\x80\x95\x1a\x2b\xd7\xaa\xd5\x04\xf0\x26\
\xc2\xaa\x5d\xaf\x0b\x20\x8c\x08\x94\xce\xd7\xa3\xf7\xa6\xe1\x76\
\xf2\x1b\xb1\x3b\xa0\x04\x84\x9d\x02\x10\x54\x78\x6e\x17\xbc\x21\
\x4f\x40\x5f\x2b\x81\x8e\xc4\x13\xe8\xb8\x40\xb7\xdb\x46\x3c\x53\
\x50\xb7\xbd\x9f\xc4\x5a\x9b\x90\x56\xf5\x8e\x77\xc0\x13\xf0\x04\
\x3c\x01\xd7\x77\xc0\xed\xde\x9a\x4e\xc7\x3b\xe0\x09\xfc\x2a\x81\
\x8a\x34\xfc\x54\xda\x98\x7e\xa0\xd2\x42\x40\x6f\x15\x22\xf1\xec\
\x75\xa8\x5d\xe4\xc9\xcc\xc5\x30\x10\x11\xb8\x71\x0a\xa8\x6f\x17\
\x08\xa0\x1f\x67\xd3\x9b\xb9\xa1\x76\xc0\x7b\xe8\x3a\x05\xfc\x35\
\xd1\x1d\xbb\xde\x34\x98\xc4\xb3\x57\x7b\xa0\x4b\xc0\x1b\x50\x02\
\x7d\x30\x83\x97\x41\xbe\x06\x13\xbf\xc2\x5e\x2e\x15\x5d\x71\x0c\
\x26\xb6\x44\x2c\x53\x9c\xfb\xfe\xb7\x8f\x02\x41\x33\x02\x54\x04\
\x6e\x54\x65\xdb\x4a\x47\x4f\x0c\x9d\xf9\x47\xf2\x09\xb5\xbd\x75\
\x94\xee\x91\xe8\xbe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x00\x9e\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x09\x00\x00\x00\x06\x08\x04\x00\x00\x00\xbb\xce\x7c\x4e\
\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\
\x02\x62\x4b\x47\x44\x00\xff\x87\x8f\xcc\xbf\x00\x00\x00\x09\x70\
\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\
\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xdc\x08\x17\x08\x15\x0f\xfd\
\x8f\xf8\x2e\x00\x00\x00\x22\x49\x44\x41\x54\x08\xd7\x63\x60\xc0\
\x0d\xfe\x9f\x87\xb1\x18\x91\x05\x18\x0d\xe1\x42\x48\x2a\x0c\x19\
\x18\x18\x91\x05\x10\x2a\xd1\x00\x00\xca\xb5\x07\xd2\x76\xbb\xb2\
\xc5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\xeb\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0d\xd7\x00\x00\x0d\xd7\
\x01\x42\x28\x9b\x78\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\x68\x49\x44\
\x41\x54\x58\x85\xed\x97\x4d\x4e\xc2\x40\x18\x86\x9f\xaf\x10\x14\
\xd4\x03\xa0\x57\x10\x13\xb6\x9e\x43\x76\xc8\x58\x8c\x26\x70\x1f\
\x31\x31\xa1\x74\x48\x97\x78\x0c\xd7\xc4\x78\x07\x71\xef\x0f\x02\
\x91\xcf\x85\x94\x20\xa0\x2c\x1c\x5c\x68\xdf\xdd\x4c\xdf\xf4\x79\
\xa6\x4d\xd3\x19\xf8\xef\x91\xf9\xb1\x6f\xcc\x09\x50\x03\x0a\xc0\
\xa6\x23\xce\x2b\x70\x27\x22\x8d\x20\x0c\x2d\xa0\xcb\x04\xc4\x37\
\x26\x04\x2a\xc0\x00\xe8\x02\x4f\x8e\x04\xb6\x81\x22\xb0\x01\xb4\
\x5a\xd6\x9e\xc6\x12\x53\x01\xdf\x18\x1f\x08\x04\x6e\xd2\x6f\x6f\
\xa5\xab\x28\xea\x39\x82\x03\x70\x5e\x2e\xe7\x47\x9e\xd7\x41\xe4\
\x50\xc0\x04\xd6\xb6\x01\xbc\x99\x4e\x0d\x18\x8c\x45\x8e\x5c\xc3\
\x01\xae\xa2\xa8\x27\xe9\x74\x09\x18\xaa\x48\x3d\x9e\x9f\x15\xd8\
\x07\xba\x61\x18\x3e\xb8\x86\xc7\x09\x82\xe0\x1e\x91\x2e\xaa\x85\
\x65\x02\x59\x54\x5f\xd6\x05\x9f\x66\x3c\x7e\x06\x72\xf1\x30\xbd\
\xaa\xef\x1b\xa3\xab\x3a\xdf\xa5\x65\xed\xfc\x97\xf6\x29\xde\x77\
\x17\x7f\x23\x89\x40\x22\x90\x08\x24\x02\x89\x40\x22\x90\x08\xac\
\xdc\x0f\xac\xfa\x9f\xff\x34\xb3\x4f\xa0\x8f\x48\xee\xcb\xa6\x33\
\xa2\xb7\x05\xf4\x17\x04\x14\xee\x80\xe2\x79\xb9\x9c\x5f\x17\xbb\
\x52\xa9\xec\xa1\x5a\x04\x6e\x17\x04\x3c\x91\x4b\x60\x63\x94\x4a\
\x5d\x57\xab\xd5\xdd\x75\xc0\x53\x22\x1d\x20\xa3\x22\x8d\x78\x7e\
\xfe\x60\xd2\x04\x7c\x60\x38\xd9\xbd\x3e\x3a\xa1\x8b\xec\x4c\x56\
\x9e\x51\x68\x86\xd6\x9e\x31\x7f\x30\x89\xab\x55\x63\x8e\x55\xa4\
\x8e\xea\x01\x90\x75\x22\xf0\xf1\xce\x6f\x51\xbd\x68\xb5\xdb\x91\
\xa3\x7b\xfe\x91\xbc\x03\x16\x71\x6a\x27\x44\x74\xfe\x4f\x00\x00\
\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x12\x44\
\x00\
\x00\x64\xf9\x78\x9c\xcd\x1c\x6b\x53\x1b\x39\xf2\xbb\x7f\x85\x16\
\xbe\x84\x9c\x1d\x6c\x83\x79\x4c\x2e\x57\x65\xc0\x04\xd7\x01\x06\
\xe3\x6c\x6e\x6b\x6b\x2b\x35\xb6\x65\x3c\x97\x61\xc6\x3b\x33\x0e\
\xb0\x57\xf9\xef\xd7\xd2\x48\xb2\x5e\xf3\x84\xe4\x0e\xef\x42\x3c\
\x92\xfa\xad\x56\x77\x4b\x9a\xdd\xb7\x0d\xf4\x16\x4d\x96\x18\x5d\
\x0d\x27\xe8\xd2\x9b\xe1\x20\xc6\xe8\x0d\x7c\xd9\x81\x06\xd2\x76\
\x1a\xae\x9e\x23\xef\x7e\x99\xa0\x37\xb3\x1d\xf4\xf7\x6e\xbb\xb3\
\xd7\x82\x5f\xfb\xff\x40\x7f\x3f\x0d\x7d\x2f\x40\x67\xeb\x3f\xd7\
\x38\x0e\xc2\xe7\x7f\xb0\x11\x37\x38\x7a\xf0\xe2\xd8\x0b\x03\xe4\
\xc5\x68\x89\x23\x3c\x7d\x46\xf7\x91\x1b\x24\x78\xde\x44\x8b\x08\
\x63\x14\x2e\xd0\x6c\xe9\x46\xf7\xb8\x89\x92\x10\xb9\xc1\x33\x5a\
\xe1\x28\x86\x01\xe1\x34\x71\xbd\xc0\x0b\xee\x91\x8b\x66\x80\x99\
\xc0\x83\xce\xc9\x12\x20\xc5\xe1\x22\x79\x74\x23\x0c\xfd\xe7\xc8\
\x8d\xe3\x70\xe6\xb9\x00\x12\xcd\xc3\xd9\xfa\x01\x07\x89\x9b\x10\
\x94\x0b\xcf\xc7\x31\x7a\x93\x00\x4b\x5b\x77\x6c\xc4\xd6\x0e\xc5\
\x33\xc7\xae\x4f\x00\x02\xd1\xa4\x99\xb7\xa2\x47\x2f\x59\x86\xeb\
\x04\x45\x38\x4e\x22\x6f\x46\xc0\x34\xa1\xd3\xcc\x5f\xcf\x09\x25\
\xbc\xd9\xf7\x1e\x3c\x86\x84\x0c\xa7\x42\x89\x09\x3c\x00\xbd\x8e\
\x81\x15\x42\x70\x13\x3d\x84\x73\x6f\x41\xfe\x62\xca\xdf\x6a\x3d\
\xf5\xbd\x78\xd9\x44\x73\x8f\x40\x9f\xae\x13\x78\x18\x93\x87\x54\
\xd6\x4d\xc2\xcd\x6e\x18\xa1\x18\xfb\x94\x38\x00\xe2\x01\x03\x94\
\xe9\x0d\x8d\xb4\x1b\x41\xb4\x22\xc2\x4d\x98\xb8\x62\xf2\xe4\x71\
\x19\x3e\xa8\xfc\x78\x94\xaa\xc5\x3a\x0a\x00\x31\xa6\xc3\xe6\x21\
\x88\x8f\xe2\xfd\x37\x9e\x25\xe4\x09\x19\xb1\x08\x7d\x3f\x7c\x24\
\x3c\xce\xc2\x60\xee\x11\xd6\x62\xa7\xc1\x2d\xc2\x9d\x86\xdf\x30\
\x65\x2a\xd5\x7f\x10\x26\x40\x73\x4a\x08\xd1\xc7\x6a\xa3\x67\xd6\
\x14\x2f\x5d\xdf\x47\x53\xcc\x84\x07\xa8\xbd\x80\x40\x23\x4f\x39\
\x5f\x11\x21\x22\x4e\xc0\x1a\x3c\xd7\x47\xab\x30\xa2\x58\x75\x7e\
\xdf\xa5\x54\x5c\x0c\xd0\xdd\xe8\x7c\xf2\xb9\x3f\x1e\xa0\xe1\x1d\
\xba\x19\x8f\x7e\x1d\x9e\x0d\xce\xd0\x56\xff\x0e\xbe\x6f\x35\xd1\
\xe7\xe1\xe4\x62\xf4\x69\x82\xa0\xc7\xb8\x7f\x3d\xf9\x0d\x8d\xce\
\x51\xff\xfa\x37\xf4\xcf\xe1\xf5\x59\x13\x0d\xfe\x75\x33\x1e\xdc\
\xdd\xa1\xd1\x98\x40\x1b\x5e\xdd\x5c\x0e\x07\xf0\x78\x78\x7d\x7a\
\xf9\xe9\x6c\x78\xfd\x11\x9d\xc0\xd0\xeb\x11\x18\xfe\x10\x2c\x1e\
\xe0\x4e\x46\x14\x27\x83\x36\x1c\xdc\x11\x78\x57\x83\xf1\xe9\x05\
\x7c\xed\x9f\x0c\x2f\x87\x93\xdf\x9a\x04\xd6\xf9\x70\x72\x4d\x20\
\x9f\x8f\xc6\xa8\x8f\x6e\xfa\xe3\xc9\xf0\xf4\xd3\x65\x7f\x8c\x6e\
\x3e\x8d\x6f\x46\x77\x03\x20\xe2\x0c\x20\x5f\x0f\xaf\xcf\xc7\x80\
\x68\x70\x35\xb8\x9e\xbc\x03\xc4\xf0\x0c\x0d\x7e\x85\x2f\xe8\xee\
\xa2\x7f\x79\x49\xb0\x11\x70\xfd\x4f\xc0\xc6\x98\x10\x8a\x4e\x47\
\x37\xbf\x8d\x87\x1f\x2f\x26\xe8\x62\x74\x79\x36\x80\x87\x27\x03\
\xa0\xaf\x7f\x72\x39\x48\xb1\x01\x77\xa7\x97\xfd\xe1\x55\x13\x9d\
\xf5\xaf\xfa\x1f\x07\x74\xd4\x08\x00\x51\x26\x49\xcf\x94\x4c\xf4\
\xf9\x62\x40\x9e\x12\xac\x7d\xf8\xef\x74\x32\x1c\x5d\x13\x7e\x4e\
\x47\xd7\x93\x31\x7c\x6d\x02\xbb\xe3\x89\x18\xfd\x79\x78\x37\x68\
\xa2\xfe\x78\x78\x47\x24\x73\x3e\x1e\x5d\x51\x4e\x89\x74\x61\xd0\
\x88\xc2\x81\xa1\xd7\x83\x14\x10\x91\xbc\xaa\x20\xe8\x42\xbe\x7f\
\xba\x1b\x08\x98\xe8\x6c\xd0\xbf\x04\x70\xa0\xad\x6b\x5d\xa1\xef\
\xe0\xc1\x6e\xa3\x71\x7b\x13\x85\xf7\x30\xf3\xe2\x13\x37\x72\x96\
\x61\xe4\xfd\x15\xc2\x54\xf6\xd1\x7f\x1a\x08\x7e\xa6\x61\x34\xc7\
\x91\x83\x3a\xab\x27\x30\x60\xdf\x9b\xa3\xed\xbd\xfe\xde\xf1\xde\
\xf1\x7b\xda\x9c\xe0\xa7\xa4\xe5\xfa\xde\x7d\xe0\x20\x98\x4e\x09\
\x8e\xd2\xe7\x2b\x77\x4e\xa6\x2e\x1d\x97\x3e\x99\xba\xb3\xaf\xf7\
\x51\xb8\x0e\xe6\x0e\xda\x06\xff\x75\xde\x39\x7f\xdf\xf8\xae\x62\
\x77\x66\xcb\x75\xf0\xd5\x42\x84\x18\xdb\x9a\x85\x7e\x08\xe4\xfc\
\x09\x8e\x0f\x83\xff\x8a\xdc\xb9\x07\x68\xdf\xc4\xab\x08\xbb\x73\
\x27\xc2\x0b\x1f\xa6\x57\x13\x3d\x75\x9c\x4e\x13\x3d\x77\x9c\xf6\
\xbb\xde\x7e\x0f\xbe\x77\xe9\xf7\xae\xd3\x86\x39\x98\x84\x2b\xa7\
\x8d\xa2\xfb\xa9\xfb\xa6\x7b\xd4\x44\x07\x07\x4d\xd4\xe9\x40\x73\
\xb7\xd7\xdb\x61\xcd\x9d\xb4\x79\xef\xb0\x89\x8e\xe0\xff\xce\xfe\
\x41\xda\xbc\x43\x68\x6e\xdc\x4e\xc2\xd0\x9f\x78\xab\x46\x29\x19\
\x99\xd4\x03\xec\x37\xc7\x40\x49\xa7\xdd\x25\xa8\x0f\x77\xde\xa7\
\x3d\x59\xf3\xe3\xd2\x4b\x70\x96\x1c\xc3\x95\x3b\xf3\x92\x67\x07\
\x75\xdb\xed\x94\x98\xcf\xde\xfc\x1e\x27\x8c\x16\x06\x22\xf6\xfc\
\x6f\x5c\x17\x26\xfe\xed\xbd\x76\xf7\xbc\x7b\x9e\x36\x83\xdf\xc3\
\xd4\xe5\xb6\x8c\x8e\xdb\x7b\xf3\x23\x3c\x3b\xd6\xfb\x31\x28\x53\
\x1f\xfa\x9b\x28\x7c\x6f\xe5\x30\x91\xbc\x97\xc4\xd3\xf2\x1e\xdc\
\x7b\xec\x80\xa7\x0a\x18\x6f\xe0\xd2\x89\x16\x1d\xa4\xf0\xe1\x00\
\xef\x0f\x60\x02\x40\x7e\x23\x4b\xfb\xdb\x87\x47\x47\x87\xc7\x53\
\x45\x68\x8c\x1a\x1d\x50\x4a\x35\x9e\x67\xc3\xe2\x3c\x92\x91\xa7\
\x4b\x3c\xfb\x7a\x12\x3e\xb1\xde\x31\x91\x35\x91\x7e\x4f\x48\x9f\
\xd3\xbc\x61\x83\xc3\x99\x4e\x19\x41\x0f\x60\x97\x1e\x48\x33\x4c\
\x92\xf0\x01\xf4\x44\xc6\xca\xc0\x1d\x58\x88\xdc\xa9\x2f\x68\x12\
\x4c\xd1\x1f\x3a\x29\x44\x57\xc7\x83\x65\x61\xe6\x26\x61\xd4\x6c\
\xdc\x7e\x04\xc2\x57\xea\x53\x06\xe2\xd1\x9b\x27\x4b\x30\x92\x23\
\x4e\xe7\x12\x93\x15\x83\x3f\xf9\x9e\x37\x96\x91\xeb\xe3\x45\x62\
\x23\x76\xd3\xdf\x59\x07\x33\xf2\x14\x82\x88\x82\xf6\x54\x7d\x76\
\x8a\x15\x28\xb9\xed\x8a\x11\x30\xeb\x59\x47\xfe\x1b\x67\x77\xee\
\x46\x5f\xbf\x78\xb0\x64\xc6\xbb\xf4\x79\x4c\x9f\xec\xd2\x71\xd3\
\xf0\xe9\x8b\x00\xf1\x6e\x15\xdc\xef\x94\x60\xc8\x59\x40\x08\x13\
\x17\xb2\xb5\x22\x8e\xaa\x04\xe1\x1c\x5a\x7e\x2f\x06\x8d\x32\xc8\
\x5d\xc8\xc6\xac\xea\x31\xfc\x85\xa2\x2e\x60\x3b\x5f\x8b\x65\x74\
\x98\xaf\xc1\x17\xeb\xaf\x9c\xf6\xca\xe8\xae\x9c\xe6\xca\xe8\xed\
\x07\x68\xad\x8a\xce\xe0\x5f\x38\x21\xf1\x5e\x00\x21\x77\x06\xb3\
\x4a\x1f\xa1\xbf\xe2\x9e\x9c\x25\x2b\xdf\x3a\xe2\xc2\x3e\xb9\x86\
\x63\x47\x5c\xc3\x44\x14\x40\x55\x64\x97\xab\x64\x4b\xcf\x17\x13\
\x57\x65\x4a\x8a\xa5\xa1\xc0\x08\xb5\x15\xa4\x96\xd5\x71\x18\xa5\
\x7d\x64\x01\x6d\x66\xc7\x17\xb9\x6e\x1b\x7d\x63\x88\xf6\xc2\x93\
\x35\xac\xab\xc1\x0f\x59\xa1\x25\xf8\x25\x16\x69\xb9\x77\xd6\x8a\
\xdc\xed\xe8\x2b\x72\xfa\x44\xc7\x96\xb1\x3e\x16\x75\xa9\xec\x62\
\x49\xbc\x1c\x5a\xd7\xc7\x42\x54\x7c\xde\x14\x76\xcc\xf3\x90\x16\
\xed\xd4\x20\xdb\x98\x52\x19\x34\x15\x0a\xd2\x14\xe3\xab\x12\x5c\
\x5a\xca\xa5\x64\xec\x38\x0f\x38\x58\xb7\xdc\x28\x0a\x1f\xcb\xad\
\x47\xaf\x41\x7c\x59\x59\xeb\xeb\x44\x99\x6e\x62\xa9\x28\xd5\x59\
\x5d\x2d\xaa\x31\x93\xb5\x5c\x14\xe8\x43\x71\x02\x86\x34\xab\xcb\
\x32\xdf\xa7\xbd\x9a\x37\xd5\xa7\x8b\x89\xb6\x71\x7b\x05\xb6\x04\
\x39\x77\x4e\x5e\x24\xe5\x88\x5a\x56\xf9\x7d\x33\xde\xa1\x69\x96\
\x01\xc5\x41\x49\xe4\x06\xe0\x9d\x23\xc8\xce\x2d\x03\xb2\xf3\x32\
\x6d\x64\x41\x7e\x6d\x02\x56\xad\xa4\x72\x6a\xae\xa4\xbc\x66\xa2\
\xab\xae\x1c\x2d\xe1\xdd\x59\x9e\xce\x1b\x84\x8f\x27\xb4\x95\x23\
\xc5\x92\xb8\xa7\xc8\xa4\xf5\x89\x40\x03\x36\x67\x62\xf9\xe3\x3d\
\x7a\x5a\x8f\x8d\x4a\x44\x01\x01\xba\xa0\xbd\x36\xfc\xe2\xff\x50\
\x18\x4a\xb3\x3f\xb1\x88\x9a\xb4\xca\x4a\x41\xbb\x6f\x49\xa9\x16\
\x47\xdf\x30\x5d\x80\x49\x1d\x33\xda\xd4\x07\xd8\x68\x52\x5c\x52\
\x49\xd2\x95\x6e\x66\xee\x69\xdf\x18\x03\x22\x32\x0b\x58\xf9\x47\
\x2c\x9d\xb6\x5a\x92\x4f\xda\xa6\xfe\x1a\x5b\xf8\xe9\xe8\x6c\x46\
\x29\x20\x5d\x5c\x7c\xd6\xa1\x92\xd9\x74\x03\x04\x00\x4e\xa0\x85\
\x9f\x66\xfe\x3a\xf6\xbe\x91\x7a\x2b\x07\xf1\x01\xd1\x59\x07\x42\
\x00\xd1\x25\xcf\xbe\xd4\x46\x60\xbd\x89\x31\x46\xb7\x7d\x2a\x28\
\x1a\x45\x11\x76\x93\x01\x07\xb4\x43\xa4\xa6\x93\xe5\x28\xb8\x36\
\xae\x01\xbd\x52\x6a\x5c\x12\x9d\x50\xdf\x8b\xf0\xda\x7c\x60\x3e\
\x01\x2f\xe0\xb6\x2a\xaf\xaf\xc1\x69\x36\x9f\x60\x35\x76\x8b\xa1\
\xfe\x1a\x4d\xe9\x22\xa0\x1b\x4d\x3d\x8b\x79\x99\xb5\x64\x47\x89\
\x25\xf0\xd4\x11\x5e\xf1\x82\x95\x83\xb9\x2e\x7f\x55\xb8\x7b\x31\
\x6f\x85\x9c\x51\xd7\x94\x06\x77\xc8\xe2\xdc\x4b\x63\x23\x60\xbe\
\x50\x30\x14\x45\xba\xd8\xb3\x8a\x68\x46\x4e\xb3\xdf\x26\x9f\xc2\
\x62\x31\xa1\xb5\x3f\x8d\x61\x25\x98\x25\x43\x70\xe7\xbf\x7a\xf8\
\x91\x41\x72\x7d\x08\xae\x48\x68\x65\xd6\x90\x0b\x57\x39\x73\xad\
\x51\x56\xe8\xb4\x78\x4c\x84\xb8\x8e\xa5\x25\x40\x2d\x8c\x4b\x55\
\xdf\x34\x84\x46\x22\x2a\x90\x93\x78\xcb\x12\xcc\x2b\xc9\xb4\xaa\
\xef\x4e\x35\x20\x22\x21\xe6\x0f\xe4\x68\x8d\x3f\xbb\x03\x40\xd8\
\x8e\x28\x8d\x14\x09\xec\x4b\x88\x1c\x07\x73\x2f\xc9\x8e\xb7\xf8\
\x9e\x88\xc2\x5d\x37\x7b\x45\xde\x2e\x23\x26\x4b\xe0\xc6\x73\x77\
\x75\x83\xa7\x22\x5c\xb6\x9e\x92\xad\x12\xd4\x6d\x73\x15\x6c\xca\
\x02\x89\x97\x80\x13\x63\x39\xfa\x7a\x0a\x66\x9a\x44\xa1\xdf\x0a\
\xc1\x3c\x89\x49\xa7\xc3\xdf\xeb\xcd\xab\x30\xa6\x7b\xa0\x10\x03\
\x86\x2b\xdb\x7e\x92\xb1\xae\xf3\xe7\x6c\x61\x37\x1b\x28\x85\x1d\
\x41\x21\xb7\xdf\xbb\x19\xe0\xf3\xfb\x11\x76\x15\x8d\x99\x8c\x56\
\x0e\x20\x8d\xb8\x37\x45\xa5\x6e\xae\x35\xd4\xc0\xa6\xd3\x53\xe5\
\xea\xa0\x3d\x40\xd7\xa1\x91\x1a\xfb\x87\x49\x8d\x84\x08\x8c\xa7\
\xdf\x3d\xee\xda\x75\xb6\x6f\x46\x4d\x1b\x9b\x63\xc3\x54\x3a\x9d\
\xa5\x1b\xcc\x7d\x6c\xd2\x6b\x81\x70\xd0\xee\x9d\xf7\x98\xd5\x42\
\x76\xd5\x62\xb1\x93\x46\xb1\x4a\x8c\x86\x0d\x34\xd5\xa2\x89\x95\
\x81\x8f\x4b\xa3\xcd\x04\xc1\xfe\xda\xb6\x95\xca\x3a\x45\xdd\x01\
\xcb\xf1\x5e\xdb\x88\xf7\xc4\x13\xab\x91\x52\xb0\x46\xbb\x6e\xe3\
\x1a\xb7\xd0\xf3\x07\x73\x4b\xe6\x48\x36\xb3\x26\x6f\x06\xfb\x56\
\x66\x09\xd4\xaa\xbc\x5a\x34\xcb\x52\xfe\xa2\x5e\x22\xc3\xa9\xa7\
\xe5\x57\xe0\xb7\xb4\x72\x8b\xb4\xcb\x38\x46\x45\xdd\xea\xb0\xbc\
\x51\xf5\xff\x48\xc3\xeb\x55\x1a\xb2\x48\x8c\xa8\x9c\xce\xc3\xc7\
\xc0\xe8\x62\x49\xfa\xc5\x4a\x69\x18\xd0\x8a\x88\x21\x0b\x3c\x11\
\xa4\xd6\x21\x0f\xb8\x34\x14\x74\x92\x40\x98\x97\xe3\xda\x64\x9f\
\xca\x25\x68\x38\x6a\xc5\x49\xeb\xd3\xb5\x86\xa3\xb6\x7b\xe2\x62\
\x62\x75\x3f\xcc\x8d\xa0\x8a\x23\x16\x56\xa9\xa1\x93\x17\x25\xc9\
\x39\x55\x76\x4c\xeb\xd5\xeb\xbb\x25\x58\xdf\x6b\x7b\xa5\x1f\xc4\
\x26\x31\xf9\xd7\x67\x34\xad\x2c\xd5\x5e\x6d\x38\xaf\x16\xff\x6b\
\xf6\xa1\xae\xa8\xae\x76\x7f\x9e\x52\xf3\xb5\x6a\xf3\xbb\x66\xa7\
\x3a\x5e\x77\xa3\xe0\xff\x99\x5e\x85\xdf\xe5\x8c\x64\x7a\xdd\x4c\
\xd7\x51\xe8\x73\xed\xa0\x85\xc7\x2d\x03\xf8\x76\x82\x9f\x92\xf2\
\x69\x4f\xa9\xec\x50\xa9\xfd\xde\xf8\xae\x17\x94\x46\x52\x80\xa5\
\x52\xf4\x4f\xb0\x5f\x60\x17\x9a\x49\x1e\x4c\x6a\x32\xb4\x42\x93\
\x53\x4f\xcf\x4f\x83\xd5\x0c\x67\x3f\x87\x82\x83\x19\xf9\x30\x93\
\xf0\xfe\xc2\x1f\x23\x6f\x55\xa1\x1e\x11\xc3\x90\x7b\x18\x62\x09\
\x80\xbb\x46\x00\xcc\x4b\xcf\x8d\xdb\x2b\x10\xf4\x67\x2f\x00\xcb\
\x92\x0a\xb4\x95\x76\x0f\xcc\x63\x6d\x3a\xb3\x62\x37\xd7\xaa\x80\
\xb9\x4b\x0f\xd3\xaa\xb5\x7f\x1b\x55\x62\x3b\x2f\x8b\xb8\xc3\x23\
\xf8\x1c\x54\x24\xae\x20\x13\x54\x69\x17\x5b\x2c\xa6\xb0\x84\x6c\
\x73\xf2\x32\x8b\xad\x14\x13\x58\xa9\xf4\xdd\xb8\x3d\x8f\xdc\x07\
\x5c\x3d\xfb\xdd\xdf\xdf\x4f\x45\x4f\xc7\xff\xbe\x20\xbf\xef\x96\
\xee\x0a\x7f\xd8\x6a\x6f\xfd\x51\x01\x9e\x12\x16\x09\xa8\x77\x89\
\x4b\xea\x64\xca\x99\xc6\xac\x51\xd2\xc6\x01\x39\x90\x09\xee\xc9\
\x72\x68\x55\x41\x03\x52\x3d\xda\x3b\xd2\xc5\xae\xea\x54\x32\xdc\
\x05\x38\xe3\xd6\x23\xd3\xd7\x34\xf4\xe7\x0a\x32\x4b\x9e\x5c\x61\
\x1a\x5e\x3c\x80\x91\x26\x00\x69\xea\x46\xa2\x18\x68\x80\xe6\x4e\
\xb6\x02\xe0\x5f\xf3\x01\xcb\xb3\xa4\x0e\xd9\x74\x7c\x19\xf0\x75\
\x48\x97\x81\xcb\x7b\xce\x37\xeb\x78\xa9\x9c\xfb\xa8\x7e\xcc\x95\
\x99\x24\x77\x75\x5a\x5c\x27\x4a\xa1\xfd\xfd\xe3\x7d\x35\x3c\xa7\
\xf5\x78\x27\x35\x0f\x4b\x6d\x49\x04\xd8\xda\x16\xa0\xd9\xa0\xed\
\xb1\x69\xa5\xab\xac\x40\x5d\xcc\x1d\x6d\xfb\x59\x15\x8b\x5e\xda\
\x7d\x15\x61\x58\x0a\x81\xaf\x2c\x8c\x12\x85\xbc\xdd\xb7\x16\x81\
\xbc\xdd\x95\xad\x60\x7b\xbf\x47\x3e\x86\x4c\x68\x45\x36\xf3\x08\
\xb9\x6d\xa7\x97\x39\x59\x7a\x16\x2a\x7c\x98\x86\xd2\x51\xe0\xec\
\x53\xd2\x2a\xa4\x82\x10\x27\x53\x8e\x35\x0b\xbc\x66\xa5\x58\xaa\
\xc2\x1d\x8a\x8d\x4e\x49\x2a\x6c\x27\x22\x53\x2c\x96\x29\x20\x92\
\xcc\xfe\xc1\xf1\xc1\xb1\x2a\x1f\x9e\x50\x48\x18\xd8\x13\x51\x6b\
\x5d\x79\x81\xd4\x91\x57\xc2\xf9\x77\x1e\xbd\x09\x40\x72\x48\xa7\
\xc3\xa2\xb1\x16\x1f\x18\x61\xbc\xf9\x5e\x5c\xe2\xb7\xf8\x0d\x85\
\x91\xbc\xe0\xed\xa0\x7b\x70\x74\xb8\x67\xb1\xf8\x3d\xbb\x61\x6f\
\x42\x9a\x3c\xbb\xd9\x77\xc9\x47\x25\x03\x65\xed\xb1\x94\x33\xac\
\xd2\x4b\x78\x69\xa3\x56\x64\xe4\xcc\xa3\x70\xd5\x22\xe9\x05\x9f\
\x17\x66\xca\xc2\x24\x91\x9f\xdf\xc9\xf5\x35\xa5\xb8\x22\x33\x43\
\x64\xc9\x6d\x59\xcf\xc4\x69\x1b\xa3\x95\x2c\x1e\xf7\x91\xfb\x6c\
\x76\xc8\x9a\x67\x44\x79\xa9\xaf\x11\x12\xd3\x4b\xad\xa9\xeb\xb2\
\x75\xd2\x24\x22\x72\xad\x0a\x27\x74\xb2\x6b\x04\x59\xc0\x1d\x72\
\x27\xce\xde\x22\x4e\xfa\xda\x1a\xab\x1e\x62\x35\x92\x5b\xcd\x7d\
\x68\xe7\x6b\x2c\x46\x7d\x04\x9f\x03\x6d\xbb\x25\x75\x01\xcc\x17\
\x2b\x13\x48\xf7\x64\xea\xa9\xcc\x32\x9e\xb1\x66\x4e\x69\xd9\xd4\
\xb2\x79\x4e\xdd\x8b\x41\xe6\x3d\x95\x23\x91\x82\x1d\xa0\x8c\x39\
\x22\xdf\x8f\xb1\x4e\x91\x74\xf3\x8b\xcf\x12\x1b\x21\x54\xc7\x3f\
\x91\x94\xb4\x3c\x6c\xa3\x44\x54\x23\x4c\x9f\xbf\x29\x54\x88\xd3\
\xc3\x39\x7d\xc2\xc5\xa2\x42\xb4\x98\x57\x4e\x2c\xd8\xd2\xf9\x9e\
\xc3\x44\xe5\x33\xb5\x5a\xe1\x8b\x26\x57\x06\xf4\xcd\x8c\xb4\x08\
\x40\x9a\xae\x39\x62\x92\x7d\xc1\x62\xf1\x2a\xce\xa6\xa6\xa8\x74\
\xdf\xf3\x42\xf7\xd2\xb8\xbd\x74\xa7\xd8\xd7\x56\xf0\xb6\x98\xee\
\x72\x9e\xc7\xb7\xe8\xcb\x67\x86\x62\x53\xdf\x59\xb9\x01\xce\xbe\
\xd6\x28\x56\x45\xcd\x3d\xe8\x2b\xbc\xb4\x08\x00\xec\xcd\x11\xca\
\x3f\x57\xb0\x34\x42\xce\xf3\xdc\x9a\x47\xee\xe3\x89\x1b\xa7\x37\
\xdb\x48\xd3\x26\xf2\x27\x47\xe7\x48\x7e\xc6\x2f\x00\xa7\x17\x7b\
\xa7\xcf\xf4\x54\x1e\x3b\x30\x97\x42\xb5\x9e\x27\x68\xe7\xf2\x99\
\x5e\xa1\xf4\xc3\x18\x33\xbf\x80\xaa\x9c\x5f\x22\xe3\x24\xb3\xc8\
\x3d\xcb\x69\x43\x56\xfd\xba\x0f\x1d\x4c\x47\xbd\x08\x2f\x5b\x91\
\xaa\xf2\xda\x62\xe3\x4a\xe2\x06\xc5\x4d\x46\x37\x68\xd2\x3f\xb9\
\xa3\x27\xae\x38\x29\x89\x3b\x75\x48\x3c\xa3\xe4\xa5\xdb\xd3\x0e\
\xf9\x64\x47\x60\x66\x8c\xcd\x97\xbd\x0c\x53\xce\x58\xe9\xe4\xa4\
\x4e\x3e\xea\x69\xc4\x3a\x34\x1a\xca\x08\x0e\x2d\xc1\x50\x57\x35\
\x71\xc1\xa6\xf3\x8b\xfd\x0c\xa7\xca\x70\x99\x48\xd5\x56\x04\x2a\
\x2f\x15\x5b\x5f\x83\x4d\x3d\x64\x34\xd9\x6c\x17\xb2\x99\x5a\x75\
\x76\x12\xb9\x7f\xd4\x3b\x3c\x98\x72\x0b\x39\x19\x4d\x26\xa3\x2b\
\xbb\x91\xa4\xac\xbc\xd8\x4e\xd2\x03\x2d\xaf\x6f\x24\x2c\xdc\xcd\
\xb5\x13\x6b\x48\x6c\x35\x15\xa6\xb7\x9f\x6c\x2d\x56\xd9\x64\x9b\
\x55\xbe\xb5\x58\x99\xb5\x1a\x8c\xce\x6c\x91\xcd\x48\x67\xce\xc0\
\x66\x2e\x07\xe7\x13\xbb\xc5\x10\xf2\x5e\x6c\x2f\xac\xd0\xf2\x63\
\xbc\x8a\xc5\x12\x6a\x99\x0b\x25\xf2\x27\x1b\x4b\x24\xca\xf0\xa5\
\x3c\x8b\xc5\x0e\x6a\x19\x8b\xca\x6a\x05\xf7\x42\x6c\x25\x7d\x2f\
\x85\xd5\x58\xd2\x48\xe2\xa5\xd6\x92\x21\x94\x9f\xb1\x08\x65\x3a\
\x20\x5d\x82\x29\x8d\xff\xdf\xd6\x52\xc6\xb3\x98\x7d\x0a\x38\xad\
\x60\x2c\x0c\x0c\x4a\x0b\xf3\xec\x76\x91\x74\xc4\xd8\xc1\x01\xcd\
\x03\x18\xb0\x5a\x47\x8b\x81\x27\xc0\x84\xac\xa8\x28\x6f\xb5\x31\
\x99\xc7\x9a\xca\xb0\xc4\x73\x9b\x9a\x3c\x19\xb9\x51\x19\xe6\xea\
\xe0\xcc\x39\x9f\x47\x93\xa1\xb3\x70\xf6\x35\x4d\x59\x72\x92\x95\
\xf6\xde\xf9\x1e\x33\x63\x7a\xd6\x76\xea\x46\xad\x34\xac\x25\x08\
\x2b\xc6\xfa\x02\x42\x10\x46\x0f\xae\x5f\x06\x04\xd8\x1d\x90\x29\
\x95\x88\x36\x54\xab\xe1\x79\x13\x29\x4d\x0b\x3f\x74\x13\x9e\x9e\
\x64\xb1\x97\x71\x03\xcc\xe2\x3a\xf2\x92\x85\x2c\x8a\xc4\xc1\x90\
\x2c\xba\x32\xe6\x99\xc3\x5e\x19\xd3\xeb\xd1\x77\xc1\xb0\x5f\x9d\
\x76\x81\x00\xc4\xbb\x07\x72\x10\xaa\x29\x8c\x7c\xb6\x1d\xb5\xc4\
\x2f\xeb\xab\x74\x72\x49\xe2\x15\x72\x40\x7d\xe9\xc5\x89\x5c\x4c\
\xce\xcb\x7f\xb3\xbd\xa6\x0c\xd4\x99\x82\xc0\x67\x4b\x71\x25\x02\
\x90\xe8\x4d\xf6\xb7\xb8\x14\x58\x96\xa4\x47\xc9\xbc\x04\x68\x01\
\xdb\x8d\x5b\xb1\x37\xf5\x41\x50\xb1\xf3\x8b\x3b\xff\x77\xe8\x05\
\x71\x8b\x5c\x33\x53\xcc\xaa\xd4\x81\x9e\x3a\x28\x7f\x0a\xc6\x5f\
\x08\xca\xd9\xd2\xf3\xe7\xd0\x33\xfd\xf6\x73\x09\xc8\xc1\x4f\x6d\
\x9c\xdc\xad\x36\x06\xa5\x2d\xea\x58\x79\x68\x85\x4c\x3d\x85\xf8\
\x25\x85\x98\x47\x68\xb8\x62\x48\xec\xd4\xda\xc8\x34\x87\x28\x44\
\x56\xa7\x92\x00\x7c\x91\x30\x45\x25\xbf\xb2\x48\x15\x97\x55\x59\
\xb0\xad\x30\x90\x56\x83\x3a\xf2\xcd\xa6\x3c\x5f\xca\x8c\xee\x7a\
\xb2\x36\xc9\xe6\x5e\x8e\xdd\x37\xd5\x22\x27\xc9\x0d\x66\x76\xd8\
\xd0\x6f\xeb\x80\xb2\x16\x85\x76\x13\xb1\xff\x18\x35\xf2\xcb\xad\
\xe4\xf0\xf4\x9c\xfe\x34\x2c\xc4\x16\xd1\x5a\x44\x6a\x31\xa5\xb6\
\x1d\x6f\x46\x10\x3b\x7c\x93\xde\x64\x72\x60\x00\xc0\xa8\xfc\x32\
\x38\x5e\x38\x3e\xb2\x2d\x54\x4a\xe4\x2d\xdd\x6c\xe6\x02\xb2\x2d\
\xf1\x32\x4d\x59\x67\x6d\x64\x1c\x74\x6f\xd9\x8d\x3e\xf2\xb7\xc2\
\x91\xd7\xc0\x11\xa5\x3c\xa7\x7f\x9e\xba\xe9\x37\xf8\xd3\x69\xa6\
\xf1\x5a\xfa\xb6\x37\xd4\x7e\xd7\x66\x3b\x44\x4d\xf1\xa4\x8b\xb6\
\xdd\x23\xf2\xe1\x8f\x3a\x90\xb9\x77\xc9\x67\xe7\x7d\x19\x69\xf0\
\xba\xfa\xbe\x51\x57\xd7\x4e\x6c\x39\xa8\xb5\x5f\x5e\x0e\x4c\x37\
\xda\xe9\x9a\x72\xb4\x94\x57\x4c\xdb\x48\x5a\x8a\x14\xa3\x13\x54\
\x53\x2d\xa6\x42\x34\x45\xfd\x44\xb5\xb4\xa9\x62\xf2\xa5\xb0\xc9\
\x0b\x32\xf3\xb2\xdc\xf7\x19\x14\xe6\x9d\xf6\x9b\x77\xf9\xdb\x12\
\x82\xa6\xdf\x57\xe1\x6a\xbd\xba\x0a\xe7\xf8\xc3\x56\x67\xeb\x0f\
\xf4\x1f\xb2\xff\x10\x06\xfe\x33\xbd\xb1\x4f\xaf\x48\xd2\x7e\x37\
\xa4\x1b\x29\x29\xe8\xe7\x70\xe8\xdd\x3e\xba\x69\xe1\x7e\xc5\xe8\
\xd1\x4d\x07\x92\x9d\x0b\x0a\x99\xdf\x59\x26\x23\x8b\xb9\xd2\x58\
\xea\xe5\xd3\xdb\x35\xe8\x1d\x06\xf4\xb5\xa5\x99\xc4\x76\x5e\x91\
\x58\x9a\x89\x49\x49\x9f\x70\xba\x52\x1e\x48\x5f\xc7\x92\x9b\x32\
\x94\x32\x01\xdb\x4d\xd4\x0d\x16\xfe\x0e\x1b\x05\xb5\x78\x9d\x19\
\x62\x3f\x99\x74\xa9\x99\x45\xa9\xe3\x3e\x59\x54\x81\x60\x89\x2c\
\x37\x7b\xc4\x68\x8a\xfd\xf0\x91\xbc\x63\x78\x4d\x50\x50\x3d\xb1\
\x57\xfb\x2a\xaa\x02\x25\x9c\x61\xdf\x7d\xc6\xf3\xf4\xfb\x03\xe8\
\x37\xad\x5f\xe9\x44\xeb\x6f\x62\xa8\x7d\x1a\x9f\x7a\x86\xd6\x21\
\xb1\x87\xb4\x00\xda\xea\x32\xdb\x88\x97\xde\x22\x41\x5e\x82\x5c\
\x34\x85\xdf\xe9\x9e\x9b\xc1\x5a\xcc\x78\x23\x6f\xf3\x35\x98\xd3\
\xe7\x4d\x36\x3f\x99\x79\x6e\xf5\x8a\xe3\x41\x99\x8a\xa3\xe8\x04\
\x0c\x75\xe0\x4b\xea\xed\xd0\xdf\xc8\x79\x24\x3a\x19\xd8\xab\x39\
\x3e\xd0\x89\x4d\x5e\x0b\x1c\xce\xe8\x2b\x9c\xd3\x57\x0d\xb3\x63\
\x75\xdc\x45\x0a\x68\x96\xa3\x87\x06\xab\xf2\xcd\xf5\xda\xe7\x4c\
\xec\x50\x69\x0c\xc9\x40\xf3\x12\x3f\xd7\x6b\x27\x53\xad\x05\x6b\
\x81\x76\xac\x45\xb7\xbf\xec\xbb\xcb\xc5\xc7\x9b\xd8\x4e\x8f\x74\
\xc2\x29\xa5\xf5\x48\xaa\xf1\xf9\xb8\x64\x36\x7e\x1f\x79\x73\x22\
\xfc\xcd\x51\x34\x76\xfc\x3f\x63\x3e\x4b\xa9\xba\x84\x08\xdc\xc7\
\xe6\xb2\x82\xfd\x90\x76\xdb\xa0\x4e\x7d\xa3\x8e\x19\x91\x6e\x1a\
\xb4\x50\x94\x3b\x1d\x5b\x0c\x6a\x39\x8d\xa7\xc4\xa0\x3a\x76\x11\
\xd6\xba\xb3\xc4\xfb\x86\x73\xe2\x5e\xd1\x21\x2b\x70\x4e\x3b\xd4\
\x89\x8c\x1b\x59\xd2\x33\x66\x73\xb9\xc5\x5b\x3f\xf6\x2a\x49\xdf\
\x72\xa7\xc4\xa4\xb8\xe2\xa5\x92\x72\xf7\x49\xb2\x6c\x82\x4e\x3b\
\xcb\x7b\x9e\x33\xa8\x75\x36\x97\xab\x9c\x85\x17\xc5\x89\x62\x7b\
\xd6\x6e\xc4\xb9\x42\x32\xa7\xdd\x46\x10\xbb\x79\x96\x7b\x2f\xb9\
\x00\x2d\x60\x8c\xe2\xa0\x15\x80\x74\x1b\x37\x9f\x74\xb9\xa3\x9d\
\xf8\xcd\xb6\x5b\x59\xea\xcd\x1b\xac\x32\x24\x9d\x01\x3b\x10\x16\
\x2c\x34\xd4\x7d\x20\xe9\xea\x88\xc5\x84\x7a\xfd\xde\x71\xef\x98\
\xd5\xbb\x89\x27\xa5\xef\x9f\xa1\xcb\x61\x18\x25\xd2\x8b\x68\xc8\
\x0a\x27\x23\xdd\x9c\x02\x7a\xa9\xdb\x97\xa1\xf2\x63\x58\x35\x0e\
\x82\xc9\x27\x8a\xa8\x1b\x39\x0d\xa3\x00\x47\xdc\xc3\xf3\xd9\x54\
\x6a\x32\xd5\x38\x8e\x2d\x16\xb0\xf0\x09\xe9\x95\xdc\xc2\x8b\xc1\
\xfa\x5d\x16\xfa\x12\x0d\x77\x9a\xb7\xa1\x57\xe6\x88\x7f\xdd\x53\
\x27\xb6\xdb\x02\xc6\xbe\x56\xf1\x8e\x30\x0f\xf1\x91\xc2\x94\xf4\
\x16\x1d\x62\x70\x1e\x98\xbc\x37\xf3\xfe\xc2\x48\x3c\x87\x4e\x31\
\x5f\xc3\xc9\x25\x1c\x87\x75\xaa\xc0\xb9\x79\x38\x9f\x5d\x2f\x4a\
\xd6\xb1\x78\x5b\x5c\xb9\xec\xd9\xea\xcd\x37\x77\xa8\x7e\x4f\x33\
\xc8\x0f\x5b\x7b\x5b\x7f\x80\xc3\x48\x9f\xd1\x18\x8a\x3e\xca\x09\
\xbd\xd9\xa5\x27\x20\x6b\xe5\x7b\x49\xb2\xc9\xa6\x2d\x74\xd9\x6e\
\xbf\xe9\xc3\x8a\x0f\x1e\x6c\xee\xbd\x15\x84\x46\x16\xd0\x5a\xe1\
\x45\xbe\x3c\x62\x1d\xa1\x55\x04\x94\x7b\x6f\xdf\x1b\xff\x05\x99\
\xf9\xdd\xb0\
\x00\x00\x07\xac\
\x00\
\x00\x2b\x10\x78\x9c\xdd\x5a\x6d\x6f\xdb\x36\x10\xfe\x5e\x20\xff\
\x81\x45\xbe\x34\x45\x9c\x48\x8a\xed\x36\xca\xa7\x75\x1b\xba\x01\
\x1b\xb0\x6c\xc1\xfa\xb1\xa0\x5e\x6c\x6b\x51\x44\x4d\x92\x97\xa4\
\x45\xff\xfb\xee\x48\xf1\x4d\xa2\x64\x3b\x71\x82\x6c\x26\x10\x3b\
\x24\x45\x1e\x9f\xbb\x7b\x78\x3c\xea\xf2\x8a\xb1\xfc\x2a\x2b\x0f\
\x5e\x7d\x3d\x78\x45\xf0\x13\xb1\x2a\x49\xab\x90\xf8\xe5\x1d\xa9\
\x59\x9e\x25\x24\xca\x69\x7c\x7d\x21\x9b\xe1\xf7\xb2\x62\xeb\x22\
\x99\xc4\x2c\x67\xd0\xf1\x70\xb1\xa0\x5e\xb0\x90\x1d\x4a\x9a\x24\
\x59\xb1\xe4\x03\x5c\x58\x63\x4e\x2a\x9a\x64\xeb\x3a\x24\x67\xba\
\x85\x95\x34\xce\x9a\x7b\xe8\xed\x79\x50\xf7\xed\xe0\xd5\xc1\xab\
\xcb\x4f\x59\xb2\x4c\x1b\x25\x92\x9c\x27\xf2\xb1\xb4\x4f\x3a\xe4\
\x38\x0b\xb0\x74\x46\x09\xb3\x26\xbd\x09\x57\xec\x9f\xb4\x52\x03\
\xf6\x9f\xbd\xfc\x25\x2b\x52\x5a\x7d\x44\x09\xd3\xa2\x79\x43\xee\
\xfc\x90\x78\xc7\xe4\x5e\x7c\xdd\x05\xe2\x3f\xf8\xf2\x8f\x49\xdd\
\xb0\x12\xfe\x97\x0b\x97\x15\x3e\x39\x8c\xa9\x37\xf7\xcf\x8f\x2e\
\x6c\xb9\x3d\xfe\x71\xca\x55\xa7\x79\x1a\x37\x69\xf2\xf4\xa2\x25\
\xef\xde\x7b\x3e\x3d\x52\x52\xfc\x9a\x16\xeb\x0f\xb4\x0a\xb9\x1c\
\x8e\xe9\x43\xd2\x54\xb4\xa8\x4b\x5a\xc1\xa4\xee\xa7\xc6\xa4\xef\
\x3e\xee\xb6\x2c\x14\x93\x1a\xd0\xd8\xc3\x97\x55\x5a\xd7\x03\xa3\
\x1f\x4e\xa7\xd3\xe1\x61\x05\xdc\xdb\xe1\xd9\x1a\x22\x7c\x00\x58\
\x81\xab\x77\x6c\x54\x06\xa1\x80\xd7\x37\x2a\x39\xaa\x00\x6a\xe0\
\x63\xe9\x36\x78\x27\x53\x30\xc6\x29\x96\xd3\xb7\xfd\xc6\x40\x36\
\xf6\x9b\x7c\x89\xc8\xdb\x53\xd1\x26\x4d\xe9\x86\x56\xcb\xac\x98\
\x44\xac\x69\xd8\x4d\x38\xd1\xae\xd5\x7a\x9b\x6c\x11\x0d\x1a\x4c\
\x8d\xdd\x10\x48\xba\x6f\xc7\x14\x94\x1f\x07\xf0\x48\xe0\xe1\x9f\
\xf6\x87\xe3\xa9\xbe\x29\x8c\x1b\x7f\x92\xd5\x34\xca\x1d\xdd\xa7\
\x1e\x96\xad\x7d\xfc\xbb\xa8\x06\x3b\x8b\x9b\x9f\x41\x86\x3f\xb3\
\xf4\x76\xef\x7e\x34\x4d\xb0\xa8\x0a\xd4\xd0\x7c\x8a\xc5\x70\xad\
\x59\x82\xe5\xa8\xbb\xc6\x05\x8b\xd7\xb5\x12\xe8\xf4\xad\x54\x41\
\xa0\x54\xb0\x67\xd7\x46\xa3\x11\x12\xe0\xb8\x3f\x26\x59\xf3\xd4\
\x70\x8c\x82\x31\xb0\x19\xb4\x7b\x41\xdd\xdc\xe7\x69\x28\x80\x18\
\x76\x64\x3f\xc5\x62\x3f\x29\x77\x91\x99\x02\xfc\xb7\x75\xbd\xfa\
\xb0\x06\x07\x28\x76\xdd\x33\x1e\x86\xc2\x6c\x8e\xc5\x32\x8a\x59\
\x80\x45\x57\xcd\x00\xab\x14\x8b\xae\x3a\x87\x2a\x8a\xc5\x40\x8b\
\xa3\x37\x3f\xb2\x17\x78\x9b\x25\xcd\xca\x01\x99\x5c\x93\x0b\x94\
\x41\x38\x15\x5c\xf3\xae\x4a\xf4\x2e\xbc\x60\x45\x33\xa9\xb3\x2f\
\x30\x80\x1f\xf4\xa8\x25\x4f\x17\x0d\xa0\xdd\xab\xaf\xb2\xe5\x4a\
\x35\x74\x15\x31\x42\xde\x8f\xc3\x3e\x48\xb0\x58\xd8\x07\x11\x16\
\x0b\xfb\xe0\x1c\x8b\x85\x7d\xf0\x1e\x8b\x81\x3d\xd7\xd8\x4c\xbb\
\xed\xf7\xec\x26\x62\x1f\xd8\x9d\x12\x59\x70\x5a\xc6\x80\x77\x9d\
\x41\x0f\xdd\x61\x97\x79\x11\x86\xb5\x4f\x9f\x93\x68\x89\xd0\xea\
\xd8\x54\x7d\x27\xd8\x7a\x6a\xda\x6b\x25\x32\x65\x32\x88\x40\x5a\
\x2b\x7f\xea\x6c\xc0\xb8\xa7\xda\xd5\x5e\xb0\x99\x6e\x6f\x93\xb6\
\x8a\xc8\xc8\x36\xd9\x53\x4e\x42\x2b\x18\x96\xde\x6f\x31\xdf\x13\
\x45\xa6\x4a\x8b\x61\x52\xb1\x72\x92\xb0\x5b\xad\x4d\x52\xaf\xa3\
\x18\xd8\xaa\x62\xf9\x84\x01\x01\x65\x45\x28\x55\x79\xd1\xef\x51\
\xb2\x3a\x43\xd9\x21\x18\x65\x25\xe1\x7c\x25\x7b\x49\x8e\x15\xec\
\x65\x1f\x53\xd0\x26\x24\x09\x7b\xbd\x43\x0c\x6f\x6d\x11\xe8\x80\
\x65\x75\xb1\x9c\x0d\xb6\x7f\xf2\xd7\xba\x6e\x08\x25\x35\xc8\x9a\
\xa7\x24\x07\xec\x88\x0c\xf3\xe4\x83\x20\xa6\xa0\x55\xeb\xa8\x84\
\x0f\xd7\xf4\x26\x25\xa2\x92\xd0\x9a\x34\xab\x94\x68\xfd\x76\x87\
\x11\xc1\xa0\x63\x24\xe8\xd6\xc3\x18\xe0\x9d\xd0\xaa\x62\xda\x28\
\x48\x76\x43\x97\x20\xfa\xba\xca\xdf\x84\xa7\xb8\x46\x06\xb1\xfc\
\x32\xfd\x9c\x01\xb0\xf5\x29\x6f\xad\x8d\xfa\x53\x1c\xe3\x33\x1f\
\xe3\xa4\x2c\x96\x5a\x93\x1f\xc1\x5c\x4a\x9c\x45\x87\x42\xcf\xc5\
\x06\x97\x57\xe9\x5d\x83\x21\x50\x27\x0c\x7b\xb6\xf9\xff\x88\xc1\
\x02\x73\x3c\xcc\xac\xc0\x50\xbf\x80\x45\xd2\x9c\x0c\x9f\xb1\x0f\
\x03\xfe\xe9\x9f\xb2\x1f\xe6\x66\x27\x20\x22\x3f\x9b\x18\x3b\x47\
\xe0\x20\x97\xe9\x7b\x2c\x92\x5c\xc8\x2a\x15\x7b\xfa\x3b\x6d\xf5\
\xe2\xe4\xc1\x1d\x81\xf8\x73\xf8\xe3\xf1\x2f\xc7\x3a\xc3\x15\x2d\
\x12\x30\x79\xbd\x5e\x6d\x51\xbb\x2e\xc8\x17\x0b\xf2\x06\x11\xe7\
\xf4\x29\x30\x37\x96\x23\xfa\xa8\xe5\x90\x1b\x38\x33\xc9\x35\x05\
\x86\x2b\x77\xb7\xb5\xc0\xbd\x20\x20\x96\x09\xfa\xa9\x4b\x85\xce\
\x9d\x13\x63\xcd\xf3\xf1\x49\x9e\x06\x0e\xcb\x00\x89\xc5\x70\x53\
\x63\x5a\x27\x37\x5a\xbc\xe8\x22\x58\x61\x02\x2e\x80\xa0\xf3\xff\
\x0a\x20\x27\x3e\xc8\xe6\x8e\x0e\x9b\xd1\x11\xfc\xcb\x79\xd1\x00\
\xe8\x98\x98\x7d\xf8\x56\xd1\xed\x62\xfa\xcd\x78\x36\x8e\xf4\xce\
\x0a\xda\x89\xfd\x01\x38\x6f\x57\x70\x62\x1f\x32\xf7\x12\x99\x7f\
\x48\x58\x54\x77\xa7\xc3\x80\x8b\x17\xac\x70\x4d\x01\x71\x61\x93\
\xc5\x7b\x25\x86\x07\x32\x9d\x04\xce\x60\x3a\x45\x75\x06\xcd\x11\
\xef\x62\xc4\x9c\x15\x67\x0f\x51\xe1\xe3\xd7\xbb\x71\xeb\x79\x5e\
\x22\x74\x2d\xe8\x19\xdd\x7c\xb7\x8d\xb8\xe3\x0e\x1b\x89\x50\x84\
\x4d\x8f\x64\xc2\x97\x87\xd0\x46\xe3\xd8\x1e\x21\x18\xe1\x61\xf0\
\xac\xcb\x96\xe4\x24\x3c\x36\xb1\xe8\x20\x74\x3b\xfc\xf6\xcb\x81\
\x03\x2c\xe8\x16\x55\x71\xe0\x06\xdf\xb6\x18\x50\x06\xa3\x23\xd9\
\x90\xc3\x60\x8a\x45\xa7\x52\x72\x9a\x15\x0f\x78\xee\xa7\x94\x02\
\x58\x78\xc8\x03\x59\xc5\xd1\x6d\x87\x1c\x8c\x91\x02\x37\x33\xdf\
\x6d\x7e\x9a\x1c\xce\x7d\x2c\x16\xf7\xcc\x3c\x2c\xba\x6a\x0e\x5c\
\xcb\xf3\xdb\xc7\x2a\x4d\xce\xb3\x1a\xb3\xce\xb5\x88\x54\x01\x56\
\x0d\x9e\xc6\xfb\x9e\x33\x8f\xb1\xe8\xc3\xe2\x2a\x8d\xaf\xf1\x88\
\x61\x65\x94\x55\x36\xd9\xc7\xa2\x3a\xff\xc0\xe2\xeb\x36\x39\x1b\
\x36\x59\x93\xa7\x0a\x99\x06\x80\x9e\xd0\x3c\x5b\x82\x15\xc7\x00\
\x44\x5a\xc9\xf3\x2f\xde\x4f\xc9\x6c\x19\x3f\x88\x89\x0a\x12\xa5\
\xcd\x6d\x9a\x16\x04\xb3\xdf\x35\xc9\x0a\x7e\x24\x6b\x18\xcb\x01\
\xe5\x4a\x9d\xc8\x1e\x8f\xb8\x48\x78\xdb\x59\x03\xae\x71\x0d\xaf\
\xe8\x72\xe4\x5c\x66\x9c\xb3\x3a\x9d\x44\x3c\x31\x03\x86\x6c\x36\
\x2d\x72\x46\x9b\xb6\x69\x07\x20\xfc\xff\x3e\x10\x6d\xce\x6a\x18\
\x8e\xc1\xfb\xc2\xbe\xbf\x0d\xce\xd1\x26\x40\xc7\x66\xe9\xe6\x48\
\xcd\x6c\x39\x99\xa8\x3f\xd6\xa5\x0e\xb0\xc2\xa7\xac\x00\xc2\x44\
\xf7\x2e\x69\x45\x1b\xb6\xcb\xc5\xe6\x26\x94\xb9\x7f\xcf\x2d\x94\
\xfd\x19\x16\xcb\xc1\xdb\x7b\x2f\x0d\x3c\xf7\xf8\xfd\x38\xf8\x34\
\xc6\xf2\x78\xf7\x1b\xc1\xcb\x50\xef\xbe\x70\xb3\x36\x59\x0e\x5b\
\x34\x9b\xc7\xfe\x3b\x05\x91\xbd\xe9\xee\x89\x03\xf7\x02\x11\xbe\
\x01\x60\x04\xad\x46\xae\xed\x71\xdc\x67\xb9\xcd\xd6\xb9\x24\x21\
\x84\x9d\x47\x12\xf7\x8c\x7d\x73\x57\x11\xed\x0e\xe9\xdb\x17\xe6\
\x00\xed\xc5\xae\xa8\xf6\xbd\x6e\xbd\xeb\x8e\xa5\x62\x4b\xe4\x0d\
\x50\xd9\x48\x56\x0b\xba\xdc\x5b\x06\xa4\x53\xf8\x6a\x0e\x27\xd7\
\xf7\x26\x01\x5a\x5b\xad\x8b\xeb\xb1\x10\x44\x18\x7f\x3b\x6a\x1b\
\x8d\x05\x27\xfe\xac\xb3\x1a\x0e\xa7\xb1\x92\x2b\x1a\xf1\xf1\x1b\
\x1a\xc9\xac\x81\xfb\xda\xce\x41\x12\x9d\xdb\x7f\x99\xf2\x6c\x93\
\xae\x6d\xf0\x35\x20\xae\xba\x43\xee\x2b\xc6\xd0\x40\xe7\x9a\xcb\
\xd1\x32\x70\xa5\xd0\x5e\xc5\x1b\x56\x69\x2b\x73\xe2\xdb\x18\xc8\
\xad\xa1\xa4\x45\x4a\xbe\x6e\xb1\x64\x11\xc7\xbb\x81\x0c\x73\x5a\
\xeb\x70\xd1\x9e\xd8\xe3\x4e\x8c\xbe\x8a\x9d\x88\xbc\xb2\x27\x88\
\xff\x8a\xd6\x80\x5a\xb3\x42\xf7\x6e\x18\x41\x7e\xcc\x69\x09\xca\
\x6c\x56\x84\x09\x07\xe7\xa3\xe8\x0d\x7d\x2c\x63\xed\x12\x6c\x91\
\x55\x75\x13\xbe\xb6\x5f\x14\xb0\xcc\xdf\x6b\x69\x66\x0f\x12\x2a\
\x62\xd7\x52\xf2\x4c\xcb\x26\x21\x5f\x0f\xbe\xc7\xe0\xb0\xc8\x8e\
\xd1\x99\xd7\x6a\xed\xba\x3a\x16\xf2\x48\x76\xf2\x3b\xbc\xa3\x5f\
\x33\x39\x72\x2e\xa6\xff\x7a\xce\x28\x1a\x5b\x68\xd5\x58\x9a\xb4\
\x72\x6f\x13\x92\x9d\x58\x4a\xbe\x07\x21\xb0\xd1\x84\x65\x5f\xa8\
\x76\x7d\x09\xa7\x77\x58\xde\xc3\x57\xb1\x67\x55\x18\xaf\xfc\xa8\
\x9a\xa0\x57\xa3\x5e\xef\xd1\xfa\xfa\x1d\x66\x63\xed\xbd\x69\x08\
\x71\x0a\x9c\x28\x31\x40\x89\xf1\x58\xc3\x83\xc7\x81\x0e\xeb\xa2\
\xed\x32\x6a\xa6\x1b\xb8\xcf\xc1\x32\x2e\x33\x57\x6f\x10\x18\xaa\
\x1e\x97\x7b\x64\xb3\xf8\x1b\x47\xa3\xf9\xb2\xff\xfa\x55\x7c\xc7\
\x37\x88\x63\x12\xdf\x8b\x1f\xba\x69\x21\x9b\x16\xbd\x26\x29\x9c\
\x7f\xe2\x75\xdf\xa7\xc2\x4c\xe0\x4c\x42\xee\x68\x3c\x93\x70\x88\
\x26\xe3\x06\x52\x1e\x2a\xf5\xca\x9e\x12\xe6\x76\xc7\x3c\x57\xc6\
\x29\xe3\x9a\xf3\x8d\x80\x77\x5d\x7b\x07\x55\xc9\x33\x90\x63\xb1\
\x03\x37\xf8\xc3\xef\xed\xb9\xc6\xe8\x9a\x82\xb8\x54\xdc\x3a\x0e\
\xe4\x8f\x47\xec\xce\x8e\x04\x5d\x13\xc9\x93\xff\xb0\xb3\xf4\xde\
\x36\x1b\xdc\x5e\xbf\xfd\x0b\x17\x3f\x69\xe4\
\x00\x00\x05\x3d\
\x00\
\x00\x13\x71\x78\x9c\xad\x57\x5b\x6f\xdb\x36\x14\x7e\x4e\x81\xfe\
\x07\x22\x7b\xd9\x82\x28\xce\x75\xe9\x54\xec\xc1\xb1\xb3\x46\x68\
\x62\xaf\xb6\xd3\xa0\x4f\x03\x25\xd1\x32\x11\x99\xd4\x28\x6a\x76\
\x56\xec\xbf\xef\x90\x12\x15\x51\xb7\x38\x41\x63\x14\x85\xc9\xc3\
\x8f\xdf\xb9\xf0\x9c\xcf\x83\x83\xf7\xef\xf6\x46\x3c\x79\x12\x34\
\x5a\x49\x74\x7a\x7c\x72\x86\xae\xd7\x98\x65\x24\x46\xa3\x18\x93\
\x34\xe5\xec\xfd\x3b\xb0\xb9\xa5\x01\x61\x29\x09\x51\xc6\x42\x22\
\x90\x5c\x11\x34\x4c\x70\x00\xff\x15\x3b\x87\xe8\x2b\x11\x29\xe5\
\x0c\x9d\x1e\x1d\xa3\x9f\x95\xc1\x7e\xb1\xb5\xff\xcb\x47\x40\x78\
\xe2\x19\x5a\xe3\x27\xc4\xb8\x44\x59\x4a\x00\x82\xa6\x68\x49\x63\
\x82\xc8\x36\x20\x89\x44\x94\xa1\x80\xaf\x93\x98\x62\x16\x10\xb4\
\xa1\x72\xa5\xaf\x29\x40\x8e\x00\xe2\x5b\x01\xc1\x7d\x89\xc1\x1a\
\x83\x7d\x02\xdf\x96\x55\x3b\x84\xa5\x26\xbc\xb7\x92\x32\x71\x07\
\x83\xcd\x66\x73\x84\x35\xd3\x23\x2e\xa2\x41\x9c\x5b\xa5\x83\x5b\
\x6f\x74\x3d\x99\x5f\x3b\xc0\x56\xdb\xdf\xb3\x18\xbc\x45\x82\xfc\
\x9d\x51\x01\x7e\xfa\x4f\x08\x27\x40\x26\xc0\x3e\x50\x8c\xf1\x06\
\x71\x81\x70\x24\x08\xec\x49\xae\xc8\x6e\x04\x95\x94\x45\x87\x28\
\xe5\x4b\xb9\xc1\x82\x00\x4a\x48\x53\x29\xa8\x9f\x49\x2b\x52\x86\
\x1a\x38\x5c\x35\x80\x58\x61\x86\xf6\x87\x73\xe4\xcd\xf7\xd1\xd5\
\x70\xee\xcd\x0f\x01\xe3\xc1\x5b\xdc\x4c\xef\x17\xe8\x61\x38\x9b\
\x0d\x27\x0b\xef\x7a\x8e\xa6\x33\x34\x9a\x4e\xc6\xde\xc2\x9b\x4e\
\xe0\xdb\x1f\x68\x38\xf9\x86\x3e\x7b\x93\xf1\x21\x22\x10\x27\xb8\
\x86\x6c\x13\xa1\xf8\x03\x49\xaa\x62\x48\x42\x15\xb0\x39\x21\x16\
\x81\x25\xcf\x09\xa5\x09\x09\xe8\x92\x06\xe0\x17\x8b\x32\x1c\x11\
\x14\xf1\x7f\x88\x60\xe0\x0e\x4a\x88\x58\xd3\x54\x65\x32\x05\x7a\
\x21\xa0\xc4\x74\x4d\x25\x96\x7a\xa5\xe1\x14\x5c\x73\x30\x50\x11\
\x1c\xe8\x52\x9a\xde\x4e\x67\x7f\x8d\x87\xb3\xcf\x48\xfd\xfd\x8e\
\x7e\x3a\xf9\x4d\x7d\xca\xad\xbb\xeb\xb1\x77\x7f\x97\x6f\x9d\x5d\
\xa8\x4f\x75\xeb\xd6\xfb\x74\xb3\x50\x5b\x17\x43\xf5\x29\xb7\xf2\
\xf5\xfc\xd4\x58\xff\x95\x5b\xc3\x11\xe4\x71\x51\x00\x8e\x2f\x3f\
\x9c\x7f\x30\x84\x0e\xd0\x77\xb0\xf2\x71\xf0\x18\x09\x0e\xbc\x5d\
\x43\x46\x55\x63\xc0\x63\x2e\x5c\x83\xa6\x56\x7c\x2e\xc0\x35\x17\
\x9d\x24\x5b\xc8\x68\x4c\x43\xc3\x02\x36\xff\x53\x78\x5f\x1e\x68\
\x18\x11\xe9\xba\x54\x92\xb5\x9b\x92\x98\x04\x2a\x8b\x8d\x4b\x72\
\x16\xe5\xa9\xd1\x8a\x04\x8f\x57\x7c\x7b\x88\xbe\xcc\x70\x48\xf9\
\x55\x26\x25\x64\xfe\x7b\xe5\x4a\xc6\x19\x29\xed\x2b\x46\x70\x15\
\x0b\xa1\x02\x25\x17\x70\xda\x00\x55\x56\x35\xca\x86\x86\x72\x05\
\xbc\xcf\x92\xad\xf2\x63\x45\xd4\x53\x2e\xbf\xf7\x81\xba\x6e\xc6\
\x02\x85\x4a\xc2\x76\xfc\x8a\x81\x45\xb8\x2d\x46\x56\x10\x76\xf0\
\xe8\x19\xda\x5d\xa9\xe2\xeb\x60\x50\xb3\xea\xa2\x51\xe6\xb1\xdf\
\xdf\x17\xbc\x7d\x93\xaf\xf5\x32\xe9\xb8\x7b\x17\x67\x5f\xe7\xaa\
\xcd\xa2\x16\x81\x4f\xb0\x9e\x00\xbc\x46\x59\x63\x11\x51\xe6\x48\
\x9e\xb8\xe8\xd7\x4a\x59\x18\x23\xd7\x95\x54\x42\x9b\x53\xb6\xda\
\xc8\xb9\xcc\x8b\x29\x26\x4b\x28\xa5\xcb\xca\x91\x79\x20\x78\x1c\
\x5f\xe1\x4e\x7a\x1d\x41\x2a\x9f\x5e\x0d\x06\x7c\x15\xf4\x5f\xce\
\x24\x8e\x35\x62\x59\xbe\x17\x39\x83\x9c\xba\x8b\x8e\xe1\x06\xf3\
\xef\xec\xb4\x8d\x90\x0b\x31\x93\x10\xc8\xd8\x7a\x15\x35\x18\x75\
\xb4\x8a\xd5\x02\xe3\xae\xa0\xed\x15\xc1\xb0\x1f\xb6\xee\x57\xbb\
\xf5\x8a\x06\x5c\xdd\xcf\x1c\xc2\x29\x68\x2a\x36\x27\x05\xab\x93\
\x3e\x56\xb6\x93\x36\x48\x05\xa0\xdf\xb5\x3a\x97\x35\xd4\x46\x81\
\x71\xda\x7f\xd0\xba\x5d\x1d\x33\xe9\xea\x3a\x87\xc3\xd0\x89\x29\
\x03\x79\x50\x5d\x4d\x33\x5f\xaf\xd6\x63\xbc\x63\x88\xf7\xe0\x7c\
\x00\xf4\x01\xcf\x01\x4f\x74\x62\xf3\x04\xf7\x51\xd0\x97\x25\x3c\
\xa5\x6a\x92\xb9\x08\xfb\x00\x0b\x73\xb8\xef\x48\x3d\x50\xb5\xa2\
\xaa\xd0\x78\xc6\x55\x4f\xe6\xf9\xe9\x14\xa6\xdd\x37\x58\x11\xad\
\x17\x7f\xeb\x05\xf0\x40\x3f\x9a\x77\xda\x05\x6f\x02\xfc\x16\x07\
\x00\xd8\x38\xd1\x8d\xfb\x56\xda\x75\x44\x75\x91\x83\x85\xe0\x1b\
\xbb\x42\xb4\x1e\x6d\xdb\xc8\x92\xb6\xd5\x90\x6f\x58\xbe\xfe\x72\
\x5b\x2a\x62\x50\x1b\x97\x67\xdd\x79\x4a\x40\x20\x35\xeb\x57\xad\
\x36\x7a\x84\x35\xf7\x86\x3e\x68\x3d\x1c\xc8\x62\x16\x54\x9a\x7a\
\x6b\x57\x69\x3d\xa4\x55\x5d\x9b\xca\xa8\xf5\x1b\x73\xcc\x03\x6d\
\xf2\x95\x92\x3c\x0c\xe9\x8a\x6f\x9c\x90\x04\x5c\x68\xf5\xe6\x18\
\xcd\x02\x81\xd1\x69\xd2\x5f\xd5\xc6\x33\xb2\x63\x84\x51\xa9\x62\
\x2a\x66\x4d\xd1\x84\x63\x09\xb2\x11\x4b\xd2\x0a\x61\x7b\x76\x43\
\x30\x24\xa5\x24\xf7\x72\x0f\x7d\x3e\x00\x11\xcf\x29\xf4\x49\xba\
\xde\xa4\x27\x90\x48\x50\xb7\x2e\x3a\xaf\xe4\xb9\xe5\x82\x52\xd7\
\x41\xc2\xdb\xb6\x6d\x89\xd0\x93\xc7\x85\xfa\xdd\x50\x3a\x1b\x09\
\x1a\xaa\x77\x53\xc6\xa6\xe6\x2a\x58\x9b\x91\x5a\xcc\xea\xbc\x7d\
\x54\x07\x5d\x6e\x03\xa3\x1a\xfb\xd5\xe6\x2f\x40\x6e\x64\xa9\x5b\
\x74\xfc\xba\xa3\xe5\xe0\x3b\x6f\x47\xea\xd3\xb1\xb6\x43\x23\xbe\
\xf6\xb9\xd6\x0a\xaf\x79\x6c\x3b\x22\x0a\x9e\x38\x0a\xf6\x87\x01\
\xda\x14\xfb\x9e\xfc\x0e\x85\x68\x1e\xd7\x3c\xa1\xcc\x48\xaa\x22\
\xce\x8e\xb0\x5a\x5f\xab\xbd\x6e\x5a\xbe\x7e\xcf\x50\x55\x8d\x4d\
\xcd\xd5\x6f\xfe\x2a\x78\x85\xfb\x6d\x03\x31\x87\xe9\xe5\x64\x1a\
\x69\x3b\xa5\x1f\x16\xbe\x39\x2c\xd6\xe4\xac\xd5\x27\xf3\x7d\xd7\
\x05\xbf\xa0\x45\x76\x09\xc2\x8b\x46\x3d\x6b\xb1\x73\x5e\x17\x3b\
\x36\x58\x9b\x26\x6c\x51\x96\x15\xb4\x06\x52\x55\x0e\xbe\xb5\x32\
\x6d\xac\x17\xa6\xb2\x21\xe6\x18\x56\x4e\x97\x93\x6d\xaa\xac\x4f\
\x40\x5b\x88\x0d\x34\x33\xeb\x4a\x3c\x35\xf4\x8a\x3d\x33\xf1\x1a\
\x32\xb6\xe7\x97\x6f\xe3\x6c\x0b\x6e\x79\x67\x2f\xae\x1d\xcc\x5b\
\xec\x93\xb8\xbb\x9c\xfe\x14\x3c\x52\x53\xd3\x34\x54\x49\xb6\xa0\
\x24\x62\x1a\x41\x10\x02\xc2\x64\xe5\x51\x54\x4c\x55\x67\xcf\xd8\
\xa3\x95\x8f\xa2\xc0\x7b\x86\x63\x0e\x73\x47\x58\xa6\x46\x44\x82\
\x45\xf9\xab\xbc\xc3\x81\xff\x01\x2c\xd9\xf9\xb9\
"
qt_resource_name = "\
\x00\x06\
\x07\xac\x02\xc3\
\x00\x73\
\x00\x74\x00\x79\x00\x6c\x00\x65\x00\x73\
\x00\x0a\
\x01\x52\xf7\x73\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\x00\x5f\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x73\
\x00\x10\
\x0f\x95\x51\xb3\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\x00\x6f\x00\x72\x00\x61\x00\x6e\x00\x67\x00\x65\x00\x5f\x00\x69\x00\x63\x00\x6f\x00\x6e\x00\x73\
\x00\x06\
\x07\x03\x7d\xc3\
\x00\x69\
\x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\
\x00\x0a\
\x02\x65\x55\xf5\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\x00\x6f\x00\x72\x00\x61\x00\x6e\x00\x67\x00\x65\
\x00\x0c\
\x04\x56\x23\x67\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0e\
\x04\xa2\xfc\xa7\
\x00\x64\
\x00\x6f\x00\x77\x00\x6e\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0a\
\x0b\x2d\x87\xc7\
\x00\x68\
\x00\x61\x00\x6e\x00\x64\x00\x6c\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x04\
\x00\x06\xa8\x8b\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\
\x00\x11\
\x0a\xe5\x6c\x07\
\x00\x72\
\x00\x61\x00\x64\x00\x69\x00\x6f\x00\x5f\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x09\
\x06\x98\x83\x27\
\x00\x63\
\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x08\x8c\x6a\xa7\
\x00\x48\
\x00\x73\x00\x65\x00\x70\x00\x61\x00\x72\x00\x74\x00\x6f\x00\x6f\x00\x6c\x00\x62\x00\x61\x00\x72\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x1a\
\x01\x21\xeb\x47\
\x00\x73\
\x00\x74\x00\x79\x00\x6c\x00\x65\x00\x73\x00\x68\x00\x65\x00\x65\x00\x74\x00\x2d\x00\x62\x00\x72\x00\x61\x00\x6e\x00\x63\x00\x68\
\x00\x2d\x00\x6d\x00\x6f\x00\x72\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0a\
\x05\x95\xde\x27\
\x00\x75\
\x00\x6e\x00\x64\x00\x6f\x00\x63\x00\x6b\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x13\
\x08\xc8\x96\xe7\
\x00\x72\
\x00\x61\x00\x64\x00\x69\x00\x6f\x00\x5f\x00\x75\x00\x6e\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x2e\x00\x70\
\x00\x6e\x00\x67\
\x00\x15\
\x0f\xf3\xc0\x07\
\x00\x75\
\x00\x70\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\
\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1f\
\x0a\xae\x27\x47\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x75\x00\x6e\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\
\x00\x64\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x0c\xe2\x68\x67\
\x00\x74\
\x00\x72\x00\x61\x00\x6e\x00\x73\x00\x70\x00\x61\x00\x72\x00\x65\x00\x6e\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x16\
\x01\x75\xcc\x87\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x75\x00\x6e\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\
\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x14\
\x0b\xc5\xd7\xc7\
\x00\x73\
\x00\x74\x00\x79\x00\x6c\x00\x65\x00\x73\x00\x68\x00\x65\x00\x65\x00\x74\x00\x2d\x00\x76\x00\x6c\x00\x69\x00\x6e\x00\x65\x00\x2e\
\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x08\x90\x94\x67\
\x00\x63\
\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2d\x00\x70\x00\x72\x00\x65\x00\x73\x00\x73\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x14\
\x07\xec\xd1\xc7\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x2e\
\x00\x70\x00\x6e\x00\x67\
\x00\x0e\
\x0e\xde\xfa\xc7\
\x00\x6c\
\x00\x65\x00\x66\x00\x74\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x12\
\x07\x8f\x9d\x27\
\x00\x62\
\x00\x72\x00\x61\x00\x6e\x00\x63\x00\x68\x00\x5f\x00\x6f\x00\x70\x00\x65\x00\x6e\x00\x2d\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\
\x00\x67\
\x00\x0f\
\x02\x9f\x05\x87\
\x00\x72\
\x00\x69\x00\x67\x00\x68\x00\x74\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x08\xc4\x6a\xa7\
\x00\x56\
\x00\x73\x00\x65\x00\x70\x00\x61\x00\x72\x00\x74\x00\x6f\x00\x6f\x00\x6c\x00\x62\x00\x61\x00\x72\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x10\
\x01\x07\x4a\xa7\
\x00\x56\
\x00\x6d\x00\x6f\x00\x76\x00\x65\x00\x74\x00\x6f\x00\x6f\x00\x6c\x00\x62\x00\x61\x00\x72\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x19\
\x08\x3e\xcc\x07\
\x00\x73\
\x00\x74\x00\x79\x00\x6c\x00\x65\x00\x73\x00\x68\x00\x65\x00\x65\x00\x74\x00\x2d\x00\x62\x00\x72\x00\x61\x00\x6e\x00\x63\x00\x68\
\x00\x2d\x00\x65\x00\x6e\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1c\
\x01\xe0\x4a\x07\
\x00\x72\
\x00\x61\x00\x64\x00\x69\x00\x6f\x00\x5f\x00\x75\x00\x6e\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x5f\x00\x64\
\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x14\
\x06\x5e\x2c\x07\
\x00\x62\
\x00\x72\x00\x61\x00\x6e\x00\x63\x00\x68\x00\x5f\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x64\x00\x2d\x00\x6f\x00\x6e\x00\x2e\
\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x06\x53\x25\xa7\
\x00\x62\
\x00\x72\x00\x61\x00\x6e\x00\x63\x00\x68\x00\x5f\x00\x6f\x00\x70\x00\x65\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0c\
\x06\x41\x40\x87\
\x00\x73\
\x00\x69\x00\x7a\x00\x65\x00\x67\x00\x72\x00\x69\x00\x70\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x10\
\x01\x00\xca\xa7\
\x00\x48\
\x00\x6d\x00\x6f\x00\x76\x00\x65\x00\x74\x00\x6f\x00\x6f\x00\x6c\x00\x62\x00\x61\x00\x72\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1c\
\x08\x3f\xda\x67\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x75\x00\x6e\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\
\x00\x64\x00\x5f\x00\x66\x00\x6f\x00\x63\x00\x75\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x01\xf4\x81\x47\
\x00\x63\
\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2d\x00\x68\x00\x6f\x00\x76\x00\x65\x00\x72\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x18\
\x03\x8e\xde\x67\
\x00\x72\
\x00\x69\x00\x67\x00\x68\x00\x74\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\
\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1a\
\x0e\xbc\xc3\x67\
\x00\x72\
\x00\x61\x00\x64\x00\x69\x00\x6f\x00\x5f\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x5f\x00\x64\x00\x69\x00\x73\
\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x17\
\x0c\xab\x51\x07\
\x00\x64\
\x00\x6f\x00\x77\x00\x6e\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\
\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x0b\xda\x30\xa7\
\x00\x62\
\x00\x72\x00\x61\x00\x6e\x00\x63\x00\x68\x00\x5f\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x1a\
\x01\x87\xae\x67\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x69\x00\x6e\x00\x64\x00\x65\x00\x74\x00\x65\x00\x72\x00\x6d\
\x00\x69\x00\x6e\x00\x61\x00\x74\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x17\
\x0c\x65\xce\x07\
\x00\x6c\
\x00\x65\x00\x66\x00\x74\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\
\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x19\
\x0b\x59\x6e\x87\
\x00\x72\
\x00\x61\x00\x64\x00\x69\x00\x6f\x00\x5f\x00\x75\x00\x6e\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x5f\x00\x66\
\x00\x6f\x00\x63\x00\x75\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1a\
\x05\x11\xe0\xe7\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x5f\
\x00\x66\x00\x6f\x00\x63\x00\x75\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x17\
\x0f\x1e\x9b\x47\
\x00\x72\
\x00\x61\x00\x64\x00\x69\x00\x6f\x00\x5f\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x5f\x00\x66\x00\x6f\x00\x63\
\x00\x75\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x20\
\x09\xd7\x1f\xa7\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x69\x00\x6e\x00\x64\x00\x65\x00\x74\x00\x65\x00\x72\x00\x6d\
\x00\x69\x00\x6e\x00\x61\x00\x74\x00\x65\x00\x5f\x00\x66\x00\x6f\x00\x63\x00\x75\x00\x73\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0c\
\x06\xe6\xe6\x67\
\x00\x75\
\x00\x70\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1d\
\x09\x07\x81\x07\
\x00\x63\
\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x62\x00\x6f\x00\x78\x00\x5f\x00\x63\x00\x68\x00\x65\x00\x63\x00\x6b\x00\x65\x00\x64\x00\x5f\
\x00\x64\x00\x69\x00\x73\x00\x61\x00\x62\x00\x6c\x00\x65\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x03\
\x00\x00\x78\xa3\
\x00\x71\
\x00\x73\x00\x73\
\x00\x08\
\x08\x8e\x55\xe3\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\x00\x2e\x00\x71\x00\x73\x00\x73\
\x00\x0e\
\x05\xf4\x92\x03\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\x00\x6f\x00\x72\x00\x61\x00\x6e\x00\x67\x00\x65\x00\x2e\x00\x71\x00\x73\x00\x73\
\x00\x09\
\x08\xe5\x8d\xa3\
\x00\x64\
\x00\x61\x00\x72\x00\x6b\x00\x32\x00\x2e\x00\x71\x00\x73\x00\x73\
"
qt_resource_struct = "\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x01\
\x00\x00\x00\x12\x00\x02\x00\x00\x00\x01\x00\x00\x00\x0d\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x09\
\x00\x00\x00\x2c\x00\x02\x00\x00\x00\x01\x00\x00\x00\x04\
\x00\x00\x00\x52\x00\x02\x00\x00\x00\x01\x00\x00\x00\x05\
\x00\x00\x00\x64\x00\x02\x00\x00\x00\x03\x00\x00\x00\x06\
\x00\x00\x00\x7e\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x00\x9c\x00\x00\x00\x00\x00\x01\x00\x00\x01\x5b\
\x00\x00\x00\xbe\x00\x00\x00\x00\x00\x01\x00\x00\x05\x4f\
\x00\x00\x07\xcc\x00\x02\x00\x00\x00\x03\x00\x00\x00\x0a\
\x00\x00\x07\xee\x00\x01\x00\x00\x00\x01\x00\x00\x5e\x01\
\x00\x00\x07\xd8\x00\x01\x00\x00\x00\x01\x00\x00\x4b\xb9\
\x00\x00\x08\x10\x00\x01\x00\x00\x00\x01\x00\x00\x65\xb1\
\x00\x00\x00\x52\x00\x02\x00\x00\x00\x01\x00\x00\x00\x0e\
\x00\x00\x00\xd8\x00\x02\x00\x00\x00\x27\x00\x00\x00\x0f\
\x00\x00\x04\xc0\x00\x00\x00\x00\x00\x01\x00\x00\x31\x1f\
\x00\x00\x03\xb4\x00\x00\x00\x00\x00\x01\x00\x00\x2a\x91\
\x00\x00\x01\x4e\x00\x00\x00\x00\x00\x01\x00\x00\x17\x16\
\x00\x00\x02\x66\x00\x00\x00\x00\x00\x01\x00\x00\x20\x30\
\x00\x00\x06\x14\x00\x00\x00\x00\x00\x01\x00\x00\x3c\x02\
\x00\x00\x04\x12\x00\x00\x00\x00\x00\x01\x00\x00\x2c\x5d\
\x00\x00\x05\x24\x00\x00\x00\x00\x00\x01\x00\x00\x33\xe6\
\x00\x00\x03\x68\x00\x00\x00\x00\x00\x01\x00\x00\x28\x85\
\x00\x00\x05\x48\x00\x00\x00\x00\x00\x01\x00\x00\x36\x40\
\x00\x00\x00\x9c\x00\x00\x00\x00\x00\x01\x00\x00\x29\x29\
\x00\x00\x06\xba\x00\x00\x00\x00\x00\x01\x00\x00\x41\x75\
\x00\x00\x01\x88\x00\x00\x00\x00\x00\x01\x00\x00\x17\xd0\
\x00\x00\x04\xa2\x00\x00\x00\x00\x00\x01\x00\x00\x30\x9a\
\x00\x00\x04\x7e\x00\x00\x00\x00\x00\x01\x00\x00\x2f\xf0\
\x00\x00\x04\x50\x00\x00\x00\x00\x00\x01\x00\x00\x2f\x59\
\x00\x00\x01\x0e\x00\x00\x00\x00\x00\x01\x00\x00\x14\x18\
\x00\x00\x07\x6e\x00\x00\x00\x00\x00\x01\x00\x00\x49\x28\
\x00\x00\x03\x3e\x00\x00\x00\x00\x00\x01\x00\x00\x27\xeb\
\x00\x00\x02\xee\x00\x00\x00\x00\x00\x01\x00\x00\x25\x51\
\x00\x00\x03\xda\x00\x00\x00\x00\x00\x01\x00\x00\x2b\x79\
\x00\x00\x04\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x31\xff\
\x00\x00\x01\x26\x00\x00\x00\x00\x00\x01\x00\x00\x16\x66\
\x00\x00\x02\xc6\x00\x00\x00\x00\x00\x01\x00\x00\x22\xf7\
\x00\x00\x03\x8c\x00\x00\x00\x00\x00\x01\x00\x00\x29\xd2\
\x00\x00\x01\xa2\x00\x00\x00\x00\x00\x01\x00\x00\x1a\x16\
\x00\x00\x07\x8c\x00\x00\x00\x00\x00\x01\x00\x00\x49\xca\
\x00\x00\x07\x28\x00\x00\x00\x00\x00\x01\x00\x00\x47\x22\
\x00\x00\x01\xfe\x00\x00\x00\x00\x00\x01\x00\x00\x1d\x95\
\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x10\x68\
\x00\x00\x06\x82\x00\x00\x00\x00\x00\x01\x00\x00\x3e\x9d\
\x00\x00\x02\x98\x00\x00\x00\x00\x00\x01\x00\x00\x22\x04\
\x00\x00\x05\xec\x00\x00\x00\x00\x00\x01\x00\x00\x3b\x5e\
\x00\x00\x06\x4e\x00\x00\x00\x00\x00\x01\x00\x00\x3d\xf3\
\x00\x00\x05\xb8\x00\x00\x00\x00\x00\x01\x00\x00\x3a\xb4\
\x00\x00\x02\x42\x00\x00\x00\x00\x00\x01\x00\x00\x1f\x69\
\x00\x00\x05\x7e\x00\x00\x00\x00\x00\x01\x00\x00\x36\xe4\
\x00\x00\x03\x1c\x00\x00\x00\x00\x00\x01\x00\x00\x27\x41\
\x00\x00\x06\xf4\x00\x00\x00\x00\x00\x01\x00\x00\x43\x79\
\x00\x00\x01\xce\x00\x00\x00\x00\x00\x01\x00\x00\x1c\xf2\
"
def qInitResources():
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
def qCleanupResources():
QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
qInitResources()
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
7337,
909,
1233,
199,
3,
199,
3,
18208,
26,
2044,
7349,
14,
663,
7829,
26,
2528,
26,
969,
6900,
199,
3,
420,
701,
26,
710,
7337,
27154,
367,
14084,
334,
4238,
373,
20,
14,
24,
14,
20,
9,
199,
3,
199,
3,
14750,
1,
2900,
4493,
6326,
315,
642,
570,
911,
506,
14669,
1,
199,
199,
504,
14084,
20,
492,
10565,
199,
199,
8440,
63,
1927,
63,
576,
275,
1867,
199,
60,
88,
383,
60,
88,
383,
60,
88,
614,
60,
88,
1641,
60,
199,
60,
88,
1407,
60,
199,
60,
88,
1400,
60,
88,
20,
69,
60,
88,
2417,
60,
88,
16,
68,
60,
88,
16,
65,
60,
88,
17,
65,
60,
88,
16,
65,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
16,
68,
60,
88,
1887,
60,
88,
2006,
60,
88,
1602,
60,
88,
2528,
60,
88,
383,
60,
199,
60,
88,
383,
60,
88,
383,
60,
88,
1643,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
1643,
60,
88,
2036,
60,
88,
1690,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
1845,
16,
60,
88,
3328,
60,
88,
1690,
60,
88,
709,
60,
199,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
1643,
60,
88,
2760,
60,
88,
2006,
60,
88,
1427,
60,
88,
2898,
60,
88,
383,
60,
88,
383,
60,
88,
16,
69,
60,
1812,
20,
60,
88,
383,
60,
88,
383,
60,
88,
16,
69,
60,
1812,
20,
60,
199,
60,
88,
614,
60,
88,
2720,
60,
88,
18,
66,
60,
88,
16,
69,
60,
88,
17,
66,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
1165,
60,
88,
2766,
60,
88,
2006,
60,
88,
2528,
60,
88,
20,
68,
60,
88,
383,
60,
88,
383,
60,
88,
23,
65,
60,
199,
60,
88,
821,
60,
88,
383,
60,
88,
383,
60,
88,
1257,
60,
88,
2658,
60,
88,
383,
60,
88,
383,
60,
1949,
25,
60,
3581,
60,
88,
383,
60,
88,
383,
60,
88,
1257,
60,
1845,
25,
60,
88,
383,
60,
88,
383,
60,
88,
2194,
60,
199,
60,
88,
1216,
60,
88,
383,
60,
88,
383,
60,
10656,
60,
88,
2259,
60,
88,
383,
60,
88,
383,
60,
88,
19,
65,
60,
88,
2905,
60,
88,
383,
60,
88,
383,
60,
88,
1196,
60,
88,
22,
70,
60,
88,
2942,
60,
88,
21,
70,
60,
1812,
21,
60,
199,
60,
88,
2466,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
11110,
60,
88,
1887,
60,
88,
1602,
60,
88,
2953,
60,
88,
1477,
60,
88,
2277,
60,
11078,
60,
88,
21,
67,
60,
88,
24,
69,
60,
1774,
17,
60,
88,
20,
69,
60,
88,
1349,
60,
199,
60,
88,
2167,
60,
88,
1085,
60,
88,
1349,
60,
88,
1822,
60,
9532,
60,
88,
20,
67,
60,
88,
18,
67,
60,
1812,
24,
60,
2207,
25,
60,
88,
18,
67,
60,
88,
16,
68,
60,
88,
2010,
60,
88,
1400,
60,
88,
17,
66,
60,
88,
16,
66,
60,
1812,
19,
60,
199,
60,
10500,
60,
88,
1194,
60,
88,
1138,
60,
9826,
60,
88,
16,
68,
60,
88,
2426,
60,
88,
20,
70,
60,
88,
2167,
60,
88,
16,
66,
60,
9932,
60,
10351,
60,
88,
19,
66,
60,
2207,
16,
60,
88,
2333,
60,
88,
2953,
60,
88,
2819,
60,
199,
60,
1812,
21,
60,
2207,
18,
60,
88,
1651,
60,
88,
20,
70,
60,
88,
996,
60,
10493,
60,
1774,
17,
60,
88,
2576,
60,
88,
2167,
60,
88,
2976,
60,
2207,
20,
60,
1812,
18,
60,
1812,
20,
60,
88,
2789,
60,
88,
18,
67,
60,
10323,
60,
199,
60,
88,
20,
68,
60,
2207,
16,
60,
88,
1887,
60,
8371,
60,
9566,
60,
1949,
24,
60,
88,
708,
60,
3581,
60,
88,
19,
70,
60,
88,
1789,
60,
88,
2006,
60,
1812,
18,
60,
88,
21,
65,
60,
88,
19,
66,
60,
88,
383,
60,
88,
1257,
60,
199,
60,
2207,
22,
60,
10500,
60,
88,
1257,
60,
1774,
19,
60,
10104,
60,
1774,
21,
60,
88,
1644,
60,
88,
1887,
60,
88,
1085,
60,
88,
2766,
60,
88,
16,
69,
60,
88,
21,
66,
60,
88,
2025,
60,
1812,
20,
60,
88,
2710,
60,
1845,
23,
60,
199,
60,
1949,
25,
60,
88,
19,
69,
60,
88,
1887,
60,
88,
2942,
60,
88,
25,
66,
60,
9957,
60,
9532,
60,
9532,
60,
10768,
60,
1774,
18,
60,
88,
23,
67,
60,
1949,
21,
60,
10745,
60,
9566,
60,
88,
966,
60,
1845,
22,
60,
199,
60,
88,
25,
67,
60,
9932,
60,
9826,
60,
88,
1165,
60,
1949,
25,
60,
88,
1167,
60,
10183,
60,
88,
2720,
60,
88,
2528,
60,
10272,
60,
88,
18,
67,
60,
10351,
60,
9957,
60,
1800,
21,
60,
88,
2635,
60,
88,
614,
60,
199,
60,
88,
2835,
60,
1845,
20,
60,
88,
25,
66,
60,
88,
1703,
60,
9566,
60,
88,
19,
67,
60,
88,
18,
65,
60,
1800,
21,
60,
88,
17,
69,
60,
1949,
16,
60,
88,
20,
70,
60,
1845,
19,
60,
88,
1703,
60,
88,
19,
69,
60,
88,
1401,
60,
88,
20,
68,
60,
199,
60,
1949,
19,
60,
88,
1651,
60,
88,
2006,
60,
88,
996,
60,
88,
383,
60,
10539,
60,
10183,
60,
88,
23,
66,
60,
88,
2576,
60,
88,
2528,
60,
11127,
60,
88,
2564,
60,
88,
2976,
60,
88,
1427,
60,
88,
2534,
60,
88,
24,
70,
60,
199,
60,
1800,
18,
60,
88,
1651,
60,
10183,
60,
88,
383,
60,
88,
2259,
60,
88,
1644,
60,
88,
383,
60,
1812,
22,
60,
88,
2905,
60,
1845,
19,
60,
11078,
60,
88,
383,
60,
88,
383,
60,
88,
3172,
60,
88,
17,
67,
60,
9532,
60,
199,
60,
1774,
20,
60,
2207,
22,
60,
88,
20,
70,
60,
88,
383,
60,
1774,
16,
60,
88,
1717,
60,
1949,
16,
60,
88,
1465,
60,
88,
22,
65,
60,
88,
25,
69,
60,
88,
1822,
60,
88,
1602,
60,
88,
2869,
60,
88,
966,
60,
88,
383,
60,
88,
2006,
60,
199,
60,
2207,
19
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
7337,
909,
1233,
199,
3,
199,
3,
18208,
26,
2044,
7349,
14,
663,
7829,
26,
2528,
26,
969,
6900,
199,
3,
420,
701,
26,
710,
7337,
27154,
367,
14084,
334,
4238,
373,
20,
14,
24,
14,
20,
9,
199,
3,
199,
3,
14750,
1,
2900,
4493,
6326,
315,
642,
570,
911,
506,
14669,
1,
199,
199,
504,
14084,
20,
492,
10565,
199,
199,
8440,
63,
1927,
63,
576,
275,
1867,
199,
60,
88,
383,
60,
88,
383,
60,
88,
614,
60,
88,
1641,
60,
199,
60,
88,
1407,
60,
199,
60,
88,
1400,
60,
88,
20,
69,
60,
88,
2417,
60,
88,
16,
68,
60,
88,
16,
65,
60,
88,
17,
65,
60,
88,
16,
65,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
16,
68,
60,
88,
1887,
60,
88,
2006,
60,
88,
1602,
60,
88,
2528,
60,
88,
383,
60,
199,
60,
88,
383,
60,
88,
383,
60,
88,
1643,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
1643,
60,
88,
2036,
60,
88,
1690,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
1845,
16,
60,
88,
3328,
60,
88,
1690,
60,
88,
709,
60,
199,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
1643,
60,
88,
2760,
60,
88,
2006,
60,
88,
1427,
60,
88,
2898,
60,
88,
383,
60,
88,
383,
60,
88,
16,
69,
60,
1812,
20,
60,
88,
383,
60,
88,
383,
60,
88,
16,
69,
60,
1812,
20,
60,
199,
60,
88,
614,
60,
88,
2720,
60,
88,
18,
66,
60,
88,
16,
69,
60,
88,
17,
66,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
88,
1165,
60,
88,
2766,
60,
88,
2006,
60,
88,
2528,
60,
88,
20,
68,
60,
88,
383,
60,
88,
383,
60,
88,
23,
65,
60,
199,
60,
88,
821,
60,
88,
383,
60,
88,
383,
60,
88,
1257,
60,
88,
2658,
60,
88,
383,
60,
88,
383,
60,
1949,
25,
60,
3581,
60,
88,
383,
60,
88,
383,
60,
88,
1257,
60,
1845,
25,
60,
88,
383,
60,
88,
383,
60,
88,
2194,
60,
199,
60,
88,
1216,
60,
88,
383,
60,
88,
383,
60,
10656,
60,
88,
2259,
60,
88,
383,
60,
88,
383,
60,
88,
19,
65,
60,
88,
2905,
60,
88,
383,
60,
88,
383,
60,
88,
1196,
60,
88,
22,
70,
60,
88,
2942,
60,
88,
21,
70,
60,
1812,
21,
60,
199,
60,
88,
2466,
60,
88,
383,
60,
88,
383,
60,
88,
383,
60,
11110,
60,
88,
1887,
60,
88,
1602,
60,
88,
2953,
60,
88,
1477,
60,
88,
2277,
60,
11078,
60,
88,
21,
67,
60,
88,
24,
69,
60,
1774,
17,
60,
88,
20,
69,
60,
88,
1349,
60,
199,
60,
88,
2167,
60,
88,
1085,
60,
88,
1349,
60,
88,
1822,
60,
9532,
60,
88,
20,
67,
60,
88,
18,
67,
60,
1812,
24,
60,
2207,
25,
60,
88,
18,
67,
60,
88,
16,
68,
60,
88,
2010,
60,
88,
1400,
60,
88,
17,
66,
60,
88,
16,
66,
60,
1812,
19,
60,
199,
60,
10500,
60,
88,
1194,
60,
88,
1138,
60,
9826,
60,
88,
16,
68,
60,
88,
2426,
60,
88,
20,
70,
60,
88,
2167,
60,
88,
16,
66,
60,
9932,
60,
10351,
60,
88,
19,
66,
60,
2207,
16,
60,
88,
2333,
60,
88,
2953,
60,
88,
2819,
60,
199,
60,
1812,
21,
60,
2207,
18,
60,
88,
1651,
60,
88,
20,
70,
60,
88,
996,
60,
10493,
60,
1774,
17,
60,
88,
2576,
60,
88,
2167,
60,
88,
2976,
60,
2207,
20,
60,
1812,
18,
60,
1812,
20,
60,
88,
2789,
60,
88,
18,
67,
60,
10323,
60,
199,
60,
88,
20,
68,
60,
2207,
16,
60,
88,
1887,
60,
8371,
60,
9566,
60,
1949,
24,
60,
88,
708,
60,
3581,
60,
88,
19,
70,
60,
88,
1789,
60,
88,
2006,
60,
1812,
18,
60,
88,
21,
65,
60,
88,
19,
66,
60,
88,
383,
60,
88,
1257,
60,
199,
60,
2207,
22,
60,
10500,
60,
88,
1257,
60,
1774,
19,
60,
10104,
60,
1774,
21,
60,
88,
1644,
60,
88,
1887,
60,
88,
1085,
60,
88,
2766,
60,
88,
16,
69,
60,
88,
21,
66,
60,
88,
2025,
60,
1812,
20,
60,
88,
2710,
60,
1845,
23,
60,
199,
60,
1949,
25,
60,
88,
19,
69,
60,
88,
1887,
60,
88,
2942,
60,
88,
25,
66,
60,
9957,
60,
9532,
60,
9532,
60,
10768,
60,
1774,
18,
60,
88,
23,
67,
60,
1949,
21,
60,
10745,
60,
9566,
60,
88,
966,
60,
1845,
22,
60,
199,
60,
88,
25,
67,
60,
9932,
60,
9826,
60,
88,
1165,
60,
1949,
25,
60,
88,
1167,
60,
10183,
60,
88,
2720,
60,
88,
2528,
60,
10272,
60,
88,
18,
67,
60,
10351,
60,
9957,
60,
1800,
21,
60,
88,
2635,
60,
88,
614,
60,
199,
60,
88,
2835,
60,
1845,
20,
60,
88,
25,
66,
60,
88,
1703,
60,
9566,
60,
88,
19,
67,
60,
88,
18,
65,
60,
1800,
21,
60,
88,
17,
69,
60,
1949,
16,
60,
88,
20,
70,
60,
1845,
19,
60,
88,
1703,
60,
88,
19,
69,
60,
88,
1401,
60,
88,
20,
68,
60,
199,
60,
1949,
19,
60,
88,
1651,
60,
88,
2006,
60,
88,
996,
60,
88,
383,
60,
10539,
60,
10183,
60,
88,
23,
66,
60,
88,
2576,
60,
88,
2528,
60,
11127,
60,
88,
2564,
60,
88,
2976,
60,
88,
1427,
60,
88,
2534,
60,
88,
24,
70,
60,
199,
60,
1800,
18,
60,
88,
1651,
60,
10183,
60,
88,
383,
60,
88,
2259,
60,
88,
1644,
60,
88,
383,
60,
1812,
22,
60,
88,
2905,
60,
1845,
19,
60,
11078,
60,
88,
383,
60,
88,
383,
60,
88,
3172,
60,
88,
17,
67,
60,
9532,
60,
199,
60,
1774,
20,
60,
2207,
22,
60,
88,
20,
70,
60,
88,
383,
60,
1774,
16,
60,
88,
1717,
60,
1949,
16,
60,
88,
1465,
60,
88,
22,
65,
60,
88,
25,
69,
60,
88,
1822,
60,
88,
1602,
60,
88,
2869,
60,
88,
966,
60,
88,
383,
60,
88,
2006,
60,
199,
60,
2207,
19,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ewmoore/numpy
|
numpy/_import_tools.py
|
13
|
12896
|
import os
import sys
__all__ = ['PackageLoader']
class PackageLoader(object):
def __init__(self, verbose=False, infunc=False):
""" Manages loading packages.
"""
if infunc:
_level = 2
else:
_level = 1
self.parent_frame = frame = sys._getframe(_level)
self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)
parent_path = eval('__path__',frame.f_globals,frame.f_locals)
if isinstance(parent_path, str):
parent_path = [parent_path]
self.parent_path = parent_path
if '__all__' not in frame.f_locals:
exec('__all__ = []',frame.f_globals,frame.f_locals)
self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)
self.info_modules = {}
self.imported_packages = []
self.verbose = None
def _get_info_files(self, package_dir, parent_path, parent_package=None):
""" Return list of (package name,info.py file) from parent_path subdirectories.
"""
from glob import glob
files = glob(os.path.join(parent_path,package_dir,'info.py'))
for info_file in glob(os.path.join(parent_path,package_dir,'info.pyc')):
if info_file[:-1] not in files:
files.append(info_file)
info_files = []
for info_file in files:
package_name = os.path.dirname(info_file[len(parent_path)+1:])\
.replace(os.sep,'.')
if parent_package:
package_name = parent_package + '.' + package_name
info_files.append((package_name,info_file))
info_files.extend(self._get_info_files('*',
os.path.dirname(info_file),
package_name))
return info_files
def _init_info_modules(self, packages=None):
"""Initialize info_modules = {<package_name>: <package info.py module>}.
"""
import imp
info_files = []
info_modules = self.info_modules
if packages is None:
for path in self.parent_path:
info_files.extend(self._get_info_files('*',path))
else:
for package_name in packages:
package_dir = os.path.join(*package_name.split('.'))
for path in self.parent_path:
names_files = self._get_info_files(package_dir, path)
if names_files:
info_files.extend(names_files)
break
else:
try:
exec 'import %s.info as info' % (package_name)
info_modules[package_name] = info
except ImportError, msg:
self.warn('No scipy-style subpackage %r found in %s. '\
'Ignoring: %s'\
% (package_name,':'.join(self.parent_path), msg))
for package_name,info_file in info_files:
if package_name in info_modules:
continue
fullname = self.parent_name +'.'+ package_name
if info_file[-1]=='c':
filedescriptor = ('.pyc','rb',2)
else:
filedescriptor = ('.py','U',1)
try:
info_module = imp.load_module(fullname+'.info',
open(info_file,filedescriptor[1]),
info_file,
filedescriptor)
except Exception,msg:
self.error(msg)
info_module = None
if info_module is None or getattr(info_module,'ignore',False):
info_modules.pop(package_name,None)
else:
self._init_info_modules(getattr(info_module,'depends',[]))
info_modules[package_name] = info_module
return
def _get_sorted_names(self):
""" Return package names sorted in the order as they should be
imported due to dependence relations between packages.
"""
depend_dict = {}
for name,info_module in self.info_modules.items():
depend_dict[name] = getattr(info_module,'depends',[])
package_names = []
for name in depend_dict.keys():
if not depend_dict[name]:
package_names.append(name)
del depend_dict[name]
while depend_dict:
for name, lst in depend_dict.items():
new_lst = [n for n in lst if n in depend_dict]
if not new_lst:
package_names.append(name)
del depend_dict[name]
else:
depend_dict[name] = new_lst
return package_names
def __call__(self,*packages, **options):
"""Load one or more packages into parent package top-level namespace.
This function is intended to shorten the need to import many
subpackages, say of scipy, constantly with statements such as
import scipy.linalg, scipy.fftpack, scipy.etc...
Instead, you can say:
import scipy
scipy.pkgload('linalg','fftpack',...)
or
scipy.pkgload()
to load all of them in one call.
If a name which doesn't exist in scipy's namespace is
given, a warning is shown.
Parameters
----------
*packages : arg-tuple
the names (one or more strings) of all the modules one
wishes to load into the top-level namespace.
verbose= : integer
verbosity level [default: -1].
verbose=-1 will suspend also warnings.
force= : bool
when True, force reloading loaded packages [default: False].
postpone= : bool
when True, don't load packages [default: False]
"""
frame = self.parent_frame
self.info_modules = {}
if options.get('force',False):
self.imported_packages = []
self.verbose = verbose = options.get('verbose',-1)
postpone = options.get('postpone',None)
self._init_info_modules(packages or None)
self.log('Imports to %r namespace\n----------------------------'\
% self.parent_name)
for package_name in self._get_sorted_names():
if package_name in self.imported_packages:
continue
info_module = self.info_modules[package_name]
global_symbols = getattr(info_module,'global_symbols',[])
postpone_import = getattr(info_module,'postpone_import',False)
if (postpone and not global_symbols) \
or (postpone_import and postpone is not None):
continue
old_object = frame.f_locals.get(package_name,None)
cmdstr = 'import '+package_name
if self._execcmd(cmdstr):
continue
self.imported_packages.append(package_name)
if verbose!=-1:
new_object = frame.f_locals.get(package_name)
if old_object is not None and old_object is not new_object:
self.warn('Overwriting %s=%s (was %s)' \
% (package_name,self._obj2repr(new_object),
self._obj2repr(old_object)))
if '.' not in package_name:
self.parent_export_names.append(package_name)
for symbol in global_symbols:
if symbol=='*':
symbols = eval('getattr(%s,"__all__",None)'\
% (package_name),
frame.f_globals,frame.f_locals)
if symbols is None:
symbols = eval('dir(%s)' % (package_name),
frame.f_globals,frame.f_locals)
symbols = filter(lambda s:not s.startswith('_'),symbols)
else:
symbols = [symbol]
if verbose!=-1:
old_objects = {}
for s in symbols:
if s in frame.f_locals:
old_objects[s] = frame.f_locals[s]
cmdstr = 'from '+package_name+' import '+symbol
if self._execcmd(cmdstr):
continue
if verbose!=-1:
for s,old_object in old_objects.items():
new_object = frame.f_locals[s]
if new_object is not old_object:
self.warn('Overwriting %s=%s (was %s)' \
% (s,self._obj2repr(new_object),
self._obj2repr(old_object)))
if symbol=='*':
self.parent_export_names.extend(symbols)
else:
self.parent_export_names.append(symbol)
return
def _execcmd(self,cmdstr):
""" Execute command in parent_frame."""
frame = self.parent_frame
try:
exec (cmdstr, frame.f_globals,frame.f_locals)
except Exception,msg:
self.error('%s -> failed: %s' % (cmdstr,msg))
return True
else:
self.log('%s -> success' % (cmdstr))
return
def _obj2repr(self,obj):
""" Return repr(obj) with"""
module = getattr(obj,'__module__',None)
file = getattr(obj,'__file__',None)
if module is not None:
return repr(obj) + ' from ' + module
if file is not None:
return repr(obj) + ' from ' + file
return repr(obj)
def log(self,mess):
if self.verbose>1:
print >> sys.stderr, str(mess)
def warn(self,mess):
if self.verbose>=0:
print >> sys.stderr, str(mess)
def error(self,mess):
if self.verbose!=-1:
print >> sys.stderr, str(mess)
def _get_doc_title(self, info_module):
""" Get the title from a package info.py file.
"""
title = getattr(info_module,'__doc_title__',None)
if title is not None:
return title
title = getattr(info_module,'__doc__',None)
if title is not None:
title = title.lstrip().split('\n',1)[0]
return title
return '* Not Available *'
def _format_titles(self,titles,colsep='---'):
display_window_width = 70 # How to determine the correct value in runtime??
lengths = [len(name)-name.find('.')-1 for (name,title) in titles]+[0]
max_length = max(lengths)
lines = []
for (name,title) in titles:
name = name[name.find('.')+1:]
w = max_length - len(name)
words = title.split()
line = '%s%s %s' % (name,w*' ',colsep)
tab = len(line) * ' '
while words:
word = words.pop(0)
if len(line)+len(word)>display_window_width:
lines.append(line)
line = tab
line += ' ' + word
else:
lines.append(line)
return '\n'.join(lines)
def get_pkgdocs(self):
""" Return documentation summary of subpackages.
"""
import sys
self.info_modules = {}
self._init_info_modules(None)
titles = []
symbols = []
for package_name, info_module in self.info_modules.items():
global_symbols = getattr(info_module,'global_symbols',[])
fullname = self.parent_name +'.'+ package_name
note = ''
if fullname not in sys.modules:
note = ' [*]'
titles.append((fullname,self._get_doc_title(info_module) + note))
if global_symbols:
symbols.append((package_name,', '.join(global_symbols)))
retstr = self._format_titles(titles) +\
'\n [*] - using a package requires explicit import (see pkgload)'
if symbols:
retstr += """\n\nGlobal symbols from subpackages"""\
"""\n-------------------------------\n""" +\
self._format_titles(symbols,'-->')
return retstr
class PackageLoaderDebug(PackageLoader):
def _execcmd(self,cmdstr):
""" Execute command in parent_frame."""
frame = self.parent_frame
print 'Executing',`cmdstr`,'...',
sys.stdout.flush()
exec (cmdstr, frame.f_globals,frame.f_locals)
print 'ok'
sys.stdout.flush()
return
if int(os.environ.get('NUMPY_IMPORT_DEBUG','0')):
PackageLoader = PackageLoaderDebug
|
bsd-3-clause
|
[
646,
747,
199,
646,
984,
199,
199,
363,
452,
363,
275,
788,
8599,
5455,
418,
199,
199,
533,
15665,
5455,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
3376,
29,
797,
12,
315,
1532,
29,
797,
304,
267,
408,
21612,
8697,
6117,
14,
267,
408,
398,
340,
315,
1532,
26,
288,
485,
1896,
275,
499,
267,
587,
26,
288,
485,
1896,
275,
413,
267,
291,
14,
1708,
63,
1943,
275,
2787,
275,
984,
423,
20912,
1547,
1896,
9,
267,
291,
14,
1708,
63,
354,
275,
3468,
10714,
354,
7500,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
267,
1676,
63,
515,
275,
3468,
10714,
515,
7500,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
267,
340,
1228,
8,
1708,
63,
515,
12,
620,
304,
288,
1676,
63,
515,
275,
359,
1708,
63,
515,
61,
267,
291,
14,
1708,
63,
515,
275,
1676,
63,
515,
267,
340,
2560,
452,
12217,
440,
315,
2787,
14,
70,
63,
9350,
26,
288,
2146,
10714,
452,
363,
275,
942,
297,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
267,
291,
14,
1708,
63,
3790,
63,
1247,
275,
3468,
10714,
452,
7500,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
398,
291,
14,
815,
63,
3112,
275,
1052,
267,
291,
14,
17932,
63,
5154,
275,
942,
267,
291,
14,
3832,
275,
488,
339,
347,
485,
362,
63,
815,
63,
1725,
8,
277,
12,
2559,
63,
694,
12,
1676,
63,
515,
12,
1676,
63,
2491,
29,
403,
304,
267,
408,
1432,
769,
402,
334,
2491,
536,
12,
815,
14,
647,
570,
9,
687,
1676,
63,
515,
24799,
14,
267,
408,
267,
687,
5739,
492,
5739,
267,
1584,
275,
5739,
8,
736,
14,
515,
14,
904,
8,
1708,
63,
515,
12,
2491,
63,
694,
2584,
815,
14,
647,
1333,
267,
367,
2256,
63,
493,
315,
5739,
8,
736,
14,
515,
14,
904,
8,
1708,
63,
515,
12,
2491,
63,
694,
2584,
815,
14,
11357,
8109,
288,
340,
2256,
63,
493,
4439,
17,
61,
440,
315,
1584,
26,
355,
1584,
14,
740,
8,
815,
63,
493,
9,
267,
2256,
63,
1725,
275,
942,
267,
367,
2256,
63,
493,
315,
1584,
26,
288,
2559,
63,
354,
275,
747,
14,
515,
14,
3475,
8,
815,
63,
493,
59,
552,
8,
1708,
63,
515,
6393,
17,
5728,
60,
2574,
1275,
1814,
8,
736,
14,
4127,
12,
1370,
358,
288,
340,
1676,
63,
2491,
26,
355,
2559,
63,
354,
275,
1676,
63,
2491,
435,
7815,
435,
2559,
63,
354,
288,
2256,
63,
1725,
14,
740,
1332,
2491,
63,
354,
12,
815,
63,
493,
430,
288,
2256,
63,
1725,
14,
2880,
8,
277,
423,
362,
63,
815,
63,
1725,
23877,
8962,
747,
14,
515,
14,
3475,
8,
815,
63,
493,
395,
8962,
2559,
63,
354,
430,
267,
372,
2256,
63,
1725,
339,
347,
485,
826,
63,
815,
63,
3112,
8,
277,
12,
6117,
29,
403,
304,
267,
408,
9345,
2256,
63,
3112,
275,
469,
28,
2491,
63,
354,
20020,
665,
2491,
2256,
14,
647,
859,
30,
5565,
267,
408,
267,
492,
1742,
267,
2256,
63,
1725,
275,
942,
267,
2256,
63,
3112,
275,
291,
14,
815,
63,
3112,
398,
340,
6117,
365,
488,
26,
288,
367,
931,
315,
291,
14,
1708,
63,
515,
26,
355,
2256,
63,
1725,
14,
2880,
8,
277,
423,
362,
63,
815,
63,
1725,
23877,
515,
430,
267,
587,
26,
288,
367,
2559,
63,
354,
315,
6117,
26,
355,
2559,
63,
694,
275,
747,
14,
515,
14,
904,
2031,
2491,
63,
354,
14,
1294,
24535,
355,
367,
931,
315,
291,
14,
1708,
63,
515,
26,
490,
1561,
63,
1725,
275,
291,
423,
362,
63,
815,
63,
1725,
8,
2491,
63,
694,
12,
931,
9,
490,
340,
1561,
63,
1725,
26,
717,
2256,
63,
1725,
14,
2880,
8,
1247,
63,
1725,
9,
717,
2059,
355,
587,
26,
490,
862,
26,
717,
2146,
283,
646,
450,
83,
14,
815,
465,
2256,
7,
450,
334,
2491,
63,
354,
9,
717,
2256,
63,
3112,
59,
2491,
63,
354,
61,
275,
2256,
490,
871,
3545,
12,
1499,
26,
717,
291,
14,
4050,
360,
1944,
7026,
13,
2487,
1007,
2491,
450,
82,
1911,
315,
450,
83,
14,
1557,
3303,
283,
32390,
26,
450,
83,
1154,
3303,
450,
334,
2491,
63,
354,
12,
356,
1370,
904,
8,
277,
14,
1708,
63,
515,
395,
1499,
430,
398,
367,
2559,
63,
354,
12,
815,
63,
493,
315,
2256,
63,
1725,
26,
288,
340,
2559,
63,
354,
315,
2256,
63,
3112,
26,
355,
1980,
288,
11064,
275,
291,
14,
1708,
63,
354,
435,
1370,
6828,
2559,
63,
354,
288,
340,
2256,
63,
493,
1988,
17,
22954,
67,
356,
355,
570,
4120,
275,
23500,
11357,
1673,
4848,
297,
18,
9,
288,
587,
26,
355,
570,
4120,
275,
23500,
647,
1673,
53,
297,
17,
9,
953,
862,
26,
355,
2256,
63,
578,
275,
1742,
14,
912,
63,
578,
8,
9930,
18098,
815,
297,
6343,
1551,
8,
815,
63,
493,
12,
493,
4120,
59,
17,
2522,
6343,
2256,
63,
493,
12,
6343,
570,
4120,
9,
288,
871,
2186,
12,
1328,
26,
355,
291,
14,
705,
8,
1328,
9,
355,
2256,
63,
578,
275,
488,
953,
340,
2256,
63,
578,
365,
488,
503,
2519,
8,
815,
63,
578,
2584,
4247,
297,
797,
304,
355,
2256,
63,
3112,
14,
1935,
8,
2491,
63,
354,
12,
403,
9,
288,
587,
26,
355,
291,
423,
826,
63,
815,
63,
3112,
8,
5675,
8,
815,
63,
578,
2584,
8912,
23993,
2459,
355,
2256,
63,
3112,
59,
2491,
63,
354,
61,
275,
2256,
63,
578,
398,
372,
339,
347,
485,
362,
63,
5917,
63,
1247,
8,
277,
304,
267,
408,
1432,
2559,
1561,
3355,
315,
314,
1865,
465,
2985,
1077,
506,
267,
8439,
7037,
370,
477,
29578,
16109,
3382,
6117,
14,
267,
408,
398,
11687,
63,
807,
275,
1052,
267,
367,
536,
12,
815,
63,
578,
315,
291,
14,
815,
63,
3112,
14,
1744,
837,
288,
11687,
63,
807,
59,
354,
61,
275,
2519,
8,
815,
63,
578,
2584,
8912,
23993,
566,
267,
2559,
63,
1247,
275,
942,
398,
367,
536,
315,
11687,
63,
807,
14,
1612,
837,
288,
340,
440,
11687,
63,
807,
59
] |
[
747,
199,
646,
984,
199,
199,
363,
452,
363,
275,
788,
8599,
5455,
418,
199,
199,
533,
15665,
5455,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
3376,
29,
797,
12,
315,
1532,
29,
797,
304,
267,
408,
21612,
8697,
6117,
14,
267,
408,
398,
340,
315,
1532,
26,
288,
485,
1896,
275,
499,
267,
587,
26,
288,
485,
1896,
275,
413,
267,
291,
14,
1708,
63,
1943,
275,
2787,
275,
984,
423,
20912,
1547,
1896,
9,
267,
291,
14,
1708,
63,
354,
275,
3468,
10714,
354,
7500,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
267,
1676,
63,
515,
275,
3468,
10714,
515,
7500,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
267,
340,
1228,
8,
1708,
63,
515,
12,
620,
304,
288,
1676,
63,
515,
275,
359,
1708,
63,
515,
61,
267,
291,
14,
1708,
63,
515,
275,
1676,
63,
515,
267,
340,
2560,
452,
12217,
440,
315,
2787,
14,
70,
63,
9350,
26,
288,
2146,
10714,
452,
363,
275,
942,
297,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
267,
291,
14,
1708,
63,
3790,
63,
1247,
275,
3468,
10714,
452,
7500,
1943,
14,
70,
63,
8473,
12,
1943,
14,
70,
63,
9350,
9,
398,
291,
14,
815,
63,
3112,
275,
1052,
267,
291,
14,
17932,
63,
5154,
275,
942,
267,
291,
14,
3832,
275,
488,
339,
347,
485,
362,
63,
815,
63,
1725,
8,
277,
12,
2559,
63,
694,
12,
1676,
63,
515,
12,
1676,
63,
2491,
29,
403,
304,
267,
408,
1432,
769,
402,
334,
2491,
536,
12,
815,
14,
647,
570,
9,
687,
1676,
63,
515,
24799,
14,
267,
408,
267,
687,
5739,
492,
5739,
267,
1584,
275,
5739,
8,
736,
14,
515,
14,
904,
8,
1708,
63,
515,
12,
2491,
63,
694,
2584,
815,
14,
647,
1333,
267,
367,
2256,
63,
493,
315,
5739,
8,
736,
14,
515,
14,
904,
8,
1708,
63,
515,
12,
2491,
63,
694,
2584,
815,
14,
11357,
8109,
288,
340,
2256,
63,
493,
4439,
17,
61,
440,
315,
1584,
26,
355,
1584,
14,
740,
8,
815,
63,
493,
9,
267,
2256,
63,
1725,
275,
942,
267,
367,
2256,
63,
493,
315,
1584,
26,
288,
2559,
63,
354,
275,
747,
14,
515,
14,
3475,
8,
815,
63,
493,
59,
552,
8,
1708,
63,
515,
6393,
17,
5728,
60,
2574,
1275,
1814,
8,
736,
14,
4127,
12,
1370,
358,
288,
340,
1676,
63,
2491,
26,
355,
2559,
63,
354,
275,
1676,
63,
2491,
435,
7815,
435,
2559,
63,
354,
288,
2256,
63,
1725,
14,
740,
1332,
2491,
63,
354,
12,
815,
63,
493,
430,
288,
2256,
63,
1725,
14,
2880,
8,
277,
423,
362,
63,
815,
63,
1725,
23877,
8962,
747,
14,
515,
14,
3475,
8,
815,
63,
493,
395,
8962,
2559,
63,
354,
430,
267,
372,
2256,
63,
1725,
339,
347,
485,
826,
63,
815,
63,
3112,
8,
277,
12,
6117,
29,
403,
304,
267,
408,
9345,
2256,
63,
3112,
275,
469,
28,
2491,
63,
354,
20020,
665,
2491,
2256,
14,
647,
859,
30,
5565,
267,
408,
267,
492,
1742,
267,
2256,
63,
1725,
275,
942,
267,
2256,
63,
3112,
275,
291,
14,
815,
63,
3112,
398,
340,
6117,
365,
488,
26,
288,
367,
931,
315,
291,
14,
1708,
63,
515,
26,
355,
2256,
63,
1725,
14,
2880,
8,
277,
423,
362,
63,
815,
63,
1725,
23877,
515,
430,
267,
587,
26,
288,
367,
2559,
63,
354,
315,
6117,
26,
355,
2559,
63,
694,
275,
747,
14,
515,
14,
904,
2031,
2491,
63,
354,
14,
1294,
24535,
355,
367,
931,
315,
291,
14,
1708,
63,
515,
26,
490,
1561,
63,
1725,
275,
291,
423,
362,
63,
815,
63,
1725,
8,
2491,
63,
694,
12,
931,
9,
490,
340,
1561,
63,
1725,
26,
717,
2256,
63,
1725,
14,
2880,
8,
1247,
63,
1725,
9,
717,
2059,
355,
587,
26,
490,
862,
26,
717,
2146,
283,
646,
450,
83,
14,
815,
465,
2256,
7,
450,
334,
2491,
63,
354,
9,
717,
2256,
63,
3112,
59,
2491,
63,
354,
61,
275,
2256,
490,
871,
3545,
12,
1499,
26,
717,
291,
14,
4050,
360,
1944,
7026,
13,
2487,
1007,
2491,
450,
82,
1911,
315,
450,
83,
14,
1557,
3303,
283,
32390,
26,
450,
83,
1154,
3303,
450,
334,
2491,
63,
354,
12,
356,
1370,
904,
8,
277,
14,
1708,
63,
515,
395,
1499,
430,
398,
367,
2559,
63,
354,
12,
815,
63,
493,
315,
2256,
63,
1725,
26,
288,
340,
2559,
63,
354,
315,
2256,
63,
3112,
26,
355,
1980,
288,
11064,
275,
291,
14,
1708,
63,
354,
435,
1370,
6828,
2559,
63,
354,
288,
340,
2256,
63,
493,
1988,
17,
22954,
67,
356,
355,
570,
4120,
275,
23500,
11357,
1673,
4848,
297,
18,
9,
288,
587,
26,
355,
570,
4120,
275,
23500,
647,
1673,
53,
297,
17,
9,
953,
862,
26,
355,
2256,
63,
578,
275,
1742,
14,
912,
63,
578,
8,
9930,
18098,
815,
297,
6343,
1551,
8,
815,
63,
493,
12,
493,
4120,
59,
17,
2522,
6343,
2256,
63,
493,
12,
6343,
570,
4120,
9,
288,
871,
2186,
12,
1328,
26,
355,
291,
14,
705,
8,
1328,
9,
355,
2256,
63,
578,
275,
488,
953,
340,
2256,
63,
578,
365,
488,
503,
2519,
8,
815,
63,
578,
2584,
4247,
297,
797,
304,
355,
2256,
63,
3112,
14,
1935,
8,
2491,
63,
354,
12,
403,
9,
288,
587,
26,
355,
291,
423,
826,
63,
815,
63,
3112,
8,
5675,
8,
815,
63,
578,
2584,
8912,
23993,
2459,
355,
2256,
63,
3112,
59,
2491,
63,
354,
61,
275,
2256,
63,
578,
398,
372,
339,
347,
485,
362,
63,
5917,
63,
1247,
8,
277,
304,
267,
408,
1432,
2559,
1561,
3355,
315,
314,
1865,
465,
2985,
1077,
506,
267,
8439,
7037,
370,
477,
29578,
16109,
3382,
6117,
14,
267,
408,
398,
11687,
63,
807,
275,
1052,
267,
367,
536,
12,
815,
63,
578,
315,
291,
14,
815,
63,
3112,
14,
1744,
837,
288,
11687,
63,
807,
59,
354,
61,
275,
2519,
8,
815,
63,
578,
2584,
8912,
23993,
566,
267,
2559,
63,
1247,
275,
942,
398,
367,
536,
315,
11687,
63,
807,
14,
1612,
837,
288,
340,
440,
11687,
63,
807,
59,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
hgl888/chromium-crosswalk
|
build/android/pylib/base/base_test_result.py
|
40
|
6134
|
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Module containing base test results classes."""
class ResultType(object):
"""Class enumerating test types."""
PASS = 'PASS'
SKIP = 'SKIP'
FAIL = 'FAIL'
CRASH = 'CRASH'
TIMEOUT = 'TIMEOUT'
UNKNOWN = 'UNKNOWN'
@staticmethod
def GetTypes():
"""Get a list of all test types."""
return [ResultType.PASS, ResultType.SKIP, ResultType.FAIL,
ResultType.CRASH, ResultType.TIMEOUT, ResultType.UNKNOWN]
class BaseTestResult(object):
"""Base class for a single test result."""
def __init__(self, name, test_type, duration=0, log=''):
"""Construct a BaseTestResult.
Args:
name: Name of the test which defines uniqueness.
test_type: Type of the test result as defined in ResultType.
duration: Time it took for the test to run in milliseconds.
log: An optional string listing any errors.
"""
assert name
assert test_type in ResultType.GetTypes()
self._name = name
self._test_type = test_type
self._duration = duration
self._log = log
def __str__(self):
return self._name
def __repr__(self):
return self._name
def __cmp__(self, other):
# pylint: disable=W0212
return cmp(self._name, other._name)
def __hash__(self):
return hash(self._name)
def SetName(self, name):
"""Set the test name.
Because we're putting this into a set, this should only be used if moving
this test result into another set.
"""
self._name = name
def GetName(self):
"""Get the test name."""
return self._name
def SetType(self, test_type):
"""Set the test result type."""
assert test_type in ResultType.GetTypes()
self._test_type = test_type
def GetType(self):
"""Get the test result type."""
return self._test_type
def GetDuration(self):
"""Get the test duration."""
return self._duration
def SetLog(self, log):
"""Set the test log."""
self._log = log
def GetLog(self):
"""Get the test log."""
return self._log
class TestRunResults(object):
"""Set of results for a test run."""
def __init__(self):
self._results = set()
def GetLogs(self):
"""Get the string representation of all test logs."""
s = []
for test_type in ResultType.GetTypes():
if test_type != ResultType.PASS:
for t in sorted(self._GetType(test_type)):
log = t.GetLog()
if log:
s.append('[%s] %s:' % (test_type, t))
s.append(log)
return '\n'.join(s)
def GetGtestForm(self):
"""Get the gtest string representation of this object."""
s = []
plural = lambda n, s, p: '%d %s' % (n, p if n != 1 else s)
tests = lambda n: plural(n, 'test', 'tests')
s.append('[==========] %s ran.' % (tests(len(self.GetAll()))))
s.append('[ PASSED ] %s.' % (tests(len(self.GetPass()))))
skipped = self.GetSkip()
if skipped:
s.append('[ SKIPPED ] Skipped %s, listed below:' % tests(len(skipped)))
for t in sorted(skipped):
s.append('[ SKIPPED ] %s' % str(t))
all_failures = self.GetFail().union(self.GetCrash(), self.GetTimeout(),
self.GetUnknown())
if all_failures:
s.append('[ FAILED ] %s, listed below:' % tests(len(all_failures)))
for t in sorted(self.GetFail()):
s.append('[ FAILED ] %s' % str(t))
for t in sorted(self.GetCrash()):
s.append('[ FAILED ] %s (CRASHED)' % str(t))
for t in sorted(self.GetTimeout()):
s.append('[ FAILED ] %s (TIMEOUT)' % str(t))
for t in sorted(self.GetUnknown()):
s.append('[ FAILED ] %s (UNKNOWN)' % str(t))
s.append('')
s.append(plural(len(all_failures), 'FAILED TEST', 'FAILED TESTS'))
return '\n'.join(s)
def GetShortForm(self):
"""Get the short string representation of this object."""
s = []
s.append('ALL: %d' % len(self._results))
for test_type in ResultType.GetTypes():
s.append('%s: %d' % (test_type, len(self._GetType(test_type))))
return ''.join([x.ljust(15) for x in s])
def __str__(self):
return self.GetLongForm()
def AddResult(self, result):
"""Add |result| to the set.
Args:
result: An instance of BaseTestResult.
"""
assert isinstance(result, BaseTestResult)
self._results.add(result)
def AddResults(self, results):
"""Add |results| to the set.
Args:
results: An iterable of BaseTestResult objects.
"""
for t in results:
self.AddResult(t)
def AddTestRunResults(self, results):
"""Add the set of test results from |results|.
Args:
results: An instance of TestRunResults.
"""
assert isinstance(results, TestRunResults)
# pylint: disable=W0212
self._results.update(results._results)
def GetAll(self):
"""Get the set of all test results."""
return self._results.copy()
def _GetType(self, test_type):
"""Get the set of test results with the given test type."""
return set(t for t in self._results if t.GetType() == test_type)
def GetPass(self):
"""Get the set of all passed test results."""
return self._GetType(ResultType.PASS)
def GetSkip(self):
"""Get the set of all skipped test results."""
return self._GetType(ResultType.SKIP)
def GetFail(self):
"""Get the set of all failed test results."""
return self._GetType(ResultType.FAIL)
def GetCrash(self):
"""Get the set of all crashed test results."""
return self._GetType(ResultType.CRASH)
def GetTimeout(self):
"""Get the set of all timed out test results."""
return self._GetType(ResultType.TIMEOUT)
def GetUnknown(self):
"""Get the set of all unknown test results."""
return self._GetType(ResultType.UNKNOWN)
def GetNotPass(self):
"""Get the set of all non-passed test results."""
return self.GetAll() - self.GetPass()
def DidRunPass(self):
"""Return whether the test run was successful."""
return not self.GetNotPass() - self.GetSkip()
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
2377,
3035,
1300,
511,
2058,
3992,
1041,
199,
199,
533,
10695,
804,
8,
785,
304,
523,
408,
2543,
3720,
10417,
511,
2943,
1041,
523,
21705,
275,
283,
6909,
7,
523,
27885,
275,
283,
13525,
7,
523,
10341,
275,
283,
8784,
7,
523,
17101,
8100,
275,
283,
2944,
8100,
7,
523,
29998,
275,
283,
8899,
7,
523,
24740,
275,
283,
11588,
7,
819,
768,
4639,
523,
347,
2372,
4100,
837,
272,
408,
1002,
282,
769,
402,
1006,
511,
2943,
1041,
272,
372,
359,
2889,
804,
14,
6909,
12,
10695,
804,
14,
13525,
12,
10695,
804,
14,
8784,
12,
288,
10695,
804,
14,
2944,
8100,
12,
10695,
804,
14,
8899,
12,
10695,
804,
14,
11588,
61,
421,
199,
533,
3523,
13120,
8,
785,
304,
523,
408,
1563,
1021,
367,
282,
2849,
511,
754,
1041,
819,
347,
636,
826,
721,
277,
12,
536,
12,
511,
63,
466,
12,
7373,
29,
16,
12,
943,
9280,
272,
408,
11493,
282,
3523,
13120,
14,
339,
3033,
26,
489,
536,
26,
2812,
402,
314,
511,
1314,
7890,
15439,
31820,
14,
489,
511,
63,
466,
26,
2434,
402,
314,
511,
754,
465,
3247,
315,
10695,
804,
14,
489,
7373,
26,
4703,
652,
27221,
367,
314,
511,
370,
1255,
315,
21131,
14,
489,
943,
26,
1626,
2716,
1059,
13778,
1263,
2552,
14,
272,
408,
272,
702,
536,
272,
702,
511,
63,
466,
315,
10695,
804,
14,
1002,
4100,
342,
272,
291,
423,
354,
275,
536,
272,
291,
423,
396,
63,
466,
275,
511,
63,
466,
272,
291,
423,
5553,
275,
7373,
272,
291,
423,
793,
275,
943,
819,
347,
636,
495,
721,
277,
304,
272,
372,
291,
423,
354,
819,
347,
636,
2722,
721,
277,
304,
272,
372,
291,
423,
354,
819,
347,
636,
5730,
721,
277,
12,
1163,
304,
272,
327,
4287,
26,
3507,
29,
55,
996,
713,
272,
372,
10467,
8,
277,
423,
354,
12,
1163,
423,
354,
9,
819,
347,
636,
2227,
721,
277,
304,
272,
372,
2631,
8,
277,
423,
354,
9,
819,
347,
2494,
985,
8,
277,
12,
536,
304,
272,
408,
1084,
314,
511,
536,
14,
339,
13821,
781,
3984,
32670,
642,
1901,
282,
663,
12,
642,
1077,
1454,
506,
1202,
340,
12876,
272,
642,
511,
754,
1901,
4573,
663,
14,
272,
408,
272,
291,
423,
354,
275,
536,
819,
347,
2372,
985,
8,
277,
304,
272,
408,
1002,
314,
511,
536,
1041,
272,
372,
291,
423,
354,
819,
347,
2494,
804,
8,
277,
12,
511,
63,
466,
304,
272,
408,
1084,
314,
511,
754,
730,
1041,
272,
702,
511,
63,
466,
315,
10695,
804,
14,
1002,
4100,
342,
272,
291,
423,
396,
63,
466,
275,
511,
63,
466,
819,
347,
2372,
804,
8,
277,
304,
272,
408,
1002,
314,
511,
754,
730,
1041,
272,
372,
291,
423,
396,
63,
466,
819,
347,
2372,
13283,
8,
277,
304,
272,
408,
1002,
314,
511,
7373,
1041,
272,
372,
291,
423,
5553,
819,
347,
2494,
2445,
8,
277,
12,
943,
304,
272,
408,
1084,
314,
511,
943,
1041,
272,
291,
423,
793,
275,
943,
819,
347,
2372,
2445,
8,
277,
304,
272,
408,
1002,
314,
511,
943,
1041,
272,
372,
291,
423,
793,
421,
199,
533,
1379,
2540,
6579,
8,
785,
304,
523,
408,
1084,
402,
2058,
367,
282,
511,
1255,
1041,
819,
347,
636,
826,
721,
277,
304,
272,
291,
423,
2604,
275,
663,
342,
819,
347,
2372,
16333,
8,
277,
304,
272,
408,
1002,
314,
1059,
6025,
402,
1006,
511,
9610,
1041,
272,
308,
275,
942,
272,
367,
511,
63,
466,
315,
10695,
804,
14,
1002,
4100,
837,
489,
340,
511,
63,
466,
1137,
10695,
804,
14,
6909,
26,
267,
367,
307,
315,
3355,
8,
277,
423,
24770,
8,
396,
63,
466,
2298,
881,
943,
275,
307,
14,
1002,
2445,
342,
881,
340,
943,
26,
288,
308,
14,
740,
360,
9722,
83,
61,
450,
83,
4881,
450,
334,
396,
63,
466,
12,
307,
430,
288,
308,
14,
740,
8,
793,
9,
272,
372,
1557,
78,
1370,
904,
8,
83,
9,
819,
347,
2372,
39,
396,
2821,
8,
277,
304,
272,
408,
1002,
314,
9088,
1059,
6025,
402,
642,
909,
1041,
272,
308,
275,
942,
272,
11718,
275,
2400,
302,
12,
308,
12,
299,
26,
1543,
68,
450,
83,
7,
450,
334,
78,
12,
299,
340,
302,
1137,
413,
587,
308,
9,
272,
2295,
275,
2400,
302,
26,
11718,
8,
78,
12,
283,
396,
297,
283,
2219,
358,
339,
308,
14,
740,
11894,
17575,
61,
450,
83,
21471,
3530,
450,
334,
2219,
8,
552,
8,
277,
14,
24578,
4059,
430,
272,
308,
14,
740,
11894,
221,
510,
32032,
221,
1622,
450,
83,
3530,
450,
334,
2219,
8,
552,
8,
277,
14,
1002,
4986,
4059,
430,
339,
9645,
275,
291,
14,
1002,
7738,
342,
272,
340,
9645,
26,
489,
308,
14,
740,
11894,
221,
27885,
19359,
1622,
8232,
1915,
450,
83,
12,
10532,
5084,
4881,
450,
2295,
8,
552,
8,
11962,
1724,
489,
367,
307,
315,
3355,
8,
11962,
304,
267,
308,
14,
740,
11894,
221,
27885,
19359,
1622,
450,
83,
7,
450,
620,
8,
84,
430,
339,
1006,
63,
9968,
275,
291,
14,
1002,
4874,
1252,
8888,
8,
277,
14,
1002,
17345,
1119,
1062,
291,
14,
1002,
6372,
1062,
267,
291,
14,
1002,
5912,
1012,
272,
340,
1006,
63,
9968,
26,
489,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
12,
10532,
5084,
4881,
450,
2295,
8,
552,
8,
452,
63,
9968,
1724,
489,
367,
307,
315,
3355,
8,
277,
14,
1002,
4874,
5109,
267,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
7,
450,
620,
8,
84,
430,
489,
367,
307,
315,
3355,
8,
277,
14,
1002,
17345,
1119,
5109,
267,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
334,
2944,
8100,
1149,
3171,
450,
620,
8,
84,
430,
489,
367,
307,
315,
3355,
8,
277,
14,
1002,
6372,
5109,
267,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
334,
8899,
3171,
450,
620,
8,
84
] |
[
1898,
334,
67,
9,
6171,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
2377,
3035,
1300,
511,
2058,
3992,
1041,
199,
199,
533,
10695,
804,
8,
785,
304,
523,
408,
2543,
3720,
10417,
511,
2943,
1041,
523,
21705,
275,
283,
6909,
7,
523,
27885,
275,
283,
13525,
7,
523,
10341,
275,
283,
8784,
7,
523,
17101,
8100,
275,
283,
2944,
8100,
7,
523,
29998,
275,
283,
8899,
7,
523,
24740,
275,
283,
11588,
7,
819,
768,
4639,
523,
347,
2372,
4100,
837,
272,
408,
1002,
282,
769,
402,
1006,
511,
2943,
1041,
272,
372,
359,
2889,
804,
14,
6909,
12,
10695,
804,
14,
13525,
12,
10695,
804,
14,
8784,
12,
288,
10695,
804,
14,
2944,
8100,
12,
10695,
804,
14,
8899,
12,
10695,
804,
14,
11588,
61,
421,
199,
533,
3523,
13120,
8,
785,
304,
523,
408,
1563,
1021,
367,
282,
2849,
511,
754,
1041,
819,
347,
636,
826,
721,
277,
12,
536,
12,
511,
63,
466,
12,
7373,
29,
16,
12,
943,
9280,
272,
408,
11493,
282,
3523,
13120,
14,
339,
3033,
26,
489,
536,
26,
2812,
402,
314,
511,
1314,
7890,
15439,
31820,
14,
489,
511,
63,
466,
26,
2434,
402,
314,
511,
754,
465,
3247,
315,
10695,
804,
14,
489,
7373,
26,
4703,
652,
27221,
367,
314,
511,
370,
1255,
315,
21131,
14,
489,
943,
26,
1626,
2716,
1059,
13778,
1263,
2552,
14,
272,
408,
272,
702,
536,
272,
702,
511,
63,
466,
315,
10695,
804,
14,
1002,
4100,
342,
272,
291,
423,
354,
275,
536,
272,
291,
423,
396,
63,
466,
275,
511,
63,
466,
272,
291,
423,
5553,
275,
7373,
272,
291,
423,
793,
275,
943,
819,
347,
636,
495,
721,
277,
304,
272,
372,
291,
423,
354,
819,
347,
636,
2722,
721,
277,
304,
272,
372,
291,
423,
354,
819,
347,
636,
5730,
721,
277,
12,
1163,
304,
272,
327,
4287,
26,
3507,
29,
55,
996,
713,
272,
372,
10467,
8,
277,
423,
354,
12,
1163,
423,
354,
9,
819,
347,
636,
2227,
721,
277,
304,
272,
372,
2631,
8,
277,
423,
354,
9,
819,
347,
2494,
985,
8,
277,
12,
536,
304,
272,
408,
1084,
314,
511,
536,
14,
339,
13821,
781,
3984,
32670,
642,
1901,
282,
663,
12,
642,
1077,
1454,
506,
1202,
340,
12876,
272,
642,
511,
754,
1901,
4573,
663,
14,
272,
408,
272,
291,
423,
354,
275,
536,
819,
347,
2372,
985,
8,
277,
304,
272,
408,
1002,
314,
511,
536,
1041,
272,
372,
291,
423,
354,
819,
347,
2494,
804,
8,
277,
12,
511,
63,
466,
304,
272,
408,
1084,
314,
511,
754,
730,
1041,
272,
702,
511,
63,
466,
315,
10695,
804,
14,
1002,
4100,
342,
272,
291,
423,
396,
63,
466,
275,
511,
63,
466,
819,
347,
2372,
804,
8,
277,
304,
272,
408,
1002,
314,
511,
754,
730,
1041,
272,
372,
291,
423,
396,
63,
466,
819,
347,
2372,
13283,
8,
277,
304,
272,
408,
1002,
314,
511,
7373,
1041,
272,
372,
291,
423,
5553,
819,
347,
2494,
2445,
8,
277,
12,
943,
304,
272,
408,
1084,
314,
511,
943,
1041,
272,
291,
423,
793,
275,
943,
819,
347,
2372,
2445,
8,
277,
304,
272,
408,
1002,
314,
511,
943,
1041,
272,
372,
291,
423,
793,
421,
199,
533,
1379,
2540,
6579,
8,
785,
304,
523,
408,
1084,
402,
2058,
367,
282,
511,
1255,
1041,
819,
347,
636,
826,
721,
277,
304,
272,
291,
423,
2604,
275,
663,
342,
819,
347,
2372,
16333,
8,
277,
304,
272,
408,
1002,
314,
1059,
6025,
402,
1006,
511,
9610,
1041,
272,
308,
275,
942,
272,
367,
511,
63,
466,
315,
10695,
804,
14,
1002,
4100,
837,
489,
340,
511,
63,
466,
1137,
10695,
804,
14,
6909,
26,
267,
367,
307,
315,
3355,
8,
277,
423,
24770,
8,
396,
63,
466,
2298,
881,
943,
275,
307,
14,
1002,
2445,
342,
881,
340,
943,
26,
288,
308,
14,
740,
360,
9722,
83,
61,
450,
83,
4881,
450,
334,
396,
63,
466,
12,
307,
430,
288,
308,
14,
740,
8,
793,
9,
272,
372,
1557,
78,
1370,
904,
8,
83,
9,
819,
347,
2372,
39,
396,
2821,
8,
277,
304,
272,
408,
1002,
314,
9088,
1059,
6025,
402,
642,
909,
1041,
272,
308,
275,
942,
272,
11718,
275,
2400,
302,
12,
308,
12,
299,
26,
1543,
68,
450,
83,
7,
450,
334,
78,
12,
299,
340,
302,
1137,
413,
587,
308,
9,
272,
2295,
275,
2400,
302,
26,
11718,
8,
78,
12,
283,
396,
297,
283,
2219,
358,
339,
308,
14,
740,
11894,
17575,
61,
450,
83,
21471,
3530,
450,
334,
2219,
8,
552,
8,
277,
14,
24578,
4059,
430,
272,
308,
14,
740,
11894,
221,
510,
32032,
221,
1622,
450,
83,
3530,
450,
334,
2219,
8,
552,
8,
277,
14,
1002,
4986,
4059,
430,
339,
9645,
275,
291,
14,
1002,
7738,
342,
272,
340,
9645,
26,
489,
308,
14,
740,
11894,
221,
27885,
19359,
1622,
8232,
1915,
450,
83,
12,
10532,
5084,
4881,
450,
2295,
8,
552,
8,
11962,
1724,
489,
367,
307,
315,
3355,
8,
11962,
304,
267,
308,
14,
740,
11894,
221,
27885,
19359,
1622,
450,
83,
7,
450,
620,
8,
84,
430,
339,
1006,
63,
9968,
275,
291,
14,
1002,
4874,
1252,
8888,
8,
277,
14,
1002,
17345,
1119,
1062,
291,
14,
1002,
6372,
1062,
267,
291,
14,
1002,
5912,
1012,
272,
340,
1006,
63,
9968,
26,
489,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
12,
10532,
5084,
4881,
450,
2295,
8,
552,
8,
452,
63,
9968,
1724,
489,
367,
307,
315,
3355,
8,
277,
14,
1002,
4874,
5109,
267,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
7,
450,
620,
8,
84,
430,
489,
367,
307,
315,
3355,
8,
277,
14,
1002,
17345,
1119,
5109,
267,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
334,
2944,
8100,
1149,
3171,
450,
620,
8,
84,
430,
489,
367,
307,
315,
3355,
8,
277,
14,
1002,
6372,
5109,
267,
308,
14,
740,
11894,
221,
26892,
221,
1622,
450,
83,
334,
8899,
3171,
450,
620,
8,
84,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
lzw120/django
|
django/contrib/localflavor/cz/forms.py
|
9
|
4488
|
"""
Czech-specific form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.cz.cz_regions import REGION_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Select, RegexField, Field
from django.utils.translation import ugettext_lazy as _
birth_number = re.compile(r'^(?P<birth>\d{6})/?(?P<id>\d{3,4})$')
ic_number = re.compile(r'^(?P<number>\d{7})(?P<check>\d)$')
class CZRegionSelect(Select):
"""
A select widget widget with list of Czech regions as choices.
"""
def __init__(self, attrs=None):
super(CZRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class CZPostalCodeField(RegexField):
"""
A form field that validates its input as Czech postal code.
Valid form is XXXXX or XXX XX, where X represents integer.
"""
default_error_messages = {
'invalid': _(u'Enter a postal code in the format XXXXX or XXX XX.'),
}
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
super(CZPostalCodeField, self).__init__(r'^\d{5}$|^\d{3} \d{2}$',
max_length, min_length, *args, **kwargs)
def clean(self, value):
"""
Validates the input and returns a string that contains only numbers.
Returns an empty string for empty values.
"""
v = super(CZPostalCodeField, self).clean(value)
return v.replace(' ', '')
class CZBirthNumberField(Field):
"""
Czech birth number field.
"""
default_error_messages = {
'invalid_format': _(u'Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.'),
'invalid': _(u'Enter a valid birth number.'),
}
def clean(self, value, gender=None):
super(CZBirthNumberField, self).clean(value)
if value in EMPTY_VALUES:
return u''
match = re.match(birth_number, value)
if not match:
raise ValidationError(self.error_messages['invalid_format'])
birth, id = match.groupdict()['birth'], match.groupdict()['id']
# Three digits for verification number were used until 1. january 1954
if len(id) == 3:
return u'%s' % value
# Birth number is in format YYMMDD. Females have month value raised by 50.
# In case that all possible number are already used (for given date),
# the month field is raised by 20.
month = int(birth[2:4])
if (not 1 <= month <= 12) and (not 21 <= month <= 32) and \
(not 51 <= month <= 62) and (not 71 <= month <= 82):
raise ValidationError(self.error_messages['invalid'])
day = int(birth[4:6])
if not (1 <= day <= 31):
raise ValidationError(self.error_messages['invalid'])
# Fourth digit has been added since 1. January 1954.
# It is modulo of dividing birth number and verification number by 11.
# If the modulo were 10, the last number was 0 (and therefore, the whole
# birth number wasn't divisable by 11. These number are no longer used (since 1985)
# and the condition 'modulo == 10' can be removed in 2085.
modulo = int(birth + id[:3]) % 11
if (modulo == int(id[-1])) or (modulo == 10 and id[-1] == '0'):
return u'%s' % value
else:
raise ValidationError(self.error_messages['invalid'])
class CZICNumberField(Field):
"""
Czech IC number field.
"""
default_error_messages = {
'invalid': _(u'Enter a valid IC number.'),
}
def clean(self, value):
super(CZICNumberField, self).clean(value)
if value in EMPTY_VALUES:
return u''
match = re.match(ic_number, value)
if not match:
raise ValidationError(self.error_messages['invalid'])
number, check = match.groupdict()['number'], int(match.groupdict()['check'])
sum = 0
weight = 8
for digit in number:
sum += int(digit)*weight
weight -= 1
remainder = sum % 11
# remainder is equal:
# 0 or 10: last digit is 1
# 1: last digit is 0
# in other case, last digit is 11 - remainder
if (not remainder % 10 and check == 1) or \
(remainder == 1 and check == 0) or \
(check == (11 - remainder)):
return u'%s' % value
raise ValidationError(self.error_messages['invalid'])
|
bsd-3-clause
|
[
624,
199,
35,
806,
335,
13,
6100,
1824,
10897,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
16823,
14,
16823,
63,
11963,
492,
14142,
1075,
63,
16236,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
9496,
12,
12939,
792,
12,
5024,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
10907,
63,
1955,
275,
295,
14,
2014,
8,
82,
24550,
48,
28,
10907,
3072,
68,
91,
22,
1552,
10197,
2229,
48,
28,
344,
3072,
68,
91,
19,
12,
20,
1552,
9988,
199,
530,
63,
1955,
275,
295,
14,
2014,
8,
82,
24550,
48,
28,
1955,
3072,
68,
91,
23,
1552,
2229,
48,
28,
1074,
3072,
68,
9,
9988,
199,
199,
533,
445,
58,
10708,
5446,
8,
5446,
304,
272,
408,
272,
437,
3504,
3938,
3938,
543,
769,
402,
445,
806,
335,
16150,
465,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
1613,
8,
27808,
10708,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
23030,
63,
16236,
9,
199,
199,
533,
445,
58,
6564,
279,
3034,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2399,
1324,
465,
445,
806,
335,
2963,
279,
1233,
14,
272,
4821,
1824,
365,
5787,
2483,
503,
5787,
1323,
56,
12,
2382,
1323,
8469,
3000,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
2963,
279,
1233,
315,
314,
1475,
5787,
2483,
503,
5787,
1323,
56,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
27808,
6564,
279,
3034,
792,
12,
291,
2843,
826,
721,
82,
15542,
68,
91,
21,
93,
31686,
12773,
68,
91,
19,
93,
971,
68,
91,
18,
19204,
288,
1390,
63,
1267,
12,
1748,
63,
1267,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
408,
267,
4821,
2335,
314,
1324,
436,
2529,
282,
1059,
626,
3509,
1454,
5579,
14,
267,
1803,
376,
2701,
1059,
367,
2701,
1338,
14,
267,
408,
267,
373,
275,
1613,
8,
27808,
6564,
279,
3034,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
372,
373,
14,
1814,
360,
1656,
4074,
199,
199,
533,
445,
58,
29229,
3259,
792,
8,
792,
304,
272,
408,
272,
445,
806,
335,
21036,
1329,
901,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
63,
908,
356,
12561,
85,
7,
8468,
282,
21036,
1329,
315,
314,
1475,
5787,
13933,
15,
6873,
503,
5787,
6873,
13933,
8038,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
21036,
1329,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
12,
24395,
29,
403,
304,
267,
1613,
8,
27808,
29229,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
398,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
398,
1336,
275,
295,
14,
1431,
8,
10907,
63,
1955,
12,
574,
9,
267,
340,
440,
1336,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
63,
908,
1105,
398,
21036,
12,
1305,
275,
1336,
14,
20567,
12047,
10907,
995,
1336,
14,
20567,
12047,
344,
418,
398,
327,
30467,
7576,
367,
14786,
1329,
4898,
1202,
5133,
413,
14,
1335,
290,
20527,
5851,
1477,
267,
340,
822,
8,
344,
9,
508,
650,
26,
288,
372,
399,
5956,
83,
7,
450,
574,
398,
327,
699,
8244,
1329,
365,
315,
1475,
1488,
57,
3218,
5745,
14,
7949,
391,
2978,
1172,
5794,
574,
4915,
701,
5238,
14,
267,
327,
1010,
1930,
626,
1006,
3962,
1329,
787,
2575,
1202,
334,
509,
1627,
1434,
395,
267,
327,
314,
5794,
901,
365,
4915,
701,
3388,
14,
267,
5794,
275,
1109,
8,
10907,
59,
18,
26,
20,
566,
267,
340,
334,
1397,
413,
2695,
5794,
2695,
3144,
9,
436,
334,
1397,
7829,
2695,
5794,
2695,
4337,
9,
436,
971,
355,
334,
1397,
8026,
2695,
5794,
2695,
16202,
9,
436,
334,
1397,
17245,
2695,
5794,
2695,
18051,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
398,
5382,
275,
1109,
8,
10907,
59,
20,
26,
22,
566,
267,
340,
440,
334,
17,
2695,
5382,
2695,
7105,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
398,
327,
23843,
273,
10964,
965,
2757,
3483,
3967,
413,
14,
17474,
20527,
5851,
1477,
14,
267,
327,
2779,
365,
27656,
402,
487,
11604,
21036,
1329,
436,
14786,
1329,
701,
4119,
14,
267,
327,
982,
314,
27656,
4898,
1616,
12,
314,
2061,
1329,
1990,
378,
334,
460,
16119,
12,
314,
8852,
267,
327,
21036,
1329,
17373,
1133,
487,
5068,
461,
701,
4119,
14,
5723,
1329,
787,
949,
8088,
1202,
334,
8585,
5851,
2426,
9,
267,
327,
436,
314,
5558,
283,
1494,
13957,
508,
1616,
7,
883,
506,
4829,
315,
499,
17494,
14,
398,
27656,
275,
1109,
8,
10907,
435,
1305,
1491,
19,
566,
450,
4119,
398,
340,
334,
1494,
13957,
508,
1109,
8,
344,
1988,
17,
2459,
503,
334,
1494,
13957,
508,
1616,
436,
1305,
1988,
17,
61,
508,
283,
16,
735,
288,
372,
399,
5956,
83,
7,
450,
574,
267,
587,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
199,
199,
533,
445,
58,
948,
3259,
792,
8,
792,
304,
272,
408,
272,
445,
806,
335,
473,
35,
1329,
901,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
473,
35,
1329,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
1613,
8,
27808,
948,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
398,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
398,
1336,
275,
295,
14,
1431,
8,
530,
63,
1955,
12,
574,
9,
267,
340,
440,
1336,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197
] |
[
199,
35,
806,
335,
13,
6100,
1824,
10897,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
2828,
14,
320,
696,
276,
4271,
14,
16823,
14,
16823,
63,
11963,
492,
14142,
1075,
63,
16236,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
9496,
12,
12939,
792,
12,
5024,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
10907,
63,
1955,
275,
295,
14,
2014,
8,
82,
24550,
48,
28,
10907,
3072,
68,
91,
22,
1552,
10197,
2229,
48,
28,
344,
3072,
68,
91,
19,
12,
20,
1552,
9988,
199,
530,
63,
1955,
275,
295,
14,
2014,
8,
82,
24550,
48,
28,
1955,
3072,
68,
91,
23,
1552,
2229,
48,
28,
1074,
3072,
68,
9,
9988,
199,
199,
533,
445,
58,
10708,
5446,
8,
5446,
304,
272,
408,
272,
437,
3504,
3938,
3938,
543,
769,
402,
445,
806,
335,
16150,
465,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
1613,
8,
27808,
10708,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
23030,
63,
16236,
9,
199,
199,
533,
445,
58,
6564,
279,
3034,
792,
8,
5103,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2399,
1324,
465,
445,
806,
335,
2963,
279,
1233,
14,
272,
4821,
1824,
365,
5787,
2483,
503,
5787,
1323,
56,
12,
2382,
1323,
8469,
3000,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
2963,
279,
1233,
315,
314,
1475,
5787,
2483,
503,
5787,
1323,
56,
8038,
272,
789,
339,
347,
636,
826,
721,
277,
12,
1390,
63,
1267,
29,
403,
12,
1748,
63,
1267,
29,
403,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
27808,
6564,
279,
3034,
792,
12,
291,
2843,
826,
721,
82,
15542,
68,
91,
21,
93,
31686,
12773,
68,
91,
19,
93,
971,
68,
91,
18,
19204,
288,
1390,
63,
1267,
12,
1748,
63,
1267,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
408,
267,
4821,
2335,
314,
1324,
436,
2529,
282,
1059,
626,
3509,
1454,
5579,
14,
267,
1803,
376,
2701,
1059,
367,
2701,
1338,
14,
267,
408,
267,
373,
275,
1613,
8,
27808,
6564,
279,
3034,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
372,
373,
14,
1814,
360,
1656,
4074,
199,
199,
533,
445,
58,
29229,
3259,
792,
8,
792,
304,
272,
408,
272,
445,
806,
335,
21036,
1329,
901,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
63,
908,
356,
12561,
85,
7,
8468,
282,
21036,
1329,
315,
314,
1475,
5787,
13933,
15,
6873,
503,
5787,
6873,
13933,
8038,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
21036,
1329,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
12,
24395,
29,
403,
304,
267,
1613,
8,
27808,
29229,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
398,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
399,
891,
398,
1336,
275,
295,
14,
1431,
8,
10907,
63,
1955,
12,
574,
9,
267,
340,
440,
1336,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
63,
908,
1105,
398,
21036,
12,
1305,
275,
1336,
14,
20567,
12047,
10907,
995,
1336,
14,
20567,
12047,
344,
418,
398,
327,
30467,
7576,
367,
14786,
1329,
4898,
1202,
5133,
413,
14,
1335,
290,
20527,
5851,
1477,
267,
340,
822,
8,
344,
9,
508,
650,
26,
288,
372,
399,
5956,
83,
7,
450,
574,
398,
327,
699,
8244,
1329,
365,
315,
1475,
1488,
57,
3218,
5745,
14,
7949,
391,
2978,
1172,
5794,
574,
4915,
701,
5238,
14,
267,
327,
1010,
1930,
626,
1006,
3962,
1329,
787,
2575,
1202,
334,
509,
1627,
1434,
395,
267,
327,
314,
5794,
901,
365,
4915,
701,
3388,
14,
267,
5794,
275,
1109,
8,
10907,
59,
18,
26,
20,
566,
267,
340,
334,
1397,
413,
2695,
5794,
2695,
3144,
9,
436,
334,
1397,
7829,
2695,
5794,
2695,
4337,
9,
436,
971,
355,
334,
1397,
8026,
2695,
5794,
2695,
16202,
9,
436,
334,
1397,
17245,
2695,
5794,
2695,
18051,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
398,
5382,
275,
1109,
8,
10907,
59,
20,
26,
22,
566,
267,
340,
440,
334,
17,
2695,
5382,
2695,
7105,
304,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
398,
327,
23843,
273,
10964,
965,
2757,
3483,
3967,
413,
14,
17474,
20527,
5851,
1477,
14,
267,
327,
2779,
365,
27656,
402,
487,
11604,
21036,
1329,
436,
14786,
1329,
701,
4119,
14,
267,
327,
982,
314,
27656,
4898,
1616,
12,
314,
2061,
1329,
1990,
378,
334,
460,
16119,
12,
314,
8852,
267,
327,
21036,
1329,
17373,
1133,
487,
5068,
461,
701,
4119,
14,
5723,
1329,
787,
949,
8088,
1202,
334,
8585,
5851,
2426,
9,
267,
327,
436,
314,
5558,
283,
1494,
13957,
508,
1616,
7,
883,
506,
4829,
315,
499,
17494,
14,
398,
27656,
275,
1109,
8,
10907,
435,
1305,
1491,
19,
566,
450,
4119,
398,
340,
334,
1494,
13957,
508,
1109,
8,
344,
1988,
17,
2459,
503,
334,
1494,
13957,
508,
1616,
436,
1305,
1988,
17,
61,
508,
283,
16,
735,
288,
372,
399,
5956,
83,
7,
450,
574,
267,
587,
26,
288,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
199,
199,
533,
445,
58,
948,
3259,
792,
8,
792,
304,
272,
408,
272,
445,
806,
335,
473,
35,
1329,
901,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
12561,
85,
7,
8468,
282,
1686,
473,
35,
1329,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
1613,
8,
27808,
948,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
398,
340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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
wetek-enigma/enigma2
|
lib/python/Screens/Console.py
|
33
|
2566
|
from enigma import eConsoleAppContainer
from Screens.Screen import Screen
from Components.ActionMap import ActionMap
from Components.ScrollLabel import ScrollLabel
from Components.Sources.StaticText import StaticText
class Console(Screen):
def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
Screen.__init__(self, session)
self.finishedCallback = finishedCallback
self.closeOnSuccess = closeOnSuccess
self.errorOcurred = False
self["text"] = ScrollLabel("")
self["summary_description"] = StaticText("")
self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
{
"ok": self.cancel,
"back": self.cancel,
"up": self["text"].pageUp,
"down": self["text"].pageDown
}, -1)
self.cmdlist = cmdlist
self.newtitle = title
self.onShown.append(self.updateTitle)
self.container = eConsoleAppContainer()
self.run = 0
self.container.appClosed.append(self.runFinished)
self.container.dataAvail.append(self.dataAvail)
self.onLayoutFinish.append(self.startRun) # dont start before gui is finished
def updateTitle(self):
self.setTitle(self.newtitle)
def startRun(self):
self["text"].setText(_("Execution progress:") + "\n\n")
self["summary_description"].setText(_("Execution progress:"))
print "Console: executing in run", self.run, " the command:", self.cmdlist[self.run]
if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
self.runFinished(-1) # so we must call runFinished manual
def runFinished(self, retval):
if retval:
self.errorOcurred = True
self.run += 1
if self.run != len(self.cmdlist):
if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
self.runFinished(-1) # so we must call runFinished manual
else:
lastpage = self["text"].isAtLastPage()
str = self["text"].getText()
str += _("Execution finished!!")
self["summary_description"].setText(_("Execution finished!!"))
self["text"].setText(str)
if lastpage:
self["text"].lastPage()
if self.finishedCallback is not None:
self.finishedCallback()
if not self.errorOcurred and self.closeOnSuccess:
self.cancel()
def cancel(self):
if self.run == len(self.cmdlist):
self.close()
self.container.appClosed.remove(self.runFinished)
self.container.dataAvail.remove(self.dataAvail)
def dataAvail(self, str):
lastpage = self["text"].isAtLastPage()
self["text"].setText(self["text"].getText() + str)
if lastpage:
self["text"].lastPage()
|
gpl-2.0
|
[
504,
655,
27021,
492,
325,
9270,
2640,
4076,
199,
504,
29372,
14,
9616,
492,
17804,
199,
504,
17823,
14,
3310,
2956,
492,
10033,
2956,
199,
504,
17823,
14,
13127,
4314,
492,
13916,
2827,
4314,
199,
504,
17823,
14,
13959,
14,
25289,
492,
13599,
1872,
199,
199,
533,
19809,
8,
9616,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2351,
12,
2538,
275,
298,
9270,
401,
2088,
513,
275,
488,
12,
9158,
2806,
275,
488,
12,
4002,
3314,
8300,
275,
756,
304,
507,
198,
9616,
855,
826,
721,
277,
12,
2351,
9,
2742,
198,
277,
14,
8669,
2806,
275,
9158,
2806,
507,
198,
277,
14,
1600,
3314,
8300,
275,
4002,
3314,
8300,
507,
198,
277,
14,
705,
47,
895,
581,
275,
756,
2742,
198,
277,
905,
505,
937,
275,
13916,
2827,
4314,
10804,
507,
198,
277,
905,
4705,
63,
1802,
937,
275,
13599,
1872,
10804,
507,
198,
277,
905,
3723,
937,
275,
10033,
2956,
5234,
20120,
9303,
401,
298,
17015,
9303,
2255,
507,
198,
91,
686,
198,
2,
745,
582,
291,
14,
6406,
12,
686,
198,
2,
894,
582,
291,
14,
6406,
12,
686,
198,
2,
384,
582,
291,
905,
505,
4140,
1606,
1721,
12,
686,
198,
2,
2110,
582,
291,
905,
505,
4140,
1606,
3514,
507,
198,
1386,
446,
17,
9,
2742,
198,
277,
14,
1760,
513,
275,
2088,
513,
507,
198,
277,
14,
1222,
1213,
275,
2538,
2742,
198,
277,
14,
265,
6824,
78,
14,
740,
8,
277,
14,
873,
6888,
9,
2742,
198,
277,
14,
3600,
275,
325,
9270,
2640,
4076,
342,
507,
198,
277,
14,
1065,
275,
378,
507,
198,
277,
14,
3600,
14,
571,
15190,
14,
740,
8,
277,
14,
1065,
13430,
9,
507,
198,
277,
14,
3600,
14,
576,
6651,
1054,
14,
740,
8,
277,
14,
576,
6651,
1054,
9,
507,
198,
277,
14,
265,
4798,
22084,
14,
740,
8,
277,
14,
928,
2540,
9,
327,
21542,
1343,
2544,
11621,
365,
9158,
421,
198,
318,
1678,
6888,
8,
277,
304,
507,
198,
277,
14,
31675,
8,
277,
14,
1222,
1213,
9,
421,
198,
318,
1343,
2540,
8,
277,
304,
507,
198,
277,
905,
505,
4140,
8341,
6115,
11310,
6696,
9107,
435,
1867,
78,
60,
78,
531,
507,
198,
277,
905,
4705,
63,
1802,
4140,
8341,
6115,
11310,
6696,
26,
2237,
507,
198,
1361,
298,
9270,
26,
14043,
315,
1255,
401,
291,
14,
1065,
12,
298,
314,
1414,
6783,
291,
14,
1760,
513,
59,
277,
14,
1065,
61,
507,
198,
692,
291,
14,
3600,
14,
2526,
8,
277,
14,
1760,
513,
59,
277,
14,
1065,
4682,
327,
928,
402,
3970,
4223,
3405,
1396,
686,
198,
277,
14,
1065,
13430,
2801,
17,
9,
327,
880,
781,
1471,
1240,
1255,
13430,
8722,
421,
198,
318,
1255,
13430,
8,
277,
12,
9151,
304,
507,
198,
692,
9151,
26,
686,
198,
277,
14,
705,
47,
895,
581,
275,
715,
507,
198,
277,
14,
1065,
847,
413,
507,
198,
692,
291,
14,
1065,
1137,
822,
8,
277,
14,
1760,
513,
304,
686,
198,
692,
291,
14,
3600,
14,
2526,
8,
277,
14,
1760,
513,
59,
277,
14,
1065,
4682,
327,
928,
402,
3970,
4223,
3405,
1396,
1585,
198,
277,
14,
1065,
13430,
2801,
17,
9,
327,
880,
781,
1471,
1240,
1255,
13430,
8722,
507,
198,
2836,
26,
686,
198,
2019,
1606,
275,
291,
905,
505,
4140,
374,
1271,
6090,
3276,
342,
686,
198,
495,
275,
291,
905,
505,
4140,
25506,
342,
686,
198,
495,
847,
3824,
11310,
9158,
3480,
531,
686,
198,
277,
905,
4705,
63,
1802,
4140,
8341,
6115,
11310,
9158,
3480,
2237,
686,
198,
277,
905,
505,
4140,
8341,
8,
495,
9,
686,
198,
692,
2061,
1606,
26,
1585,
198,
277,
905,
505,
4140,
2019,
3276,
342,
686,
198,
692,
291,
14,
8669,
2806,
365,
440,
488,
26,
1585,
198,
277,
14,
8669,
2806,
342,
686,
198,
692,
440,
291,
14,
705,
47,
895,
581,
436,
291,
14,
1600,
3314,
8300,
26,
1585,
198,
277,
14,
6406,
342,
421,
198,
318,
9311,
8,
277,
304,
507,
198,
692,
291,
14,
1065,
508,
822,
8,
277,
14,
1760,
513,
304,
686,
198,
277,
14,
1600,
342,
686,
198,
277,
14,
3600,
14,
571,
15190,
14,
2168,
8,
277,
14,
1065,
13430,
9,
686,
198,
277,
14,
3600,
14,
576,
6651,
1054,
14,
2168,
8,
277,
14,
576,
6651,
1054,
9,
421,
198,
318,
666,
6651,
1054,
8,
277,
12,
620,
304,
507,
198,
2019,
1606,
275,
291,
905,
505,
4140,
374,
1271,
6090,
3276,
342,
507,
198,
277,
905,
505,
4140,
8341,
8,
277,
905,
505,
4140,
25506,
342,
435,
620,
9,
507,
198,
692,
2061,
1606,
26,
686,
198,
277,
905,
505,
4140,
2019,
3276,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
655,
27021,
492,
325,
9270,
2640,
4076,
199,
504,
29372,
14,
9616,
492,
17804,
199,
504,
17823,
14,
3310,
2956,
492,
10033,
2956,
199,
504,
17823,
14,
13127,
4314,
492,
13916,
2827,
4314,
199,
504,
17823,
14,
13959,
14,
25289,
492,
13599,
1872,
199,
199,
533,
19809,
8,
9616,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2351,
12,
2538,
275,
298,
9270,
401,
2088,
513,
275,
488,
12,
9158,
2806,
275,
488,
12,
4002,
3314,
8300,
275,
756,
304,
507,
198,
9616,
855,
826,
721,
277,
12,
2351,
9,
2742,
198,
277,
14,
8669,
2806,
275,
9158,
2806,
507,
198,
277,
14,
1600,
3314,
8300,
275,
4002,
3314,
8300,
507,
198,
277,
14,
705,
47,
895,
581,
275,
756,
2742,
198,
277,
905,
505,
937,
275,
13916,
2827,
4314,
10804,
507,
198,
277,
905,
4705,
63,
1802,
937,
275,
13599,
1872,
10804,
507,
198,
277,
905,
3723,
937,
275,
10033,
2956,
5234,
20120,
9303,
401,
298,
17015,
9303,
2255,
507,
198,
91,
686,
198,
2,
745,
582,
291,
14,
6406,
12,
686,
198,
2,
894,
582,
291,
14,
6406,
12,
686,
198,
2,
384,
582,
291,
905,
505,
4140,
1606,
1721,
12,
686,
198,
2,
2110,
582,
291,
905,
505,
4140,
1606,
3514,
507,
198,
1386,
446,
17,
9,
2742,
198,
277,
14,
1760,
513,
275,
2088,
513,
507,
198,
277,
14,
1222,
1213,
275,
2538,
2742,
198,
277,
14,
265,
6824,
78,
14,
740,
8,
277,
14,
873,
6888,
9,
2742,
198,
277,
14,
3600,
275,
325,
9270,
2640,
4076,
342,
507,
198,
277,
14,
1065,
275,
378,
507,
198,
277,
14,
3600,
14,
571,
15190,
14,
740,
8,
277,
14,
1065,
13430,
9,
507,
198,
277,
14,
3600,
14,
576,
6651,
1054,
14,
740,
8,
277,
14,
576,
6651,
1054,
9,
507,
198,
277,
14,
265,
4798,
22084,
14,
740,
8,
277,
14,
928,
2540,
9,
327,
21542,
1343,
2544,
11621,
365,
9158,
421,
198,
318,
1678,
6888,
8,
277,
304,
507,
198,
277,
14,
31675,
8,
277,
14,
1222,
1213,
9,
421,
198,
318,
1343,
2540,
8,
277,
304,
507,
198,
277,
905,
505,
4140,
8341,
6115,
11310,
6696,
9107,
435,
1867,
78,
60,
78,
531,
507,
198,
277,
905,
4705,
63,
1802,
4140,
8341,
6115,
11310,
6696,
26,
2237,
507,
198,
1361,
298,
9270,
26,
14043,
315,
1255,
401,
291,
14,
1065,
12,
298,
314,
1414,
6783,
291,
14,
1760,
513,
59,
277,
14,
1065,
61,
507,
198,
692,
291,
14,
3600,
14,
2526,
8,
277,
14,
1760,
513,
59,
277,
14,
1065,
4682,
327,
928,
402,
3970,
4223,
3405,
1396,
686,
198,
277,
14,
1065,
13430,
2801,
17,
9,
327,
880,
781,
1471,
1240,
1255,
13430,
8722,
421,
198,
318,
1255,
13430,
8,
277,
12,
9151,
304,
507,
198,
692,
9151,
26,
686,
198,
277,
14,
705,
47,
895,
581,
275,
715,
507,
198,
277,
14,
1065,
847,
413,
507,
198,
692,
291,
14,
1065,
1137,
822,
8,
277,
14,
1760,
513,
304,
686,
198,
692,
291,
14,
3600,
14,
2526,
8,
277,
14,
1760,
513,
59,
277,
14,
1065,
4682,
327,
928,
402,
3970,
4223,
3405,
1396,
1585,
198,
277,
14,
1065,
13430,
2801,
17,
9,
327,
880,
781,
1471,
1240,
1255,
13430,
8722,
507,
198,
2836,
26,
686,
198,
2019,
1606,
275,
291,
905,
505,
4140,
374,
1271,
6090,
3276,
342,
686,
198,
495,
275,
291,
905,
505,
4140,
25506,
342,
686,
198,
495,
847,
3824,
11310,
9158,
3480,
531,
686,
198,
277,
905,
4705,
63,
1802,
4140,
8341,
6115,
11310,
9158,
3480,
2237,
686,
198,
277,
905,
505,
4140,
8341,
8,
495,
9,
686,
198,
692,
2061,
1606,
26,
1585,
198,
277,
905,
505,
4140,
2019,
3276,
342,
686,
198,
692,
291,
14,
8669,
2806,
365,
440,
488,
26,
1585,
198,
277,
14,
8669,
2806,
342,
686,
198,
692,
440,
291,
14,
705,
47,
895,
581,
436,
291,
14,
1600,
3314,
8300,
26,
1585,
198,
277,
14,
6406,
342,
421,
198,
318,
9311,
8,
277,
304,
507,
198,
692,
291,
14,
1065,
508,
822,
8,
277,
14,
1760,
513,
304,
686,
198,
277,
14,
1600,
342,
686,
198,
277,
14,
3600,
14,
571,
15190,
14,
2168,
8,
277,
14,
1065,
13430,
9,
686,
198,
277,
14,
3600,
14,
576,
6651,
1054,
14,
2168,
8,
277,
14,
576,
6651,
1054,
9,
421,
198,
318,
666,
6651,
1054,
8,
277,
12,
620,
304,
507,
198,
2019,
1606,
275,
291,
905,
505,
4140,
374,
1271,
6090,
3276,
342,
507,
198,
277,
905,
505,
4140,
8341,
8,
277,
905,
505,
4140,
25506,
342,
435,
620,
9,
507,
198,
692,
2061,
1606,
26,
686,
198,
277,
905,
505,
4140,
2019,
3276,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
dessHub/bc-14-online-store-application
|
flask/lib/python2.7/site-packages/pip/_vendor/html5lib/_inputstream.py
|
328
|
32532
|
from __future__ import absolute_import, division, unicode_literals
from pip._vendor.six import text_type, binary_type
from pip._vendor.six.moves import http_client, urllib
import codecs
import re
from pip._vendor import webencodings
from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase
from .constants import ReparseException
from . import _utils
from io import StringIO
try:
from io import BytesIO
except ImportError:
BytesIO = StringIO
# Non-unicode versions of constants for use in the pre-parser
spaceCharactersBytes = frozenset([item.encode("ascii") for item in spaceCharacters])
asciiLettersBytes = frozenset([item.encode("ascii") for item in asciiLetters])
asciiUppercaseBytes = frozenset([item.encode("ascii") for item in asciiUppercase])
spacesAngleBrackets = spaceCharactersBytes | frozenset([b">", b"<"])
invalid_unicode_no_surrogate = "[\u0001-\u0008\u000B\u000E-\u001F\u007F-\u009F\uFDD0-\uFDEF\uFFFE\uFFFF\U0001FFFE\U0001FFFF\U0002FFFE\U0002FFFF\U0003FFFE\U0003FFFF\U0004FFFE\U0004FFFF\U0005FFFE\U0005FFFF\U0006FFFE\U0006FFFF\U0007FFFE\U0007FFFF\U0008FFFE\U0008FFFF\U0009FFFE\U0009FFFF\U000AFFFE\U000AFFFF\U000BFFFE\U000BFFFF\U000CFFFE\U000CFFFF\U000DFFFE\U000DFFFF\U000EFFFE\U000EFFFF\U000FFFFE\U000FFFFF\U0010FFFE\U0010FFFF]" # noqa
if _utils.supports_lone_surrogates:
# Use one extra step of indirection and create surrogates with
# eval. Not using this indirection would introduce an illegal
# unicode literal on platforms not supporting such lone
# surrogates.
assert invalid_unicode_no_surrogate[-1] == "]" and invalid_unicode_no_surrogate.count("]") == 1
invalid_unicode_re = re.compile(invalid_unicode_no_surrogate[:-1] +
eval('"\\uD800-\\uDFFF"') + # pylint:disable=eval-used
"]")
else:
invalid_unicode_re = re.compile(invalid_unicode_no_surrogate)
non_bmp_invalid_codepoints = set([0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE,
0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF,
0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE,
0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF,
0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE,
0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
0x10FFFE, 0x10FFFF])
ascii_punctuation_re = re.compile("[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]")
# Cache for charsUntil()
charsUntilRegEx = {}
class BufferedStream(object):
"""Buffering for streams that do not have buffering of their own
The buffer is implemented as a list of chunks on the assumption that
joining many strings will be slow since it is O(n**2)
"""
def __init__(self, stream):
self.stream = stream
self.buffer = []
self.position = [-1, 0] # chunk number, offset
def tell(self):
pos = 0
for chunk in self.buffer[:self.position[0]]:
pos += len(chunk)
pos += self.position[1]
return pos
def seek(self, pos):
assert pos <= self._bufferedBytes()
offset = pos
i = 0
while len(self.buffer[i]) < offset:
offset -= len(self.buffer[i])
i += 1
self.position = [i, offset]
def read(self, bytes):
if not self.buffer:
return self._readStream(bytes)
elif (self.position[0] == len(self.buffer) and
self.position[1] == len(self.buffer[-1])):
return self._readStream(bytes)
else:
return self._readFromBuffer(bytes)
def _bufferedBytes(self):
return sum([len(item) for item in self.buffer])
def _readStream(self, bytes):
data = self.stream.read(bytes)
self.buffer.append(data)
self.position[0] += 1
self.position[1] = len(data)
return data
def _readFromBuffer(self, bytes):
remainingBytes = bytes
rv = []
bufferIndex = self.position[0]
bufferOffset = self.position[1]
while bufferIndex < len(self.buffer) and remainingBytes != 0:
assert remainingBytes > 0
bufferedData = self.buffer[bufferIndex]
if remainingBytes <= len(bufferedData) - bufferOffset:
bytesToRead = remainingBytes
self.position = [bufferIndex, bufferOffset + bytesToRead]
else:
bytesToRead = len(bufferedData) - bufferOffset
self.position = [bufferIndex, len(bufferedData)]
bufferIndex += 1
rv.append(bufferedData[bufferOffset:bufferOffset + bytesToRead])
remainingBytes -= bytesToRead
bufferOffset = 0
if remainingBytes:
rv.append(self._readStream(remainingBytes))
return b"".join(rv)
def HTMLInputStream(source, **kwargs):
# Work around Python bug #20007: read(0) closes the connection.
# http://bugs.python.org/issue20007
if (isinstance(source, http_client.HTTPResponse) or
# Also check for addinfourl wrapping HTTPResponse
(isinstance(source, urllib.response.addbase) and
isinstance(source.fp, http_client.HTTPResponse))):
isUnicode = False
elif hasattr(source, "read"):
isUnicode = isinstance(source.read(0), text_type)
else:
isUnicode = isinstance(source, text_type)
if isUnicode:
encodings = [x for x in kwargs if x.endswith("_encoding")]
if encodings:
raise TypeError("Cannot set an encoding with a unicode input, set %r" % encodings)
return HTMLUnicodeInputStream(source, **kwargs)
else:
return HTMLBinaryInputStream(source, **kwargs)
class HTMLUnicodeInputStream(object):
"""Provides a unicode stream of characters to the HTMLTokenizer.
This class takes care of character encoding and removing or replacing
incorrect byte-sequences and also provides column and line tracking.
"""
_defaultChunkSize = 10240
def __init__(self, source):
"""Initialises the HTMLInputStream.
HTMLInputStream(source, [encoding]) -> Normalized stream from source
for use by html5lib.
source can be either a file-object, local filename or a string.
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will be used,
regardless of any BOM or later declaration (such as in a meta
element)
"""
if not _utils.supports_lone_surrogates:
# Such platforms will have already checked for such
# surrogate errors, so no need to do this checking.
self.reportCharacterErrors = None
elif len("\U0010FFFF") == 1:
self.reportCharacterErrors = self.characterErrorsUCS4
else:
self.reportCharacterErrors = self.characterErrorsUCS2
# List of where new lines occur
self.newLines = [0]
self.charEncoding = (lookupEncoding("utf-8"), "certain")
self.dataStream = self.openStream(source)
self.reset()
def reset(self):
self.chunk = ""
self.chunkSize = 0
self.chunkOffset = 0
self.errors = []
# number of (complete) lines in previous chunks
self.prevNumLines = 0
# number of columns in the last line of the previous chunk
self.prevNumCols = 0
# Deal with CR LF and surrogates split over chunk boundaries
self._bufferedCharacter = None
def openStream(self, source):
"""Produces a file object from source.
source can be either a file object, local filename or a string.
"""
# Already a file object
if hasattr(source, 'read'):
stream = source
else:
stream = StringIO(source)
return stream
def _position(self, offset):
chunk = self.chunk
nLines = chunk.count('\n', 0, offset)
positionLine = self.prevNumLines + nLines
lastLinePos = chunk.rfind('\n', 0, offset)
if lastLinePos == -1:
positionColumn = self.prevNumCols + offset
else:
positionColumn = offset - (lastLinePos + 1)
return (positionLine, positionColumn)
def position(self):
"""Returns (line, col) of the current position in the stream."""
line, col = self._position(self.chunkOffset)
return (line + 1, col)
def char(self):
""" Read one character from the stream or queue if available. Return
EOF when EOF is reached.
"""
# Read a new chunk from the input stream if necessary
if self.chunkOffset >= self.chunkSize:
if not self.readChunk():
return EOF
chunkOffset = self.chunkOffset
char = self.chunk[chunkOffset]
self.chunkOffset = chunkOffset + 1
return char
def readChunk(self, chunkSize=None):
if chunkSize is None:
chunkSize = self._defaultChunkSize
self.prevNumLines, self.prevNumCols = self._position(self.chunkSize)
self.chunk = ""
self.chunkSize = 0
self.chunkOffset = 0
data = self.dataStream.read(chunkSize)
# Deal with CR LF and surrogates broken across chunks
if self._bufferedCharacter:
data = self._bufferedCharacter + data
self._bufferedCharacter = None
elif not data:
# We have no more data, bye-bye stream
return False
if len(data) > 1:
lastv = ord(data[-1])
if lastv == 0x0D or 0xD800 <= lastv <= 0xDBFF:
self._bufferedCharacter = data[-1]
data = data[:-1]
if self.reportCharacterErrors:
self.reportCharacterErrors(data)
# Replace invalid characters
data = data.replace("\r\n", "\n")
data = data.replace("\r", "\n")
self.chunk = data
self.chunkSize = len(data)
return True
def characterErrorsUCS4(self, data):
for _ in range(len(invalid_unicode_re.findall(data))):
self.errors.append("invalid-codepoint")
def characterErrorsUCS2(self, data):
# Someone picked the wrong compile option
# You lose
skip = False
for match in invalid_unicode_re.finditer(data):
if skip:
continue
codepoint = ord(match.group())
pos = match.start()
# Pretty sure there should be endianness issues here
if _utils.isSurrogatePair(data[pos:pos + 2]):
# We have a surrogate pair!
char_val = _utils.surrogatePairToCodepoint(data[pos:pos + 2])
if char_val in non_bmp_invalid_codepoints:
self.errors.append("invalid-codepoint")
skip = True
elif (codepoint >= 0xD800 and codepoint <= 0xDFFF and
pos == len(data) - 1):
self.errors.append("invalid-codepoint")
else:
skip = False
self.errors.append("invalid-codepoint")
def charsUntil(self, characters, opposite=False):
""" Returns a string of characters from the stream up to but not
including any character in 'characters' or EOF. 'characters' must be
a container that supports the 'in' method and iteration over its
characters.
"""
# Use a cache of regexps to find the required characters
try:
chars = charsUntilRegEx[(characters, opposite)]
except KeyError:
if __debug__:
for c in characters:
assert(ord(c) < 128)
regex = "".join(["\\x%02x" % ord(c) for c in characters])
if not opposite:
regex = "^%s" % regex
chars = charsUntilRegEx[(characters, opposite)] = re.compile("[%s]+" % regex)
rv = []
while True:
# Find the longest matching prefix
m = chars.match(self.chunk, self.chunkOffset)
if m is None:
# If nothing matched, and it wasn't because we ran out of chunk,
# then stop
if self.chunkOffset != self.chunkSize:
break
else:
end = m.end()
# If not the whole chunk matched, return everything
# up to the part that didn't match
if end != self.chunkSize:
rv.append(self.chunk[self.chunkOffset:end])
self.chunkOffset = end
break
# If the whole remainder of the chunk matched,
# use it all and read the next chunk
rv.append(self.chunk[self.chunkOffset:])
if not self.readChunk():
# Reached EOF
break
r = "".join(rv)
return r
def unget(self, char):
# Only one character is allowed to be ungotten at once - it must
# be consumed again before any further call to unget
if char is not None:
if self.chunkOffset == 0:
# unget is called quite rarely, so it's a good idea to do
# more work here if it saves a bit of work in the frequently
# called char and charsUntil.
# So, just prepend the ungotten character onto the current
# chunk:
self.chunk = char + self.chunk
self.chunkSize += 1
else:
self.chunkOffset -= 1
assert self.chunk[self.chunkOffset] == char
class HTMLBinaryInputStream(HTMLUnicodeInputStream):
"""Provides a unicode stream of characters to the HTMLTokenizer.
This class takes care of character encoding and removing or replacing
incorrect byte-sequences and also provides column and line tracking.
"""
def __init__(self, source, override_encoding=None, transport_encoding=None,
same_origin_parent_encoding=None, likely_encoding=None,
default_encoding="windows-1252", useChardet=True):
"""Initialises the HTMLInputStream.
HTMLInputStream(source, [encoding]) -> Normalized stream from source
for use by html5lib.
source can be either a file-object, local filename or a string.
The optional encoding parameter must be a string that indicates
the encoding. If specified, that encoding will be used,
regardless of any BOM or later declaration (such as in a meta
element)
"""
# Raw Stream - for unicode objects this will encode to utf-8 and set
# self.charEncoding as appropriate
self.rawStream = self.openStream(source)
HTMLUnicodeInputStream.__init__(self, self.rawStream)
# Encoding Information
# Number of bytes to use when looking for a meta element with
# encoding information
self.numBytesMeta = 1024
# Number of bytes to use when using detecting encoding using chardet
self.numBytesChardet = 100
# Things from args
self.override_encoding = override_encoding
self.transport_encoding = transport_encoding
self.same_origin_parent_encoding = same_origin_parent_encoding
self.likely_encoding = likely_encoding
self.default_encoding = default_encoding
# Determine encoding
self.charEncoding = self.determineEncoding(useChardet)
assert self.charEncoding[0] is not None
# Call superclass
self.reset()
def reset(self):
self.dataStream = self.charEncoding[0].codec_info.streamreader(self.rawStream, 'replace')
HTMLUnicodeInputStream.reset(self)
def openStream(self, source):
"""Produces a file object from source.
source can be either a file object, local filename or a string.
"""
# Already a file object
if hasattr(source, 'read'):
stream = source
else:
stream = BytesIO(source)
try:
stream.seek(stream.tell())
except: # pylint:disable=bare-except
stream = BufferedStream(stream)
return stream
def determineEncoding(self, chardet=True):
# BOMs take precedence over everything
# This will also read past the BOM if present
charEncoding = self.detectBOM(), "certain"
if charEncoding[0] is not None:
return charEncoding
# If we've been overriden, we've been overriden
charEncoding = lookupEncoding(self.override_encoding), "certain"
if charEncoding[0] is not None:
return charEncoding
# Now check the transport layer
charEncoding = lookupEncoding(self.transport_encoding), "certain"
if charEncoding[0] is not None:
return charEncoding
# Look for meta elements with encoding information
charEncoding = self.detectEncodingMeta(), "tentative"
if charEncoding[0] is not None:
return charEncoding
# Parent document encoding
charEncoding = lookupEncoding(self.same_origin_parent_encoding), "tentative"
if charEncoding[0] is not None and not charEncoding[0].name.startswith("utf-16"):
return charEncoding
# "likely" encoding
charEncoding = lookupEncoding(self.likely_encoding), "tentative"
if charEncoding[0] is not None:
return charEncoding
# Guess with chardet, if available
if chardet:
try:
from chardet.universaldetector import UniversalDetector
except ImportError:
pass
else:
buffers = []
detector = UniversalDetector()
while not detector.done:
buffer = self.rawStream.read(self.numBytesChardet)
assert isinstance(buffer, bytes)
if not buffer:
break
buffers.append(buffer)
detector.feed(buffer)
detector.close()
encoding = lookupEncoding(detector.result['encoding'])
self.rawStream.seek(0)
if encoding is not None:
return encoding, "tentative"
# Try the default encoding
charEncoding = lookupEncoding(self.default_encoding), "tentative"
if charEncoding[0] is not None:
return charEncoding
# Fallback to html5lib's default if even that hasn't worked
return lookupEncoding("windows-1252"), "tentative"
def changeEncoding(self, newEncoding):
assert self.charEncoding[1] != "certain"
newEncoding = lookupEncoding(newEncoding)
if newEncoding is None:
return
if newEncoding.name in ("utf-16be", "utf-16le"):
newEncoding = lookupEncoding("utf-8")
assert newEncoding is not None
elif newEncoding == self.charEncoding[0]:
self.charEncoding = (self.charEncoding[0], "certain")
else:
self.rawStream.seek(0)
self.charEncoding = (newEncoding, "certain")
self.reset()
raise ReparseException("Encoding changed from %s to %s" % (self.charEncoding[0], newEncoding))
def detectBOM(self):
"""Attempts to detect at BOM at the start of the stream. If
an encoding can be determined from the BOM return the name of the
encoding otherwise return None"""
bomDict = {
codecs.BOM_UTF8: 'utf-8',
codecs.BOM_UTF16_LE: 'utf-16le', codecs.BOM_UTF16_BE: 'utf-16be',
codecs.BOM_UTF32_LE: 'utf-32le', codecs.BOM_UTF32_BE: 'utf-32be'
}
# Go to beginning of file and read in 4 bytes
string = self.rawStream.read(4)
assert isinstance(string, bytes)
# Try detecting the BOM using bytes from the string
encoding = bomDict.get(string[:3]) # UTF-8
seek = 3
if not encoding:
# Need to detect UTF-32 before UTF-16
encoding = bomDict.get(string) # UTF-32
seek = 4
if not encoding:
encoding = bomDict.get(string[:2]) # UTF-16
seek = 2
# Set the read position past the BOM if one was found, otherwise
# set it to the start of the stream
if encoding:
self.rawStream.seek(seek)
return lookupEncoding(encoding)
else:
self.rawStream.seek(0)
return None
def detectEncodingMeta(self):
"""Report the encoding declared by the meta element
"""
buffer = self.rawStream.read(self.numBytesMeta)
assert isinstance(buffer, bytes)
parser = EncodingParser(buffer)
self.rawStream.seek(0)
encoding = parser.getEncoding()
if encoding is not None and encoding.name in ("utf-16be", "utf-16le"):
encoding = lookupEncoding("utf-8")
return encoding
class EncodingBytes(bytes):
"""String-like object with an associated position and various extra methods
If the position is ever greater than the string length then an exception is
raised"""
def __new__(self, value):
assert isinstance(value, bytes)
return bytes.__new__(self, value.lower())
def __init__(self, value):
# pylint:disable=unused-argument
self._position = -1
def __iter__(self):
return self
def __next__(self):
p = self._position = self._position + 1
if p >= len(self):
raise StopIteration
elif p < 0:
raise TypeError
return self[p:p + 1]
def next(self):
# Py2 compat
return self.__next__()
def previous(self):
p = self._position
if p >= len(self):
raise StopIteration
elif p < 0:
raise TypeError
self._position = p = p - 1
return self[p:p + 1]
def setPosition(self, position):
if self._position >= len(self):
raise StopIteration
self._position = position
def getPosition(self):
if self._position >= len(self):
raise StopIteration
if self._position >= 0:
return self._position
else:
return None
position = property(getPosition, setPosition)
def getCurrentByte(self):
return self[self.position:self.position + 1]
currentByte = property(getCurrentByte)
def skip(self, chars=spaceCharactersBytes):
"""Skip past a list of characters"""
p = self.position # use property for the error-checking
while p < len(self):
c = self[p:p + 1]
if c not in chars:
self._position = p
return c
p += 1
self._position = p
return None
def skipUntil(self, chars):
p = self.position
while p < len(self):
c = self[p:p + 1]
if c in chars:
self._position = p
return c
p += 1
self._position = p
return None
def matchBytes(self, bytes):
"""Look for a sequence of bytes at the start of a string. If the bytes
are found return True and advance the position to the byte after the
match. Otherwise return False and leave the position alone"""
p = self.position
data = self[p:p + len(bytes)]
rv = data.startswith(bytes)
if rv:
self.position += len(bytes)
return rv
def jumpTo(self, bytes):
"""Look for the next sequence of bytes matching a given sequence. If
a match is found advance the position to the last byte of the match"""
newPosition = self[self.position:].find(bytes)
if newPosition > -1:
# XXX: This is ugly, but I can't see a nicer way to fix this.
if self._position == -1:
self._position = 0
self._position += (newPosition + len(bytes) - 1)
return True
else:
raise StopIteration
class EncodingParser(object):
"""Mini parser for detecting character encoding from meta elements"""
def __init__(self, data):
"""string - the data to work on for encoding detection"""
self.data = EncodingBytes(data)
self.encoding = None
def getEncoding(self):
methodDispatch = (
(b"<!--", self.handleComment),
(b"<meta", self.handleMeta),
(b"</", self.handlePossibleEndTag),
(b"<!", self.handleOther),
(b"<?", self.handleOther),
(b"<", self.handlePossibleStartTag))
for _ in self.data:
keepParsing = True
for key, method in methodDispatch:
if self.data.matchBytes(key):
try:
keepParsing = method()
break
except StopIteration:
keepParsing = False
break
if not keepParsing:
break
return self.encoding
def handleComment(self):
"""Skip over comments"""
return self.data.jumpTo(b"-->")
def handleMeta(self):
if self.data.currentByte not in spaceCharactersBytes:
# if we have <meta not followed by a space so just keep going
return True
# We have a valid meta element we want to search for attributes
hasPragma = False
pendingEncoding = None
while True:
# Try to find the next attribute after the current position
attr = self.getAttribute()
if attr is None:
return True
else:
if attr[0] == b"http-equiv":
hasPragma = attr[1] == b"content-type"
if hasPragma and pendingEncoding is not None:
self.encoding = pendingEncoding
return False
elif attr[0] == b"charset":
tentativeEncoding = attr[1]
codec = lookupEncoding(tentativeEncoding)
if codec is not None:
self.encoding = codec
return False
elif attr[0] == b"content":
contentParser = ContentAttrParser(EncodingBytes(attr[1]))
tentativeEncoding = contentParser.parse()
if tentativeEncoding is not None:
codec = lookupEncoding(tentativeEncoding)
if codec is not None:
if hasPragma:
self.encoding = codec
return False
else:
pendingEncoding = codec
def handlePossibleStartTag(self):
return self.handlePossibleTag(False)
def handlePossibleEndTag(self):
next(self.data)
return self.handlePossibleTag(True)
def handlePossibleTag(self, endTag):
data = self.data
if data.currentByte not in asciiLettersBytes:
# If the next byte is not an ascii letter either ignore this
# fragment (possible start tag case) or treat it according to
# handleOther
if endTag:
data.previous()
self.handleOther()
return True
c = data.skipUntil(spacesAngleBrackets)
if c == b"<":
# return to the first step in the overall "two step" algorithm
# reprocessing the < byte
data.previous()
else:
# Read all attributes
attr = self.getAttribute()
while attr is not None:
attr = self.getAttribute()
return True
def handleOther(self):
return self.data.jumpTo(b">")
def getAttribute(self):
"""Return a name,value pair for the next attribute in the stream,
if one is found, or None"""
data = self.data
# Step 1 (skip chars)
c = data.skip(spaceCharactersBytes | frozenset([b"/"]))
assert c is None or len(c) == 1
# Step 2
if c in (b">", None):
return None
# Step 3
attrName = []
attrValue = []
# Step 4 attribute name
while True:
if c == b"=" and attrName:
break
elif c in spaceCharactersBytes:
# Step 6!
c = data.skip()
break
elif c in (b"/", b">"):
return b"".join(attrName), b""
elif c in asciiUppercaseBytes:
attrName.append(c.lower())
elif c is None:
return None
else:
attrName.append(c)
# Step 5
c = next(data)
# Step 7
if c != b"=":
data.previous()
return b"".join(attrName), b""
# Step 8
next(data)
# Step 9
c = data.skip()
# Step 10
if c in (b"'", b'"'):
# 10.1
quoteChar = c
while True:
# 10.2
c = next(data)
# 10.3
if c == quoteChar:
next(data)
return b"".join(attrName), b"".join(attrValue)
# 10.4
elif c in asciiUppercaseBytes:
attrValue.append(c.lower())
# 10.5
else:
attrValue.append(c)
elif c == b">":
return b"".join(attrName), b""
elif c in asciiUppercaseBytes:
attrValue.append(c.lower())
elif c is None:
return None
else:
attrValue.append(c)
# Step 11
while True:
c = next(data)
if c in spacesAngleBrackets:
return b"".join(attrName), b"".join(attrValue)
elif c in asciiUppercaseBytes:
attrValue.append(c.lower())
elif c is None:
return None
else:
attrValue.append(c)
class ContentAttrParser(object):
def __init__(self, data):
assert isinstance(data, bytes)
self.data = data
def parse(self):
try:
# Check if the attr name is charset
# otherwise return
self.data.jumpTo(b"charset")
self.data.position += 1
self.data.skip()
if not self.data.currentByte == b"=":
# If there is no = sign keep looking for attrs
return None
self.data.position += 1
self.data.skip()
# Look for an encoding between matching quote marks
if self.data.currentByte in (b'"', b"'"):
quoteMark = self.data.currentByte
self.data.position += 1
oldPosition = self.data.position
if self.data.jumpTo(quoteMark):
return self.data[oldPosition:self.data.position]
else:
return None
else:
# Unquoted value
oldPosition = self.data.position
try:
self.data.skipUntil(spaceCharactersBytes)
return self.data[oldPosition:self.data.position]
except StopIteration:
# Return the whole remaining value
return self.data[oldPosition:]
except StopIteration:
return None
def lookupEncoding(encoding):
"""Return the python codec name corresponding to an encoding or None if the
string doesn't correspond to a valid encoding."""
if isinstance(encoding, binary_type):
try:
encoding = encoding.decode("ascii")
except UnicodeDecodeError:
return None
if encoding is not None:
try:
return webencodings.lookup(encoding)
except AttributeError:
return None
else:
return None
|
gpl-3.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
504,
7305,
423,
9884,
14,
4174,
492,
1318,
63,
466,
12,
3366,
63,
466,
199,
504,
7305,
423,
9884,
14,
4174,
14,
4912,
492,
1455,
63,
1258,
12,
4011,
199,
199,
646,
6010,
199,
646,
295,
199,
199,
504,
7305,
423,
9884,
492,
3330,
21138,
199,
199,
504,
1275,
5559,
492,
9027,
12,
25431,
12,
13294,
28760,
12,
13294,
19316,
2546,
199,
504,
1275,
5559,
492,
799,
1122,
1726,
199,
504,
1275,
492,
485,
1208,
199,
199,
504,
5890,
492,
5228,
199,
199,
893,
26,
272,
687,
5890,
492,
11808,
199,
2590,
3545,
26,
272,
11808,
275,
5228,
199,
199,
3,
10172,
13,
2975,
5459,
402,
5262,
367,
675,
315,
314,
876,
13,
2087,
199,
2638,
9272,
5571,
275,
9522,
779,
1053,
14,
2143,
480,
4371,
531,
367,
1242,
315,
25431,
566,
199,
4371,
28760,
5571,
275,
9522,
779,
1053,
14,
2143,
480,
4371,
531,
367,
1242,
315,
13294,
28760,
566,
199,
4371,
19316,
2546,
5571,
275,
9522,
779,
1053,
14,
2143,
480,
4371,
531,
367,
1242,
315,
13294,
19316,
2546,
566,
199,
10749,
16943,
29418,
83,
275,
25431,
5571,
1204,
9522,
779,
66,
1743,
401,
330,
17030,
3135,
421,
199,
3197,
63,
2975,
63,
889,
63,
16380,
275,
298,
7023,
85,
4183,
2696,
85,
19141,
60,
85,
1493,
34,
60,
85,
1493,
37,
2696,
85,
4587,
38,
60,
85,
8255,
38,
2696,
85,
8581,
38,
60,
19872,
5745,
16,
2696,
19872,
5638,
60,
15347,
5100,
60,
85,
6968,
60,
53,
4183,
27897,
60,
53,
4183,
6968,
60,
53,
9425,
27897,
60,
53,
9425,
6968,
60,
53,
16861,
27897,
60,
53,
16861,
6968,
60,
53,
16643,
27897,
60,
53,
16643,
6968,
60,
53,
15646,
27897,
60,
53,
15646,
6968,
60,
53,
20965,
27897,
60,
53,
20965,
6968,
60,
53,
22530,
27897,
60,
53,
22530,
6968,
60,
53,
19141,
27897,
60,
53,
19141,
6968,
60,
53,
21144,
27897,
60,
53,
21144,
6968,
60,
53,
1493,
25900,
5100,
60,
53,
1493,
33,
6968,
60,
53,
1493,
34,
27897,
60,
53,
1493,
34,
6968,
60,
53,
1493,
35,
27897,
60,
53,
1493,
35,
6968,
60,
53,
1493,
36,
27897,
60,
53,
1493,
36,
6968,
60,
53,
1493,
37,
27897,
60,
53,
1493,
37,
6968,
60,
53,
1493,
6968,
37,
60,
53,
1493,
6968,
38,
60,
53,
17657,
27897,
60,
53,
17657,
6968,
8480,
221,
327,
8151,
199,
199,
692,
485,
1208,
14,
9823,
63,
76,
368,
63,
5105,
19029,
2335,
26,
272,
327,
3645,
1373,
2402,
3650,
402,
2539,
4017,
436,
1218,
6296,
19029,
2335,
543,
272,
327,
3468,
14,
2832,
1808,
642,
2539,
4017,
3955,
13318,
3402,
376,
20282,
272,
327,
2649,
8785,
641,
10677,
440,
21038,
4066,
634,
368,
272,
327,
6296,
19029,
2335,
14,
272,
702,
3866,
63,
2975,
63,
889,
63,
16380,
1988,
17,
61,
508,
298,
8480,
436,
3866,
63,
2975,
63,
889,
63,
16380,
14,
835,
480,
12523,
508,
413,
272,
3866,
63,
2975,
63,
264,
275,
295,
14,
2014,
8,
3197,
63,
2975,
63,
889,
63,
16380,
4439,
17,
61,
435,
2511,
3468,
14088,
1103,
18867,
6718,
31206,
18867,
24254,
9008,
435,
221,
327,
4287,
26,
5993,
29,
2579,
13,
2972,
2511,
298,
12523,
199,
2836,
26,
272,
3866,
63,
2975,
63,
264,
275,
295,
14,
2014,
8,
3197,
63,
2975,
63,
889,
63,
16380,
9,
199,
199,
2865,
63,
22308,
63,
3197,
63,
600,
3438,
275,
663,
779,
16,
88,
17,
27897,
12,
378,
88,
17,
6968,
12,
378,
88,
18,
27897,
12,
378,
88,
18,
6968,
12,
378,
88,
19,
27897,
12,
3303,
378,
88,
19,
6968,
12,
378,
88,
20,
27897,
12,
378,
88,
20,
6968,
12,
378,
88,
21,
27897,
12,
378,
88,
21,
6968,
12,
3303,
378,
88,
22,
27897,
12,
378,
88,
22,
6968,
12,
378,
88,
23,
27897,
12,
378,
88,
23,
6968,
12,
378,
88,
24,
27897,
12,
3303,
378,
88,
24,
6968,
12,
378,
88,
25,
27897,
12,
378,
88,
25,
6968,
12,
378,
7471,
27897,
12,
378,
7471,
6968,
12,
3303,
378,
8094,
27897,
12,
378,
8094,
6968,
12,
378,
8163,
27897,
12,
378,
8163,
6968,
12,
378,
8313,
27897,
12,
3303,
378,
8313,
6968,
12,
378,
6991,
27897,
12,
378,
6991,
6968,
12,
378,
23973,
37,
12,
378,
23973,
38,
12,
3303,
378,
88,
709,
27897,
12,
378,
88,
709,
6968,
566,
199,
199,
4371,
63,
25181,
63,
264,
275,
295,
14,
2014,
480,
7023,
85,
21144,
2696,
85,
1493,
36,
60,
85,
20734,
2696,
85,
7432,
38,
60,
85,
8262,
33,
2696,
85,
25665,
60,
85,
7972,
34,
2696,
85,
29120,
60,
85,
8255,
34,
2696,
85,
8255,
37,
12523,
199,
199,
3,
11977,
367,
8365,
18667,
342,
199,
6574,
18667,
2872,
920,
275,
1052,
421,
199,
533,
26832,
3296,
8,
785,
304,
272,
408,
3299,
316,
367,
13788,
626,
886,
440,
1172,
21033,
402,
3932,
5705,
339,
710,
3335,
365,
6366,
465,
282,
769,
402,
8291,
641,
314,
30075,
626,
272,
4263,
316,
5002,
3326,
911,
506,
11999,
3967,
652,
365,
593,
8,
78,
538,
18,
9,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2547,
304,
267,
291,
14,
1745,
275,
2547,
267,
291,
14,
2738,
275,
942,
267,
291,
14,
3124,
275,
5243,
17,
12,
378,
61,
221,
327,
3728,
1329,
12,
3268,
339,
347,
11480,
8,
277,
304,
267,
2086,
275,
378,
267,
367,
3728,
315,
291,
14,
2738,
1491,
277,
14,
3124,
59,
16,
27589,
288,
2086,
847,
822,
8,
4604,
9,
267,
2086,
847,
291,
14,
3124,
59,
17,
61,
267,
372,
2086,
339,
347,
12005,
8,
277,
12,
2086,
304,
267,
702,
2086,
2695,
291,
423,
17605,
5571,
342,
267,
3268,
275,
2086,
267,
284,
275,
378,
267,
1830,
822,
8,
277,
14,
2738,
59,
73,
566,
665,
3268,
26,
288,
3268,
4862,
822,
8,
277,
14,
2738,
59,
73,
566,
288,
284,
847,
413,
267,
291,
14,
3124,
275,
359,
73,
12,
3268,
61,
339,
347,
1586,
8,
277,
12,
2783,
304,
267,
340,
440,
291,
14,
2738,
26,
288,
372,
291,
423,
739,
3296,
8,
2394,
9,
267,
916,
334,
277,
14,
3124,
59,
16,
61,
508,
822,
8,
277,
14,
2738
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
504,
7305,
423,
9884,
14,
4174,
492,
1318,
63,
466,
12,
3366,
63,
466,
199,
504,
7305,
423,
9884,
14,
4174,
14,
4912,
492,
1455,
63,
1258,
12,
4011,
199,
199,
646,
6010,
199,
646,
295,
199,
199,
504,
7305,
423,
9884,
492,
3330,
21138,
199,
199,
504,
1275,
5559,
492,
9027,
12,
25431,
12,
13294,
28760,
12,
13294,
19316,
2546,
199,
504,
1275,
5559,
492,
799,
1122,
1726,
199,
504,
1275,
492,
485,
1208,
199,
199,
504,
5890,
492,
5228,
199,
199,
893,
26,
272,
687,
5890,
492,
11808,
199,
2590,
3545,
26,
272,
11808,
275,
5228,
199,
199,
3,
10172,
13,
2975,
5459,
402,
5262,
367,
675,
315,
314,
876,
13,
2087,
199,
2638,
9272,
5571,
275,
9522,
779,
1053,
14,
2143,
480,
4371,
531,
367,
1242,
315,
25431,
566,
199,
4371,
28760,
5571,
275,
9522,
779,
1053,
14,
2143,
480,
4371,
531,
367,
1242,
315,
13294,
28760,
566,
199,
4371,
19316,
2546,
5571,
275,
9522,
779,
1053,
14,
2143,
480,
4371,
531,
367,
1242,
315,
13294,
19316,
2546,
566,
199,
10749,
16943,
29418,
83,
275,
25431,
5571,
1204,
9522,
779,
66,
1743,
401,
330,
17030,
3135,
421,
199,
3197,
63,
2975,
63,
889,
63,
16380,
275,
298,
7023,
85,
4183,
2696,
85,
19141,
60,
85,
1493,
34,
60,
85,
1493,
37,
2696,
85,
4587,
38,
60,
85,
8255,
38,
2696,
85,
8581,
38,
60,
19872,
5745,
16,
2696,
19872,
5638,
60,
15347,
5100,
60,
85,
6968,
60,
53,
4183,
27897,
60,
53,
4183,
6968,
60,
53,
9425,
27897,
60,
53,
9425,
6968,
60,
53,
16861,
27897,
60,
53,
16861,
6968,
60,
53,
16643,
27897,
60,
53,
16643,
6968,
60,
53,
15646,
27897,
60,
53,
15646,
6968,
60,
53,
20965,
27897,
60,
53,
20965,
6968,
60,
53,
22530,
27897,
60,
53,
22530,
6968,
60,
53,
19141,
27897,
60,
53,
19141,
6968,
60,
53,
21144,
27897,
60,
53,
21144,
6968,
60,
53,
1493,
25900,
5100,
60,
53,
1493,
33,
6968,
60,
53,
1493,
34,
27897,
60,
53,
1493,
34,
6968,
60,
53,
1493,
35,
27897,
60,
53,
1493,
35,
6968,
60,
53,
1493,
36,
27897,
60,
53,
1493,
36,
6968,
60,
53,
1493,
37,
27897,
60,
53,
1493,
37,
6968,
60,
53,
1493,
6968,
37,
60,
53,
1493,
6968,
38,
60,
53,
17657,
27897,
60,
53,
17657,
6968,
8480,
221,
327,
8151,
199,
199,
692,
485,
1208,
14,
9823,
63,
76,
368,
63,
5105,
19029,
2335,
26,
272,
327,
3645,
1373,
2402,
3650,
402,
2539,
4017,
436,
1218,
6296,
19029,
2335,
543,
272,
327,
3468,
14,
2832,
1808,
642,
2539,
4017,
3955,
13318,
3402,
376,
20282,
272,
327,
2649,
8785,
641,
10677,
440,
21038,
4066,
634,
368,
272,
327,
6296,
19029,
2335,
14,
272,
702,
3866,
63,
2975,
63,
889,
63,
16380,
1988,
17,
61,
508,
298,
8480,
436,
3866,
63,
2975,
63,
889,
63,
16380,
14,
835,
480,
12523,
508,
413,
272,
3866,
63,
2975,
63,
264,
275,
295,
14,
2014,
8,
3197,
63,
2975,
63,
889,
63,
16380,
4439,
17,
61,
435,
2511,
3468,
14088,
1103,
18867,
6718,
31206,
18867,
24254,
9008,
435,
221,
327,
4287,
26,
5993,
29,
2579,
13,
2972,
2511,
298,
12523,
199,
2836,
26,
272,
3866,
63,
2975,
63,
264,
275,
295,
14,
2014,
8,
3197,
63,
2975,
63,
889,
63,
16380,
9,
199,
199,
2865,
63,
22308,
63,
3197,
63,
600,
3438,
275,
663,
779,
16,
88,
17,
27897,
12,
378,
88,
17,
6968,
12,
378,
88,
18,
27897,
12,
378,
88,
18,
6968,
12,
378,
88,
19,
27897,
12,
3303,
378,
88,
19,
6968,
12,
378,
88,
20,
27897,
12,
378,
88,
20,
6968,
12,
378,
88,
21,
27897,
12,
378,
88,
21,
6968,
12,
3303,
378,
88,
22,
27897,
12,
378,
88,
22,
6968,
12,
378,
88,
23,
27897,
12,
378,
88,
23,
6968,
12,
378,
88,
24,
27897,
12,
3303,
378,
88,
24,
6968,
12,
378,
88,
25,
27897,
12,
378,
88,
25,
6968,
12,
378,
7471,
27897,
12,
378,
7471,
6968,
12,
3303,
378,
8094,
27897,
12,
378,
8094,
6968,
12,
378,
8163,
27897,
12,
378,
8163,
6968,
12,
378,
8313,
27897,
12,
3303,
378,
8313,
6968,
12,
378,
6991,
27897,
12,
378,
6991,
6968,
12,
378,
23973,
37,
12,
378,
23973,
38,
12,
3303,
378,
88,
709,
27897,
12,
378,
88,
709,
6968,
566,
199,
199,
4371,
63,
25181,
63,
264,
275,
295,
14,
2014,
480,
7023,
85,
21144,
2696,
85,
1493,
36,
60,
85,
20734,
2696,
85,
7432,
38,
60,
85,
8262,
33,
2696,
85,
25665,
60,
85,
7972,
34,
2696,
85,
29120,
60,
85,
8255,
34,
2696,
85,
8255,
37,
12523,
199,
199,
3,
11977,
367,
8365,
18667,
342,
199,
6574,
18667,
2872,
920,
275,
1052,
421,
199,
533,
26832,
3296,
8,
785,
304,
272,
408,
3299,
316,
367,
13788,
626,
886,
440,
1172,
21033,
402,
3932,
5705,
339,
710,
3335,
365,
6366,
465,
282,
769,
402,
8291,
641,
314,
30075,
626,
272,
4263,
316,
5002,
3326,
911,
506,
11999,
3967,
652,
365,
593,
8,
78,
538,
18,
9,
272,
408,
339,
347,
636,
826,
721,
277,
12,
2547,
304,
267,
291,
14,
1745,
275,
2547,
267,
291,
14,
2738,
275,
942,
267,
291,
14,
3124,
275,
5243,
17,
12,
378,
61,
221,
327,
3728,
1329,
12,
3268,
339,
347,
11480,
8,
277,
304,
267,
2086,
275,
378,
267,
367,
3728,
315,
291,
14,
2738,
1491,
277,
14,
3124,
59,
16,
27589,
288,
2086,
847,
822,
8,
4604,
9,
267,
2086,
847,
291,
14,
3124,
59,
17,
61,
267,
372,
2086,
339,
347,
12005,
8,
277,
12,
2086,
304,
267,
702,
2086,
2695,
291,
423,
17605,
5571,
342,
267,
3268,
275,
2086,
267,
284,
275,
378,
267,
1830,
822,
8,
277,
14,
2738,
59,
73,
566,
665,
3268,
26,
288,
3268,
4862,
822,
8,
277,
14,
2738,
59,
73,
566,
288,
284,
847,
413,
267,
291,
14,
3124,
275,
359,
73,
12,
3268,
61,
339,
347,
1586,
8,
277,
12,
2783,
304,
267,
340,
440,
291,
14,
2738,
26,
288,
372,
291,
423,
739,
3296,
8,
2394,
9,
267,
916,
334,
277,
14,
3124,
59,
16,
61,
508,
822,
8,
277,
14,
2738,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
QualiSystems/AWS-Shell
|
package/tests/test_domain_services/test_instance_waiter.py
|
1
|
6035
|
from unittest import TestCase
from mock import Mock, patch
from cloudshell.cp.aws.domain.services.waiters.instance import InstanceWaiter
instance = Mock()
instance.state = {'Name': ''}
class helper:
@staticmethod
def change_to_terminate(a):
instance.state['Name'] = InstanceWaiter.TERMINATED
@staticmethod
def change_to_stopped(a):
instance.state['Name'] = InstanceWaiter.STOPPED
@staticmethod
def change_to_running(a):
instance.state['Name'] = InstanceWaiter.RUNNING
@staticmethod
def change_to_stopping(a):
instance.state['Name'] = InstanceWaiter.STOPPING
@staticmethod
def change_to_pending(a):
instance.state['Name'] = InstanceWaiter.PENDING
class TestInstanceWaiter(TestCase):
def setUp(self):
self.cancellation_service = Mock()
self.instance_waiter = InstanceWaiter(self.cancellation_service, 1, 0.02)
self.instance = Mock()
self.logger = Mock()
@patch('time.sleep', helper.change_to_stopped)
def test_waiter(self):
helper.change_to_running(Mock())
inst = self.instance_waiter.wait(instance, InstanceWaiter.STOPPED)
self.assertEqual(inst, instance)
self.assertEqual(inst.reload.call_count, 1)
def test_waiter_timeout(self):
helper.change_to_running(Mock())
self.assertRaises(Exception, self.instance_waiter.wait, instance, InstanceWaiter.STOPPED)
@patch('time.sleep', helper.change_to_stopped)
def test_waiter_multi(self):
helper.change_to_stopped(Mock())
instance.state['Name'] = InstanceWaiter.RUNNING
inst = Mock()
inst.state = dict()
inst.state['Name'] = InstanceWaiter.STOPPED
res = self.instance_waiter.multi_wait([instance, inst], InstanceWaiter.STOPPED)
self.assertEqual(res, [instance, inst])
self.assertTrue(instance.reload.call_count, 2)
@patch('time.sleep', helper.change_to_stopped)
def test_waiter_multi_with_cancellation(self):
cancellation_context = Mock()
helper.change_to_stopped(Mock())
instance.state['Name'] = InstanceWaiter.RUNNING
inst = Mock()
inst.state = dict()
inst.state['Name'] = InstanceWaiter.STOPPED
instances = [instance, inst]
res = self.instance_waiter.multi_wait(instances, InstanceWaiter.STOPPED, cancellation_context)
self.assertEqual(res, [instance, inst])
self.assertTrue(instance.reload.call_count, 2)
self.assertTrue(self.cancellation_service.check_if_cancelled.call_count, 2)
instance_ids = filter(lambda x: str(x.id), instances)
self.cancellation_service.check_if_cancelled.assert_called_with(cancellation_context,
{'instance_ids': instance_ids})
def test_waiter_multi_errors(self):
self.assertRaises(ValueError, self.instance_waiter.multi_wait, [], InstanceWaiter.STOPPED)
self.assertRaises(ValueError, self.instance_waiter.multi_wait, [Mock], 'blalala')
@patch('cloudshell.cp.aws.domain.services.waiters.instance.time')
def test_wait_status_ok(self, time):
# arrange
def describe_instance_status_handler(*args, **kwargs):
result = Mock()
instance_id_mock = kwargs['InstanceIds'][0]
if hasattr(instance_id_mock, "called_already") and instance_id_mock.called_already is True:
result.InstanceStatuses = [{'SystemStatus': {'Status': self.instance_waiter.STATUS_OK},
'InstanceStatus': {'Status': self.instance_waiter.STATUS_OK}}]
else:
instance_id_mock.called_already = True
result.InstanceStatuses = [
{'SystemStatus': {'Status': 'initializing'}, 'InstanceStatus': {'Status': 'initializing'}}]
return result
time.time.return_value = 0
ec2_client = Mock()
ec2_client.describe_instance_status = Mock(side_effect=describe_instance_status_handler)
instance = Mock()
# act
instance_state = self.instance_waiter.wait_status_ok(ec2_client=ec2_client,
instance=instance,
logger=self.logger)
# assert
self.assertEquals(instance_state['SystemStatus']['Status'], self.instance_waiter.STATUS_OK)
self.assertEquals(instance_state['InstanceStatus']['Status'], self.instance_waiter.STATUS_OK)
@patch('cloudshell.cp.aws.domain.services.waiters.instance.time')
def test_wait_status_ok_raises_impaired_status(self, time):
# arrange
def describe_instance_status_handler(*args, **kwargs):
result = Mock()
instance_id_mock = kwargs['InstanceIds'][0]
if hasattr(instance_id_mock, "called_already") and instance_id_mock.called_already is True:
result.InstanceStatuses = [{'SystemStatus': {'Status': self.instance_waiter.STATUS_IMPAIRED},
'InstanceStatus': {'Status': self.instance_waiter.STATUS_IMPAIRED}}]
else:
instance_id_mock.called_already = True
result.InstanceStatuses = [
{'SystemStatus': {'Status': 'initializing'}, 'InstanceStatus': {'Status': 'initializing'}}]
return result
time.time.return_value = 0
ec2_client = Mock()
ec2_client.describe_instance_status = Mock(side_effect=describe_instance_status_handler)
instance = Mock()
# act & assert
with self.assertRaisesRegexp(ValueError, "Instance status check is not OK.*"):
instance_state = self.instance_waiter.wait_status_ok(ec2_client=ec2_client,
instance=instance,
logger=self.logger)
|
isc
|
[
504,
2882,
492,
7640,
199,
504,
1683,
492,
4420,
12,
3371,
199,
199,
504,
8002,
5641,
14,
1850,
14,
7231,
14,
2261,
14,
5950,
14,
758,
15266,
14,
842,
492,
10066,
24804,
1661,
199,
199,
842,
275,
4420,
342,
199,
842,
14,
929,
275,
791,
985,
356,
28174,
421,
199,
533,
5922,
26,
272,
768,
4639,
272,
347,
1570,
63,
475,
63,
14478,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
28376,
6989,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
14661,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
19359,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
5720,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
17305,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
2379,
4073,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
15675,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
6455,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
21243,
421,
199,
533,
1379,
3244,
24804,
1661,
8,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
6406,
2212,
63,
1364,
275,
4420,
342,
267,
291,
14,
842,
63,
758,
1661,
275,
10066,
24804,
1661,
8,
277,
14,
6406,
2212,
63,
1364,
12,
413,
12,
378,
14,
996,
9,
267,
291,
14,
842,
275,
4420,
342,
267,
291,
14,
2921,
275,
4420,
342,
339,
768,
2068,
360,
521,
14,
4532,
297,
5922,
14,
1461,
63,
475,
63,
14661,
9,
272,
347,
511,
63,
758,
1661,
8,
277,
304,
267,
5922,
14,
1461,
63,
475,
63,
5720,
8,
3346,
1012,
267,
2727,
275,
291,
14,
842,
63,
758,
1661,
14,
2573,
8,
842,
12,
10066,
24804,
1661,
14,
11632,
19359,
9,
267,
291,
14,
629,
8,
3615,
12,
1256,
9,
267,
291,
14,
629,
8,
3615,
14,
9233,
14,
1250,
63,
835,
12,
413,
9,
339,
347,
511,
63,
758,
1661,
63,
2593,
8,
277,
304,
267,
5922,
14,
1461,
63,
475,
63,
5720,
8,
3346,
1012,
267,
291,
14,
1855,
8,
1726,
12,
291,
14,
842,
63,
758,
1661,
14,
2573,
12,
1256,
12,
10066,
24804,
1661,
14,
11632,
19359,
9,
339,
768,
2068,
360,
521,
14,
4532,
297,
5922,
14,
1461,
63,
475,
63,
14661,
9,
272,
347,
511,
63,
758,
1661,
63,
3029,
8,
277,
304,
267,
5922,
14,
1461,
63,
475,
63,
14661,
8,
3346,
1012,
398,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
17305,
398,
2727,
275,
4420,
342,
267,
2727,
14,
929,
275,
1211,
342,
267,
2727,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
19359,
398,
522,
275,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
779,
842,
12,
2727,
467,
10066,
24804,
1661,
14,
11632,
19359,
9,
267,
291,
14,
629,
8,
470,
12,
359,
842,
12,
2727,
566,
267,
291,
14,
1815,
8,
842,
14,
9233,
14,
1250,
63,
835,
12,
499,
9,
339,
768,
2068,
360,
521,
14,
4532,
297,
5922,
14,
1461,
63,
475,
63,
14661,
9,
272,
347,
511,
63,
758,
1661,
63,
3029,
63,
1045,
63,
6406,
2212,
8,
277,
304,
267,
9311,
2212,
63,
1100,
275,
4420,
342,
267,
5922,
14,
1461,
63,
475,
63,
14661,
8,
3346,
1012,
398,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
17305,
398,
2727,
275,
4420,
342,
267,
2727,
14,
929,
275,
1211,
342,
267,
2727,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
19359,
398,
4454,
275,
359,
842,
12,
2727,
61,
398,
522,
275,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
8,
5990,
12,
10066,
24804,
1661,
14,
11632,
19359,
12,
9311,
2212,
63,
1100,
9,
398,
291,
14,
629,
8,
470,
12,
359,
842,
12,
2727,
566,
267,
291,
14,
1815,
8,
842,
14,
9233,
14,
1250,
63,
835,
12,
499,
9,
267,
291,
14,
1815,
8,
277,
14,
6406,
2212,
63,
1364,
14,
1074,
63,
692,
63,
21924,
14,
1250,
63,
835,
12,
499,
9,
267,
1256,
63,
1580,
275,
2457,
8,
2734,
671,
26,
620,
8,
88,
14,
344,
395,
4454,
9,
267,
291,
14,
6406,
2212,
63,
1364,
14,
1074,
63,
692,
63,
21924,
14,
479,
63,
3527,
63,
1045,
8,
6406,
2212,
63,
1100,
12,
6684,
263,
791,
842,
63,
1580,
356,
1256,
63,
1580,
1552,
339,
347,
511,
63,
758,
1661,
63,
3029,
63,
2550,
8,
277,
304,
267,
291,
14,
1855,
8,
3393,
12,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
12,
990,
10066,
24804,
1661,
14,
11632,
19359,
9,
267,
291,
14,
1855,
8,
3393,
12,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
12,
359,
3346,
467,
283,
3345,
279,
14774,
358,
339,
768,
2068,
360,
4091,
5641,
14,
1850,
14,
7231,
14,
2261,
14,
5950,
14,
758,
15266,
14,
842,
14,
521,
358,
272,
347,
511,
63,
2573,
63,
1205,
63,
745,
8,
277,
12,
900,
304,
267,
327,
601,
1842,
267,
347,
13743,
63,
842,
63,
1205,
63,
2232,
2031,
589,
12,
1011,
958,
304,
288,
754,
275,
4420,
342,
288,
1256,
63,
344,
63,
1805,
275,
2074,
459,
3244,
11506,
3488,
16,
61,
288,
340,
2688,
8,
842,
63,
344,
63,
1805,
12,
298,
3527,
63,
14039,
531,
436,
1256,
63,
344,
63,
1805,
14,
3527,
63,
14039,
365,
715,
26,
355,
754,
14,
3244,
11232,
5589,
275,
9016,
3989,
3694,
356,
791,
3694,
356,
291,
14,
842,
63,
758,
1661,
14,
6305,
63,
3593,
1386,
4490,
283,
3244,
3694,
356,
791,
3694,
356,
291,
14,
842,
63,
758,
1661,
14,
6305,
63,
3593,
4863,
61,
288,
587,
26,
355,
1256,
63,
344,
63,
1805,
14,
3527,
63,
14039,
275,
715,
355,
754,
14,
3244,
11232,
5589,
275,
359,
490,
791,
3989,
3694,
356,
791,
3694,
356,
283,
2747,
9147,
2267,
283,
3244,
3694,
356,
791,
3694,
356,
283,
2747,
9147,
936,
11049,
953,
372,
754,
398,
900,
14,
521,
14,
1107,
63,
585,
275,
378,
267,
7062,
18,
63,
1258,
275,
4420,
342,
267,
7062,
18,
63
] |
[
2882,
492,
7640,
199,
504,
1683,
492,
4420,
12,
3371,
199,
199,
504,
8002,
5641,
14,
1850,
14,
7231,
14,
2261,
14,
5950,
14,
758,
15266,
14,
842,
492,
10066,
24804,
1661,
199,
199,
842,
275,
4420,
342,
199,
842,
14,
929,
275,
791,
985,
356,
28174,
421,
199,
533,
5922,
26,
272,
768,
4639,
272,
347,
1570,
63,
475,
63,
14478,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
28376,
6989,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
14661,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
19359,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
5720,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
17305,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
2379,
4073,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
15675,
339,
768,
4639,
272,
347,
1570,
63,
475,
63,
6455,
8,
65,
304,
267,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
21243,
421,
199,
533,
1379,
3244,
24804,
1661,
8,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
291,
14,
6406,
2212,
63,
1364,
275,
4420,
342,
267,
291,
14,
842,
63,
758,
1661,
275,
10066,
24804,
1661,
8,
277,
14,
6406,
2212,
63,
1364,
12,
413,
12,
378,
14,
996,
9,
267,
291,
14,
842,
275,
4420,
342,
267,
291,
14,
2921,
275,
4420,
342,
339,
768,
2068,
360,
521,
14,
4532,
297,
5922,
14,
1461,
63,
475,
63,
14661,
9,
272,
347,
511,
63,
758,
1661,
8,
277,
304,
267,
5922,
14,
1461,
63,
475,
63,
5720,
8,
3346,
1012,
267,
2727,
275,
291,
14,
842,
63,
758,
1661,
14,
2573,
8,
842,
12,
10066,
24804,
1661,
14,
11632,
19359,
9,
267,
291,
14,
629,
8,
3615,
12,
1256,
9,
267,
291,
14,
629,
8,
3615,
14,
9233,
14,
1250,
63,
835,
12,
413,
9,
339,
347,
511,
63,
758,
1661,
63,
2593,
8,
277,
304,
267,
5922,
14,
1461,
63,
475,
63,
5720,
8,
3346,
1012,
267,
291,
14,
1855,
8,
1726,
12,
291,
14,
842,
63,
758,
1661,
14,
2573,
12,
1256,
12,
10066,
24804,
1661,
14,
11632,
19359,
9,
339,
768,
2068,
360,
521,
14,
4532,
297,
5922,
14,
1461,
63,
475,
63,
14661,
9,
272,
347,
511,
63,
758,
1661,
63,
3029,
8,
277,
304,
267,
5922,
14,
1461,
63,
475,
63,
14661,
8,
3346,
1012,
398,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
17305,
398,
2727,
275,
4420,
342,
267,
2727,
14,
929,
275,
1211,
342,
267,
2727,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
19359,
398,
522,
275,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
779,
842,
12,
2727,
467,
10066,
24804,
1661,
14,
11632,
19359,
9,
267,
291,
14,
629,
8,
470,
12,
359,
842,
12,
2727,
566,
267,
291,
14,
1815,
8,
842,
14,
9233,
14,
1250,
63,
835,
12,
499,
9,
339,
768,
2068,
360,
521,
14,
4532,
297,
5922,
14,
1461,
63,
475,
63,
14661,
9,
272,
347,
511,
63,
758,
1661,
63,
3029,
63,
1045,
63,
6406,
2212,
8,
277,
304,
267,
9311,
2212,
63,
1100,
275,
4420,
342,
267,
5922,
14,
1461,
63,
475,
63,
14661,
8,
3346,
1012,
398,
1256,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
17305,
398,
2727,
275,
4420,
342,
267,
2727,
14,
929,
275,
1211,
342,
267,
2727,
14,
929,
459,
985,
418,
275,
10066,
24804,
1661,
14,
11632,
19359,
398,
4454,
275,
359,
842,
12,
2727,
61,
398,
522,
275,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
8,
5990,
12,
10066,
24804,
1661,
14,
11632,
19359,
12,
9311,
2212,
63,
1100,
9,
398,
291,
14,
629,
8,
470,
12,
359,
842,
12,
2727,
566,
267,
291,
14,
1815,
8,
842,
14,
9233,
14,
1250,
63,
835,
12,
499,
9,
267,
291,
14,
1815,
8,
277,
14,
6406,
2212,
63,
1364,
14,
1074,
63,
692,
63,
21924,
14,
1250,
63,
835,
12,
499,
9,
267,
1256,
63,
1580,
275,
2457,
8,
2734,
671,
26,
620,
8,
88,
14,
344,
395,
4454,
9,
267,
291,
14,
6406,
2212,
63,
1364,
14,
1074,
63,
692,
63,
21924,
14,
479,
63,
3527,
63,
1045,
8,
6406,
2212,
63,
1100,
12,
6684,
263,
791,
842,
63,
1580,
356,
1256,
63,
1580,
1552,
339,
347,
511,
63,
758,
1661,
63,
3029,
63,
2550,
8,
277,
304,
267,
291,
14,
1855,
8,
3393,
12,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
12,
990,
10066,
24804,
1661,
14,
11632,
19359,
9,
267,
291,
14,
1855,
8,
3393,
12,
291,
14,
842,
63,
758,
1661,
14,
3029,
63,
2573,
12,
359,
3346,
467,
283,
3345,
279,
14774,
358,
339,
768,
2068,
360,
4091,
5641,
14,
1850,
14,
7231,
14,
2261,
14,
5950,
14,
758,
15266,
14,
842,
14,
521,
358,
272,
347,
511,
63,
2573,
63,
1205,
63,
745,
8,
277,
12,
900,
304,
267,
327,
601,
1842,
267,
347,
13743,
63,
842,
63,
1205,
63,
2232,
2031,
589,
12,
1011,
958,
304,
288,
754,
275,
4420,
342,
288,
1256,
63,
344,
63,
1805,
275,
2074,
459,
3244,
11506,
3488,
16,
61,
288,
340,
2688,
8,
842,
63,
344,
63,
1805,
12,
298,
3527,
63,
14039,
531,
436,
1256,
63,
344,
63,
1805,
14,
3527,
63,
14039,
365,
715,
26,
355,
754,
14,
3244,
11232,
5589,
275,
9016,
3989,
3694,
356,
791,
3694,
356,
291,
14,
842,
63,
758,
1661,
14,
6305,
63,
3593,
1386,
4490,
283,
3244,
3694,
356,
791,
3694,
356,
291,
14,
842,
63,
758,
1661,
14,
6305,
63,
3593,
4863,
61,
288,
587,
26,
355,
1256,
63,
344,
63,
1805,
14,
3527,
63,
14039,
275,
715,
355,
754,
14,
3244,
11232,
5589,
275,
359,
490,
791,
3989,
3694,
356,
791,
3694,
356,
283,
2747,
9147,
2267,
283,
3244,
3694,
356,
791,
3694,
356,
283,
2747,
9147,
936,
11049,
953,
372,
754,
398,
900,
14,
521,
14,
1107,
63,
585,
275,
378,
267,
7062,
18,
63,
1258,
275,
4420,
342,
267,
7062,
18,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Quarx2k/android_kernel_asus_padfone_s
|
Documentation/networking/cxacru-cf.py
|
14668
|
1626
|
#!/usr/bin/env python
# Copyright 2009 Simon Arlott
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Usage: cxacru-cf.py < cxacru-cf.bin
# Output: values string suitable for the sysfs adsl_config attribute
#
# Warning: cxacru-cf.bin with MD5 hash cdbac2689969d5ed5d4850f117702110
# contains mis-aligned values which will stop the modem from being able
# to make a connection. If the first and last two bytes are removed then
# the values become valid, but the modulation will be forced to ANSI
# T1.413 only which may not be appropriate.
#
# The original binary format is a packed list of le32 values.
import sys
import struct
i = 0
while True:
buf = sys.stdin.read(4)
if len(buf) == 0:
break
elif len(buf) != 4:
sys.stdout.write("\n")
sys.stderr.write("Error: read {0} not 4 bytes\n".format(len(buf)))
sys.exit(1)
if i > 0:
sys.stdout.write(" ")
sys.stdout.write("{0:x}={1}".format(i, struct.unpack("<I", buf)[0]))
i += 1
sys.stdout.write("\n")
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
8937,
10751,
265,
1952,
1653,
84,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
199,
3,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
199,
3,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
199,
3,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
199,
3,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
8155,
199,
3,
15630,
10902,
446,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
12,
8217,
14,
199,
3,
199,
3,
11028,
26,
286,
10104,
6558,
13,
2177,
14,
647,
665,
286,
10104,
6558,
13,
2177,
14,
1393,
199,
3,
7242,
26,
1338,
1059,
11233,
367,
314,
984,
2319,
282,
795,
76,
63,
888,
2225,
199,
3,
199,
3,
15902,
26,
286,
10104,
6558,
13,
2177,
14,
1393,
543,
15830,
21,
2631,
286,
697,
645,
13731,
1020,
1876,
68,
21,
379,
21,
68,
2006,
1400,
70,
845,
1138,
996,
6019,
199,
3,
3509,
3201,
13,
19175,
1338,
1314,
911,
3631,
314,
818,
77,
687,
3769,
7688,
199,
3,
370,
1852,
282,
1950,
14,
982,
314,
1642,
436,
2061,
2877,
2783,
787,
4829,
2066,
199,
3,
314,
1338,
8649,
1686,
12,
1325,
314,
3413,
5332,
911,
506,
19565,
370,
25600,
199,
3,
377,
17,
14,
23663,
1454,
1314,
1443,
440,
506,
5827,
14,
199,
3,
199,
3,
710,
3379,
3366,
1475,
365,
282,
13170,
769,
402,
1026,
708,
1338,
14,
199,
199,
646,
984,
199,
646,
2702,
199,
199,
73,
275,
378,
199,
6710,
715,
26,
199,
198,
1436,
275,
984,
14,
6626,
14,
739,
8,
20,
9,
421,
198,
692,
822,
8,
1436,
9,
508,
378,
26,
507,
198,
4785,
199,
198,
4164,
822,
8,
1436,
9,
1137,
841,
26,
507,
198,
1274,
14,
2703,
14,
952,
4582,
78,
531,
507,
198,
1274,
14,
3083,
14,
952,
480,
547,
26,
1586,
469,
16,
93,
440,
841,
2783,
60,
78,
1674,
908,
8,
552,
8,
1436,
1724,
507,
198,
1274,
14,
2224,
8,
17,
9,
421,
198,
692,
284,
690,
378,
26,
507,
198,
1274,
14,
2703,
14,
952,
480,
6099,
199,
198,
1274,
14,
2703,
14,
952,
13076,
16,
26,
88,
93,
3126,
17,
5469,
908,
8,
73,
12,
2702,
14,
5301,
6757,
41,
401,
4123,
2788,
16,
2459,
199,
198,
73,
847,
413,
199,
199,
1274,
14,
2703,
14,
952,
4582,
78,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
8937,
10751,
265,
1952,
1653,
84,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
199,
3,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
314,
2868,
199,
3,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
199,
3,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
2428,
199,
3,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
3169,
503,
199,
3,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
1696,
1684,
844,
367,
199,
3,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
3180,
543,
199,
3,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
8155,
199,
3,
15630,
10902,
446,
14453,
13540,
12,
8226,
12,
4828,
221,
15673,
13,
13421,
12,
8217,
14,
199,
3,
199,
3,
11028,
26,
286,
10104,
6558,
13,
2177,
14,
647,
665,
286,
10104,
6558,
13,
2177,
14,
1393,
199,
3,
7242,
26,
1338,
1059,
11233,
367,
314,
984,
2319,
282,
795,
76,
63,
888,
2225,
199,
3,
199,
3,
15902,
26,
286,
10104,
6558,
13,
2177,
14,
1393,
543,
15830,
21,
2631,
286,
697,
645,
13731,
1020,
1876,
68,
21,
379,
21,
68,
2006,
1400,
70,
845,
1138,
996,
6019,
199,
3,
3509,
3201,
13,
19175,
1338,
1314,
911,
3631,
314,
818,
77,
687,
3769,
7688,
199,
3,
370,
1852,
282,
1950,
14,
982,
314,
1642,
436,
2061,
2877,
2783,
787,
4829,
2066,
199,
3,
314,
1338,
8649,
1686,
12,
1325,
314,
3413,
5332,
911,
506,
19565,
370,
25600,
199,
3,
377,
17,
14,
23663,
1454,
1314,
1443,
440,
506,
5827,
14,
199,
3,
199,
3,
710,
3379,
3366,
1475,
365,
282,
13170,
769,
402,
1026,
708,
1338,
14,
199,
199,
646,
984,
199,
646,
2702,
199,
199,
73,
275,
378,
199,
6710,
715,
26,
199,
198,
1436,
275,
984,
14,
6626,
14,
739,
8,
20,
9,
421,
198,
692,
822,
8,
1436,
9,
508,
378,
26,
507,
198,
4785,
199,
198,
4164,
822,
8,
1436,
9,
1137,
841,
26,
507,
198,
1274,
14,
2703,
14,
952,
4582,
78,
531,
507,
198,
1274,
14,
3083,
14,
952,
480,
547,
26,
1586,
469,
16,
93,
440,
841,
2783,
60,
78,
1674,
908,
8,
552,
8,
1436,
1724,
507,
198,
1274,
14,
2224,
8,
17,
9,
421,
198,
692,
284,
690,
378,
26,
507,
198,
1274,
14,
2703,
14,
952,
480,
6099,
199,
198,
1274,
14,
2703,
14,
952,
13076,
16,
26,
88,
93,
3126,
17,
5469,
908,
8,
73,
12,
2702,
14,
5301,
6757,
41,
401,
4123,
2788,
16,
2459,
199,
198,
73,
847,
413,
199,
199,
1274,
14,
2703,
14,
952,
4582,
78,
531,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
brakhane/python-mode
|
pymode/environment.py
|
2
|
6239
|
""" Define interfaces. """
from __future__ import print_function
import vim
import json
import time
import os.path
from ._compat import PY2
class VimPymodeEnviroment(object):
""" Vim User interface. """
prefix = '[Pymode]'
def __init__(self):
""" Init VIM environment. """
self.current = vim.current
self.options = dict(encoding=vim.eval('&enc'))
self.options['debug'] = self.var('g:pymode_debug', True)
@property
def curdir(self):
""" Return current working directory. """
return self.var('getcwd()')
@property
def curbuf(self):
""" Return current buffer. """
return self.current.buffer
@property
def cursor(self):
""" Return current window position.
:return tuple: (row, col)
"""
return self.current.window.cursor
@property
def source(self):
""" Return source of current buffer. """
return "\n".join(self.lines)
@property
def lines(self):
""" Iterate by lines in current file.
:return list:
"""
if not PY2:
return self.curbuf
return [l.decode(self.options.get('encoding')) for l in self.curbuf]
@staticmethod
def var(name, to_bool=False, silence=False):
""" Get vim variable.
:return vimobj:
"""
try:
value = vim.eval(name)
except vim.error:
if silence:
return None
raise
if to_bool:
try:
value = bool(int(value))
except ValueError:
value = value
return value
@staticmethod
def message(msg, history=False):
""" Show message to user.
:return: :None
"""
if history:
return vim.command('echom "%s"' % str(msg))
return vim.command('call pymode#wide_message("%s")' % str(msg))
def user_input(self, msg, default=''):
""" Return user input or default.
:return str:
"""
msg = '%s %s ' % (self.prefix, msg)
if default != '':
msg += '[%s] ' % default
try:
vim.command('echohl Debug')
input_str = vim.eval('input("%s> ")' % msg)
vim.command('echohl none')
except KeyboardInterrupt:
input_str = ''
return input_str or default
def user_confirm(self, msg, yes=False):
""" Get user confirmation.
:return bool:
"""
default = 'yes' if yes else 'no'
action = self.user_input(msg, default)
return action and 'yes'.startswith(action)
def user_input_choices(self, msg, *options):
""" Get one of many options.
:return str: A choosen option
"""
choices = ['%s %s' % (self.prefix, msg)]
choices += [
"%s. %s" % (num, opt) for num, opt in enumerate(options, 1)]
try:
input_str = int(
vim.eval('inputlist(%s)' % self.prepare_value(choices)))
except (KeyboardInterrupt, ValueError):
input_str = 0
if not input_str:
self.message('Cancelled!')
return False
try:
return options[input_str - 1]
except (IndexError, ValueError):
self.error('Invalid option: %s' % input_str)
return self.user_input_choices(msg, *options)
@staticmethod
def error(msg):
""" Show error to user. """
vim.command('call pymode#error("%s")' % str(msg))
def debug(self, msg, *args):
""" Print debug information. """
if self.options.get('debug'):
print("%s %s [%s]" % (
int(time.time()), msg, ', '.join([str(a) for a in args])))
def stop(self, value=None):
""" Break Vim function. """
cmd = 'return'
if value is not None:
cmd += ' ' + self.prepare_value(value)
vim.command(cmd)
def catch_exceptions(self, func):
""" Decorator. Make execution more silence.
:return func:
"""
def _wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except (Exception, vim.error) as e: # noqa
if self.options.get('debug'):
raise
self.error(e)
return None
return _wrapper
def run(self, name, *args):
""" Run vim function. """
vim.command('call %s(%s)' % (name, ", ".join([
self.prepare_value(a) for a in args
])))
def let(self, name, value):
""" Set variable. """
cmd = 'let %s = %s' % (name, self.prepare_value(value))
self.debug(cmd)
vim.command(cmd)
def prepare_value(self, value, dumps=True):
""" Decode bstr to vim encoding.
:return unicode string:
"""
if dumps:
value = json.dumps(value)
if PY2:
value = value.decode('utf-8').encode(self.options.get('encoding'))
return value
def get_offset_params(self, cursor=None, base=""):
""" Calculate current offset.
:return tuple: (source, offset)
"""
row, col = cursor or env.cursor
source = ""
offset = 0
for i, line in enumerate(self.lines, 1):
if i == row:
source += line[:col] + base
offset = len(source)
source += line[col:]
else:
source += line
source += '\n'
env.debug('Get offset', base or None, row, col, offset)
return source, offset
@staticmethod
def goto_line(line):
""" Go to line. """
vim.command('normal %sggzz' % line)
def goto_file(self, path, cmd='e', force=False):
""" Function description. """
if force or os.path.abspath(path) != self.curbuf.name:
self.debug('read', path)
vim.command("%s %s" % (cmd, path))
@staticmethod
def goto_buffer(bufnr):
""" Open buffer. """
if str(bufnr) != '-1':
vim.command('buffer %s' % bufnr)
env = VimPymodeEnviroment()
|
lgpl-3.0
|
[
624,
13930,
8386,
14,
408,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
6695,
199,
646,
2022,
199,
646,
900,
199,
646,
747,
14,
515,
199,
199,
504,
13653,
5819,
492,
7843,
18,
421,
199,
533,
812,
1017,
2713,
632,
1327,
433,
293,
434,
8,
785,
304,
339,
408,
812,
1017,
2876,
3217,
14,
408,
339,
2403,
275,
6730,
2713,
632,
6616,
339,
347,
636,
826,
721,
277,
304,
267,
408,
21026,
812,
1469,
3734,
14,
408,
267,
291,
14,
1818,
275,
6695,
14,
1818,
267,
291,
14,
1419,
275,
1211,
8,
2991,
29,
16361,
14,
2579,
20040,
10945,
1333,
267,
291,
14,
1419,
459,
1757,
418,
275,
291,
14,
1391,
360,
71,
26,
647,
632,
63,
1757,
297,
715,
9,
339,
768,
1829,
272,
347,
1094,
694,
8,
277,
304,
267,
408,
1432,
1453,
6449,
2082,
14,
408,
267,
372,
291,
14,
1391,
360,
9458,
19004,
339,
768,
1829,
272,
347,
1094,
1436,
8,
277,
304,
267,
408,
1432,
1453,
3335,
14,
408,
267,
372,
291,
14,
1818,
14,
2738,
339,
768,
1829,
272,
347,
3920,
8,
277,
304,
267,
408,
1432,
1453,
4353,
3421,
14,
398,
520,
1107,
2008,
26,
334,
1143,
12,
1048,
9,
398,
408,
267,
372,
291,
14,
1818,
14,
3806,
14,
3937,
339,
768,
1829,
272,
347,
1350,
8,
277,
304,
267,
408,
1432,
1350,
402,
1453,
3335,
14,
408,
267,
372,
1867,
78,
1674,
904,
8,
277,
14,
1278,
9,
339,
768,
1829,
272,
347,
2385,
8,
277,
304,
267,
408,
23989,
701,
2385,
315,
1453,
570,
14,
398,
520,
1107,
769,
26,
398,
408,
267,
340,
440,
7843,
18,
26,
288,
372,
291,
14,
895,
1436,
398,
372,
359,
76,
14,
2708,
8,
277,
14,
1419,
14,
362,
360,
2991,
1333,
367,
634,
315,
291,
14,
895,
1436,
61,
339,
768,
4639,
272,
347,
2729,
8,
354,
12,
370,
63,
2245,
29,
797,
12,
9767,
21225,
29,
797,
304,
267,
408,
2372,
6695,
1750,
14,
398,
520,
1107,
1321,
573,
468,
26,
398,
408,
267,
862,
26,
288,
574,
275,
6695,
14,
2579,
8,
354,
9,
267,
871,
6695,
14,
705,
26,
288,
340,
9767,
21225,
26,
355,
372,
488,
288,
746,
398,
340,
370,
63,
2245,
26,
288,
862,
26,
355,
574,
275,
2155,
8,
442,
8,
585,
430,
288,
871,
1722,
26,
355,
574,
275,
574,
267,
372,
574,
339,
768,
4639,
272,
347,
1245,
8,
1328,
12,
7994,
29,
797,
304,
267,
408,
12968,
1245,
370,
922,
14,
398,
520,
1107,
26,
520,
403,
398,
408,
267,
340,
7994,
26,
288,
372,
6695,
14,
1531,
360,
12736,
676,
2071,
83,
4507,
450,
620,
8,
1328,
430,
398,
372,
6695,
14,
1531,
360,
1250,
1134,
632,
3,
13062,
63,
1188,
3647,
83,
32292,
450,
620,
8,
1328,
430,
339,
347,
922,
63,
1210,
8,
277,
12,
1499,
12,
849,
9280,
267,
408,
1432,
922,
1324,
503,
849,
14,
398,
520,
1107,
620,
26,
398,
408,
267,
1499,
275,
1543,
83,
450,
83,
283,
450,
334,
277,
14,
1861,
12,
1499,
9,
398,
340,
849,
1137,
8061,
288,
1499,
847,
30423,
83,
61,
283,
450,
849,
398,
862,
26,
288,
6695,
14,
1531,
360,
7878,
15544,
14245,
358,
288,
1324,
63,
495,
275,
6695,
14,
2579,
360,
1210,
3647,
83,
30,
298,
3171,
450,
1499,
9,
288,
6695,
14,
1531,
360,
7878,
15544,
7179,
358,
267,
871,
13483,
26,
288,
1324,
63,
495,
275,
2125,
398,
372,
1324,
63,
495,
503,
849,
339,
347,
922,
63,
9548,
8,
277,
12,
1499,
12,
9456,
29,
797,
304,
267,
408,
2372,
922,
18791,
14,
398,
520,
1107,
2155,
26,
398,
408,
267,
849,
275,
283,
5066,
7,
340,
9456,
587,
283,
889,
7,
267,
1595,
275,
291,
14,
751,
63,
1210,
8,
1328,
12,
849,
9,
267,
372,
1595,
436,
283,
5066,
1370,
2460,
8,
1287,
9,
339,
347,
922,
63,
1210,
63,
4577,
8,
277,
12,
1499,
12,
627,
1419,
304,
267,
408,
2372,
1373,
402,
5002,
1511,
14,
398,
520,
1107,
620,
26,
437,
2468,
79,
2464,
945,
398,
408,
267,
3415,
275,
15926,
83,
450,
83,
7,
450,
334,
277,
14,
1861,
12,
1499,
1874,
267,
3415,
847,
359,
288,
2071,
83,
14,
450,
83,
2,
450,
334,
1507,
12,
2450,
9,
367,
1967,
12,
2450,
315,
3874,
8,
1419,
12,
413,
1874,
267,
862,
26,
288,
1324,
63,
495,
275,
1109,
8,
355,
6695,
14,
2579,
360,
1210,
513,
4042,
83,
3171,
450,
291,
14,
6726,
63,
585,
8,
4577,
1724,
267,
871,
334,
31538,
12,
1722,
304,
288,
1324,
63,
495,
275,
378,
398,
340,
440,
1324,
63,
495,
26,
288,
291,
14,
1188,
360,
22127,
10916,
288,
372,
756,
398,
862,
26,
288,
372,
1511,
59,
1210,
63,
495,
446,
413,
61,
267,
871,
334,
12129,
12,
1722,
304,
288,
291,
14,
705,
360,
3364,
945,
26,
450,
83,
7,
450,
1324,
63,
495,
9,
288,
372,
291,
14,
751,
63,
1210,
63,
4577,
8,
1328,
12,
627,
1419,
9,
339,
768,
4639,
272,
347,
1125,
8,
1328,
304,
267,
408,
12968,
1125,
370,
922,
14,
408,
267,
6695,
14,
1531,
360,
1250,
1134,
632,
3,
705,
3647,
83,
32292,
450,
620,
8,
1328,
430,
339,
347,
3105,
8,
277,
12,
1499,
12,
627,
589,
304,
267,
408,
9101,
3105,
2556,
14,
408,
267,
340,
291,
14,
1419,
14,
362,
360,
1757,
735,
288,
870,
3647,
83,
450,
83,
8978,
83,
8480,
450,
334,
355,
1109,
8,
521,
14,
521,
4000,
1499,
12,
1656,
1987,
904,
779,
495,
8,
65,
9,
367,
282,
315,
1249,
11845,
339,
347,
3631,
8,
277,
12,
574,
29,
403,
304,
267,
408,
22535,
812,
1017,
805,
14,
408,
267,
2088,
275,
283,
1107,
7,
267,
340,
574,
365,
440,
488,
26,
288,
2088,
847,
283,
283,
435,
291,
14,
6726,
63,
585,
8,
585,
9,
267,
6695,
14,
1531,
8,
1760,
9,
339,
347,
8579,
63,
3924,
8,
277,
12,
2562,
304,
267,
408,
30684,
14,
4155,
6451,
1655,
9767,
21225,
14,
398,
520,
1107,
2562,
26,
398,
408,
267,
347,
485,
5029,
2031,
589,
12,
1011,
958,
304,
288,
862,
26,
355,
372,
2562,
2031,
589,
12,
1011,
958
] |
[
13930,
8386,
14,
408,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
6695,
199,
646,
2022,
199,
646,
900,
199,
646,
747,
14,
515,
199,
199,
504,
13653,
5819,
492,
7843,
18,
421,
199,
533,
812,
1017,
2713,
632,
1327,
433,
293,
434,
8,
785,
304,
339,
408,
812,
1017,
2876,
3217,
14,
408,
339,
2403,
275,
6730,
2713,
632,
6616,
339,
347,
636,
826,
721,
277,
304,
267,
408,
21026,
812,
1469,
3734,
14,
408,
267,
291,
14,
1818,
275,
6695,
14,
1818,
267,
291,
14,
1419,
275,
1211,
8,
2991,
29,
16361,
14,
2579,
20040,
10945,
1333,
267,
291,
14,
1419,
459,
1757,
418,
275,
291,
14,
1391,
360,
71,
26,
647,
632,
63,
1757,
297,
715,
9,
339,
768,
1829,
272,
347,
1094,
694,
8,
277,
304,
267,
408,
1432,
1453,
6449,
2082,
14,
408,
267,
372,
291,
14,
1391,
360,
9458,
19004,
339,
768,
1829,
272,
347,
1094,
1436,
8,
277,
304,
267,
408,
1432,
1453,
3335,
14,
408,
267,
372,
291,
14,
1818,
14,
2738,
339,
768,
1829,
272,
347,
3920,
8,
277,
304,
267,
408,
1432,
1453,
4353,
3421,
14,
398,
520,
1107,
2008,
26,
334,
1143,
12,
1048,
9,
398,
408,
267,
372,
291,
14,
1818,
14,
3806,
14,
3937,
339,
768,
1829,
272,
347,
1350,
8,
277,
304,
267,
408,
1432,
1350,
402,
1453,
3335,
14,
408,
267,
372,
1867,
78,
1674,
904,
8,
277,
14,
1278,
9,
339,
768,
1829,
272,
347,
2385,
8,
277,
304,
267,
408,
23989,
701,
2385,
315,
1453,
570,
14,
398,
520,
1107,
769,
26,
398,
408,
267,
340,
440,
7843,
18,
26,
288,
372,
291,
14,
895,
1436,
398,
372,
359,
76,
14,
2708,
8,
277,
14,
1419,
14,
362,
360,
2991,
1333,
367,
634,
315,
291,
14,
895,
1436,
61,
339,
768,
4639,
272,
347,
2729,
8,
354,
12,
370,
63,
2245,
29,
797,
12,
9767,
21225,
29,
797,
304,
267,
408,
2372,
6695,
1750,
14,
398,
520,
1107,
1321,
573,
468,
26,
398,
408,
267,
862,
26,
288,
574,
275,
6695,
14,
2579,
8,
354,
9,
267,
871,
6695,
14,
705,
26,
288,
340,
9767,
21225,
26,
355,
372,
488,
288,
746,
398,
340,
370,
63,
2245,
26,
288,
862,
26,
355,
574,
275,
2155,
8,
442,
8,
585,
430,
288,
871,
1722,
26,
355,
574,
275,
574,
267,
372,
574,
339,
768,
4639,
272,
347,
1245,
8,
1328,
12,
7994,
29,
797,
304,
267,
408,
12968,
1245,
370,
922,
14,
398,
520,
1107,
26,
520,
403,
398,
408,
267,
340,
7994,
26,
288,
372,
6695,
14,
1531,
360,
12736,
676,
2071,
83,
4507,
450,
620,
8,
1328,
430,
398,
372,
6695,
14,
1531,
360,
1250,
1134,
632,
3,
13062,
63,
1188,
3647,
83,
32292,
450,
620,
8,
1328,
430,
339,
347,
922,
63,
1210,
8,
277,
12,
1499,
12,
849,
9280,
267,
408,
1432,
922,
1324,
503,
849,
14,
398,
520,
1107,
620,
26,
398,
408,
267,
1499,
275,
1543,
83,
450,
83,
283,
450,
334,
277,
14,
1861,
12,
1499,
9,
398,
340,
849,
1137,
8061,
288,
1499,
847,
30423,
83,
61,
283,
450,
849,
398,
862,
26,
288,
6695,
14,
1531,
360,
7878,
15544,
14245,
358,
288,
1324,
63,
495,
275,
6695,
14,
2579,
360,
1210,
3647,
83,
30,
298,
3171,
450,
1499,
9,
288,
6695,
14,
1531,
360,
7878,
15544,
7179,
358,
267,
871,
13483,
26,
288,
1324,
63,
495,
275,
2125,
398,
372,
1324,
63,
495,
503,
849,
339,
347,
922,
63,
9548,
8,
277,
12,
1499,
12,
9456,
29,
797,
304,
267,
408,
2372,
922,
18791,
14,
398,
520,
1107,
2155,
26,
398,
408,
267,
849,
275,
283,
5066,
7,
340,
9456,
587,
283,
889,
7,
267,
1595,
275,
291,
14,
751,
63,
1210,
8,
1328,
12,
849,
9,
267,
372,
1595,
436,
283,
5066,
1370,
2460,
8,
1287,
9,
339,
347,
922,
63,
1210,
63,
4577,
8,
277,
12,
1499,
12,
627,
1419,
304,
267,
408,
2372,
1373,
402,
5002,
1511,
14,
398,
520,
1107,
620,
26,
437,
2468,
79,
2464,
945,
398,
408,
267,
3415,
275,
15926,
83,
450,
83,
7,
450,
334,
277,
14,
1861,
12,
1499,
1874,
267,
3415,
847,
359,
288,
2071,
83,
14,
450,
83,
2,
450,
334,
1507,
12,
2450,
9,
367,
1967,
12,
2450,
315,
3874,
8,
1419,
12,
413,
1874,
267,
862,
26,
288,
1324,
63,
495,
275,
1109,
8,
355,
6695,
14,
2579,
360,
1210,
513,
4042,
83,
3171,
450,
291,
14,
6726,
63,
585,
8,
4577,
1724,
267,
871,
334,
31538,
12,
1722,
304,
288,
1324,
63,
495,
275,
378,
398,
340,
440,
1324,
63,
495,
26,
288,
291,
14,
1188,
360,
22127,
10916,
288,
372,
756,
398,
862,
26,
288,
372,
1511,
59,
1210,
63,
495,
446,
413,
61,
267,
871,
334,
12129,
12,
1722,
304,
288,
291,
14,
705,
360,
3364,
945,
26,
450,
83,
7,
450,
1324,
63,
495,
9,
288,
372,
291,
14,
751,
63,
1210,
63,
4577,
8,
1328,
12,
627,
1419,
9,
339,
768,
4639,
272,
347,
1125,
8,
1328,
304,
267,
408,
12968,
1125,
370,
922,
14,
408,
267,
6695,
14,
1531,
360,
1250,
1134,
632,
3,
705,
3647,
83,
32292,
450,
620,
8,
1328,
430,
339,
347,
3105,
8,
277,
12,
1499,
12,
627,
589,
304,
267,
408,
9101,
3105,
2556,
14,
408,
267,
340,
291,
14,
1419,
14,
362,
360,
1757,
735,
288,
870,
3647,
83,
450,
83,
8978,
83,
8480,
450,
334,
355,
1109,
8,
521,
14,
521,
4000,
1499,
12,
1656,
1987,
904,
779,
495,
8,
65,
9,
367,
282,
315,
1249,
11845,
339,
347,
3631,
8,
277,
12,
574,
29,
403,
304,
267,
408,
22535,
812,
1017,
805,
14,
408,
267,
2088,
275,
283,
1107,
7,
267,
340,
574,
365,
440,
488,
26,
288,
2088,
847,
283,
283,
435,
291,
14,
6726,
63,
585,
8,
585,
9,
267,
6695,
14,
1531,
8,
1760,
9,
339,
347,
8579,
63,
3924,
8,
277,
12,
2562,
304,
267,
408,
30684,
14,
4155,
6451,
1655,
9767,
21225,
14,
398,
520,
1107,
2562,
26,
398,
408,
267,
347,
485,
5029,
2031,
589,
12,
1011,
958,
304,
288,
862,
26,
355,
372,
2562,
2031,
589,
12,
1011,
958,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
xuxiandi/picasso-graphic
|
tools/gyp/pylib/gyp/generator/ninja.py
|
25
|
73934
|
# Copyright (c) 2013 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import copy
import hashlib
import multiprocessing
import os.path
import re
import signal
import subprocess
import sys
import gyp
import gyp.common
import gyp.msvs_emulation
import gyp.MSVSUtil as MSVSUtil
import gyp.xcode_emulation
from gyp.common import GetEnvironFallback
import gyp.ninja_syntax as ninja_syntax
generator_default_variables = {
'EXECUTABLE_PREFIX': '',
'EXECUTABLE_SUFFIX': '',
'STATIC_LIB_PREFIX': 'lib',
'STATIC_LIB_SUFFIX': '.a',
'SHARED_LIB_PREFIX': 'lib',
# Gyp expects the following variables to be expandable by the build
# system to the appropriate locations. Ninja prefers paths to be
# known at gyp time. To resolve this, introduce special
# variables starting with $! and $| (which begin with a $ so gyp knows it
# should be treated specially, but is otherwise an invalid
# ninja/shell variable) that are passed to gyp here but expanded
# before writing out into the target .ninja files; see
# ExpandSpecial.
# $! is used for variables that represent a path and that can only appear at
# the start of a string, while $| is used for variables that can appear
# anywhere in a string.
'INTERMEDIATE_DIR': '$!INTERMEDIATE_DIR',
'SHARED_INTERMEDIATE_DIR': '$!PRODUCT_DIR/gen',
'PRODUCT_DIR': '$!PRODUCT_DIR',
'CONFIGURATION_NAME': '$|CONFIGURATION_NAME',
# Special variables that may be used by gyp 'rule' targets.
# We generate definitions for these variables on the fly when processing a
# rule.
'RULE_INPUT_ROOT': '${root}',
'RULE_INPUT_DIRNAME': '${dirname}',
'RULE_INPUT_PATH': '${source}',
'RULE_INPUT_EXT': '${ext}',
'RULE_INPUT_NAME': '${name}',
}
# Placates pylint.
generator_additional_non_configuration_keys = []
generator_additional_path_sections = []
generator_extra_sources_for_rules = []
# TODO: figure out how to not build extra host objects in the non-cross-compile
# case when this is enabled, and enable unconditionally.
generator_supports_multiple_toolsets = (
os.environ.get('GYP_CROSSCOMPILE') or
os.environ.get('AR_host') or
os.environ.get('CC_host') or
os.environ.get('CXX_host') or
os.environ.get('AR_target') or
os.environ.get('CC_target') or
os.environ.get('CXX_target'))
def StripPrefix(arg, prefix):
if arg.startswith(prefix):
return arg[len(prefix):]
return arg
def QuoteShellArgument(arg, flavor):
"""Quote a string such that it will be interpreted as a single argument
by the shell."""
# Rather than attempting to enumerate the bad shell characters, just
# whitelist common OK ones and quote anything else.
if re.match(r'^[a-zA-Z0-9_=.\\/-]+$', arg):
return arg # No quoting necessary.
if flavor == 'win':
return gyp.msvs_emulation.QuoteForRspFile(arg)
return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'"
def Define(d, flavor):
"""Takes a preprocessor define and returns a -D parameter that's ninja- and
shell-escaped."""
if flavor == 'win':
# cl.exe replaces literal # characters with = in preprocesor definitions for
# some reason. Octal-encode to work around that.
d = d.replace('#', '\\%03o' % ord('#'))
return QuoteShellArgument(ninja_syntax.escape('-D' + d), flavor)
class Target:
"""Target represents the paths used within a single gyp target.
Conceptually, building a single target A is a series of steps:
1) actions/rules/copies generates source/resources/etc.
2) compiles generates .o files
3) link generates a binary (library/executable)
4) bundle merges the above in a mac bundle
(Any of these steps can be optional.)
From a build ordering perspective, a dependent target B could just
depend on the last output of this series of steps.
But some dependent commands sometimes need to reach inside the box.
For example, when linking B it needs to get the path to the static
library generated by A.
This object stores those paths. To keep things simple, member
variables only store concrete paths to single files, while methods
compute derived values like "the last output of the target".
"""
def __init__(self, type):
# Gyp type ("static_library", etc.) of this target.
self.type = type
# File representing whether any input dependencies necessary for
# dependent actions have completed.
self.preaction_stamp = None
# File representing whether any input dependencies necessary for
# dependent compiles have completed.
self.precompile_stamp = None
# File representing the completion of actions/rules/copies, if any.
self.actions_stamp = None
# Path to the output of the link step, if any.
self.binary = None
# Path to the file representing the completion of building the bundle,
# if any.
self.bundle = None
# On Windows, incremental linking requires linking against all the .objs
# that compose a .lib (rather than the .lib itself). That list is stored
# here.
self.component_objs = None
# Windows only. The import .lib is the output of a build step, but
# because dependents only link against the lib (not both the lib and the
# dll) we keep track of the import library here.
self.import_lib = None
def Linkable(self):
"""Return true if this is a target that can be linked against."""
return self.type in ('static_library', 'shared_library')
def UsesToc(self, flavor):
"""Return true if the target should produce a restat rule based on a TOC
file."""
# For bundles, the .TOC should be produced for the binary, not for
# FinalOutput(). But the naive approach would put the TOC file into the
# bundle, so don't do this for bundles for now.
if flavor == 'win' or self.bundle:
return False
return self.type in ('shared_library', 'loadable_module')
def PreActionInput(self, flavor):
"""Return the path, if any, that should be used as a dependency of
any dependent action step."""
if self.UsesToc(flavor):
return self.FinalOutput() + '.TOC'
return self.FinalOutput() or self.preaction_stamp
def PreCompileInput(self):
"""Return the path, if any, that should be used as a dependency of
any dependent compile step."""
return self.actions_stamp or self.precompile_stamp
def FinalOutput(self):
"""Return the last output of the target, which depends on all prior
steps."""
return self.bundle or self.binary or self.actions_stamp
# A small discourse on paths as used within the Ninja build:
# All files we produce (both at gyp and at build time) appear in the
# build directory (e.g. out/Debug).
#
# Paths within a given .gyp file are always relative to the directory
# containing the .gyp file. Call these "gyp paths". This includes
# sources as well as the starting directory a given gyp rule/action
# expects to be run from. We call the path from the source root to
# the gyp file the "base directory" within the per-.gyp-file
# NinjaWriter code.
#
# All paths as written into the .ninja files are relative to the build
# directory. Call these paths "ninja paths".
#
# We translate between these two notions of paths with two helper
# functions:
#
# - GypPathToNinja translates a gyp path (i.e. relative to the .gyp file)
# into the equivalent ninja path.
#
# - GypPathToUniqueOutput translates a gyp path into a ninja path to write
# an output file; the result can be namespaced such that it is unique
# to the input file name as well as the output target name.
class NinjaWriter:
def __init__(self, qualified_target, target_outputs, base_dir, build_dir,
output_file, flavor, toplevel_dir=None):
"""
base_dir: path from source root to directory containing this gyp file,
by gyp semantics, all input paths are relative to this
build_dir: path from source root to build output
toplevel_dir: path to the toplevel directory
"""
self.qualified_target = qualified_target
self.target_outputs = target_outputs
self.base_dir = base_dir
self.build_dir = build_dir
self.ninja = ninja_syntax.Writer(output_file)
self.flavor = flavor
self.abs_build_dir = None
if toplevel_dir is not None:
self.abs_build_dir = os.path.abspath(os.path.join(toplevel_dir,
build_dir))
self.obj_ext = '.obj' if flavor == 'win' else '.o'
if flavor == 'win':
# See docstring of msvs_emulation.GenerateEnvironmentFiles().
self.win_env = {}
for arch in ('x86', 'x64'):
self.win_env[arch] = 'environment.' + arch
# Relative path from build output dir to base dir.
build_to_top = gyp.common.InvertRelativePath(build_dir, toplevel_dir)
self.build_to_base = os.path.join(build_to_top, base_dir)
# Relative path from base dir to build dir.
base_to_top = gyp.common.InvertRelativePath(base_dir, toplevel_dir)
self.base_to_build = os.path.join(base_to_top, build_dir)
def ExpandSpecial(self, path, product_dir=None):
"""Expand specials like $!PRODUCT_DIR in |path|.
If |product_dir| is None, assumes the cwd is already the product
dir. Otherwise, |product_dir| is the relative path to the product
dir.
"""
PRODUCT_DIR = '$!PRODUCT_DIR'
if PRODUCT_DIR in path:
if product_dir:
path = path.replace(PRODUCT_DIR, product_dir)
else:
path = path.replace(PRODUCT_DIR + '/', '')
path = path.replace(PRODUCT_DIR + '\\', '')
path = path.replace(PRODUCT_DIR, '.')
INTERMEDIATE_DIR = '$!INTERMEDIATE_DIR'
if INTERMEDIATE_DIR in path:
int_dir = self.GypPathToUniqueOutput('gen')
# GypPathToUniqueOutput generates a path relative to the product dir,
# so insert product_dir in front if it is provided.
path = path.replace(INTERMEDIATE_DIR,
os.path.join(product_dir or '', int_dir))
CONFIGURATION_NAME = '$|CONFIGURATION_NAME'
path = path.replace(CONFIGURATION_NAME, self.config_name)
return path
def ExpandRuleVariables(self, path, root, dirname, source, ext, name):
if self.flavor == 'win':
path = self.msvs_settings.ConvertVSMacros(
path, config=self.config_name)
path = path.replace(generator_default_variables['RULE_INPUT_ROOT'], root)
path = path.replace(generator_default_variables['RULE_INPUT_DIRNAME'],
dirname)
path = path.replace(generator_default_variables['RULE_INPUT_PATH'], source)
path = path.replace(generator_default_variables['RULE_INPUT_EXT'], ext)
path = path.replace(generator_default_variables['RULE_INPUT_NAME'], name)
return path
def GypPathToNinja(self, path, env=None):
"""Translate a gyp path to a ninja path, optionally expanding environment
variable references in |path| with |env|.
See the above discourse on path conversions."""
if env:
if self.flavor == 'mac':
path = gyp.xcode_emulation.ExpandEnvVars(path, env)
elif self.flavor == 'win':
path = gyp.msvs_emulation.ExpandMacros(path, env)
if path.startswith('$!'):
expanded = self.ExpandSpecial(path)
if self.flavor == 'win':
expanded = os.path.normpath(expanded)
return expanded
if '$|' in path:
path = self.ExpandSpecial(path)
assert '$' not in path, path
return os.path.normpath(os.path.join(self.build_to_base, path))
def GypPathToUniqueOutput(self, path, qualified=True):
"""Translate a gyp path to a ninja path for writing output.
If qualified is True, qualify the resulting filename with the name
of the target. This is necessary when e.g. compiling the same
path twice for two separate output targets.
See the above discourse on path conversions."""
path = self.ExpandSpecial(path)
assert not path.startswith('$'), path
# Translate the path following this scheme:
# Input: foo/bar.gyp, target targ, references baz/out.o
# Output: obj/foo/baz/targ.out.o (if qualified)
# obj/foo/baz/out.o (otherwise)
# (and obj.host instead of obj for cross-compiles)
#
# Why this scheme and not some other one?
# 1) for a given input, you can compute all derived outputs by matching
# its path, even if the input is brought via a gyp file with '..'.
# 2) simple files like libraries and stamps have a simple filename.
obj = 'obj'
if self.toolset != 'target':
obj += '.' + self.toolset
path_dir, path_basename = os.path.split(path)
if qualified:
path_basename = self.name + '.' + path_basename
return os.path.normpath(os.path.join(obj, self.base_dir, path_dir,
path_basename))
def WriteCollapsedDependencies(self, name, targets):
"""Given a list of targets, return a path for a single file
representing the result of building all the targets or None.
Uses a stamp file if necessary."""
assert targets == filter(None, targets), targets
if len(targets) == 0:
return None
if len(targets) > 1:
stamp = self.GypPathToUniqueOutput(name + '.stamp')
targets = self.ninja.build(stamp, 'stamp', targets)
self.ninja.newline()
return targets[0]
def WriteSpec(self, spec, config_name, generator_flags,
case_sensitive_filesystem):
"""The main entry point for NinjaWriter: write the build rules for a spec.
Returns a Target object, which represents the output paths for this spec.
Returns None if there are no outputs (e.g. a settings-only 'none' type
target)."""
self.config_name = config_name
self.name = spec['target_name']
self.toolset = spec['toolset']
config = spec['configurations'][config_name]
self.target = Target(spec['type'])
self.is_standalone_static_library = bool(
spec.get('standalone_static_library', 0))
self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec)
self.xcode_settings = self.msvs_settings = None
if self.flavor == 'mac':
self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec)
if self.flavor == 'win':
self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec,
generator_flags)
arch = self.msvs_settings.GetArch(config_name)
self.ninja.variable('arch', self.win_env[arch])
# Compute predepends for all rules.
# actions_depends is the dependencies this target depends on before running
# any of its action/rule/copy steps.
# compile_depends is the dependencies this target depends on before running
# any of its compile steps.
actions_depends = []
compile_depends = []
# TODO(evan): it is rather confusing which things are lists and which
# are strings. Fix these.
if 'dependencies' in spec:
for dep in spec['dependencies']:
if dep in self.target_outputs:
target = self.target_outputs[dep]
actions_depends.append(target.PreActionInput(self.flavor))
compile_depends.append(target.PreCompileInput())
actions_depends = filter(None, actions_depends)
compile_depends = filter(None, compile_depends)
actions_depends = self.WriteCollapsedDependencies('actions_depends',
actions_depends)
compile_depends = self.WriteCollapsedDependencies('compile_depends',
compile_depends)
self.target.preaction_stamp = actions_depends
self.target.precompile_stamp = compile_depends
# Write out actions, rules, and copies. These must happen before we
# compile any sources, so compute a list of predependencies for sources
# while we do it.
extra_sources = []
mac_bundle_depends = []
self.target.actions_stamp = self.WriteActionsRulesCopies(
spec, extra_sources, actions_depends, mac_bundle_depends)
# If we have actions/rules/copies, we depend directly on those, but
# otherwise we depend on dependent target's actions/rules/copies etc.
# We never need to explicitly depend on previous target's link steps,
# because no compile ever depends on them.
compile_depends_stamp = (self.target.actions_stamp or compile_depends)
# Write out the compilation steps, if any.
link_deps = []
sources = spec.get('sources', []) + extra_sources
if sources:
pch = None
if self.flavor == 'win':
gyp.msvs_emulation.VerifyMissingSources(
sources, self.abs_build_dir, generator_flags, self.GypPathToNinja)
pch = gyp.msvs_emulation.PrecompiledHeader(
self.msvs_settings, config_name, self.GypPathToNinja,
self.GypPathToUniqueOutput, self.obj_ext)
else:
pch = gyp.xcode_emulation.MacPrefixHeader(
self.xcode_settings, self.GypPathToNinja,
lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang))
link_deps = self.WriteSources(
config_name, config, sources, compile_depends_stamp, pch,
case_sensitive_filesystem, spec)
# Some actions/rules output 'sources' that are already object files.
link_deps += [self.GypPathToNinja(f)
for f in sources if f.endswith(self.obj_ext)]
if self.flavor == 'win' and self.target.type == 'static_library':
self.target.component_objs = link_deps
# Write out a link step, if needed.
output = None
if link_deps or self.target.actions_stamp or actions_depends:
output = self.WriteTarget(spec, config_name, config, link_deps,
self.target.actions_stamp or actions_depends)
if self.is_mac_bundle:
mac_bundle_depends.append(output)
# Bundle all of the above together, if needed.
if self.is_mac_bundle:
output = self.WriteMacBundle(spec, mac_bundle_depends)
if not output:
return None
assert self.target.FinalOutput(), output
return self.target
def _WinIdlRule(self, source, prebuild, outputs):
"""Handle the implicit VS .idl rule for one source file. Fills |outputs|
with files that are generated."""
outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData(
source, self.config_name)
outdir = self.GypPathToNinja(outdir)
def fix_path(path, rel=None):
path = os.path.join(outdir, path)
dirname, basename = os.path.split(source)
root, ext = os.path.splitext(basename)
path = self.ExpandRuleVariables(
path, root, dirname, source, ext, basename)
if rel:
path = os.path.relpath(path, rel)
return path
vars = [(name, fix_path(value, outdir)) for name, value in vars]
output = [fix_path(p) for p in output]
vars.append(('outdir', outdir))
vars.append(('idlflags', flags))
input = self.GypPathToNinja(source)
self.ninja.build(output, 'idl', input,
variables=vars, order_only=prebuild)
outputs.extend(output)
def WriteWinIdlFiles(self, spec, prebuild):
"""Writes rules to match MSVS's implicit idl handling."""
assert self.flavor == 'win'
if self.msvs_settings.HasExplicitIdlRules(spec):
return []
outputs = []
for source in filter(lambda x: x.endswith('.idl'), spec['sources']):
self._WinIdlRule(source, prebuild, outputs)
return outputs
def WriteActionsRulesCopies(self, spec, extra_sources, prebuild,
mac_bundle_depends):
"""Write out the Actions, Rules, and Copies steps. Return a path
representing the outputs of these steps."""
outputs = []
extra_mac_bundle_resources = []
if 'actions' in spec:
outputs += self.WriteActions(spec['actions'], extra_sources, prebuild,
extra_mac_bundle_resources)
if 'rules' in spec:
outputs += self.WriteRules(spec['rules'], extra_sources, prebuild,
extra_mac_bundle_resources)
if 'copies' in spec:
outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends)
if 'sources' in spec and self.flavor == 'win':
outputs += self.WriteWinIdlFiles(spec, prebuild)
stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs)
if self.is_mac_bundle:
mac_bundle_resources = spec.get('mac_bundle_resources', []) + \
extra_mac_bundle_resources
self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends)
self.WriteMacInfoPlist(mac_bundle_depends)
return stamp
def GenerateDescription(self, verb, message, fallback):
"""Generate and return a description of a build step.
|verb| is the short summary, e.g. ACTION or RULE.
|message| is a hand-written description, or None if not available.
|fallback| is the gyp-level name of the step, usable as a fallback.
"""
if self.toolset != 'target':
verb += '(%s)' % self.toolset
if message:
return '%s %s' % (verb, self.ExpandSpecial(message))
else:
return '%s %s: %s' % (verb, self.name, fallback)
def WriteActions(self, actions, extra_sources, prebuild,
extra_mac_bundle_resources):
# Actions cd into the base directory.
env = self.GetSortedXcodeEnv()
if self.flavor == 'win':
env = self.msvs_settings.GetVSMacroEnv(
'$!PRODUCT_DIR', config=self.config_name)
all_outputs = []
for action in actions:
# First write out a rule for the action.
name = '%s_%s' % (action['action_name'],
hashlib.md5(self.qualified_target).hexdigest())
description = self.GenerateDescription('ACTION',
action.get('message', None),
name)
is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action)
if self.flavor == 'win' else False)
args = action['action']
rule_name, _ = self.WriteNewNinjaRule(name, args, description,
is_cygwin, env=env)
inputs = [self.GypPathToNinja(i, env) for i in action['inputs']]
if int(action.get('process_outputs_as_sources', False)):
extra_sources += action['outputs']
if int(action.get('process_outputs_as_mac_bundle_resources', False)):
extra_mac_bundle_resources += action['outputs']
outputs = [self.GypPathToNinja(o, env) for o in action['outputs']]
# Then write out an edge using the rule.
self.ninja.build(outputs, rule_name, inputs,
order_only=prebuild)
all_outputs += outputs
self.ninja.newline()
return all_outputs
def WriteRules(self, rules, extra_sources, prebuild,
extra_mac_bundle_resources):
env = self.GetSortedXcodeEnv()
all_outputs = []
for rule in rules:
# First write out a rule for the rule action.
name = '%s_%s' % (rule['rule_name'],
hashlib.md5(self.qualified_target).hexdigest())
# Skip a rule with no action and no inputs.
if 'action' not in rule and not rule.get('rule_sources', []):
continue
args = rule['action']
description = self.GenerateDescription(
'RULE',
rule.get('message', None),
('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name)
is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule)
if self.flavor == 'win' else False)
rule_name, args = self.WriteNewNinjaRule(
name, args, description, is_cygwin, env=env)
# TODO: if the command references the outputs directly, we should
# simplify it to just use $out.
# Rules can potentially make use of some special variables which
# must vary per source file.
# Compute the list of variables we'll need to provide.
special_locals = ('source', 'root', 'dirname', 'ext', 'name')
needed_variables = set(['source'])
for argument in args:
for var in special_locals:
if ('${%s}' % var) in argument:
needed_variables.add(var)
def cygwin_munge(path):
if is_cygwin:
return path.replace('\\', '/')
return path
# For each source file, write an edge that generates all the outputs.
for source in rule.get('rule_sources', []):
dirname, basename = os.path.split(source)
root, ext = os.path.splitext(basename)
# Gather the list of inputs and outputs, expanding $vars if possible.
outputs = [self.ExpandRuleVariables(o, root, dirname,
source, ext, basename)
for o in rule['outputs']]
inputs = [self.ExpandRuleVariables(i, root, dirname,
source, ext, basename)
for i in rule.get('inputs', [])]
if int(rule.get('process_outputs_as_sources', False)):
extra_sources += outputs
if int(rule.get('process_outputs_as_mac_bundle_resources', False)):
extra_mac_bundle_resources += outputs
extra_bindings = []
for var in needed_variables:
if var == 'root':
extra_bindings.append(('root', cygwin_munge(root)))
elif var == 'dirname':
extra_bindings.append(('dirname', cygwin_munge(dirname)))
elif var == 'source':
# '$source' is a parameter to the rule action, which means
# it shouldn't be converted to a Ninja path. But we don't
# want $!PRODUCT_DIR in there either.
source_expanded = self.ExpandSpecial(source, self.base_to_build)
extra_bindings.append(('source', cygwin_munge(source_expanded)))
elif var == 'ext':
extra_bindings.append(('ext', ext))
elif var == 'name':
extra_bindings.append(('name', cygwin_munge(basename)))
else:
assert var == None, repr(var)
inputs = [self.GypPathToNinja(i, env) for i in inputs]
outputs = [self.GypPathToNinja(o, env) for o in outputs]
extra_bindings.append(('unique_name',
hashlib.md5(outputs[0]).hexdigest()))
self.ninja.build(outputs, rule_name, self.GypPathToNinja(source),
implicit=inputs,
order_only=prebuild,
variables=extra_bindings)
all_outputs.extend(outputs)
return all_outputs
def WriteCopies(self, copies, prebuild, mac_bundle_depends):
outputs = []
env = self.GetSortedXcodeEnv()
for copy in copies:
for path in copy['files']:
# Normalize the path so trailing slashes don't confuse us.
path = os.path.normpath(path)
basename = os.path.split(path)[1]
src = self.GypPathToNinja(path, env)
dst = self.GypPathToNinja(os.path.join(copy['destination'], basename),
env)
outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild)
if self.is_mac_bundle:
# gyp has mac_bundle_resources to copy things into a bundle's
# Resources folder, but there's no built-in way to copy files to other
# places in the bundle. Hence, some targets use copies for this. Check
# if this file is copied into the current bundle, and if so add it to
# the bundle depends so that dependent targets get rebuilt if the copy
# input changes.
if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()):
mac_bundle_depends.append(dst)
return outputs
def WriteMacBundleResources(self, resources, bundle_depends):
"""Writes ninja edges for 'mac_bundle_resources'."""
for output, res in gyp.xcode_emulation.GetMacBundleResources(
self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']),
self.xcode_settings, map(self.GypPathToNinja, resources)):
self.ninja.build(output, 'mac_tool', res,
variables=[('mactool_cmd', 'copy-bundle-resource')])
bundle_depends.append(output)
def WriteMacInfoPlist(self, bundle_depends):
"""Write build rules for bundle Info.plist files."""
info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist(
self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']),
self.xcode_settings, self.GypPathToNinja)
if not info_plist:
return
if defines:
# Create an intermediate file to store preprocessed results.
intermediate_plist = self.GypPathToUniqueOutput(
os.path.basename(info_plist))
defines = ' '.join([Define(d, self.flavor) for d in defines])
info_plist = self.ninja.build(intermediate_plist, 'infoplist', info_plist,
variables=[('defines',defines)])
env = self.GetSortedXcodeEnv(additional_settings=extra_env)
env = self.ComputeExportEnvString(env)
self.ninja.build(out, 'mac_tool', info_plist,
variables=[('mactool_cmd', 'copy-info-plist'),
('env', env)])
bundle_depends.append(out)
def WriteSources(self, config_name, config, sources, predepends,
precompiled_header, case_sensitive_filesystem, spec):
"""Write build rules to compile all of |sources|."""
if self.toolset == 'host':
self.ninja.variable('ar', '$ar_host')
self.ninja.variable('cc', '$cc_host')
self.ninja.variable('cxx', '$cxx_host')
self.ninja.variable('ld', '$ld_host')
extra_defines = []
if self.flavor == 'mac':
cflags = self.xcode_settings.GetCflags(config_name)
cflags_c = self.xcode_settings.GetCflagsC(config_name)
cflags_cc = self.xcode_settings.GetCflagsCC(config_name)
cflags_objc = ['$cflags_c'] + \
self.xcode_settings.GetCflagsObjC(config_name)
cflags_objcc = ['$cflags_cc'] + \
self.xcode_settings.GetCflagsObjCC(config_name)
elif self.flavor == 'win':
cflags = self.msvs_settings.GetCflags(config_name)
cflags_c = self.msvs_settings.GetCflagsC(config_name)
cflags_cc = self.msvs_settings.GetCflagsCC(config_name)
extra_defines = self.msvs_settings.GetComputedDefines(config_name)
pdbpath = self.msvs_settings.GetCompilerPdbName(
config_name, self.ExpandSpecial)
if not pdbpath:
obj = 'obj'
if self.toolset != 'target':
obj += '.' + self.toolset
pdbpath = os.path.normpath(os.path.join(obj, self.base_dir,
self.name + '.pdb'))
self.WriteVariableList('pdbname', [pdbpath])
self.WriteVariableList('pchprefix', [self.name])
else:
cflags = config.get('cflags', [])
cflags_c = config.get('cflags_c', [])
cflags_cc = config.get('cflags_cc', [])
defines = config.get('defines', []) + extra_defines
self.WriteVariableList('defines', [Define(d, self.flavor) for d in defines])
if self.flavor == 'win':
self.WriteVariableList('rcflags',
[QuoteShellArgument(self.ExpandSpecial(f), self.flavor)
for f in self.msvs_settings.GetRcflags(config_name,
self.GypPathToNinja)])
include_dirs = config.get('include_dirs', [])
if self.flavor == 'win':
include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs,
config_name)
self.WriteVariableList('includes',
[QuoteShellArgument('-I' + self.GypPathToNinja(i), self.flavor)
for i in include_dirs])
pch_commands = precompiled_header.GetPchBuildCommands()
if self.flavor == 'mac':
self.WriteVariableList('cflags_pch_c',
[precompiled_header.GetInclude('c')])
self.WriteVariableList('cflags_pch_cc',
[precompiled_header.GetInclude('cc')])
self.WriteVariableList('cflags_pch_objc',
[precompiled_header.GetInclude('m')])
self.WriteVariableList('cflags_pch_objcc',
[precompiled_header.GetInclude('mm')])
self.WriteVariableList('cflags', map(self.ExpandSpecial, cflags))
self.WriteVariableList('cflags_c', map(self.ExpandSpecial, cflags_c))
self.WriteVariableList('cflags_cc', map(self.ExpandSpecial, cflags_cc))
if self.flavor == 'mac':
self.WriteVariableList('cflags_objc', map(self.ExpandSpecial,
cflags_objc))
self.WriteVariableList('cflags_objcc', map(self.ExpandSpecial,
cflags_objcc))
self.ninja.newline()
outputs = []
for source in sources:
filename, ext = os.path.splitext(source)
ext = ext[1:]
obj_ext = self.obj_ext
if ext in ('cc', 'cpp', 'cxx'):
command = 'cxx'
elif ext == 'c' or (ext == 'S' and self.flavor != 'win'):
command = 'cc'
elif ext == 's' and self.flavor != 'win': # Doesn't generate .o.d files.
command = 'cc_s'
elif (self.flavor == 'win' and ext == 'asm' and
self.msvs_settings.GetArch(config_name) == 'x86' and
not self.msvs_settings.HasExplicitAsmRules(spec)):
# Asm files only get auto assembled for x86 (not x64).
command = 'asm'
# Add the _asm suffix as msvs is capable of handling .cc and
# .asm files of the same name without collision.
obj_ext = '_asm.obj'
elif self.flavor == 'mac' and ext == 'm':
command = 'objc'
elif self.flavor == 'mac' and ext == 'mm':
command = 'objcxx'
elif self.flavor == 'win' and ext == 'rc':
command = 'rc'
obj_ext = '.res'
else:
# Ignore unhandled extensions.
continue
input = self.GypPathToNinja(source)
output = self.GypPathToUniqueOutput(filename + obj_ext)
# Ninja's depfile handling gets confused when the case of a filename
# changes on a case-insensitive file system. To work around that, always
# convert .o filenames to lowercase on such file systems. See
# https://github.com/martine/ninja/issues/402 for details.
if not case_sensitive_filesystem:
output = output.lower()
implicit = precompiled_header.GetObjDependencies([input], [output])
variables = []
if self.flavor == 'win':
variables, output, implicit = precompiled_header.GetFlagsModifications(
input, output, implicit, command, cflags_c, cflags_cc,
self.ExpandSpecial)
self.ninja.build(output, command, input,
implicit=[gch for _, _, gch in implicit],
order_only=predepends, variables=variables)
outputs.append(output)
self.WritePchTargets(pch_commands)
self.ninja.newline()
return outputs
def WritePchTargets(self, pch_commands):
"""Writes ninja rules to compile prefix headers."""
if not pch_commands:
return
for gch, lang_flag, lang, input in pch_commands:
var_name = {
'c': 'cflags_pch_c',
'cc': 'cflags_pch_cc',
'm': 'cflags_pch_objc',
'mm': 'cflags_pch_objcc',
}[lang]
map = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }
cmd = map.get(lang)
self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)])
def WriteLink(self, spec, config_name, config, link_deps):
"""Write out a link step. Fills out target.binary. """
command = {
'executable': 'link',
'loadable_module': 'solink_module',
'shared_library': 'solink',
}[spec['type']]
implicit_deps = set()
solibs = set()
if 'dependencies' in spec:
# Two kinds of dependencies:
# - Linkable dependencies (like a .a or a .so): add them to the link line.
# - Non-linkable dependencies (like a rule that generates a file
# and writes a stamp file): add them to implicit_deps
extra_link_deps = set()
for dep in spec['dependencies']:
target = self.target_outputs.get(dep)
if not target:
continue
linkable = target.Linkable()
if linkable:
if (self.flavor == 'win' and
target.component_objs and
self.msvs_settings.IsUseLibraryDependencyInputs(config_name)):
extra_link_deps |= set(target.component_objs)
elif self.flavor == 'win' and target.import_lib:
extra_link_deps.add(target.import_lib)
elif target.UsesToc(self.flavor):
solibs.add(target.binary)
implicit_deps.add(target.binary + '.TOC')
else:
extra_link_deps.add(target.binary)
final_output = target.FinalOutput()
if not linkable or final_output != target.binary:
implicit_deps.add(final_output)
link_deps.extend(list(extra_link_deps))
extra_bindings = []
if self.is_mac_bundle:
output = self.ComputeMacBundleBinaryOutput()
else:
output = self.ComputeOutput(spec)
extra_bindings.append(('postbuilds',
self.GetPostbuildCommand(spec, output, output)))
is_executable = spec['type'] == 'executable'
if self.flavor == 'mac':
ldflags = self.xcode_settings.GetLdflags(config_name,
self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']),
self.GypPathToNinja)
elif self.flavor == 'win':
manifest_name = self.GypPathToUniqueOutput(
self.ComputeOutputFileName(spec))
ldflags, manifest_files = self.msvs_settings.GetLdflags(config_name,
self.GypPathToNinja, self.ExpandSpecial, manifest_name, is_executable)
self.WriteVariableList('manifests', manifest_files)
else:
ldflags = config.get('ldflags', [])
if is_executable and len(solibs):
ldflags.append('-Wl,-rpath=\$$ORIGIN/lib/')
self.WriteVariableList('ldflags',
gyp.common.uniquer(map(self.ExpandSpecial,
ldflags)))
libraries = gyp.common.uniquer(map(self.ExpandSpecial,
spec.get('libraries', [])))
if self.flavor == 'mac':
libraries = self.xcode_settings.AdjustLibraries(libraries)
elif self.flavor == 'win':
libraries = self.msvs_settings.AdjustLibraries(libraries)
self.WriteVariableList('libs', libraries)
self.target.binary = output
if command in ('solink', 'solink_module'):
extra_bindings.append(('soname', os.path.split(output)[1]))
extra_bindings.append(('lib',
gyp.common.EncodePOSIXShellArgument(output)))
if self.flavor == 'win':
extra_bindings.append(('dll', output))
if '/NOENTRY' not in ldflags:
self.target.import_lib = output + '.lib'
extra_bindings.append(('implibflag',
'/IMPLIB:%s' % self.target.import_lib))
output = [output, self.target.import_lib]
else:
output = [output, output + '.TOC']
if len(solibs):
extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs)))
self.ninja.build(output, command, link_deps,
implicit=list(implicit_deps),
variables=extra_bindings)
def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
if spec['type'] == 'none':
# TODO(evan): don't call this function for 'none' target types, as
# it doesn't do anything, and we fake out a 'binary' with a stamp file.
self.target.binary = compile_deps
elif spec['type'] == 'static_library':
self.target.binary = self.ComputeOutput(spec)
variables = []
postbuild = self.GetPostbuildCommand(
spec, self.target.binary, self.target.binary)
if postbuild:
variables.append(('postbuilds', postbuild))
if self.xcode_settings:
variables.append(('libtool_flags',
self.xcode_settings.GetLibtoolflags(config_name)))
if (self.flavor not in ('mac', 'win') and not
self.is_standalone_static_library):
self.ninja.build(self.target.binary, 'alink_thin', link_deps,
order_only=compile_deps, variables=variables)
else:
if self.msvs_settings:
libflags = self.msvs_settings.GetLibFlags(config_name,
self.GypPathToNinja)
variables.append(('libflags', libflags))
self.ninja.build(self.target.binary, 'alink', link_deps,
order_only=compile_deps, variables=variables)
else:
self.WriteLink(spec, config_name, config, link_deps)
return self.target.binary
def WriteMacBundle(self, spec, mac_bundle_depends):
assert self.is_mac_bundle
package_framework = spec['type'] in ('shared_library', 'loadable_module')
output = self.ComputeMacBundleOutput()
postbuild = self.GetPostbuildCommand(spec, output, self.target.binary,
is_command_start=not package_framework)
variables = []
if postbuild:
variables.append(('postbuilds', postbuild))
if package_framework:
variables.append(('version', self.xcode_settings.GetFrameworkVersion()))
self.ninja.build(output, 'package_framework', mac_bundle_depends,
variables=variables)
else:
self.ninja.build(output, 'stamp', mac_bundle_depends,
variables=variables)
self.target.bundle = output
return output
def GetSortedXcodeEnv(self, additional_settings=None):
"""Returns the variables Xcode would set for build steps."""
assert self.abs_build_dir
abs_build_dir = self.abs_build_dir
return gyp.xcode_emulation.GetSortedXcodeEnv(
self.xcode_settings, abs_build_dir,
os.path.join(abs_build_dir, self.build_to_base), self.config_name,
additional_settings)
def GetSortedXcodePostbuildEnv(self):
"""Returns the variables Xcode would set for postbuild steps."""
postbuild_settings = {}
# CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack.
# TODO(thakis): It would be nice to have some general mechanism instead.
strip_save_file = self.xcode_settings.GetPerTargetSetting(
'CHROMIUM_STRIP_SAVE_FILE')
if strip_save_file:
postbuild_settings['CHROMIUM_STRIP_SAVE_FILE'] = strip_save_file
return self.GetSortedXcodeEnv(additional_settings=postbuild_settings)
def GetPostbuildCommand(self, spec, output, output_binary,
is_command_start=False):
"""Returns a shell command that runs all the postbuilds, and removes
|output| if any of them fails. If |is_command_start| is False, then the
returned string will start with ' && '."""
if not self.xcode_settings or spec['type'] == 'none' or not output:
return ''
output = QuoteShellArgument(output, self.flavor)
target_postbuilds = self.xcode_settings.GetTargetPostbuilds(
self.config_name,
os.path.normpath(os.path.join(self.base_to_build, output)),
QuoteShellArgument(
os.path.normpath(os.path.join(self.base_to_build, output_binary)),
self.flavor),
quiet=True)
postbuilds = gyp.xcode_emulation.GetSpecPostbuildCommands(spec, quiet=True)
postbuilds = target_postbuilds + postbuilds
if not postbuilds:
return ''
# Postbuilds expect to be run in the gyp file's directory, so insert an
# implicit postbuild to cd to there.
postbuilds.insert(0, gyp.common.EncodePOSIXShellList(
['cd', self.build_to_base]))
env = self.ComputeExportEnvString(self.GetSortedXcodePostbuildEnv())
# G will be non-null if any postbuild fails. Run all postbuilds in a
# subshell.
commands = env + ' (F=0; ' + \
' '.join([ninja_syntax.escape(command) + ' || F=$$?;'
for command in postbuilds])
command_string = (commands + ' exit $$F); G=$$?; '
# Remove the final output if any postbuild failed.
'((exit $$G) || rm -rf %s) ' % output + '&& exit $$G)')
if is_command_start:
return '(' + command_string + ' && '
else:
return '$ && (' + command_string
def ComputeExportEnvString(self, env):
"""Given an environment, returns a string looking like
'export FOO=foo; export BAR="${FOO} bar;'
that exports |env| to the shell."""
export_str = []
for k, v in env:
export_str.append('export %s=%s;' %
(k, ninja_syntax.escape(gyp.common.EncodePOSIXShellArgument(v))))
return ' '.join(export_str)
def ComputeMacBundleOutput(self):
"""Return the 'output' (full output path) to a bundle output directory."""
assert self.is_mac_bundle
path = self.ExpandSpecial(generator_default_variables['PRODUCT_DIR'])
return os.path.join(path, self.xcode_settings.GetWrapperName())
def ComputeMacBundleBinaryOutput(self):
"""Return the 'output' (full output path) to the binary in a bundle."""
assert self.is_mac_bundle
path = self.ExpandSpecial(generator_default_variables['PRODUCT_DIR'])
return os.path.join(path, self.xcode_settings.GetExecutablePath())
def ComputeOutputFileName(self, spec, type=None):
"""Compute the filename of the final output for the current target."""
if not type:
type = spec['type']
default_variables = copy.copy(generator_default_variables)
CalculateVariables(default_variables, {'flavor': self.flavor})
# Compute filename prefix: the product prefix, or a default for
# the product type.
DEFAULT_PREFIX = {
'loadable_module': default_variables['SHARED_LIB_PREFIX'],
'shared_library': default_variables['SHARED_LIB_PREFIX'],
'static_library': default_variables['STATIC_LIB_PREFIX'],
'executable': default_variables['EXECUTABLE_PREFIX'],
}
prefix = spec.get('product_prefix', DEFAULT_PREFIX.get(type, ''))
# Compute filename extension: the product extension, or a default
# for the product type.
DEFAULT_EXTENSION = {
'loadable_module': default_variables['SHARED_LIB_SUFFIX'],
'shared_library': default_variables['SHARED_LIB_SUFFIX'],
'static_library': default_variables['STATIC_LIB_SUFFIX'],
'executable': default_variables['EXECUTABLE_SUFFIX'],
}
extension = spec.get('product_extension')
if extension:
extension = '.' + extension
else:
extension = DEFAULT_EXTENSION.get(type, '')
if 'product_name' in spec:
# If we were given an explicit name, use that.
target = spec['product_name']
else:
# Otherwise, derive a name from the target name.
target = spec['target_name']
if prefix == 'lib':
# Snip out an extra 'lib' from libs if appropriate.
target = StripPrefix(target, 'lib')
if type in ('static_library', 'loadable_module', 'shared_library',
'executable'):
return '%s%s%s' % (prefix, target, extension)
elif type == 'none':
return '%s.stamp' % target
else:
raise Exception('Unhandled output type %s' % type)
def ComputeOutput(self, spec, type=None):
"""Compute the path for the final output of the spec."""
assert not self.is_mac_bundle or type
if not type:
type = spec['type']
if self.flavor == 'win':
override = self.msvs_settings.GetOutputName(self.config_name,
self.ExpandSpecial)
if override:
return override
if self.flavor == 'mac' and type in (
'static_library', 'executable', 'shared_library', 'loadable_module'):
filename = self.xcode_settings.GetExecutablePath()
else:
filename = self.ComputeOutputFileName(spec, type)
if 'product_dir' in spec:
path = os.path.join(spec['product_dir'], filename)
return self.ExpandSpecial(path)
# Some products go into the output root, libraries go into shared library
# dir, and everything else goes into the normal place.
type_in_output_root = ['executable', 'loadable_module']
if self.flavor == 'mac' and self.toolset == 'target':
type_in_output_root += ['shared_library', 'static_library']
elif self.flavor == 'win' and self.toolset == 'target':
type_in_output_root += ['shared_library']
if type in type_in_output_root or self.is_standalone_static_library:
return filename
elif type == 'shared_library':
libdir = 'lib'
if self.toolset != 'target':
libdir = os.path.join('lib', '%s' % self.toolset)
return os.path.join(libdir, filename)
else:
return self.GypPathToUniqueOutput(filename, qualified=False)
def WriteVariableList(self, var, values):
assert not isinstance(values, str)
if values is None:
values = []
self.ninja.variable(var, ' '.join(values))
def WriteNewNinjaRule(self, name, args, description, is_cygwin, env):
"""Write out a new ninja "rule" statement for a given command.
Returns the name of the new rule, and a copy of |args| with variables
expanded."""
if self.flavor == 'win':
args = [self.msvs_settings.ConvertVSMacros(
arg, self.base_to_build, config=self.config_name)
for arg in args]
description = self.msvs_settings.ConvertVSMacros(
description, config=self.config_name)
elif self.flavor == 'mac':
# |env| is an empty list on non-mac.
args = [gyp.xcode_emulation.ExpandEnvVars(arg, env) for arg in args]
description = gyp.xcode_emulation.ExpandEnvVars(description, env)
# TODO: we shouldn't need to qualify names; we do it because
# currently the ninja rule namespace is global, but it really
# should be scoped to the subninja.
rule_name = self.name
if self.toolset == 'target':
rule_name += '.' + self.toolset
rule_name += '.' + name
rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name)
# Remove variable references, but not if they refer to the magic rule
# variables. This is not quite right, as it also protects these for
# actions, not just for rules where they are valid. Good enough.
protect = [ '${root}', '${dirname}', '${source}', '${ext}', '${name}' ]
protect = '(?!' + '|'.join(map(re.escape, protect)) + ')'
description = re.sub(protect + r'\$', '_', description)
# gyp dictates that commands are run from the base directory.
# cd into the directory before running, and adjust paths in
# the arguments to point to the proper locations.
rspfile = None
rspfile_content = None
args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args]
if self.flavor == 'win':
rspfile = rule_name + '.$unique_name.rsp'
# The cygwin case handles this inside the bash sub-shell.
run_in = '' if is_cygwin else ' ' + self.build_to_base
if is_cygwin:
rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine(
args, self.build_to_base)
else:
rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args)
command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable +
rspfile + run_in)
else:
env = self.ComputeExportEnvString(env)
command = gyp.common.EncodePOSIXShellList(args)
command = 'cd %s; ' % self.build_to_base + env + command
# GYP rules/actions express being no-ops by not touching their outputs.
# Avoid executing downstream dependencies in this case by specifying
# restat=1 to ninja.
self.ninja.rule(rule_name, command, description, restat=True,
rspfile=rspfile, rspfile_content=rspfile_content)
self.ninja.newline()
return rule_name, args
def CalculateVariables(default_variables, params):
"""Calculate additional variables for use in the build (called by gyp)."""
global generator_additional_non_configuration_keys
global generator_additional_path_sections
flavor = gyp.common.GetFlavor(params)
if flavor == 'mac':
default_variables.setdefault('OS', 'mac')
default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib')
default_variables.setdefault('SHARED_LIB_DIR',
generator_default_variables['PRODUCT_DIR'])
default_variables.setdefault('LIB_DIR',
generator_default_variables['PRODUCT_DIR'])
# Copy additional generator configuration data from Xcode, which is shared
# by the Mac Ninja generator.
import gyp.generator.xcode as xcode_generator
generator_additional_non_configuration_keys = getattr(xcode_generator,
'generator_additional_non_configuration_keys', [])
generator_additional_path_sections = getattr(xcode_generator,
'generator_additional_path_sections', [])
global generator_extra_sources_for_rules
generator_extra_sources_for_rules = getattr(xcode_generator,
'generator_extra_sources_for_rules', [])
elif flavor == 'win':
default_variables.setdefault('OS', 'win')
default_variables['EXECUTABLE_SUFFIX'] = '.exe'
default_variables['STATIC_LIB_PREFIX'] = ''
default_variables['STATIC_LIB_SUFFIX'] = '.lib'
default_variables['SHARED_LIB_PREFIX'] = ''
default_variables['SHARED_LIB_SUFFIX'] = '.dll'
generator_flags = params.get('generator_flags', {})
# Copy additional generator configuration data from VS, which is shared
# by the Windows Ninja generator.
import gyp.generator.msvs as msvs_generator
generator_additional_non_configuration_keys = getattr(msvs_generator,
'generator_additional_non_configuration_keys', [])
generator_additional_path_sections = getattr(msvs_generator,
'generator_additional_path_sections', [])
# Set a variable so conditions can be based on msvs_version.
msvs_version = gyp.msvs_emulation.GetVSVersion(generator_flags)
default_variables['MSVS_VERSION'] = msvs_version.ShortName()
# To determine processor word size on Windows, in addition to checking
# PROCESSOR_ARCHITECTURE (which reflects the word size of the current
# process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which
# contains the actual word size of the system when running thru WOW64).
if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or
'64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')):
default_variables['MSVS_OS_BITS'] = 64
else:
default_variables['MSVS_OS_BITS'] = 32
else:
operating_system = flavor
if flavor == 'android':
operating_system = 'linux' # Keep this legacy behavior for now.
default_variables.setdefault('OS', operating_system)
default_variables.setdefault('SHARED_LIB_SUFFIX', '.so')
default_variables.setdefault('SHARED_LIB_DIR',
os.path.join('$!PRODUCT_DIR', 'lib'))
default_variables.setdefault('LIB_DIR',
os.path.join('$!PRODUCT_DIR', 'obj'))
def OpenOutput(path, mode='w'):
"""Open |path| for writing, creating directories if necessary."""
try:
os.makedirs(os.path.dirname(path))
except OSError:
pass
return open(path, mode)
def GenerateOutputForConfig(target_list, target_dicts, data, params,
config_name):
options = params['options']
flavor = gyp.common.GetFlavor(params)
generator_flags = params.get('generator_flags', {})
# generator_dir: relative path from pwd to where make puts build files.
# Makes migrating from make to ninja easier, ninja doesn't put anything here.
generator_dir = os.path.relpath(params['options'].generator_output or '.')
# output_dir: relative path from generator_dir to the build directory.
output_dir = generator_flags.get('output_dir', 'out')
# build_dir: relative path from source root to our output files.
# e.g. "out/Debug"
build_dir = os.path.normpath(os.path.join(generator_dir,
output_dir,
config_name))
toplevel_build = os.path.join(options.toplevel_dir, build_dir)
master_ninja = ninja_syntax.Writer(
OpenOutput(os.path.join(toplevel_build, 'build.ninja')),
width=120)
case_sensitive_filesystem = not os.path.exists(
os.path.join(toplevel_build, 'BUILD.NINJA'))
# Put build-time support tools in out/{config_name}.
gyp.common.CopyTool(flavor, toplevel_build)
# Grab make settings for CC/CXX.
# The rules are
# - The priority from low to high is gcc/g++, the 'make_global_settings' in
# gyp, the environment variable.
# - If there is no 'make_global_settings' for CC.host/CXX.host or
# 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set
# to cc/cxx.
if flavor == 'win':
cc = 'cl.exe'
cxx = 'cl.exe'
ld = 'link.exe'
gyp.msvs_emulation.GenerateEnvironmentFiles(
toplevel_build, generator_flags, OpenOutput)
ld_host = '$ld'
else:
cc = 'gcc'
cxx = 'g++'
ld = '$cxx'
ld_host = '$cxx_host'
cc_host = None
cxx_host = None
cc_host_global_setting = None
cxx_host_global_setting = None
build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
make_global_settings = data[build_file].get('make_global_settings', [])
build_to_root = gyp.common.InvertRelativePath(build_dir,
options.toplevel_dir)
for key, value in make_global_settings:
if key == 'CC':
cc = os.path.join(build_to_root, value)
if key == 'CXX':
cxx = os.path.join(build_to_root, value)
if key == 'LD':
ld = os.path.join(build_to_root, value)
if key == 'CC.host':
cc_host = os.path.join(build_to_root, value)
cc_host_global_setting = value
if key == 'CXX.host':
cxx_host = os.path.join(build_to_root, value)
cxx_host_global_setting = value
if key == 'LD.host':
ld_host = os.path.join(build_to_root, value)
flock = 'flock'
if flavor == 'mac':
flock = './gyp-mac-tool flock'
cc = GetEnvironFallback(['CC_target', 'CC'], cc)
master_ninja.variable('cc', cc)
cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx)
master_ninja.variable('cxx', cxx)
ld = GetEnvironFallback(['LD_target', 'LD'], ld)
if not cc_host:
cc_host = cc
if not cxx_host:
cxx_host = cxx
if flavor == 'win':
master_ninja.variable('ld', ld)
master_ninja.variable('idl', 'midl.exe')
master_ninja.variable('ar', 'lib.exe')
master_ninja.variable('rc', 'rc.exe')
master_ninja.variable('asm', 'ml.exe')
master_ninja.variable('mt', 'mt.exe')
master_ninja.variable('use_dep_database', '1')
else:
master_ninja.variable('ld', flock + ' linker.lock ' + ld)
master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar'))
master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar'))
cc_host = GetEnvironFallback(['CC_host'], cc_host)
cxx_host = GetEnvironFallback(['CXX_host'], cxx_host)
ld_host = GetEnvironFallback(['LD_host'], ld_host)
# The environment variable could be used in 'make_global_settings', like
# ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here.
if '$(CC)' in cc_host and cc_host_global_setting:
cc_host = cc_host_global_setting.replace('$(CC)', cc)
if '$(CXX)' in cxx_host and cxx_host_global_setting:
cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx)
master_ninja.variable('cc_host', cc_host)
master_ninja.variable('cxx_host', cxx_host)
if flavor == 'win':
master_ninja.variable('ld_host', ld_host)
else:
master_ninja.variable('ld_host', flock + ' linker.lock ' + ld_host)
master_ninja.newline()
if flavor != 'win':
master_ninja.rule(
'cc',
description='CC $out',
command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c '
'$cflags_pch_c -c $in -o $out'),
depfile='$out.d')
master_ninja.rule(
'cc_s',
description='CC $out',
command=('$cc $defines $includes $cflags $cflags_c '
'$cflags_pch_c -c $in -o $out'))
master_ninja.rule(
'cxx',
description='CXX $out',
command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc '
'$cflags_pch_cc -c $in -o $out'),
depfile='$out.d')
else:
cc_command = ('ninja -t msvc -o $out -e $arch '
'-- '
'$cc /nologo /showIncludes /FC '
'@$out.rsp /c $in /Fo$out /Fd$pdbname ')
cxx_command = ('ninja -t msvc -o $out -e $arch '
'-- '
'$cxx /nologo /showIncludes /FC '
'@$out.rsp /c $in /Fo$out /Fd$pdbname ')
master_ninja.rule(
'cc',
description='CC $out',
command=cc_command,
depfile='$out.d',
rspfile='$out.rsp',
rspfile_content='$defines $includes $cflags $cflags_c')
master_ninja.rule(
'cxx',
description='CXX $out',
command=cxx_command,
depfile='$out.d',
rspfile='$out.rsp',
rspfile_content='$defines $includes $cflags $cflags_cc')
master_ninja.rule(
'idl',
description='IDL $in',
command=('%s gyp-win-tool midl-wrapper $arch $outdir '
'$tlb $h $dlldata $iid $proxy $in '
'$idlflags' % sys.executable))
master_ninja.rule(
'rc',
description='RC $in',
# Note: $in must be last otherwise rc.exe complains.
command=('%s gyp-win-tool rc-wrapper '
'$arch $rc $defines $includes $rcflags /fo$out $in' %
sys.executable))
master_ninja.rule(
'asm',
description='ASM $in',
command=('%s gyp-win-tool asm-wrapper '
'$arch $asm $defines $includes /c /Fo $out $in' %
sys.executable))
if flavor != 'mac' and flavor != 'win':
master_ninja.rule(
'alink',
description='AR $out',
command='rm -f $out && $ar rcs $out $in')
master_ninja.rule(
'alink_thin',
description='AR $out',
command='rm -f $out && $ar rcsT $out $in')
# This allows targets that only need to depend on $lib's API to declare an
# order-only dependency on $lib.TOC and avoid relinking such downstream
# dependencies when $lib changes only in non-public ways.
# The resulting string leaves an uninterpolated %{suffix} which
# is used in the final substitution below.
mtime_preserving_solink_base = (
'if [ ! -e $lib -o ! -e ${lib}.TOC ]; then '
'%(solink)s && %(extract_toc)s > ${lib}.TOC; else '
'%(solink)s && %(extract_toc)s > ${lib}.tmp && '
'if ! cmp -s ${lib}.tmp ${lib}.TOC; then mv ${lib}.tmp ${lib}.TOC ; '
'fi; fi'
% { 'solink':
'$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s',
'extract_toc':
('{ readelf -d ${lib} | grep SONAME ; '
'nm -gD -f p ${lib} | cut -f1-2 -d\' \'; }')})
master_ninja.rule(
'solink',
description='SOLINK $lib',
restat=True,
command=(mtime_preserving_solink_base % {
'suffix': '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive '
'$libs'}))
master_ninja.rule(
'solink_module',
description='SOLINK(module) $lib',
restat=True,
command=(mtime_preserving_solink_base % {
'suffix': '-Wl,--start-group $in $solibs -Wl,--end-group $libs'}))
master_ninja.rule(
'link',
description='LINK $out',
command=('$ld $ldflags -o $out '
'-Wl,--start-group $in $solibs -Wl,--end-group $libs'))
elif flavor == 'win':
master_ninja.rule(
'alink',
description='LIB $out',
command=('%s gyp-win-tool link-wrapper $arch '
'$ar /nologo /ignore:4221 /OUT:$out @$out.rsp' %
sys.executable),
rspfile='$out.rsp',
rspfile_content='$in_newline $libflags')
dlldesc = 'LINK(DLL) $dll'
dllcmd = ('%s gyp-win-tool link-wrapper $arch '
'$ld /nologo $implibflag /DLL /OUT:$dll '
'/PDB:$dll.pdb @$dll.rsp' % sys.executable)
dllcmd += (' && %s gyp-win-tool manifest-wrapper $arch '
'cmd /c if exist $dll.manifest del $dll.manifest' %
sys.executable)
dllcmd += (' && %s gyp-win-tool manifest-wrapper $arch '
'$mt -nologo -manifest $manifests -out:$dll.manifest' %
sys.executable)
master_ninja.rule('solink', description=dlldesc, command=dllcmd,
rspfile='$dll.rsp',
rspfile_content='$libs $in_newline $ldflags',
restat=True)
master_ninja.rule('solink_module', description=dlldesc, command=dllcmd,
rspfile='$dll.rsp',
rspfile_content='$libs $in_newline $ldflags',
restat=True)
# Note that ldflags goes at the end so that it has the option of
# overriding default settings earlier in the command line.
master_ninja.rule(
'link',
description='LINK $out',
command=('%s gyp-win-tool link-wrapper $arch '
'$ld /nologo /OUT:$out /PDB:$out.pdb @$out.rsp && '
'%s gyp-win-tool manifest-wrapper $arch '
'cmd /c if exist $out.manifest del $out.manifest && '
'%s gyp-win-tool manifest-wrapper $arch '
'$mt -nologo -manifest $manifests -out:$out.manifest' %
(sys.executable, sys.executable, sys.executable)),
rspfile='$out.rsp',
rspfile_content='$in_newline $libs $ldflags')
else:
master_ninja.rule(
'objc',
description='OBJC $out',
command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc '
'$cflags_pch_objc -c $in -o $out'),
depfile='$out.d')
master_ninja.rule(
'objcxx',
description='OBJCXX $out',
command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_objcc '
'$cflags_pch_objcc -c $in -o $out'),
depfile='$out.d')
master_ninja.rule(
'alink',
description='LIBTOOL-STATIC $out, POSTBUILDS',
command='rm -f $out && '
'./gyp-mac-tool filter-libtool libtool $libtool_flags '
'-static -o $out $in'
'$postbuilds')
# Record the public interface of $lib in $lib.TOC. See the corresponding
# comment in the posix section above for details.
mtime_preserving_solink_base = (
'if [ ! -e $lib -o ! -e ${lib}.TOC ] || '
# Always force dependent targets to relink if this library
# reexports something. Handling this correctly would require
# recursive TOC dumping but this is rare in practice, so punt.
'otool -l $lib | grep -q LC_REEXPORT_DYLIB ; then '
'%(solink)s && %(extract_toc)s > ${lib}.TOC; '
'else '
'%(solink)s && %(extract_toc)s > ${lib}.tmp && '
'if ! cmp -s ${lib}.tmp ${lib}.TOC; then '
'mv ${lib}.tmp ${lib}.TOC ; '
'fi; '
'fi'
% { 'solink': '$ld -shared $ldflags -o $lib %(suffix)s',
'extract_toc':
'{ otool -l $lib | grep LC_ID_DYLIB -A 5; '
'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'})
# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass
# -bundle -single_module here (for osmesa.so).
master_ninja.rule(
'solink',
description='SOLINK $lib, POSTBUILDS',
restat=True,
command=(mtime_preserving_solink_base % {
'suffix': '$in $solibs $libs$postbuilds'}))
master_ninja.rule(
'solink_module',
description='SOLINK(module) $lib, POSTBUILDS',
restat=True,
command=(mtime_preserving_solink_base % {
'suffix': '$in $solibs $libs$postbuilds'}))
master_ninja.rule(
'link',
description='LINK $out, POSTBUILDS',
command=('$ld $ldflags -o $out '
'$in $solibs $libs$postbuilds'))
master_ninja.rule(
'infoplist',
description='INFOPLIST $out',
command=('$cc -E -P -Wno-trigraphs -x c $defines $in -o $out && '
'plutil -convert xml1 $out $out'))
master_ninja.rule(
'mac_tool',
description='MACTOOL $mactool_cmd $in',
command='$env ./gyp-mac-tool $mactool_cmd $in $out')
master_ninja.rule(
'package_framework',
description='PACKAGE FRAMEWORK $out, POSTBUILDS',
command='./gyp-mac-tool package-framework $out $version$postbuilds '
'&& touch $out')
if flavor == 'win':
master_ninja.rule(
'stamp',
description='STAMP $out',
command='%s gyp-win-tool stamp $out' % sys.executable)
master_ninja.rule(
'copy',
description='COPY $in $out',
command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable)
else:
master_ninja.rule(
'stamp',
description='STAMP $out',
command='${postbuilds}touch $out')
master_ninja.rule(
'copy',
description='COPY $in $out',
command='ln -f $in $out 2>/dev/null || (rm -rf $out && cp -af $in $out)')
master_ninja.newline()
all_targets = set()
for build_file in params['build_files']:
for target in gyp.common.AllTargets(target_list,
target_dicts,
os.path.normpath(build_file)):
all_targets.add(target)
all_outputs = set()
# target_outputs is a map from qualified target name to a Target object.
target_outputs = {}
# target_short_names is a map from target short name to a list of Target
# objects.
target_short_names = {}
for qualified_target in target_list:
# qualified_target is like: third_party/icu/icu.gyp:icui18n#target
build_file, name, toolset = \
gyp.common.ParseQualifiedTarget(qualified_target)
this_make_global_settings = data[build_file].get('make_global_settings', [])
assert make_global_settings == this_make_global_settings, (
"make_global_settings needs to be the same for all targets.")
spec = target_dicts[qualified_target]
if flavor == 'mac':
gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec)
build_file = gyp.common.RelativePath(build_file, options.toplevel_dir)
base_path = os.path.dirname(build_file)
obj = 'obj'
if toolset != 'target':
obj += '.' + toolset
output_file = os.path.join(obj, base_path, name + '.ninja')
abs_build_dir = os.path.abspath(toplevel_build)
writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir,
OpenOutput(os.path.join(toplevel_build, output_file)),
flavor, toplevel_dir=options.toplevel_dir)
master_ninja.subninja(output_file)
target = writer.WriteSpec(
spec, config_name, generator_flags, case_sensitive_filesystem)
if target:
if name != target.FinalOutput() and spec['toolset'] == 'target':
target_short_names.setdefault(name, []).append(target)
target_outputs[qualified_target] = target
if qualified_target in all_targets:
all_outputs.add(target.FinalOutput())
if target_short_names:
# Write a short name to build this target. This benefits both the
# "build chrome" case as well as the gyp tests, which expect to be
# able to run actions and build libraries by their short name.
master_ninja.newline()
master_ninja.comment('Short names for targets.')
for short_name in target_short_names:
master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in
target_short_names[short_name]])
if all_outputs:
master_ninja.newline()
master_ninja.build('all', 'phony', list(all_outputs))
master_ninja.default(generator_flags.get('default_target', 'all'))
def PerformBuild(data, configurations, params):
options = params['options']
for config in configurations:
builddir = os.path.join(options.toplevel_dir, 'out', config)
arguments = ['ninja', '-C', builddir]
print 'Building [%s]: %s' % (config, arguments)
subprocess.check_call(arguments)
def CallGenerateOutputForConfig(arglist):
# Ignore the interrupt signal so that the parent process catches it and
# kills all multiprocessing children.
signal.signal(signal.SIGINT, signal.SIG_IGN)
(target_list, target_dicts, data, params, config_name) = arglist
GenerateOutputForConfig(target_list, target_dicts, data, params, config_name)
def GenerateOutput(target_list, target_dicts, data, params):
user_config = params.get('generator_flags', {}).get('config', None)
if gyp.common.GetFlavor(params) == 'win':
target_list, target_dicts = MSVSUtil.ShardTargets(target_list, target_dicts)
if user_config:
GenerateOutputForConfig(target_list, target_dicts, data, params,
user_config)
else:
config_names = target_dicts[target_list[0]]['configurations'].keys()
if params['parallel']:
try:
pool = multiprocessing.Pool(len(config_names))
arglists = []
for config_name in config_names:
arglists.append(
(target_list, target_dicts, data, params, config_name))
pool.map(CallGenerateOutputForConfig, arglists)
except KeyboardInterrupt, e:
pool.terminate()
raise e
else:
for config_name in config_names:
GenerateOutputForConfig(target_list, target_dicts, data, params,
config_name)
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6171,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
1331,
199,
646,
8337,
199,
646,
12866,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
4673,
199,
646,
3873,
199,
646,
984,
199,
646,
4902,
199,
646,
4902,
14,
2330,
199,
646,
4902,
14,
8338,
63,
20526,
199,
646,
4902,
14,
3053,
54,
6195,
2270,
465,
11694,
6195,
2270,
199,
646,
4902,
14,
8701,
63,
20526,
199,
199,
504,
4902,
14,
2330,
492,
2372,
23027,
21860,
199,
646,
4902,
14,
8675,
63,
7093,
465,
14822,
63,
7093,
199,
199,
4679,
63,
885,
63,
3669,
275,
469,
523,
283,
21623,
63,
6351,
356,
3260,
523,
283,
21623,
63,
12273,
356,
3260,
523,
283,
10449,
63,
5617,
63,
6351,
356,
283,
773,
297,
523,
283,
10449,
63,
5617,
63,
12273,
356,
1987,
65,
297,
523,
283,
13772,
63,
5617,
63,
6351,
356,
283,
773,
297,
819,
327,
14133,
14292,
314,
2569,
2860,
370,
506,
6544,
461,
701,
314,
1900,
523,
327,
2656,
370,
314,
5827,
9918,
14,
221,
653,
4135,
20491,
1192,
3792,
370,
506,
523,
327,
6040,
737,
4902,
900,
14,
221,
4005,
7512,
642,
12,
13318,
3402,
4539,
523,
327,
2860,
6617,
543,
2672,
1,
436,
2672,
92,
334,
6777,
5386,
543,
282,
2672,
880,
4902,
19428,
652,
523,
327,
1077,
506,
10184,
1106,
1183,
12,
1325,
365,
4257,
376,
3866,
523,
327,
14822,
15,
5641,
1750,
9,
626,
787,
3032,
370,
4902,
2348,
1325,
11507,
523,
327,
2544,
3575,
734,
1901,
314,
1347,
1275,
8675,
1584,
27,
1937,
523,
327,
18890,
12246,
14,
523,
327,
2672,
1,
365,
1202,
367,
2860,
626,
2954,
282,
931,
436,
626,
883,
1454,
7468,
737,
523,
327,
314,
1343,
402,
282,
1059,
12,
1830,
2672,
92,
365,
1202,
367,
2860,
626,
883,
7468,
523,
327,
26523,
315,
282,
1059,
14,
523,
283,
23227,
63,
3022,
356,
4505,
1,
23227,
63,
3022,
297,
523,
283,
13772,
63,
23227,
63,
3022,
356,
4505,
1,
14853,
63,
3022,
15,
2268,
297,
523,
283,
14853,
63,
3022,
356,
4505,
1,
14853,
63,
3022,
297,
523,
283,
22212,
63,
2339,
356,
4505,
92,
22212,
63,
2339,
297,
819,
327,
12568,
2860,
626,
1443,
506,
1202,
701,
4902,
283,
2200,
7,
4545,
14,
523,
327,
2136,
3550,
10269,
367,
3520,
2860,
641,
314,
23158,
1380,
6661,
282,
523,
327,
2332,
14,
523,
283,
13578,
63,
7321,
63,
5441,
356,
20044,
1231,
7293,
523,
283,
13578,
63,
7321,
63,
3022,
2339,
356,
20044,
3475,
7293,
523,
283,
13578,
63,
7321,
63,
3243,
356,
20044,
1365,
7293,
523,
283,
13578,
63,
7321,
63,
2472,
356,
20044,
832,
7293,
523,
283,
13578,
63,
7321,
63,
2339,
356,
20044,
354,
7293,
199,
93,
199,
199,
3,
510,
416,
1411,
83,
4287,
14,
199,
4679,
63,
8460,
63,
2865,
63,
4758,
63,
1612,
275,
942,
199,
4679,
63,
8460,
63,
515,
63,
7786,
275,
942,
199,
4679,
63,
2911,
63,
4553,
63,
509,
63,
4423,
275,
942,
199,
199,
3,
3254,
26,
9658,
734,
4212,
370,
440,
1900,
2402,
1591,
2251,
315,
314,
2222,
13,
7925,
13,
2014,
199,
3,
1930,
1380,
642,
365,
5223,
12,
436,
4756,
625,
31565,
14,
199,
4679,
63,
9823,
63,
6048,
63,
30116,
275,
334,
523,
747,
14,
2314,
14,
362,
360,
14884,
63,
28368,
29911,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
689,
63,
1102,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
2571,
63,
1102,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
12206,
63,
1102,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
689,
63,
1375,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
2571,
63,
1375,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
12206,
63,
1375,
1333,
421,
199,
318,
19828,
4793,
8,
1273,
12,
2403,
304,
523,
340,
1680,
14,
2460,
8,
1861,
304,
272,
372,
1680,
59,
552,
8,
1861,
15405,
523,
372,
1680,
421,
199,
318,
29335,
8529,
5201,
8,
1273,
12,
8541,
304,
523,
408,
12838,
282,
1059,
4066,
626,
652,
911,
506,
11922,
465,
282,
2849,
1423,
523,
701,
314,
5218,
1041,
523,
327,
3898,
728,
2419,
19595,
370,
3874,
314,
4875,
5218,
4110,
12,
2951,
523,
327,
22671,
2863,
9949,
7869,
436,
6313,
7003,
587,
14,
523,
340,
295,
14,
1431,
8,
82,
23811,
65,
13,
6353,
13,
58,
16,
13,
25,
10683,
14,
1103,
15,
20253,
4268,
1680,
304,
272,
372,
1680,
221,
327,
3091,
18593,
5784,
14,
523,
340,
8541,
508,
283,
2676,
356,
272,
372,
4902,
14,
8338,
63,
20526,
14,
12838,
1858,
17796,
1173,
8,
1273,
9,
523,
372,
21673,
435,
1680,
14,
1814,
27769,
21673,
435,
283,
3212,
30385,
435,
3546,
531,
221,
435,
21673,
421,
199,
318,
13930,
8,
68,
12,
8541,
304,
523,
408,
32488,
282,
22335,
5627,
436,
2529,
282,
446,
36,
2725,
626,
1159,
14822,
13,
436,
523,
5218,
13,
13572,
1041,
523,
340,
8541,
508,
283,
2676,
356,
272,
327,
824,
14,
5803,
19058,
8785,
327,
4110,
543,
275,
315,
876,
496,
823,
269,
10269,
367,
272,
327,
2005,
4499,
14,
18365,
279,
13,
2143,
370,
1736,
6818,
626,
14,
272,
366,
275,
366,
14,
1814,
7863,
297,
6468,
5,
1644,
79,
7,
450,
6206,
7863,
1333,
523,
372,
29335,
8529,
5201,
8,
8675,
63,
7093,
14,
3765,
3654,
36,
7,
435,
366,
395,
8541,
9,
421,
199,
533,
10256,
26,
523,
408,
4277,
8469,
314,
3792,
1202,
4453,
282,
2849,
4902,
1347,
14,
819,
1448,
716,
3163,
12,
10015,
282,
2849,
1347,
437,
365,
282,
6779,
402,
7124,
26,
819,
413,
9,
5445,
15,
4423,
15,
16847,
221,
12821,
1350,
15,
4435,
15,
6839,
14,
523,
499,
9,
6555,
83,
4519,
12821,
1275,
79,
1584,
523,
650,
9,
2142,
8295,
12821,
282,
3366,
334,
4342,
15,
5904,
9,
523,
841,
9,
8844,
4483,
32716,
314,
3432,
315,
282,
4497,
8844,
819,
334,
9874,
402,
3520,
7124,
883,
506,
2716,
4959,
819,
11606,
282,
1900,
7794,
1126,
16657,
12,
282,
11410,
1347,
699,
4293,
2951,
523,
11687,
641,
314,
2061
] |
[
1898,
334,
67,
9,
6171,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
646,
1331,
199,
646,
8337,
199,
646,
12866,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
4673,
199,
646,
3873,
199,
646,
984,
199,
646,
4902,
199,
646,
4902,
14,
2330,
199,
646,
4902,
14,
8338,
63,
20526,
199,
646,
4902,
14,
3053,
54,
6195,
2270,
465,
11694,
6195,
2270,
199,
646,
4902,
14,
8701,
63,
20526,
199,
199,
504,
4902,
14,
2330,
492,
2372,
23027,
21860,
199,
646,
4902,
14,
8675,
63,
7093,
465,
14822,
63,
7093,
199,
199,
4679,
63,
885,
63,
3669,
275,
469,
523,
283,
21623,
63,
6351,
356,
3260,
523,
283,
21623,
63,
12273,
356,
3260,
523,
283,
10449,
63,
5617,
63,
6351,
356,
283,
773,
297,
523,
283,
10449,
63,
5617,
63,
12273,
356,
1987,
65,
297,
523,
283,
13772,
63,
5617,
63,
6351,
356,
283,
773,
297,
819,
327,
14133,
14292,
314,
2569,
2860,
370,
506,
6544,
461,
701,
314,
1900,
523,
327,
2656,
370,
314,
5827,
9918,
14,
221,
653,
4135,
20491,
1192,
3792,
370,
506,
523,
327,
6040,
737,
4902,
900,
14,
221,
4005,
7512,
642,
12,
13318,
3402,
4539,
523,
327,
2860,
6617,
543,
2672,
1,
436,
2672,
92,
334,
6777,
5386,
543,
282,
2672,
880,
4902,
19428,
652,
523,
327,
1077,
506,
10184,
1106,
1183,
12,
1325,
365,
4257,
376,
3866,
523,
327,
14822,
15,
5641,
1750,
9,
626,
787,
3032,
370,
4902,
2348,
1325,
11507,
523,
327,
2544,
3575,
734,
1901,
314,
1347,
1275,
8675,
1584,
27,
1937,
523,
327,
18890,
12246,
14,
523,
327,
2672,
1,
365,
1202,
367,
2860,
626,
2954,
282,
931,
436,
626,
883,
1454,
7468,
737,
523,
327,
314,
1343,
402,
282,
1059,
12,
1830,
2672,
92,
365,
1202,
367,
2860,
626,
883,
7468,
523,
327,
26523,
315,
282,
1059,
14,
523,
283,
23227,
63,
3022,
356,
4505,
1,
23227,
63,
3022,
297,
523,
283,
13772,
63,
23227,
63,
3022,
356,
4505,
1,
14853,
63,
3022,
15,
2268,
297,
523,
283,
14853,
63,
3022,
356,
4505,
1,
14853,
63,
3022,
297,
523,
283,
22212,
63,
2339,
356,
4505,
92,
22212,
63,
2339,
297,
819,
327,
12568,
2860,
626,
1443,
506,
1202,
701,
4902,
283,
2200,
7,
4545,
14,
523,
327,
2136,
3550,
10269,
367,
3520,
2860,
641,
314,
23158,
1380,
6661,
282,
523,
327,
2332,
14,
523,
283,
13578,
63,
7321,
63,
5441,
356,
20044,
1231,
7293,
523,
283,
13578,
63,
7321,
63,
3022,
2339,
356,
20044,
3475,
7293,
523,
283,
13578,
63,
7321,
63,
3243,
356,
20044,
1365,
7293,
523,
283,
13578,
63,
7321,
63,
2472,
356,
20044,
832,
7293,
523,
283,
13578,
63,
7321,
63,
2339,
356,
20044,
354,
7293,
199,
93,
199,
199,
3,
510,
416,
1411,
83,
4287,
14,
199,
4679,
63,
8460,
63,
2865,
63,
4758,
63,
1612,
275,
942,
199,
4679,
63,
8460,
63,
515,
63,
7786,
275,
942,
199,
4679,
63,
2911,
63,
4553,
63,
509,
63,
4423,
275,
942,
199,
199,
3,
3254,
26,
9658,
734,
4212,
370,
440,
1900,
2402,
1591,
2251,
315,
314,
2222,
13,
7925,
13,
2014,
199,
3,
1930,
1380,
642,
365,
5223,
12,
436,
4756,
625,
31565,
14,
199,
4679,
63,
9823,
63,
6048,
63,
30116,
275,
334,
523,
747,
14,
2314,
14,
362,
360,
14884,
63,
28368,
29911,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
689,
63,
1102,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
2571,
63,
1102,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
12206,
63,
1102,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
689,
63,
1375,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
2571,
63,
1375,
358,
503,
523,
747,
14,
2314,
14,
362,
360,
12206,
63,
1375,
1333,
421,
199,
318,
19828,
4793,
8,
1273,
12,
2403,
304,
523,
340,
1680,
14,
2460,
8,
1861,
304,
272,
372,
1680,
59,
552,
8,
1861,
15405,
523,
372,
1680,
421,
199,
318,
29335,
8529,
5201,
8,
1273,
12,
8541,
304,
523,
408,
12838,
282,
1059,
4066,
626,
652,
911,
506,
11922,
465,
282,
2849,
1423,
523,
701,
314,
5218,
1041,
523,
327,
3898,
728,
2419,
19595,
370,
3874,
314,
4875,
5218,
4110,
12,
2951,
523,
327,
22671,
2863,
9949,
7869,
436,
6313,
7003,
587,
14,
523,
340,
295,
14,
1431,
8,
82,
23811,
65,
13,
6353,
13,
58,
16,
13,
25,
10683,
14,
1103,
15,
20253,
4268,
1680,
304,
272,
372,
1680,
221,
327,
3091,
18593,
5784,
14,
523,
340,
8541,
508,
283,
2676,
356,
272,
372,
4902,
14,
8338,
63,
20526,
14,
12838,
1858,
17796,
1173,
8,
1273,
9,
523,
372,
21673,
435,
1680,
14,
1814,
27769,
21673,
435,
283,
3212,
30385,
435,
3546,
531,
221,
435,
21673,
421,
199,
318,
13930,
8,
68,
12,
8541,
304,
523,
408,
32488,
282,
22335,
5627,
436,
2529,
282,
446,
36,
2725,
626,
1159,
14822,
13,
436,
523,
5218,
13,
13572,
1041,
523,
340,
8541,
508,
283,
2676,
356,
272,
327,
824,
14,
5803,
19058,
8785,
327,
4110,
543,
275,
315,
876,
496,
823,
269,
10269,
367,
272,
327,
2005,
4499,
14,
18365,
279,
13,
2143,
370,
1736,
6818,
626,
14,
272,
366,
275,
366,
14,
1814,
7863,
297,
6468,
5,
1644,
79,
7,
450,
6206,
7863,
1333,
523,
372,
29335,
8529,
5201,
8,
8675,
63,
7093,
14,
3765,
3654,
36,
7,
435,
366,
395,
8541,
9,
421,
199,
533,
10256,
26,
523,
408,
4277,
8469,
314,
3792,
1202,
4453,
282,
2849,
4902,
1347,
14,
819,
1448,
716,
3163,
12,
10015,
282,
2849,
1347,
437,
365,
282,
6779,
402,
7124,
26,
819,
413,
9,
5445,
15,
4423,
15,
16847,
221,
12821,
1350,
15,
4435,
15,
6839,
14,
523,
499,
9,
6555,
83,
4519,
12821,
1275,
79,
1584,
523,
650,
9,
2142,
8295,
12821,
282,
3366,
334,
4342,
15,
5904,
9,
523,
841,
9,
8844,
4483,
32716,
314,
3432,
315,
282,
4497,
8844,
819,
334,
9874,
402,
3520,
7124,
883,
506,
2716,
4959,
819,
11606,
282,
1900,
7794,
1126,
16657,
12,
282,
11410,
1347,
699,
4293,
2951,
523,
11687,
641,
314,
2061,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
hanselke/erpnext-1
|
erpnext/config/manufacturing.py
|
38
|
2674
|
from __future__ import unicode_literals
from frappe import _
def get_data():
return [
{
"label": _("Documents"),
"icon": "icon-star",
"items": [
{
"type": "doctype",
"name": "BOM",
"description": _("Bill of Materials (BOM)"),
"label": _("Bill of Material")
},
{
"type": "doctype",
"name": "Production Order",
"description": _("Orders released for production."),
},
{
"type": "doctype",
"name": "Time Log",
"description": _("Time Logs for manufacturing."),
},
{
"type": "doctype",
"name": "Item",
"description": _("All Products or Services."),
},
{
"type": "doctype",
"name": "Workstation",
"description": _("Where manufacturing operations are carried."),
},
{
"type": "doctype",
"name": "Operation",
"description": _("Details of the operations carried out."),
},
]
},
{
"label": _("Tools"),
"icon": "icon-wrench",
"items": [
{
"type": "doctype",
"name": "Production Planning Tool",
"description": _("Generate Material Requests (MRP) and Production Orders."),
},
{
"type": "doctype",
"name": "BOM Replace Tool",
"description": _("Replace Item / BOM in all BOMs"),
},
{
"type": "page",
"name": "bom-browser",
"icon": "icon-sitemap",
"label": _("BOM Browser"),
"description": _("Tree of Bill of Materials"),
"doctype": "BOM"
}
]
},
{
"label": _("Setup"),
"items": [
{
"type": "doctype",
"name": "Manufacturing Settings",
"description": _("Global settings for all manufacturing processes."),
}
]
},
{
"label": _("Standard Reports"),
"icon": "icon-list",
"items": [
{
"type": "report",
"is_query_report": True,
"name": "Open Production Orders",
"doctype": "Production Order"
},
{
"type": "report",
"is_query_report": True,
"name": "Production Orders in Progress",
"doctype": "Production Order"
},
{
"type": "report",
"is_query_report": True,
"name": "Issued Items Against Production Order",
"doctype": "Production Order"
},
{
"type": "report",
"is_query_report": True,
"name": "Completed Production Orders",
"doctype": "Production Order"
},
{
"type": "report",
"is_query_report": True,
"name": "BOM Search",
"doctype": "BOM"
},
]
},
{
"label": _("Help"),
"icon": "icon-facetime-video",
"items": [
{
"type": "help",
"label": _("Bill of Materials"),
"youtube_id": "hDV0c1OeWLo"
},
]
}
]
|
agpl-3.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
6950,
492,
485,
199,
199,
318,
664,
63,
576,
837,
199,
198,
1107,
359,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
26872,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
7848,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
19550,
401,
1871,
198,
2,
1802,
582,
3824,
34,
778,
402,
26570,
83,
334,
19550,
13185,
1871,
198,
2,
1302,
582,
3824,
34,
778,
402,
26570,
531,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
26432,
9240,
401,
1871,
198,
2,
1802,
582,
3824,
4738,
83,
14286,
367,
9920,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
1366,
5297,
401,
1871,
198,
2,
1802,
582,
3824,
1366,
3835,
458,
367,
2169,
7415,
319,
4039,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
2081,
401,
1871,
198,
2,
1802,
582,
3824,
2422,
32411,
503,
21813,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
6517,
10600,
401,
1871,
198,
2,
1802,
582,
3824,
26493,
2169,
7415,
319,
4039,
5331,
787,
9590,
18906,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
6044,
401,
1871,
198,
2,
1802,
582,
3824,
11347,
402,
314,
5331,
9590,
18906,
734,
7651,
1585,
198,
1386,
6319,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
11654,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
87,
15148,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
26432,
7497,
11495,
15650,
401,
1871,
198,
2,
1802,
582,
3824,
6864,
26570,
20260,
334,
45,
18612,
9,
436,
24114,
4236,
7735,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
19550,
14402,
15650,
401,
1871,
198,
2,
1802,
582,
3824,
11328,
7020,
1182,
17720,
315,
1006,
4367,
13586,
1288,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
1606,
401,
1871,
198,
2,
354,
582,
298,
16302,
13,
5750,
401,
1871,
198,
2,
4677,
582,
298,
4677,
13,
17205,
401,
1871,
198,
2,
1302,
582,
3824,
19550,
27620,
1288,
1871,
198,
2,
1802,
582,
3824,
3987,
402,
699,
778,
402,
26570,
83,
1288,
1871,
198,
2,
6356,
582,
298,
19550,
2,
1585,
198,
93,
686,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
8555,
1288,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
2395,
7415,
319,
4039,
13303,
401,
1871,
198,
2,
1802,
582,
3824,
7025,
2202,
367,
1006,
2169,
7415,
319,
4039,
10358,
7651,
1585,
198,
93,
686,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
9232,
799,
5203,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
513,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
4299,
24114,
4236,
7735,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
26432,
4236,
7735,
315,
21211,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
17106,
68,
20720,
437,
13020,
270,
24114,
9240,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
19908,
24114,
4236,
7735,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
19550,
8730,
401,
1871,
198,
2,
6356,
582,
298,
19550,
2,
1585,
198,
1386,
686,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
8673,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
1409,
521,
13,
3722,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3437,
401,
1871,
198,
2,
1302,
582,
3824,
34,
778,
402,
26570,
83,
1288,
1871,
198,
2,
9788,
63,
344,
582,
298,
72,
6741,
16,
67,
17,
47,
69,
55,
2041,
2,
1585,
198,
1386,
686,
198,
61,
507,
198,
93,
199,
198,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
6950,
492,
485,
199,
199,
318,
664,
63,
576,
837,
199,
198,
1107,
359,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
26872,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
7848,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
19550,
401,
1871,
198,
2,
1802,
582,
3824,
34,
778,
402,
26570,
83,
334,
19550,
13185,
1871,
198,
2,
1302,
582,
3824,
34,
778,
402,
26570,
531,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
26432,
9240,
401,
1871,
198,
2,
1802,
582,
3824,
4738,
83,
14286,
367,
9920,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
1366,
5297,
401,
1871,
198,
2,
1802,
582,
3824,
1366,
3835,
458,
367,
2169,
7415,
319,
4039,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
2081,
401,
1871,
198,
2,
1802,
582,
3824,
2422,
32411,
503,
21813,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
6517,
10600,
401,
1871,
198,
2,
1802,
582,
3824,
26493,
2169,
7415,
319,
4039,
5331,
787,
9590,
18906,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
6044,
401,
1871,
198,
2,
1802,
582,
3824,
11347,
402,
314,
5331,
9590,
18906,
734,
7651,
1585,
198,
1386,
6319,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
11654,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
87,
15148,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
26432,
7497,
11495,
15650,
401,
1871,
198,
2,
1802,
582,
3824,
6864,
26570,
20260,
334,
45,
18612,
9,
436,
24114,
4236,
7735,
7651,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
19550,
14402,
15650,
401,
1871,
198,
2,
1802,
582,
3824,
11328,
7020,
1182,
17720,
315,
1006,
4367,
13586,
1288,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
1606,
401,
1871,
198,
2,
354,
582,
298,
16302,
13,
5750,
401,
1871,
198,
2,
4677,
582,
298,
4677,
13,
17205,
401,
1871,
198,
2,
1302,
582,
3824,
19550,
27620,
1288,
1871,
198,
2,
1802,
582,
3824,
3987,
402,
699,
778,
402,
26570,
83,
1288,
1871,
198,
2,
6356,
582,
298,
19550,
2,
1585,
198,
93,
686,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
8555,
1288,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
6356,
401,
1871,
198,
2,
354,
582,
298,
2395,
7415,
319,
4039,
13303,
401,
1871,
198,
2,
1802,
582,
3824,
7025,
2202,
367,
1006,
2169,
7415,
319,
4039,
10358,
7651,
1585,
198,
93,
686,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
9232,
799,
5203,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
513,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
4299,
24114,
4236,
7735,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
26432,
4236,
7735,
315,
21211,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
17106,
68,
20720,
437,
13020,
270,
24114,
9240,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
19908,
24114,
4236,
7735,
401,
1871,
198,
2,
6356,
582,
298,
26432,
9240,
2,
1585,
198,
1386,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3070,
401,
1871,
198,
2,
374,
63,
1131,
63,
3070,
582,
715,
12,
1871,
198,
2,
354,
582,
298,
19550,
8730,
401,
1871,
198,
2,
6356,
582,
298,
19550,
2,
1585,
198,
1386,
686,
198,
61,
507,
198,
1386,
507,
198,
91,
686,
198,
2,
1302,
582,
3824,
8673,
1288,
686,
198,
2,
4677,
582,
298,
4677,
13,
1409,
521,
13,
3722,
401,
686,
198,
2,
1744,
582,
359,
1585,
198,
91,
1871,
198,
2,
466,
582,
298,
3437,
401,
1871,
198,
2,
1302,
582,
3824,
34,
778,
402,
26570,
83,
1288,
1871,
198,
2,
9788,
63,
344,
582,
298,
72,
6741,
16,
67,
17,
47,
69,
55,
2041,
2,
1585,
198,
1386,
686,
198,
61,
507,
198,
93,
199,
198,
61,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sthirugn/robottelo
|
robottelo/ui/architecture.py
|
2
|
1561
|
# -*- encoding: utf-8 -*-
"""Implements Architecture UI"""
from robottelo.constants import FILTER
from robottelo.ui.base import Base
from robottelo.ui.locators import common_locators, locators
from robottelo.ui.navigator import Navigator
class Architecture(Base):
"""Manipulates architecture from UI"""
def navigate_to_entity(self):
"""Navigate to Architecture entity page"""
Navigator(self.browser).go_to_architectures()
def _search_locator(self):
"""Specify locator for Architecture entity search procedure"""
return locators['arch.arch_name']
def create(self, name, os_names=None):
"""Creates new architecture from UI with existing OS"""
self.click(locators['arch.new'])
self.assign_value(locators['arch.name'], name)
self.configure_entity(os_names, FILTER['arch_os'])
self.click(common_locators['submit'])
def delete(self, name, really=True):
"""Delete existing architecture from UI"""
self.delete_entity(
name,
really,
locators['arch.delete'],
)
def update(self, old_name, new_name=None, os_names=None,
new_os_names=None):
"""Update existing arch's name and OS"""
self.search_and_click(old_name)
if new_name:
self.assign_value(locators['arch.name'], new_name)
self.configure_entity(
os_names,
FILTER['arch_os'],
new_entity_list=new_os_names
)
self.click(common_locators['submit'])
|
gpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
624,
29452,
19521,
10497,
14041,
624,
199,
199,
504,
14544,
266,
320,
14,
5559,
492,
23244,
199,
504,
14544,
266,
320,
14,
1907,
14,
1095,
492,
3523,
199,
504,
14544,
266,
320,
14,
1907,
14,
2102,
2750,
492,
2863,
63,
2102,
2750,
12,
4355,
2750,
199,
504,
14544,
266,
320,
14,
1907,
14,
15595,
24934,
492,
20721,
24934,
421,
199,
533,
19521,
10497,
8,
1563,
304,
272,
408,
2395,
711,
15409,
15931,
687,
14041,
624,
339,
347,
20850,
63,
475,
63,
4502,
8,
277,
304,
267,
408,
31914,
370,
19521,
10497,
4642,
2034,
624,
267,
20721,
24934,
8,
277,
14,
5750,
680,
1939,
63,
475,
63,
1047,
1175,
22004,
342,
339,
347,
485,
1733,
63,
6354,
8,
277,
304,
267,
408,
17768,
14067,
367,
19521,
10497,
4642,
2754,
17782,
624,
267,
372,
4355,
2750,
459,
1047,
14,
1047,
63,
354,
418,
339,
347,
1218,
8,
277,
12,
536,
12,
747,
63,
1247,
29,
403,
304,
267,
408,
10607,
892,
15931,
687,
14041,
543,
3411,
4403,
624,
267,
291,
14,
4891,
8,
2102,
2750,
459,
1047,
14,
1222,
1105,
267,
291,
14,
5038,
63,
585,
8,
2102,
2750,
459,
1047,
14,
354,
995,
536,
9,
267,
291,
14,
6472,
63,
4502,
8,
736,
63,
1247,
12,
23244,
459,
1047,
63,
736,
1105,
267,
291,
14,
4891,
8,
2330,
63,
2102,
2750,
459,
7275,
1105,
339,
347,
3145,
8,
277,
12,
536,
12,
7710,
29,
549,
304,
267,
408,
5392,
3411,
15931,
687,
14041,
624,
267,
291,
14,
1807,
63,
4502,
8,
288,
536,
12,
288,
7710,
12,
288,
4355,
2750,
459,
1047,
14,
1807,
995,
267,
776,
339,
347,
1678,
8,
277,
12,
2269,
63,
354,
12,
892,
63,
354,
29,
403,
12,
747,
63,
1247,
29,
403,
12,
2049,
892,
63,
736,
63,
1247,
29,
403,
304,
267,
408,
4152,
3411,
3819,
1159,
536,
436,
4403,
624,
267,
291,
14,
1733,
63,
460,
63,
4891,
8,
1753,
63,
354,
9,
267,
340,
892,
63,
354,
26,
288,
291,
14,
5038,
63,
585,
8,
2102,
2750,
459,
1047,
14,
354,
995,
892,
63,
354,
9,
267,
291,
14,
6472,
63,
4502,
8,
288,
747,
63,
1247,
12,
288,
23244,
459,
1047,
63,
736,
995,
288,
892,
63,
4502,
63,
513,
29,
1222,
63,
736,
63,
1247,
267,
776,
267,
291,
14,
4891,
8,
2330,
63,
2102,
2750,
459,
7275,
1105,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
624,
29452,
19521,
10497,
14041,
624,
199,
199,
504,
14544,
266,
320,
14,
5559,
492,
23244,
199,
504,
14544,
266,
320,
14,
1907,
14,
1095,
492,
3523,
199,
504,
14544,
266,
320,
14,
1907,
14,
2102,
2750,
492,
2863,
63,
2102,
2750,
12,
4355,
2750,
199,
504,
14544,
266,
320,
14,
1907,
14,
15595,
24934,
492,
20721,
24934,
421,
199,
533,
19521,
10497,
8,
1563,
304,
272,
408,
2395,
711,
15409,
15931,
687,
14041,
624,
339,
347,
20850,
63,
475,
63,
4502,
8,
277,
304,
267,
408,
31914,
370,
19521,
10497,
4642,
2034,
624,
267,
20721,
24934,
8,
277,
14,
5750,
680,
1939,
63,
475,
63,
1047,
1175,
22004,
342,
339,
347,
485,
1733,
63,
6354,
8,
277,
304,
267,
408,
17768,
14067,
367,
19521,
10497,
4642,
2754,
17782,
624,
267,
372,
4355,
2750,
459,
1047,
14,
1047,
63,
354,
418,
339,
347,
1218,
8,
277,
12,
536,
12,
747,
63,
1247,
29,
403,
304,
267,
408,
10607,
892,
15931,
687,
14041,
543,
3411,
4403,
624,
267,
291,
14,
4891,
8,
2102,
2750,
459,
1047,
14,
1222,
1105,
267,
291,
14,
5038,
63,
585,
8,
2102,
2750,
459,
1047,
14,
354,
995,
536,
9,
267,
291,
14,
6472,
63,
4502,
8,
736,
63,
1247,
12,
23244,
459,
1047,
63,
736,
1105,
267,
291,
14,
4891,
8,
2330,
63,
2102,
2750,
459,
7275,
1105,
339,
347,
3145,
8,
277,
12,
536,
12,
7710,
29,
549,
304,
267,
408,
5392,
3411,
15931,
687,
14041,
624,
267,
291,
14,
1807,
63,
4502,
8,
288,
536,
12,
288,
7710,
12,
288,
4355,
2750,
459,
1047,
14,
1807,
995,
267,
776,
339,
347,
1678,
8,
277,
12,
2269,
63,
354,
12,
892,
63,
354,
29,
403,
12,
747,
63,
1247,
29,
403,
12,
2049,
892,
63,
736,
63,
1247,
29,
403,
304,
267,
408,
4152,
3411,
3819,
1159,
536,
436,
4403,
624,
267,
291,
14,
1733,
63,
460,
63,
4891,
8,
1753,
63,
354,
9,
267,
340,
892,
63,
354,
26,
288,
291,
14,
5038,
63,
585,
8,
2102,
2750,
459,
1047,
14,
354,
995,
892,
63,
354,
9,
267,
291,
14,
6472,
63,
4502,
8,
288,
747,
63,
1247,
12,
288,
23244,
459,
1047,
63,
736,
995,
288,
892,
63,
4502,
63,
513,
29,
1222,
63,
736,
63,
1247,
267,
776,
267,
291,
14,
4891,
8,
2330,
63,
2102,
2750,
459,
7275,
1105,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jjingrong/PONUS-1.2
|
venv/Lib/encodings/aliases.py
|
418
|
14848
|
""" Encoding Aliases Support
This module is used by the encodings package search function to
map encodings names to module names.
Note that the search function normalizes the encoding names before
doing the lookup, so the mapping will have to map normalized
encoding names to module names.
Contents:
The following aliases dictionary contains mappings of all IANA
character set names for which the Python core library provides
codecs. In addition to these, a few Python specific codec
aliases have also been added.
"""
aliases = {
# Please keep this list sorted alphabetically by value !
# ascii codec
'646' : 'ascii',
'ansi_x3.4_1968' : 'ascii',
'ansi_x3_4_1968' : 'ascii', # some email headers use this non-standard name
'ansi_x3.4_1986' : 'ascii',
'cp367' : 'ascii',
'csascii' : 'ascii',
'ibm367' : 'ascii',
'iso646_us' : 'ascii',
'iso_646.irv_1991' : 'ascii',
'iso_ir_6' : 'ascii',
'us' : 'ascii',
'us_ascii' : 'ascii',
# base64_codec codec
'base64' : 'base64_codec',
'base_64' : 'base64_codec',
# big5 codec
'big5_tw' : 'big5',
'csbig5' : 'big5',
# big5hkscs codec
'big5_hkscs' : 'big5hkscs',
'hkscs' : 'big5hkscs',
# bz2_codec codec
'bz2' : 'bz2_codec',
# cp037 codec
'037' : 'cp037',
'csibm037' : 'cp037',
'ebcdic_cp_ca' : 'cp037',
'ebcdic_cp_nl' : 'cp037',
'ebcdic_cp_us' : 'cp037',
'ebcdic_cp_wt' : 'cp037',
'ibm037' : 'cp037',
'ibm039' : 'cp037',
# cp1026 codec
'1026' : 'cp1026',
'csibm1026' : 'cp1026',
'ibm1026' : 'cp1026',
# cp1140 codec
'1140' : 'cp1140',
'ibm1140' : 'cp1140',
# cp1250 codec
'1250' : 'cp1250',
'windows_1250' : 'cp1250',
# cp1251 codec
'1251' : 'cp1251',
'windows_1251' : 'cp1251',
# cp1252 codec
'1252' : 'cp1252',
'windows_1252' : 'cp1252',
# cp1253 codec
'1253' : 'cp1253',
'windows_1253' : 'cp1253',
# cp1254 codec
'1254' : 'cp1254',
'windows_1254' : 'cp1254',
# cp1255 codec
'1255' : 'cp1255',
'windows_1255' : 'cp1255',
# cp1256 codec
'1256' : 'cp1256',
'windows_1256' : 'cp1256',
# cp1257 codec
'1257' : 'cp1257',
'windows_1257' : 'cp1257',
# cp1258 codec
'1258' : 'cp1258',
'windows_1258' : 'cp1258',
# cp424 codec
'424' : 'cp424',
'csibm424' : 'cp424',
'ebcdic_cp_he' : 'cp424',
'ibm424' : 'cp424',
# cp437 codec
'437' : 'cp437',
'cspc8codepage437' : 'cp437',
'ibm437' : 'cp437',
# cp500 codec
'500' : 'cp500',
'csibm500' : 'cp500',
'ebcdic_cp_be' : 'cp500',
'ebcdic_cp_ch' : 'cp500',
'ibm500' : 'cp500',
# cp775 codec
'775' : 'cp775',
'cspc775baltic' : 'cp775',
'ibm775' : 'cp775',
# cp850 codec
'850' : 'cp850',
'cspc850multilingual' : 'cp850',
'ibm850' : 'cp850',
# cp852 codec
'852' : 'cp852',
'cspcp852' : 'cp852',
'ibm852' : 'cp852',
# cp855 codec
'855' : 'cp855',
'csibm855' : 'cp855',
'ibm855' : 'cp855',
# cp857 codec
'857' : 'cp857',
'csibm857' : 'cp857',
'ibm857' : 'cp857',
# cp858 codec
'858' : 'cp858',
'csibm858' : 'cp858',
'ibm858' : 'cp858',
# cp860 codec
'860' : 'cp860',
'csibm860' : 'cp860',
'ibm860' : 'cp860',
# cp861 codec
'861' : 'cp861',
'cp_is' : 'cp861',
'csibm861' : 'cp861',
'ibm861' : 'cp861',
# cp862 codec
'862' : 'cp862',
'cspc862latinhebrew' : 'cp862',
'ibm862' : 'cp862',
# cp863 codec
'863' : 'cp863',
'csibm863' : 'cp863',
'ibm863' : 'cp863',
# cp864 codec
'864' : 'cp864',
'csibm864' : 'cp864',
'ibm864' : 'cp864',
# cp865 codec
'865' : 'cp865',
'csibm865' : 'cp865',
'ibm865' : 'cp865',
# cp866 codec
'866' : 'cp866',
'csibm866' : 'cp866',
'ibm866' : 'cp866',
# cp869 codec
'869' : 'cp869',
'cp_gr' : 'cp869',
'csibm869' : 'cp869',
'ibm869' : 'cp869',
# cp932 codec
'932' : 'cp932',
'ms932' : 'cp932',
'mskanji' : 'cp932',
'ms_kanji' : 'cp932',
# cp949 codec
'949' : 'cp949',
'ms949' : 'cp949',
'uhc' : 'cp949',
# cp950 codec
'950' : 'cp950',
'ms950' : 'cp950',
# euc_jis_2004 codec
'jisx0213' : 'euc_jis_2004',
'eucjis2004' : 'euc_jis_2004',
'euc_jis2004' : 'euc_jis_2004',
# euc_jisx0213 codec
'eucjisx0213' : 'euc_jisx0213',
# euc_jp codec
'eucjp' : 'euc_jp',
'ujis' : 'euc_jp',
'u_jis' : 'euc_jp',
# euc_kr codec
'euckr' : 'euc_kr',
'korean' : 'euc_kr',
'ksc5601' : 'euc_kr',
'ks_c_5601' : 'euc_kr',
'ks_c_5601_1987' : 'euc_kr',
'ksx1001' : 'euc_kr',
'ks_x_1001' : 'euc_kr',
# gb18030 codec
'gb18030_2000' : 'gb18030',
# gb2312 codec
'chinese' : 'gb2312',
'csiso58gb231280' : 'gb2312',
'euc_cn' : 'gb2312',
'euccn' : 'gb2312',
'eucgb2312_cn' : 'gb2312',
'gb2312_1980' : 'gb2312',
'gb2312_80' : 'gb2312',
'iso_ir_58' : 'gb2312',
# gbk codec
'936' : 'gbk',
'cp936' : 'gbk',
'ms936' : 'gbk',
# hex_codec codec
'hex' : 'hex_codec',
# hp_roman8 codec
'roman8' : 'hp_roman8',
'r8' : 'hp_roman8',
'csHPRoman8' : 'hp_roman8',
# hz codec
'hzgb' : 'hz',
'hz_gb' : 'hz',
'hz_gb_2312' : 'hz',
# iso2022_jp codec
'csiso2022jp' : 'iso2022_jp',
'iso2022jp' : 'iso2022_jp',
'iso_2022_jp' : 'iso2022_jp',
# iso2022_jp_1 codec
'iso2022jp_1' : 'iso2022_jp_1',
'iso_2022_jp_1' : 'iso2022_jp_1',
# iso2022_jp_2 codec
'iso2022jp_2' : 'iso2022_jp_2',
'iso_2022_jp_2' : 'iso2022_jp_2',
# iso2022_jp_2004 codec
'iso_2022_jp_2004' : 'iso2022_jp_2004',
'iso2022jp_2004' : 'iso2022_jp_2004',
# iso2022_jp_3 codec
'iso2022jp_3' : 'iso2022_jp_3',
'iso_2022_jp_3' : 'iso2022_jp_3',
# iso2022_jp_ext codec
'iso2022jp_ext' : 'iso2022_jp_ext',
'iso_2022_jp_ext' : 'iso2022_jp_ext',
# iso2022_kr codec
'csiso2022kr' : 'iso2022_kr',
'iso2022kr' : 'iso2022_kr',
'iso_2022_kr' : 'iso2022_kr',
# iso8859_10 codec
'csisolatin6' : 'iso8859_10',
'iso_8859_10' : 'iso8859_10',
'iso_8859_10_1992' : 'iso8859_10',
'iso_ir_157' : 'iso8859_10',
'l6' : 'iso8859_10',
'latin6' : 'iso8859_10',
# iso8859_11 codec
'thai' : 'iso8859_11',
'iso_8859_11' : 'iso8859_11',
'iso_8859_11_2001' : 'iso8859_11',
# iso8859_13 codec
'iso_8859_13' : 'iso8859_13',
'l7' : 'iso8859_13',
'latin7' : 'iso8859_13',
# iso8859_14 codec
'iso_8859_14' : 'iso8859_14',
'iso_8859_14_1998' : 'iso8859_14',
'iso_celtic' : 'iso8859_14',
'iso_ir_199' : 'iso8859_14',
'l8' : 'iso8859_14',
'latin8' : 'iso8859_14',
# iso8859_15 codec
'iso_8859_15' : 'iso8859_15',
'l9' : 'iso8859_15',
'latin9' : 'iso8859_15',
# iso8859_16 codec
'iso_8859_16' : 'iso8859_16',
'iso_8859_16_2001' : 'iso8859_16',
'iso_ir_226' : 'iso8859_16',
'l10' : 'iso8859_16',
'latin10' : 'iso8859_16',
# iso8859_2 codec
'csisolatin2' : 'iso8859_2',
'iso_8859_2' : 'iso8859_2',
'iso_8859_2_1987' : 'iso8859_2',
'iso_ir_101' : 'iso8859_2',
'l2' : 'iso8859_2',
'latin2' : 'iso8859_2',
# iso8859_3 codec
'csisolatin3' : 'iso8859_3',
'iso_8859_3' : 'iso8859_3',
'iso_8859_3_1988' : 'iso8859_3',
'iso_ir_109' : 'iso8859_3',
'l3' : 'iso8859_3',
'latin3' : 'iso8859_3',
# iso8859_4 codec
'csisolatin4' : 'iso8859_4',
'iso_8859_4' : 'iso8859_4',
'iso_8859_4_1988' : 'iso8859_4',
'iso_ir_110' : 'iso8859_4',
'l4' : 'iso8859_4',
'latin4' : 'iso8859_4',
# iso8859_5 codec
'csisolatincyrillic' : 'iso8859_5',
'cyrillic' : 'iso8859_5',
'iso_8859_5' : 'iso8859_5',
'iso_8859_5_1988' : 'iso8859_5',
'iso_ir_144' : 'iso8859_5',
# iso8859_6 codec
'arabic' : 'iso8859_6',
'asmo_708' : 'iso8859_6',
'csisolatinarabic' : 'iso8859_6',
'ecma_114' : 'iso8859_6',
'iso_8859_6' : 'iso8859_6',
'iso_8859_6_1987' : 'iso8859_6',
'iso_ir_127' : 'iso8859_6',
# iso8859_7 codec
'csisolatingreek' : 'iso8859_7',
'ecma_118' : 'iso8859_7',
'elot_928' : 'iso8859_7',
'greek' : 'iso8859_7',
'greek8' : 'iso8859_7',
'iso_8859_7' : 'iso8859_7',
'iso_8859_7_1987' : 'iso8859_7',
'iso_ir_126' : 'iso8859_7',
# iso8859_8 codec
'csisolatinhebrew' : 'iso8859_8',
'hebrew' : 'iso8859_8',
'iso_8859_8' : 'iso8859_8',
'iso_8859_8_1988' : 'iso8859_8',
'iso_ir_138' : 'iso8859_8',
# iso8859_9 codec
'csisolatin5' : 'iso8859_9',
'iso_8859_9' : 'iso8859_9',
'iso_8859_9_1989' : 'iso8859_9',
'iso_ir_148' : 'iso8859_9',
'l5' : 'iso8859_9',
'latin5' : 'iso8859_9',
# johab codec
'cp1361' : 'johab',
'ms1361' : 'johab',
# koi8_r codec
'cskoi8r' : 'koi8_r',
# latin_1 codec
#
# Note that the latin_1 codec is implemented internally in C and a
# lot faster than the charmap codec iso8859_1 which uses the same
# encoding. This is why we discourage the use of the iso8859_1
# codec and alias it to latin_1 instead.
#
'8859' : 'latin_1',
'cp819' : 'latin_1',
'csisolatin1' : 'latin_1',
'ibm819' : 'latin_1',
'iso8859' : 'latin_1',
'iso8859_1' : 'latin_1',
'iso_8859_1' : 'latin_1',
'iso_8859_1_1987' : 'latin_1',
'iso_ir_100' : 'latin_1',
'l1' : 'latin_1',
'latin' : 'latin_1',
'latin1' : 'latin_1',
# mac_cyrillic codec
'maccyrillic' : 'mac_cyrillic',
# mac_greek codec
'macgreek' : 'mac_greek',
# mac_iceland codec
'maciceland' : 'mac_iceland',
# mac_latin2 codec
'maccentraleurope' : 'mac_latin2',
'maclatin2' : 'mac_latin2',
# mac_roman codec
'macroman' : 'mac_roman',
# mac_turkish codec
'macturkish' : 'mac_turkish',
# mbcs codec
'dbcs' : 'mbcs',
# ptcp154 codec
'csptcp154' : 'ptcp154',
'pt154' : 'ptcp154',
'cp154' : 'ptcp154',
'cyrillic_asian' : 'ptcp154',
# quopri_codec codec
'quopri' : 'quopri_codec',
'quoted_printable' : 'quopri_codec',
'quotedprintable' : 'quopri_codec',
# rot_13 codec
'rot13' : 'rot_13',
# shift_jis codec
'csshiftjis' : 'shift_jis',
'shiftjis' : 'shift_jis',
'sjis' : 'shift_jis',
's_jis' : 'shift_jis',
# shift_jis_2004 codec
'shiftjis2004' : 'shift_jis_2004',
'sjis_2004' : 'shift_jis_2004',
's_jis_2004' : 'shift_jis_2004',
# shift_jisx0213 codec
'shiftjisx0213' : 'shift_jisx0213',
'sjisx0213' : 'shift_jisx0213',
's_jisx0213' : 'shift_jisx0213',
# tactis codec
'tis260' : 'tactis',
# tis_620 codec
'tis620' : 'tis_620',
'tis_620_0' : 'tis_620',
'tis_620_2529_0' : 'tis_620',
'tis_620_2529_1' : 'tis_620',
'iso_ir_166' : 'tis_620',
# utf_16 codec
'u16' : 'utf_16',
'utf16' : 'utf_16',
# utf_16_be codec
'unicodebigunmarked' : 'utf_16_be',
'utf_16be' : 'utf_16_be',
# utf_16_le codec
'unicodelittleunmarked' : 'utf_16_le',
'utf_16le' : 'utf_16_le',
# utf_32 codec
'u32' : 'utf_32',
'utf32' : 'utf_32',
# utf_32_be codec
'utf_32be' : 'utf_32_be',
# utf_32_le codec
'utf_32le' : 'utf_32_le',
# utf_7 codec
'u7' : 'utf_7',
'utf7' : 'utf_7',
'unicode_1_1_utf_7' : 'utf_7',
# utf_8 codec
'u8' : 'utf_8',
'utf' : 'utf_8',
'utf8' : 'utf_8',
'utf8_ucs2' : 'utf_8',
'utf8_ucs4' : 'utf_8',
# uu_codec codec
'uu' : 'uu_codec',
# zlib_codec codec
'zip' : 'zlib_codec',
'zlib' : 'zlib_codec',
}
|
mit
|
[
624,
19694,
15170,
3274,
12502,
339,
961,
859,
365,
1202,
701,
314,
14134,
2559,
2754,
805,
370,
272,
2341,
14134,
1561,
370,
859,
1561,
14,
339,
3390,
626,
314,
2754,
805,
3293,
6491,
314,
2644,
1561,
2544,
272,
9689,
314,
4237,
12,
880,
314,
4412,
911,
1172,
370,
2341,
9657,
272,
2644,
1561,
370,
859,
1561,
14,
339,
6646,
83,
26,
398,
710,
2569,
5481,
2600,
3509,
13546,
402,
1006,
473,
879,
33,
267,
4528,
663,
1561,
367,
1314,
314,
2018,
6170,
3555,
6571,
267,
6010,
14,
1010,
10234,
370,
3520,
12,
282,
9284,
2018,
2488,
9076,
267,
5481,
1172,
2597,
2757,
3483,
14,
199,
199,
624,
199,
8602,
275,
469,
339,
327,
7754,
4215,
642,
769,
3355,
23331,
17269,
701,
574,
8546,
339,
327,
13294,
9076,
272,
283,
11387,
7,
4483,
520,
283,
4371,
297,
272,
283,
22204,
63,
88,
19,
14,
20,
63,
1167,
2333,
7,
258,
520,
283,
4371,
297,
272,
283,
22204,
63,
88,
19,
63,
20,
63,
1167,
2333,
7,
258,
520,
283,
4371,
297,
327,
2005,
3031,
2323,
675,
642,
2222,
13,
6807,
536,
272,
283,
22204,
63,
88,
19,
14,
20,
63,
1167,
1184,
7,
258,
520,
283,
4371,
297,
272,
283,
1850,
12684,
7,
4519,
520,
283,
4371,
297,
272,
283,
1259,
4371,
7,
3322,
520,
283,
4371,
297,
272,
283,
19870,
12684,
7,
3777,
520,
283,
4371,
297,
272,
283,
4595,
11387,
63,
527,
7,
3515,
520,
283,
4371,
297,
272,
283,
4595,
63,
11387,
14,
723,
86,
63,
7155,
17,
7,
257,
520,
283,
4371,
297,
272,
283,
4595,
63,
723,
63,
22,
7,
3698,
520,
283,
4371,
297,
272,
283,
527,
7,
463,
520,
283,
4371,
297,
272,
283,
527,
63,
4371,
7,
3698,
520,
283,
4371,
297,
339,
327,
1300,
772,
63,
9276,
9076,
272,
283,
1095,
772,
7,
3777,
520,
283,
1095,
772,
63,
9276,
297,
272,
283,
1095,
63,
772,
7,
3322,
520,
283,
1095,
772,
63,
9276,
297,
339,
327,
7282,
21,
9076,
272,
283,
5076,
21,
63,
8122,
7,
3322,
520,
283,
5076,
21,
297,
272,
283,
1259,
5076,
21,
7,
3777,
520,
283,
5076,
21,
297,
339,
327,
7282,
21,
21557,
551,
83,
9076,
272,
283,
5076,
21,
63,
21557,
551,
83,
7,
260,
520,
283,
5076,
21,
21557,
551,
83,
297,
272,
283,
21557,
551,
83,
7,
4519,
520,
283,
5076,
21,
21557,
551,
83,
297,
339,
327,
15055,
18,
63,
9276,
9076,
272,
283,
10582,
18,
7,
4483,
520,
283,
10582,
18,
63,
9276,
297,
339,
327,
7667,
18325,
9076,
272,
283,
18325,
7,
4483,
520,
283,
1850,
18325,
297,
272,
283,
67,
6637,
77,
18325,
7,
3698,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
696,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
7530,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
527,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
9115,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
19870,
18325,
7,
3777,
520,
283,
1850,
18325,
297,
272,
283,
19870,
10005,
7,
3777,
520,
283,
1850,
18325,
297,
339,
327,
7667,
32351,
9076,
272,
283,
32351,
7,
5185,
520,
283,
1850,
32351,
297,
272,
283,
67,
6637,
77,
32351,
7,
3515,
520,
283,
1850,
32351,
297,
272,
283,
19870,
32351,
7,
3322,
520,
283,
1850,
32351,
297,
339,
327,
7667,
845,
2167,
9076,
272,
283,
845,
2167,
7,
5185,
520,
283,
1850,
845,
2167,
297,
272,
283,
19870,
845,
2167,
7,
3322,
520,
283,
1850,
845,
2167,
297,
339,
327,
7667,
26572,
9076,
272,
283,
26572,
7,
5185,
520,
283,
1850,
26572,
297,
272,
283,
8258,
63,
26572,
7,
755,
520,
283,
1850,
26572,
297,
339,
327,
7667,
21381,
9076,
272,
283,
21381,
7,
5185,
520,
283,
1850,
21381,
297,
272,
283,
8258,
63,
21381,
7,
755,
520,
283,
1850,
21381,
297,
339,
327,
7667,
19364,
9076,
272,
283,
19364,
7,
5185,
520,
283,
1850,
19364,
297,
272,
283,
8258,
63,
19364,
7,
755,
520,
283,
1850,
19364,
297,
339,
327,
7667,
28452,
9076,
272,
283,
28452,
7,
5185,
520,
283,
1850,
28452,
297,
272,
283,
8258,
63,
28452,
7,
755,
520,
283,
1850,
28452,
297,
339,
327,
7667,
31195,
9076,
272,
283,
31195,
7,
5185,
520,
283,
1850,
31195,
297,
272,
283,
8258,
63,
31195,
7,
755,
520,
283,
1850,
31195,
297,
339,
327,
7667,
20197,
9076,
272,
283,
20197,
7,
5185,
520,
283,
1850,
20197,
297,
272,
283,
8258,
63,
20197,
7,
755,
520,
283,
1850,
20197,
297,
339,
327,
7667,
713,
1367,
9076,
272,
283,
713,
1367,
7,
5185,
520,
283,
1850,
713,
1367,
297,
272,
283,
8258,
63,
713,
1367,
7,
755,
520,
283,
1850,
713,
1367,
297,
339,
327,
7667,
713,
1641,
9076,
272,
283,
713,
1641,
7,
5185,
520,
283,
1850,
713,
1641,
297,
272,
283,
8258,
63,
713,
1641,
7,
755,
520,
283,
1850,
713,
1641,
297,
339,
327,
7667,
30572,
9076,
272,
283,
30572,
7,
5185,
520,
283,
1850,
30572,
297,
272,
283,
8258,
63,
30572,
7,
755,
520,
283,
1850,
30572,
297,
339,
327,
7667,
21089,
9076,
272,
283,
21089,
7,
4483,
520,
283,
1850,
21089,
297,
272,
283,
67,
6637,
77,
21089,
7,
3698,
520,
283,
1850,
21089,
297,
272,
283,
26816,
5000,
63,
1850,
63,
426,
7,
755,
520,
283,
1850,
21089,
297,
272,
283,
19870,
21089,
7,
3777,
520,
283,
1850,
21089,
297,
339,
327,
7667,
21717,
9076,
272,
283,
21717,
7,
4483,
520,
283,
1850,
21717,
297,
272,
283,
30608,
67,
24,
600,
1606,
21717,
7,
257,
520,
283,
1850,
21717,
297,
272,
283,
19870,
21717,
7,
3777,
520,
283,
1850,
21717,
297,
339,
327,
7667,
5783,
9076,
272,
283,
5783,
7,
4483,
520,
283,
1850,
5783,
297,
272,
283,
67,
6637,
77,
5783,
7,
3698,
520,
283,
1850,
5783,
297,
272,
283,
26816,
5000,
63,
1850,
63,
1235,
7,
755,
520,
283,
1850,
5783,
297,
272,
283,
26816,
5000,
63,
1850,
63,
335,
7,
755,
520,
283,
1850,
5783,
297,
272,
283,
19870,
5783,
7,
3777,
520,
283,
1850,
5783,
297,
339,
327,
7667,
12710,
9076,
272,
283,
12710,
7,
4483,
520,
283,
1850
] |
[
19694,
15170,
3274,
12502,
339,
961,
859,
365,
1202,
701,
314,
14134,
2559,
2754,
805,
370,
272,
2341,
14134,
1561,
370,
859,
1561,
14,
339,
3390,
626,
314,
2754,
805,
3293,
6491,
314,
2644,
1561,
2544,
272,
9689,
314,
4237,
12,
880,
314,
4412,
911,
1172,
370,
2341,
9657,
272,
2644,
1561,
370,
859,
1561,
14,
339,
6646,
83,
26,
398,
710,
2569,
5481,
2600,
3509,
13546,
402,
1006,
473,
879,
33,
267,
4528,
663,
1561,
367,
1314,
314,
2018,
6170,
3555,
6571,
267,
6010,
14,
1010,
10234,
370,
3520,
12,
282,
9284,
2018,
2488,
9076,
267,
5481,
1172,
2597,
2757,
3483,
14,
199,
199,
624,
199,
8602,
275,
469,
339,
327,
7754,
4215,
642,
769,
3355,
23331,
17269,
701,
574,
8546,
339,
327,
13294,
9076,
272,
283,
11387,
7,
4483,
520,
283,
4371,
297,
272,
283,
22204,
63,
88,
19,
14,
20,
63,
1167,
2333,
7,
258,
520,
283,
4371,
297,
272,
283,
22204,
63,
88,
19,
63,
20,
63,
1167,
2333,
7,
258,
520,
283,
4371,
297,
327,
2005,
3031,
2323,
675,
642,
2222,
13,
6807,
536,
272,
283,
22204,
63,
88,
19,
14,
20,
63,
1167,
1184,
7,
258,
520,
283,
4371,
297,
272,
283,
1850,
12684,
7,
4519,
520,
283,
4371,
297,
272,
283,
1259,
4371,
7,
3322,
520,
283,
4371,
297,
272,
283,
19870,
12684,
7,
3777,
520,
283,
4371,
297,
272,
283,
4595,
11387,
63,
527,
7,
3515,
520,
283,
4371,
297,
272,
283,
4595,
63,
11387,
14,
723,
86,
63,
7155,
17,
7,
257,
520,
283,
4371,
297,
272,
283,
4595,
63,
723,
63,
22,
7,
3698,
520,
283,
4371,
297,
272,
283,
527,
7,
463,
520,
283,
4371,
297,
272,
283,
527,
63,
4371,
7,
3698,
520,
283,
4371,
297,
339,
327,
1300,
772,
63,
9276,
9076,
272,
283,
1095,
772,
7,
3777,
520,
283,
1095,
772,
63,
9276,
297,
272,
283,
1095,
63,
772,
7,
3322,
520,
283,
1095,
772,
63,
9276,
297,
339,
327,
7282,
21,
9076,
272,
283,
5076,
21,
63,
8122,
7,
3322,
520,
283,
5076,
21,
297,
272,
283,
1259,
5076,
21,
7,
3777,
520,
283,
5076,
21,
297,
339,
327,
7282,
21,
21557,
551,
83,
9076,
272,
283,
5076,
21,
63,
21557,
551,
83,
7,
260,
520,
283,
5076,
21,
21557,
551,
83,
297,
272,
283,
21557,
551,
83,
7,
4519,
520,
283,
5076,
21,
21557,
551,
83,
297,
339,
327,
15055,
18,
63,
9276,
9076,
272,
283,
10582,
18,
7,
4483,
520,
283,
10582,
18,
63,
9276,
297,
339,
327,
7667,
18325,
9076,
272,
283,
18325,
7,
4483,
520,
283,
1850,
18325,
297,
272,
283,
67,
6637,
77,
18325,
7,
3698,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
696,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
7530,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
527,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
26816,
5000,
63,
1850,
63,
9115,
7,
755,
520,
283,
1850,
18325,
297,
272,
283,
19870,
18325,
7,
3777,
520,
283,
1850,
18325,
297,
272,
283,
19870,
10005,
7,
3777,
520,
283,
1850,
18325,
297,
339,
327,
7667,
32351,
9076,
272,
283,
32351,
7,
5185,
520,
283,
1850,
32351,
297,
272,
283,
67,
6637,
77,
32351,
7,
3515,
520,
283,
1850,
32351,
297,
272,
283,
19870,
32351,
7,
3322,
520,
283,
1850,
32351,
297,
339,
327,
7667,
845,
2167,
9076,
272,
283,
845,
2167,
7,
5185,
520,
283,
1850,
845,
2167,
297,
272,
283,
19870,
845,
2167,
7,
3322,
520,
283,
1850,
845,
2167,
297,
339,
327,
7667,
26572,
9076,
272,
283,
26572,
7,
5185,
520,
283,
1850,
26572,
297,
272,
283,
8258,
63,
26572,
7,
755,
520,
283,
1850,
26572,
297,
339,
327,
7667,
21381,
9076,
272,
283,
21381,
7,
5185,
520,
283,
1850,
21381,
297,
272,
283,
8258,
63,
21381,
7,
755,
520,
283,
1850,
21381,
297,
339,
327,
7667,
19364,
9076,
272,
283,
19364,
7,
5185,
520,
283,
1850,
19364,
297,
272,
283,
8258,
63,
19364,
7,
755,
520,
283,
1850,
19364,
297,
339,
327,
7667,
28452,
9076,
272,
283,
28452,
7,
5185,
520,
283,
1850,
28452,
297,
272,
283,
8258,
63,
28452,
7,
755,
520,
283,
1850,
28452,
297,
339,
327,
7667,
31195,
9076,
272,
283,
31195,
7,
5185,
520,
283,
1850,
31195,
297,
272,
283,
8258,
63,
31195,
7,
755,
520,
283,
1850,
31195,
297,
339,
327,
7667,
20197,
9076,
272,
283,
20197,
7,
5185,
520,
283,
1850,
20197,
297,
272,
283,
8258,
63,
20197,
7,
755,
520,
283,
1850,
20197,
297,
339,
327,
7667,
713,
1367,
9076,
272,
283,
713,
1367,
7,
5185,
520,
283,
1850,
713,
1367,
297,
272,
283,
8258,
63,
713,
1367,
7,
755,
520,
283,
1850,
713,
1367,
297,
339,
327,
7667,
713,
1641,
9076,
272,
283,
713,
1641,
7,
5185,
520,
283,
1850,
713,
1641,
297,
272,
283,
8258,
63,
713,
1641,
7,
755,
520,
283,
1850,
713,
1641,
297,
339,
327,
7667,
30572,
9076,
272,
283,
30572,
7,
5185,
520,
283,
1850,
30572,
297,
272,
283,
8258,
63,
30572,
7,
755,
520,
283,
1850,
30572,
297,
339,
327,
7667,
21089,
9076,
272,
283,
21089,
7,
4483,
520,
283,
1850,
21089,
297,
272,
283,
67,
6637,
77,
21089,
7,
3698,
520,
283,
1850,
21089,
297,
272,
283,
26816,
5000,
63,
1850,
63,
426,
7,
755,
520,
283,
1850,
21089,
297,
272,
283,
19870,
21089,
7,
3777,
520,
283,
1850,
21089,
297,
339,
327,
7667,
21717,
9076,
272,
283,
21717,
7,
4483,
520,
283,
1850,
21717,
297,
272,
283,
30608,
67,
24,
600,
1606,
21717,
7,
257,
520,
283,
1850,
21717,
297,
272,
283,
19870,
21717,
7,
3777,
520,
283,
1850,
21717,
297,
339,
327,
7667,
5783,
9076,
272,
283,
5783,
7,
4483,
520,
283,
1850,
5783,
297,
272,
283,
67,
6637,
77,
5783,
7,
3698,
520,
283,
1850,
5783,
297,
272,
283,
26816,
5000,
63,
1850,
63,
1235,
7,
755,
520,
283,
1850,
5783,
297,
272,
283,
26816,
5000,
63,
1850,
63,
335,
7,
755,
520,
283,
1850,
5783,
297,
272,
283,
19870,
5783,
7,
3777,
520,
283,
1850,
5783,
297,
339,
327,
7667,
12710,
9076,
272,
283,
12710,
7,
4483,
520,
283,
1850,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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) Eric Firing.
#
# This file and the colormaps in it are released under the CC0 license /
# public domain dedication. We would appreciate credit if you use or
# redistribute these colormaps, but do not impose any legal restrictions.
#
# To the extent possible under law, the persons who associated CC0 with
# mpl-colormaps have waived all copyright and related or neighboring rights
# to mpl-colormaps.
#
# You should have received a copy of the CC0 legalcode along with this
# work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
__all__ = ['magma', 'inferno', 'plasma', 'viridis']
_magma_data = [[0.001462, 0.000466, 0.013866],
[0.002258, 0.001295, 0.018331],
[0.003279, 0.002305, 0.023708],
[0.004512, 0.003490, 0.029965],
[0.005950, 0.004843, 0.037130],
[0.007588, 0.006356, 0.044973],
[0.009426, 0.008022, 0.052844],
[0.011465, 0.009828, 0.060750],
[0.013708, 0.011771, 0.068667],
[0.016156, 0.013840, 0.076603],
[0.018815, 0.016026, 0.084584],
[0.021692, 0.018320, 0.092610],
[0.024792, 0.020715, 0.100676],
[0.028123, 0.023201, 0.108787],
[0.031696, 0.025765, 0.116965],
[0.035520, 0.028397, 0.125209],
[0.039608, 0.031090, 0.133515],
[0.043830, 0.033830, 0.141886],
[0.048062, 0.036607, 0.150327],
[0.052320, 0.039407, 0.158841],
[0.056615, 0.042160, 0.167446],
[0.060949, 0.044794, 0.176129],
[0.065330, 0.047318, 0.184892],
[0.069764, 0.049726, 0.193735],
[0.074257, 0.052017, 0.202660],
[0.078815, 0.054184, 0.211667],
[0.083446, 0.056225, 0.220755],
[0.088155, 0.058133, 0.229922],
[0.092949, 0.059904, 0.239164],
[0.097833, 0.061531, 0.248477],
[0.102815, 0.063010, 0.257854],
[0.107899, 0.064335, 0.267289],
[0.113094, 0.065492, 0.276784],
[0.118405, 0.066479, 0.286321],
[0.123833, 0.067295, 0.295879],
[0.129380, 0.067935, 0.305443],
[0.135053, 0.068391, 0.315000],
[0.140858, 0.068654, 0.324538],
[0.146785, 0.068738, 0.334011],
[0.152839, 0.068637, 0.343404],
[0.159018, 0.068354, 0.352688],
[0.165308, 0.067911, 0.361816],
[0.171713, 0.067305, 0.370771],
[0.178212, 0.066576, 0.379497],
[0.184801, 0.065732, 0.387973],
[0.191460, 0.064818, 0.396152],
[0.198177, 0.063862, 0.404009],
[0.204935, 0.062907, 0.411514],
[0.211718, 0.061992, 0.418647],
[0.218512, 0.061158, 0.425392],
[0.225302, 0.060445, 0.431742],
[0.232077, 0.059889, 0.437695],
[0.238826, 0.059517, 0.443256],
[0.245543, 0.059352, 0.448436],
[0.252220, 0.059415, 0.453248],
[0.258857, 0.059706, 0.457710],
[0.265447, 0.060237, 0.461840],
[0.271994, 0.060994, 0.465660],
[0.278493, 0.061978, 0.469190],
[0.284951, 0.063168, 0.472451],
[0.291366, 0.064553, 0.475462],
[0.297740, 0.066117, 0.478243],
[0.304081, 0.067835, 0.480812],
[0.310382, 0.069702, 0.483186],
[0.316654, 0.071690, 0.485380],
[0.322899, 0.073782, 0.487408],
[0.329114, 0.075972, 0.489287],
[0.335308, 0.078236, 0.491024],
[0.341482, 0.080564, 0.492631],
[0.347636, 0.082946, 0.494121],
[0.353773, 0.085373, 0.495501],
[0.359898, 0.087831, 0.496778],
[0.366012, 0.090314, 0.497960],
[0.372116, 0.092816, 0.499053],
[0.378211, 0.095332, 0.500067],
[0.384299, 0.097855, 0.501002],
[0.390384, 0.100379, 0.501864],
[0.396467, 0.102902, 0.502658],
[0.402548, 0.105420, 0.503386],
[0.408629, 0.107930, 0.504052],
[0.414709, 0.110431, 0.504662],
[0.420791, 0.112920, 0.505215],
[0.426877, 0.115395, 0.505714],
[0.432967, 0.117855, 0.506160],
[0.439062, 0.120298, 0.506555],
[0.445163, 0.122724, 0.506901],
[0.451271, 0.125132, 0.507198],
[0.457386, 0.127522, 0.507448],
[0.463508, 0.129893, 0.507652],
[0.469640, 0.132245, 0.507809],
[0.475780, 0.134577, 0.507921],
[0.481929, 0.136891, 0.507989],
[0.488088, 0.139186, 0.508011],
[0.494258, 0.141462, 0.507988],
[0.500438, 0.143719, 0.507920],
[0.506629, 0.145958, 0.507806],
[0.512831, 0.148179, 0.507648],
[0.519045, 0.150383, 0.507443],
[0.525270, 0.152569, 0.507192],
[0.531507, 0.154739, 0.506895],
[0.537755, 0.156894, 0.506551],
[0.544015, 0.159033, 0.506159],
[0.550287, 0.161158, 0.505719],
[0.556571, 0.163269, 0.505230],
[0.562866, 0.165368, 0.504692],
[0.569172, 0.167454, 0.504105],
[0.575490, 0.169530, 0.503466],
[0.581819, 0.171596, 0.502777],
[0.588158, 0.173652, 0.502035],
[0.594508, 0.175701, 0.501241],
[0.600868, 0.177743, 0.500394],
[0.607238, 0.179779, 0.499492],
[0.613617, 0.181811, 0.498536],
[0.620005, 0.183840, 0.497524],
[0.626401, 0.185867, 0.496456],
[0.632805, 0.187893, 0.495332],
[0.639216, 0.189921, 0.494150],
[0.645633, 0.191952, 0.492910],
[0.652056, 0.193986, 0.491611],
[0.658483, 0.196027, 0.490253],
[0.664915, 0.198075, 0.488836],
[0.671349, 0.200133, 0.487358],
[0.677786, 0.202203, 0.485819],
[0.684224, 0.204286, 0.484219],
[0.690661, 0.206384, 0.482558],
[0.697098, 0.208501, 0.480835],
[0.703532, 0.210638, 0.479049],
[0.709962, 0.212797, 0.477201],
[0.716387, 0.214982, 0.475290],
[0.722805, 0.217194, 0.473316],
[0.729216, 0.219437, 0.471279],
[0.735616, 0.221713, 0.469180],
[0.742004, 0.224025, 0.467018],
[0.748378, 0.226377, 0.464794],
[0.754737, 0.228772, 0.462509],
[0.761077, 0.231214, 0.460162],
[0.767398, 0.233705, 0.457755],
[0.773695, 0.236249, 0.455289],
[0.779968, 0.238851, 0.452765],
[0.786212, 0.241514, 0.450184],
[0.792427, 0.244242, 0.447543],
[0.798608, 0.247040, 0.444848],
[0.804752, 0.249911, 0.442102],
[0.810855, 0.252861, 0.439305],
[0.816914, 0.255895, 0.436461],
[0.822926, 0.259016, 0.433573],
[0.828886, 0.262229, 0.430644],
[0.834791, 0.265540, 0.427671],
[0.840636, 0.268953, 0.424666],
[0.846416, 0.272473, 0.421631],
[0.852126, 0.276106, 0.418573],
[0.857763, 0.279857, 0.415496],
[0.863320, 0.283729, 0.412403],
[0.868793, 0.287728, 0.409303],
[0.874176, 0.291859, 0.406205],
[0.879464, 0.296125, 0.403118],
[0.884651, 0.300530, 0.400047],
[0.889731, 0.305079, 0.397002],
[0.894700, 0.309773, 0.393995],
[0.899552, 0.314616, 0.391037],
[0.904281, 0.319610, 0.388137],
[0.908884, 0.324755, 0.385308],
[0.913354, 0.330052, 0.382563],
[0.917689, 0.335500, 0.379915],
[0.921884, 0.341098, 0.377376],
[0.925937, 0.346844, 0.374959],
[0.929845, 0.352734, 0.372677],
[0.933606, 0.358764, 0.370541],
[0.937221, 0.364929, 0.368567],
[0.940687, 0.371224, 0.366762],
[0.944006, 0.377643, 0.365136],
[0.947180, 0.384178, 0.363701],
[0.950210, 0.390820, 0.362468],
[0.953099, 0.397563, 0.361438],
[0.955849, 0.404400, 0.360619],
[0.958464, 0.411324, 0.360014],
[0.960949, 0.418323, 0.359630],
[0.963310, 0.425390, 0.359469],
[0.965549, 0.432519, 0.359529],
[0.967671, 0.439703, 0.359810],
[0.969680, 0.446936, 0.360311],
[0.971582, 0.454210, 0.361030],
[0.973381, 0.461520, 0.361965],
[0.975082, 0.468861, 0.363111],
[0.976690, 0.476226, 0.364466],
[0.978210, 0.483612, 0.366025],
[0.979645, 0.491014, 0.367783],
[0.981000, 0.498428, 0.369734],
[0.982279, 0.505851, 0.371874],
[0.983485, 0.513280, 0.374198],
[0.984622, 0.520713, 0.376698],
[0.985693, 0.528148, 0.379371],
[0.986700, 0.535582, 0.382210],
[0.987646, 0.543015, 0.385210],
[0.988533, 0.550446, 0.388365],
[0.989363, 0.557873, 0.391671],
[0.990138, 0.565296, 0.395122],
[0.990871, 0.572706, 0.398714],
[0.991558, 0.580107, 0.402441],
[0.992196, 0.587502, 0.406299],
[0.992785, 0.594891, 0.410283],
[0.993326, 0.602275, 0.414390],
[0.993834, 0.609644, 0.418613],
[0.994309, 0.616999, 0.422950],
[0.994738, 0.624350, 0.427397],
[0.995122, 0.631696, 0.431951],
[0.995480, 0.639027, 0.436607],
[0.995810, 0.646344, 0.441361],
[0.996096, 0.653659, 0.446213],
[0.996341, 0.660969, 0.451160],
[0.996580, 0.668256, 0.456192],
[0.996775, 0.675541, 0.461314],
[0.996925, 0.682828, 0.466526],
[0.997077, 0.690088, 0.471811],
[0.997186, 0.697349, 0.477182],
[0.997254, 0.704611, 0.482635],
[0.997325, 0.711848, 0.488154],
[0.997351, 0.719089, 0.493755],
[0.997351, 0.726324, 0.499428],
[0.997341, 0.733545, 0.505167],
[0.997285, 0.740772, 0.510983],
[0.997228, 0.747981, 0.516859],
[0.997138, 0.755190, 0.522806],
[0.997019, 0.762398, 0.528821],
[0.996898, 0.769591, 0.534892],
[0.996727, 0.776795, 0.541039],
[0.996571, 0.783977, 0.547233],
[0.996369, 0.791167, 0.553499],
[0.996162, 0.798348, 0.559820],
[0.995932, 0.805527, 0.566202],
[0.995680, 0.812706, 0.572645],
[0.995424, 0.819875, 0.579140],
[0.995131, 0.827052, 0.585701],
[0.994851, 0.834213, 0.592307],
[0.994524, 0.841387, 0.598983],
[0.994222, 0.848540, 0.605696],
[0.993866, 0.855711, 0.612482],
[0.993545, 0.862859, 0.619299],
[0.993170, 0.870024, 0.626189],
[0.992831, 0.877168, 0.633109],
[0.992440, 0.884330, 0.640099],
[0.992089, 0.891470, 0.647116],
[0.991688, 0.898627, 0.654202],
[0.991332, 0.905763, 0.661309],
[0.990930, 0.912915, 0.668481],
[0.990570, 0.920049, 0.675675],
[0.990175, 0.927196, 0.682926],
[0.989815, 0.934329, 0.690198],
[0.989434, 0.941470, 0.697519],
[0.989077, 0.948604, 0.704863],
[0.988717, 0.955742, 0.712242],
[0.988367, 0.962878, 0.719649],
[0.988033, 0.970012, 0.727077],
[0.987691, 0.977154, 0.734536],
[0.987387, 0.984288, 0.742002],
[0.987053, 0.991438, 0.749504]]
_inferno_data = [[0.001462, 0.000466, 0.013866],
[0.002267, 0.001270, 0.018570],
[0.003299, 0.002249, 0.024239],
[0.004547, 0.003392, 0.030909],
[0.006006, 0.004692, 0.038558],
[0.007676, 0.006136, 0.046836],
[0.009561, 0.007713, 0.055143],
[0.011663, 0.009417, 0.063460],
[0.013995, 0.011225, 0.071862],
[0.016561, 0.013136, 0.080282],
[0.019373, 0.015133, 0.088767],
[0.022447, 0.017199, 0.097327],
[0.025793, 0.019331, 0.105930],
[0.029432, 0.021503, 0.114621],
[0.033385, 0.023702, 0.123397],
[0.037668, 0.025921, 0.132232],
[0.042253, 0.028139, 0.141141],
[0.046915, 0.030324, 0.150164],
[0.051644, 0.032474, 0.159254],
[0.056449, 0.034569, 0.168414],
[0.061340, 0.036590, 0.177642],
[0.066331, 0.038504, 0.186962],
[0.071429, 0.040294, 0.196354],
[0.076637, 0.041905, 0.205799],
[0.081962, 0.043328, 0.215289],
[0.087411, 0.044556, 0.224813],
[0.092990, 0.045583, 0.234358],
[0.098702, 0.046402, 0.243904],
[0.104551, 0.047008, 0.253430],
[0.110536, 0.047399, 0.262912],
[0.116656, 0.047574, 0.272321],
[0.122908, 0.047536, 0.281624],
[0.129285, 0.047293, 0.290788],
[0.135778, 0.046856, 0.299776],
[0.142378, 0.046242, 0.308553],
[0.149073, 0.045468, 0.317085],
[0.155850, 0.044559, 0.325338],
[0.162689, 0.043554, 0.333277],
[0.169575, 0.042489, 0.340874],
[0.176493, 0.041402, 0.348111],
[0.183429, 0.040329, 0.354971],
[0.190367, 0.039309, 0.361447],
[0.197297, 0.038400, 0.367535],
[0.204209, 0.037632, 0.373238],
[0.211095, 0.037030, 0.378563],
[0.217949, 0.036615, 0.383522],
[0.224763, 0.036405, 0.388129],
[0.231538, 0.036405, 0.392400],
[0.238273, 0.036621, 0.396353],
[0.244967, 0.037055, 0.400007],
[0.251620, 0.037705, 0.403378],
[0.258234, 0.038571, 0.406485],
[0.264810, 0.039647, 0.409345],
[0.271347, 0.040922, 0.411976],
[0.277850, 0.042353, 0.414392],
[0.284321, 0.043933, 0.416608],
[0.290763, 0.045644, 0.418637],
[0.297178, 0.047470, 0.420491],
[0.303568, 0.049396, 0.422182],
[0.309935, 0.051407, 0.423721],
[0.316282, 0.053490, 0.425116],
[0.322610, 0.055634, 0.426377],
[0.328921, 0.057827, 0.427511],
[0.335217, 0.060060, 0.428524],
[0.341500, 0.062325, 0.429425],
[0.347771, 0.064616, 0.430217],
[0.354032, 0.066925, 0.430906],
[0.360284, 0.069247, 0.431497],
[0.366529, 0.071579, 0.431994],
[0.372768, 0.073915, 0.432400],
[0.379001, 0.076253, 0.432719],
[0.385228, 0.078591, 0.432955],
[0.391453, 0.080927, 0.433109],
[0.397674, 0.083257, 0.433183],
[0.403894, 0.085580, 0.433179],
[0.410113, 0.087896, 0.433098],
[0.416331, 0.090203, 0.432943],
[0.422549, 0.092501, 0.432714],
[0.428768, 0.094790, 0.432412],
[0.434987, 0.097069, 0.432039],
[0.441207, 0.099338, 0.431594],
[0.447428, 0.101597, 0.431080],
[0.453651, 0.103848, 0.430498],
[0.459875, 0.106089, 0.429846],
[0.466100, 0.108322, 0.429125],
[0.472328, 0.110547, 0.428334],
[0.478558, 0.112764, 0.427475],
[0.484789, 0.114974, 0.426548],
[0.491022, 0.117179, 0.425552],
[0.497257, 0.119379, 0.424488],
[0.503493, 0.121575, 0.423356],
[0.509730, 0.123769, 0.422156],
[0.515967, 0.125960, 0.420887],
[0.522206, 0.128150, 0.419549],
[0.528444, 0.130341, 0.418142],
[0.534683, 0.132534, 0.416667],
[0.540920, 0.134729, 0.415123],
[0.547157, 0.136929, 0.413511],
[0.553392, 0.139134, 0.411829],
[0.559624, 0.141346, 0.410078],
[0.565854, 0.143567, 0.408258],
[0.572081, 0.145797, 0.406369],
[0.578304, 0.148039, 0.404411],
[0.584521, 0.150294, 0.402385],
[0.590734, 0.152563, 0.400290],
[0.596940, 0.154848, 0.398125],
[0.603139, 0.157151, 0.395891],
[0.609330, 0.159474, 0.393589],
[0.615513, 0.161817, 0.391219],
[0.621685, 0.164184, 0.388781],
[0.627847, 0.166575, 0.386276],
[0.633998, 0.168992, 0.383704],
[0.640135, 0.171438, 0.381065],
[0.646260, 0.173914, 0.378359],
[0.652369, 0.176421, 0.375586],
[0.658463, 0.178962, 0.372748],
[0.664540, 0.181539, 0.369846],
[0.670599, 0.184153, 0.366879],
[0.676638, 0.186807, 0.363849],
[0.682656, 0.189501, 0.360757],
[0.688653, 0.192239, 0.357603],
[0.694627, 0.195021, 0.354388],
[0.700576, 0.197851, 0.351113],
[0.706500, 0.200728, 0.347777],
[0.712396, 0.203656, 0.344383],
[0.718264, 0.206636, 0.340931],
[0.724103, 0.209670, 0.337424],
[0.729909, 0.212759, 0.333861],
[0.735683, 0.215906, 0.330245],
[0.741423, 0.219112, 0.326576],
[0.747127, 0.222378, 0.322856],
[0.752794, 0.225706, 0.319085],
[0.758422, 0.229097, 0.315266],
[0.764010, 0.232554, 0.311399],
[0.769556, 0.236077, 0.307485],
[0.775059, 0.239667, 0.303526],
[0.780517, 0.243327, 0.299523],
[0.785929, 0.247056, 0.295477],
[0.791293, 0.250856, 0.291390],
[0.796607, 0.254728, 0.287264],
[0.801871, 0.258674, 0.283099],
[0.807082, 0.262692, 0.278898],
[0.812239, 0.266786, 0.274661],
[0.817341, 0.270954, 0.270390],
[0.822386, 0.275197, 0.266085],
[0.827372, 0.279517, 0.261750],
[0.832299, 0.283913, 0.257383],
[0.837165, 0.288385, 0.252988],
[0.841969, 0.292933, 0.248564],
[0.846709, 0.297559, 0.244113],
[0.851384, 0.302260, 0.239636],
[0.855992, 0.307038, 0.235133],
[0.860533, 0.311892, 0.230606],
[0.865006, 0.316822, 0.226055],
[0.869409, 0.321827, 0.221482],
[0.873741, 0.326906, 0.216886],
[0.878001, 0.332060, 0.212268],
[0.882188, 0.337287, 0.207628],
[0.886302, 0.342586, 0.202968],
[0.890341, 0.347957, 0.198286],
[0.894305, 0.353399, 0.193584],
[0.898192, 0.358911, 0.188860],
[0.902003, 0.364492, 0.184116],
[0.905735, 0.370140, 0.179350],
[0.909390, 0.375856, 0.174563],
[0.912966, 0.381636, 0.169755],
[0.916462, 0.387481, 0.164924],
[0.919879, 0.393389, 0.160070],
[0.923215, 0.399359, 0.155193],
[0.926470, 0.405389, 0.150292],
[0.929644, 0.411479, 0.145367],
[0.932737, 0.417627, 0.140417],
[0.935747, 0.423831, 0.135440],
[0.938675, 0.430091, 0.130438],
[0.941521, 0.436405, 0.125409],
[0.944285, 0.442772, 0.120354],
[0.946965, 0.449191, 0.115272],
[0.949562, 0.455660, 0.110164],
[0.952075, 0.462178, 0.105031],
[0.954506, 0.468744, 0.099874],
[0.956852, 0.475356, 0.094695],
[0.959114, 0.482014, 0.089499],
[0.961293, 0.488716, 0.084289],
[0.963387, 0.495462, 0.079073],
[0.965397, 0.502249, 0.073859],
[0.967322, 0.509078, 0.068659],
[0.969163, 0.515946, 0.063488],
[0.970919, 0.522853, 0.058367],
[0.972590, 0.529798, 0.053324],
[0.974176, 0.536780, 0.048392],
[0.975677, 0.543798, 0.043618],
[0.977092, 0.550850, 0.039050],
[0.978422, 0.557937, 0.034931],
[0.979666, 0.565057, 0.031409],
[0.980824, 0.572209, 0.028508],
[0.981895, 0.579392, 0.026250],
[0.982881, 0.586606, 0.024661],
[0.983779, 0.593849, 0.023770],
[0.984591, 0.601122, 0.023606],
[0.985315, 0.608422, 0.024202],
[0.985952, 0.615750, 0.025592],
[0.986502, 0.623105, 0.027814],
[0.986964, 0.630485, 0.030908],
[0.987337, 0.637890, 0.034916],
[0.987622, 0.645320, 0.039886],
[0.987819, 0.652773, 0.045581],
[0.987926, 0.660250, 0.051750],
[0.987945, 0.667748, 0.058329],
[0.987874, 0.675267, 0.065257],
[0.987714, 0.682807, 0.072489],
[0.987464, 0.690366, 0.079990],
[0.987124, 0.697944, 0.087731],
[0.986694, 0.705540, 0.095694],
[0.986175, 0.713153, 0.103863],
[0.985566, 0.720782, 0.112229],
[0.984865, 0.728427, 0.120785],
[0.984075, 0.736087, 0.129527],
[0.983196, 0.743758, 0.138453],
[0.982228, 0.751442, 0.147565],
[0.981173, 0.759135, 0.156863],
[0.980032, 0.766837, 0.166353],
[0.978806, 0.774545, 0.176037],
[0.977497, 0.782258, 0.185923],
[0.976108, 0.789974, 0.196018],
[0.974638, 0.797692, 0.206332],
[0.973088, 0.805409, 0.216877],
[0.971468, 0.813122, 0.227658],
[0.969783, 0.820825, 0.238686],
[0.968041, 0.828515, 0.249972],
[0.966243, 0.836191, 0.261534],
[0.964394, 0.843848, 0.273391],
[0.962517, 0.851476, 0.285546],
[0.960626, 0.859069, 0.298010],
[0.958720, 0.866624, 0.310820],
[0.956834, 0.874129, 0.323974],
[0.954997, 0.881569, 0.337475],
[0.953215, 0.888942, 0.351369],
[0.951546, 0.896226, 0.365627],
[0.950018, 0.903409, 0.380271],
[0.948683, 0.910473, 0.395289],
[0.947594, 0.917399, 0.410665],
[0.946809, 0.924168, 0.426373],
[0.946392, 0.930761, 0.442367],
[0.946403, 0.937159, 0.458592],
[0.946903, 0.943348, 0.474970],
[0.947937, 0.949318, 0.491426],
[0.949545, 0.955063, 0.507860],
[0.951740, 0.960587, 0.524203],
[0.954529, 0.965896, 0.540361],
[0.957896, 0.971003, 0.556275],
[0.961812, 0.975924, 0.571925],
[0.966249, 0.980678, 0.587206],
[0.971162, 0.985282, 0.602154],
[0.976511, 0.989753, 0.616760],
[0.982257, 0.994109, 0.631017],
[0.988362, 0.998364, 0.644924]]
_plasma_data = [[0.050383, 0.029803, 0.527975],
[0.063536, 0.028426, 0.533124],
[0.075353, 0.027206, 0.538007],
[0.086222, 0.026125, 0.542658],
[0.096379, 0.025165, 0.547103],
[0.105980, 0.024309, 0.551368],
[0.115124, 0.023556, 0.555468],
[0.123903, 0.022878, 0.559423],
[0.132381, 0.022258, 0.563250],
[0.140603, 0.021687, 0.566959],
[0.148607, 0.021154, 0.570562],
[0.156421, 0.020651, 0.574065],
[0.164070, 0.020171, 0.577478],
[0.171574, 0.019706, 0.580806],
[0.178950, 0.019252, 0.584054],
[0.186213, 0.018803, 0.587228],
[0.193374, 0.018354, 0.590330],
[0.200445, 0.017902, 0.593364],
[0.207435, 0.017442, 0.596333],
[0.214350, 0.016973, 0.599239],
[0.221197, 0.016497, 0.602083],
[0.227983, 0.016007, 0.604867],
[0.234715, 0.015502, 0.607592],
[0.241396, 0.014979, 0.610259],
[0.248032, 0.014439, 0.612868],
[0.254627, 0.013882, 0.615419],
[0.261183, 0.013308, 0.617911],
[0.267703, 0.012716, 0.620346],
[0.274191, 0.012109, 0.622722],
[0.280648, 0.011488, 0.625038],
[0.287076, 0.010855, 0.627295],
[0.293478, 0.010213, 0.629490],
[0.299855, 0.009561, 0.631624],
[0.306210, 0.008902, 0.633694],
[0.312543, 0.008239, 0.635700],
[0.318856, 0.007576, 0.637640],
[0.325150, 0.006915, 0.639512],
[0.331426, 0.006261, 0.641316],
[0.337683, 0.005618, 0.643049],
[0.343925, 0.004991, 0.644710],
[0.350150, 0.004382, 0.646298],
[0.356359, 0.003798, 0.647810],
[0.362553, 0.003243, 0.649245],
[0.368733, 0.002724, 0.650601],
[0.374897, 0.002245, 0.651876],
[0.381047, 0.001814, 0.653068],
[0.387183, 0.001434, 0.654177],
[0.393304, 0.001114, 0.655199],
[0.399411, 0.000859, 0.656133],
[0.405503, 0.000678, 0.656977],
[0.411580, 0.000577, 0.657730],
[0.417642, 0.000564, 0.658390],
[0.423689, 0.000646, 0.658956],
[0.429719, 0.000831, 0.659425],
[0.435734, 0.001127, 0.659797],
[0.441732, 0.001540, 0.660069],
[0.447714, 0.002080, 0.660240],
[0.453677, 0.002755, 0.660310],
[0.459623, 0.003574, 0.660277],
[0.465550, 0.004545, 0.660139],
[0.471457, 0.005678, 0.659897],
[0.477344, 0.006980, 0.659549],
[0.483210, 0.008460, 0.659095],
[0.489055, 0.010127, 0.658534],
[0.494877, 0.011990, 0.657865],
[0.500678, 0.014055, 0.657088],
[0.506454, 0.016333, 0.656202],
[0.512206, 0.018833, 0.655209],
[0.517933, 0.021563, 0.654109],
[0.523633, 0.024532, 0.652901],
[0.529306, 0.027747, 0.651586],
[0.534952, 0.031217, 0.650165],
[0.540570, 0.034950, 0.648640],
[0.546157, 0.038954, 0.647010],
[0.551715, 0.043136, 0.645277],
[0.557243, 0.047331, 0.643443],
[0.562738, 0.051545, 0.641509],
[0.568201, 0.055778, 0.639477],
[0.573632, 0.060028, 0.637349],
[0.579029, 0.064296, 0.635126],
[0.584391, 0.068579, 0.632812],
[0.589719, 0.072878, 0.630408],
[0.595011, 0.077190, 0.627917],
[0.600266, 0.081516, 0.625342],
[0.605485, 0.085854, 0.622686],
[0.610667, 0.090204, 0.619951],
[0.615812, 0.094564, 0.617140],
[0.620919, 0.098934, 0.614257],
[0.625987, 0.103312, 0.611305],
[0.631017, 0.107699, 0.608287],
[0.636008, 0.112092, 0.605205],
[0.640959, 0.116492, 0.602065],
[0.645872, 0.120898, 0.598867],
[0.650746, 0.125309, 0.595617],
[0.655580, 0.129725, 0.592317],
[0.660374, 0.134144, 0.588971],
[0.665129, 0.138566, 0.585582],
[0.669845, 0.142992, 0.582154],
[0.674522, 0.147419, 0.578688],
[0.679160, 0.151848, 0.575189],
[0.683758, 0.156278, 0.571660],
[0.688318, 0.160709, 0.568103],
[0.692840, 0.165141, 0.564522],
[0.697324, 0.169573, 0.560919],
[0.701769, 0.174005, 0.557296],
[0.706178, 0.178437, 0.553657],
[0.710549, 0.182868, 0.550004],
[0.714883, 0.187299, 0.546338],
[0.719181, 0.191729, 0.542663],
[0.723444, 0.196158, 0.538981],
[0.727670, 0.200586, 0.535293],
[0.731862, 0.205013, 0.531601],
[0.736019, 0.209439, 0.527908],
[0.740143, 0.213864, 0.524216],
[0.744232, 0.218288, 0.520524],
[0.748289, 0.222711, 0.516834],
[0.752312, 0.227133, 0.513149],
[0.756304, 0.231555, 0.509468],
[0.760264, 0.235976, 0.505794],
[0.764193, 0.240396, 0.502126],
[0.768090, 0.244817, 0.498465],
[0.771958, 0.249237, 0.494813],
[0.775796, 0.253658, 0.491171],
[0.779604, 0.258078, 0.487539],
[0.783383, 0.262500, 0.483918],
[0.787133, 0.266922, 0.480307],
[0.790855, 0.271345, 0.476706],
[0.794549, 0.275770, 0.473117],
[0.798216, 0.280197, 0.469538],
[0.801855, 0.284626, 0.465971],
[0.805467, 0.289057, 0.462415],
[0.809052, 0.293491, 0.458870],
[0.812612, 0.297928, 0.455338],
[0.816144, 0.302368, 0.451816],
[0.819651, 0.306812, 0.448306],
[0.823132, 0.311261, 0.444806],
[0.826588, 0.315714, 0.441316],
[0.830018, 0.320172, 0.437836],
[0.833422, 0.324635, 0.434366],
[0.836801, 0.329105, 0.430905],
[0.840155, 0.333580, 0.427455],
[0.843484, 0.338062, 0.424013],
[0.846788, 0.342551, 0.420579],
[0.850066, 0.347048, 0.417153],
[0.853319, 0.351553, 0.413734],
[0.856547, 0.356066, 0.410322],
[0.859750, 0.360588, 0.406917],
[0.862927, 0.365119, 0.403519],
[0.866078, 0.369660, 0.400126],
[0.869203, 0.374212, 0.396738],
[0.872303, 0.378774, 0.393355],
[0.875376, 0.383347, 0.389976],
[0.878423, 0.387932, 0.386600],
[0.881443, 0.392529, 0.383229],
[0.884436, 0.397139, 0.379860],
[0.887402, 0.401762, 0.376494],
[0.890340, 0.406398, 0.373130],
[0.893250, 0.411048, 0.369768],
[0.896131, 0.415712, 0.366407],
[0.898984, 0.420392, 0.363047],
[0.901807, 0.425087, 0.359688],
[0.904601, 0.429797, 0.356329],
[0.907365, 0.434524, 0.352970],
[0.910098, 0.439268, 0.349610],
[0.912800, 0.444029, 0.346251],
[0.915471, 0.448807, 0.342890],
[0.918109, 0.453603, 0.339529],
[0.920714, 0.458417, 0.336166],
[0.923287, 0.463251, 0.332801],
[0.925825, 0.468103, 0.329435],
[0.928329, 0.472975, 0.326067],
[0.930798, 0.477867, 0.322697],
[0.933232, 0.482780, 0.319325],
[0.935630, 0.487712, 0.315952],
[0.937990, 0.492667, 0.312575],
[0.940313, 0.497642, 0.309197],
[0.942598, 0.502639, 0.305816],
[0.944844, 0.507658, 0.302433],
[0.947051, 0.512699, 0.299049],
[0.949217, 0.517763, 0.295662],
[0.951344, 0.522850, 0.292275],
[0.953428, 0.527960, 0.288883],
[0.955470, 0.533093, 0.285490],
[0.957469, 0.538250, 0.282096],
[0.959424, 0.543431, 0.278701],
[0.961336, 0.548636, 0.275305],
[0.963203, 0.553865, 0.271909],
[0.965024, 0.559118, 0.268513],
[0.966798, 0.564396, 0.265118],
[0.968526, 0.569700, 0.261721],
[0.970205, 0.575028, 0.258325],
[0.971835, 0.580382, 0.254931],
[0.973416, 0.585761, 0.251540],
[0.974947, 0.591165, 0.248151],
[0.976428, 0.596595, 0.244767],
[0.977856, 0.602051, 0.241387],
[0.979233, 0.607532, 0.238013],
[0.980556, 0.613039, 0.234646],
[0.981826, 0.618572, 0.231287],
[0.983041, 0.624131, 0.227937],
[0.984199, 0.629718, 0.224595],
[0.985301, 0.635330, 0.221265],
[0.986345, 0.640969, 0.217948],
[0.987332, 0.646633, 0.214648],
[0.988260, 0.652325, 0.211364],
[0.989128, 0.658043, 0.208100],
[0.989935, 0.663787, 0.204859],
[0.990681, 0.669558, 0.201642],
[0.991365, 0.675355, 0.198453],
[0.991985, 0.681179, 0.195295],
[0.992541, 0.687030, 0.192170],
[0.993032, 0.692907, 0.189084],
[0.993456, 0.698810, 0.186041],
[0.993814, 0.704741, 0.183043],
[0.994103, 0.710698, 0.180097],
[0.994324, 0.716681, 0.177208],
[0.994474, 0.722691, 0.174381],
[0.994553, 0.728728, 0.171622],
[0.994561, 0.734791, 0.168938],
[0.994495, 0.740880, 0.166335],
[0.994355, 0.746995, 0.163821],
[0.994141, 0.753137, 0.161404],
[0.993851, 0.759304, 0.159092],
[0.993482, 0.765499, 0.156891],
[0.993033, 0.771720, 0.154808],
[0.992505, 0.777967, 0.152855],
[0.991897, 0.784239, 0.151042],
[0.991209, 0.790537, 0.149377],
[0.990439, 0.796859, 0.147870],
[0.989587, 0.803205, 0.146529],
[0.988648, 0.809579, 0.145357],
[0.987621, 0.815978, 0.144363],
[0.986509, 0.822401, 0.143557],
[0.985314, 0.828846, 0.142945],
[0.984031, 0.835315, 0.142528],
[0.982653, 0.841812, 0.142303],
[0.981190, 0.848329, 0.142279],
[0.979644, 0.854866, 0.142453],
[0.977995, 0.861432, 0.142808],
[0.976265, 0.868016, 0.143351],
[0.974443, 0.874622, 0.144061],
[0.972530, 0.881250, 0.144923],
[0.970533, 0.887896, 0.145919],
[0.968443, 0.894564, 0.147014],
[0.966271, 0.901249, 0.148180],
[0.964021, 0.907950, 0.149370],
[0.961681, 0.914672, 0.150520],
[0.959276, 0.921407, 0.151566],
[0.956808, 0.928152, 0.152409],
[0.954287, 0.934908, 0.152921],
[0.951726, 0.941671, 0.152925],
[0.949151, 0.948435, 0.152178],
[0.946602, 0.955190, 0.150328],
[0.944152, 0.961916, 0.146861],
[0.941896, 0.968590, 0.140956],
[0.940015, 0.975158, 0.131326]]
_viridis_data = [[0.267004, 0.004874, 0.329415],
[0.268510, 0.009605, 0.335427],
[0.269944, 0.014625, 0.341379],
[0.271305, 0.019942, 0.347269],
[0.272594, 0.025563, 0.353093],
[0.273809, 0.031497, 0.358853],
[0.274952, 0.037752, 0.364543],
[0.276022, 0.044167, 0.370164],
[0.277018, 0.050344, 0.375715],
[0.277941, 0.056324, 0.381191],
[0.278791, 0.062145, 0.386592],
[0.279566, 0.067836, 0.391917],
[0.280267, 0.073417, 0.397163],
[0.280894, 0.078907, 0.402329],
[0.281446, 0.084320, 0.407414],
[0.281924, 0.089666, 0.412415],
[0.282327, 0.094955, 0.417331],
[0.282656, 0.100196, 0.422160],
[0.282910, 0.105393, 0.426902],
[0.283091, 0.110553, 0.431554],
[0.283197, 0.115680, 0.436115],
[0.283229, 0.120777, 0.440584],
[0.283187, 0.125848, 0.444960],
[0.283072, 0.130895, 0.449241],
[0.282884, 0.135920, 0.453427],
[0.282623, 0.140926, 0.457517],
[0.282290, 0.145912, 0.461510],
[0.281887, 0.150881, 0.465405],
[0.281412, 0.155834, 0.469201],
[0.280868, 0.160771, 0.472899],
[0.280255, 0.165693, 0.476498],
[0.279574, 0.170599, 0.479997],
[0.278826, 0.175490, 0.483397],
[0.278012, 0.180367, 0.486697],
[0.277134, 0.185228, 0.489898],
[0.276194, 0.190074, 0.493001],
[0.275191, 0.194905, 0.496005],
[0.274128, 0.199721, 0.498911],
[0.273006, 0.204520, 0.501721],
[0.271828, 0.209303, 0.504434],
[0.270595, 0.214069, 0.507052],
[0.269308, 0.218818, 0.509577],
[0.267968, 0.223549, 0.512008],
[0.266580, 0.228262, 0.514349],
[0.265145, 0.232956, 0.516599],
[0.263663, 0.237631, 0.518762],
[0.262138, 0.242286, 0.520837],
[0.260571, 0.246922, 0.522828],
[0.258965, 0.251537, 0.524736],
[0.257322, 0.256130, 0.526563],
[0.255645, 0.260703, 0.528312],
[0.253935, 0.265254, 0.529983],
[0.252194, 0.269783, 0.531579],
[0.250425, 0.274290, 0.533103],
[0.248629, 0.278775, 0.534556],
[0.246811, 0.283237, 0.535941],
[0.244972, 0.287675, 0.537260],
[0.243113, 0.292092, 0.538516],
[0.241237, 0.296485, 0.539709],
[0.239346, 0.300855, 0.540844],
[0.237441, 0.305202, 0.541921],
[0.235526, 0.309527, 0.542944],
[0.233603, 0.313828, 0.543914],
[0.231674, 0.318106, 0.544834],
[0.229739, 0.322361, 0.545706],
[0.227802, 0.326594, 0.546532],
[0.225863, 0.330805, 0.547314],
[0.223925, 0.334994, 0.548053],
[0.221989, 0.339161, 0.548752],
[0.220057, 0.343307, 0.549413],
[0.218130, 0.347432, 0.550038],
[0.216210, 0.351535, 0.550627],
[0.214298, 0.355619, 0.551184],
[0.212395, 0.359683, 0.551710],
[0.210503, 0.363727, 0.552206],
[0.208623, 0.367752, 0.552675],
[0.206756, 0.371758, 0.553117],
[0.204903, 0.375746, 0.553533],
[0.203063, 0.379716, 0.553925],
[0.201239, 0.383670, 0.554294],
[0.199430, 0.387607, 0.554642],
[0.197636, 0.391528, 0.554969],
[0.195860, 0.395433, 0.555276],
[0.194100, 0.399323, 0.555565],
[0.192357, 0.403199, 0.555836],
[0.190631, 0.407061, 0.556089],
[0.188923, 0.410910, 0.556326],
[0.187231, 0.414746, 0.556547],
[0.185556, 0.418570, 0.556753],
[0.183898, 0.422383, 0.556944],
[0.182256, 0.426184, 0.557120],
[0.180629, 0.429975, 0.557282],
[0.179019, 0.433756, 0.557430],
[0.177423, 0.437527, 0.557565],
[0.175841, 0.441290, 0.557685],
[0.174274, 0.445044, 0.557792],
[0.172719, 0.448791, 0.557885],
[0.171176, 0.452530, 0.557965],
[0.169646, 0.456262, 0.558030],
[0.168126, 0.459988, 0.558082],
[0.166617, 0.463708, 0.558119],
[0.165117, 0.467423, 0.558141],
[0.163625, 0.471133, 0.558148],
[0.162142, 0.474838, 0.558140],
[0.160665, 0.478540, 0.558115],
[0.159194, 0.482237, 0.558073],
[0.157729, 0.485932, 0.558013],
[0.156270, 0.489624, 0.557936],
[0.154815, 0.493313, 0.557840],
[0.153364, 0.497000, 0.557724],
[0.151918, 0.500685, 0.557587],
[0.150476, 0.504369, 0.557430],
[0.149039, 0.508051, 0.557250],
[0.147607, 0.511733, 0.557049],
[0.146180, 0.515413, 0.556823],
[0.144759, 0.519093, 0.556572],
[0.143343, 0.522773, 0.556295],
[0.141935, 0.526453, 0.555991],
[0.140536, 0.530132, 0.555659],
[0.139147, 0.533812, 0.555298],
[0.137770, 0.537492, 0.554906],
[0.136408, 0.541173, 0.554483],
[0.135066, 0.544853, 0.554029],
[0.133743, 0.548535, 0.553541],
[0.132444, 0.552216, 0.553018],
[0.131172, 0.555899, 0.552459],
[0.129933, 0.559582, 0.551864],
[0.128729, 0.563265, 0.551229],
[0.127568, 0.566949, 0.550556],
[0.126453, 0.570633, 0.549841],
[0.125394, 0.574318, 0.549086],
[0.124395, 0.578002, 0.548287],
[0.123463, 0.581687, 0.547445],
[0.122606, 0.585371, 0.546557],
[0.121831, 0.589055, 0.545623],
[0.121148, 0.592739, 0.544641],
[0.120565, 0.596422, 0.543611],
[0.120092, 0.600104, 0.542530],
[0.119738, 0.603785, 0.541400],
[0.119512, 0.607464, 0.540218],
[0.119423, 0.611141, 0.538982],
[0.119483, 0.614817, 0.537692],
[0.119699, 0.618490, 0.536347],
[0.120081, 0.622161, 0.534946],
[0.120638, 0.625828, 0.533488],
[0.121380, 0.629492, 0.531973],
[0.122312, 0.633153, 0.530398],
[0.123444, 0.636809, 0.528763],
[0.124780, 0.640461, 0.527068],
[0.126326, 0.644107, 0.525311],
[0.128087, 0.647749, 0.523491],
[0.130067, 0.651384, 0.521608],
[0.132268, 0.655014, 0.519661],
[0.134692, 0.658636, 0.517649],
[0.137339, 0.662252, 0.515571],
[0.140210, 0.665859, 0.513427],
[0.143303, 0.669459, 0.511215],
[0.146616, 0.673050, 0.508936],
[0.150148, 0.676631, 0.506589],
[0.153894, 0.680203, 0.504172],
[0.157851, 0.683765, 0.501686],
[0.162016, 0.687316, 0.499129],
[0.166383, 0.690856, 0.496502],
[0.170948, 0.694384, 0.493803],
[0.175707, 0.697900, 0.491033],
[0.180653, 0.701402, 0.488189],
[0.185783, 0.704891, 0.485273],
[0.191090, 0.708366, 0.482284],
[0.196571, 0.711827, 0.479221],
[0.202219, 0.715272, 0.476084],
[0.208030, 0.718701, 0.472873],
[0.214000, 0.722114, 0.469588],
[0.220124, 0.725509, 0.466226],
[0.226397, 0.728888, 0.462789],
[0.232815, 0.732247, 0.459277],
[0.239374, 0.735588, 0.455688],
[0.246070, 0.738910, 0.452024],
[0.252899, 0.742211, 0.448284],
[0.259857, 0.745492, 0.444467],
[0.266941, 0.748751, 0.440573],
[0.274149, 0.751988, 0.436601],
[0.281477, 0.755203, 0.432552],
[0.288921, 0.758394, 0.428426],
[0.296479, 0.761561, 0.424223],
[0.304148, 0.764704, 0.419943],
[0.311925, 0.767822, 0.415586],
[0.319809, 0.770914, 0.411152],
[0.327796, 0.773980, 0.406640],
[0.335885, 0.777018, 0.402049],
[0.344074, 0.780029, 0.397381],
[0.352360, 0.783011, 0.392636],
[0.360741, 0.785964, 0.387814],
[0.369214, 0.788888, 0.382914],
[0.377779, 0.791781, 0.377939],
[0.386433, 0.794644, 0.372886],
[0.395174, 0.797475, 0.367757],
[0.404001, 0.800275, 0.362552],
[0.412913, 0.803041, 0.357269],
[0.421908, 0.805774, 0.351910],
[0.430983, 0.808473, 0.346476],
[0.440137, 0.811138, 0.340967],
[0.449368, 0.813768, 0.335384],
[0.458674, 0.816363, 0.329727],
[0.468053, 0.818921, 0.323998],
[0.477504, 0.821444, 0.318195],
[0.487026, 0.823929, 0.312321],
[0.496615, 0.826376, 0.306377],
[0.506271, 0.828786, 0.300362],
[0.515992, 0.831158, 0.294279],
[0.525776, 0.833491, 0.288127],
[0.535621, 0.835785, 0.281908],
[0.545524, 0.838039, 0.275626],
[0.555484, 0.840254, 0.269281],
[0.565498, 0.842430, 0.262877],
[0.575563, 0.844566, 0.256415],
[0.585678, 0.846661, 0.249897],
[0.595839, 0.848717, 0.243329],
[0.606045, 0.850733, 0.236712],
[0.616293, 0.852709, 0.230052],
[0.626579, 0.854645, 0.223353],
[0.636902, 0.856542, 0.216620],
[0.647257, 0.858400, 0.209861],
[0.657642, 0.860219, 0.203082],
[0.668054, 0.861999, 0.196293],
[0.678489, 0.863742, 0.189503],
[0.688944, 0.865448, 0.182725],
[0.699415, 0.867117, 0.175971],
[0.709898, 0.868751, 0.169257],
[0.720391, 0.870350, 0.162603],
[0.730889, 0.871916, 0.156029],
[0.741388, 0.873449, 0.149561],
[0.751884, 0.874951, 0.143228],
[0.762373, 0.876424, 0.137064],
[0.772852, 0.877868, 0.131109],
[0.783315, 0.879285, 0.125405],
[0.793760, 0.880678, 0.120005],
[0.804182, 0.882046, 0.114965],
[0.814576, 0.883393, 0.110347],
[0.824940, 0.884720, 0.106217],
[0.835270, 0.886029, 0.102646],
[0.845561, 0.887322, 0.099702],
[0.855810, 0.888601, 0.097452],
[0.866013, 0.889868, 0.095953],
[0.876168, 0.891125, 0.095250],
[0.886271, 0.892374, 0.095374],
[0.896320, 0.893616, 0.096335],
[0.906311, 0.894855, 0.098125],
[0.916242, 0.896091, 0.100717],
[0.926106, 0.897330, 0.104071],
[0.935904, 0.898570, 0.108131],
[0.945636, 0.899815, 0.112838],
[0.955300, 0.901065, 0.118128],
[0.964894, 0.902323, 0.123941],
[0.974417, 0.903590, 0.130215],
[0.983868, 0.904867, 0.136897],
[0.993248, 0.906157, 0.143936]]
from matplotlib.colors import ListedColormap
cmaps = {}
for (name, data) in (('magma', _magma_data),
('inferno', _inferno_data),
('plasma', _plasma_data),
('viridis', _viridis_data)):
cmaps[name] = ListedColormap(data, name=name)
magma = cmaps['magma']
inferno = cmaps['inferno']
plasma = cmaps['plasma']
viridis = cmaps['viridis']
|
mit
|
[
3,
7053,
8027,
3164,
8919,
701,
653,
1619,
290,
14769,
1603,
14,
25924,
12,
17854,
12269,
20744,
16921,
644,
4478,
12,
199,
3,
436,
334,
262,
314,
1930,
402,
1321,
322,
2297,
9,
662,
1567,
481,
16648,
14,
199,
3,
199,
3,
961,
570,
436,
314,
3164,
8919,
315,
652,
787,
14286,
1334,
314,
17586,
16,
4190,
1182,
199,
3,
4575,
2881,
477,
21171,
14,
2136,
3955,
2771,
20940,
323,
16630,
340,
1265,
675,
503,
199,
3,
3604,
3520,
3164,
8919,
12,
1325,
886,
440,
1742,
3362,
1263,
18393,
24488,
14,
199,
3,
199,
3,
4005,
314,
13675,
3962,
1334,
4179,
12,
314,
12103,
3963,
4568,
17586,
16,
543,
199,
3,
22513,
13,
2326,
8919,
1172,
14442,
12905,
1006,
4248,
436,
4048,
503,
1279,
4594,
6854,
4481,
199,
3,
370,
22513,
13,
2326,
8919,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
17586,
16,
18393,
600,
3180,
543,
642,
199,
3,
1736,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1353,
1905,
2330,
83,
14,
1308,
15,
3455,
2261,
15,
4262,
15,
17,
14,
16,
4743,
199,
199,
363,
452,
363,
275,
788,
5615,
391,
297,
283,
14578,
889,
297,
283,
1168,
305,
391,
297,
283,
433,
322,
2297,
418,
199,
199,
63,
5615,
391,
63,
576,
275,
3474,
16,
14,
24037,
2789,
12,
378,
14,
16643,
1272,
12,
378,
14,
614,
8040,
22,
467,
2049,
359,
16,
14,
7432,
12234,
12,
378,
14,
22728,
2720,
12,
378,
14,
12549,
15638,
467,
2049,
359,
16,
14,
30867,
1965,
12,
378,
14,
7432,
11565,
12,
378,
14,
996,
1401,
2036,
467,
2049,
359,
16,
14,
31214,
713,
12,
378,
14,
383,
1082,
2710,
12,
378,
14,
996,
1020,
2182,
467,
2049,
359,
16,
14,
31690,
1400,
12,
378,
14,
7979,
14349,
12,
378,
14,
18325,
9056,
467,
2049,
359,
16,
14,
31028,
1299,
12,
378,
14,
8010,
13251,
12,
378,
14,
966,
1887,
2898,
467,
2049,
359,
16,
14,
383,
2635,
1479,
12,
378,
14,
8662,
16348,
12,
378,
14,
1717,
10681,
20,
467,
2049,
359,
16,
14,
614,
1079,
2182,
12,
378,
14,
383,
2905,
1651,
12,
378,
14,
1690,
1780,
1400,
467,
2049,
359,
16,
14,
614,
1401,
2036,
12,
378,
14,
614,
8881,
17,
12,
378,
14,
1690,
1184,
1822,
467,
2049,
359,
16,
14,
10882,
11309,
12,
378,
14,
614,
8188,
16,
12,
378,
14,
1780,
1272,
1644,
467,
2049,
359,
16,
14,
614,
1299,
1046,
12,
378,
14,
10882,
14842,
12,
378,
14,
26107,
12248,
467,
2049,
359,
16,
14,
996,
975,
2942,
12,
378,
14,
12549,
12122,
12,
378,
14,
1643,
1479,
709,
467,
2049,
359,
16,
14,
5284,
22364,
12,
378,
14,
996,
1780,
1046,
12,
378,
14,
1960,
19087,
467,
2049,
359,
16,
14,
15501,
4288,
12,
378,
14,
996,
708,
614,
12,
378,
14,
709,
1555,
1555,
467,
2049,
359,
16,
14,
1644,
975,
2534,
12,
378,
14,
18823,
19335,
12,
378,
14,
845,
1876,
2182,
467,
2049,
359,
16,
14,
1644,
1229,
1165,
12,
378,
14,
15501,
13145,
12,
378,
14,
6889,
11303,
467,
2049,
359,
16,
14,
10005,
32700,
12,
378,
14,
1644,
709,
2710,
12,
378,
14,
969,
1276,
1046,
467,
2049,
359,
16,
14,
16307,
1216,
12,
378,
14,
23951,
1216,
12,
378,
14,
1079,
1085,
1184,
467,
2049,
359,
16,
14,
966,
1257,
2789,
12,
378,
14,
1644,
1272,
1780,
12,
378,
14,
8251,
11754,
467,
2049,
359,
16,
14,
1717,
8001,
16,
12,
378,
14,
10005,
12641,
12,
378,
14,
1046,
1299,
2953,
467,
2049,
359,
16,
14,
1717,
1272,
1046,
12,
378,
14,
13011,
8488,
12,
378,
14,
975,
1342,
2466,
467,
2049,
359,
16,
14,
1690,
1643,
1887,
12,
378,
14,
9111,
21618,
12,
378,
14,
10216,
7263,
467,
2049,
359,
16,
14,
21254,
14137,
12,
378,
14,
966,
2898,
1085,
12,
378,
14,
10078,
15765,
467,
2049,
359,
16,
14,
1690,
2576,
772,
12,
378,
14,
966,
2576,
1479,
12,
378,
14,
1167,
1401,
1276,
467,
2049,
359,
16,
14,
24888,
11551,
12,
378,
14,
1717,
10680,
12,
378,
14,
4999,
15268,
467,
2049,
359,
16,
14,
1780,
1299,
1046,
12,
378,
14,
22663,
10078,
12,
378,
14,
12832,
14916,
467,
2049,
359,
16,
14,
2036,
1082,
2466,
12,
378,
14,
25369,
10932,
12,
378,
14,
1081,
1780,
1229,
467,
2049,
359,
16,
14,
27930,
11520,
12,
378,
14,
18009,
10456,
12,
378,
14,
1081,
1020,
1081,
467,
2049,
359,
16,
14,
1643,
1398,
1887,
12,
378,
14,
1717,
1020,
966,
12,
378,
14,
9803,
8982,
467,
2049,
359,
16,
14,
1643,
2277,
1153,
12,
378,
14,
1690,
1046,
2192,
12,
378,
14,
1194,
1349,
1138,
467,
2049,
359,
16,
14,
709,
1651,
1046,
12,
378,
14,
1690,
8507,
16,
12,
378,
14,
821,
2277,
1477,
467,
2049,
359,
16,
14,
709,
2277,
1020,
12,
378,
14,
17010,
13793,
12,
378,
14,
1479,
2819,
1407,
467,
2049,
359,
16,
14,
845,
1216,
2635,
12,
378,
14,
1690,
1477,
2942,
12,
378,
14,
1465,
1822,
1349,
467,
2049,
359,
16,
14,
845,
1349,
1717,
12,
378,
14,
1690,
772,
1965,
12,
378,
14,
11125,
12638,
467,
2049,
359,
16,
14,
713,
1703,
1153,
12,
378,
14,
19338,
11405,
12,
378,
14,
11405,
13657,
467,
2049,
359,
16,
14,
713,
3129,
1257,
12,
378,
14,
1690,
1965,
1276,
12,
378,
14,
1216,
1477,
2824,
467,
2049,
359,
16,
14,
969,
1400,
2481,
12,
378,
14,
19846,
16959,
12,
378,
14,
9927,
1493,
467,
2049,
359,
16,
14,
1079,
2036,
2010,
12,
378,
14,
1690,
1184,
1477,
12,
378,
14,
708,
2322,
1703,
467,
2049,
359,
16,
14,
1079,
1822,
2426,
12,
378,
14,
1690,
1555,
1703,
12,
378,
14,
8425,
13059,
467,
2049,
359,
16,
14,
1046,
1651,
1355,
12,
378,
14,
1690,
1184,
1401,
12,
378,
14,
1082,
1082,
966,
467,
2049,
359,
16,
14,
9327,
12549,
12,
378,
14,
19846,
12967,
12,
378,
14,
1276,
1479,
1299,
467,
2049,
359,
16,
14,
10355,
12127,
12,
378,
14,
1690,
1965,
845,
12,
378,
14,
1344,
1085,
975,
467,
2049,
359,
16,
14,
1196,
1196,
969,
12,
378,
14,
19338,
11565,
12,
378,
14,
13812,
19371,
467,
2049,
359,
16,
14,
1196,
2564
] |
[
7053,
8027,
3164,
8919,
701,
653,
1619,
290,
14769,
1603,
14,
25924,
12,
17854,
12269,
20744,
16921,
644,
4478,
12,
199,
3,
436,
334,
262,
314,
1930,
402,
1321,
322,
2297,
9,
662,
1567,
481,
16648,
14,
199,
3,
199,
3,
961,
570,
436,
314,
3164,
8919,
315,
652,
787,
14286,
1334,
314,
17586,
16,
4190,
1182,
199,
3,
4575,
2881,
477,
21171,
14,
2136,
3955,
2771,
20940,
323,
16630,
340,
1265,
675,
503,
199,
3,
3604,
3520,
3164,
8919,
12,
1325,
886,
440,
1742,
3362,
1263,
18393,
24488,
14,
199,
3,
199,
3,
4005,
314,
13675,
3962,
1334,
4179,
12,
314,
12103,
3963,
4568,
17586,
16,
543,
199,
3,
22513,
13,
2326,
8919,
1172,
14442,
12905,
1006,
4248,
436,
4048,
503,
1279,
4594,
6854,
4481,
199,
3,
370,
22513,
13,
2326,
8919,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
17586,
16,
18393,
600,
3180,
543,
642,
199,
3,
1736,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1353,
1905,
2330,
83,
14,
1308,
15,
3455,
2261,
15,
4262,
15,
17,
14,
16,
4743,
199,
199,
363,
452,
363,
275,
788,
5615,
391,
297,
283,
14578,
889,
297,
283,
1168,
305,
391,
297,
283,
433,
322,
2297,
418,
199,
199,
63,
5615,
391,
63,
576,
275,
3474,
16,
14,
24037,
2789,
12,
378,
14,
16643,
1272,
12,
378,
14,
614,
8040,
22,
467,
2049,
359,
16,
14,
7432,
12234,
12,
378,
14,
22728,
2720,
12,
378,
14,
12549,
15638,
467,
2049,
359,
16,
14,
30867,
1965,
12,
378,
14,
7432,
11565,
12,
378,
14,
996,
1401,
2036,
467,
2049,
359,
16,
14,
31214,
713,
12,
378,
14,
383,
1082,
2710,
12,
378,
14,
996,
1020,
2182,
467,
2049,
359,
16,
14,
31690,
1400,
12,
378,
14,
7979,
14349,
12,
378,
14,
18325,
9056,
467,
2049,
359,
16,
14,
31028,
1299,
12,
378,
14,
8010,
13251,
12,
378,
14,
966,
1887,
2898,
467,
2049,
359,
16,
14,
383,
2635,
1479,
12,
378,
14,
8662,
16348,
12,
378,
14,
1717,
10681,
20,
467,
2049,
359,
16,
14,
614,
1079,
2182,
12,
378,
14,
383,
2905,
1651,
12,
378,
14,
1690,
1780,
1400,
467,
2049,
359,
16,
14,
614,
1401,
2036,
12,
378,
14,
614,
8881,
17,
12,
378,
14,
1690,
1184,
1822,
467,
2049,
359,
16,
14,
10882,
11309,
12,
378,
14,
614,
8188,
16,
12,
378,
14,
1780,
1272,
1644,
467,
2049,
359,
16,
14,
614,
1299,
1046,
12,
378,
14,
10882,
14842,
12,
378,
14,
26107,
12248,
467,
2049,
359,
16,
14,
996,
975,
2942,
12,
378,
14,
12549,
12122,
12,
378,
14,
1643,
1479,
709,
467,
2049,
359,
16,
14,
5284,
22364,
12,
378,
14,
996,
1780,
1046,
12,
378,
14,
1960,
19087,
467,
2049,
359,
16,
14,
15501,
4288,
12,
378,
14,
996,
708,
614,
12,
378,
14,
709,
1555,
1555,
467,
2049,
359,
16,
14,
1644,
975,
2534,
12,
378,
14,
18823,
19335,
12,
378,
14,
845,
1876,
2182,
467,
2049,
359,
16,
14,
1644,
1229,
1165,
12,
378,
14,
15501,
13145,
12,
378,
14,
6889,
11303,
467,
2049,
359,
16,
14,
10005,
32700,
12,
378,
14,
1644,
709,
2710,
12,
378,
14,
969,
1276,
1046,
467,
2049,
359,
16,
14,
16307,
1216,
12,
378,
14,
23951,
1216,
12,
378,
14,
1079,
1085,
1184,
467,
2049,
359,
16,
14,
966,
1257,
2789,
12,
378,
14,
1644,
1272,
1780,
12,
378,
14,
8251,
11754,
467,
2049,
359,
16,
14,
1717,
8001,
16,
12,
378,
14,
10005,
12641,
12,
378,
14,
1046,
1299,
2953,
467,
2049,
359,
16,
14,
1717,
1272,
1046,
12,
378,
14,
13011,
8488,
12,
378,
14,
975,
1342,
2466,
467,
2049,
359,
16,
14,
1690,
1643,
1887,
12,
378,
14,
9111,
21618,
12,
378,
14,
10216,
7263,
467,
2049,
359,
16,
14,
21254,
14137,
12,
378,
14,
966,
2898,
1085,
12,
378,
14,
10078,
15765,
467,
2049,
359,
16,
14,
1690,
2576,
772,
12,
378,
14,
966,
2576,
1479,
12,
378,
14,
1167,
1401,
1276,
467,
2049,
359,
16,
14,
24888,
11551,
12,
378,
14,
1717,
10680,
12,
378,
14,
4999,
15268,
467,
2049,
359,
16,
14,
1780,
1299,
1046,
12,
378,
14,
22663,
10078,
12,
378,
14,
12832,
14916,
467,
2049,
359,
16,
14,
2036,
1082,
2466,
12,
378,
14,
25369,
10932,
12,
378,
14,
1081,
1780,
1229,
467,
2049,
359,
16,
14,
27930,
11520,
12,
378,
14,
18009,
10456,
12,
378,
14,
1081,
1020,
1081,
467,
2049,
359,
16,
14,
1643,
1398,
1887,
12,
378,
14,
1717,
1020,
966,
12,
378,
14,
9803,
8982,
467,
2049,
359,
16,
14,
1643,
2277,
1153,
12,
378,
14,
1690,
1046,
2192,
12,
378,
14,
1194,
1349,
1138,
467,
2049,
359,
16,
14,
709,
1651,
1046,
12,
378,
14,
1690,
8507,
16,
12,
378,
14,
821,
2277,
1477,
467,
2049,
359,
16,
14,
709,
2277,
1020,
12,
378,
14,
17010,
13793,
12,
378,
14,
1479,
2819,
1407,
467,
2049,
359,
16,
14,
845,
1216,
2635,
12,
378,
14,
1690,
1477,
2942,
12,
378,
14,
1465,
1822,
1349,
467,
2049,
359,
16,
14,
845,
1349,
1717,
12,
378,
14,
1690,
772,
1965,
12,
378,
14,
11125,
12638,
467,
2049,
359,
16,
14,
713,
1703,
1153,
12,
378,
14,
19338,
11405,
12,
378,
14,
11405,
13657,
467,
2049,
359,
16,
14,
713,
3129,
1257,
12,
378,
14,
1690,
1965,
1276,
12,
378,
14,
1216,
1477,
2824,
467,
2049,
359,
16,
14,
969,
1400,
2481,
12,
378,
14,
19846,
16959,
12,
378,
14,
9927,
1493,
467,
2049,
359,
16,
14,
1079,
2036,
2010,
12,
378,
14,
1690,
1184,
1477,
12,
378,
14,
708,
2322,
1703,
467,
2049,
359,
16,
14,
1079,
1822,
2426,
12,
378,
14,
1690,
1555,
1703,
12,
378,
14,
8425,
13059,
467,
2049,
359,
16,
14,
1046,
1651,
1355,
12,
378,
14,
1690,
1184,
1401,
12,
378,
14,
1082,
1082,
966,
467,
2049,
359,
16,
14,
9327,
12549,
12,
378,
14,
19846,
12967,
12,
378,
14,
1276,
1479,
1299,
467,
2049,
359,
16,
14,
10355,
12127,
12,
378,
14,
1690,
1965,
845,
12,
378,
14,
1344,
1085,
975,
467,
2049,
359,
16,
14,
1196,
1196,
969,
12,
378,
14,
19338,
11565,
12,
378,
14,
13812,
19371,
467,
2049,
359,
16,
14,
1196,
2564,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
juju/juju-gui-charm
|
hooks/charmhelpers/core/templating.py
|
1
|
3186
|
# Copyright 2014-2015 Canonical Limited.
#
# This file is part of charm-helpers.
#
# charm-helpers is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3 as
# published by the Free Software Foundation.
#
# charm-helpers is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
import os
from charmhelpers.core import host
from charmhelpers.core import hookenv
def render(source, target, context, owner='root', group='root',
perms=0o444, templates_dir=None, encoding='UTF-8', template_loader=None):
"""
Render a template.
The `source` path, if not absolute, is relative to the `templates_dir`.
The `target` path should be absolute. It can also be `None`, in which
case no file will be written.
The context should be a dict containing the values to be replaced in the
template.
The `owner`, `group`, and `perms` options will be passed to `write_file`.
If omitted, `templates_dir` defaults to the `templates` folder in the charm.
The rendered template will be written to the file as well as being returned
as a string.
Note: Using this requires python-jinja2; if it is not installed, calling
this will attempt to use charmhelpers.fetch.apt_install to install it.
"""
try:
from jinja2 import FileSystemLoader, Environment, exceptions
except ImportError:
try:
from charmhelpers.fetch import apt_install
except ImportError:
hookenv.log('Could not import jinja2, and could not import '
'charmhelpers.fetch to install it',
level=hookenv.ERROR)
raise
apt_install('python-jinja2', fatal=True)
from jinja2 import FileSystemLoader, Environment, exceptions
if template_loader:
template_env = Environment(loader=template_loader)
else:
if templates_dir is None:
templates_dir = os.path.join(hookenv.charm_dir(), 'templates')
template_env = Environment(loader=FileSystemLoader(templates_dir))
try:
source = source
template = template_env.get_template(source)
except exceptions.TemplateNotFound as e:
hookenv.log('Could not load template %s from %s.' %
(source, templates_dir),
level=hookenv.ERROR)
raise e
content = template.render(context)
if target is not None:
target_dir = os.path.dirname(target)
if not os.path.exists(target_dir):
# This is a terrible default directory permission, as the file
# or its siblings will often contain secrets.
host.mkdir(os.path.dirname(target), owner, group, perms=0o755)
host.write_file(target, content.encode(encoding), owner, group, perms)
return content
|
agpl-3.0
|
[
3,
1898,
6927,
13,
7806,
6855,
7174,
23954,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1495,
77,
13,
7546,
14,
199,
3,
199,
3,
1495,
77,
13,
7546,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
1015,
650,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
199,
3,
1495,
77,
13,
7546,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
1495,
77,
13,
7546,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
747,
199,
199,
504,
1495,
77,
7546,
14,
1018,
492,
1591,
199,
504,
1495,
77,
7546,
14,
1018,
492,
21404,
421,
199,
318,
3795,
8,
1365,
12,
1347,
12,
1067,
12,
5771,
534,
1231,
297,
1572,
534,
1231,
297,
1779,
17340,
29,
16,
79,
18078,
12,
7009,
63,
694,
29,
403,
12,
2644,
534,
6610,
13,
24,
297,
1978,
63,
3422,
29,
403,
304,
272,
408,
272,
17769,
282,
1978,
14,
339,
710,
658,
1365,
64,
931,
12,
340,
440,
3679,
12,
365,
3847,
370,
314,
658,
5876,
63,
694,
2313,
339,
710,
658,
1375,
64,
931,
1077,
506,
3679,
14,
221,
2779,
883,
2597,
506,
658,
403,
3559,
315,
1314,
272,
1930,
949,
570,
911,
506,
5313,
14,
339,
710,
1067,
1077,
506,
282,
1211,
3035,
314,
1338,
370,
506,
8717,
315,
314,
272,
1978,
14,
339,
710,
658,
4597,
3559,
658,
923,
3559,
436,
658,
12068,
64,
1511,
911,
506,
3032,
370,
658,
952,
63,
493,
2313,
339,
982,
11684,
12,
658,
5876,
63,
694,
64,
4243,
370,
314,
658,
5876,
64,
4922,
315,
314,
1495,
77,
14,
339,
710,
8018,
1978,
911,
506,
5313,
370,
314,
570,
465,
5521,
465,
3769,
2138,
272,
465,
282,
1059,
14,
339,
3390,
26,
11719,
642,
5074,
2366,
13,
12264,
18,
27,
340,
652,
365,
440,
4903,
12,
6358,
272,
642,
911,
7427,
370,
675,
1495,
77,
7546,
14,
3535,
14,
6182,
63,
3174,
370,
3907,
652,
14,
272,
408,
272,
862,
26,
267,
687,
10321,
18,
492,
23754,
5455,
12,
9711,
12,
4967,
272,
871,
3545,
26,
267,
862,
26,
288,
687,
1495,
77,
7546,
14,
3535,
492,
20932,
63,
3174,
267,
871,
3545,
26,
288,
21404,
14,
793,
360,
6531,
440,
492,
10321,
18,
12,
436,
4293,
440,
492,
283,
717,
283,
1560,
77,
7546,
14,
3535,
370,
3907,
652,
297,
717,
2166,
29,
3664,
1813,
14,
3170,
9,
288,
746,
267,
20932,
63,
3174,
360,
1548,
13,
12264,
18,
297,
14294,
29,
549,
9,
267,
687,
10321,
18,
492,
23754,
5455,
12,
9711,
12,
4967,
339,
340,
1978,
63,
3422,
26,
267,
1978,
63,
1813,
275,
9711,
8,
3422,
29,
1160,
63,
3422,
9,
272,
587,
26,
267,
340,
7009,
63,
694,
365,
488,
26,
288,
7009,
63,
694,
275,
747,
14,
515,
14,
904,
8,
3664,
1813,
14,
1560,
77,
63,
694,
1062,
283,
5876,
358,
267,
1978,
63,
1813,
275,
9711,
8,
3422,
29,
17521,
5455,
8,
5876,
63,
694,
430,
272,
862,
26,
267,
1350,
275,
1350,
267,
1978,
275,
1978,
63,
1813,
14,
362,
63,
1160,
8,
1365,
9,
272,
871,
4967,
14,
4231,
4667,
465,
325,
26,
267,
21404,
14,
793,
360,
6531,
440,
2248,
1978,
450,
83,
687,
450,
83,
3530,
450,
490,
334,
1365,
12,
7009,
63,
694,
395,
490,
2166,
29,
3664,
1813,
14,
3170,
9,
267,
746,
325,
272,
1564,
275,
1978,
14,
3352,
8,
1100,
9,
272,
340,
1347,
365,
440,
488,
26,
267,
1347,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
1375,
9,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
1375,
63,
694,
304,
288,
327,
961,
365,
282,
2044,
322,
830,
849,
2082,
4983,
12,
465,
314,
570,
288,
327,
503,
2399,
31871,
911,
14115,
1395,
25563,
14,
288,
1591,
14,
8215,
8,
736,
14,
515,
14,
3475,
8,
1375,
395,
5771,
12,
1572,
12,
17340,
29,
16,
79,
12315,
9,
267,
1591,
14,
952,
63,
493,
8,
1375,
12,
1564,
14,
2143,
8,
2991,
395,
5771,
12,
1572,
12,
17340,
9,
272,
372,
1564,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6927,
13,
7806,
6855,
7174,
23954,
14,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1495,
77,
13,
7546,
14,
199,
3,
199,
3,
1495,
77,
13,
7546,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
1015,
650,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
14,
199,
3,
199,
3,
1495,
77,
13,
7546,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
1495,
77,
13,
7546,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
747,
199,
199,
504,
1495,
77,
7546,
14,
1018,
492,
1591,
199,
504,
1495,
77,
7546,
14,
1018,
492,
21404,
421,
199,
318,
3795,
8,
1365,
12,
1347,
12,
1067,
12,
5771,
534,
1231,
297,
1572,
534,
1231,
297,
1779,
17340,
29,
16,
79,
18078,
12,
7009,
63,
694,
29,
403,
12,
2644,
534,
6610,
13,
24,
297,
1978,
63,
3422,
29,
403,
304,
272,
408,
272,
17769,
282,
1978,
14,
339,
710,
658,
1365,
64,
931,
12,
340,
440,
3679,
12,
365,
3847,
370,
314,
658,
5876,
63,
694,
2313,
339,
710,
658,
1375,
64,
931,
1077,
506,
3679,
14,
221,
2779,
883,
2597,
506,
658,
403,
3559,
315,
1314,
272,
1930,
949,
570,
911,
506,
5313,
14,
339,
710,
1067,
1077,
506,
282,
1211,
3035,
314,
1338,
370,
506,
8717,
315,
314,
272,
1978,
14,
339,
710,
658,
4597,
3559,
658,
923,
3559,
436,
658,
12068,
64,
1511,
911,
506,
3032,
370,
658,
952,
63,
493,
2313,
339,
982,
11684,
12,
658,
5876,
63,
694,
64,
4243,
370,
314,
658,
5876,
64,
4922,
315,
314,
1495,
77,
14,
339,
710,
8018,
1978,
911,
506,
5313,
370,
314,
570,
465,
5521,
465,
3769,
2138,
272,
465,
282,
1059,
14,
339,
3390,
26,
11719,
642,
5074,
2366,
13,
12264,
18,
27,
340,
652,
365,
440,
4903,
12,
6358,
272,
642,
911,
7427,
370,
675,
1495,
77,
7546,
14,
3535,
14,
6182,
63,
3174,
370,
3907,
652,
14,
272,
408,
272,
862,
26,
267,
687,
10321,
18,
492,
23754,
5455,
12,
9711,
12,
4967,
272,
871,
3545,
26,
267,
862,
26,
288,
687,
1495,
77,
7546,
14,
3535,
492,
20932,
63,
3174,
267,
871,
3545,
26,
288,
21404,
14,
793,
360,
6531,
440,
492,
10321,
18,
12,
436,
4293,
440,
492,
283,
717,
283,
1560,
77,
7546,
14,
3535,
370,
3907,
652,
297,
717,
2166,
29,
3664,
1813,
14,
3170,
9,
288,
746,
267,
20932,
63,
3174,
360,
1548,
13,
12264,
18,
297,
14294,
29,
549,
9,
267,
687,
10321,
18,
492,
23754,
5455,
12,
9711,
12,
4967,
339,
340,
1978,
63,
3422,
26,
267,
1978,
63,
1813,
275,
9711,
8,
3422,
29,
1160,
63,
3422,
9,
272,
587,
26,
267,
340,
7009,
63,
694,
365,
488,
26,
288,
7009,
63,
694,
275,
747,
14,
515,
14,
904,
8,
3664,
1813,
14,
1560,
77,
63,
694,
1062,
283,
5876,
358,
267,
1978,
63,
1813,
275,
9711,
8,
3422,
29,
17521,
5455,
8,
5876,
63,
694,
430,
272,
862,
26,
267,
1350,
275,
1350,
267,
1978,
275,
1978,
63,
1813,
14,
362,
63,
1160,
8,
1365,
9,
272,
871,
4967,
14,
4231,
4667,
465,
325,
26,
267,
21404,
14,
793,
360,
6531,
440,
2248,
1978,
450,
83,
687,
450,
83,
3530,
450,
490,
334,
1365,
12,
7009,
63,
694,
395,
490,
2166,
29,
3664,
1813,
14,
3170,
9,
267,
746,
325,
272,
1564,
275,
1978,
14,
3352,
8,
1100,
9,
272,
340,
1347,
365,
440,
488,
26,
267,
1347,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
1375,
9,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
1375,
63,
694,
304,
288,
327,
961,
365,
282,
2044,
322,
830,
849,
2082,
4983,
12,
465,
314,
570,
288,
327,
503,
2399,
31871,
911,
14115,
1395,
25563,
14,
288,
1591,
14,
8215,
8,
736,
14,
515,
14,
3475,
8,
1375,
395,
5771,
12,
1572,
12,
17340,
29,
16,
79,
12315,
9,
267,
1591,
14,
952,
63,
493,
8,
1375,
12,
1564,
14,
2143,
8,
2991,
395,
5771,
12,
1572,
12,
17340,
9,
272,
372,
1564,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
google-research/ssl_detection
|
third_party/tensorpack/tensorpack/dataflow/imgaug/crop.py
|
2
|
6674
|
# -*- coding: utf-8 -*-
# File: crop.py
import numpy as np
import cv2
from ...utils.argtools import shape2d
from ...utils.develop import log_deprecated
from .base import ImageAugmentor, ImagePlaceholder
from .transform import CropTransform, TransformList, ResizeTransform, PhotometricTransform
from .misc import ResizeShortestEdge
__all__ = ['RandomCrop', 'CenterCrop', 'RandomCropRandomShape',
'GoogleNetRandomCropAndResize', 'RandomCutout']
class RandomCrop(ImageAugmentor):
""" Randomly crop the image into a smaller one """
def __init__(self, crop_shape):
"""
Args:
crop_shape: (h, w), int or a tuple of int
"""
crop_shape = shape2d(crop_shape)
crop_shape = (int(crop_shape[0]), int(crop_shape[1]))
super(RandomCrop, self).__init__()
self._init(locals())
def get_transform(self, img):
orig_shape = img.shape
assert orig_shape[0] >= self.crop_shape[0] \
and orig_shape[1] >= self.crop_shape[1], orig_shape
diffh = orig_shape[0] - self.crop_shape[0]
h0 = self.rng.randint(diffh + 1)
diffw = orig_shape[1] - self.crop_shape[1]
w0 = self.rng.randint(diffw + 1)
return CropTransform(h0, w0, self.crop_shape[0], self.crop_shape[1])
class CenterCrop(ImageAugmentor):
""" Crop the image at the center"""
def __init__(self, crop_shape):
"""
Args:
crop_shape: (h, w) tuple or a int
"""
crop_shape = shape2d(crop_shape)
self._init(locals())
def get_transform(self, img):
orig_shape = img.shape
assert orig_shape[0] >= self.crop_shape[0] \
and orig_shape[1] >= self.crop_shape[1], orig_shape
h0 = int((orig_shape[0] - self.crop_shape[0]) * 0.5)
w0 = int((orig_shape[1] - self.crop_shape[1]) * 0.5)
return CropTransform(h0, w0, self.crop_shape[0], self.crop_shape[1])
class RandomCropRandomShape(ImageAugmentor):
""" Random crop with a random shape"""
def __init__(self, wmin, hmin,
wmax=None, hmax=None,
max_aspect_ratio=None):
"""
Randomly crop a box of shape (h, w), sampled from [min, max] (both inclusive).
If max is None, will use the input image shape.
Args:
wmin, hmin, wmax, hmax: range to sample shape.
max_aspect_ratio (float): this argument has no effect and is deprecated.
"""
super(RandomCropRandomShape, self).__init__()
if max_aspect_ratio is not None:
log_deprecated("RandomCropRandomShape(max_aspect_ratio)", "It is never implemented!", "2020-06-06")
self._init(locals())
def get_transform(self, img):
hmax = self.hmax or img.shape[0]
wmax = self.wmax or img.shape[1]
h = self.rng.randint(self.hmin, hmax + 1)
w = self.rng.randint(self.wmin, wmax + 1)
diffh = img.shape[0] - h
diffw = img.shape[1] - w
assert diffh >= 0 and diffw >= 0, str(diffh) + ", " + str(diffw)
y0 = 0 if diffh == 0 else self.rng.randint(diffh)
x0 = 0 if diffw == 0 else self.rng.randint(diffw)
return CropTransform(y0, x0, h, w)
class GoogleNetRandomCropAndResize(ImageAugmentor):
"""
The random crop and resize augmentation proposed in
Sec. 6 of "Going Deeper with Convolutions" by Google.
This implementation follows the details in ``fb.resnet.torch``.
It attempts to crop a random rectangle with 8%~100% area of the original image,
and keep the aspect ratio between 3/4 to 4/3. Then it resize this crop to the target shape.
If such crop cannot be found in 10 iterations, it will do a ResizeShortestEdge + CenterCrop.
"""
def __init__(self, crop_area_fraction=(0.08, 1.),
aspect_ratio_range=(0.75, 1.333),
target_shape=224, interp=cv2.INTER_LINEAR):
"""
Args:
crop_area_fraction (tuple(float)): Defaults to crop 8%-100% area.
aspect_ratio_range (tuple(float)): Defaults to make aspect ratio in 3/4-4/3.
target_shape (int): Defaults to 224, the standard ImageNet image shape.
"""
super(GoogleNetRandomCropAndResize, self).__init__()
self._init(locals())
def get_transform(self, img):
h, w = img.shape[:2]
area = h * w
for _ in range(10):
targetArea = self.rng.uniform(*self.crop_area_fraction) * area
aspectR = self.rng.uniform(*self.aspect_ratio_range)
ww = int(np.sqrt(targetArea * aspectR) + 0.5)
hh = int(np.sqrt(targetArea / aspectR) + 0.5)
if self.rng.uniform() < 0.5:
ww, hh = hh, ww
if hh <= h and ww <= w:
x1 = self.rng.randint(0, w - ww + 1)
y1 = self.rng.randint(0, h - hh + 1)
return TransformList([
CropTransform(y1, x1, hh, ww),
ResizeTransform(hh, ww, self.target_shape, self.target_shape, interp=self.interp)
])
resize = ResizeShortestEdge(self.target_shape, interp=self.interp).get_transform(img)
out_shape = (resize.new_h, resize.new_w)
crop = CenterCrop(self.target_shape).get_transform(ImagePlaceholder(shape=out_shape))
return TransformList([resize, crop])
class RandomCutout(ImageAugmentor):
"""
The cutout augmentation, as described in https://arxiv.org/abs/1708.04552
"""
def __init__(self, h_range, w_range, fill=0.):
"""
Args:
h_range (int or tuple): the height of rectangle to cut.
If a tuple, will randomly sample from this range [low, high)
w_range (int or tuple): similar to above
fill (float): the fill value
"""
super(RandomCutout, self).__init__()
self._init(locals())
def _get_cutout_shape(self):
if isinstance(self.h_range, int):
h = self.h_range
else:
h = self.rng.randint(self.h_range)
if isinstance(self.w_range, int):
w = self.w_range
else:
w = self.rng.randint(self.w_range)
return h, w
@staticmethod
def _cutout(img, y0, x0, h, w, fill):
img[y0:y0 + h, x0:x0 + w] = fill
return img
def get_transform(self, img):
h, w = self._get_cutout_shape()
x0 = self.rng.randint(0, img.shape[1] + 1 - w)
y0 = self.rng.randint(0, img.shape[0] + 1 - h)
return PhotometricTransform(
lambda img: RandomCutout._cutout(img, y0, x0, h, w, self.fill),
"cutout")
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
3814,
26,
18366,
14,
647,
199,
199,
646,
2680,
465,
980,
199,
646,
6277,
18,
199,
199,
504,
2263,
1208,
14,
1273,
2537,
492,
2215,
18,
68,
199,
504,
2263,
1208,
14,
32176,
492,
943,
63,
6667,
199,
504,
1275,
1095,
492,
6047,
21640,
434,
269,
12,
6047,
20185,
199,
504,
1275,
4711,
492,
445,
2675,
6939,
12,
19463,
1296,
12,
799,
890,
6939,
12,
510,
8885,
15890,
6939,
199,
504,
1275,
9923,
492,
799,
890,
2662,
269,
396,
12886,
199,
199,
363,
452,
363,
275,
788,
3883,
35,
2675,
297,
283,
13551,
35,
2675,
297,
283,
3883,
35,
2675,
3883,
7238,
297,
1779,
283,
13266,
2480,
3883,
35,
2675,
3325,
24559,
297,
283,
3883,
23498,
548,
418,
421,
199,
533,
9571,
35,
2675,
8,
3491,
21640,
434,
269,
304,
272,
408,
9571,
590,
18366,
314,
1834,
1901,
282,
12700,
1373,
408,
339,
347,
636,
826,
721,
277,
12,
18366,
63,
1392,
304,
267,
408,
267,
3033,
26,
288,
18366,
63,
1392,
26,
334,
72,
12,
336,
395,
1109,
503,
282,
2008,
402,
1109,
267,
408,
267,
18366,
63,
1392,
275,
2215,
18,
68,
8,
15816,
63,
1392,
9,
267,
18366,
63,
1392,
275,
334,
442,
8,
15816,
63,
1392,
59,
16,
2522,
1109,
8,
15816,
63,
1392,
59,
17,
2459,
267,
1613,
8,
3883,
35,
2675,
12,
291,
2843,
826,
4533,
267,
291,
423,
826,
8,
9350,
1012,
339,
347,
664,
63,
4711,
8,
277,
12,
6050,
304,
267,
2306,
63,
1392,
275,
6050,
14,
1392,
267,
702,
2306,
63,
1392,
59,
16,
61,
2356,
291,
14,
15816,
63,
1392,
59,
16,
61,
971,
288,
436,
2306,
63,
1392,
59,
17,
61,
2356,
291,
14,
15816,
63,
1392,
59,
17,
467,
2306,
63,
1392,
267,
3915,
72,
275,
2306,
63,
1392,
59,
16,
61,
446,
291,
14,
15816,
63,
1392,
59,
16,
61,
267,
394,
16,
275,
291,
14,
12686,
14,
8393,
8,
3028,
72,
435,
413,
9,
267,
3915,
87,
275,
2306,
63,
1392,
59,
17,
61,
446,
291,
14,
15816,
63,
1392,
59,
17,
61,
267,
336,
16,
275,
291,
14,
12686,
14,
8393,
8,
3028,
87,
435,
413,
9,
267,
372,
445,
2675,
6939,
8,
72,
16,
12,
336,
16,
12,
291,
14,
15816,
63,
1392,
59,
16,
467,
291,
14,
15816,
63,
1392,
59,
17,
566,
421,
199,
533,
24699,
35,
2675,
8,
3491,
21640,
434,
269,
304,
272,
408,
445,
2675,
314,
1834,
737,
314,
8126,
624,
339,
347,
636,
826,
721,
277,
12,
18366,
63,
1392,
304,
267,
408,
267,
3033,
26,
288,
18366,
63,
1392,
26,
334,
72,
12,
336,
9,
2008,
503,
282,
1109,
267,
408,
267,
18366,
63,
1392,
275,
2215,
18,
68,
8,
15816,
63,
1392,
9,
267,
291,
423,
826,
8,
9350,
1012,
339,
347,
664,
63,
4711,
8,
277,
12,
6050,
304,
267,
2306,
63,
1392,
275,
6050,
14,
1392,
267,
702,
2306,
63,
1392,
59,
16,
61,
2356,
291,
14,
15816,
63,
1392,
59,
16,
61,
971,
288,
436,
2306,
63,
1392,
59,
17,
61,
2356,
291,
14,
15816,
63,
1392,
59,
17,
467,
2306,
63,
1392,
267,
394,
16,
275,
1109,
1332,
2981,
63,
1392,
59,
16,
61,
446,
291,
14,
15816,
63,
1392,
59,
16,
566,
627,
378,
14,
21,
9,
267,
336,
16,
275,
1109,
1332,
2981,
63,
1392,
59,
17,
61,
446,
291,
14,
15816,
63,
1392,
59,
17,
566,
627,
378,
14,
21,
9,
267,
372,
445,
2675,
6939,
8,
72,
16,
12,
336,
16,
12,
291,
14,
15816,
63,
1392,
59,
16,
467,
291,
14,
15816,
63,
1392,
59,
17,
566,
421,
199,
533,
9571,
35,
2675,
3883,
7238,
8,
3491,
21640,
434,
269,
304,
272,
408,
9571,
18366,
543,
282,
2196,
2215,
624,
339,
347,
636,
826,
721,
277,
12,
336,
827,
12,
394,
827,
12,
326,
336,
988,
29,
403,
12,
394,
988,
29,
403,
12,
326,
1390,
63,
18658,
63,
6884,
29,
403,
304,
267,
408,
267,
9571,
590,
18366,
282,
5689,
402,
2215,
334,
72,
12,
336,
395,
24914,
687,
359,
827,
12,
1390,
61,
334,
10727,
20728,
680,
267,
982,
1390,
365,
488,
12,
911,
675,
314,
1324,
1834,
2215,
14,
398,
3033,
26,
288,
336,
827,
12,
394,
827,
12,
336,
988,
12,
394,
988,
26,
1425,
370,
2690,
2215,
14,
288,
1390,
63,
18658,
63,
6884,
334,
1609,
304,
642,
1423,
965,
949,
7763,
436,
365,
5906,
14,
267,
408,
267,
1613,
8,
3883,
35,
2675,
3883,
7238,
12,
291,
2843,
826,
4533,
267,
340,
1390,
63,
18658,
63,
6884,
365,
440,
488,
26,
288,
943,
63,
6667,
480,
3883,
35,
2675,
3883,
7238,
8,
988,
63,
18658,
63,
6884,
4186,
298,
7940,
365,
7078,
6366,
17716,
298,
13934,
13,
1690,
13,
1690,
531,
267,
291,
423,
826,
8,
9350,
1012,
339,
347,
664,
63,
4711,
8,
277,
12,
6050,
304,
267,
394,
988,
275,
291,
14,
72,
988,
503,
6050,
14,
1392,
59,
16,
61,
267,
336,
988,
275,
291,
14,
87,
988,
503,
6050,
14,
1392,
59,
17,
61,
267,
394,
275,
291,
14,
12686,
14,
8393,
8,
277,
14,
72,
827,
12,
394,
988,
435,
413,
9,
267,
336,
275,
291,
14,
12686,
14,
8393,
8,
277,
14,
87,
827,
12,
336,
988,
435,
413,
9,
267,
3915,
72,
275,
6050,
14,
1392,
59,
16,
61,
446,
394,
267,
3915,
87,
275,
6050,
14,
1392,
59,
17,
61,
446,
336,
267,
702,
3915,
72,
2356,
378,
436,
3915,
87,
2356,
378,
12,
620,
8,
3028,
72,
9,
435,
3872,
298,
435,
620,
8,
3028,
87,
9,
267,
612,
16,
275,
378,
340,
3915,
72,
508,
378,
587,
291,
14,
12686,
14,
8393,
8,
3028,
72,
9,
267,
671,
16,
275,
378,
340,
3915,
87,
508,
378,
587,
291,
14,
12686,
14,
8393,
8,
3028,
87,
9,
267,
372,
445,
2675,
6939,
8,
89,
16,
12,
671,
16,
12,
394,
12,
336,
9,
421,
199,
533,
4475,
2480,
3883,
35,
2675,
3325,
24559,
8,
3491,
21640,
434,
269,
304,
272,
408,
272,
710,
2196,
18366,
436,
15210,
18336,
3117,
14075,
315,
272,
9433,
14,
1227,
402,
298,
7250,
316,
577,
1024,
529,
543,
1448,
5650
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
3814,
26,
18366,
14,
647,
199,
199,
646,
2680,
465,
980,
199,
646,
6277,
18,
199,
199,
504,
2263,
1208,
14,
1273,
2537,
492,
2215,
18,
68,
199,
504,
2263,
1208,
14,
32176,
492,
943,
63,
6667,
199,
504,
1275,
1095,
492,
6047,
21640,
434,
269,
12,
6047,
20185,
199,
504,
1275,
4711,
492,
445,
2675,
6939,
12,
19463,
1296,
12,
799,
890,
6939,
12,
510,
8885,
15890,
6939,
199,
504,
1275,
9923,
492,
799,
890,
2662,
269,
396,
12886,
199,
199,
363,
452,
363,
275,
788,
3883,
35,
2675,
297,
283,
13551,
35,
2675,
297,
283,
3883,
35,
2675,
3883,
7238,
297,
1779,
283,
13266,
2480,
3883,
35,
2675,
3325,
24559,
297,
283,
3883,
23498,
548,
418,
421,
199,
533,
9571,
35,
2675,
8,
3491,
21640,
434,
269,
304,
272,
408,
9571,
590,
18366,
314,
1834,
1901,
282,
12700,
1373,
408,
339,
347,
636,
826,
721,
277,
12,
18366,
63,
1392,
304,
267,
408,
267,
3033,
26,
288,
18366,
63,
1392,
26,
334,
72,
12,
336,
395,
1109,
503,
282,
2008,
402,
1109,
267,
408,
267,
18366,
63,
1392,
275,
2215,
18,
68,
8,
15816,
63,
1392,
9,
267,
18366,
63,
1392,
275,
334,
442,
8,
15816,
63,
1392,
59,
16,
2522,
1109,
8,
15816,
63,
1392,
59,
17,
2459,
267,
1613,
8,
3883,
35,
2675,
12,
291,
2843,
826,
4533,
267,
291,
423,
826,
8,
9350,
1012,
339,
347,
664,
63,
4711,
8,
277,
12,
6050,
304,
267,
2306,
63,
1392,
275,
6050,
14,
1392,
267,
702,
2306,
63,
1392,
59,
16,
61,
2356,
291,
14,
15816,
63,
1392,
59,
16,
61,
971,
288,
436,
2306,
63,
1392,
59,
17,
61,
2356,
291,
14,
15816,
63,
1392,
59,
17,
467,
2306,
63,
1392,
267,
3915,
72,
275,
2306,
63,
1392,
59,
16,
61,
446,
291,
14,
15816,
63,
1392,
59,
16,
61,
267,
394,
16,
275,
291,
14,
12686,
14,
8393,
8,
3028,
72,
435,
413,
9,
267,
3915,
87,
275,
2306,
63,
1392,
59,
17,
61,
446,
291,
14,
15816,
63,
1392,
59,
17,
61,
267,
336,
16,
275,
291,
14,
12686,
14,
8393,
8,
3028,
87,
435,
413,
9,
267,
372,
445,
2675,
6939,
8,
72,
16,
12,
336,
16,
12,
291,
14,
15816,
63,
1392,
59,
16,
467,
291,
14,
15816,
63,
1392,
59,
17,
566,
421,
199,
533,
24699,
35,
2675,
8,
3491,
21640,
434,
269,
304,
272,
408,
445,
2675,
314,
1834,
737,
314,
8126,
624,
339,
347,
636,
826,
721,
277,
12,
18366,
63,
1392,
304,
267,
408,
267,
3033,
26,
288,
18366,
63,
1392,
26,
334,
72,
12,
336,
9,
2008,
503,
282,
1109,
267,
408,
267,
18366,
63,
1392,
275,
2215,
18,
68,
8,
15816,
63,
1392,
9,
267,
291,
423,
826,
8,
9350,
1012,
339,
347,
664,
63,
4711,
8,
277,
12,
6050,
304,
267,
2306,
63,
1392,
275,
6050,
14,
1392,
267,
702,
2306,
63,
1392,
59,
16,
61,
2356,
291,
14,
15816,
63,
1392,
59,
16,
61,
971,
288,
436,
2306,
63,
1392,
59,
17,
61,
2356,
291,
14,
15816,
63,
1392,
59,
17,
467,
2306,
63,
1392,
267,
394,
16,
275,
1109,
1332,
2981,
63,
1392,
59,
16,
61,
446,
291,
14,
15816,
63,
1392,
59,
16,
566,
627,
378,
14,
21,
9,
267,
336,
16,
275,
1109,
1332,
2981,
63,
1392,
59,
17,
61,
446,
291,
14,
15816,
63,
1392,
59,
17,
566,
627,
378,
14,
21,
9,
267,
372,
445,
2675,
6939,
8,
72,
16,
12,
336,
16,
12,
291,
14,
15816,
63,
1392,
59,
16,
467,
291,
14,
15816,
63,
1392,
59,
17,
566,
421,
199,
533,
9571,
35,
2675,
3883,
7238,
8,
3491,
21640,
434,
269,
304,
272,
408,
9571,
18366,
543,
282,
2196,
2215,
624,
339,
347,
636,
826,
721,
277,
12,
336,
827,
12,
394,
827,
12,
326,
336,
988,
29,
403,
12,
394,
988,
29,
403,
12,
326,
1390,
63,
18658,
63,
6884,
29,
403,
304,
267,
408,
267,
9571,
590,
18366,
282,
5689,
402,
2215,
334,
72,
12,
336,
395,
24914,
687,
359,
827,
12,
1390,
61,
334,
10727,
20728,
680,
267,
982,
1390,
365,
488,
12,
911,
675,
314,
1324,
1834,
2215,
14,
398,
3033,
26,
288,
336,
827,
12,
394,
827,
12,
336,
988,
12,
394,
988,
26,
1425,
370,
2690,
2215,
14,
288,
1390,
63,
18658,
63,
6884,
334,
1609,
304,
642,
1423,
965,
949,
7763,
436,
365,
5906,
14,
267,
408,
267,
1613,
8,
3883,
35,
2675,
3883,
7238,
12,
291,
2843,
826,
4533,
267,
340,
1390,
63,
18658,
63,
6884,
365,
440,
488,
26,
288,
943,
63,
6667,
480,
3883,
35,
2675,
3883,
7238,
8,
988,
63,
18658,
63,
6884,
4186,
298,
7940,
365,
7078,
6366,
17716,
298,
13934,
13,
1690,
13,
1690,
531,
267,
291,
423,
826,
8,
9350,
1012,
339,
347,
664,
63,
4711,
8,
277,
12,
6050,
304,
267,
394,
988,
275,
291,
14,
72,
988,
503,
6050,
14,
1392,
59,
16,
61,
267,
336,
988,
275,
291,
14,
87,
988,
503,
6050,
14,
1392,
59,
17,
61,
267,
394,
275,
291,
14,
12686,
14,
8393,
8,
277,
14,
72,
827,
12,
394,
988,
435,
413,
9,
267,
336,
275,
291,
14,
12686,
14,
8393,
8,
277,
14,
87,
827,
12,
336,
988,
435,
413,
9,
267,
3915,
72,
275,
6050,
14,
1392,
59,
16,
61,
446,
394,
267,
3915,
87,
275,
6050,
14,
1392,
59,
17,
61,
446,
336,
267,
702,
3915,
72,
2356,
378,
436,
3915,
87,
2356,
378,
12,
620,
8,
3028,
72,
9,
435,
3872,
298,
435,
620,
8,
3028,
87,
9,
267,
612,
16,
275,
378,
340,
3915,
72,
508,
378,
587,
291,
14,
12686,
14,
8393,
8,
3028,
72,
9,
267,
671,
16,
275,
378,
340,
3915,
87,
508,
378,
587,
291,
14,
12686,
14,
8393,
8,
3028,
87,
9,
267,
372,
445,
2675,
6939,
8,
89,
16,
12,
671,
16,
12,
394,
12,
336,
9,
421,
199,
533,
4475,
2480,
3883,
35,
2675,
3325,
24559,
8,
3491,
21640,
434,
269,
304,
272,
408,
272,
710,
2196,
18366,
436,
15210,
18336,
3117,
14075,
315,
272,
9433,
14,
1227,
402,
298,
7250,
316,
577,
1024,
529,
543,
1448,
5650,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
nathanielmanistaatgoogle/grpc
|
src/python/src/grpc/framework/base/exceptions.py
|
44
|
1716
|
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Exceptions defined and used by the base layer of RPC Framework."""
class NoSuchMethodError(Exception):
"""Indicates that an operation with an unrecognized name has been called."""
|
bsd-3-clause
|
[
3,
1898,
6900,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
16836,
3247,
436,
1202,
701,
314,
1300,
4045,
402,
11785,
22545,
1041,
421,
199,
533,
23798,
3767,
547,
8,
1726,
304,
523,
408,
607,
16292,
626,
376,
3439,
543,
376,
24718,
536,
965,
2757,
2797,
1041,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6900,
12,
4475,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
624,
16836,
3247,
436,
1202,
701,
314,
1300,
4045,
402,
11785,
22545,
1041,
421,
199,
533,
23798,
3767,
547,
8,
1726,
304,
523,
408,
607,
16292,
626,
376,
3439,
543,
376,
24718,
536,
965,
2757,
2797,
1041,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Oi-Android/android_kernel_xiaomi_ferrari-mr
|
tools/perf/scripts/python/futex-contention.py
|
11261
|
1486
|
# futex contention
# (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com>
# Licensed under the terms of the GNU GPL License version 2
#
# Translation of:
#
# http://sourceware.org/systemtap/wiki/WSFutexContention
#
# to perf python scripting.
#
# Measures futex contention
import os, sys
sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from Util import *
process_names = {}
thread_thislock = {}
thread_blocktime = {}
lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time
process_names = {} # long-lived pid-to-execname mapping
def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm,
nr, uaddr, op, val, utime, uaddr2, val3):
cmd = op & FUTEX_CMD_MASK
if cmd != FUTEX_WAIT:
return # we don't care about originators of WAKE events
process_names[tid] = comm
thread_thislock[tid] = uaddr
thread_blocktime[tid] = nsecs(s, ns)
def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm,
nr, ret):
if thread_blocktime.has_key(tid):
elapsed = nsecs(s, ns) - thread_blocktime[tid]
add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed)
del thread_blocktime[tid]
del thread_thislock[tid]
def trace_begin():
print "Press control+C to stop and show the summary"
def trace_end():
for (tid, lock) in lock_waits:
min, max, avg, count = lock_waits[tid, lock]
print "%s[%d] lock %x contended %d times, %d avg ns" % \
(process_names[tid], tid, lock, count, avg)
|
gpl-2.0
|
[
3,
289,
18173,
406,
9553,
199,
3,
334,
67,
9,
7129,
12,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
25224,
402,
26,
199,
3,
199,
3,
1455,
921,
1365,
1068,
14,
1308,
15,
2253,
16609,
15,
6797,
15,
5035,
38,
18173,
714,
9553,
199,
3,
199,
3,
370,
8582,
2366,
2884,
316,
14,
199,
3,
199,
3,
3194,
305,
1482,
289,
18173,
406,
9553,
199,
199,
646,
747,
12,
984,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
504,
21248,
492,
627,
199,
199,
1412,
63,
1247,
275,
1052,
199,
2671,
63,
3749,
831,
275,
1052,
199,
2671,
63,
1457,
521,
275,
1052,
199,
199,
831,
63,
758,
1405,
275,
1052,
327,
1846,
13,
317,
1354,
5020,
641,
334,
5700,
12,
831,
9,
1853,
474,
14439,
900,
199,
1412,
63,
1247,
275,
1052,
327,
1846,
13,
317,
1354,
4422,
13,
475,
13,
1628,
354,
4412,
199,
199,
318,
19473,
363,
1274,
63,
4200,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
420,
14762,
12,
399,
2697,
12,
1687,
12,
1139,
12,
399,
521,
12,
399,
2697,
18,
12,
1139,
19,
304,
199,
198,
1760,
275,
1687,
1253,
481,
934,
1438,
63,
9744,
63,
12880,
199,
198,
692,
2088,
1137,
481,
934,
1438,
63,
12458,
26,
507,
198,
1107,
327,
781,
2793,
1133,
10296,
3595,
6330,
2750,
402,
644,
22339,
4474,
421,
198,
1412,
63,
1247,
59,
5700,
61,
275,
1923,
199,
198,
2671,
63,
3749,
831,
59,
5700,
61,
275,
399,
2697,
199,
198,
2671,
63,
1457,
521,
59,
5700,
61,
275,
13781,
8,
83,
12,
700,
9,
199,
199,
318,
19473,
363,
1274,
63,
2224,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
258,
14762,
12,
2203,
304,
199,
198,
692,
2462,
63,
1457,
521,
14,
1989,
63,
498,
8,
5700,
304,
507,
198,
16691,
275,
13781,
8,
83,
12,
700,
9,
446,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
525,
63,
3200,
8,
831,
63,
758,
1405,
12,
334,
5700,
12,
2462,
63,
3749,
831,
59,
5700,
2522,
14439,
9,
507,
198,
2264,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
2264,
2462,
63,
3749,
831,
59,
5700,
61,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
14414,
3304,
11,
35,
370,
3631,
436,
2498,
314,
6212,
2,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
509,
334,
5700,
12,
4650,
9,
315,
4650,
63,
758,
1405,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
4650,
63,
758,
1405,
59,
5700,
12,
4650,
61,
507,
198,
1361,
2071,
83,
9722,
68,
61,
4650,
450,
88,
406,
6943,
450,
68,
5431,
12,
450,
68,
12402,
700,
2,
450,
971,
686,
420,
334,
1412,
63,
1247,
59,
5700,
467,
11559,
12,
4650,
12,
2338,
12,
12402,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
289,
18173,
406,
9553,
199,
3,
334,
67,
9,
7129,
12,
1952,
78,
279,
1117,
14243,
637,
526,
477,
3194,
320,
665,
18107,
32,
17164,
14,
957,
30,
199,
3,
3909,
1334,
314,
2895,
402,
314,
1664,
14629,
844,
1015,
499,
199,
3,
199,
3,
25224,
402,
26,
199,
3,
199,
3,
1455,
921,
1365,
1068,
14,
1308,
15,
2253,
16609,
15,
6797,
15,
5035,
38,
18173,
714,
9553,
199,
3,
199,
3,
370,
8582,
2366,
2884,
316,
14,
199,
3,
199,
3,
3194,
305,
1482,
289,
18173,
406,
9553,
199,
199,
646,
747,
12,
984,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
504,
21248,
492,
627,
199,
199,
1412,
63,
1247,
275,
1052,
199,
2671,
63,
3749,
831,
275,
1052,
199,
2671,
63,
1457,
521,
275,
1052,
199,
199,
831,
63,
758,
1405,
275,
1052,
327,
1846,
13,
317,
1354,
5020,
641,
334,
5700,
12,
831,
9,
1853,
474,
14439,
900,
199,
1412,
63,
1247,
275,
1052,
327,
1846,
13,
317,
1354,
4422,
13,
475,
13,
1628,
354,
4412,
199,
199,
318,
19473,
363,
1274,
63,
4200,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
420,
14762,
12,
399,
2697,
12,
1687,
12,
1139,
12,
399,
521,
12,
399,
2697,
18,
12,
1139,
19,
304,
199,
198,
1760,
275,
1687,
1253,
481,
934,
1438,
63,
9744,
63,
12880,
199,
198,
692,
2088,
1137,
481,
934,
1438,
63,
12458,
26,
507,
198,
1107,
327,
781,
2793,
1133,
10296,
3595,
6330,
2750,
402,
644,
22339,
4474,
421,
198,
1412,
63,
1247,
59,
5700,
61,
275,
1923,
199,
198,
2671,
63,
3749,
831,
59,
5700,
61,
275,
399,
2697,
199,
198,
2671,
63,
1457,
521,
59,
5700,
61,
275,
13781,
8,
83,
12,
700,
9,
199,
199,
318,
19473,
363,
1274,
63,
2224,
63,
70,
18173,
8,
1430,
12,
11216,
12,
5033,
12,
308,
12,
700,
12,
11559,
12,
1923,
12,
1585,
258,
14762,
12,
2203,
304,
199,
198,
692,
2462,
63,
1457,
521,
14,
1989,
63,
498,
8,
5700,
304,
507,
198,
16691,
275,
13781,
8,
83,
12,
700,
9,
446,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
525,
63,
3200,
8,
831,
63,
758,
1405,
12,
334,
5700,
12,
2462,
63,
3749,
831,
59,
5700,
2522,
14439,
9,
507,
198,
2264,
2462,
63,
1457,
521,
59,
5700,
61,
507,
198,
2264,
2462,
63,
3749,
831,
59,
5700,
61,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
14414,
3304,
11,
35,
370,
3631,
436,
2498,
314,
6212,
2,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
509,
334,
5700,
12,
4650,
9,
315,
4650,
63,
758,
1405,
26,
507,
198,
827,
12,
1390,
12,
12402,
12,
2338,
275,
4650,
63,
758,
1405,
59,
5700,
12,
4650,
61,
507,
198,
1361,
2071,
83,
9722,
68,
61,
4650,
450,
88,
406,
6943,
450,
68,
5431,
12,
450,
68,
12402,
700,
2,
450,
971,
686,
420,
334,
1412,
63,
1247,
59,
5700,
467,
11559,
12,
4650,
12,
2338,
12,
12402,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
losywee/rethinkdb
|
external/v8_3.30.33.16/build/gyp/test/win/gyptest-link-deffile.py
|
344
|
1252
|
#!/usr/bin/env python
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Make sure a .def file is handled in the link.
"""
import TestGyp
import sys
if sys.platform == 'win32':
test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
CHDIR = 'linker-flags'
# Multiple .def files doesn't make any sense, should fail at generate time.
test.run_gyp('deffile-multiple.gyp', chdir=CHDIR, stderr=None, status=1)
test.run_gyp('deffile.gyp', chdir=CHDIR)
test.build('deffile.gyp', test.ALL, chdir=CHDIR)
def HasExport(binary, export):
full_path = test.built_file_path(binary, chdir=CHDIR)
output = test.run_dumpbin('/exports', full_path)
return export in output
# Make sure we only have the export when the .def file is in use.
if HasExport('test_deffile_dll_notexported.dll', 'AnExportedFunction'):
test.fail_test()
if not HasExport('test_deffile_dll_ok.dll', 'AnExportedFunction'):
test.fail_test()
if HasExport('test_deffile_exe_notexported.exe', 'AnExportedFunction'):
test.fail_test()
if not HasExport('test_deffile_exe_ok.exe', 'AnExportedFunction'):
test.fail_test()
test.pass_test()
|
agpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
5483,
3238,
282,
1275,
318,
570,
365,
8860,
315,
314,
2142,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
646,
984,
199,
199,
692,
984,
14,
3246,
508,
283,
2676,
708,
356,
523,
511,
275,
25688,
14,
774,
13899,
8,
6321,
2968,
8338,
297,
283,
8675,
1105,
819,
6624,
3022,
275,
283,
20311,
13,
2469,
7,
819,
327,
14326,
1275,
318,
1584,
3181,
1133,
1852,
1263,
12249,
12,
1077,
2449,
737,
3550,
900,
14,
523,
511,
14,
1065,
63,
6179,
360,
318,
493,
13,
6048,
14,
6179,
297,
13097,
29,
30285,
12,
4635,
29,
403,
12,
2004,
29,
17,
9,
819,
511,
14,
1065,
63,
6179,
360,
318,
493,
14,
6179,
297,
13097,
29,
30285,
9,
523,
511,
14,
1506,
360,
318,
493,
14,
6179,
297,
511,
14,
1761,
12,
13097,
29,
30285,
9,
819,
347,
13481,
11399,
8,
3008,
12,
4843,
304,
272,
2615,
63,
515,
275,
511,
14,
11730,
63,
493,
63,
515,
8,
3008,
12,
13097,
29,
30285,
9,
272,
1072,
275,
511,
14,
1065,
63,
2724,
1393,
2336,
20775,
297,
2615,
63,
515,
9,
272,
372,
4843,
315,
1072,
819,
327,
4155,
3238,
781,
1454,
1172,
314,
4843,
1380,
314,
1275,
318,
570,
365,
315,
675,
14,
819,
340,
13481,
11399,
360,
396,
63,
318,
493,
63,
9259,
63,
889,
3858,
2315,
14,
9259,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
523,
340,
440,
13481,
11399,
360,
396,
63,
318,
493,
63,
9259,
63,
745,
14,
9259,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
819,
340,
13481,
11399,
360,
396,
63,
318,
493,
63,
5803,
63,
889,
3858,
2315,
14,
5803,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
523,
340,
440,
13481,
11399,
360,
396,
63,
318,
493,
63,
5803,
63,
745,
14,
5803,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
819,
511,
14,
1529,
63,
396,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
199,
5483,
3238,
282,
1275,
318,
570,
365,
8860,
315,
314,
2142,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
646,
984,
199,
199,
692,
984,
14,
3246,
508,
283,
2676,
708,
356,
523,
511,
275,
25688,
14,
774,
13899,
8,
6321,
2968,
8338,
297,
283,
8675,
1105,
819,
6624,
3022,
275,
283,
20311,
13,
2469,
7,
819,
327,
14326,
1275,
318,
1584,
3181,
1133,
1852,
1263,
12249,
12,
1077,
2449,
737,
3550,
900,
14,
523,
511,
14,
1065,
63,
6179,
360,
318,
493,
13,
6048,
14,
6179,
297,
13097,
29,
30285,
12,
4635,
29,
403,
12,
2004,
29,
17,
9,
819,
511,
14,
1065,
63,
6179,
360,
318,
493,
14,
6179,
297,
13097,
29,
30285,
9,
523,
511,
14,
1506,
360,
318,
493,
14,
6179,
297,
511,
14,
1761,
12,
13097,
29,
30285,
9,
819,
347,
13481,
11399,
8,
3008,
12,
4843,
304,
272,
2615,
63,
515,
275,
511,
14,
11730,
63,
493,
63,
515,
8,
3008,
12,
13097,
29,
30285,
9,
272,
1072,
275,
511,
14,
1065,
63,
2724,
1393,
2336,
20775,
297,
2615,
63,
515,
9,
272,
372,
4843,
315,
1072,
819,
327,
4155,
3238,
781,
1454,
1172,
314,
4843,
1380,
314,
1275,
318,
570,
365,
315,
675,
14,
819,
340,
13481,
11399,
360,
396,
63,
318,
493,
63,
9259,
63,
889,
3858,
2315,
14,
9259,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
523,
340,
440,
13481,
11399,
360,
396,
63,
318,
493,
63,
9259,
63,
745,
14,
9259,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
819,
340,
13481,
11399,
360,
396,
63,
318,
493,
63,
5803,
63,
889,
3858,
2315,
14,
5803,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
523,
340,
440,
13481,
11399,
360,
396,
63,
318,
493,
63,
5803,
63,
745,
14,
5803,
297,
283,
2493,
920,
2315,
3481,
735,
272,
511,
14,
1633,
63,
396,
342,
819,
511,
14,
1529,
63,
396,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
aviciimaxwell/odoo
|
addons/purchase/edi/purchase_order.py
|
439
|
9703
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2011-2012 OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import osv
from openerp.tools.translate import _
from openerp.addons.edi import EDIMixin
PURCHASE_ORDER_LINE_EDI_STRUCT = {
'name': True,
'date_planned': True,
'product_id': True,
'product_uom': True,
'price_unit': True,
'product_qty': True,
# fields used for web preview only - discarded on import
'price_subtotal': True,
}
PURCHASE_ORDER_EDI_STRUCT = {
'company_id': True, # -> to be changed into partner
'name': True,
'partner_ref': True,
'origin': True,
'date_order': True,
'partner_id': True,
#custom: 'partner_address',
'notes': True,
'order_line': PURCHASE_ORDER_LINE_EDI_STRUCT,
#custom: currency_id
# fields used for web preview only - discarded on import
'amount_total': True,
'amount_untaxed': True,
'amount_tax': True,
'state':True,
}
class purchase_order(osv.osv, EDIMixin):
_inherit = 'purchase.order'
def edi_export(self, cr, uid, records, edi_struct=None, context=None):
"""Exports a purchase order"""
edi_struct = dict(edi_struct or PURCHASE_ORDER_EDI_STRUCT)
res_company = self.pool.get('res.company')
res_partner_obj = self.pool.get('res.partner')
edi_doc_list = []
for order in records:
# generate the main report
self._edi_generate_report_attachment(cr, uid, order, context=context)
# Get EDI doc based on struct. The result will also contain all metadata fields and attachments.
edi_doc = super(purchase_order,self).edi_export(cr, uid, [order], edi_struct, context)[0]
edi_doc.update({
# force trans-typing to purchase.order upon import
'__import_model': 'sale.order',
'__import_module': 'sale',
'company_address': res_company.edi_export_address(cr, uid, order.company_id, context=context),
'partner_address': res_partner_obj.edi_export(cr, uid, [order.partner_id], context=context)[0],
'currency': self.pool.get('res.currency').edi_export(cr, uid, [order.pricelist_id.currency_id],
context=context)[0],
})
if edi_doc.get('order_line'):
for line in edi_doc['order_line']:
line['__import_model'] = 'sale.order.line'
edi_doc_list.append(edi_doc)
return edi_doc_list
def edi_import_company(self, cr, uid, edi_document, context=None):
# TODO: for multi-company setups, we currently import the document in the
# user's current company, but we should perhaps foresee a way to select
# the desired company among the user's allowed companies
self._edi_requires_attributes(('company_id','company_address'), edi_document)
res_partner = self.pool.get('res.partner')
xid, company_name = edi_document.pop('company_id')
# Retrofit address info into a unified partner info (changed in v7 - used to keep them separate)
company_address_edi = edi_document.pop('company_address')
company_address_edi['name'] = company_name
company_address_edi['is_company'] = True
company_address_edi['__import_model'] = 'res.partner'
company_address_edi['__id'] = xid # override address ID, as of v7 they should be the same anyway
if company_address_edi.get('logo'):
company_address_edi['image'] = company_address_edi.pop('logo')
company_address_edi['supplier'] = True
partner_id = res_partner.edi_import(cr, uid, company_address_edi, context=context)
# modify edi_document to refer to new partner
partner = res_partner.browse(cr, uid, partner_id, context=context)
partner_edi_m2o = self.edi_m2o(cr, uid, partner, context=context)
edi_document['partner_id'] = partner_edi_m2o
edi_document.pop('partner_address', None) # ignored, that's supposed to be our own address!
return partner_id
def _edi_get_pricelist(self, cr, uid, partner_id, currency, context=None):
# TODO: refactor into common place for purchase/sale, e.g. into product module
partner_model = self.pool.get('res.partner')
partner = partner_model.browse(cr, uid, partner_id, context=context)
pricelist = partner.property_product_pricelist_purchase
if not pricelist:
pricelist = self.pool.get('ir.model.data').get_object(cr, uid, 'purchase', 'list0', context=context)
if not pricelist.currency_id == currency:
# look for a pricelist with the right type and currency, or make a new one
pricelist_type = 'purchase'
product_pricelist = self.pool.get('product.pricelist')
match_pricelist_ids = product_pricelist.search(cr, uid,[('type','=',pricelist_type),
('currency_id','=',currency.id)])
if match_pricelist_ids:
pricelist_id = match_pricelist_ids[0]
else:
pricelist_name = _('EDI Pricelist (%s)') % (currency.name,)
pricelist_id = product_pricelist.create(cr, uid, {'name': pricelist_name,
'type': pricelist_type,
'currency_id': currency.id,
})
self.pool.get('product.pricelist.version').create(cr, uid, {'name': pricelist_name,
'pricelist_id': pricelist_id})
pricelist = product_pricelist.browse(cr, uid, pricelist_id)
return self.edi_m2o(cr, uid, pricelist, context=context)
def _edi_get_location(self, cr, uid, partner_id, context=None):
partner_model = self.pool.get('res.partner')
partner = partner_model.browse(cr, uid, partner_id, context=context)
location = partner.property_stock_customer
if not location:
location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock', context=context)
return self.edi_m2o(cr, uid, location, context=context)
def edi_import(self, cr, uid, edi_document, context=None):
self._edi_requires_attributes(('company_id','company_address','order_line','date_order','currency'), edi_document)
#import company as a new partner
partner_id = self.edi_import_company(cr, uid, edi_document, context=context)
# currency for rounding the discount calculations and for the pricelist
res_currency = self.pool.get('res.currency')
currency_info = edi_document.pop('currency')
currency_id = res_currency.edi_import(cr, uid, currency_info, context=context)
order_currency = res_currency.browse(cr, uid, currency_id)
partner_ref = edi_document.pop('partner_ref', False)
edi_document['partner_ref'] = edi_document['name']
edi_document['name'] = partner_ref or edi_document['name']
edi_document['pricelist_id'] = self._edi_get_pricelist(cr, uid, partner_id, order_currency, context=context)
edi_document['location_id'] = self._edi_get_location(cr, uid, partner_id, context=context)
# discard web preview fields, if present
edi_document.pop('amount_total', None)
edi_document.pop('amount_tax', None)
edi_document.pop('amount_untaxed', None)
edi_document.pop('payment_term', None)
edi_document.pop('order_policy', None)
edi_document.pop('user_id', None)
for order_line in edi_document['order_line']:
self._edi_requires_attributes(('date_planned', 'product_id', 'product_uom', 'product_qty', 'price_unit'), order_line)
# original sale order contains unit price and discount, but not final line price
discount = order_line.pop('discount', 0.0)
if discount:
order_line['price_unit'] = res_currency.round(cr, uid, order_currency,
(order_line['price_unit'] * (1 - (discount or 0.0) / 100.0)))
# sale order lines have sequence numbers, not purchase order lines
order_line.pop('sequence', None)
# discard web preview fields, if present
order_line.pop('price_subtotal', None)
return super(purchase_order,self).edi_import(cr, uid, edi_document, context=context)
class purchase_order_line(osv.osv, EDIMixin):
_inherit='purchase.order.line'
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
23813,
24636,
199,
3,
259,
1898,
334,
67,
9,
7760,
13,
7409,
7653,
428,
14,
33,
14,
665,
1014,
921,
11267,
14,
957,
30,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
10788,
14,
6297,
492,
662,
19080,
3774,
199,
199,
48,
1230,
1244,
8162,
63,
12125,
63,
6174,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
602,
63,
20235,
356,
715,
12,
272,
283,
2558,
63,
344,
356,
715,
12,
272,
283,
2558,
63,
7519,
356,
715,
12,
272,
283,
4777,
63,
3248,
356,
715,
12,
272,
283,
2558,
63,
5643,
356,
715,
12,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
283,
4777,
63,
954,
2923,
356,
715,
12,
199,
93,
199,
199,
48,
1230,
1244,
8162,
63,
12125,
63,
7458,
63,
8893,
275,
469,
272,
283,
4627,
63,
344,
356,
715,
12,
327,
1035,
370,
506,
2896,
1901,
5854,
272,
283,
354,
356,
715,
12,
272,
283,
3899,
63,
1121,
356,
715,
12,
272,
283,
6493,
356,
715,
12,
272,
283,
602,
63,
1648,
356,
715,
12,
272,
283,
3899,
63,
344,
356,
715,
12,
272,
327,
4229,
26,
283,
3899,
63,
1562,
297,
272,
283,
5983,
356,
715,
12,
272,
283,
1648,
63,
604,
356,
3084,
1244,
8162,
63,
12125,
63,
6174,
63,
7458,
63,
8893,
12,
272,
327,
4229,
26,
9952,
63,
344,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
283,
4606,
63,
2923,
356,
715,
12,
272,
283,
4606,
63,
324,
5530,
379,
356,
715,
12,
272,
283,
4606,
63,
5530,
356,
715,
12,
272,
283,
929,
356,
549,
12,
199,
93,
199,
199,
533,
15932,
63,
1648,
8,
4795,
14,
4795,
12,
662,
19080,
3774,
304,
272,
485,
6486,
275,
283,
9533,
14,
1648,
7,
339,
347,
7860,
63,
3790,
8,
277,
12,
2467,
12,
1747,
12,
5767,
12,
7860,
63,
1820,
29,
403,
12,
1067,
29,
403,
304,
267,
408,
920,
5203,
282,
15932,
1865,
624,
267,
7860,
63,
1820,
275,
1211,
8,
6297,
63,
1820,
503,
3084,
1244,
8162,
63,
12125,
63,
7458,
63,
8893,
9,
267,
522,
63,
4627,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
4627,
358,
267,
522,
63,
3899,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3899,
358,
267,
7860,
63,
1301,
63,
513,
275,
942,
267,
367,
1865,
315,
5767,
26,
288,
327,
3550,
314,
2446,
3622,
288,
291,
423,
6297,
63,
4208,
63,
3070,
63,
8905,
8,
1556,
12,
1747,
12,
1865,
12,
1067,
29,
1100,
9,
953,
327,
2372,
662,
1914,
1382,
4079,
641,
2702,
14,
710,
754,
911,
2597,
1395,
1006,
3341,
1504,
436,
18912,
14,
288,
7860,
63,
1301,
275,
1613,
8,
9533,
63,
1648,
12,
277,
680,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
1648,
467,
7860,
63,
1820,
12,
1067,
2788,
16,
61,
288,
7860,
63,
1301,
14,
873,
2561,
490,
327,
3542,
1752,
13,
29747,
370,
15932,
14,
1648,
12188,
492,
490,
2560,
646,
63,
1238,
356,
283,
8515,
14,
1648,
297,
490,
2560,
646,
63,
578,
356,
283,
8515,
297,
4951,
283,
4627,
63,
1562,
356,
522,
63,
4627,
14,
6297,
63,
3790,
63,
1562,
8,
1556,
12,
1747,
12,
1865,
14,
4627,
63,
344,
12,
1067,
29,
1100,
395,
490,
283,
3899,
63,
1562,
356,
522,
63,
3899,
63,
1113,
14,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
1648,
14,
3899,
63,
344,
467,
1067,
29,
1100,
2788,
16,
467,
490,
283,
4968,
356,
291,
14,
2293,
14,
362,
360,
470,
14,
4968,
1959,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
1648,
14,
17385,
63,
344,
14,
4968,
63,
344,
467,
6684,
260,
1067,
29,
1100,
2788,
16,
467,
288,
3828,
288,
340,
7860,
63,
1301,
14,
362,
360,
1648,
63,
604,
735,
355,
367,
1004,
315,
7860,
63,
1301,
459,
1648,
63,
604,
2565,
490,
1004,
13742,
646,
63,
1238,
418,
275,
283,
8515,
14,
1648,
14,
604,
7,
288,
7860,
63,
1301,
63,
513,
14,
740,
8,
6297,
63,
1301,
9,
267,
372,
7860,
63,
1301,
63,
513,
339,
347,
7860,
63,
646,
63,
4627,
8,
277,
12,
2467,
12,
1747,
12,
7860,
63,
3554,
12,
1067,
29,
403,
304,
267,
327,
3254,
26,
367,
3510,
13,
4627,
3272,
83,
12,
781,
5544,
492,
314,
2213,
315,
314,
267,
327,
755,
922,
1159,
1453,
7233,
12,
1325,
781,
1077,
25358,
11257,
3239,
282,
4340,
370,
3504,
267,
327,
755,
314,
6387,
7233,
16885,
314,
922,
1159,
4370,
1013,
23461,
398,
291,
423,
6297,
63,
6537,
63,
2987,
4725,
4627,
63,
344,
1673,
4627,
63,
1562,
659,
7860,
63,
3554,
9,
267,
522,
63,
3899,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3899,
358,
398,
23382,
12,
7233,
63,
354,
275,
7860,
63,
3554,
14,
1935,
360,
4627,
63,
344,
358,
267,
327,
8747,
293,
3269,
2287,
2256,
1901,
282,
25344,
5854,
2256,
334,
2489,
315,
373,
23,
446
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
23813,
24636,
199,
3,
259,
1898,
334,
67,
9,
7760,
13,
7409,
7653,
428,
14,
33,
14,
665,
1014,
921,
11267,
14,
957,
30,
199,
3,
199,
3,
259,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
259,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
259,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
259,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
259,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
259,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
259,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
259,
1664,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
259,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
1696,
1684,
844,
199,
3,
259,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
4605,
199,
199,
504,
5166,
14,
4795,
492,
9506,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
14,
10788,
14,
6297,
492,
662,
19080,
3774,
199,
199,
48,
1230,
1244,
8162,
63,
12125,
63,
6174,
63,
7458,
63,
8893,
275,
469,
272,
283,
354,
356,
715,
12,
272,
283,
602,
63,
20235,
356,
715,
12,
272,
283,
2558,
63,
344,
356,
715,
12,
272,
283,
2558,
63,
7519,
356,
715,
12,
272,
283,
4777,
63,
3248,
356,
715,
12,
272,
283,
2558,
63,
5643,
356,
715,
12,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
283,
4777,
63,
954,
2923,
356,
715,
12,
199,
93,
199,
199,
48,
1230,
1244,
8162,
63,
12125,
63,
7458,
63,
8893,
275,
469,
272,
283,
4627,
63,
344,
356,
715,
12,
327,
1035,
370,
506,
2896,
1901,
5854,
272,
283,
354,
356,
715,
12,
272,
283,
3899,
63,
1121,
356,
715,
12,
272,
283,
6493,
356,
715,
12,
272,
283,
602,
63,
1648,
356,
715,
12,
272,
283,
3899,
63,
344,
356,
715,
12,
272,
327,
4229,
26,
283,
3899,
63,
1562,
297,
272,
283,
5983,
356,
715,
12,
272,
283,
1648,
63,
604,
356,
3084,
1244,
8162,
63,
12125,
63,
6174,
63,
7458,
63,
8893,
12,
272,
327,
4229,
26,
9952,
63,
344,
339,
327,
1504,
1202,
367,
3330,
19653,
1454,
446,
22002,
641,
492,
272,
283,
4606,
63,
2923,
356,
715,
12,
272,
283,
4606,
63,
324,
5530,
379,
356,
715,
12,
272,
283,
4606,
63,
5530,
356,
715,
12,
272,
283,
929,
356,
549,
12,
199,
93,
199,
199,
533,
15932,
63,
1648,
8,
4795,
14,
4795,
12,
662,
19080,
3774,
304,
272,
485,
6486,
275,
283,
9533,
14,
1648,
7,
339,
347,
7860,
63,
3790,
8,
277,
12,
2467,
12,
1747,
12,
5767,
12,
7860,
63,
1820,
29,
403,
12,
1067,
29,
403,
304,
267,
408,
920,
5203,
282,
15932,
1865,
624,
267,
7860,
63,
1820,
275,
1211,
8,
6297,
63,
1820,
503,
3084,
1244,
8162,
63,
12125,
63,
7458,
63,
8893,
9,
267,
522,
63,
4627,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
4627,
358,
267,
522,
63,
3899,
63,
1113,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3899,
358,
267,
7860,
63,
1301,
63,
513,
275,
942,
267,
367,
1865,
315,
5767,
26,
288,
327,
3550,
314,
2446,
3622,
288,
291,
423,
6297,
63,
4208,
63,
3070,
63,
8905,
8,
1556,
12,
1747,
12,
1865,
12,
1067,
29,
1100,
9,
953,
327,
2372,
662,
1914,
1382,
4079,
641,
2702,
14,
710,
754,
911,
2597,
1395,
1006,
3341,
1504,
436,
18912,
14,
288,
7860,
63,
1301,
275,
1613,
8,
9533,
63,
1648,
12,
277,
680,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
1648,
467,
7860,
63,
1820,
12,
1067,
2788,
16,
61,
288,
7860,
63,
1301,
14,
873,
2561,
490,
327,
3542,
1752,
13,
29747,
370,
15932,
14,
1648,
12188,
492,
490,
2560,
646,
63,
1238,
356,
283,
8515,
14,
1648,
297,
490,
2560,
646,
63,
578,
356,
283,
8515,
297,
4951,
283,
4627,
63,
1562,
356,
522,
63,
4627,
14,
6297,
63,
3790,
63,
1562,
8,
1556,
12,
1747,
12,
1865,
14,
4627,
63,
344,
12,
1067,
29,
1100,
395,
490,
283,
3899,
63,
1562,
356,
522,
63,
3899,
63,
1113,
14,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
1648,
14,
3899,
63,
344,
467,
1067,
29,
1100,
2788,
16,
467,
490,
283,
4968,
356,
291,
14,
2293,
14,
362,
360,
470,
14,
4968,
1959,
6297,
63,
3790,
8,
1556,
12,
1747,
12,
359,
1648,
14,
17385,
63,
344,
14,
4968,
63,
344,
467,
6684,
260,
1067,
29,
1100,
2788,
16,
467,
288,
3828,
288,
340,
7860,
63,
1301,
14,
362,
360,
1648,
63,
604,
735,
355,
367,
1004,
315,
7860,
63,
1301,
459,
1648,
63,
604,
2565,
490,
1004,
13742,
646,
63,
1238,
418,
275,
283,
8515,
14,
1648,
14,
604,
7,
288,
7860,
63,
1301,
63,
513,
14,
740,
8,
6297,
63,
1301,
9,
267,
372,
7860,
63,
1301,
63,
513,
339,
347,
7860,
63,
646,
63,
4627,
8,
277,
12,
2467,
12,
1747,
12,
7860,
63,
3554,
12,
1067,
29,
403,
304,
267,
327,
3254,
26,
367,
3510,
13,
4627,
3272,
83,
12,
781,
5544,
492,
314,
2213,
315,
314,
267,
327,
755,
922,
1159,
1453,
7233,
12,
1325,
781,
1077,
25358,
11257,
3239,
282,
4340,
370,
3504,
267,
327,
755,
314,
6387,
7233,
16885,
314,
922,
1159,
4370,
1013,
23461,
398,
291,
423,
6297,
63,
6537,
63,
2987,
4725,
4627,
63,
344,
1673,
4627,
63,
1562,
659,
7860,
63,
3554,
9,
267,
522,
63,
3899,
275,
291,
14,
2293,
14,
362,
360,
470,
14,
3899,
358,
398,
23382,
12,
7233,
63,
354,
275,
7860,
63,
3554,
14,
1935,
360,
4627,
63,
344,
358,
267,
327,
8747,
293,
3269,
2287,
2256,
1901,
282,
25344,
5854,
2256,
334,
2489,
315,
373,
23,
446,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
lfblogs/aio2py
|
aio2py/db/field.py
|
2
|
1321
|
# -*- coding: UTF-8 -*-
__author__ = "Liu Fei"
__github__ = "http://github.com/lfblogs"
__all__ = [
"Field",
"StringField",
"BooleanField",
"IntegerField",
"FloatField",
"TextField",
]
"""
Define field
"""
class Field(object):
def __init__(self, name, column_type, primary_key, default):
self.name = name
self.column_type = column_type
self.primary_key = primary_key
self.default = default
def __str__(self):
return '<{},{}:{}>'.format(self.__class__.__name__, self.column_type, self.name)
class StringField(Field):
def __init__(self, name=None, primary_key=False, default=None, ddl='varchar(100)'):
super().__init__(name, ddl, primary_key, default)
class BooleanField(Field):
def __init__(self, name=None, default=False):
super().__init__(name, 'boolean', False, default)
class IntegerField(Field):
def __init__(self, name=None, primary_key=False, default=0):
super().__init__(name, 'bigint', primary_key, default)
class FloatField(Field):
def __init__(self, name=None, primary_key=False, default=0):
super().__init__(name, 'real', primary_key, default)
class TextField(Field):
def __init__(self, name=None, default=None):
super().__init__(name, 'text', False, default)
|
apache-2.0
|
[
3,
1882,
2803,
26,
9094,
13,
24,
1882,
199,
199,
363,
2502,
363,
275,
298,
13009,
85,
7949,
73,
2,
199,
363,
5031,
363,
275,
298,
1014,
921,
5031,
14,
957,
15,
276,
66,
7270,
2,
199,
363,
452,
363,
275,
359,
272,
298,
792,
401,
272,
298,
14912,
401,
272,
298,
5036,
401,
272,
298,
3901,
401,
272,
298,
13019,
401,
272,
298,
6254,
401,
199,
199,
61,
199,
199,
624,
199,
199,
16213,
901,
199,
199,
624,
421,
199,
533,
5024,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
536,
12,
2763,
63,
466,
12,
5062,
63,
498,
12,
849,
304,
267,
291,
14,
354,
275,
536,
267,
291,
14,
2301,
63,
466,
275,
2763,
63,
466,
267,
291,
14,
3327,
63,
498,
275,
5062,
63,
498,
267,
291,
14,
885,
275,
849,
339,
347,
636,
495,
721,
277,
304,
267,
372,
2650,
27125,
2440,
29930,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
2301,
63,
466,
12,
291,
14,
354,
9,
199,
199,
533,
21409,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
5062,
63,
498,
29,
797,
12,
849,
29,
403,
12,
366,
5030,
534,
25545,
8,
1960,
9,
735,
267,
1613,
11027,
826,
721,
354,
12,
366,
5030,
12,
5062,
63,
498,
12,
849,
9,
199,
199,
533,
9411,
792,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
849,
29,
797,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
4871,
297,
756,
12,
849,
9,
199,
199,
533,
26141,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
5062,
63,
498,
29,
797,
12,
849,
29,
16,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
24884,
297,
5062,
63,
498,
12,
849,
9,
199,
199,
533,
11140,
792,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
5062,
63,
498,
29,
797,
12,
849,
29,
16,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
3093,
297,
5062,
63,
498,
12,
849,
9,
199,
199,
533,
4516,
792,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
849,
29,
403,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
505,
297,
756,
12,
849,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
9094,
13,
24,
1882,
199,
199,
363,
2502,
363,
275,
298,
13009,
85,
7949,
73,
2,
199,
363,
5031,
363,
275,
298,
1014,
921,
5031,
14,
957,
15,
276,
66,
7270,
2,
199,
363,
452,
363,
275,
359,
272,
298,
792,
401,
272,
298,
14912,
401,
272,
298,
5036,
401,
272,
298,
3901,
401,
272,
298,
13019,
401,
272,
298,
6254,
401,
199,
199,
61,
199,
199,
624,
199,
199,
16213,
901,
199,
199,
624,
421,
199,
533,
5024,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
536,
12,
2763,
63,
466,
12,
5062,
63,
498,
12,
849,
304,
267,
291,
14,
354,
275,
536,
267,
291,
14,
2301,
63,
466,
275,
2763,
63,
466,
267,
291,
14,
3327,
63,
498,
275,
5062,
63,
498,
267,
291,
14,
885,
275,
849,
339,
347,
636,
495,
721,
277,
304,
267,
372,
2650,
27125,
2440,
29930,
22936,
908,
8,
277,
855,
533,
4914,
354,
3108,
291,
14,
2301,
63,
466,
12,
291,
14,
354,
9,
199,
199,
533,
21409,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
5062,
63,
498,
29,
797,
12,
849,
29,
403,
12,
366,
5030,
534,
25545,
8,
1960,
9,
735,
267,
1613,
11027,
826,
721,
354,
12,
366,
5030,
12,
5062,
63,
498,
12,
849,
9,
199,
199,
533,
9411,
792,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
849,
29,
797,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
4871,
297,
756,
12,
849,
9,
199,
199,
533,
26141,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
5062,
63,
498,
29,
797,
12,
849,
29,
16,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
24884,
297,
5062,
63,
498,
12,
849,
9,
199,
199,
533,
11140,
792,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
5062,
63,
498,
29,
797,
12,
849,
29,
16,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
3093,
297,
5062,
63,
498,
12,
849,
9,
199,
199,
533,
4516,
792,
8,
792,
304,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
849,
29,
403,
304,
267,
1613,
11027,
826,
721,
354,
12,
283,
505,
297,
756,
12,
849,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
idrogeno/FusionOE
|
lib/python/Screens/LocationBox.py
|
23
|
15370
|
#
# Generic Screen to select a path/filename combination
#
# GUI (Screens)
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Screens.InputBox import InputBox
from Screens.HelpMenu import HelpableScreen
from Screens.ChoiceBox import ChoiceBox
# Generic
from Tools.BoundFunction import boundFunction
from Tools.Directories import pathExists, createDir, removeDir
from Components.config import config
import os
# Quickselect
from Tools.NumericalTextInput import NumericalTextInput
# GUI (Components)
from Components.ActionMap import NumberActionMap, HelpableActionMap
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.Button import Button
from Components.FileList import FileList
from Components.MenuList import MenuList
# Timer
from enigma import eTimer
defaultInhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"]
class LocationBox(Screen, NumericalTextInput, HelpableScreen):
"""Simple Class similar to MessageBox / ChoiceBox but used to choose a folder/pathname combination"""
def __init__(self, session, text="", filename="", currDir=None, bookmarks=None, userMode=False, windowTitle=_("Select location"), minFree=None, autoAdd=False, editDir=False, inhibitDirs=None, inhibitMounts=None):
# Init parents
if not inhibitDirs: inhibitDirs = []
if not inhibitMounts: inhibitMounts = []
Screen.__init__(self, session)
NumericalTextInput.__init__(self, handleTimeout = False)
HelpableScreen.__init__(self)
# Set useable chars
self.setUseableChars(u'1234567890abcdefghijklmnopqrstuvwxyz')
# Quickselect Timer
self.qs_timer = eTimer()
self.qs_timer.callback.append(self.timeout)
self.qs_timer_type = 0
# Initialize Quickselect
self.curr_pos = -1
self.quickselect = ""
# Set Text
self["text"] = Label(text)
self["textbook"] = Label(_("Bookmarks"))
# Save parameters locally
self.text = text
self.filename = filename
self.minFree = minFree
self.realBookmarks = bookmarks
self.bookmarks = bookmarks and bookmarks.value[:] or []
self.userMode = userMode
self.autoAdd = autoAdd
self.editDir = editDir
self.inhibitDirs = inhibitDirs
# Initialize FileList
self["filelist"] = FileList(currDir, showDirectories = True, showFiles = False, inhibitMounts = inhibitMounts, inhibitDirs = inhibitDirs)
# Initialize BookList
self["booklist"] = MenuList(self.bookmarks)
# Buttons
self["key_green"] = Button(_("OK"))
self["key_yellow"] = Button(_("Rename"))
self["key_blue"] = Button(_("Remove bookmark"))
self["key_red"] = Button(_("Cancel"))
# Background for Buttons
self["green"] = Pixmap()
self["yellow"] = Pixmap()
self["blue"] = Pixmap()
self["red"] = Pixmap()
# Initialize Target
self["target"] = Label()
self["targetfreespace"] = Label()
if self.userMode:
self.usermodeOn()
# Custom Action Handler
class LocationBoxActionMap(HelpableActionMap):
def __init__(self, parent, context, actions=None, prio=0):
if not actions: actions = {}
HelpableActionMap.__init__(self, parent, context, actions, prio)
self.box = parent
def action(self, contexts, action):
# Reset Quickselect
self.box.timeout(force = True)
return HelpableActionMap.action(self, contexts, action)
# Actions that will reset quickselect
self["WizardActions"] = LocationBoxActionMap(self, "WizardActions",
{
"ok": (self.ok, _("select")),
"back": (self.cancel, _("Cancel")),
}, -2)
self["DirectionActions"] = LocationBoxActionMap(self, "DirectionActions",
{
"left": self.left,
"right": self.right,
"up": self.up,
"down": self.down,
}, -2)
self["ColorActions"] = LocationBoxActionMap(self, "ColorActions",
{
"red": self.cancel,
"green": self.select,
"yellow": self.changeName,
"blue": self.addRemoveBookmark,
}, -2)
self["EPGSelectActions"] = LocationBoxActionMap(self, "EPGSelectActions",
{
"prevService": (self.switchToBookList, _("switch to bookmarks")),
"nextService": (self.switchToFileList, _("switch to filelist")),
}, -2)
self["MenuActions"] = LocationBoxActionMap(self, "MenuActions",
{
"menu": (self.showMenu, _("menu")),
}, -2)
# Actions used by quickselect
self["NumberActions"] = NumberActionMap(["NumberActions"],
{
"1": self.keyNumberGlobal,
"2": self.keyNumberGlobal,
"3": self.keyNumberGlobal,
"4": self.keyNumberGlobal,
"5": self.keyNumberGlobal,
"6": self.keyNumberGlobal,
"7": self.keyNumberGlobal,
"8": self.keyNumberGlobal,
"9": self.keyNumberGlobal,
"0": self.keyNumberGlobal
})
# Run some functions when shown
self.onShown.extend((
boundFunction(self.setTitle, _("Select Location")),
self.updateTarget,
self.showHideRename,
))
self.onLayoutFinish.append(self.switchToFileListOnStart)
# Make sure we remove our callback
self.onClose.append(self.disableTimer)
def switchToFileListOnStart(self):
self.switchToFileList()
def disableTimer(self):
self.qs_timer.callback.remove(self.timeout)
def showHideRename(self):
# Don't allow renaming when filename is empty
if self.filename == "":
self["key_yellow"].hide()
def switchToFileList(self):
if not self.userMode:
self.currList = "filelist"
self["filelist"].selectionEnabled(1)
self["booklist"].selectionEnabled(0)
self["key_blue"].text = _("Add bookmark")
self.updateTarget()
def switchToBookList(self):
self.currList = "booklist"
self["filelist"].selectionEnabled(0)
self["booklist"].selectionEnabled(1)
self["key_blue"].text = _("Remove bookmark")
self.updateTarget()
def addRemoveBookmark(self):
if self.currList == "filelist":
# add bookmark
folder = self["filelist"].getSelection()[0]
if folder is not None and not folder in self.bookmarks:
self.bookmarks.append(folder)
self.bookmarks.sort()
self["booklist"].setList(self.bookmarks)
else:
# remove bookmark
if not self.userMode:
name = self["booklist"].getCurrent()
self.session.openWithCallback(
boundFunction(self.removeBookmark, name),
MessageBox,
_("Do you really want to remove your bookmark of %s?") % name,
)
def removeBookmark(self, name, ret):
if not ret:
return
if name in self.bookmarks:
self.bookmarks.remove(name)
self["booklist"].setList(self.bookmarks)
def createDir(self):
if self["filelist"].current_directory is not None:
self.session.openWithCallback(
self.createDirCallback,
InputBox,
title = _("Please enter name of the new directory"),
text = ""
)
def createDirCallback(self, res):
if res:
path = os.path.join(self["filelist"].current_directory, res)
if not pathExists(path):
if not createDir(path):
self.session.open(
MessageBox,
_("Creating directory %s failed.") % path,
type = MessageBox.TYPE_ERROR,
timeout = 5
)
self["filelist"].refresh()
else:
self.session.open(
MessageBox,
_("The path %s already exists.") % path,
type = MessageBox.TYPE_ERROR,
timeout = 5
)
def removeDir(self):
sel = self["filelist"].getSelection()
if sel and pathExists(sel[0]):
self.session.openWithCallback(
boundFunction(self.removeDirCallback, sel[0]),
MessageBox,
_("Do you really want to remove directory %s from the disk?") % (sel[0]),
type = MessageBox.TYPE_YESNO
)
else:
self.session.open(
MessageBox,
_("Invalid directory selected: %s") % (sel[0]),
type = MessageBox.TYPE_ERROR,
timeout = 5
)
def removeDirCallback(self, name, res):
if res:
if not removeDir(name):
self.session.open(
MessageBox,
_("Removing directory %s failed. (Maybe not empty.)") % name,
type = MessageBox.TYPE_ERROR,
timeout = 5
)
else:
self["filelist"].refresh()
self.removeBookmark(name, True)
val = self.realBookmarks and self.realBookmarks.value
if val and name in val:
val.remove(name)
self.realBookmarks.value = val
self.realBookmarks.save()
def up(self):
self[self.currList].up()
self.updateTarget()
def down(self):
self[self.currList].down()
self.updateTarget()
def left(self):
self[self.currList].pageUp()
self.updateTarget()
def right(self):
self[self.currList].pageDown()
self.updateTarget()
def ok(self):
if self.currList == "filelist":
if self["filelist"].canDescent():
self["filelist"].descent()
self.updateTarget()
else:
self.select()
def cancel(self):
self.close(None)
def getPreferredFolder(self):
if self.currList == "filelist":
# XXX: We might want to change this for parent folder...
return self["filelist"].getSelection()[0]
else:
return self["booklist"].getCurrent()
def selectConfirmed(self, ret):
if ret:
ret = ''.join((self.getPreferredFolder(), self.filename))
if self.realBookmarks:
if self.autoAdd and not ret in self.bookmarks:
self.bookmarks.append(self.getPreferredFolder())
self.bookmarks.sort()
if self.bookmarks != self.realBookmarks.value:
self.realBookmarks.value = self.bookmarks
self.realBookmarks.save()
self.close(ret)
def select(self):
currentFolder = self.getPreferredFolder()
# Do nothing unless current Directory is valid
if currentFolder is not None:
# Check if we need to have a minimum of free Space available
if self.minFree is not None:
# Try to read fs stats
try:
s = os.statvfs(currentFolder)
if (s.f_bavail * s.f_bsize) / 1000000 > self.minFree:
# Automatically confirm if we have enough free disk Space available
return self.selectConfirmed(True)
except OSError:
pass
# Ask User if he really wants to select this folder
self.session.openWithCallback(
self.selectConfirmed,
MessageBox,
_("There might not be enough space on the selected partition..\nDo you really want to continue?"),
type = MessageBox.TYPE_YESNO
)
# No minimum free Space means we can safely close
else:
self.selectConfirmed(True)
def changeName(self):
if self.filename != "":
# TODO: Add Information that changing extension is bad? disallow?
self.session.openWithCallback(
self.nameChanged,
InputBox,
title = _("Please enter a new filename"),
text = self.filename
)
def nameChanged(self, res):
if res is not None:
if len(res):
self.filename = res
self.updateTarget()
else:
self.session.open(
MessageBox,
_("An empty filename is illegal."),
type = MessageBox.TYPE_ERROR,
timeout = 5
)
def updateTarget(self):
# Write Combination of Folder & Filename when Folder is valid
currFolder = self.getPreferredFolder()
if currFolder is not None:
free = ""
try:
stat = os.statvfs(currFolder)
free = ("%0.f GB " + _("free")) % (float(stat.f_bavail) * stat.f_bsize / 1024 / 1024 /1024)
except:
pass
self["targetfreespace"].setText(free)
self["target"].setText(''.join((currFolder, self.filename)))
# Display a Warning otherwise
else:
self["target"].setText(_("Invalid location"))
def showMenu(self):
if not self.userMode and self.realBookmarks:
if self.currList == "filelist":
menu = [
(_("switch to bookmarks"), self.switchToBookList),
(_("add bookmark"), self.addRemoveBookmark)
]
if self.editDir:
menu.extend((
(_("create directory"), self.createDir),
(_("remove directory"), self.removeDir)
))
else:
menu = (
(_("switch to filelist"), self.switchToFileList),
(_("remove bookmark"), self.addRemoveBookmark)
)
self.session.openWithCallback(
self.menuCallback,
ChoiceBox,
title = "",
list = menu
)
def menuCallback(self, choice):
if choice:
choice[1]()
def usermodeOn(self):
self.switchToBookList()
self["filelist"].hide()
self["key_blue"].hide()
def keyNumberGlobal(self, number):
# Cancel Timeout
self.qs_timer.stop()
# See if another key was pressed before
if number != self.lastKey:
# Reset lastKey again so NumericalTextInput triggers its keychange
self.nextKey()
# Try to select what was typed
self.selectByStart()
# Increment position
self.curr_pos += 1
# Get char and append to text
char = self.getKey(number)
self.quickselect = self.quickselect[:self.curr_pos] + unicode(char)
# Start Timeout
self.qs_timer_type = 0
self.qs_timer.start(1000, 1)
def selectByStart(self):
# Don't do anything on initial call
if not self.quickselect:
return
# Don't select if no dir
if self["filelist"].getCurrentDirectory():
# TODO: implement proper method in Components.FileList
files = self["filelist"].getFileList()
# Initialize index
idx = 0
# We select by filename which is absolute
lookfor = self["filelist"].getCurrentDirectory() + self.quickselect
# Select file starting with generated text
for file in files:
if file[0][0] and file[0][0].lower().startswith(lookfor):
self["filelist"].instance.moveSelectionTo(idx)
break
idx += 1
def timeout(self, force = False):
# Timeout Key
if not force and self.qs_timer_type == 0:
# Try to select what was typed
self.selectByStart()
# Reset Key
self.lastKey = -1
# Change type
self.qs_timer_type = 1
# Start timeout again
self.qs_timer.start(1000, 1)
# Timeout Quickselect
else:
# Eventually stop Timer
self.qs_timer.stop()
# Invalidate
self.lastKey = -1
self.curr_pos = -1
self.quickselect = ""
def __repr__(self):
return str(type(self)) + "(" + self.text + ")"
def MovieLocationBox(session, text, dir, minFree = None):
return LocationBox(session, text = text, currDir = dir, bookmarks = config.movielist.videodirs, autoAdd = True, editDir = True, inhibitDirs = defaultInhibitDirs, minFree = minFree)
class TimeshiftLocationBox(LocationBox):
def __init__(self, session):
LocationBox.__init__(
self,
session,
text = _("Where to save temporary timeshift recordings?"),
currDir = config.usage.timeshift_path.value,
bookmarks = config.usage.allowed_timeshift_paths,
autoAdd = True,
editDir = True,
inhibitDirs = defaultInhibitDirs,
minFree = 1024 # the same requirement is hardcoded in servicedvb.cpp
)
self.skinName = "LocationBox"
def cancel(self):
config.usage.timeshift_path.cancel()
LocationBox.cancel(self)
def selectConfirmed(self, ret):
if ret:
config.usage.timeshift_path.value = self.getPreferredFolder()
config.usage.timeshift_path.save()
LocationBox.selectConfirmed(self, ret)
class AutorecordLocationBox(LocationBox):
def __init__(self, session):
LocationBox.__init__(
self,
session,
text = _("Where to save temporary timeshift recordings?"),
currDir = config.usage.autorecord_path.value,
bookmarks = config.usage.allowed_autorecord_paths,
autoAdd = True,
editDir = True,
inhibitDirs = defaultInhibitDirs,
minFree = 1024 # the same requirement is hardcoded in servicedvb.cpp
)
self.skinName = "LocationBox"
def cancel(self):
config.usage.autorecord_path.cancel()
LocationBox.cancel(self)
def selectConfirmed(self, ret):
if ret:
config.usage.autorecord_path.setValue(self.getPreferredFolder())
config.usage.autorecord_path.save()
LocationBox.selectConfirmed(self, ret)
|
gpl-2.0
|
[
3,
199,
3,
8307,
17804,
370,
3504,
282,
931,
15,
1501,
14665,
199,
3,
199,
199,
3,
17160,
334,
9616,
83,
9,
199,
504,
29372,
14,
9616,
492,
17804,
199,
504,
29372,
14,
13695,
492,
28923,
199,
504,
29372,
14,
3205,
3532,
492,
6924,
3532,
199,
504,
29372,
14,
8673,
5977,
492,
15456,
461,
9616,
199,
504,
29372,
14,
9054,
3532,
492,
16053,
3532,
199,
199,
3,
8307,
199,
504,
23228,
14,
8934,
3481,
492,
3914,
3481,
199,
504,
23228,
14,
13752,
492,
931,
7965,
12,
1218,
3567,
12,
2813,
3567,
199,
504,
17823,
14,
888,
492,
1101,
199,
646,
747,
199,
199,
3,
27534,
2416,
199,
504,
23228,
14,
46,
27685,
18362,
492,
653,
27685,
18362,
199,
199,
3,
17160,
334,
22714,
9,
199,
504,
17823,
14,
3310,
2956,
492,
4860,
3310,
2956,
12,
15456,
461,
3310,
2956,
199,
504,
17823,
14,
4314,
492,
10354,
199,
504,
17823,
14,
16049,
492,
510,
12879,
199,
504,
17823,
14,
4259,
492,
16005,
199,
504,
17823,
14,
1173,
1296,
492,
3814,
1296,
199,
504,
17823,
14,
5977,
1296,
492,
18281,
1296,
199,
199,
3,
22287,
199,
504,
655,
27021,
492,
325,
7929,
199,
199,
885,
607,
20215,
390,
17051,
275,
2097,
15,
1393,
401,
3286,
4930,
401,
3286,
2374,
401,
3286,
6839,
401,
3286,
773,
401,
3286,
4687,
401,
3286,
21457,
401,
3286,
1274,
401,
3286,
2647,
401,
3286,
1391,
937,
199,
199,
533,
12625,
3532,
8,
9616,
12,
653,
27685,
18362,
12,
15456,
461,
9616,
304,
199,
198,
624,
3184,
8089,
8545,
370,
28923,
1182,
16053,
3532,
1325,
1202,
370,
11496,
282,
4922,
15,
12445,
14665,
624,
199,
198,
318,
636,
826,
721,
277,
12,
2351,
12,
1318,
8772,
1788,
8772,
8230,
3567,
29,
403,
12,
32410,
29,
403,
12,
922,
1385,
29,
797,
12,
4353,
6888,
9384,
5446,
2909,
1288,
1748,
10146,
29,
403,
12,
2599,
1123,
29,
797,
12,
5283,
3567,
29,
797,
12,
315,
20215,
390,
17051,
29,
403,
12,
315,
20215,
390,
24467,
83,
29,
403,
304,
507,
198,
3,
21026,
8623,
507,
198,
692,
440,
315,
20215,
390,
17051,
26,
315,
20215,
390,
17051,
275,
942,
507,
198,
692,
440,
315,
20215,
390,
24467,
83,
26,
315,
20215,
390,
24467,
83,
275,
942,
507,
198,
9616,
855,
826,
721,
277,
12,
2351,
9,
507,
198,
46,
27685,
18362,
855,
826,
721,
277,
12,
2429,
6372,
275,
756,
9,
507,
198,
8673,
461,
9616,
855,
826,
721,
277,
9,
2742,
198,
3,
2494,
675,
461,
8365,
507,
198,
277,
14,
409,
6119,
461,
11229,
8,
85,
7,
21515,
23459,
358,
2742,
198,
3,
27534,
2416,
22287,
507,
198,
277,
14,
6177,
63,
7414,
275,
325,
7929,
342,
507,
198,
277,
14,
6177,
63,
7414,
14,
3058,
14,
740,
8,
277,
14,
2593,
9,
507,
198,
277,
14,
6177,
63,
7414,
63,
466,
275,
378,
2742,
198,
3,
11578,
27534,
2416,
507,
198,
277,
14,
9808,
63,
1712,
275,
446,
17,
507,
198,
277,
14,
13239,
2416,
275,
3087,
2742,
198,
3,
2494,
4516,
507,
198,
277,
905,
505,
937,
275,
10354,
8,
505,
9,
507,
198,
277,
905,
505,
2706,
937,
275,
10354,
6115,
8696,
10375,
2237,
2742,
198,
3,
11063,
2633,
17738,
507,
198,
277,
14,
505,
275,
1318,
507,
198,
277,
14,
1501,
275,
1788,
507,
198,
277,
14,
827,
10146,
275,
1748,
10146,
507,
198,
277,
14,
3093,
8696,
10375,
275,
32410,
507,
198,
277,
14,
25799,
275,
32410,
436,
32410,
14,
585,
5873,
503,
942,
507,
198,
277,
14,
751,
1385,
275,
922,
1385,
507,
198,
277,
14,
2495,
1123,
275,
2599,
1123,
507,
198,
277,
14,
3773,
3567,
275,
5283,
3567,
507,
198,
277,
14,
17695,
1892,
390,
17051,
275,
315,
20215,
390,
17051,
2742,
198,
3,
11578,
3814,
1296,
507,
198,
277,
905,
14964,
937,
275,
3814,
1296,
8,
9808,
3567,
12,
2498,
13752,
275,
715,
12,
2498,
5535,
275,
756,
12,
315,
20215,
390,
24467,
83,
275,
315,
20215,
390,
24467,
83,
12,
315,
20215,
390,
17051,
275,
315,
20215,
390,
17051,
9,
2742,
198,
3,
11578,
8944,
1296,
507,
198,
277,
905,
2706,
513,
937,
275,
18281,
1296,
8,
277,
14,
25799,
9,
2742,
198,
3,
16005,
83,
507,
198,
277,
905,
498,
63,
7731,
937,
275,
16005,
6115,
3593,
2237,
507,
198,
277,
905,
498,
63,
14514,
937,
275,
16005,
6115,
16843,
2237,
507,
198,
277,
905,
498,
63,
6304,
937,
275,
16005,
6115,
5587,
23799,
2237,
507,
198,
277,
905,
498,
63,
581,
937,
275,
16005,
6115,
9083,
2237,
2742,
198,
3,
10257,
3928,
367,
16005,
83,
507,
198,
277,
905,
7731,
937,
275,
510,
12879,
342,
507,
198,
277,
905,
14514,
937,
275,
510,
12879,
342,
507,
198,
277,
905,
6304,
937,
275,
510,
12879,
342,
507,
198,
277,
905,
581,
937,
275,
510,
12879,
342,
2742,
198,
3,
11578,
10256,
507,
198,
277,
905,
1375,
937,
275,
10354,
342,
507,
198,
277,
905,
1375,
70,
5710,
1142,
937,
275,
10354,
342,
2742,
198,
692,
291,
14,
751,
1385,
26,
686,
198,
277,
14,
751,
632,
3314,
342,
2742,
198,
3,
8388,
10033,
18599,
507,
198,
533,
12625,
3532,
3310,
2956,
8,
8673,
461,
3310,
2956,
304,
686,
198,
318,
636,
826,
721,
277,
12,
1676,
12,
1067,
12,
5445,
29,
403,
12,
20449,
29,
16,
304,
1585,
198,
692,
440,
5445,
26,
5445,
275,
1052,
1585,
198,
8673,
461,
3310,
2956,
855,
826,
721,
277,
12,
1676,
12,
1067,
12,
5445,
12,
20449,
9,
1585,
198,
277,
14,
1977,
275,
1676,
6319,
198,
318,
1595,
8,
277,
12,
18191,
12,
1595,
304,
1585,
198,
3,
15510,
27534,
2416,
1585,
198,
277,
14,
1977,
14,
2593,
8,
3990,
275,
715,
9,
16737,
198,
1107,
15456,
461,
3310,
2956,
14,
1287,
8,
277,
12,
18191,
12,
1595,
9,
2742,
198,
3,
24367,
626,
911,
5305,
12530,
2416,
507,
198,
277,
905,
20120,
9303,
937,
275,
12625,
3532,
3310,
2956,
8,
277,
12,
298,
20120,
9303,
401,
686,
198,
91,
1585,
198,
2,
745,
582,
334,
277,
14,
745,
12,
3824,
2416,
8150,
1585,
198,
2,
894,
582,
334,
277,
14,
6406,
12,
3824,
9083,
8150,
686,
198,
1386,
446,
18,
9,
2742,
198,
277,
905,
17015,
9303,
937,
275,
12625,
3532
] |
[
199,
3,
8307,
17804,
370,
3504,
282,
931,
15,
1501,
14665,
199,
3,
199,
199,
3,
17160,
334,
9616,
83,
9,
199,
504,
29372,
14,
9616,
492,
17804,
199,
504,
29372,
14,
13695,
492,
28923,
199,
504,
29372,
14,
3205,
3532,
492,
6924,
3532,
199,
504,
29372,
14,
8673,
5977,
492,
15456,
461,
9616,
199,
504,
29372,
14,
9054,
3532,
492,
16053,
3532,
199,
199,
3,
8307,
199,
504,
23228,
14,
8934,
3481,
492,
3914,
3481,
199,
504,
23228,
14,
13752,
492,
931,
7965,
12,
1218,
3567,
12,
2813,
3567,
199,
504,
17823,
14,
888,
492,
1101,
199,
646,
747,
199,
199,
3,
27534,
2416,
199,
504,
23228,
14,
46,
27685,
18362,
492,
653,
27685,
18362,
199,
199,
3,
17160,
334,
22714,
9,
199,
504,
17823,
14,
3310,
2956,
492,
4860,
3310,
2956,
12,
15456,
461,
3310,
2956,
199,
504,
17823,
14,
4314,
492,
10354,
199,
504,
17823,
14,
16049,
492,
510,
12879,
199,
504,
17823,
14,
4259,
492,
16005,
199,
504,
17823,
14,
1173,
1296,
492,
3814,
1296,
199,
504,
17823,
14,
5977,
1296,
492,
18281,
1296,
199,
199,
3,
22287,
199,
504,
655,
27021,
492,
325,
7929,
199,
199,
885,
607,
20215,
390,
17051,
275,
2097,
15,
1393,
401,
3286,
4930,
401,
3286,
2374,
401,
3286,
6839,
401,
3286,
773,
401,
3286,
4687,
401,
3286,
21457,
401,
3286,
1274,
401,
3286,
2647,
401,
3286,
1391,
937,
199,
199,
533,
12625,
3532,
8,
9616,
12,
653,
27685,
18362,
12,
15456,
461,
9616,
304,
199,
198,
624,
3184,
8089,
8545,
370,
28923,
1182,
16053,
3532,
1325,
1202,
370,
11496,
282,
4922,
15,
12445,
14665,
624,
199,
198,
318,
636,
826,
721,
277,
12,
2351,
12,
1318,
8772,
1788,
8772,
8230,
3567,
29,
403,
12,
32410,
29,
403,
12,
922,
1385,
29,
797,
12,
4353,
6888,
9384,
5446,
2909,
1288,
1748,
10146,
29,
403,
12,
2599,
1123,
29,
797,
12,
5283,
3567,
29,
797,
12,
315,
20215,
390,
17051,
29,
403,
12,
315,
20215,
390,
24467,
83,
29,
403,
304,
507,
198,
3,
21026,
8623,
507,
198,
692,
440,
315,
20215,
390,
17051,
26,
315,
20215,
390,
17051,
275,
942,
507,
198,
692,
440,
315,
20215,
390,
24467,
83,
26,
315,
20215,
390,
24467,
83,
275,
942,
507,
198,
9616,
855,
826,
721,
277,
12,
2351,
9,
507,
198,
46,
27685,
18362,
855,
826,
721,
277,
12,
2429,
6372,
275,
756,
9,
507,
198,
8673,
461,
9616,
855,
826,
721,
277,
9,
2742,
198,
3,
2494,
675,
461,
8365,
507,
198,
277,
14,
409,
6119,
461,
11229,
8,
85,
7,
21515,
23459,
358,
2742,
198,
3,
27534,
2416,
22287,
507,
198,
277,
14,
6177,
63,
7414,
275,
325,
7929,
342,
507,
198,
277,
14,
6177,
63,
7414,
14,
3058,
14,
740,
8,
277,
14,
2593,
9,
507,
198,
277,
14,
6177,
63,
7414,
63,
466,
275,
378,
2742,
198,
3,
11578,
27534,
2416,
507,
198,
277,
14,
9808,
63,
1712,
275,
446,
17,
507,
198,
277,
14,
13239,
2416,
275,
3087,
2742,
198,
3,
2494,
4516,
507,
198,
277,
905,
505,
937,
275,
10354,
8,
505,
9,
507,
198,
277,
905,
505,
2706,
937,
275,
10354,
6115,
8696,
10375,
2237,
2742,
198,
3,
11063,
2633,
17738,
507,
198,
277,
14,
505,
275,
1318,
507,
198,
277,
14,
1501,
275,
1788,
507,
198,
277,
14,
827,
10146,
275,
1748,
10146,
507,
198,
277,
14,
3093,
8696,
10375,
275,
32410,
507,
198,
277,
14,
25799,
275,
32410,
436,
32410,
14,
585,
5873,
503,
942,
507,
198,
277,
14,
751,
1385,
275,
922,
1385,
507,
198,
277,
14,
2495,
1123,
275,
2599,
1123,
507,
198,
277,
14,
3773,
3567,
275,
5283,
3567,
507,
198,
277,
14,
17695,
1892,
390,
17051,
275,
315,
20215,
390,
17051,
2742,
198,
3,
11578,
3814,
1296,
507,
198,
277,
905,
14964,
937,
275,
3814,
1296,
8,
9808,
3567,
12,
2498,
13752,
275,
715,
12,
2498,
5535,
275,
756,
12,
315,
20215,
390,
24467,
83,
275,
315,
20215,
390,
24467,
83,
12,
315,
20215,
390,
17051,
275,
315,
20215,
390,
17051,
9,
2742,
198,
3,
11578,
8944,
1296,
507,
198,
277,
905,
2706,
513,
937,
275,
18281,
1296,
8,
277,
14,
25799,
9,
2742,
198,
3,
16005,
83,
507,
198,
277,
905,
498,
63,
7731,
937,
275,
16005,
6115,
3593,
2237,
507,
198,
277,
905,
498,
63,
14514,
937,
275,
16005,
6115,
16843,
2237,
507,
198,
277,
905,
498,
63,
6304,
937,
275,
16005,
6115,
5587,
23799,
2237,
507,
198,
277,
905,
498,
63,
581,
937,
275,
16005,
6115,
9083,
2237,
2742,
198,
3,
10257,
3928,
367,
16005,
83,
507,
198,
277,
905,
7731,
937,
275,
510,
12879,
342,
507,
198,
277,
905,
14514,
937,
275,
510,
12879,
342,
507,
198,
277,
905,
6304,
937,
275,
510,
12879,
342,
507,
198,
277,
905,
581,
937,
275,
510,
12879,
342,
2742,
198,
3,
11578,
10256,
507,
198,
277,
905,
1375,
937,
275,
10354,
342,
507,
198,
277,
905,
1375,
70,
5710,
1142,
937,
275,
10354,
342,
2742,
198,
692,
291,
14,
751,
1385,
26,
686,
198,
277,
14,
751,
632,
3314,
342,
2742,
198,
3,
8388,
10033,
18599,
507,
198,
533,
12625,
3532,
3310,
2956,
8,
8673,
461,
3310,
2956,
304,
686,
198,
318,
636,
826,
721,
277,
12,
1676,
12,
1067,
12,
5445,
29,
403,
12,
20449,
29,
16,
304,
1585,
198,
692,
440,
5445,
26,
5445,
275,
1052,
1585,
198,
8673,
461,
3310,
2956,
855,
826,
721,
277,
12,
1676,
12,
1067,
12,
5445,
12,
20449,
9,
1585,
198,
277,
14,
1977,
275,
1676,
6319,
198,
318,
1595,
8,
277,
12,
18191,
12,
1595,
304,
1585,
198,
3,
15510,
27534,
2416,
1585,
198,
277,
14,
1977,
14,
2593,
8,
3990,
275,
715,
9,
16737,
198,
1107,
15456,
461,
3310,
2956,
14,
1287,
8,
277,
12,
18191,
12,
1595,
9,
2742,
198,
3,
24367,
626,
911,
5305,
12530,
2416,
507,
198,
277,
905,
20120,
9303,
937,
275,
12625,
3532,
3310,
2956,
8,
277,
12,
298,
20120,
9303,
401,
686,
198,
91,
1585,
198,
2,
745,
582,
334,
277,
14,
745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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
danduggan/hltd
|
lib/urllib3-1.10/urllib3_hltd/response.py
|
243
|
11686
|
import zlib
import io
from socket import timeout as SocketTimeout
from ._collections import HTTPHeaderDict
from .exceptions import ProtocolError, DecodeError, ReadTimeoutError
from .packages.six import string_types as basestring, binary_type
from .connection import HTTPException, BaseSSLError
from .util.response import is_fp_closed
class DeflateDecoder(object):
def __init__(self):
self._first_try = True
self._data = binary_type()
self._obj = zlib.decompressobj()
def __getattr__(self, name):
return getattr(self._obj, name)
def decompress(self, data):
if not self._first_try:
return self._obj.decompress(data)
self._data += data
try:
return self._obj.decompress(data)
except zlib.error:
self._first_try = False
self._obj = zlib.decompressobj(-zlib.MAX_WBITS)
try:
return self.decompress(self._data)
finally:
self._data = None
def _get_decoder(mode):
if mode == 'gzip':
return zlib.decompressobj(16 + zlib.MAX_WBITS)
return DeflateDecoder()
class HTTPResponse(io.IOBase):
"""
HTTP Response container.
Backwards-compatible to httplib's HTTPResponse but the response ``body`` is
loaded and decoded on-demand when the ``data`` property is accessed. This
class is also compatible with the Python standard library's :mod:`io`
module, and can hence be treated as a readable object in the context of that
framework.
Extra parameters for behaviour not present in httplib.HTTPResponse:
:param preload_content:
If True, the response's body will be preloaded during construction.
:param decode_content:
If True, attempts to decode specific content-encoding's based on headers
(like 'gzip' and 'deflate') will be skipped and raw data will be used
instead.
:param original_response:
When this HTTPResponse wrapper is generated from an httplib.HTTPResponse
object, it's convenient to include the original for debug purposes. It's
otherwise unused.
"""
CONTENT_DECODERS = ['gzip', 'deflate']
REDIRECT_STATUSES = [301, 302, 303, 307, 308]
def __init__(self, body='', headers=None, status=0, version=0, reason=None,
strict=0, preload_content=True, decode_content=True,
original_response=None, pool=None, connection=None):
self.headers = HTTPHeaderDict()
if headers:
self.headers.update(headers)
self.status = status
self.version = version
self.reason = reason
self.strict = strict
self.decode_content = decode_content
self._decoder = None
self._body = None
self._fp = None
self._original_response = original_response
self._fp_bytes_read = 0
if body and isinstance(body, (basestring, binary_type)):
self._body = body
self._pool = pool
self._connection = connection
if hasattr(body, 'read'):
self._fp = body
if preload_content and not self._body:
self._body = self.read(decode_content=decode_content)
def get_redirect_location(self):
"""
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
"""
if self.status in self.REDIRECT_STATUSES:
return self.headers.get('location')
return False
def release_conn(self):
if not self._pool or not self._connection:
return
self._pool._put_conn(self._connection)
self._connection = None
@property
def data(self):
# For backwords-compat with earlier urllib3 0.4 and earlier.
if self._body:
return self._body
if self._fp:
return self.read(cache_content=True)
def tell(self):
"""
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``HTTPResponse.read`` if bytes
are encoded on the wire (e.g, compressed).
"""
return self._fp_bytes_read
def read(self, amt=None, decode_content=None, cache_content=False):
"""
Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the full
response.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
:param cache_content:
If True, will save the returned data such that the same result is
returned despite of the state of the underlying file object. This
is useful if you want the ``.data`` property to continue working
after having ``.read()`` the file object. (Overridden if ``amt`` is
set.)
"""
# Note: content-encoding value should be case-insensitive, per RFC 7230
# Section 3.2
content_encoding = self.headers.get('content-encoding', '').lower()
if self._decoder is None:
if content_encoding in self.CONTENT_DECODERS:
self._decoder = _get_decoder(content_encoding)
if decode_content is None:
decode_content = self.decode_content
if self._fp is None:
return
flush_decoder = False
try:
try:
if amt is None:
# cStringIO doesn't like amt=None
data = self._fp.read()
flush_decoder = True
else:
cache_content = False
data = self._fp.read(amt)
if amt != 0 and not data: # Platform-specific: Buggy versions of Python.
# Close the connection when no data is returned
#
# This is redundant to what httplib/http.client _should_
# already do. However, versions of python released before
# December 15, 2012 (http://bugs.python.org/issue16298) do
# not properly close the connection in all cases. There is
# no harm in redundantly calling close.
self._fp.close()
flush_decoder = True
except SocketTimeout:
# FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
# there is yet no clean way to get at it from this context.
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
except BaseSSLError as e:
# FIXME: Is there a better way to differentiate between SSLErrors?
if not 'read operation timed out' in str(e): # Defensive:
# This shouldn't happen but just in case we're missing an edge
# case, let's avoid swallowing SSL errors.
raise
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
except HTTPException as e:
# This includes IncompleteRead.
raise ProtocolError('Connection broken: %r' % e, e)
self._fp_bytes_read += len(data)
try:
if decode_content and self._decoder:
data = self._decoder.decompress(data)
except (IOError, zlib.error) as e:
raise DecodeError(
"Received response with content-encoding: %s, but "
"failed to decode it." % content_encoding, e)
if flush_decoder and decode_content and self._decoder:
buf = self._decoder.decompress(binary_type())
data += buf + self._decoder.flush()
if cache_content:
self._body = data
return data
finally:
if self._original_response and self._original_response.isclosed():
self.release_conn()
def stream(self, amt=2**16, decode_content=None):
"""
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator will return up to
much data per iteration, but may return less. This is particularly
likely when using compressed data. However, the empty string will
never be returned.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
"""
while not is_fp_closed(self._fp):
data = self.read(amt=amt, decode_content=decode_content)
if data:
yield data
@classmethod
def from_httplib(ResponseCls, r, **response_kw):
"""
Given an :class:`httplib.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.
Remaining parameters are passed to the HTTPResponse constructor, along
with ``original_response=r``.
"""
headers = HTTPHeaderDict()
for k, v in r.getheaders():
headers.add(k, v)
# HTTPResponse objects in Python 3 don't have a .strict attribute
strict = getattr(r, 'strict', 0)
return ResponseCls(body=r,
headers=headers,
status=r.status,
version=r.version,
reason=r.reason,
strict=strict,
original_response=r,
**response_kw)
# Backwards-compatibility methods for httplib.HTTPResponse
def getheaders(self):
return self.headers
def getheader(self, name, default=None):
return self.headers.get(name, default)
# Overrides from io.IOBase
def close(self):
if not self.closed:
self._fp.close()
@property
def closed(self):
if self._fp is None:
return True
elif hasattr(self._fp, 'closed'):
return self._fp.closed
elif hasattr(self._fp, 'isclosed'): # Python 2
return self._fp.isclosed()
else:
return True
def fileno(self):
if self._fp is None:
raise IOError("HTTPResponse has no file to get a fileno from")
elif hasattr(self._fp, "fileno"):
return self._fp.fileno()
else:
raise IOError("The file-like object this HTTPResponse is wrapped "
"around has no file descriptor")
def flush(self):
if self._fp is not None and hasattr(self._fp, 'flush'):
return self._fp.flush()
def readable(self):
# This method is required for `io` module compatibility.
return True
def readinto(self, b):
# This method is required for `io` module compatibility.
temp = self.read(len(b))
if len(temp) == 0:
return 0
else:
b[:len(temp)] = temp
return len(temp)
|
lgpl-3.0
|
[
646,
12472,
199,
646,
5890,
199,
504,
2838,
492,
2653,
465,
17766,
6372,
199,
199,
504,
13653,
7882,
492,
3101,
2567,
2141,
199,
504,
1275,
3924,
492,
30797,
12,
22462,
547,
12,
5574,
19382,
199,
504,
1275,
5154,
14,
4174,
492,
1059,
63,
1313,
465,
7116,
12,
3366,
63,
466,
199,
504,
1275,
2105,
492,
28185,
12,
3523,
27102,
199,
504,
1275,
1974,
14,
1310,
492,
365,
63,
3997,
63,
5938,
4388,
199,
533,
11391,
750,
8326,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2246,
63,
893,
275,
715,
267,
291,
423,
576,
275,
3366,
63,
466,
342,
267,
291,
423,
1113,
275,
12472,
14,
14954,
1113,
342,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
423,
1113,
12,
536,
9,
339,
347,
24733,
8,
277,
12,
666,
304,
267,
340,
440,
291,
423,
2246,
63,
893,
26,
288,
372,
291,
423,
1113,
14,
14954,
8,
576,
9,
398,
291,
423,
576,
847,
666,
267,
862,
26,
288,
372,
291,
423,
1113,
14,
14954,
8,
576,
9,
267,
871,
12472,
14,
705,
26,
288,
291,
423,
2246,
63,
893,
275,
756,
288,
291,
423,
1113,
275,
12472,
14,
14954,
1113,
2801,
15371,
14,
4283,
63,
55,
14662,
9,
288,
862,
26,
355,
372,
291,
14,
14954,
8,
277,
423,
576,
9,
288,
3753,
26,
355,
291,
423,
576,
275,
488,
421,
199,
318,
485,
362,
63,
8813,
8,
632,
304,
272,
340,
818,
508,
283,
12256,
356,
267,
372,
12472,
14,
14954,
1113,
8,
975,
435,
12472,
14,
4283,
63,
55,
14662,
9,
339,
372,
11391,
750,
8326,
342,
421,
199,
533,
29034,
8,
2308,
14,
23413,
304,
272,
408,
272,
3101,
7232,
3970,
14,
339,
10257,
4751,
13,
6490,
370,
8809,
1159,
29034,
1325,
314,
1177,
1124,
2030,
1040,
365,
272,
6511,
436,
11203,
641,
13,
24152,
1380,
314,
1124,
576,
1040,
3324,
365,
13810,
14,
221,
961,
272,
1021,
365,
2597,
9025,
543,
314,
2018,
4465,
3555,
1159,
520,
1494,
1705,
2308,
64,
272,
859,
12,
436,
883,
19407,
506,
10184,
465,
282,
12701,
909,
315,
314,
1067,
402,
626,
272,
10059,
14,
339,
11177,
2633,
367,
13942,
440,
3451,
315,
8809,
14,
27068,
26,
339,
520,
635,
32511,
63,
1317,
26,
267,
982,
715,
12,
314,
1177,
1159,
2396,
911,
506,
876,
4591,
5309,
14538,
14,
339,
520,
635,
4849,
63,
1317,
26,
267,
982,
715,
12,
12454,
370,
4849,
2488,
1564,
13,
2991,
1159,
4079,
641,
2323,
267,
334,
2930,
283,
12256,
7,
436,
283,
20902,
358,
911,
506,
9645,
436,
3066,
666,
911,
506,
1202,
267,
3140,
14,
339,
520,
635,
3379,
63,
1310,
26,
267,
3979,
642,
29034,
4975,
365,
4046,
687,
376,
8809,
14,
27068,
267,
909,
12,
652,
1159,
22700,
370,
2387,
314,
3379,
367,
3105,
12901,
14,
2779,
1159,
267,
4257,
9563,
14,
272,
408,
339,
29417,
63,
1093,
12592,
3960,
275,
788,
12256,
297,
283,
20902,
418,
272,
820,
7458,
4168,
63,
6305,
654,
275,
359,
8507,
12,
11485,
12,
25989,
12,
26959,
12,
650,
2036,
61,
339,
347,
636,
826,
721,
277,
12,
2396,
4581,
2323,
29,
403,
12,
2004,
29,
16,
12,
1015,
29,
16,
12,
4499,
29,
403,
12,
326,
7478,
29,
16,
12,
32511,
63,
1317,
29,
549,
12,
4849,
63,
1317,
29,
549,
12,
326,
3379,
63,
1310,
29,
403,
12,
4203,
29,
403,
12,
1950,
29,
403,
304,
398,
291,
14,
2139,
275,
3101,
2567,
2141,
342,
267,
340,
2323,
26,
288,
291,
14,
2139,
14,
873,
8,
2139,
9,
267,
291,
14,
1205,
275,
2004,
267,
291,
14,
1023,
275,
1015,
267,
291,
14,
5764,
275,
4499,
267,
291,
14,
4768,
275,
7478,
267,
291,
14,
2708,
63,
1317,
275,
4849,
63,
1317,
398,
291,
423,
8813,
275,
488,
267,
291,
423,
2030,
275,
488,
267,
291,
423,
3997,
275,
488,
267,
291,
423,
5043,
63,
1310,
275,
3379,
63,
1310,
267,
291,
423,
3997,
63,
2394,
63,
739,
275,
378,
398,
340,
2396,
436,
1228,
8,
2030,
12,
334,
17628,
12,
3366,
63,
466,
2298,
288,
291,
423,
2030,
275,
2396,
398,
291,
423,
2293,
275,
4203,
267,
291,
423,
2105,
275,
1950,
398,
340,
2688,
8,
2030,
12,
283,
739,
735,
288,
291,
423,
3997,
275,
2396,
398,
340,
32511,
63,
1317,
436,
440,
291,
423,
2030,
26,
288,
291,
423,
2030,
275,
291,
14,
739,
8,
2708,
63,
1317,
29,
2708,
63,
1317,
9,
339,
347,
664,
63,
4876,
63,
1985,
8,
277,
304,
267,
408,
267,
7719,
781,
4660,
436,
2382,
370,
31,
398,
520,
5808,
26,
28814,
762,
89,
4660,
2909,
1059,
340,
781,
4788,
282,
4660,
2004,
288,
1233,
436,
1686,
2909,
14,
1124,
403,
1040,
340,
4660,
2004,
436,
949,
288,
2909,
14,
1124,
797,
1040,
340,
440,
282,
4660,
2004,
1233,
14,
267,
408,
267,
340,
291,
14,
1205,
315,
291,
14,
19747,
63,
6305,
654,
26,
288,
372,
291,
14,
2139,
14,
362,
360,
1985,
358,
398,
372,
756,
339,
347,
4683,
63,
1631,
8,
277,
304,
267,
340,
440,
291,
423,
2293,
503,
440,
291,
423,
2105,
26,
288,
372,
398,
291,
423,
2293,
423,
524,
63,
1631,
8,
277,
423,
2105,
9,
267,
291,
423,
2105,
275,
488,
339,
768,
1829,
272,
347,
666,
8,
277,
304,
267,
327,
2104,
1771,
3148,
13,
5819,
543,
14119,
4011,
19,
378,
14,
20,
436,
14119,
14,
267,
340,
291,
423,
2030,
26,
288,
372,
291,
423,
2030,
398,
340,
291,
423,
3997,
26,
288,
372,
291,
14,
739,
8,
1637,
63,
1317,
29,
549,
9,
339,
347,
11480,
8,
277,
304,
267,
408,
267,
17985,
877,
314,
1329,
402,
2783,
25239,
1146,
1806,
314,
11799,
880,
12474,
14,
10162,
14460,
687,
267,
314,
5982,
402,
1564,
2138,
701,
520,
5247,
5409,
27068,
14,
739,
1040,
340,
2783,
267,
787,
5737,
641,
314,
11799,
334,
69,
14,
71,
12,
12335,
680,
267,
408,
267,
372,
291,
423,
3997,
63,
2394,
63,
739,
339,
347,
1586,
8,
277,
12,
23486,
29,
403,
12,
4849,
63,
1317,
29,
403,
12,
2581,
63,
1317,
29,
797,
304,
267,
408,
267,
20046,
370,
520,
5247,
1705,
12942,
14,
27068,
14,
739
] |
[
12472,
199,
646,
5890,
199,
504,
2838,
492,
2653,
465,
17766,
6372,
199,
199,
504,
13653,
7882,
492,
3101,
2567,
2141,
199,
504,
1275,
3924,
492,
30797,
12,
22462,
547,
12,
5574,
19382,
199,
504,
1275,
5154,
14,
4174,
492,
1059,
63,
1313,
465,
7116,
12,
3366,
63,
466,
199,
504,
1275,
2105,
492,
28185,
12,
3523,
27102,
199,
504,
1275,
1974,
14,
1310,
492,
365,
63,
3997,
63,
5938,
4388,
199,
533,
11391,
750,
8326,
8,
785,
304,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2246,
63,
893,
275,
715,
267,
291,
423,
576,
275,
3366,
63,
466,
342,
267,
291,
423,
1113,
275,
12472,
14,
14954,
1113,
342,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
423,
1113,
12,
536,
9,
339,
347,
24733,
8,
277,
12,
666,
304,
267,
340,
440,
291,
423,
2246,
63,
893,
26,
288,
372,
291,
423,
1113,
14,
14954,
8,
576,
9,
398,
291,
423,
576,
847,
666,
267,
862,
26,
288,
372,
291,
423,
1113,
14,
14954,
8,
576,
9,
267,
871,
12472,
14,
705,
26,
288,
291,
423,
2246,
63,
893,
275,
756,
288,
291,
423,
1113,
275,
12472,
14,
14954,
1113,
2801,
15371,
14,
4283,
63,
55,
14662,
9,
288,
862,
26,
355,
372,
291,
14,
14954,
8,
277,
423,
576,
9,
288,
3753,
26,
355,
291,
423,
576,
275,
488,
421,
199,
318,
485,
362,
63,
8813,
8,
632,
304,
272,
340,
818,
508,
283,
12256,
356,
267,
372,
12472,
14,
14954,
1113,
8,
975,
435,
12472,
14,
4283,
63,
55,
14662,
9,
339,
372,
11391,
750,
8326,
342,
421,
199,
533,
29034,
8,
2308,
14,
23413,
304,
272,
408,
272,
3101,
7232,
3970,
14,
339,
10257,
4751,
13,
6490,
370,
8809,
1159,
29034,
1325,
314,
1177,
1124,
2030,
1040,
365,
272,
6511,
436,
11203,
641,
13,
24152,
1380,
314,
1124,
576,
1040,
3324,
365,
13810,
14,
221,
961,
272,
1021,
365,
2597,
9025,
543,
314,
2018,
4465,
3555,
1159,
520,
1494,
1705,
2308,
64,
272,
859,
12,
436,
883,
19407,
506,
10184,
465,
282,
12701,
909,
315,
314,
1067,
402,
626,
272,
10059,
14,
339,
11177,
2633,
367,
13942,
440,
3451,
315,
8809,
14,
27068,
26,
339,
520,
635,
32511,
63,
1317,
26,
267,
982,
715,
12,
314,
1177,
1159,
2396,
911,
506,
876,
4591,
5309,
14538,
14,
339,
520,
635,
4849,
63,
1317,
26,
267,
982,
715,
12,
12454,
370,
4849,
2488,
1564,
13,
2991,
1159,
4079,
641,
2323,
267,
334,
2930,
283,
12256,
7,
436,
283,
20902,
358,
911,
506,
9645,
436,
3066,
666,
911,
506,
1202,
267,
3140,
14,
339,
520,
635,
3379,
63,
1310,
26,
267,
3979,
642,
29034,
4975,
365,
4046,
687,
376,
8809,
14,
27068,
267,
909,
12,
652,
1159,
22700,
370,
2387,
314,
3379,
367,
3105,
12901,
14,
2779,
1159,
267,
4257,
9563,
14,
272,
408,
339,
29417,
63,
1093,
12592,
3960,
275,
788,
12256,
297,
283,
20902,
418,
272,
820,
7458,
4168,
63,
6305,
654,
275,
359,
8507,
12,
11485,
12,
25989,
12,
26959,
12,
650,
2036,
61,
339,
347,
636,
826,
721,
277,
12,
2396,
4581,
2323,
29,
403,
12,
2004,
29,
16,
12,
1015,
29,
16,
12,
4499,
29,
403,
12,
326,
7478,
29,
16,
12,
32511,
63,
1317,
29,
549,
12,
4849,
63,
1317,
29,
549,
12,
326,
3379,
63,
1310,
29,
403,
12,
4203,
29,
403,
12,
1950,
29,
403,
304,
398,
291,
14,
2139,
275,
3101,
2567,
2141,
342,
267,
340,
2323,
26,
288,
291,
14,
2139,
14,
873,
8,
2139,
9,
267,
291,
14,
1205,
275,
2004,
267,
291,
14,
1023,
275,
1015,
267,
291,
14,
5764,
275,
4499,
267,
291,
14,
4768,
275,
7478,
267,
291,
14,
2708,
63,
1317,
275,
4849,
63,
1317,
398,
291,
423,
8813,
275,
488,
267,
291,
423,
2030,
275,
488,
267,
291,
423,
3997,
275,
488,
267,
291,
423,
5043,
63,
1310,
275,
3379,
63,
1310,
267,
291,
423,
3997,
63,
2394,
63,
739,
275,
378,
398,
340,
2396,
436,
1228,
8,
2030,
12,
334,
17628,
12,
3366,
63,
466,
2298,
288,
291,
423,
2030,
275,
2396,
398,
291,
423,
2293,
275,
4203,
267,
291,
423,
2105,
275,
1950,
398,
340,
2688,
8,
2030,
12,
283,
739,
735,
288,
291,
423,
3997,
275,
2396,
398,
340,
32511,
63,
1317,
436,
440,
291,
423,
2030,
26,
288,
291,
423,
2030,
275,
291,
14,
739,
8,
2708,
63,
1317,
29,
2708,
63,
1317,
9,
339,
347,
664,
63,
4876,
63,
1985,
8,
277,
304,
267,
408,
267,
7719,
781,
4660,
436,
2382,
370,
31,
398,
520,
5808,
26,
28814,
762,
89,
4660,
2909,
1059,
340,
781,
4788,
282,
4660,
2004,
288,
1233,
436,
1686,
2909,
14,
1124,
403,
1040,
340,
4660,
2004,
436,
949,
288,
2909,
14,
1124,
797,
1040,
340,
440,
282,
4660,
2004,
1233,
14,
267,
408,
267,
340,
291,
14,
1205,
315,
291,
14,
19747,
63,
6305,
654,
26,
288,
372,
291,
14,
2139,
14,
362,
360,
1985,
358,
398,
372,
756,
339,
347,
4683,
63,
1631,
8,
277,
304,
267,
340,
440,
291,
423,
2293,
503,
440,
291,
423,
2105,
26,
288,
372,
398,
291,
423,
2293,
423,
524,
63,
1631,
8,
277,
423,
2105,
9,
267,
291,
423,
2105,
275,
488,
339,
768,
1829,
272,
347,
666,
8,
277,
304,
267,
327,
2104,
1771,
3148,
13,
5819,
543,
14119,
4011,
19,
378,
14,
20,
436,
14119,
14,
267,
340,
291,
423,
2030,
26,
288,
372,
291,
423,
2030,
398,
340,
291,
423,
3997,
26,
288,
372,
291,
14,
739,
8,
1637,
63,
1317,
29,
549,
9,
339,
347,
11480,
8,
277,
304,
267,
408,
267,
17985,
877,
314,
1329,
402,
2783,
25239,
1146,
1806,
314,
11799,
880,
12474,
14,
10162,
14460,
687,
267,
314,
5982,
402,
1564,
2138,
701,
520,
5247,
5409,
27068,
14,
739,
1040,
340,
2783,
267,
787,
5737,
641,
314,
11799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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
marscher/PyEMMA
|
pyemma/_base/progress/test_progress.py
|
3
|
3522
|
# This file is part of PyEMMA.
#
# Copyright (c) 2017 Computational Molecular Biology Group, Freie Universitaet Berlin (GER)
#
# PyEMMA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from pyemma._base.progress import ProgressReporterMixin, ProgressReporter
from pyemma.util.contexts import settings
import pyemma
class TestProgress(unittest.TestCase):
@classmethod
def setUpClass(cls):
import sys, os
cls.old_std_err = sys.stderr
sys.stderr = os.devnull
@classmethod
def tearDownClass(cls):
pyemma.config.show_progress_bars = False
import sys
sys.stderr = cls.old_std_err
def setUp(self):
pyemma.config.show_progress_bars = True
self.pg = ProgressReporterMixin()
self.pg._progress_register(100, "test")
def test_config_override(self):
self.pg.show_progress = True
with settings(show_progress_bars=False):
assert self.pg.show_progress == False
def test_config_2(self):
self.pg.show_progress = False
with settings(show_progress_bars=True):
assert not self.pg.show_progress
def test_ctx(self):
pg = ProgressReporter()
pg.register(100, 'test')
pg.register(40, 'test2')
try:
with pg.context():
pg.update(50, stage='test')
raise Exception()
except Exception:
assert pg.num_registered == 0
def test_ctx2(self):
pg = ProgressReporter()
assert pg.show_progress
pg.register(100, stage='test')
pg.register(40, stage='test2')
try:
with pg.context(stage='test'):
pg.update(50, stage='test')
raise Exception()
except Exception:
assert pg.num_registered == 1
assert 'test2' in pg.registered_stages
def test_ctx3(self):
pg = ProgressReporter()
assert pg.show_progress
pg.register(100, stage='test')
pg.register(40, stage='test2')
pg.register(25, stage='test3')
try:
with pg.context(stage=('test', 'test3')):
pg.update(50, stage='test')
pg.update(2, stage='test3')
raise Exception()
except Exception:
assert pg.num_registered == 1
assert 'test2' in pg.registered_stages
def test_ctx4(self):
pg = ProgressReporter()
pg.register(100, 'test')
pg.register(40, 'test2')
try:
with pg.context():
pg.update(50, stage='all')
raise Exception()
except Exception:
assert pg.num_registered == 0
def test_below_threshold(self):
# show not raise
pg = ProgressReporter()
pg.register(2)
pg.update(1)
pg.set_description('dummy')
if __name__ == '__main__':
unittest.main()
|
lgpl-3.0
|
[
3,
961,
570,
365,
1777,
402,
1611,
2769,
2054,
14,
199,
3,
199,
3,
1898,
334,
67,
9,
9708,
3599,
337,
6279,
3930,
10251,
2238,
699,
2308,
4956,
5611,
12,
481,
264,
1873,
1910,
4380,
338,
502,
386,
23207,
472,
334,
11784,
9,
199,
3,
199,
3,
1611,
2769,
2054,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
2882,
199,
199,
504,
1134,
5633,
391,
423,
1095,
14,
5734,
492,
21211,
15891,
4256,
12,
21211,
15891,
199,
504,
1134,
5633,
391,
14,
1974,
14,
19010,
492,
2202,
199,
646,
1134,
5633,
391,
421,
199,
533,
1379,
11504,
8,
2796,
14,
1746,
304,
272,
768,
3744,
272,
347,
18561,
8,
1886,
304,
267,
492,
984,
12,
747,
267,
843,
14,
1753,
63,
1516,
63,
1508,
275,
984,
14,
3083,
267,
984,
14,
3083,
275,
747,
14,
19778,
339,
768,
3744,
272,
347,
24468,
8,
1886,
304,
267,
1134,
5633,
391,
14,
888,
14,
2384,
63,
5734,
63,
16264,
275,
756,
267,
492,
984,
267,
984,
14,
3083,
275,
843,
14,
1753,
63,
1516,
63,
1508,
339,
347,
3613,
8,
277,
304,
267,
1134,
5633,
391,
14,
888,
14,
2384,
63,
5734,
63,
16264,
275,
715,
267,
291,
14,
4198,
275,
21211,
15891,
4256,
342,
267,
291,
14,
4198,
423,
5734,
63,
2683,
8,
1960,
12,
298,
396,
531,
339,
347,
511,
63,
888,
63,
4415,
8,
277,
304,
267,
291,
14,
4198,
14,
2384,
63,
5734,
275,
715,
267,
543,
2202,
8,
2384,
63,
5734,
63,
16264,
29,
797,
304,
288,
702,
291,
14,
4198,
14,
2384,
63,
5734,
508,
756,
339,
347,
511,
63,
888,
63,
18,
8,
277,
304,
267,
291,
14,
4198,
14,
2384,
63,
5734,
275,
756,
267,
543,
2202,
8,
2384,
63,
5734,
63,
16264,
29,
549,
304,
288,
702,
440,
291,
14,
4198,
14,
2384,
63,
5734,
339,
347,
511,
63,
3799,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
10275,
14,
2683,
8,
1960,
12,
283,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
283,
396,
18,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
837,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
396,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
378,
339,
347,
511,
63,
3799,
18,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
702,
10275,
14,
2384,
63,
5734,
267,
10275,
14,
2683,
8,
1960,
12,
9546,
534,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
9546,
534,
396,
18,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
8,
8614,
534,
396,
735,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
396,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
413,
288,
702,
283,
396,
18,
7,
315,
10275,
14,
11616,
63,
30646,
339,
347,
511,
63,
3799,
19,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
702,
10275,
14,
2384,
63,
5734,
267,
10275,
14,
2683,
8,
1960,
12,
9546,
534,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
9546,
534,
396,
18,
358,
267,
10275,
14,
2683,
8,
821,
12,
9546,
534,
396,
19,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
8,
8614,
7782,
396,
297,
283,
396,
19,
8109,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
396,
358,
355,
10275,
14,
873,
8,
18,
12,
9546,
534,
396,
19,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
413,
288,
702,
283,
396,
18,
7,
315,
10275,
14,
11616,
63,
30646,
339,
347,
511,
63,
3799,
20,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
10275,
14,
2683,
8,
1960,
12,
283,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
283,
396,
18,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
837,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
452,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
378,
339,
347,
511,
63,
12843,
63,
7227,
8,
277,
304,
267,
327,
2498,
440,
746,
267,
10275,
275,
21211,
15891,
342,
267,
10275,
14,
2683,
8,
18,
9,
267,
10275,
14,
873,
8,
17,
9,
267,
10275,
14,
409,
63,
1802,
360,
5869,
358,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
961,
570,
365,
1777,
402,
1611,
2769,
2054,
14,
199,
3,
199,
3,
1898,
334,
67,
9,
9708,
3599,
337,
6279,
3930,
10251,
2238,
699,
2308,
4956,
5611,
12,
481,
264,
1873,
1910,
4380,
338,
502,
386,
23207,
472,
334,
11784,
9,
199,
3,
199,
3,
1611,
2769,
2054,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
646,
2882,
199,
199,
504,
1134,
5633,
391,
423,
1095,
14,
5734,
492,
21211,
15891,
4256,
12,
21211,
15891,
199,
504,
1134,
5633,
391,
14,
1974,
14,
19010,
492,
2202,
199,
646,
1134,
5633,
391,
421,
199,
533,
1379,
11504,
8,
2796,
14,
1746,
304,
272,
768,
3744,
272,
347,
18561,
8,
1886,
304,
267,
492,
984,
12,
747,
267,
843,
14,
1753,
63,
1516,
63,
1508,
275,
984,
14,
3083,
267,
984,
14,
3083,
275,
747,
14,
19778,
339,
768,
3744,
272,
347,
24468,
8,
1886,
304,
267,
1134,
5633,
391,
14,
888,
14,
2384,
63,
5734,
63,
16264,
275,
756,
267,
492,
984,
267,
984,
14,
3083,
275,
843,
14,
1753,
63,
1516,
63,
1508,
339,
347,
3613,
8,
277,
304,
267,
1134,
5633,
391,
14,
888,
14,
2384,
63,
5734,
63,
16264,
275,
715,
267,
291,
14,
4198,
275,
21211,
15891,
4256,
342,
267,
291,
14,
4198,
423,
5734,
63,
2683,
8,
1960,
12,
298,
396,
531,
339,
347,
511,
63,
888,
63,
4415,
8,
277,
304,
267,
291,
14,
4198,
14,
2384,
63,
5734,
275,
715,
267,
543,
2202,
8,
2384,
63,
5734,
63,
16264,
29,
797,
304,
288,
702,
291,
14,
4198,
14,
2384,
63,
5734,
508,
756,
339,
347,
511,
63,
888,
63,
18,
8,
277,
304,
267,
291,
14,
4198,
14,
2384,
63,
5734,
275,
756,
267,
543,
2202,
8,
2384,
63,
5734,
63,
16264,
29,
549,
304,
288,
702,
440,
291,
14,
4198,
14,
2384,
63,
5734,
339,
347,
511,
63,
3799,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
10275,
14,
2683,
8,
1960,
12,
283,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
283,
396,
18,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
837,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
396,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
378,
339,
347,
511,
63,
3799,
18,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
702,
10275,
14,
2384,
63,
5734,
267,
10275,
14,
2683,
8,
1960,
12,
9546,
534,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
9546,
534,
396,
18,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
8,
8614,
534,
396,
735,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
396,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
413,
288,
702,
283,
396,
18,
7,
315,
10275,
14,
11616,
63,
30646,
339,
347,
511,
63,
3799,
19,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
702,
10275,
14,
2384,
63,
5734,
267,
10275,
14,
2683,
8,
1960,
12,
9546,
534,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
9546,
534,
396,
18,
358,
267,
10275,
14,
2683,
8,
821,
12,
9546,
534,
396,
19,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
8,
8614,
7782,
396,
297,
283,
396,
19,
8109,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
396,
358,
355,
10275,
14,
873,
8,
18,
12,
9546,
534,
396,
19,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
413,
288,
702,
283,
396,
18,
7,
315,
10275,
14,
11616,
63,
30646,
339,
347,
511,
63,
3799,
20,
8,
277,
304,
267,
10275,
275,
21211,
15891,
342,
267,
10275,
14,
2683,
8,
1960,
12,
283,
396,
358,
267,
10275,
14,
2683,
8,
2167,
12,
283,
396,
18,
358,
267,
862,
26,
288,
543,
10275,
14,
1100,
837,
355,
10275,
14,
873,
8,
1400,
12,
9546,
534,
452,
358,
355,
746,
2186,
342,
267,
871,
2186,
26,
288,
702,
10275,
14,
1507,
63,
11616,
508,
378,
339,
347,
511,
63,
12843,
63,
7227,
8,
277,
304,
267,
327,
2498,
440,
746,
267,
10275,
275,
21211,
15891,
342,
267,
10275,
14,
2683,
8,
18,
9,
267,
10275,
14,
873,
8,
17,
9,
267,
10275,
14,
409,
63,
1802,
360,
5869,
358,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
vktr/CouchPotatoServer
|
libs/subliminal/tasks.py
|
170
|
2328
|
# -*- coding: utf-8 -*-
# Copyright 2011-2012 Antoine Bertin <diaoulael@gmail.com>
#
# This file is part of subliminal.
#
# subliminal is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# subliminal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with subliminal. If not, see <http://www.gnu.org/licenses/>.
__all__ = ['Task', 'ListTask', 'DownloadTask', 'StopTask']
class Task(object):
"""Base class for tasks to use in subliminal"""
pass
class ListTask(Task):
"""List task used by the worker to search for subtitles
:param video: video to search subtitles for
:type video: :class:`~subliminal.videos.Video`
:param list languages: languages to search for
:param string service: name of the service to use
:param config: configuration for the service
:type config: :class:`~subliminal.services.ServiceConfig`
"""
def __init__(self, video, languages, service, config):
super(ListTask, self).__init__()
self.video = video
self.service = service
self.languages = languages
self.config = config
def __repr__(self):
return 'ListTask(%r, %r, %s, %r)' % (self.video, self.languages, self.service, self.config)
class DownloadTask(Task):
"""Download task used by the worker to download subtitles
:param video: video to download subtitles for
:type video: :class:`~subliminal.videos.Video`
:param subtitles: subtitles to download in order of preference
:type subtitles: list of :class:`~subliminal.subtitles.Subtitle`
"""
def __init__(self, video, subtitles):
super(DownloadTask, self).__init__()
self.video = video
self.subtitles = subtitles
def __repr__(self):
return 'DownloadTask(%r, %r)' % (self.video, self.subtitles)
class StopTask(Task):
"""Stop task that will stop the worker"""
pass
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
7760,
13,
7409,
437,
29680,
1132,
23207,
1346,
665,
2391,
79,
7586,
352,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1007,
13769,
279,
14,
199,
3,
199,
3,
1007,
13769,
279,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1007,
13769,
279,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
1007,
13769,
279,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
363,
452,
363,
275,
788,
4476,
297,
283,
1296,
4476,
297,
283,
11950,
4476,
297,
283,
6293,
4476,
418,
421,
199,
533,
8495,
8,
785,
304,
272,
408,
1563,
1021,
367,
6527,
370,
675,
315,
1007,
13769,
279,
624,
272,
986,
421,
199,
533,
3820,
4476,
8,
4476,
304,
272,
408,
1296,
2120,
1202,
701,
314,
7239,
370,
2754,
367,
19297,
339,
520,
635,
3991,
26,
3991,
370,
2754,
19297,
367,
272,
520,
466,
3991,
26,
520,
533,
6054,
954,
13769,
279,
14,
11418,
14,
9166,
64,
272,
520,
635,
769,
10815,
26,
10815,
370,
2754,
367,
272,
520,
635,
1059,
2435,
26,
536,
402,
314,
2435,
370,
675,
272,
520,
635,
1101,
26,
2897,
367,
314,
2435,
272,
520,
466,
1101,
26,
520,
533,
6054,
954,
13769,
279,
14,
5950,
14,
3167,
2028,
64,
339,
408,
272,
347,
636,
826,
721,
277,
12,
3991,
12,
10815,
12,
2435,
12,
1101,
304,
267,
1613,
8,
1296,
4476,
12,
291,
2843,
826,
4533,
267,
291,
14,
3722,
275,
3991,
267,
291,
14,
1364,
275,
2435,
267,
291,
14,
13209,
275,
10815,
267,
291,
14,
888,
275,
1101,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1296,
4476,
4042,
82,
12,
450,
82,
12,
450,
83,
12,
450,
82,
3171,
450,
334,
277,
14,
3722,
12,
291,
14,
13209,
12,
291,
14,
1364,
12,
291,
14,
888,
9,
421,
199,
533,
17955,
4476,
8,
4476,
304,
272,
408,
11950,
2120,
1202,
701,
314,
7239,
370,
5235,
19297,
339,
520,
635,
3991,
26,
3991,
370,
5235,
19297,
367,
272,
520,
466,
3991,
26,
520,
533,
6054,
954,
13769,
279,
14,
11418,
14,
9166,
64,
272,
520,
635,
19297,
26,
19297,
370,
5235,
315,
1865,
402,
16705,
272,
520,
466,
19297,
26,
769,
402,
520,
533,
6054,
954,
13769,
279,
14,
16858,
14,
29907,
64,
339,
408,
272,
347,
636,
826,
721,
277,
12,
3991,
12,
19297,
304,
267,
1613,
8,
11950,
4476,
12,
291,
2843,
826,
4533,
267,
291,
14,
3722,
275,
3991,
267,
291,
14,
16858,
275,
19297,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
11950,
4476,
4042,
82,
12,
450,
82,
3171,
450,
334,
277,
14,
3722,
12,
291,
14,
16858,
9,
421,
199,
533,
8015,
4476,
8,
4476,
304,
272,
408,
6293,
2120,
626,
911,
3631,
314,
7239,
624,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
7760,
13,
7409,
437,
29680,
1132,
23207,
1346,
665,
2391,
79,
7586,
352,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1007,
13769,
279,
14,
199,
3,
199,
3,
1007,
13769,
279,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
27,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
1007,
13769,
279,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
1007,
13769,
279,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
363,
452,
363,
275,
788,
4476,
297,
283,
1296,
4476,
297,
283,
11950,
4476,
297,
283,
6293,
4476,
418,
421,
199,
533,
8495,
8,
785,
304,
272,
408,
1563,
1021,
367,
6527,
370,
675,
315,
1007,
13769,
279,
624,
272,
986,
421,
199,
533,
3820,
4476,
8,
4476,
304,
272,
408,
1296,
2120,
1202,
701,
314,
7239,
370,
2754,
367,
19297,
339,
520,
635,
3991,
26,
3991,
370,
2754,
19297,
367,
272,
520,
466,
3991,
26,
520,
533,
6054,
954,
13769,
279,
14,
11418,
14,
9166,
64,
272,
520,
635,
769,
10815,
26,
10815,
370,
2754,
367,
272,
520,
635,
1059,
2435,
26,
536,
402,
314,
2435,
370,
675,
272,
520,
635,
1101,
26,
2897,
367,
314,
2435,
272,
520,
466,
1101,
26,
520,
533,
6054,
954,
13769,
279,
14,
5950,
14,
3167,
2028,
64,
339,
408,
272,
347,
636,
826,
721,
277,
12,
3991,
12,
10815,
12,
2435,
12,
1101,
304,
267,
1613,
8,
1296,
4476,
12,
291,
2843,
826,
4533,
267,
291,
14,
3722,
275,
3991,
267,
291,
14,
1364,
275,
2435,
267,
291,
14,
13209,
275,
10815,
267,
291,
14,
888,
275,
1101,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1296,
4476,
4042,
82,
12,
450,
82,
12,
450,
83,
12,
450,
82,
3171,
450,
334,
277,
14,
3722,
12,
291,
14,
13209,
12,
291,
14,
1364,
12,
291,
14,
888,
9,
421,
199,
533,
17955,
4476,
8,
4476,
304,
272,
408,
11950,
2120,
1202,
701,
314,
7239,
370,
5235,
19297,
339,
520,
635,
3991,
26,
3991,
370,
5235,
19297,
367,
272,
520,
466,
3991,
26,
520,
533,
6054,
954,
13769,
279,
14,
11418,
14,
9166,
64,
272,
520,
635,
19297,
26,
19297,
370,
5235,
315,
1865,
402,
16705,
272,
520,
466,
19297,
26,
769,
402,
520,
533,
6054,
954,
13769,
279,
14,
16858,
14,
29907,
64,
339,
408,
272,
347,
636,
826,
721,
277,
12,
3991,
12,
19297,
304,
267,
1613,
8,
11950,
4476,
12,
291,
2843,
826,
4533,
267,
291,
14,
3722,
275,
3991,
267,
291,
14,
16858,
275,
19297,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
11950,
4476,
4042,
82,
12,
450,
82,
3171,
450,
334,
277,
14,
3722,
12,
291,
14,
16858,
9,
421,
199,
533,
8015,
4476,
8,
4476,
304,
272,
408,
6293,
2120,
626,
911,
3631,
314,
7239,
624,
272,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nkalodimas/invenio
|
modules/bibupload/lib/bibupload.py
|
1
|
143104
|
# -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""
BibUpload: Receive MARC XML file and update the appropriate database
tables according to options.
"""
__revision__ = "$Id$"
import os
import re
import sys
import time
from datetime import datetime
from zlib import compress
import socket
import marshal
import copy
import tempfile
import urlparse
import urllib2
import urllib
from invenio.config import CFG_OAI_ID_FIELD, \
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG, \
CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG, \
CFG_BIBUPLOAD_EXTERNAL_OAIID_PROVENANCE_TAG, \
CFG_BIBUPLOAD_STRONG_TAGS, \
CFG_BIBUPLOAD_CONTROLLED_PROVENANCE_TAGS, \
CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE, \
CFG_BIBUPLOAD_DELETE_FORMATS, \
CFG_SITE_URL, CFG_SITE_SECURE_URL, CFG_SITE_RECORD, \
CFG_OAI_PROVENANCE_ALTERED_SUBFIELD, \
CFG_BIBUPLOAD_DISABLE_RECORD_REVISIONS, \
CFG_BIBUPLOAD_CONFLICTING_REVISION_TICKET_QUEUE
from invenio.jsonutils import json, CFG_JSON_AVAILABLE
from invenio.bibupload_config import CFG_BIBUPLOAD_CONTROLFIELD_TAGS, \
CFG_BIBUPLOAD_SPECIAL_TAGS, \
CFG_BIBUPLOAD_DELETE_CODE, \
CFG_BIBUPLOAD_DELETE_VALUE, \
CFG_BIBUPLOAD_OPT_MODES
from invenio.dbquery import run_sql, \
Error
from invenio.bibrecord import create_records, \
record_add_field, \
record_delete_field, \
record_xml_output, \
record_get_field_instances, \
record_get_field_value, \
record_get_field_values, \
field_get_subfield_values, \
field_get_subfield_instances, \
record_modify_subfield, \
record_delete_subfield_from, \
record_delete_fields, \
record_add_subfield_into, \
record_find_field, \
record_extract_oai_id, \
record_extract_dois, \
record_has_field,\
records_identical
from invenio.search_engine import get_record
from invenio.dateutils import convert_datestruct_to_datetext
from invenio.errorlib import register_exception
from invenio.bibcatalog import bibcatalog_system
from invenio.intbitset import intbitset
from invenio.urlutils import make_user_agent_string
from invenio.config import CFG_BIBDOCFILE_FILEDIR
from invenio.bibtask import task_init, write_message, \
task_set_option, task_get_option, task_get_task_param, task_update_status, \
task_update_progress, task_sleep_now_if_required, fix_argv_paths
from invenio.bibdocfile import BibRecDocs, file_strip_ext, normalize_format, \
get_docname_from_url, check_valid_url, download_url, \
KEEP_OLD_VALUE, decompose_bibdocfile_url, InvenioBibDocFileError, \
bibdocfile_url_p, CFG_BIBDOCFILE_AVAILABLE_FLAGS, guess_format_from_url, \
BibRelation, MoreInfo
from invenio.search_engine import search_pattern
from invenio.bibupload_revisionverifier import RevisionVerifier, \
InvenioBibUploadConflictingRevisionsError, \
InvenioBibUploadInvalidRevisionError, \
InvenioBibUploadMissing005Error, \
InvenioBibUploadUnchangedRecordError
#Statistic variables
stat = {}
stat['nb_records_to_upload'] = 0
stat['nb_records_updated'] = 0
stat['nb_records_inserted'] = 0
stat['nb_errors'] = 0
stat['nb_holdingpen'] = 0
stat['exectime'] = time.localtime()
_WRITING_RIGHTS = None
CFG_BIBUPLOAD_ALLOWED_SPECIAL_TREATMENTS = ('oracle', )
CFG_HAS_BIBCATALOG = "UNKNOWN"
def check_bibcatalog():
"""
Return True if bibcatalog is available.
"""
global CFG_HAS_BIBCATALOG # pylint: disable=W0603
if CFG_HAS_BIBCATALOG != "UNKNOWN":
return CFG_HAS_BIBCATALOG
CFG_HAS_BIBCATALOG = True
if bibcatalog_system is not None:
bibcatalog_response = bibcatalog_system.check_system()
else:
bibcatalog_response = "No ticket system configured"
if bibcatalog_response != "":
write_message("BibCatalog error: %s\n" % (bibcatalog_response,))
CFG_HAS_BIBCATALOG = False
return CFG_HAS_BIBCATALOG
## Let's set a reasonable timeout for URL request (e.g. FFT)
socket.setdefaulttimeout(40)
def parse_identifier(identifier):
"""Parse the identifier and determine if it is temporary or fixed"""
id_str = str(identifier)
if not id_str.startswith("TMP:"):
return (False, identifier)
else:
return (True, id_str[4:])
def resolve_identifier(tmps, identifier):
"""Resolves an identifier. If the identifier is not temporary, this
function is an identity on the second argument. Otherwise, a resolved
value is returned or an exception raised"""
is_tmp, tmp_id = parse_identifier(identifier)
if is_tmp:
if not tmp_id in tmps:
raise StandardError("Temporary identifier %s not present in the dictionary" % (tmp_id, ))
if tmps[tmp_id] == -1:
# the identifier has been signalised but never assigned a value - probably error during processing
raise StandardError("Temporary identifier %s has been declared, but never assigned a value. Probably an error during processign of an appropriate FFT has happened. Please see the log" % (tmp_id, ))
return int(tmps[tmp_id])
else:
return int(identifier)
_re_find_001 = re.compile('<controlfield\\s+tag=("001"|\'001\')\\s*>\\s*(\\d*)\\s*</controlfield>', re.S)
def bibupload_pending_recids():
"""This function embed a bit of A.I. and is more a hack than an elegant
algorithm. It should be updated in case bibupload/bibsched are modified
in incompatible ways.
This function return the intbitset of all the records that are being
(or are scheduled to be) touched by other bibuploads.
"""
options = run_sql("""SELECT arguments FROM schTASK WHERE status<>'DONE' AND
proc='bibupload' AND (status='RUNNING' OR status='CONTINUING' OR
status='WAITING' OR status='SCHEDULED' OR status='ABOUT TO STOP' OR
status='ABOUT TO SLEEP')""")
ret = intbitset()
xmls = []
if options:
for arguments in options:
arguments = marshal.loads(arguments[0])
for argument in arguments[1:]:
if argument.startswith('/'):
# XMLs files are recognizable because they're absolute
# files...
xmls.append(argument)
for xmlfile in xmls:
# Let's grep for the 001
try:
xml = open(xmlfile).read()
ret += [int(group[1]) for group in _re_find_001.findall(xml)]
except:
continue
return ret
### bibupload engine functions:
def bibupload(record, opt_mode=None, opt_notimechange=0, oai_rec_id="", pretend=False,
tmp_ids=None, tmp_vers=None):
"""Main function: process a record and fit it in the tables
bibfmt, bibrec, bibrec_bibxxx, bibxxx with proper record
metadata.
Return (error_code, recID) of the processed record.
"""
if tmp_ids is None:
tmp_ids = {}
if tmp_vers is None:
tmp_vers = {}
if opt_mode == 'reference':
## NOTE: reference mode has been deprecated in favour of 'correct'
opt_mode = 'correct'
assert(opt_mode in CFG_BIBUPLOAD_OPT_MODES)
error = None
affected_tags = {}
original_record = {}
rec_old = {}
now = datetime.now() # will hold record creation/modification date
record_had_altered_bit = False
is_opt_mode_delete = False
# Extraction of the Record Id from 001, SYSNO or OAIID or DOI tags:
rec_id = retrieve_rec_id(record, opt_mode, pretend=pretend)
if rec_id == -1:
msg = " Failed: either the record already exists and insert was " \
"requested or the record does not exists and " \
"replace/correct/append has been used"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, -1, msg)
elif rec_id > 0:
write_message(" -Retrieve record ID (found %s): DONE." % rec_id, verbose=2)
(unique_p, msg) = check_record_doi_is_unique(rec_id, record)
if not unique_p:
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
if not record.has_key('001'):
# Found record ID by means of SYSNO or OAIID or DOI, and the
# input MARCXML buffer does not have this 001 tag, so we
# should add it now:
error = record_add_field(record, '001', controlfield_value=rec_id)
if error is None:
msg = " Failed: Error during adding the 001 controlfield " \
"to the record"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
else:
error = None
write_message(" -Added tag 001: DONE.", verbose=2)
write_message(" -Check if the xml marc file is already in the database: DONE" , verbose=2)
record_deleted_p = False
if opt_mode == 'insert' or \
(opt_mode == 'replace_or_insert') and rec_id is None:
insert_mode_p = True
# Insert the record into the bibrec databases to have a recordId
rec_id = create_new_record(pretend=pretend)
write_message(" -Creation of a new record id (%d): DONE" % rec_id, verbose=2)
# we add the record Id control field to the record
error = record_add_field(record, '001', controlfield_value=rec_id)
if error is None:
msg = " Failed: Error during adding the 001 controlfield " \
"to the record"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
else:
error = None
error = record_add_field(record, '005', controlfield_value=now.strftime("%Y%m%d%H%M%S.0"))
if error is None:
msg = " Failed: Error during adding to 005 controlfield to record"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
else:
error=None
elif opt_mode != 'insert':
insert_mode_p = False
# Update Mode
# Retrieve the old record to update
rec_old = get_record(rec_id)
record_had_altered_bit = record_get_field_values(rec_old, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4], CFG_OAI_PROVENANCE_ALTERED_SUBFIELD)
# Also save a copy to restore previous situation in case of errors
original_record = get_record(rec_id)
if rec_old is None:
msg = " Failed during the creation of the old record!"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
else:
write_message(" -Retrieve the old record to update: DONE", verbose=2)
# flag to check whether the revisions have been verified and patch generated.
# If revision verification failed, then we need to manually identify the affected tags
# and process them
revision_verified = False
rev_verifier = RevisionVerifier()
#check for revision conflicts before updating record
if record_has_field(record, '005') and not CFG_BIBUPLOAD_DISABLE_RECORD_REVISIONS:
write_message(" -Upload Record has 005. Verifying Revision", verbose=2)
try:
rev_res = rev_verifier.verify_revision(record, original_record, opt_mode)
if rev_res:
opt_mode = rev_res[0]
record = rev_res[1]
affected_tags = rev_res[2]
revision_verified = True
write_message(lambda: " -Patch record generated. Changing opt_mode to correct.\nPatch:\n%s " % record_xml_output(record), verbose=2)
else:
write_message(" -No Patch Record.", verbose=2)
except InvenioBibUploadUnchangedRecordError, err:
msg = " -ISSUE: %s" % err
write_message(msg, verbose=1, stream=sys.stderr)
write_message(msg, " Continuing anyway in case there are FFT or other tags")
except InvenioBibUploadConflictingRevisionsError, err:
msg = " -ERROR: Conflicting Revisions - %s" % err
write_message(msg, verbose=1, stream=sys.stderr)
submit_ticket_for_holding_pen(rec_id, err, "Conflicting Revisions. Inserting record into holding pen.")
insert_record_into_holding_pen(record, str(rec_id))
return (2, int(rec_id), msg)
except InvenioBibUploadInvalidRevisionError, err:
msg = " -ERROR: Invalid Revision - %s" % err
write_message(msg)
submit_ticket_for_holding_pen(rec_id, err, "Invalid Revisions. Inserting record into holding pen.")
insert_record_into_holding_pen(record, str(rec_id))
return (2, int(rec_id), msg)
except InvenioBibUploadMissing005Error, err:
msg = " -ERROR: Missing 005 - %s" % err
write_message(msg)
submit_ticket_for_holding_pen(rec_id, err, "Missing 005. Inserting record into holding pen.")
insert_record_into_holding_pen(record, str(rec_id))
return (2, int(rec_id), msg)
else:
write_message(" - No 005 Tag Present. Resuming normal flow.", verbose=2)
# dictionaries to temporarily hold original recs tag-fields
existing_tags = {}
retained_tags = {}
# in case of delete operation affected tags should be deleted in delete_bibrec_bibxxx
# but should not be updated again in STAGE 4
# utilising the below flag
is_opt_mode_delete = False
if not revision_verified:
# either 005 was not present or opt_mode was not correct/replace
# in this case we still need to find out affected tags to process
write_message(" - Missing 005 or opt_mode!=Replace/Correct.Revision Verifier not called.", verbose=2)
# Identify affected tags
if opt_mode == 'correct' or opt_mode == 'replace' or opt_mode == 'replace_or_insert':
rec_diff = rev_verifier.compare_records(record, original_record, opt_mode)
affected_tags = rev_verifier.retrieve_affected_tags_with_ind(rec_diff)
elif opt_mode == 'delete':
# populate an intermediate dictionary
# used in upcoming step related to 'delete' mode
is_opt_mode_delete = True
for tag, fields in original_record.iteritems():
existing_tags[tag] = [tag + (field[1] != ' ' and field[1] or '_') + (field[2] != ' ' and field[2] or '_') for field in fields]
elif opt_mode == 'append':
for tag, fields in record.iteritems():
if tag not in CFG_BIBUPLOAD_CONTROLFIELD_TAGS:
affected_tags[tag]=[(field[1], field[2]) for field in fields]
# In Replace mode, take over old strong tags if applicable:
if opt_mode == 'replace' or \
opt_mode == 'replace_or_insert':
copy_strong_tags_from_old_record(record, rec_old)
# Delete tags to correct in the record
if opt_mode == 'correct':
delete_tags_to_correct(record, rec_old)
write_message(" -Delete the old tags to correct in the old record: DONE",
verbose=2)
# Delete tags specified if in delete mode
if opt_mode == 'delete':
record = delete_tags(record, rec_old)
for tag, fields in record.iteritems():
retained_tags[tag] = [tag + (field[1] != ' ' and field[1] or '_') + (field[2] != ' ' and field[2] or '_') for field in fields]
#identify the tags that have been deleted
for tag in existing_tags.keys():
if tag not in retained_tags:
for item in existing_tags[tag]:
tag_to_add = item[0:3]
ind1, ind2 = item[3], item[4]
if tag_to_add in affected_tags and (ind1, ind2) not in affected_tags[tag_to_add]:
affected_tags[tag_to_add].append((ind1, ind2))
else:
affected_tags[tag_to_add] = [(ind1, ind2)]
else:
deleted = list(set(existing_tags[tag]) - set(retained_tags[tag]))
for item in deleted:
tag_to_add = item[0:3]
ind1, ind2 = item[3], item[4]
if tag_to_add in affected_tags and (ind1, ind2) not in affected_tags[tag_to_add]:
affected_tags[tag_to_add].append((ind1, ind2))
else:
affected_tags[tag_to_add] = [(ind1, ind2)]
write_message(" -Delete specified tags in the old record: DONE", verbose=2)
# Append new tag to the old record and update the new record with the old_record modified
if opt_mode == 'append' or opt_mode == 'correct':
record = append_new_tag_to_old_record(record, rec_old)
write_message(" -Append new tags to the old record: DONE", verbose=2)
write_message(" -Affected Tags found after comparing upload and original records: %s"%(str(affected_tags)), verbose=2)
# 005 tag should be added everytime the record is modified
# If an exiting record is modified, its 005 tag should be overwritten with a new revision value
if record.has_key('005'):
record_delete_field(record, '005')
write_message(" Deleted the existing 005 tag.", verbose=2)
last_revision = run_sql("SELECT MAX(job_date) FROM hstRECORD WHERE id_bibrec=%s", (rec_id, ))[0][0]
if last_revision and last_revision.strftime("%Y%m%d%H%M%S.0") == now.strftime("%Y%m%d%H%M%S.0"):
## We are updating the same record within the same seconds! It's less than
## the minimal granularity. Let's pause for 1 more second to take a breath :-)
time.sleep(1)
now = datetime.now()
error = record_add_field(record, '005', controlfield_value=now.strftime("%Y%m%d%H%M%S.0"))
if error is None:
write_message(" Failed: Error during adding to 005 controlfield to record", verbose=1, stream=sys.stderr)
return (1, int(rec_id))
else:
error=None
write_message(lambda: " -Added tag 005: DONE. "+ str(record_get_field_value(record, '005', '', '')), verbose=2)
# adding 005 to affected tags will delete the existing 005 entry
# and update with the latest timestamp.
if '005' not in affected_tags:
affected_tags['005'] = [(' ', ' ')]
write_message(" -Stage COMPLETED", verbose=2)
record_deleted_p = False
try:
if not record_is_valid(record):
msg = "ERROR: record is not valid"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, -1, msg)
# Have a look if we have FFT tags
write_message("Stage 2: Start (Process FFT tags if exist).", verbose=2)
record_had_FFT = False
if extract_tag_from_record(record, 'FFT') is not None:
record_had_FFT = True
if not writing_rights_p():
write_message(" Stage 2 failed: Error no rights to write fulltext files",
verbose=1, stream=sys.stderr)
task_update_status("ERROR")
sys.exit(1)
try:
record = elaborate_fft_tags(record, rec_id, opt_mode,
pretend=pretend, tmp_ids=tmp_ids,
tmp_vers=tmp_vers)
except Exception, e:
register_exception()
msg = " Stage 2 failed: Error while elaborating FFT tags: %s" % e
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
if record is None:
msg = " Stage 2 failed: Error while elaborating FFT tags"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
write_message(" -Stage COMPLETED", verbose=2)
else:
write_message(" -Stage NOT NEEDED", verbose=2)
# Have a look if we have FFT tags
write_message("Stage 2B: Start (Synchronize 8564 tags).", verbose=2)
if record_had_FFT or extract_tag_from_record(record, '856') is not None:
try:
record = synchronize_8564(rec_id, record, record_had_FFT, pretend=pretend)
# in case if FFT is in affected list make appropriate changes
if ('4', ' ') not in affected_tags.get('856', []):
if '856' not in affected_tags:
affected_tags['856'] = [('4', ' ')]
elif ('4', ' ') not in affected_tags['856']:
affected_tags['856'].append(('4', ' '))
write_message(" -Modified field list updated with FFT details: %s" % str(affected_tags), verbose=2)
except Exception, e:
register_exception(alert_admin=True)
msg = " Stage 2B failed: Error while synchronizing 8564 tags: %s" % e
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
if record is None:
msg = " Stage 2B failed: Error while synchronizing 8564 tags"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
write_message(" -Stage COMPLETED", verbose=2)
else:
write_message(" -Stage NOT NEEDED", verbose=2)
write_message("Stage 3: Start (Apply fields deletion requests).", verbose=2)
write_message(lambda: " Record before deletion:\n%s" % record_xml_output(record), verbose=9)
# remove fields with __DELETE_FIELDS__
# NOTE:creating a temporary deep copy of record for iteration to avoid RunTimeError
# RuntimeError due to change in dictionary size during iteration
tmp_rec = copy.deepcopy(record)
for tag in tmp_rec:
for data_tuple in record[tag]:
if (CFG_BIBUPLOAD_DELETE_CODE, CFG_BIBUPLOAD_DELETE_VALUE) in data_tuple[0]:
# delete the tag with particular indicator pairs from original record
record_delete_field(record, tag, data_tuple[1], data_tuple[2])
write_message(lambda: " Record after cleaning up fields to be deleted:\n%s" % record_xml_output(record), verbose=9)
# Update of the BibFmt
write_message("Stage 4: Start (Update bibfmt).", verbose=2)
updates_exist = not records_identical(record, original_record)
if updates_exist:
# if record_had_altered_bit, this must be set to true, since the
# record has been altered.
if record_had_altered_bit:
oai_provenance_fields = record_get_field_instances(record, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4])
for oai_provenance_field in oai_provenance_fields:
for i, (code, dummy_value) in enumerate(oai_provenance_field[0]):
if code == CFG_OAI_PROVENANCE_ALTERED_SUBFIELD:
oai_provenance_field[0][i] = (code, 'true')
tmp_indicators = (CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4])
if tmp_indicators not in affected_tags.get(CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3], []):
if CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3] not in affected_tags:
affected_tags[CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3]] = [tmp_indicators]
else:
affected_tags[CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3]].append(tmp_indicators)
write_message(lambda: " Updates exists:\n%s\n!=\n%s" % (record, original_record), verbose=9)
# format the single record as xml
rec_xml_new = record_xml_output(record)
# Update bibfmt with the format xm of this record
modification_date = time.strftime('%Y-%m-%d %H:%M:%S', time.strptime(record_get_field_value(record, '005'), '%Y%m%d%H%M%S.0'))
error = update_bibfmt_format(rec_id, rec_xml_new, 'xm', modification_date, pretend=pretend)
if error == 1:
msg = " Failed: error during update_bibfmt_format 'xm'"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
if CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE:
error = update_bibfmt_format(rec_id, marshal.dumps(record), 'recstruct', modification_date, pretend=pretend)
if error == 1:
msg = " Failed: error during update_bibfmt_format 'recstruct'"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
if not CFG_BIBUPLOAD_DISABLE_RECORD_REVISIONS:
# archive MARCXML format of this record for version history purposes:
error = archive_marcxml_for_history(rec_id, pretend=pretend)
if error == 1:
msg = " Failed to archive MARCXML for history"
write_message(msg, verbose=1, stream=sys.stderr)
return (1, int(rec_id), msg)
else:
write_message(" -Archived MARCXML for history: DONE", verbose=2)
# delete some formats like HB upon record change:
if updates_exist or record_had_FFT:
for format_to_delete in CFG_BIBUPLOAD_DELETE_FORMATS:
try:
delete_bibfmt_format(rec_id, format_to_delete, pretend=pretend)
except:
# OK, some formats like HB could not have been deleted, no big deal
pass
write_message(" -Stage COMPLETED", verbose=2)
# Update the database MetaData
write_message("Stage 5: Start (Update the database with the metadata).",
verbose=2)
if insert_mode_p:
update_database_with_metadata(record, rec_id, oai_rec_id, pretend=pretend)
elif opt_mode in ('replace', 'replace_or_insert',
'append', 'correct', 'delete') and updates_exist:
# now we clear all the rows from bibrec_bibxxx from the old
record_deleted_p = True
delete_bibrec_bibxxx(rec_old, rec_id, affected_tags, pretend=pretend)
# metadata update will insert tags that are available in affected_tags.
# but for delete, once the tags have been deleted from bibrec_bibxxx, they dont have to be inserted
# except for 005.
if is_opt_mode_delete:
tmp_affected_tags = copy.deepcopy(affected_tags)
for tag in tmp_affected_tags:
if tag != '005':
affected_tags.pop(tag)
write_message(" -Clean bibrec_bibxxx: DONE", verbose=2)
update_database_with_metadata(record, rec_id, oai_rec_id, affected_tags, pretend=pretend)
else:
write_message(" -Stage NOT NEEDED in mode %s" % opt_mode,
verbose=2)
write_message(" -Stage COMPLETED", verbose=2)
record_deleted_p = False
# Finally we update the bibrec table with the current date
write_message("Stage 6: Start (Update bibrec table with current date).",
verbose=2)
if opt_notimechange == 0 and (updates_exist or record_had_FFT):
bibrec_now = convert_datestruct_to_datetext(time.localtime())
write_message(" -Retrieved current localtime: DONE", verbose=2)
update_bibrec_date(bibrec_now, rec_id, insert_mode_p, pretend=pretend)
write_message(" -Stage COMPLETED", verbose=2)
else:
write_message(" -Stage NOT NEEDED", verbose=2)
# Increase statistics
if insert_mode_p:
stat['nb_records_inserted'] += 1
else:
stat['nb_records_updated'] += 1
# Upload of this record finish
write_message("Record "+str(rec_id)+" DONE", verbose=1)
return (0, int(rec_id), "")
finally:
if record_deleted_p:
## BibUpload has failed living the record deleted. We should
## back the original record then.
update_database_with_metadata(original_record, rec_id, oai_rec_id, pretend=pretend)
write_message(" Restored original record", verbose=1, stream=sys.stderr)
def record_is_valid(record):
"""
Check if the record is valid. Currently this simply checks if the record
has exactly one rec_id.
@param record: the record
@type record: recstruct
@return: True if the record is valid
@rtype: bool
"""
rec_ids = record_get_field_values(record, tag="001")
if len(rec_ids) != 1:
write_message(" The record is not valid: it has not a single rec_id: %s" % (rec_ids), stream=sys.stderr)
return False
return True
def find_record_ids_by_oai_id(oaiId):
"""
A method finding the records identifier provided the oai identifier
returns a list of identifiers matching a given oai identifier
"""
# Is this record already in invenio (matching by oaiid)
if oaiId:
recids = search_pattern(p=oaiId, f=CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG, m='e')
# Is this record already in invenio (matching by reportnumber i.e.
# particularly 037. Idea: to avoid doubbles insertions)
repnumber = oaiId.split(":")[-1]
if repnumber:
recids |= search_pattern(p = repnumber,
f = "reportnumber",
m = 'e' )
# Is this record already in invenio (matching by reportnumber i.e.
# particularly 037. Idea: to avoid double insertions)
repnumber = "arXiv:" + oaiId.split(":")[-1]
recids |= search_pattern(p = repnumber,
f = "reportnumber",
m = 'e' )
return recids
else:
return intbitset()
def bibupload_post_phase(record, mode=None, rec_id="", pretend=False,
tmp_ids=None, tmp_vers=None):
def _elaborate_tag(record, tag, fun):
if extract_tag_from_record(record, tag) is not None:
try:
record = fun()
except Exception, e:
register_exception()
write_message(" Stage failed: Error while elaborating %s tags: %s" % (tag, e),
verbose=1, stream=sys.stderr)
return (1, int(rec_id)) # TODO: ?
if record is None:
write_message(" Stage failed: Error while elaborating %s tags" % (tag, ),
verbose=1, stream=sys.stderr)
return (1, int(rec_id))
write_message(" -Stage COMPLETED", verbose=2)
else:
write_message(" -Stage NOT NEEDED", verbose=2)
if tmp_ids is None:
tmp_ids = {}
if tmp_vers is None:
tmp_vers = {}
_elaborate_tag(record, "BDR", lambda: elaborate_brt_tags(record, rec_id = rec_id,
mode = mode,
pretend = pretend,
tmp_ids = tmp_ids,
tmp_vers = tmp_vers))
_elaborate_tag(record, "BDM", lambda: elaborate_mit_tags(record, rec_id = rec_id,
mode = mode,
pretend = pretend,
tmp_ids = tmp_ids,
tmp_vers = tmp_vers))
def submit_ticket_for_holding_pen(rec_id, err, msg):
"""
Submit a ticket via BibCatalog to report about a record that has been put
into the Holding Pen.
@rec_id: the affected record
@err: the corresponding Exception
msg: verbose message
"""
from invenio import bibtask
from invenio.webuser import get_email_from_username, get_uid_from_email
user = task_get_task_param("user")
uid = None
if user:
try:
uid = get_uid_from_email(get_email_from_username(user))
except Exception, err:
write_message("WARNING: can't reliably retrieve uid for user %s: %s" % (user, err), stream=sys.stderr)
if check_bibcatalog():
text = """
%(msg)s found for record %(rec_id)s: %(err)s
See: <%(siteurl)s/record/edit/#state=edit&recid=%(rec_id)s>
BibUpload task information:
task_id: %(task_id)s
task_specific_name: %(task_specific_name)s
user: %(user)s
task_params: %(task_params)s
task_options: %(task_options)s""" % {
"msg": msg,
"rec_id": rec_id,
"err": err,
"siteurl": CFG_SITE_SECURE_URL,
"task_id": task_get_task_param("task_id"),
"task_specific_name": task_get_task_param("task_specific_name"),
"user": user,
"task_params": bibtask._TASK_PARAMS,
"task_options": bibtask._OPTIONS}
bibcatalog_system.ticket_submit(subject="%s: %s by %s" % (msg, rec_id, user), recordid=rec_id, text=text, queue=CFG_BIBUPLOAD_CONFLICTING_REVISION_TICKET_QUEUE, owner=uid)
def insert_record_into_holding_pen(record, oai_id, pretend=False):
query = "INSERT INTO bibHOLDINGPEN (oai_id, changeset_date, changeset_xml, id_bibrec) VALUES (%s, NOW(), %s, %s)"
xml_record = record_xml_output(record)
bibrec_ids = find_record_ids_by_oai_id(oai_id) # here determining the identifier of the record
if len(bibrec_ids) > 0:
bibrec_id = bibrec_ids.pop()
else:
# id not found by using the oai_id, let's use a wider search based
# on any information we might have.
bibrec_id = retrieve_rec_id(record, 'holdingpen', pretend=pretend)
if bibrec_id is None:
bibrec_id = 0
if not pretend:
run_sql(query, (oai_id, xml_record, bibrec_id))
# record_id is logged as 0! ( We are not inserting into the main database)
log_record_uploading(oai_id, task_get_task_param('task_id', 0), 0, 'H', pretend=pretend)
stat['nb_holdingpen'] += 1
def print_out_bibupload_statistics():
"""Print the statistics of the process"""
out = "Task stats: %(nb_input)d input records, %(nb_updated)d updated, " \
"%(nb_inserted)d inserted, %(nb_errors)d errors, %(nb_holdingpen)d inserted to holding pen. " \
"Time %(nb_sec).2f sec." % { \
'nb_input': stat['nb_records_to_upload'],
'nb_updated': stat['nb_records_updated'],
'nb_inserted': stat['nb_records_inserted'],
'nb_errors': stat['nb_errors'],
'nb_holdingpen': stat['nb_holdingpen'],
'nb_sec': time.time() - time.mktime(stat['exectime']) }
write_message(out)
def open_marc_file(path):
"""Open a file and return the data"""
try:
# open the file containing the marc document
marc_file = open(path, 'r')
marc = marc_file.read()
marc_file.close()
except IOError, erro:
write_message("Error: %s" % erro, verbose=1, stream=sys.stderr)
write_message("Exiting.", sys.stderr)
if erro.errno == 2:
# No such file or directory
# Not scary
task_update_status("CERROR")
else:
task_update_status("ERROR")
sys.exit(1)
return marc
def xml_marc_to_records(xml_marc):
"""create the records"""
# Creation of the records from the xml Marc in argument
recs = create_records(xml_marc, 1, 1)
if recs == []:
write_message("Error: Cannot parse MARCXML file.", verbose=1, stream=sys.stderr)
write_message("Exiting.", sys.stderr)
task_update_status("ERROR")
sys.exit(1)
elif recs[0][0] is None:
write_message("Error: MARCXML file has wrong format: %s" % recs,
verbose=1, stream=sys.stderr)
write_message("Exiting.", sys.stderr)
task_update_status("CERROR")
sys.exit(1)
else:
recs = map((lambda x:x[0]), recs)
return recs
def find_record_format(rec_id, bibformat):
"""Look whether record REC_ID is formatted in FORMAT,
i.e. whether FORMAT exists in the bibfmt table for this record.
Return the number of times it is formatted: 0 if not, 1 if yes,
2 if found more than once (should never occur).
"""
out = 0
query = """SELECT COUNT(*) FROM bibfmt WHERE id_bibrec=%s AND format=%s"""
params = (rec_id, bibformat)
res = []
res = run_sql(query, params)
out = res[0][0]
return out
def find_record_from_recid(rec_id):
"""
Try to find record in the database from the REC_ID number.
Return record ID if found, None otherwise.
"""
res = run_sql("SELECT id FROM bibrec WHERE id=%s",
(rec_id,))
if res:
return res[0][0]
else:
return None
def find_record_from_sysno(sysno):
"""
Try to find record in the database from the external SYSNO number.
Return record ID if found, None otherwise.
"""
bibxxx = 'bib'+CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[0:2]+'x'
bibrec_bibxxx = 'bibrec_' + bibxxx
res = run_sql("""SELECT bb.id_bibrec FROM %(bibrec_bibxxx)s AS bb,
%(bibxxx)s AS b WHERE b.tag=%%s AND b.value=%%s
AND bb.id_bibxxx=b.id""" % \
{'bibxxx': bibxxx,
'bibrec_bibxxx': bibrec_bibxxx},
(CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG, sysno,))
if res:
return res[0][0]
else:
return None
def find_records_from_extoaiid(extoaiid, extoaisrc=None):
"""
Try to find records in the database from the external EXTOAIID number.
Return list of record ID if found, None otherwise.
"""
assert(CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:5] == CFG_BIBUPLOAD_EXTERNAL_OAIID_PROVENANCE_TAG[:5])
bibxxx = 'bib'+CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[0:2]+'x'
bibrec_bibxxx = 'bibrec_' + bibxxx
write_message(' Looking for extoaiid="%s" with extoaisrc="%s"' % (extoaiid, extoaisrc), verbose=9)
id_bibrecs = intbitset(run_sql("""SELECT bb.id_bibrec FROM %(bibrec_bibxxx)s AS bb,
%(bibxxx)s AS b WHERE b.tag=%%s AND b.value=%%s
AND bb.id_bibxxx=b.id""" % \
{'bibxxx': bibxxx,
'bibrec_bibxxx': bibrec_bibxxx},
(CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG, extoaiid,)))
write_message(' Partially found %s for extoaiid="%s"' % (id_bibrecs, extoaiid), verbose=9)
ret = intbitset()
for id_bibrec in id_bibrecs:
record = get_record(id_bibrec)
instances = record_get_field_instances(record, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[0:3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4])
write_message(' recid %s -> instances "%s"' % (id_bibrec, instances), verbose=9)
for instance in instances:
this_extoaisrc = field_get_subfield_values(instance, CFG_BIBUPLOAD_EXTERNAL_OAIID_PROVENANCE_TAG[5])
this_extoaisrc = this_extoaisrc and this_extoaisrc[0] or None
this_extoaiid = field_get_subfield_values(instance, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[5])
this_extoaiid = this_extoaiid and this_extoaiid[0] or None
write_message(" this_extoaisrc -> %s, this_extoaiid -> %s" % (this_extoaisrc, this_extoaiid), verbose=9)
if this_extoaiid == extoaiid:
write_message(' recid %s -> provenance "%s"' % (id_bibrec, this_extoaisrc), verbose=9)
if this_extoaisrc == extoaisrc:
write_message('Found recid %s for extoaiid="%s" with provenance="%s"' % (id_bibrec, extoaiid, extoaisrc), verbose=9)
ret.add(id_bibrec)
break
if this_extoaisrc is None:
write_message('WARNING: Found recid %s for extoaiid="%s" that doesn\'t specify any provenance, while input record does.' % (id_bibrec, extoaiid), stream=sys.stderr)
if extoaisrc is None:
write_message('WARNING: Found recid %s for extoaiid="%s" that specify a provenance (%s), while input record does not have a provenance.' % (id_bibrec, extoaiid, this_extoaisrc), stream=sys.stderr)
return ret
def find_record_from_oaiid(oaiid):
"""
Try to find record in the database from the OAI ID number and OAI SRC.
Return record ID if found, None otherwise.
"""
bibxxx = 'bib'+CFG_OAI_ID_FIELD[0:2]+'x'
bibrec_bibxxx = 'bibrec_' + bibxxx
res = run_sql("""SELECT bb.id_bibrec FROM %(bibrec_bibxxx)s AS bb,
%(bibxxx)s AS b WHERE b.tag=%%s AND b.value=%%s
AND bb.id_bibxxx=b.id""" % \
{'bibxxx': bibxxx,
'bibrec_bibxxx': bibrec_bibxxx},
(CFG_OAI_ID_FIELD, oaiid,))
if res:
return res[0][0]
else:
return None
def find_record_from_doi(doi):
"""
Try to find record in the database from the given DOI.
Return record ID if found, None otherwise.
"""
bibxxx = 'bib02x'
bibrec_bibxxx = 'bibrec_' + bibxxx
res = run_sql("""SELECT bb.id_bibrec, bb.field_number
FROM %(bibrec_bibxxx)s AS bb, %(bibxxx)s AS b
WHERE b.tag=%%s AND b.value=%%s
AND bb.id_bibxxx=b.id""" % \
{'bibxxx': bibxxx,
'bibrec_bibxxx': bibrec_bibxxx},
('0247_a', doi,))
# For each of the result, make sure that it is really tagged as doi
for (id_bibrec, field_number) in res:
res = run_sql("""SELECT bb.id_bibrec
FROM %(bibrec_bibxxx)s AS bb, %(bibxxx)s AS b
WHERE b.tag=%%s AND b.value=%%s
AND bb.id_bibxxx=b.id and bb.field_number=%%s and bb.id_bibrec=%%s""" % \
{'bibxxx': bibxxx,
'bibrec_bibxxx': bibrec_bibxxx},
('0247_2', "doi", field_number, id_bibrec))
if res and res[0][0] == id_bibrec:
return res[0][0]
return None
def extract_tag_from_record(record, tag_number):
""" Extract the tag_number for record."""
# first step verify if the record is not already in the database
if record:
return record.get(tag_number, None)
return None
def retrieve_rec_id(record, opt_mode, pretend=False, post_phase = False):
"""Retrieve the record Id from a record by using tag 001 or SYSNO or OAI ID or DOI
tag. opt_mod is the desired mode.
@param post_phase Tells if we are calling this method in the postprocessing phase. If true, we accept presence of 001 fields even in the insert mode
@type post_phase boolean
"""
rec_id = None
# 1st step: we look for the tag 001
tag_001 = extract_tag_from_record(record, '001')
if tag_001 is not None:
# We extract the record ID from the tag
rec_id = tag_001[0][3]
# if we are in insert mode => error
if opt_mode == 'insert' and not post_phase:
write_message(" Failed: tag 001 found in the xml" \
" submitted, you should use the option replace," \
" correct or append to replace an existing" \
" record. (-h for help)",
verbose=1, stream=sys.stderr)
return -1
else:
# we found the rec id and we are not in insert mode => continue
# we try to match rec_id against the database:
if find_record_from_recid(rec_id) is not None:
# okay, 001 corresponds to some known record
return int(rec_id)
elif opt_mode in ('replace', 'replace_or_insert'):
if task_get_option('force'):
# we found the rec_id but it's not in the system and we are
# requested to replace records. Therefore we create on the fly
# a empty record allocating the recid.
write_message(" Warning: tag 001 found in the xml with"
" value %(rec_id)s, but rec_id %(rec_id)s does"
" not exist. Since the mode replace was"
" requested the rec_id %(rec_id)s is allocated"
" on-the-fly." % {"rec_id": rec_id},
stream=sys.stderr)
return create_new_record(rec_id=rec_id, pretend=pretend)
else:
# Since --force was not used we are going to raise an error
write_message(" Failed: tag 001 found in the xml"
" submitted with value %(rec_id)s. The"
" corresponding record however does not"
" exists. If you want to really create"
" such record, please use the --force"
" parameter when calling bibupload." % {
"rec_id": rec_id}, stream=sys.stderr)
return -1
else:
# The record doesn't exist yet. We shall have try to check
# the SYSNO or OAI or DOI id later.
write_message(" -Tag 001 value not found in database.",
verbose=9)
rec_id = None
else:
write_message(" -Tag 001 not found in the xml marc file.", verbose=9)
if rec_id is None:
# 2nd step we look for the SYSNO
sysnos = record_get_field_values(record,
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[0:3],
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[3:4] != "_" and \
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[3:4] or "",
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[4:5] != "_" and \
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[4:5] or "",
CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[5:6])
if sysnos:
sysno = sysnos[0] # there should be only one external SYSNO
write_message(" -Checking if SYSNO " + sysno + \
" exists in the database", verbose=9)
# try to find the corresponding rec id from the database
rec_id = find_record_from_sysno(sysno)
if rec_id is not None:
# rec_id found
pass
else:
# The record doesn't exist yet. We will try to check
# external and internal OAI ids later.
write_message(" -Tag SYSNO value not found in database.",
verbose=9)
rec_id = None
else:
write_message(" -Tag SYSNO not found in the xml marc file.",
verbose=9)
if rec_id is None:
# 2nd step we look for the external OAIID
extoai_fields = record_get_field_instances(record,
CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[0:3],
CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3:4] != "_" and \
CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3:4] or "",
CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4:5] != "_" and \
CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4:5] or "")
if extoai_fields:
for field in extoai_fields:
extoaiid = field_get_subfield_values(field, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[5:6])
extoaisrc = field_get_subfield_values(field, CFG_BIBUPLOAD_EXTERNAL_OAIID_PROVENANCE_TAG[5:6])
if extoaiid:
extoaiid = extoaiid[0]
if extoaisrc:
extoaisrc = extoaisrc[0]
else:
extoaisrc = None
write_message(" -Checking if EXTOAIID %s (%s) exists in the database" % (extoaiid, extoaisrc), verbose=9)
# try to find the corresponding rec id from the database
rec_ids = find_records_from_extoaiid(extoaiid, extoaisrc)
if rec_ids:
# rec_id found
rec_id = rec_ids.pop()
break
else:
# The record doesn't exist yet. We will try to check
# OAI id later.
write_message(" -Tag EXTOAIID value not found in database.",
verbose=9)
rec_id = None
else:
write_message(" -Tag EXTOAIID not found in the xml marc file.", verbose=9)
if rec_id is None:
# 4th step we look for the OAI ID
oaiidvalues = record_get_field_values(record,
CFG_OAI_ID_FIELD[0:3],
CFG_OAI_ID_FIELD[3:4] != "_" and \
CFG_OAI_ID_FIELD[3:4] or "",
CFG_OAI_ID_FIELD[4:5] != "_" and \
CFG_OAI_ID_FIELD[4:5] or "",
CFG_OAI_ID_FIELD[5:6])
if oaiidvalues:
oaiid = oaiidvalues[0] # there should be only one OAI ID
write_message(" -Check if local OAI ID " + oaiid + \
" exist in the database", verbose=9)
# try to find the corresponding rec id from the database
rec_id = find_record_from_oaiid(oaiid)
if rec_id is not None:
# rec_id found
pass
else:
write_message(" -Tag OAI ID value not found in database.",
verbose=9)
rec_id = None
else:
write_message(" -Tag SYSNO not found in the xml marc file.",
verbose=9)
if rec_id is None:
# 5th step we look for the DOI.
record_dois = record_extract_dois(record)
matching_recids = set()
if record_dois:
# try to find the corresponding rec id from the database
for record_doi in record_dois:
possible_recid = find_record_from_doi(record_doi)
if possible_recid:
matching_recids.add(possible_recid)
if len(matching_recids) > 1:
# Oops, this record refers to DOI existing in multiple records.
# Dunno which one to choose.
write_message(" Failed: Multiple records found in the" \
" database %s that match the DOI(s) in the input" \
" MARCXML %s" % (repr(matching_recids), repr(record_dois)),
verbose=1, stream=sys.stderr)
return -1
elif len(matching_recids) == 1:
rec_id = matching_recids.pop()
if opt_mode == 'insert':
write_message(" Failed: DOI tag matching record #%s found in the xml" \
" submitted, you should use the option replace," \
" correct or append to replace an existing" \
" record. (-h for help)" % rec_id,
verbose=1, stream=sys.stderr)
return -1
else:
write_message(" - Tag DOI value not found in database.",
verbose=9)
rec_id = None
else:
write_message(" -Tag DOI not found in the xml marc file.",
verbose=9)
# Now we should have detected rec_id from SYSNO or OAIID
# tags. (None otherwise.)
if rec_id:
if opt_mode == 'insert':
write_message(" Failed: Record found in the database," \
" you should use the option replace," \
" correct or append to replace an existing" \
" record. (-h for help)",
verbose=1, stream=sys.stderr)
return -1
else:
if opt_mode != 'insert' and \
opt_mode != 'replace_or_insert':
write_message(" Failed: Record not found in the database."\
" Please insert the file before updating it."\
" (-h for help)", verbose=1, stream=sys.stderr)
return -1
return rec_id and int(rec_id) or None
def check_record_doi_is_unique(rec_id, record):
"""
Check that DOI found in 'record' does not exist in any other
record than 'recid'.
Return (boolean, msg) where 'boolean' would be True if the DOI is
unique.
"""
record_dois = record_extract_dois(record)
if record_dois:
matching_recids = set()
for record_doi in record_dois:
possible_recid = find_record_from_doi(record_doi)
if possible_recid:
matching_recids.add(possible_recid)
if len(matching_recids) > 1:
# Oops, this record refers to DOI existing in multiple records.
msg = " Failed: Multiple records found in the" \
" database %s that match the DOI(s) in the input" \
" MARCXML %s" % (repr(matching_recids), repr(record_dois))
return (False, msg)
elif len(matching_recids) == 1:
matching_recid = matching_recids.pop()
if str(matching_recid) != str(rec_id):
# Oops, this record refers to DOI existing in a different record.
msg = " Failed: DOI(s) %s found in this record (#%s)" \
" already exist(s) in another other record (#%s)" % \
(repr(record_dois), rec_id, matching_recid)
return (False, msg)
return (True, "")
### Insert functions
def create_new_record(rec_id=None, pretend=False):
"""
Create new record in the database
@param rec_id: if specified the new record will have this rec_id.
@type rec_id: int
@return: the allocated rec_id
@rtype: int
@note: in case of errors will be returned None
"""
if rec_id is not None:
try:
rec_id = int(rec_id)
except (ValueError, TypeError), error:
write_message(" Error during the creation_new_record function: %s "
% error, verbose=1, stream=sys.stderr)
return None
if run_sql("SELECT id FROM bibrec WHERE id=%s", (rec_id, )):
write_message(" Error during the creation_new_record function: the requested rec_id %s already exists." % rec_id)
return None
if pretend:
if rec_id:
return rec_id
else:
return run_sql("SELECT max(id)+1 FROM bibrec")[0][0]
if rec_id is not None:
return run_sql("INSERT INTO bibrec (id, creation_date, modification_date) VALUES (%s, NOW(), NOW())", (rec_id, ))
else:
return run_sql("INSERT INTO bibrec (creation_date, modification_date) VALUES (NOW(), NOW())")
def insert_bibfmt(id_bibrec, marc, bibformat, modification_date='1970-01-01 00:00:00', pretend=False):
"""Insert the format in the table bibfmt"""
# compress the marc value
pickled_marc = compress(marc)
try:
time.strptime(modification_date, "%Y-%m-%d %H:%M:%S")
except ValueError:
modification_date = '1970-01-01 00:00:00'
query = """INSERT LOW_PRIORITY INTO bibfmt (id_bibrec, format, last_updated, value)
VALUES (%s, %s, %s, %s)"""
if not pretend:
row_id = run_sql(query, (id_bibrec, bibformat, modification_date, pickled_marc))
return row_id
else:
return 1
def insert_record_bibxxx(tag, value, pretend=False):
"""Insert the record into bibxxx"""
# determine into which table one should insert the record
table_name = 'bib'+tag[0:2]+'x'
# check if the tag, value combination exists in the table
query = """SELECT id,value FROM %s """ % table_name
query += """ WHERE tag=%s AND value=%s"""
params = (tag, value)
res = None
res = run_sql(query, params)
# Note: compare now the found values one by one and look for
# string binary equality (e.g. to respect lowercase/uppercase
# match), regardless of the charset etc settings. Ideally we
# could use a BINARY operator in the above SELECT statement, but
# we would have to check compatibility on various MySQLdb versions
# etc; this approach checks all matched values in Python, not in
# MySQL, which is less cool, but more conservative, so it should
# work better on most setups.
if res:
for row in res:
row_id = row[0]
row_value = row[1]
if row_value == value:
return (table_name, row_id)
# We got here only when the tag, value combination was not found,
# so it is now necessary to insert the tag, value combination into
# bibxxx table as new.
query = """INSERT INTO %s """ % table_name
query += """ (tag, value) values (%s , %s)"""
params = (tag, value)
if not pretend:
row_id = run_sql(query, params)
else:
return (table_name, 1)
return (table_name, row_id)
def insert_record_bibrec_bibxxx(table_name, id_bibxxx,
field_number, id_bibrec, pretend=False):
"""Insert the record into bibrec_bibxxx"""
# determine into which table one should insert the record
full_table_name = 'bibrec_'+ table_name
# insert the proper row into the table
query = """INSERT INTO %s """ % full_table_name
query += """(id_bibrec,id_bibxxx, field_number) values (%s , %s, %s)"""
params = (id_bibrec, id_bibxxx, field_number)
if not pretend:
res = run_sql(query, params)
else:
return 1
return res
def synchronize_8564(rec_id, record, record_had_FFT, pretend=False):
"""
Synchronize 8564_ tags and BibDocFile tables.
This function directly manipulate the record parameter.
@type rec_id: positive integer
@param rec_id: the record identifier.
@param record: the record structure as created by bibrecord.create_record
@type record_had_FFT: boolean
@param record_had_FFT: True if the incoming bibuploaded-record used FFT
@return: the manipulated record (which is also modified as a side effect)
"""
def merge_marc_into_bibdocfile(field, pretend=False):
"""
Internal function that reads a single field and stores its content
in BibDocFile tables.
@param field: the 8564_ field containing a BibDocFile URL.
"""
write_message('Merging field: %s' % (field, ), verbose=9)
url = field_get_subfield_values(field, 'u')[:1] or field_get_subfield_values(field, 'q')[:1]
description = field_get_subfield_values(field, 'y')[:1]
comment = field_get_subfield_values(field, 'z')[:1]
if url:
recid, docname, docformat = decompose_bibdocfile_url(url[0])
if recid != rec_id:
write_message("INFO: URL %s is not pointing to a fulltext owned by this record (%s)" % (url, recid), stream=sys.stderr)
else:
try:
bibdoc = BibRecDocs(recid).get_bibdoc(docname)
if description and not pretend:
bibdoc.set_description(description[0], docformat)
if comment and not pretend:
bibdoc.set_comment(comment[0], docformat)
except InvenioBibDocFileError:
## Apparently the referenced docname doesn't exist anymore.
## Too bad. Let's skip it.
write_message("WARNING: docname %s does not seem to exist for record %s. Has it been renamed outside FFT?" % (docname, recid), stream=sys.stderr)
def merge_bibdocfile_into_marc(field, subfields):
"""
Internal function that reads BibDocFile table entries referenced by
the URL in the given 8564_ field and integrate the given information
directly with the provided subfields.
@param field: the 8564_ field containing a BibDocFile URL.
@param subfields: the subfields corresponding to the BibDocFile URL
generated after BibDocFile tables.
"""
write_message('Merging subfields %s into field %s' % (subfields, field), verbose=9)
subfields = dict(subfields) ## We make a copy not to have side-effects
subfield_to_delete = []
for subfield_position, (code, value) in enumerate(field_get_subfield_instances(field)):
## For each subfield instance already existing...
if code in subfields:
## ...We substitute it with what is in BibDocFile tables
record_modify_subfield(record, '856', code, subfields[code],
subfield_position, field_position_global=field[4])
del subfields[code]
else:
## ...We delete it otherwise
subfield_to_delete.append(subfield_position)
subfield_to_delete.sort()
for counter, position in enumerate(subfield_to_delete):
## FIXME: Very hackish algorithm. Since deleting a subfield
## will alterate the position of following subfields, we
## are taking note of this and adjusting further position
## by using a counter.
record_delete_subfield_from(record, '856', position - counter,
field_position_global=field[4])
subfields = subfields.items()
subfields.sort()
for code, value in subfields:
## Let's add non-previously existing subfields
record_add_subfield_into(record, '856', code, value,
field_position_global=field[4])
def get_bibdocfile_managed_info():
"""
Internal function, returns a dictionary of
BibDocFile URL -> wanna-be subfields.
This information is retrieved from internal BibDoc
structures rather than from input MARC XML files
@rtype: mapping
@return: BibDocFile URL -> wanna-be subfields dictionary
"""
ret = {}
bibrecdocs = BibRecDocs(rec_id)
latest_files = bibrecdocs.list_latest_files(list_hidden=False)
for afile in latest_files:
url = afile.get_url()
ret[url] = {'u': url}
description = afile.get_description()
comment = afile.get_comment()
subformat = afile.get_subformat()
if description:
ret[url]['y'] = description
if comment:
ret[url]['z'] = comment
if subformat:
ret[url]['x'] = subformat
return ret
write_message("Synchronizing MARC of recid '%s' with:\n%s" % (rec_id, record), verbose=9)
tags856s = record_get_field_instances(record, '856', '%', '%')
write_message("Original 856%% instances: %s" % tags856s, verbose=9)
tags8564s_to_add = get_bibdocfile_managed_info()
write_message("BibDocFile instances: %s" % tags8564s_to_add, verbose=9)
positions_tags8564s_to_remove = []
for local_position, field in enumerate(tags856s):
if field[1] == '4' and field[2] == ' ':
write_message('Analysing %s' % (field, ), verbose=9)
for url in field_get_subfield_values(field, 'u') + field_get_subfield_values(field, 'q'):
if url in tags8564s_to_add:
# there exists a link in the MARC of the record and the connection exists in BibDoc tables
if record_had_FFT:
merge_bibdocfile_into_marc(field, tags8564s_to_add[url])
else:
merge_marc_into_bibdocfile(field, pretend=pretend)
del tags8564s_to_add[url]
break
elif bibdocfile_url_p(url) and decompose_bibdocfile_url(url)[0] == rec_id:
# The link exists and is potentially correct-looking link to a document
# moreover, it refers to current record id ... but it does not exist in
# internal BibDoc structures. This could have happen in the case of renaming a document
# or its removal. In both cases we have to remove link... a new one will be created
positions_tags8564s_to_remove.append(local_position)
write_message("%s to be deleted and re-synchronized" % (field, ), verbose=9)
break
record_delete_fields(record, '856', positions_tags8564s_to_remove)
tags8564s_to_add = tags8564s_to_add.values()
tags8564s_to_add.sort()
for subfields in tags8564s_to_add:
subfields = subfields.items()
subfields.sort()
record_add_field(record, '856', '4', ' ', subfields=subfields)
write_message('Final record: %s' % record, verbose=9)
return record
def _get_subfield_value(field, subfield_code, default=None):
res = field_get_subfield_values(field, subfield_code)
if res != [] and res != None:
return res[0]
else:
return default
def elaborate_mit_tags(record, rec_id, mode, pretend = False, tmp_ids = {},
tmp_vers = {}):
"""
Uploading MoreInfo -> BDM tags
"""
tuple_list = extract_tag_from_record(record, 'BDM')
# Now gathering information from BDR tags - to be processed later
write_message("Processing BDM entries of the record ")
recordDocs = BibRecDocs(rec_id)
if tuple_list:
for mit in record_get_field_instances(record, 'BDM', ' ', ' '):
relation_id = _get_subfield_value(mit, "r")
bibdoc_id = _get_subfield_value(mit, "i")
# checking for a possibly temporary ID
if not (bibdoc_id is None):
bibdoc_id = resolve_identifier(tmp_ids, bibdoc_id)
bibdoc_ver = _get_subfield_value(mit, "v")
if not (bibdoc_ver is None):
bibdoc_ver = resolve_identifier(tmp_vers, bibdoc_ver)
bibdoc_name = _get_subfield_value(mit, "n")
bibdoc_fmt = _get_subfield_value(mit, "f")
moreinfo_str = _get_subfield_value(mit, "m")
if bibdoc_id == None:
if bibdoc_name == None:
raise StandardError("Incorrect relation. Neither name nor identifier of the first obejct has been specified")
else:
# retrieving the ID based on the document name (inside current record)
# The document is attached to current record.
try:
bibdoc_id = recordDocs.get_docid(bibdoc_name)
except:
raise StandardError("BibDoc of a name %s does not exist within a record" % (bibdoc_name, ))
else:
if bibdoc_name != None:
write_message("Warning: both name and id of the first document of a relation have been specified. Ignoring the name")
if (moreinfo_str is None or mode in ("replace", "correct")) and (not pretend):
MoreInfo(docid=bibdoc_id , version = bibdoc_ver,
docformat = bibdoc_fmt, relation = relation_id).delete()
if (not moreinfo_str is None) and (not pretend):
MoreInfo.create_from_serialised(moreinfo_str,
docid=bibdoc_id,
version = bibdoc_ver,
docformat = bibdoc_fmt,
relation = relation_id)
return record
def elaborate_brt_tags(record, rec_id, mode, pretend=False, tmp_ids = {}, tmp_vers = {}):
"""
Process BDR tags describing relations between existing objects
"""
tuple_list = extract_tag_from_record(record, 'BDR')
# Now gathering information from BDR tags - to be processed later
relations_to_create = []
write_message("Processing BDR entries of the record ")
recordDocs = BibRecDocs(rec_id) #TODO: check what happens if there is no record yet ! Will the class represent an empty set?
if tuple_list:
for brt in record_get_field_instances(record, 'BDR', ' ', ' '):
relation_id = _get_subfield_value(brt, "r")
bibdoc1_id = None
bibdoc1_name = None
bibdoc1_ver = None
bibdoc1_fmt = None
bibdoc2_id = None
bibdoc2_name = None
bibdoc2_ver = None
bibdoc2_fmt = None
if not relation_id:
bibdoc1_id = _get_subfield_value(brt, "i")
bibdoc1_name = _get_subfield_value(brt, "n")
if bibdoc1_id == None:
if bibdoc1_name == None:
raise StandardError("Incorrect relation. Neither name nor identifier of the first obejct has been specified")
else:
# retrieving the ID based on the document name (inside current record)
# The document is attached to current record.
try:
bibdoc1_id = recordDocs.get_docid(bibdoc1_name)
except:
raise StandardError("BibDoc of a name %s does not exist within a record" % \
(bibdoc1_name, ))
else:
# resolving temporary identifier
bibdoc1_id = resolve_identifier(tmp_ids, bibdoc1_id)
if bibdoc1_name != None:
write_message("Warning: both name and id of the first document of a relation have been specified. Ignoring the name")
bibdoc1_ver = _get_subfield_value(brt, "v")
if not (bibdoc1_ver is None):
bibdoc1_ver = resolve_identifier(tmp_vers, bibdoc1_ver)
bibdoc1_fmt = _get_subfield_value(brt, "f")
bibdoc2_id = _get_subfield_value(brt, "j")
bibdoc2_name = _get_subfield_value(brt, "o")
if bibdoc2_id == None:
if bibdoc2_name == None:
raise StandardError("Incorrect relation. Neither name nor identifier of the second obejct has been specified")
else:
# retrieving the ID based on the document name (inside current record)
# The document is attached to current record.
try:
bibdoc2_id = recordDocs.get_docid(bibdoc2_name)
except:
raise StandardError("BibDoc of a name %s does not exist within a record" % (bibdoc2_name, ))
else:
bibdoc2_id = resolve_identifier(tmp_ids, bibdoc2_id)
if bibdoc2_name != None:
write_message("Warning: both name and id of the first document of a relation have been specified. Ignoring the name")
bibdoc2_ver = _get_subfield_value(brt, "w")
if not (bibdoc2_ver is None):
bibdoc2_ver = resolve_identifier(tmp_vers, bibdoc2_ver)
bibdoc2_fmt = _get_subfield_value(brt, "g")
control_command = _get_subfield_value(brt, "d")
relation_type = _get_subfield_value(brt, "t")
if not relation_type and not relation_id:
raise StandardError("The relation type must be specified")
more_info = _get_subfield_value(brt, "m")
# the relation id might be specified in the case of updating
# MoreInfo table instead of other fields
rel_obj = None
if not relation_id:
rels = BibRelation.get_relations(rel_type = relation_type,
bibdoc1_id = bibdoc1_id,
bibdoc2_id = bibdoc2_id,
bibdoc1_ver = bibdoc1_ver,
bibdoc2_ver = bibdoc2_ver,
bibdoc1_fmt = bibdoc1_fmt,
bibdoc2_fmt = bibdoc2_fmt)
if len(rels) > 0:
rel_obj = rels[0]
relation_id = rel_obj.id
else:
rel_obj = BibRelation(rel_id=relation_id)
relations_to_create.append((relation_id, bibdoc1_id, bibdoc1_ver,
bibdoc1_fmt, bibdoc2_id, bibdoc2_ver,
bibdoc2_fmt, relation_type, more_info,
rel_obj, control_command))
record_delete_field(record, 'BDR', ' ', ' ')
if mode in ("insert", "replace_or_insert", "append", "correct", "replace"):
# now creating relations between objects based on the data
if not pretend:
for (relation_id, bibdoc1_id, bibdoc1_ver, bibdoc1_fmt,
bibdoc2_id, bibdoc2_ver, bibdoc2_fmt, rel_type,
more_info, rel_obj, control_command) in relations_to_create:
if rel_obj == None:
rel_obj = BibRelation.create(bibdoc1_id = bibdoc1_id,
bibdoc1_ver = bibdoc1_ver,
bibdoc1_fmt = bibdoc1_fmt,
bibdoc2_id = bibdoc2_id,
bibdoc2_ver = bibdoc2_ver,
bibdoc2_fmt = bibdoc2_fmt,
rel_type = rel_type)
relation_id = rel_obj.id
if mode in ("replace"):
# Clearing existing MoreInfo content
rel_obj.get_more_info().delete()
if more_info:
MoreInfo.create_from_serialised(more_info, relation = relation_id)
if control_command == "DELETE":
rel_obj.delete()
else:
write_message("BDR tag is not processed in the %s mode" % (mode, ))
return record
def elaborate_fft_tags(record, rec_id, mode, pretend=False,
tmp_ids = {}, tmp_vers = {}):
"""
Process FFT tags that should contain $a with file pathes or URLs
to get the fulltext from. This function enriches record with
proper 8564 URL tags, downloads fulltext files and stores them
into var/data structure where appropriate.
CFG_BIBUPLOAD_WGET_SLEEP_TIME defines time to sleep in seconds in
between URL downloads.
Note: if an FFT tag contains multiple $a subfields, we upload them
into different 856 URL tags in the metadata. See regression test
case test_multiple_fft_insert_via_http().
"""
# Let's define some handy sub procedure.
def _add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, modification_date, pretend=False):
"""Adds a new format for a given bibdoc. Returns True when everything's fine."""
write_message('Add new format to %s url: %s, format: %s, docname: %s, doctype: %s, newname: %s, description: %s, comment: %s, flags: %s, modification_date: %s' % (repr(bibdoc), url, docformat, docname, doctype, newname, description, comment, flags, modification_date), verbose=9)
try:
if not url: # Not requesting a new url. Just updating comment & description
return _update_description_and_comment(bibdoc, docname, docformat, description, comment, flags, pretend=pretend)
try:
if not pretend:
bibdoc.add_file_new_format(url, description=description, comment=comment, flags=flags, modification_date=modification_date)
except StandardError, e:
write_message("('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') not inserted because format already exists (%s)." % (url, docformat, docname, doctype, newname, description, comment, flags, modification_date, e), stream=sys.stderr)
raise
except Exception, e:
write_message("Error in adding '%s' as a new format because of: %s" % (url, e), stream=sys.stderr)
raise
return True
def _add_new_version(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, modification_date, pretend=False):
"""Adds a new version for a given bibdoc. Returns True when everything's fine."""
write_message('Add new version to %s url: %s, format: %s, docname: %s, doctype: %s, newname: %s, description: %s, comment: %s, flags: %s' % (repr(bibdoc), url, docformat, docname, doctype, newname, description, comment, flags))
try:
if not url:
return _update_description_and_comment(bibdoc, docname, docformat, description, comment, flags, pretend=pretend)
try:
if not pretend:
bibdoc.add_file_new_version(url, description=description, comment=comment, flags=flags, modification_date=modification_date)
except StandardError, e:
write_message("('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') not inserted because '%s'." % (url, docformat, docname, doctype, newname, description, comment, flags, modification_date, e), stream=sys.stderr)
raise
except Exception, e:
write_message("Error in adding '%s' as a new version because of: %s" % (url, e), stream=sys.stderr)
raise
return True
def _update_description_and_comment(bibdoc, docname, docformat, description, comment, flags, pretend=False):
"""Directly update comments and descriptions."""
write_message('Just updating description and comment for %s with format %s with description %s, comment %s and flags %s' % (docname, docformat, description, comment, flags), verbose=9)
try:
if not pretend:
bibdoc.set_description(description, docformat)
bibdoc.set_comment(comment, docformat)
for flag in CFG_BIBDOCFILE_AVAILABLE_FLAGS:
if flag in flags:
bibdoc.set_flag(flag, docformat)
else:
bibdoc.unset_flag(flag, docformat)
except StandardError, e:
write_message("('%s', '%s', '%s', '%s', '%s') description and comment not updated because '%s'." % (docname, docformat, description, comment, flags, e))
raise
return True
def _process_document_moreinfos(more_infos, docname, version, docformat, mode):
if not mode in ('correct', 'append', 'replace_or_insert', 'replace', 'correct', 'insert'):
print "exited because the mode is incorrect"
return
brd = BibRecDocs(rec_id)
docid = None
try:
docid = brd.get_docid(docname)
except:
raise StandardError("MoreInfo: No document of a given name associated with the record")
if not version:
# We have to retrieve the most recent version ...
version = brd.get_bibdoc(docname).get_latest_version()
doc_moreinfo_s, version_moreinfo_s, version_format_moreinfo_s, format_moreinfo_s = more_infos
if mode in ("replace", "replace_or_insert"):
if doc_moreinfo_s: #only if specified, otherwise do not touch
MoreInfo(docid = docid).delete()
if format_moreinfo_s: #only if specified... otherwise do not touch
MoreInfo(docid = docid, docformat = docformat).delete()
if not doc_moreinfo_s is None:
MoreInfo.create_from_serialised(ser_str = doc_moreinfo_s, docid = docid)
if not version_moreinfo_s is None:
MoreInfo.create_from_serialised(ser_str = version_moreinfo_s,
docid = docid, version = version)
if not version_format_moreinfo_s is None:
MoreInfo.create_from_serialised(ser_str = version_format_moreinfo_s,
docid = docid, version = version,
docformat = docformat)
if not format_moreinfo_s is None:
MoreInfo.create_from_serialised(ser_str = format_moreinfo_s,
docid = docid, docformat = docformat)
if mode == 'delete':
raise StandardError('FFT tag specified but bibupload executed in --delete mode')
tuple_list = extract_tag_from_record(record, 'FFT')
if tuple_list: # FFT Tags analysis
write_message("FFTs: "+str(tuple_list), verbose=9)
docs = {} # docnames and their data
for fft in record_get_field_instances(record, 'FFT', ' ', ' '):
# Very first, we retrieve the potentially temporary odentifiers...
#even if the rest fails, we should include them in teh dictionary
version = _get_subfield_value(fft, 'v', '')
# checking if version is temporary... if so, filling a different varaible
is_tmp_ver, bibdoc_tmpver = parse_identifier(version)
if is_tmp_ver:
version = None
else:
bibdoc_tmpver = None
if not version: #treating cases of empty string etc...
version = None
bibdoc_tmpid = field_get_subfield_values(fft, 'i')
if bibdoc_tmpid:
bibdoc_tmpid = bibdoc_tmpid[0]
else:
bibdoc_tmpid
is_tmp_id, bibdoc_tmpid = parse_identifier(bibdoc_tmpid)
if not is_tmp_id:
bibdoc_tmpid = None
# In the case of having temporary id's, we dont resolve them yet but signaklise that they have been used
# value -1 means that identifier has been declared but not assigned a value yet
if bibdoc_tmpid:
if bibdoc_tmpid in tmp_ids:
write_message("WARNING: the temporary identifier %s has been declared more than once. Ignoring the second occurance" % (bibdoc_tmpid, ))
else:
tmp_ids[bibdoc_tmpid] = -1
if bibdoc_tmpver:
if bibdoc_tmpver in tmp_vers:
write_message("WARNING: the temporary version identifier %s has been declared more than once. Ignoring the second occurance" % (bibdoc_tmpver, ))
else:
tmp_vers[bibdoc_tmpver] = -1
# Let's discover the type of the document
# This is a legacy field and will not be enforced any particular
# check on it.
doctype = _get_subfield_value(fft, 't', 'Main') #Default is Main
# Let's discover the url.
url = field_get_subfield_values(fft, 'a')
if url:
url = url[0]
try:
check_valid_url(url)
except StandardError, e:
raise StandardError, "fft '%s' specifies in $a a location ('%s') with problems: %s" % (fft, url, e)
else:
url = ''
#TODO: a lot of code can be compactified using similar syntax ... should be more readable on the longer scale
# maybe right side expressions look a bit cryptic, but the elaborate_fft function would be much clearer
if mode == 'correct' and doctype != 'FIX-MARC':
arg2 = ""
else:
arg2 = KEEP_OLD_VALUE
description = _get_subfield_value(fft, 'd', arg2)
# Let's discover the description
# description = field_get_subfield_values(fft, 'd')
# if description != []:
# description = description[0]
# else:
# if mode == 'correct' and doctype != 'FIX-MARC':
## If the user require to correct, and do not specify
## a description this means she really want to
## modify the description.
# description = ''
# else:
# description = KEEP_OLD_VALUE
# Let's discover the desired docname to be created/altered
name = field_get_subfield_values(fft, 'n')
if name:
## Let's remove undesired extensions
name = file_strip_ext(name[0] + '.pdf')
else:
if url:
name = get_docname_from_url(url)
elif mode != 'correct' and doctype != 'FIX-MARC':
raise StandardError, "Warning: fft '%s' doesn't specifies either a location in $a or a docname in $n" % str(fft)
else:
continue
# Let's discover the desired new docname in case we want to change it
newname = field_get_subfield_values(fft, 'm')
if newname:
newname = file_strip_ext(newname[0] + '.pdf')
else:
newname = name
# Let's discover the desired format
docformat = field_get_subfield_values(fft, 'f')
if docformat:
docformat = normalize_format(docformat[0])
else:
if url:
docformat = guess_format_from_url(url)
else:
docformat = ""
# Let's discover the icon
icon = field_get_subfield_values(fft, 'x')
if icon != []:
icon = icon[0]
if icon != KEEP_OLD_VALUE:
try:
check_valid_url(icon)
except StandardError, e:
raise StandardError, "fft '%s' specifies in $x an icon ('%s') with problems: %s" % (fft, icon, e)
else:
icon = ''
# Let's discover the comment
comment = field_get_subfield_values(fft, 'z')
if comment != []:
comment = comment[0]
else:
if mode == 'correct' and doctype != 'FIX-MARC':
## See comment on description
comment = ''
else:
comment = KEEP_OLD_VALUE
# Let's discover the restriction
restriction = field_get_subfield_values(fft, 'r')
if restriction != []:
restriction = restriction[0]
else:
if mode == 'correct' and doctype != 'FIX-MARC':
## See comment on description
restriction = ''
else:
restriction = KEEP_OLD_VALUE
document_moreinfo = _get_subfield_value(fft, 'w')
version_moreinfo = _get_subfield_value(fft, 'p')
version_format_moreinfo = _get_subfield_value(fft, 'b')
format_moreinfo = _get_subfield_value(fft, 'u')
# Let's discover the timestamp of the file (if any)
timestamp = field_get_subfield_values(fft, 's')
if timestamp:
try:
timestamp = datetime(*(time.strptime(timestamp[0], "%Y-%m-%d %H:%M:%S")[:6]))
except ValueError:
write_message('Warning: The timestamp is not in a good format, thus will be ignored. The format should be YYYY-MM-DD HH:MM:SS')
timestamp = ''
else:
timestamp = ''
flags = field_get_subfield_values(fft, 'o')
for flag in flags:
if flag not in CFG_BIBDOCFILE_AVAILABLE_FLAGS:
raise StandardError, "fft '%s' specifies a non available flag: %s" % (fft, flag)
if docs.has_key(name): # new format considered
(doctype2, newname2, restriction2, version2, urls, dummybibdoc_moreinfos2, dummybibdoc_tmpid2, dummybibdoc_tmpver2 ) = docs[name]
if doctype2 != doctype:
raise StandardError, "fft '%s' specifies a different doctype from previous fft with docname '%s'" % (str(fft), name)
if newname2 != newname:
raise StandardError, "fft '%s' specifies a different newname from previous fft with docname '%s'" % (str(fft), name)
if restriction2 != restriction:
raise StandardError, "fft '%s' specifies a different restriction from previous fft with docname '%s'" % (str(fft), name)
if version2 != version:
raise StandardError, "fft '%s' specifies a different version than the previous fft with docname '%s'" % (str(fft), name)
for (dummyurl2, format2, dummydescription2, dummycomment2, dummyflags2, dummytimestamp2) in urls:
if docformat == format2:
raise StandardError, "fft '%s' specifies a second file '%s' with the same format '%s' from previous fft with docname '%s'" % (str(fft), url, docformat, name)
if url or docformat:
urls.append((url, docformat, description, comment, flags, timestamp))
if icon:
urls.append((icon, icon[len(file_strip_ext(icon)):] + ';icon', description, comment, flags, timestamp))
else:
if url or docformat:
docs[name] = (doctype, newname, restriction, version, [(url, docformat, description, comment, flags, timestamp)], [document_moreinfo, version_moreinfo, version_format_moreinfo, format_moreinfo], bibdoc_tmpid, bibdoc_tmpver)
if icon:
docs[name][4].append((icon, icon[len(file_strip_ext(icon)):] + ';icon', description, comment, flags, timestamp))
elif icon:
docs[name] = (doctype, newname, restriction, version, [(icon, icon[len(file_strip_ext(icon)):] + ';icon', description, comment, flags, timestamp)], [document_moreinfo, version_moreinfo, version_format_moreinfo, format_moreinfo], bibdoc_tmpid, bibdoc_tmpver)
else:
docs[name] = (doctype, newname, restriction, version, [], [document_moreinfo, version_moreinfo, version_format_moreinfo, format_moreinfo], bibdoc_tmpid, bibdoc_tmpver)
write_message('Result of FFT analysis:\n\tDocs: %s' % (docs,), verbose=9)
# Let's remove all FFT tags
record_delete_field(record, 'FFT', ' ', ' ')
# Preprocessed data elaboration
bibrecdocs = BibRecDocs(rec_id)
## Let's pre-download all the URLs to see if, in case of mode 'correct' or 'append'
## we can avoid creating a new revision.
for docname, (doctype, newname, restriction, version, urls, more_infos, bibdoc_tmpid, bibdoc_tmpver ) in docs.items():
downloaded_urls = []
try:
bibdoc = bibrecdocs.get_bibdoc(docname)
except InvenioBibDocFileError:
## A bibdoc with the given docname does not exists.
## So there is no chance we are going to revise an existing
## format with an identical file :-)
bibdoc = None
new_revision_needed = False
for url, docformat, description, comment, flags, timestamp in urls:
if url:
try:
downloaded_url = download_url(url, docformat)
write_message("%s saved into %s" % (url, downloaded_url), verbose=9)
except Exception, err:
write_message("Error in downloading '%s' because of: %s" % (url, err), stream=sys.stderr)
raise
if mode == 'correct' and bibdoc is not None and not new_revision_needed:
downloaded_urls.append((downloaded_url, docformat, description, comment, flags, timestamp))
if not bibrecdocs.check_file_exists(downloaded_url, docformat):
new_revision_needed = True
else:
write_message("WARNING: %s is already attached to bibdoc %s for recid %s" % (url, docname, rec_id), stream=sys.stderr)
elif mode == 'append' and bibdoc is not None:
if not bibrecdocs.check_file_exists(downloaded_url, docformat):
downloaded_urls.append((downloaded_url, docformat, description, comment, flags, timestamp))
else:
write_message("WARNING: %s is already attached to bibdoc %s for recid %s" % (url, docname, rec_id), stream=sys.stderr)
else:
downloaded_urls.append((downloaded_url, docformat, description, comment, flags, timestamp))
else:
downloaded_urls.append(('', docformat, description, comment, flags, timestamp))
if mode == 'correct' and bibdoc is not None and not new_revision_needed:
## Since we don't need a new revision (because all the files
## that are being uploaded are different)
## we can simply remove the urls but keep the other information
write_message("No need to add a new revision for docname %s for recid %s" % (docname, rec_id), verbose=2)
docs[docname] = (doctype, newname, restriction, version, [('', docformat, description, comment, flags, timestamp) for (dummy, docformat, description, comment, flags, timestamp) in downloaded_urls], more_infos, bibdoc_tmpid, bibdoc_tmpver)
for downloaded_url, dummy, dummy, dummy, dummy, dummy in downloaded_urls:
## Let's free up some space :-)
if downloaded_url and os.path.exists(downloaded_url):
os.remove(downloaded_url)
else:
if downloaded_urls or mode != 'append':
docs[docname] = (doctype, newname, restriction, version, downloaded_urls, more_infos, bibdoc_tmpid, bibdoc_tmpver)
else:
## In case we are in append mode and there are no urls to append
## we discard the whole FFT
del docs[docname]
if mode == 'replace': # First we erase previous bibdocs
if not pretend:
for bibdoc in bibrecdocs.list_bibdocs():
bibdoc.delete()
bibrecdocs.build_bibdoc_list()
for docname, (doctype, newname, restriction, version, urls, more_infos, bibdoc_tmpid, bibdoc_tmpver) in docs.iteritems():
write_message("Elaborating olddocname: '%s', newdocname: '%s', doctype: '%s', restriction: '%s', urls: '%s', mode: '%s'" % (docname, newname, doctype, restriction, urls, mode), verbose=9)
if mode in ('insert', 'replace'): # new bibdocs, new docnames, new marc
if newname in bibrecdocs.get_bibdoc_names():
write_message("('%s', '%s') not inserted because docname already exists." % (newname, urls), stream=sys.stderr)
raise StandardError("('%s', '%s') not inserted because docname already exists." % (newname, urls), stream=sys.stderr)
try:
if not pretend:
bibdoc = bibrecdocs.add_bibdoc(doctype, newname)
bibdoc.set_status(restriction)
else:
bibdoc = None
except Exception, e:
write_message("('%s', '%s', '%s') not inserted because: '%s'." % (doctype, newname, urls, e), stream=sys.stderr)
raise e
for (url, docformat, description, comment, flags, timestamp) in urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp, pretend=pretend))
elif mode == 'replace_or_insert': # to be thought as correct_or_insert
for bibdoc in bibrecdocs.list_bibdocs():
brd = BibRecDocs(rec_id)
dn = brd.get_docname(bibdoc.id)
if dn == docname:
if doctype not in ('PURGE', 'DELETE', 'EXPUNGE', 'REVERT', 'FIX-ALL', 'FIX-MARC', 'DELETE-FILE'):
if newname != docname:
try:
if not pretend:
bibrecdocs.change_name(newname = newname, docid = bibdoc.id)
## Let's refresh the list of bibdocs.
bibrecdocs.build_bibdoc_list()
except StandardError, e:
write_message(e, stream=sys.stderr)
raise
found_bibdoc = False
for bibdoc in bibrecdocs.list_bibdocs():
brd = BibRecDocs(rec_id)
dn = brd.get_docname(bibdoc.id)
if dn == newname:
found_bibdoc = True
if doctype == 'PURGE':
if not pretend:
bibdoc.purge()
elif doctype == 'DELETE':
if not pretend:
bibdoc.delete()
elif doctype == 'EXPUNGE':
if not pretend:
bibdoc.expunge()
elif doctype == 'FIX-ALL':
if not pretend:
bibrecdocs.fix(docname)
elif doctype == 'FIX-MARC':
pass
elif doctype == 'DELETE-FILE':
if urls:
for (url, docformat, description, comment, flags, timestamp) in urls:
if not pretend:
bibdoc.delete_file(docformat, version)
elif doctype == 'REVERT':
try:
if not pretend:
bibdoc.revert(version)
except Exception, e:
write_message('(%s, %s) not correctly reverted: %s' % (newname, version, e), stream=sys.stderr)
raise
else:
if restriction != KEEP_OLD_VALUE:
if not pretend:
bibdoc.set_status(restriction)
# Since the docname already existed we have to first
# bump the version by pushing the first new file
# then pushing the other files.
if urls:
(first_url, first_format, first_description, first_comment, first_flags, first_timestamp) = urls[0]
other_urls = urls[1:]
assert(_add_new_version(bibdoc, first_url, first_format, docname, doctype, newname, first_description, first_comment, first_flags, first_timestamp, pretend=pretend))
for (url, docformat, description, comment, flags, timestamp) in other_urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp, pretend=pretend))
## Let's refresh the list of bibdocs.
bibrecdocs.build_bibdoc_list()
if not found_bibdoc:
if not pretend:
bibdoc = bibrecdocs.add_bibdoc(doctype, newname)
bibdoc.set_status(restriction)
for (url, docformat, description, comment, flags, timestamp) in urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp))
elif mode == 'correct':
for bibdoc in bibrecdocs.list_bibdocs():
brd = BibRecDocs(rec_id)
dn = brd.get_docname(bibdoc.id)
if dn == docname:
if doctype not in ('PURGE', 'DELETE', 'EXPUNGE', 'REVERT', 'FIX-ALL', 'FIX-MARC', 'DELETE-FILE'):
if newname != docname:
try:
if not pretend:
bibrecdocs.change_name(docid = bibdoc.id, newname=newname)
## Let's refresh the list of bibdocs.
bibrecdocs.build_bibdoc_list()
except StandardError, e:
write_message('Error in renaming %s to %s: %s' % (docname, newname, e), stream=sys.stderr)
raise
found_bibdoc = False
for bibdoc in bibrecdocs.list_bibdocs():
brd = BibRecDocs(rec_id)
dn = brd.get_docname(bibdoc.id)
if dn == newname:
found_bibdoc = True
if doctype == 'PURGE':
if not pretend:
bibdoc.purge()
elif doctype == 'DELETE':
if not pretend:
bibdoc.delete()
elif doctype == 'EXPUNGE':
if not pretend:
bibdoc.expunge()
elif doctype == 'FIX-ALL':
if not pretend:
bibrecdocs.fix(newname)
elif doctype == 'FIX-MARC':
pass
elif doctype == 'DELETE-FILE':
if urls:
for (url, docformat, description, comment, flags, timestamp) in urls:
if not pretend:
bibdoc.delete_file(docformat, version)
elif doctype == 'REVERT':
try:
if not pretend:
bibdoc.revert(version)
except Exception, e:
write_message('(%s, %s) not correctly reverted: %s' % (newname, version, e), stream=sys.stderr)
raise
else:
if restriction != KEEP_OLD_VALUE:
if not pretend:
bibdoc.set_status(restriction)
if doctype and doctype!= KEEP_OLD_VALUE:
if not pretend:
bibdoc.change_doctype(doctype)
if urls:
(first_url, first_format, first_description, first_comment, first_flags, first_timestamp) = urls[0]
other_urls = urls[1:]
assert(_add_new_version(bibdoc, first_url, first_format, docname, doctype, newname, first_description, first_comment, first_flags, first_timestamp, pretend=pretend))
for (url, docformat, description, comment, flags, timestamp) in other_urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp, pretend=pretend))
## Let's refresh the list of bibdocs.
bibrecdocs.build_bibdoc_list()
if not found_bibdoc:
if doctype in ('PURGE', 'DELETE', 'EXPUNGE', 'FIX-ALL', 'FIX-MARC', 'DELETE-FILE', 'REVERT'):
write_message("('%s', '%s', '%s') not performed because '%s' docname didn't existed." % (doctype, newname, urls, docname), stream=sys.stderr)
raise StandardError
else:
if not pretend:
bibdoc = bibrecdocs.add_bibdoc(doctype, newname)
bibdoc.set_status(restriction)
for (url, docformat, description, comment, flags, timestamp) in urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp))
elif mode == 'append':
try:
found_bibdoc = False
for bibdoc in bibrecdocs.list_bibdocs():
brd = BibRecDocs(rec_id)
dn = brd.get_docname(bibdoc.id)
if dn == docname:
found_bibdoc = True
for (url, docformat, description, comment, flags, timestamp) in urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp, pretend=pretend))
if not found_bibdoc:
try:
if not pretend:
bibdoc = bibrecdocs.add_bibdoc(doctype, docname)
bibdoc.set_status(restriction)
for (url, docformat, description, comment, flags, timestamp) in urls:
assert(_add_new_format(bibdoc, url, docformat, docname, doctype, newname, description, comment, flags, timestamp))
except Exception, e:
register_exception()
write_message("('%s', '%s', '%s') not appended because: '%s'." % (doctype, newname, urls, e), stream=sys.stderr)
raise
except:
register_exception()
raise
if not pretend:
_process_document_moreinfos(more_infos, newname, version, urls and urls[0][1], mode)
# resolving temporary version and identifier
brd = BibRecDocs(rec_id)
if bibdoc_tmpid:
if bibdoc_tmpid in tmp_ids and tmp_ids[bibdoc_tmpid] != -1:
write_message("WARNING: the temporary identifier %s has been declared more than once. Ignoring the second occurance" % (bibdoc_tmpid, ))
else:
tmp_ids[bibdoc_tmpid] = brd.get_docid(docname)
if bibdoc_tmpver:
if bibdoc_tmpver in tmp_vers and tmp_vers[bibdoc_tmpver] != -1:
write_message("WARNING: the temporary version identifier %s has been declared more than once. Ignoring the second occurance" % (bibdoc_tmpver, ))
else:
if version == None:
if version:
tmp_vers[bibdoc_tmpver] = version
else:
tmp_vers[bibdoc_tmpver] = brd.get_bibdoc(docname).get_latest_version()
else:
tmp_vers[bibdoc_tmpver] = version
return record
### Update functions
def update_bibrec_date(now, bibrec_id, insert_mode_p, pretend=False):
"""Update the date of the record in bibrec table """
if insert_mode_p:
query = """UPDATE bibrec SET creation_date=%s, modification_date=%s WHERE id=%s"""
params = (now, now, bibrec_id)
else:
query = """UPDATE bibrec SET modification_date=%s WHERE id=%s"""
params = (now, bibrec_id)
if not pretend:
run_sql(query, params)
write_message(" -Update record creation/modification date: DONE" , verbose=2)
def update_bibfmt_format(id_bibrec, format_value, format_name, modification_date=None, pretend=False):
"""Update the format in the table bibfmt"""
if modification_date is None:
modification_date = time.strftime('%Y-%m-%d %H:%M:%S')
else:
try:
time.strptime(modification_date, "%Y-%m-%d %H:%M:%S")
except ValueError:
modification_date = '1970-01-01 00:00:00'
# We check if the format is already in bibFmt
nb_found = find_record_format(id_bibrec, format_name)
if nb_found == 1:
# we are going to update the format
# compress the format_value value
pickled_format_value = compress(format_value)
# update the format:
query = """UPDATE LOW_PRIORITY bibfmt SET last_updated=%s, value=%s WHERE id_bibrec=%s AND format=%s"""
params = (modification_date, pickled_format_value, id_bibrec, format_name)
if not pretend:
row_id = run_sql(query, params)
if not pretend and row_id is None:
write_message(" Failed: Error during update_bibfmt_format function", verbose=1, stream=sys.stderr)
return 1
else:
write_message(" -Update the format %s in bibfmt: DONE" % format_name , verbose=2)
return 0
elif nb_found > 1:
write_message(" Failed: Same format %s found several time in bibfmt for the same record." % format_name, verbose=1, stream=sys.stderr)
return 1
else:
# Insert the format information in BibFMT
res = insert_bibfmt(id_bibrec, format_value, format_name, modification_date, pretend=pretend)
if res is None:
write_message(" Failed: Error during insert_bibfmt", verbose=1, stream=sys.stderr)
return 1
else:
write_message(" -Insert the format %s in bibfmt: DONE" % format_name , verbose=2)
return 0
def delete_bibfmt_format(id_bibrec, format_name, pretend=False):
"""
Delete format FORMAT_NAME from bibfmt table fo record ID_BIBREC.
"""
if not pretend:
run_sql("DELETE LOW_PRIORITY FROM bibfmt WHERE id_bibrec=%s and format=%s", (id_bibrec, format_name))
return 0
def archive_marcxml_for_history(recID, pretend=False):
"""
Archive current MARCXML format of record RECID from BIBFMT table
into hstRECORD table. Useful to keep MARCXML history of records.
Return 0 if everything went fine. Return 1 otherwise.
"""
res = run_sql("SELECT id_bibrec, value, last_updated FROM bibfmt WHERE format='xm' AND id_bibrec=%s",
(recID,))
if res and not pretend:
run_sql("""INSERT INTO hstRECORD (id_bibrec, marcxml, job_id, job_name, job_person, job_date, job_details)
VALUES (%s,%s,%s,%s,%s,%s,%s)""",
(res[0][0], res[0][1], task_get_task_param('task_id', 0), 'bibupload', task_get_task_param('user', 'UNKNOWN'), res[0][2],
'mode: ' + task_get_option('mode', 'UNKNOWN') + '; file: ' + task_get_option('file_path', 'UNKNOWN') + '.'))
return 0
def update_database_with_metadata(record, rec_id, oai_rec_id="oai", affected_tags=None, pretend=False):
"""Update the database tables with the record and the record id given in parameter"""
# extract only those tags that have been affected.
# check happens at subfield level. This is to prevent overhead
# associated with inserting already existing field with given ind pair
write_message("update_database_with_metadata: record=%s, rec_id=%s, oai_rec_id=%s, affected_tags=%s" % (record, rec_id, oai_rec_id, affected_tags), verbose=9)
tmp_record = {}
if affected_tags:
for tag in record.keys():
if tag in affected_tags.keys():
write_message(" -Tag %s found to be modified.Setting up for update" % tag, verbose=9)
# initialize new list to hold affected field
new_data_tuple_list = []
for data_tuple in record[tag]:
ind1 = data_tuple[1]
ind2 = data_tuple[2]
if (ind1, ind2) in affected_tags[tag]:
write_message(" -Indicator pair (%s, %s) added to update list" % (ind1, ind2), verbose=9)
new_data_tuple_list.append(data_tuple)
tmp_record[tag] = new_data_tuple_list
write_message(lambda: " -Modified fields: \n%s" % record_xml_output(tmp_record), verbose=2)
else:
tmp_record = record
for tag in tmp_record.keys():
# check if tag is not a special one:
if tag not in CFG_BIBUPLOAD_SPECIAL_TAGS:
# for each tag there is a list of tuples representing datafields
tuple_list = tmp_record[tag]
# this list should contain the elements of a full tag [tag, ind1, ind2, subfield_code]
tag_list = []
tag_list.append(tag)
for single_tuple in tuple_list:
# these are the contents of a single tuple
subfield_list = single_tuple[0]
ind1 = single_tuple[1]
ind2 = single_tuple[2]
# append the ind's to the full tag
if ind1 == '' or ind1 == ' ':
tag_list.append('_')
else:
tag_list.append(ind1)
if ind2 == '' or ind2 == ' ':
tag_list.append('_')
else:
tag_list.append(ind2)
datafield_number = single_tuple[4]
if tag in CFG_BIBUPLOAD_SPECIAL_TAGS:
# nothing to do for special tags (FFT, BDR, BDM)
pass
elif tag in CFG_BIBUPLOAD_CONTROLFIELD_TAGS and tag != "001":
value = single_tuple[3]
# get the full tag
full_tag = ''.join(tag_list)
# update the tables
write_message(" insertion of the tag "+full_tag+" with the value "+value, verbose=9)
# insert the tag and value into into bibxxx
(table_name, bibxxx_row_id) = insert_record_bibxxx(full_tag, value, pretend=pretend)
#print 'tname, bibrow', table_name, bibxxx_row_id;
if table_name is None or bibxxx_row_id is None:
write_message(" Failed: during insert_record_bibxxx", verbose=1, stream=sys.stderr)
# connect bibxxx and bibrec with the table bibrec_bibxxx
res = insert_record_bibrec_bibxxx(table_name, bibxxx_row_id, datafield_number, rec_id, pretend=pretend)
if res is None:
write_message(" Failed: during insert_record_bibrec_bibxxx", verbose=1, stream=sys.stderr)
else:
# get the tag and value from the content of each subfield
for subfield in subfield_list:
subtag = subfield[0]
value = subfield[1]
tag_list.append(subtag)
# get the full tag
full_tag = ''.join(tag_list)
# update the tables
write_message(" insertion of the tag "+full_tag+" with the value "+value, verbose=9)
# insert the tag and value into into bibxxx
(table_name, bibxxx_row_id) = insert_record_bibxxx(full_tag, value, pretend=pretend)
if table_name is None or bibxxx_row_id is None:
write_message(" Failed: during insert_record_bibxxx", verbose=1, stream=sys.stderr)
# connect bibxxx and bibrec with the table bibrec_bibxxx
res = insert_record_bibrec_bibxxx(table_name, bibxxx_row_id, datafield_number, rec_id, pretend=pretend)
if res is None:
write_message(" Failed: during insert_record_bibrec_bibxxx", verbose=1, stream=sys.stderr)
# remove the subtag from the list
tag_list.pop()
tag_list.pop()
tag_list.pop()
tag_list.pop()
write_message(" -Update the database with metadata: DONE", verbose=2)
log_record_uploading(oai_rec_id, task_get_task_param('task_id', 0), rec_id, 'P', pretend=pretend)
def append_new_tag_to_old_record(record, rec_old):
"""Append new tags to a old record"""
def _append_tag(tag):
if tag in CFG_BIBUPLOAD_CONTROLFIELD_TAGS:
if tag == '001':
pass
else:
# if it is a controlfield, just access the value
for single_tuple in record[tag]:
controlfield_value = single_tuple[3]
# add the field to the old record
newfield_number = record_add_field(rec_old, tag,
controlfield_value=controlfield_value)
if newfield_number is None:
write_message(" Error when adding the field"+tag, verbose=1, stream=sys.stderr)
else:
# For each tag there is a list of tuples representing datafields
for single_tuple in record[tag]:
# We retrieve the information of the tag
subfield_list = single_tuple[0]
ind1 = single_tuple[1]
ind2 = single_tuple[2]
if '%s%s%s' % (tag, ind1 == ' ' and '_' or ind1, ind2 == ' ' and '_' or ind2) in (CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:5], CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG[:5]):
## We don't want to append the external identifier
## if it is already existing.
if record_find_field(rec_old, tag, single_tuple)[0] is not None:
write_message(" Not adding tag: %s ind1=%s ind2=%s subfields=%s: it's already there" % (tag, ind1, ind2, subfield_list), verbose=9)
continue
# We add the datafield to the old record
write_message(" Adding tag: %s ind1=%s ind2=%s subfields=%s" % (tag, ind1, ind2, subfield_list), verbose=9)
newfield_number = record_add_field(rec_old, tag, ind1,
ind2, subfields=subfield_list)
if newfield_number is None:
write_message(" Error when adding the field"+tag, verbose=1, stream=sys.stderr)
# Go through each tag in the appended record
for tag in record:
_append_tag(tag)
return rec_old
def copy_strong_tags_from_old_record(record, rec_old):
"""
Look for strong tags in RECORD and REC_OLD. If no strong tags are
found in RECORD, then copy them over from REC_OLD. This function
modifies RECORD structure on the spot.
"""
for strong_tag in CFG_BIBUPLOAD_STRONG_TAGS:
if not record_get_field_instances(record, strong_tag, strong_tag[3:4] or '%', strong_tag[4:5] or '%'):
strong_tag_old_field_instances = record_get_field_instances(rec_old, strong_tag)
if strong_tag_old_field_instances:
for strong_tag_old_field_instance in strong_tag_old_field_instances:
sf_vals, fi_ind1, fi_ind2, controlfield, dummy = strong_tag_old_field_instance
record_add_field(record, strong_tag, fi_ind1, fi_ind2, controlfield, sf_vals)
return
### Delete functions
def delete_tags(record, rec_old):
"""
Returns a record structure with all the fields in rec_old minus the
fields in record.
@param record: The record containing tags to delete.
@type record: record structure
@param rec_old: The original record.
@type rec_old: record structure
@return: The modified record.
@rtype: record structure
"""
returned_record = copy.deepcopy(rec_old)
for tag, fields in record.iteritems():
if tag in ('001', ):
continue
for field in fields:
local_position = record_find_field(returned_record, tag, field)[1]
if local_position is not None:
record_delete_field(returned_record, tag, field_position_local=local_position)
return returned_record
def delete_tags_to_correct(record, rec_old):
"""
Delete tags from REC_OLD which are also existing in RECORD. When
deleting, pay attention not only to tags, but also to indicators,
so that fields with the same tags but different indicators are not
deleted.
"""
## Some fields are controlled via provenance information.
## We should re-add saved fields at the end.
fields_to_readd = {}
for tag in CFG_BIBUPLOAD_CONTROLLED_PROVENANCE_TAGS:
if tag[:3] in record:
tmp_field_instances = record_get_field_instances(record, tag[:3], tag[3], tag[4]) ## Let's discover the provenance that will be updated
provenances_to_update = []
for instance in tmp_field_instances:
for code, value in instance[0]:
if code == tag[5]:
if value not in provenances_to_update:
provenances_to_update.append(value)
break
else:
## The provenance is not specified.
## let's add the special empty provenance.
if '' not in provenances_to_update:
provenances_to_update.append('')
potential_fields_to_readd = record_get_field_instances(rec_old, tag[:3], tag[3], tag[4]) ## Let's take all the field corresponding to tag
## Let's save apart all the fields that should be updated, but
## since they have a different provenance not mentioned in record
## they should be preserved.
fields = []
for sf_vals, ind1, ind2, dummy_cf, dummy_line in potential_fields_to_readd:
for code, value in sf_vals:
if code == tag[5]:
if value not in provenances_to_update:
fields.append(sf_vals)
break
else:
if '' not in provenances_to_update:
## Empty provenance, let's protect in any case
fields.append(sf_vals)
fields_to_readd[tag] = fields
# browse through all the tags from the MARCXML file:
for tag in record:
# check if the tag exists in the old record too:
if tag in rec_old and tag != '001':
# the tag does exist, so delete all record's tag+ind1+ind2 combinations from rec_old
for dummy_sf_vals, ind1, ind2, dummy_cf, dummyfield_number in record[tag]:
write_message(" Delete tag: " + tag + " ind1=" + ind1 + " ind2=" + ind2, verbose=9)
record_delete_field(rec_old, tag, ind1, ind2)
## Ok, we readd necessary fields!
for tag, fields in fields_to_readd.iteritems():
for sf_vals in fields:
write_message(" Adding tag: " + tag[:3] + " ind1=" + tag[3] + " ind2=" + tag[4] + " code=" + str(sf_vals), verbose=9)
record_add_field(rec_old, tag[:3], tag[3], tag[4], subfields=sf_vals)
def delete_bibrec_bibxxx(record, id_bibrec, affected_tags={}, pretend=False):
"""Delete the database record from the table bibxxx given in parameters"""
# we clear all the rows from bibrec_bibxxx from the old record
# clearing only those tags that have been modified.
write_message(lambda: "delete_bibrec_bibxxx(record=%s, id_bibrec=%s, affected_tags=%s)" % (record, id_bibrec, affected_tags), verbose=9)
for tag in affected_tags:
# sanity check with record keys just to make sure its fine.
if tag not in CFG_BIBUPLOAD_SPECIAL_TAGS:
write_message("%s found in record"%tag, verbose=2)
# for each name construct the bibrec_bibxxx table name
table_name = 'bib'+tag[0:2]+'x'
bibrec_table = 'bibrec_'+table_name
# delete all the records with proper id_bibrec. Indicators matter for individual affected tags
tmp_ind_1 = ''
tmp_ind_2 = ''
# construct exact tag value using indicators
for ind_pair in affected_tags[tag]:
if ind_pair[0] == ' ':
tmp_ind_1 = '_'
else:
tmp_ind_1 = ind_pair[0]
if ind_pair[1] == ' ':
tmp_ind_2 = '_'
else:
tmp_ind_2 = ind_pair[1]
# need to escape incase of underscore so that mysql treats it as a char
tag_val = tag+"\\"+tmp_ind_1+"\\"+tmp_ind_2 + '%'
query = """DELETE br.* FROM `%s` br,`%s` b where br.id_bibrec=%%s and br.id_bibxxx=b.id and b.tag like %%s""" % (bibrec_table, table_name)
params = (id_bibrec, tag_val)
write_message(query % params, verbose=9)
if not pretend:
run_sql(query, params)
else:
write_message("%s not found"%tag, verbose=2)
def main():
"""Main that construct all the bibtask."""
task_init(authorization_action='runbibupload',
authorization_msg="BibUpload Task Submission",
description="""Receive MARC XML file and update appropriate database
tables according to options.
Examples:
$ bibupload -i input.xml
""",
help_specific_usage=""" -a, --append\t\tnew fields are appended to the existing record
-c, --correct\t\tfields are replaced by the new ones in the existing record, except
\t\t\twhen overridden by CFG_BIBUPLOAD_CONTROLLED_PROVENANCE_TAGS
-i, --insert\t\tinsert the new record in the database
-r, --replace\t\tthe existing record is entirely replaced by the new one,
\t\t\texcept for fields in CFG_BIBUPLOAD_STRONG_TAGS
-d, --delete\t\tspecified fields are deleted in existing record
-n, --notimechange\tdo not change record last modification date when updating
-o, --holdingpen\tInsert record into holding pen instead of the normal database
--pretend\t\tdo not really insert/append/correct/replace the input file
--force\t\twhen --replace, use provided 001 tag values, even if the matching
\t\t\trecord does not exist (thus allocating it on-the-fly)
--callback-url\tSend via a POST request a JSON-serialized answer (see admin guide), in
\t\t\torder to provide a feedback to an external service about the outcome of the operation.
--nonce\t\twhen used together with --callback add the nonce value in the JSON message.
--special-treatment=MODE\tif "oracle" is specified, when used together with --callback_url,
\t\t\tPOST an application/x-www-form-urlencoded request where the JSON message is encoded
\t\t\tinside a form field called "results".
""",
version=__revision__,
specific_params=("ircazdnoS:",
[
"insert",
"replace",
"correct",
"append",
"reference",
"delete",
"notimechange",
"holdingpen",
"pretend",
"force",
"callback-url=",
"nonce=",
"special-treatment=",
"stage=",
]),
task_submit_elaborate_specific_parameter_fnc=task_submit_elaborate_specific_parameter,
task_run_fnc=task_run_core)
def task_submit_elaborate_specific_parameter(key, value, opts, args): # pylint: disable=W0613
""" Given the string key it checks it's meaning, eventually using the
value. Usually it fills some key in the options dict.
It must return True if it has elaborated the key, False, if it doesn't
know that key.
eg:
if key in ['-n', '--number']:
task_get_option(\1) = value
return True
return False
"""
# No time change option
if key in ("-n", "--notimechange"):
task_set_option('notimechange', 1)
# Insert mode option
elif key in ("-i", "--insert"):
if task_get_option('mode') == 'replace':
# if also replace found, then set to replace_or_insert
task_set_option('mode', 'replace_or_insert')
else:
task_set_option('mode', 'insert')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
# Replace mode option
elif key in ("-r", "--replace"):
if task_get_option('mode') == 'insert':
# if also insert found, then set to replace_or_insert
task_set_option('mode', 'replace_or_insert')
else:
task_set_option('mode', 'replace')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
# Holding pen mode option
elif key in ("-o", "--holdingpen"):
write_message("Holding pen mode", verbose=3)
task_set_option('mode', 'holdingpen')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
# Correct mode option
elif key in ("-c", "--correct"):
task_set_option('mode', 'correct')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
# Append mode option
elif key in ("-a", "--append"):
task_set_option('mode', 'append')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
# Deprecated reference mode option (now correct)
elif key in ("-z", "--reference"):
task_set_option('mode', 'correct')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
elif key in ("-d", "--delete"):
task_set_option('mode', 'delete')
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
elif key in ("--pretend",):
task_set_option('pretend', True)
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
elif key in ("--force",):
task_set_option('force', True)
fix_argv_paths([args[0]])
task_set_option('file_path', os.path.abspath(args[0]))
elif key in ("--callback-url", ):
task_set_option('callback_url', value)
elif key in ("--nonce", ):
task_set_option('nonce', value)
elif key in ("--special-treatment", ):
if value.lower() in CFG_BIBUPLOAD_ALLOWED_SPECIAL_TREATMENTS:
if value.lower() == 'oracle':
task_set_option('oracle_friendly', True)
else:
print >> sys.stderr, """The specified value is not in the list of allowed special treatments codes: %s""" % CFG_BIBUPLOAD_ALLOWED_SPECIAL_TREATMENTS
return False
elif key in ("-S", "--stage"):
print >> sys.stderr, """WARNING: the --stage parameter is deprecated and ignored."""
else:
return False
return True
def task_submit_check_options():
""" Reimplement this method for having the possibility to check options
before submitting the task, in order for example to provide default
values. It must return False if there are errors in the options.
"""
if task_get_option('mode') is None:
write_message("Please specify at least one update/insert mode!")
return False
if task_get_option('file_path') is None:
write_message("Missing filename! -h for help.")
return False
return True
def writing_rights_p():
"""Return True in case bibupload has the proper rights to write in the
fulltext file folder."""
if _WRITING_RIGHTS is not None:
return _WRITING_RIGHTS
try:
if not os.path.exists(CFG_BIBDOCFILE_FILEDIR):
os.makedirs(CFG_BIBDOCFILE_FILEDIR)
fd, filename = tempfile.mkstemp(suffix='.txt', prefix='test', dir=CFG_BIBDOCFILE_FILEDIR)
test = os.fdopen(fd, 'w')
test.write('TEST')
test.close()
if open(filename).read() != 'TEST':
raise IOError("Can not successfully write and readback %s" % filename)
os.remove(filename)
except:
register_exception(alert_admin=True)
return False
return True
def post_results_to_callback_url(results, callback_url):
write_message("Sending feedback to %s" % callback_url)
if not CFG_JSON_AVAILABLE:
from warnings import warn
warn("--callback-url used but simplejson/json not available")
return
json_results = json.dumps(results)
write_message("Message to send: %s" % json_results, verbose=9)
## <scheme>://<netloc>/<path>?<query>#<fragment>
scheme, dummynetloc, dummypath, dummyquery, dummyfragment = urlparse.urlsplit(callback_url)
## See: http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-python
if scheme == 'http':
opener = urllib2.build_opener(urllib2.HTTPHandler)
elif scheme == 'https':
opener = urllib2.build_opener(urllib2.HTTPSHandler)
else:
raise ValueError("Scheme not handled %s for callback_url %s" % (scheme, callback_url))
if task_get_option('oracle_friendly'):
write_message("Oracle friendly mode requested", verbose=9)
request = urllib2.Request(callback_url, data=urllib.urlencode({'results': json_results}))
request.add_header('Content-Type', 'application/x-www-form-urlencoded')
else:
request = urllib2.Request(callback_url, data=json_results)
request.add_header('Content-Type', 'application/json')
request.add_header('User-Agent', make_user_agent_string('BibUpload'))
write_message("Headers about to be sent: %s" % request.headers, verbose=9)
write_message("Data about to be sent: %s" % request.data, verbose=9)
res = opener.open(request)
msg = res.read()
write_message("Result of posting the feedback: %s %s" % (res.code, res.msg), verbose=9)
write_message("Returned message is: %s" % msg, verbose=9)
return res
def bibupload_records(records, opt_mode=None, opt_notimechange=0,
pretend=False, callback_url=None, results_for_callback=None):
"""perform the task of uploading a set of records
returns list of (error_code, recid) tuples for separate records
"""
#Dictionaries maintaining temporary identifiers
# Structure: identifier -> number
tmp_ids = {}
tmp_vers = {}
results = []
# The first phase -> assigning meaning to temporary identifiers
if opt_mode == 'reference':
## NOTE: reference mode has been deprecated in favour of 'correct'
opt_mode = 'correct'
record = None
for record in records:
record_id = record_extract_oai_id(record)
task_sleep_now_if_required(can_stop_too=True)
if opt_mode == "holdingpen":
#inserting into the holding pen
write_message("Inserting into holding pen", verbose=3)
insert_record_into_holding_pen(record, record_id)
else:
write_message("Inserting into main database", verbose=3)
error = bibupload(
record,
opt_mode = opt_mode,
opt_notimechange = opt_notimechange,
oai_rec_id = record_id,
pretend = pretend,
tmp_ids = tmp_ids,
tmp_vers = tmp_vers)
results.append(error)
if error[0] == 1:
if record:
write_message(lambda: record_xml_output(record),
stream=sys.stderr)
else:
write_message("Record could not have been parsed",
stream=sys.stderr)
stat['nb_errors'] += 1
if callback_url:
results_for_callback['results'].append({'recid': error[1], 'success': False, 'error_message': error[2]})
elif error[0] == 2:
if record:
write_message(lambda: record_xml_output(record),
stream=sys.stderr)
else:
write_message("Record could not have been parsed",
stream=sys.stderr)
stat['nb_holdingpen'] += 1
if callback_url:
results_for_callback['results'].append({'recid': error[1], 'success': False, 'error_message': error[2]})
elif error[0] == 0:
if callback_url:
from invenio.search_engine import print_record
results_for_callback['results'].append({'recid': error[1], 'success': True, "marcxml": print_record(error[1], 'xm'), 'url': "%s/%s/%s" % (CFG_SITE_URL, CFG_SITE_RECORD, error[1])})
else:
if callback_url:
results_for_callback['results'].append({'recid': error[1], 'success': False, 'error_message': error[2]})
# stat us a global variable
task_update_progress("Done %d out of %d." % \
(stat['nb_records_inserted'] + \
stat['nb_records_updated'],
stat['nb_records_to_upload']))
# Second phase -> Now we can process all entries where temporary identifiers might appear (BDR, BDM)
write_message("Identifiers table after processing: %s versions: %s" % (str(tmp_ids), str(tmp_vers)))
write_message("Uploading BDR and BDM fields")
if opt_mode != "holdingpen":
for record in records:
record_id = retrieve_rec_id(record, opt_mode, pretend=pretend, post_phase = True)
bibupload_post_phase(record,
rec_id = record_id,
mode = opt_mode,
pretend = pretend,
tmp_ids = tmp_ids,
tmp_vers = tmp_vers)
return results
def task_run_core():
""" Reimplement to add the body of the task."""
write_message("Input file '%s', input mode '%s'." %
(task_get_option('file_path'), task_get_option('mode')))
write_message("STAGE 0:", verbose=2)
if task_get_option('file_path') is not None:
write_message("start preocessing", verbose=3)
task_update_progress("Reading XML input")
recs = xml_marc_to_records(open_marc_file(task_get_option('file_path')))
stat['nb_records_to_upload'] = len(recs)
write_message(" -Open XML marc: DONE", verbose=2)
task_sleep_now_if_required(can_stop_too=True)
write_message("Entering records loop", verbose=3)
callback_url = task_get_option('callback_url')
results_for_callback = {'results': []}
if recs is not None:
# We proceed each record by record
bibupload_records(records=recs, opt_mode=task_get_option('mode'),
opt_notimechange=task_get_option('notimechange'),
pretend=task_get_option('pretend'),
callback_url=callback_url,
results_for_callback=results_for_callback)
else:
write_message(" Error bibupload failed: No record found",
verbose=1, stream=sys.stderr)
callback_url = task_get_option("callback_url")
if callback_url:
nonce = task_get_option("nonce")
if nonce:
results_for_callback["nonce"] = nonce
post_results_to_callback_url(results_for_callback, callback_url)
if task_get_task_param('verbose') >= 1:
# Print out the statistics
print_out_bibupload_statistics()
# Check if they were errors
return not stat['nb_errors'] >= 1
def log_record_uploading(oai_rec_id, task_id, bibrec_id, insertion_db, pretend=False):
if oai_rec_id != "" and oai_rec_id != None:
query = """UPDATE oaiHARVESTLOG SET date_inserted=NOW(), inserted_to_db=%s, id_bibrec=%s WHERE oai_id = %s AND bibupload_task_id = %s ORDER BY date_harvested LIMIT 1"""
if not pretend:
run_sql(query, (str(insertion_db), str(bibrec_id), str(oai_rec_id), str(task_id), ))
if __name__ == "__main__":
main()
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
309,
199,
309,
961,
570,
365,
1777,
402,
12235,
14,
199,
309,
1898,
334,
35,
9,
8315,
12,
10219,
12,
9079,
12,
8937,
12,
7129,
12,
7760,
12,
6029,
12,
6171,
24354,
14,
199,
309,
199,
309,
12235,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
309,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
309,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
199,
309,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
12235,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
309,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
309,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
199,
309,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
309,
3180,
543,
12235,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
309,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
12,
8217,
14,
199,
199,
624,
199,
25217,
10301,
26,
799,
5251,
603,
24028,
4692,
570,
436,
1678,
314,
5827,
3050,
199,
5987,
7182,
370,
1511,
14,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
646,
900,
199,
504,
2197,
492,
2197,
199,
504,
12472,
492,
11029,
199,
646,
2838,
199,
646,
21985,
199,
646,
1331,
199,
646,
5549,
199,
646,
7097,
199,
646,
4011,
18,
199,
646,
4011,
199,
199,
504,
13640,
14,
888,
492,
10974,
63,
47,
7730,
63,
998,
63,
8609,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
21043,
63,
13326,
2826,
63,
6967,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
21043,
63,
47,
7730,
998,
63,
6967,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
21043,
63,
47,
7730,
998,
63,
2514,
8253,
7140,
63,
6967,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
3027,
7770,
63,
17626,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
13060,
5290,
63,
2514,
8253,
7140,
63,
17626,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
19637,
11025,
63,
15060,
63,
8893,
3942,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
7014,
63,
14019,
12,
971,
1362,
10974,
63,
7917,
63,
2632,
12,
10974,
63,
7917,
63,
20696,
63,
2632,
12,
10974,
63,
7917,
63,
15060,
12,
971,
1362,
10974,
63,
47,
7730,
63,
2514,
8253,
7140,
63,
19350,
1149,
63,
6348,
8609,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
13052,
63,
15060,
63,
907,
11793,
2823,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
3103,
2507,
52,
1206,
63,
907,
18775,
63,
52,
13884,
775,
63,
15125,
199,
199,
504,
13640,
14,
1001,
1208,
492,
2022,
12,
10974,
63,
6243,
63,
17377,
199,
504,
13640,
14,
8804,
5064,
63,
888,
492,
10974,
63,
19832,
16418,
63,
13060,
8609,
63,
17626,
12,
971,
272,
10974,
63,
19832,
16418,
63,
25748,
63,
17626,
12,
971,
272,
10974,
63,
19832,
16418,
63,
7014,
63,
6012,
12,
971,
272,
10974,
63,
19832,
16418,
63,
7014,
63,
7041,
12,
971,
272,
10974,
63,
19832,
16418,
63,
5123,
63,
31095,
199,
504,
13640,
14,
697,
1131,
492,
1255,
63,
3009,
12,
971,
1169,
4520,
199,
504,
13640,
14,
8804,
3059,
492,
1218,
63,
6502,
12,
971,
2892,
2777,
63,
525,
63,
698,
12,
971,
2892,
2777,
63,
1807,
63,
698,
12,
971,
2892,
2777,
63,
1652,
63,
1199,
12,
971,
2892,
2777,
63,
362,
63,
698,
63,
5990,
12,
971,
2892,
2777,
63,
362,
63,
698,
63,
585,
12,
971,
2892,
2777,
63,
362,
63,
698,
63,
1459,
12,
971,
2892,
901,
63,
362,
63,
11852,
63,
1459,
12,
971,
2892,
901,
63,
362,
63,
11852,
63,
5990,
12,
971,
2892,
2777,
63,
8951,
63,
11852,
12,
971,
2892,
2777,
63,
1807,
63,
11852,
63,
504,
12,
971,
2892,
2777,
63,
1807,
63,
955,
12,
971,
2892,
2777,
63,
525,
63,
11852,
63,
9924,
12,
971,
2892,
2777,
63,
1623,
63,
698,
12,
971,
2892,
2777,
63,
5005,
63,
28475,
63,
344,
12,
971,
2892,
2777,
63,
5005,
63,
1117,
374,
12,
971,
2892,
2777,
63,
1989,
63,
698,
4202,
2892,
5767,
63,
14576,
199,
504,
13640,
14,
1733,
63,
3908,
492,
664,
63,
3059,
199,
504,
13640,
14,
602,
1208,
492,
3957,
63,
602,
1820,
63,
475,
63,
602,
505,
199,
504,
13640,
14,
705,
773,
492,
2274,
63,
1971,
199,
504,
13640,
14,
8804,
7959,
492,
11314,
7959,
63,
2253,
199,
504,
13640,
14,
442,
2075,
409,
492,
1109,
2075,
409,
199,
504,
13640,
14,
633,
1208,
492,
1852,
63,
751,
63,
4054,
63,
875,
199,
504,
13640,
14,
888,
492,
10974,
63,
19832,
16618,
3817,
63,
3817,
3022,
199,
504,
13640,
14,
8804,
1765,
492,
2120,
63,
826,
12,
2218,
63,
1188,
12,
971,
272,
2120,
63,
409,
63,
1422,
12,
2120,
63,
362,
63,
1422,
12,
2120,
63,
362,
63,
1765,
63,
635,
12,
2120,
63,
873,
63,
1205,
12,
971,
272,
2120,
63,
873,
63,
5734,
12,
2120,
63,
4532,
63,
2131,
63,
692,
63,
2427,
12,
5325,
63,
3020,
63,
3771,
199,
504,
13640,
14,
26415,
493,
492,
21949,
21561,
27858,
12,
570,
63,
1913,
63,
832,
12,
7666,
63,
908,
12,
971,
272,
664,
63,
21828,
63,
504,
63,
633,
12,
1104,
63,
1078,
63,
633,
12,
5235,
63,
633,
12,
971,
272,
1804,
37,
6102,
63,
5104,
63,
7041,
12,
477,
12607,
63,
26415,
493,
63,
633,
12,
12235,
25217,
3768,
25212,
12,
971,
272,
23682,
493,
63,
633,
63,
80,
12,
10974,
63,
19832,
16618,
3817,
63,
17377,
63,
4831,
12,
9519,
63,
908,
63,
504,
63,
633,
12,
971,
272,
21949,
12617,
12,
16917,
2354,
199,
199,
504,
13640,
14,
1733,
63,
3908,
492,
2754,
63,
3401,
199,
199,
504,
13640,
14,
8804,
5064,
63,
5792,
21227,
492,
27095,
3673,
9893,
12,
971,
6901,
12235,
25217,
10301,
15919,
316,
497,
13193,
547,
12,
971,
6901,
12235,
25217,
10301,
3364,
12714,
547
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
309,
199,
309,
961,
570,
365,
1777,
402,
12235,
14,
199,
309,
1898,
334,
35,
9,
8315,
12,
10219,
12,
9079,
12,
8937,
12,
7129,
12,
7760,
12,
6029,
12,
6171,
24354,
14,
199,
309,
199,
309,
12235,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
309,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
199,
309,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
199,
309,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
309,
199,
309,
12235,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
1325,
199,
309,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
309,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
309,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
309,
199,
309,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
309,
3180,
543,
12235,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
2752,
12,
3277,
2020,
199,
309,
8155,
15630,
10902,
12,
14453,
13540,
12,
8226,
12,
4828,
15673,
13,
13421,
12,
8217,
14,
199,
199,
624,
199,
25217,
10301,
26,
799,
5251,
603,
24028,
4692,
570,
436,
1678,
314,
5827,
3050,
199,
5987,
7182,
370,
1511,
14,
199,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
646,
900,
199,
504,
2197,
492,
2197,
199,
504,
12472,
492,
11029,
199,
646,
2838,
199,
646,
21985,
199,
646,
1331,
199,
646,
5549,
199,
646,
7097,
199,
646,
4011,
18,
199,
646,
4011,
199,
199,
504,
13640,
14,
888,
492,
10974,
63,
47,
7730,
63,
998,
63,
8609,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
21043,
63,
13326,
2826,
63,
6967,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
21043,
63,
47,
7730,
998,
63,
6967,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
21043,
63,
47,
7730,
998,
63,
2514,
8253,
7140,
63,
6967,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
3027,
7770,
63,
17626,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
13060,
5290,
63,
2514,
8253,
7140,
63,
17626,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
19637,
11025,
63,
15060,
63,
8893,
3942,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
7014,
63,
14019,
12,
971,
1362,
10974,
63,
7917,
63,
2632,
12,
10974,
63,
7917,
63,
20696,
63,
2632,
12,
10974,
63,
7917,
63,
15060,
12,
971,
1362,
10974,
63,
47,
7730,
63,
2514,
8253,
7140,
63,
19350,
1149,
63,
6348,
8609,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
13052,
63,
15060,
63,
907,
11793,
2823,
12,
971,
1362,
10974,
63,
19832,
16418,
63,
3103,
2507,
52,
1206,
63,
907,
18775,
63,
52,
13884,
775,
63,
15125,
199,
199,
504,
13640,
14,
1001,
1208,
492,
2022,
12,
10974,
63,
6243,
63,
17377,
199,
504,
13640,
14,
8804,
5064,
63,
888,
492,
10974,
63,
19832,
16418,
63,
13060,
8609,
63,
17626,
12,
971,
272,
10974,
63,
19832,
16418,
63,
25748,
63,
17626,
12,
971,
272,
10974,
63,
19832,
16418,
63,
7014,
63,
6012,
12,
971,
272,
10974,
63,
19832,
16418,
63,
7014,
63,
7041,
12,
971,
272,
10974,
63,
19832,
16418,
63,
5123,
63,
31095,
199,
504,
13640,
14,
697,
1131,
492,
1255,
63,
3009,
12,
971,
1169,
4520,
199,
504,
13640,
14,
8804,
3059,
492,
1218,
63,
6502,
12,
971,
2892,
2777,
63,
525,
63,
698,
12,
971,
2892,
2777,
63,
1807,
63,
698,
12,
971,
2892,
2777,
63,
1652,
63,
1199,
12,
971,
2892,
2777,
63,
362,
63,
698,
63,
5990,
12,
971,
2892,
2777,
63,
362,
63,
698,
63,
585,
12,
971,
2892,
2777,
63,
362,
63,
698,
63,
1459,
12,
971,
2892,
901,
63,
362,
63,
11852,
63,
1459,
12,
971,
2892,
901,
63,
362,
63,
11852,
63,
5990,
12,
971,
2892,
2777,
63,
8951,
63,
11852,
12,
971,
2892,
2777,
63,
1807,
63,
11852,
63,
504,
12,
971,
2892,
2777,
63,
1807,
63,
955,
12,
971,
2892,
2777,
63,
525,
63,
11852,
63,
9924,
12,
971,
2892,
2777,
63,
1623,
63,
698,
12,
971,
2892,
2777,
63,
5005,
63,
28475,
63,
344,
12,
971,
2892,
2777,
63,
5005,
63,
1117,
374,
12,
971,
2892,
2777,
63,
1989,
63,
698,
4202,
2892,
5767,
63,
14576,
199,
504,
13640,
14,
1733,
63,
3908,
492,
664,
63,
3059,
199,
504,
13640,
14,
602,
1208,
492,
3957,
63,
602,
1820,
63,
475,
63,
602,
505,
199,
504,
13640,
14,
705,
773,
492,
2274,
63,
1971,
199,
504,
13640,
14,
8804,
7959,
492,
11314,
7959,
63,
2253,
199,
504,
13640,
14,
442,
2075,
409,
492,
1109,
2075,
409,
199,
504,
13640,
14,
633,
1208,
492,
1852,
63,
751,
63,
4054,
63,
875,
199,
504,
13640,
14,
888,
492,
10974,
63,
19832,
16618,
3817,
63,
3817,
3022,
199,
504,
13640,
14,
8804,
1765,
492,
2120,
63,
826,
12,
2218,
63,
1188,
12,
971,
272,
2120,
63,
409,
63,
1422,
12,
2120,
63,
362,
63,
1422,
12,
2120,
63,
362,
63,
1765,
63,
635,
12,
2120,
63,
873,
63,
1205,
12,
971,
272,
2120,
63,
873,
63,
5734,
12,
2120,
63,
4532,
63,
2131,
63,
692,
63,
2427,
12,
5325,
63,
3020,
63,
3771,
199,
504,
13640,
14,
26415,
493,
492,
21949,
21561,
27858,
12,
570,
63,
1913,
63,
832,
12,
7666,
63,
908,
12,
971,
272,
664,
63,
21828,
63,
504,
63,
633,
12,
1104,
63,
1078,
63,
633,
12,
5235,
63,
633,
12,
971,
272,
1804,
37,
6102,
63,
5104,
63,
7041,
12,
477,
12607,
63,
26415,
493,
63,
633,
12,
12235,
25217,
3768,
25212,
12,
971,
272,
23682,
493,
63,
633,
63,
80,
12,
10974,
63,
19832,
16618,
3817,
63,
17377,
63,
4831,
12,
9519,
63,
908,
63,
504,
63,
633,
12,
971,
272,
21949,
12617,
12,
16917,
2354,
199,
199,
504,
13640,
14,
1733,
63,
3908,
492,
2754,
63,
3401,
199,
199,
504,
13640,
14,
8804,
5064,
63,
5792,
21227,
492,
27095,
3673,
9893,
12,
971,
6901,
12235,
25217,
10301,
15919,
316,
497,
13193,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kivy/plyer
|
plyer/facades/wifi.py
|
1
|
4169
|
'''
Wifi Facade.
=============
The :class:`Wifi` is to provide access to the wifi of your mobile/ desktop
devices.
It currently supports `connecting`, `disconnecting`, `scanning`, `getting
available wifi network list` and `getting network information`.
Simple examples
---------------
To enable/ turn on wifi scanning::
>>> from plyer import wifi
>>> wifi.start_scanning()
Once the wifi is enabled/ turned on, then this command starts to scan
all the nearby available wifi networks.
To get network info::
>>> from plyer import wifi
>>> wifi.start_scanning()
>>> return wifi.get_network_info(name)
Returns network details of the network who's name/ssid is provided in the
`name` parameter.
To connect to a network::
>>> from plyer import wifi
>>> wifi.start_scanning()
>>> wifi.connect(network, parameters)
This connects to the network who's name/ssid is provided under `network`
parameter and along with other necessary methods for connection
which depends upon platform to platform.
please visit following files for more details about requirements of
`paramaters` argument in `connect` method:
plyer/platforms/win/wifi.py
plyer/platforms/macosx/wifi.py
plyer/platforms/win/wifi.py
To disconnect from wifi::
>>> from plyer import wifi
>>> wifi.disconnect()
This disconnects your device from any wifi network.
To get available wifi networks::
>>> from plyer import wifi
>>> wifi.start_scanning()
>>> return wifi.get_available_wifi()
This returns all the available wifi networks near the device.
Supported Platforms
-------------------
Windows, OS X, Linux
Ex: 6
----------
from plyer import wifi
wifi.enable()
This enables wifi device.
Ex: 7
----------
from plyer import wifi
wifi.disable()
This disable wifi device
'''
class Wifi:
'''
Wifi Facade.
'''
def is_enabled(self):
'''
Return enabled status of WiFi hardware.
'''
return self._is_enabled()
def is_connected(self, interface=None):
'''
Return connection state of WiFi interface.
.. versionadded:: 1.4.0
'''
return self._is_connected(interface=interface)
@property
def interfaces(self):
'''
List all available WiFi interfaces.
.. versionadded:: 1.4.0
'''
raise NotImplementedError()
def start_scanning(self, interface=None):
'''
Turn on scanning.
'''
return self._start_scanning(interface=interface)
def get_network_info(self, name):
'''
Return a dictionary of specified network.
'''
return self._get_network_info(name=name)
def get_available_wifi(self):
'''
Returns a list of all the available wifi.
'''
return self._get_available_wifi()
def connect(self, network, parameters, interface=None):
'''
Method to connect to some network.
'''
self._connect(
network=network,
parameters=parameters,
interface=interface
)
def disconnect(self, interface=None):
'''
To disconnect from some network.
'''
self._disconnect(interface=interface)
def enable(self):
'''
Wifi interface power state is set to "ON".
'''
self._enable()
def disable(self):
'''
Wifi interface power state is set to "OFF".
'''
self._disable()
# private
def _is_enabled(self):
raise NotImplementedError()
def _is_connected(self, interface=None):
raise NotImplementedError()
def _start_scanning(self, interface=None):
raise NotImplementedError()
def _get_network_info(self, **kwargs):
raise NotImplementedError()
def _get_available_wifi(self):
raise NotImplementedError()
def _connect(self, **kwargs):
raise NotImplementedError()
def _disconnect(self, interface=None):
raise NotImplementedError()
def _enable(self):
raise NotImplementedError()
def _disable(self):
raise NotImplementedError()
|
mit
|
[
2344,
199,
3848,
481,
645,
9587,
14,
199,
9152,
199,
199,
1918,
520,
533,
1705,
3848,
64,
365,
370,
5647,
2879,
370,
314,
7912,
402,
2195,
21305,
15,
19763,
199,
6410,
14,
199,
199,
7940,
5544,
5171,
658,
2242,
316,
3559,
658,
10673,
316,
3559,
658,
551,
11495,
3559,
658,
362,
1337,
199,
4561,
7912,
2784,
769,
64,
436,
658,
362,
1337,
2784,
2556,
2313,
199,
199,
3184,
7251,
199,
18964,
199,
199,
1378,
4756,
15,
7485,
641,
7912,
24928,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
199,
199,
25690,
314,
7912,
365,
5223,
15,
19136,
641,
12,
2066,
642,
1414,
9174,
370,
8000,
199,
452,
314,
17429,
991,
2808,
7912,
11759,
14,
199,
199,
1378,
664,
2784,
2256,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
272,
1306,
372,
7912,
14,
362,
63,
1200,
63,
815,
8,
354,
9,
199,
199,
3407,
2784,
2436,
402,
314,
2784,
3963,
1159,
536,
15,
23283,
365,
2741,
315,
314,
199,
64,
354,
64,
2725,
14,
199,
199,
1378,
4907,
370,
282,
2784,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
272,
1306,
7912,
14,
2242,
8,
1200,
12,
2633,
9,
199,
199,
2765,
4907,
83,
370,
314,
2784,
3963,
1159,
536,
15,
23283,
365,
2741,
1334,
658,
1200,
64,
199,
5329,
436,
3180,
543,
1163,
5784,
3102,
367,
1950,
199,
6777,
8350,
12188,
4298,
370,
4298,
14,
199,
199,
27567,
5684,
2569,
1584,
367,
1655,
2436,
3595,
9760,
402,
199,
64,
635,
323,
2393,
64,
1423,
315,
658,
2242,
64,
1083,
26,
339,
299,
590,
281,
15,
19601,
15,
2676,
15,
4326,
14,
647,
272,
299,
590,
281,
15,
19601,
15,
28546,
15,
4326,
14,
647,
272,
299,
590,
281,
15,
19601,
15,
2676,
15,
4326,
14,
647,
199,
199,
1378,
17639,
687,
7912,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
10673,
342,
199,
199,
2765,
17639,
83,
2195,
2243,
687,
1263,
7912,
2784,
14,
199,
199,
1378,
664,
2808,
7912,
11759,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
272,
1306,
372,
7912,
14,
362,
63,
4561,
63,
4326,
342,
199,
199,
2765,
2529,
1006,
314,
2808,
7912,
11759,
17429,
314,
2243,
14,
199,
199,
10682,
510,
4452,
3351,
199,
777,
2595,
199,
8647,
12,
4403,
1323,
12,
10130,
199,
199,
920,
26,
1227,
199,
9460,
199,
199,
504,
299,
590,
281,
492,
7912,
199,
4326,
14,
4296,
342,
199,
199,
2765,
22741,
7912,
2243,
14,
199,
199,
920,
26,
1520,
199,
9460,
199,
199,
504,
299,
590,
281,
492,
7912,
199,
4326,
14,
5993,
342,
199,
199,
2765,
3507,
7912,
2243,
199,
2344,
421,
199,
533,
644,
1903,
26,
272,
1449,
272,
644,
1903,
481,
645,
9587,
14,
272,
1449,
339,
347,
365,
63,
3827,
8,
277,
304,
267,
1449,
267,
1432,
5223,
2004,
402,
644,
73,
9047,
14991,
14,
267,
1449,
267,
372,
291,
423,
374,
63,
3827,
342,
339,
347,
365,
63,
7113,
8,
277,
12,
3217,
29,
403,
304,
267,
1449,
267,
1432,
1950,
1174,
402,
644,
73,
9047,
3217,
14,
398,
2508,
7445,
447,
413,
14,
20,
14,
16,
267,
1449,
267,
372,
291,
423,
374,
63,
7113,
8,
3266,
29,
3266,
9,
339,
768,
1829,
272,
347,
8386,
8,
277,
304,
267,
1449,
267,
3820,
1006,
2808,
644,
73,
9047,
8386,
14,
398,
2508,
7445,
447,
413,
14,
20,
14,
16,
267,
1449,
398,
746,
4279,
342,
339,
347,
1343,
63,
551,
11495,
8,
277,
12,
3217,
29,
403,
304,
267,
1449,
267,
16147,
641,
24928,
14,
267,
1449,
267,
372,
291,
423,
928,
63,
551,
11495,
8,
3266,
29,
3266,
9,
339,
347,
664,
63,
1200,
63,
815,
8,
277,
12,
536,
304,
267,
1449,
267,
1432,
282,
2600,
402,
2013,
2784,
14,
267,
1449,
267,
372,
291,
423,
362,
63,
1200,
63,
815,
8,
354,
29,
354,
9,
339,
347,
664,
63,
4561,
63,
4326,
8,
277,
304,
267,
1449,
267,
1803,
282,
769,
402,
1006,
314,
2808,
7912,
14,
267,
1449,
267,
372,
291,
423,
362,
63,
4561,
63,
4326,
342,
339,
347,
4907,
8,
277,
12,
2784,
12,
2633,
12,
3217,
29,
403,
304,
267,
1449,
267,
9075,
370,
4907,
370,
2005,
2784,
14,
267,
1449,
267,
291,
423,
2242,
8,
288,
2784,
29,
1200,
12,
288,
2633,
29,
3214,
12,
288,
3217,
29,
3266,
267,
776,
339,
347,
17639,
8,
277,
12,
3217,
29,
403,
304,
267,
1449,
267,
4005,
17639,
687,
2005,
2784,
14,
267,
1449,
267,
291,
423,
10673,
8,
3266,
29,
3266,
9,
339,
347,
4756,
8,
277,
304,
267,
1449,
267,
644,
1903,
3217,
7074,
1174,
365,
663,
370,
298,
615,
1674,
267,
1449,
267,
291,
423,
4296,
342,
339,
347,
3507,
8,
277,
304,
267,
1449,
267,
644,
1903,
3217,
7074,
1174,
365,
663,
370,
298,
7517,
1674,
267,
1449,
267,
291,
423,
5993,
342,
339,
327,
5726,
339,
347,
485,
374,
63,
3827,
8,
277,
304,
267,
746,
4279,
342,
339,
347,
485,
374,
63,
7113,
8,
277,
12,
3217,
29,
403,
304,
267,
746,
4279,
342,
339,
347,
485,
928,
63,
551,
11495,
8,
277,
12,
3217,
29,
403,
304,
267,
746,
4279,
342,
339,
347,
485,
362,
63,
1200,
63,
815,
8,
277,
12,
1011,
958,
304,
267,
746,
4279,
342,
339,
347,
485,
362,
63,
4561,
63,
4326,
8,
277,
304,
267,
746,
4279,
342,
339,
347,
485,
2242,
8,
277,
12,
1011,
958,
304,
267,
746,
4279,
342,
339,
347,
485,
10673,
8,
277,
12,
3217,
29,
403,
304,
267,
746,
4279,
342,
339,
347,
485,
4296,
8,
277,
304,
267,
746,
4279,
342,
339,
347,
485,
5993,
8,
277,
304,
267,
746,
4279,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
3848,
481,
645,
9587,
14,
199,
9152,
199,
199,
1918,
520,
533,
1705,
3848,
64,
365,
370,
5647,
2879,
370,
314,
7912,
402,
2195,
21305,
15,
19763,
199,
6410,
14,
199,
199,
7940,
5544,
5171,
658,
2242,
316,
3559,
658,
10673,
316,
3559,
658,
551,
11495,
3559,
658,
362,
1337,
199,
4561,
7912,
2784,
769,
64,
436,
658,
362,
1337,
2784,
2556,
2313,
199,
199,
3184,
7251,
199,
18964,
199,
199,
1378,
4756,
15,
7485,
641,
7912,
24928,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
199,
199,
25690,
314,
7912,
365,
5223,
15,
19136,
641,
12,
2066,
642,
1414,
9174,
370,
8000,
199,
452,
314,
17429,
991,
2808,
7912,
11759,
14,
199,
199,
1378,
664,
2784,
2256,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
272,
1306,
372,
7912,
14,
362,
63,
1200,
63,
815,
8,
354,
9,
199,
199,
3407,
2784,
2436,
402,
314,
2784,
3963,
1159,
536,
15,
23283,
365,
2741,
315,
314,
199,
64,
354,
64,
2725,
14,
199,
199,
1378,
4907,
370,
282,
2784,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
272,
1306,
7912,
14,
2242,
8,
1200,
12,
2633,
9,
199,
199,
2765,
4907,
83,
370,
314,
2784,
3963,
1159,
536,
15,
23283,
365,
2741,
1334,
658,
1200,
64,
199,
5329,
436,
3180,
543,
1163,
5784,
3102,
367,
1950,
199,
6777,
8350,
12188,
4298,
370,
4298,
14,
199,
199,
27567,
5684,
2569,
1584,
367,
1655,
2436,
3595,
9760,
402,
199,
64,
635,
323,
2393,
64,
1423,
315,
658,
2242,
64,
1083,
26,
339,
299,
590,
281,
15,
19601,
15,
2676,
15,
4326,
14,
647,
272,
299,
590,
281,
15,
19601,
15,
28546,
15,
4326,
14,
647,
272,
299,
590,
281,
15,
19601,
15,
2676,
15,
4326,
14,
647,
199,
199,
1378,
17639,
687,
7912,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
10673,
342,
199,
199,
2765,
17639,
83,
2195,
2243,
687,
1263,
7912,
2784,
14,
199,
199,
1378,
664,
2808,
7912,
11759,
447,
339,
1306,
687,
299,
590,
281,
492,
7912,
272,
1306,
7912,
14,
928,
63,
551,
11495,
342,
272,
1306,
372,
7912,
14,
362,
63,
4561,
63,
4326,
342,
199,
199,
2765,
2529,
1006,
314,
2808,
7912,
11759,
17429,
314,
2243,
14,
199,
199,
10682,
510,
4452,
3351,
199,
777,
2595,
199,
8647,
12,
4403,
1323,
12,
10130,
199,
199,
920,
26,
1227,
199,
9460,
199,
199,
504,
299,
590,
281,
492,
7912,
199,
4326,
14,
4296,
342,
199,
199,
2765,
22741,
7912,
2243,
14,
199,
199,
920,
26,
1520,
199,
9460,
199,
199,
504,
299,
590,
281,
492,
7912,
199,
4326,
14,
5993,
342,
199,
199,
2765,
3507,
7912,
2243,
199,
2344,
421,
199,
533,
644,
1903,
26,
272,
1449,
272,
644,
1903,
481,
645,
9587,
14,
272,
1449,
339,
347,
365,
63,
3827,
8,
277,
304,
267,
1449,
267,
1432,
5223,
2004,
402,
644,
73,
9047,
14991,
14,
267,
1449,
267,
372,
291,
423,
374,
63,
3827,
342,
339,
347,
365,
63,
7113,
8,
277,
12,
3217,
29,
403,
304,
267,
1449,
267,
1432,
1950,
1174,
402,
644,
73,
9047,
3217,
14,
398,
2508,
7445,
447,
413,
14,
20,
14,
16,
267,
1449,
267,
372,
291,
423,
374,
63,
7113,
8,
3266,
29,
3266,
9,
339,
768,
1829,
272,
347,
8386,
8,
277,
304,
267,
1449,
267,
3820,
1006,
2808,
644,
73,
9047,
8386,
14,
398,
2508,
7445,
447,
413,
14,
20,
14,
16,
267,
1449,
398,
746,
4279,
342,
339,
347,
1343,
63,
551,
11495,
8,
277,
12,
3217,
29,
403,
304,
267,
1449,
267,
16147,
641,
24928,
14,
267,
1449,
267,
372,
291,
423,
928,
63,
551,
11495,
8,
3266,
29,
3266,
9,
339,
347,
664,
63,
1200,
63,
815,
8,
277,
12,
536,
304,
267,
1449,
267,
1432,
282,
2600,
402,
2013,
2784,
14,
267,
1449,
267,
372,
291,
423,
362,
63,
1200,
63,
815,
8,
354,
29,
354,
9,
339,
347,
664,
63,
4561,
63,
4326,
8,
277,
304,
267,
1449,
267,
1803,
282,
769,
402,
1006,
314,
2808,
7912,
14,
267,
1449,
267,
372,
291,
423,
362,
63,
4561,
63,
4326,
342,
339,
347,
4907,
8,
277,
12,
2784,
12,
2633,
12,
3217,
29,
403,
304,
267,
1449,
267,
9075,
370,
4907,
370,
2005,
2784,
14,
267,
1449,
267,
291,
423,
2242,
8,
288,
2784,
29,
1200,
12,
288,
2633,
29,
3214,
12,
288,
3217,
29,
3266,
267,
776,
339,
347,
17639,
8,
277,
12,
3217,
29,
403,
304,
267,
1449,
267,
4005,
17639,
687,
2005,
2784,
14,
267,
1449,
267,
291,
423,
10673,
8,
3266,
29,
3266,
9,
339,
347,
4756,
8,
277,
304,
267,
1449,
267,
644,
1903,
3217,
7074,
1174,
365,
663,
370,
298,
615,
1674,
267,
1449,
267,
291,
423,
4296,
342,
339,
347,
3507,
8,
277,
304,
267,
1449,
267,
644,
1903,
3217,
7074,
1174,
365,
663,
370,
298,
7517,
1674,
267,
1449,
267,
291,
423,
5993,
342,
339,
327,
5726,
339,
347,
485,
374,
63,
3827,
8,
277,
304,
267,
746,
4279,
342,
339,
347,
485,
374,
63,
7113,
8,
277,
12,
3217,
29,
403,
304,
267,
746,
4279,
342,
339,
347,
485,
928,
63,
551,
11495,
8,
277,
12,
3217,
29,
403,
304,
267,
746,
4279,
342,
339,
347,
485,
362,
63,
1200,
63,
815,
8,
277,
12,
1011,
958,
304,
267,
746,
4279,
342,
339,
347,
485,
362,
63,
4561,
63,
4326,
8,
277,
304,
267,
746,
4279,
342,
339,
347,
485,
2242,
8,
277,
12,
1011,
958,
304,
267,
746,
4279,
342,
339,
347,
485,
10673,
8,
277,
12,
3217,
29,
403,
304,
267,
746,
4279,
342,
339,
347,
485,
4296,
8,
277,
304,
267,
746,
4279,
342,
339,
347,
485,
5993,
8,
277,
304,
267,
746,
4279,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
karllessard/tensorflow
|
tensorflow/python/autograph/converters/break_statements.py
|
14
|
5865
|
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Lowers break statements to conditionals."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.autograph.core import converter
from tensorflow.python.autograph.pyct import anno
from tensorflow.python.autograph.pyct import qual_names
from tensorflow.python.autograph.pyct import templates
from tensorflow.python.autograph.pyct.static_analysis import activity
from tensorflow.python.autograph.pyct.static_analysis.annos import NodeAnno
class _Break(object):
def __init__(self):
self.used = False
self.control_var_name = None
def __repr__(self):
return 'used: %s, var: %s' % (self.used, self.control_var_name)
class BreakTransformer(converter.Base):
"""Canonicalizes break statements into additional conditionals."""
def visit_Break(self, node):
self.state[_Break].used = True
var_name = self.state[_Break].control_var_name
# TODO(mdan): This will fail when expanded inside a top-level else block.
template = """
var_name = True
continue
"""
return templates.replace(template, var_name=var_name)
def _guard_if_present(self, block, var_name):
"""Prevents the block from executing if var_name is set."""
if not block:
return block
template = """
if not var_name:
block
"""
node = templates.replace(
template,
var_name=var_name,
block=block)
return node
def _process_body(self, nodes, break_var):
self.state[_Break].enter()
self.state[_Break].control_var_name = break_var
nodes = self.visit_block(nodes)
break_used = self.state[_Break].used
self.state[_Break].exit()
return nodes, break_used
def visit_While(self, node):
original_node = node
scope = anno.getanno(node, NodeAnno.BODY_SCOPE)
break_var = self.ctx.namer.new_symbol('break_', scope.referenced)
node.test = self.visit(node.test)
node.body, break_used = self._process_body(node.body, break_var)
# A break in the else clause applies to the containing scope.
node.orelse = self.visit_block(node.orelse)
if not break_used:
template = """
while test:
body
orelse
"""
node = templates.replace(
template, test=node.test, body=node.body, orelse=node.orelse)
new_while_node = node[0]
anno.copyanno(original_node, new_while_node, anno.Basic.DIRECTIVES)
return node
# Python's else clause only triggers if the loop exited cleanly (e.g.
# break did not trigger).
guarded_orelse = self._guard_if_present(node.orelse, break_var)
template = """
var_name = False
while not var_name and test:
body
orelse
"""
node = templates.replace(
template,
var_name=break_var,
test=node.test,
body=node.body,
orelse=guarded_orelse)
new_while_node = node[1]
anno.copyanno(original_node, new_while_node, anno.Basic.DIRECTIVES)
return node
def visit_For(self, node):
original_node = node
scope = anno.getanno(node, NodeAnno.BODY_SCOPE)
break_var = self.ctx.namer.new_symbol('break_', scope.referenced)
node.target = self.visit(node.target)
node.iter = self.visit(node.iter)
node.body, break_used = self._process_body(node.body, break_var)
# A break in the else clause applies to the containing scope.
node.orelse = self.visit_block(node.orelse)
if not break_used:
template = """
for target in iter_:
body
orelse
"""
node = templates.replace(
template,
iter_=node.iter,
target=node.target,
body=node.body,
orelse=node.orelse)
new_for_node = node[0]
anno.copyanno(original_node, new_for_node, anno.Basic.EXTRA_LOOP_TEST)
anno.copyanno(original_node, new_for_node, anno.Basic.DIRECTIVES)
return node
# Python's else clause only triggers if the loop exited cleanly (e.g.
# break did not trigger).
guarded_orelse = self._guard_if_present(node.orelse, break_var)
extra_test = templates.replace_as_expression(
'not var_name', var_name=break_var)
# The extra test is hidden in the AST, which will confuse the static
# analysis. To mitigate that, we insert a no-op statement that ensures
# the control variable is marked as used.
# TODO(mdan): Use a marker instead, e.g. ag__.condition_loop_on(var_name)
template = """
var_name = False
for target in iter_:
(var_name,)
body
orelse
"""
node = templates.replace(
template,
var_name=break_var,
iter_=node.iter,
target=node.target,
body=node.body,
orelse=guarded_orelse)
new_for_node = node[1]
anno.setanno(new_for_node, anno.Basic.EXTRA_LOOP_TEST, extra_test)
anno.copyanno(original_node, new_for_node, anno.Basic.DIRECTIVES)
return node
def transform(node, ctx):
node = qual_names.resolve(node)
node = activity.resolve(node, ctx, None)
transformer = BreakTransformer(ctx)
node = transformer.visit(node)
return node
|
apache-2.0
|
[
3,
1898,
9708,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
10281,
1192,
2059,
9834,
370,
29265,
1041,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
1018,
492,
11109,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
492,
22984,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
492,
6420,
63,
1247,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
492,
7009,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
14,
1986,
63,
10466,
492,
10679,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
14,
1986,
63,
10466,
14,
1189,
736,
492,
5013,
2493,
889,
421,
199,
533,
485,
13948,
8,
785,
304,
819,
347,
636,
826,
721,
277,
304,
272,
291,
14,
2972,
275,
756,
272,
291,
14,
2785,
63,
1391,
63,
354,
275,
488,
819,
347,
636,
2722,
721,
277,
304,
272,
372,
283,
2972,
26,
450,
83,
12,
2729,
26,
450,
83,
7,
450,
334,
277,
14,
2972,
12,
291,
14,
2785,
63,
1391,
63,
354,
9,
421,
199,
533,
22535,
19761,
8,
11256,
14,
1563,
304,
523,
408,
6049,
7174,
6491,
2059,
9834,
1901,
4722,
29265,
1041,
819,
347,
5684,
63,
13948,
8,
277,
12,
1031,
304,
272,
291,
14,
929,
13040,
13948,
1055,
2972,
275,
715,
272,
2729,
63,
354,
275,
291,
14,
929,
13040,
13948,
1055,
2785,
63,
1391,
63,
354,
272,
327,
3254,
8,
1064,
290,
304,
961,
911,
2449,
1380,
11507,
6272,
282,
2746,
13,
1896,
587,
1853,
14,
272,
1978,
275,
408,
489,
2729,
63,
354,
275,
715,
489,
1980,
272,
408,
272,
372,
7009,
14,
1814,
8,
1160,
12,
2729,
63,
354,
29,
1391,
63,
354,
9,
819,
347,
485,
15606,
63,
692,
63,
1881,
8,
277,
12,
1853,
12,
2729,
63,
354,
304,
272,
408,
2398,
782,
83,
314,
1853,
687,
14043,
340,
2729,
63,
354,
365,
663,
1041,
272,
340,
440,
1853,
26,
489,
372,
1853,
339,
1978,
275,
408,
267,
340,
440,
2729,
63,
354,
26,
881,
1853,
489,
408,
272,
1031,
275,
7009,
14,
1814,
8,
267,
1978,
12,
267,
2729,
63,
354,
29,
1391,
63,
354,
12,
267,
1853,
29,
1457,
9,
272,
372,
1031,
819,
347,
485,
1412,
63,
2030,
8,
277,
12,
3380,
12,
2059,
63,
1391,
304,
272,
291,
14,
929,
13040,
13948,
1055,
4200,
342,
272,
291,
14,
929,
13040,
13948,
1055,
2785,
63,
1391,
63,
354,
275,
2059,
63,
1391,
272,
3380,
275,
291,
14,
5427,
63,
1457,
8,
2415,
9,
272,
2059,
63,
2972,
275,
291,
14,
929,
13040,
13948,
1055,
2972,
272,
291,
14,
929,
13040,
13948,
1055,
2224,
342,
272,
372,
3380,
12,
2059,
63,
2972,
819,
347,
5684,
63,
25215,
8,
277,
12,
1031,
304,
272,
3379,
63,
932,
275,
1031,
272,
4194,
275,
22984,
14,
362,
25264,
8,
932,
12,
5013,
2493,
889,
14,
23708,
63,
17998,
9,
272,
2059,
63,
1391,
275,
291,
14,
3799,
14,
354,
82,
14,
1222,
63,
5155,
360,
4785,
14474,
4194,
14,
22355,
9,
339,
1031,
14,
396,
275,
291,
14,
5427,
8,
932,
14,
396,
9,
272,
1031,
14,
2030,
12,
2059,
63,
2972,
275,
291,
423,
1412,
63,
2030,
8,
932,
14,
2030,
12,
2059,
63,
1391,
9,
272,
327,
437,
2059,
315,
314,
587,
8502,
12966,
370,
314,
3035,
4194,
14,
272,
1031,
14,
720,
76,
261,
275,
291,
14,
5427,
63,
1457,
8,
932,
14,
720,
76,
261,
9,
339,
340,
440,
2059,
63,
2972,
26,
489,
1978,
275,
408,
267,
1830,
511,
26,
881,
2396,
267,
312,
3369,
261,
489,
408,
489,
1031,
275,
7009,
14,
1814,
8,
881,
1978,
12,
511,
29,
932,
14,
396,
12,
2396,
29,
932,
14,
2030,
12,
312,
3369,
261,
29,
932,
14,
720,
76,
261,
9,
2541,
892,
63,
6710,
63,
932,
275,
1031,
59,
16,
61,
489,
22984,
14,
1574,
25264,
8,
5043,
63,
932,
12,
892,
63,
6710,
63,
932,
12,
22984,
14,
6845,
14,
6098,
6882,
654,
9,
2541,
372,
1031,
339,
327,
2018,
1159,
587,
8502,
1454,
18899,
340,
314,
4438,
22987,
3633,
590,
334,
69,
14,
71,
14,
272,
327,
2059,
8103,
440,
6804,
680,
272,
8129,
12910,
63,
720,
76,
261,
275,
291,
423,
15606,
63,
692,
63,
1881,
8,
932,
14,
720,
76,
261,
12,
2059,
63,
1391,
9,
339,
1978,
275,
408,
489,
2729,
63,
354,
275,
756,
489,
1830,
440,
2729,
63,
354,
436,
511,
26,
267,
2396,
489,
312,
3369,
261,
272,
408,
272,
1031,
275,
7009,
14,
1814,
8,
267,
1978,
12,
267,
2729,
63,
354,
29,
4785,
63,
1391,
12,
267,
511,
29,
932,
14,
396,
12,
267,
2396,
29,
932,
14,
2030,
12,
267,
312,
3369,
261,
29,
6051,
12910,
63,
720,
76,
261,
9,
339,
892,
63,
6710,
63,
932,
275,
1031,
59,
17,
61,
272,
22984,
14,
1574,
25264,
8,
5043,
63,
932,
12,
892,
63,
6710,
63,
932,
12,
22984,
14,
6845,
14,
6098,
6882,
654,
9,
339,
372,
1031,
819,
347,
5684,
63,
1858,
8,
277,
12,
1031,
304,
272,
3379,
63,
932,
275,
1031,
272,
4194,
275,
22984,
14,
362,
25264,
8,
932,
12,
5013,
2493,
889,
14,
23708,
63,
17998,
9,
272,
2059,
63
] |
[
1898,
9708,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
10281,
1192,
2059,
9834,
370,
29265,
1041,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
1018,
492,
11109,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
492,
22984,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
492,
6420,
63,
1247,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
492,
7009,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
14,
1986,
63,
10466,
492,
10679,
199,
504,
3228,
14,
1548,
14,
2495,
2180,
14,
647,
319,
14,
1986,
63,
10466,
14,
1189,
736,
492,
5013,
2493,
889,
421,
199,
533,
485,
13948,
8,
785,
304,
819,
347,
636,
826,
721,
277,
304,
272,
291,
14,
2972,
275,
756,
272,
291,
14,
2785,
63,
1391,
63,
354,
275,
488,
819,
347,
636,
2722,
721,
277,
304,
272,
372,
283,
2972,
26,
450,
83,
12,
2729,
26,
450,
83,
7,
450,
334,
277,
14,
2972,
12,
291,
14,
2785,
63,
1391,
63,
354,
9,
421,
199,
533,
22535,
19761,
8,
11256,
14,
1563,
304,
523,
408,
6049,
7174,
6491,
2059,
9834,
1901,
4722,
29265,
1041,
819,
347,
5684,
63,
13948,
8,
277,
12,
1031,
304,
272,
291,
14,
929,
13040,
13948,
1055,
2972,
275,
715,
272,
2729,
63,
354,
275,
291,
14,
929,
13040,
13948,
1055,
2785,
63,
1391,
63,
354,
272,
327,
3254,
8,
1064,
290,
304,
961,
911,
2449,
1380,
11507,
6272,
282,
2746,
13,
1896,
587,
1853,
14,
272,
1978,
275,
408,
489,
2729,
63,
354,
275,
715,
489,
1980,
272,
408,
272,
372,
7009,
14,
1814,
8,
1160,
12,
2729,
63,
354,
29,
1391,
63,
354,
9,
819,
347,
485,
15606,
63,
692,
63,
1881,
8,
277,
12,
1853,
12,
2729,
63,
354,
304,
272,
408,
2398,
782,
83,
314,
1853,
687,
14043,
340,
2729,
63,
354,
365,
663,
1041,
272,
340,
440,
1853,
26,
489,
372,
1853,
339,
1978,
275,
408,
267,
340,
440,
2729,
63,
354,
26,
881,
1853,
489,
408,
272,
1031,
275,
7009,
14,
1814,
8,
267,
1978,
12,
267,
2729,
63,
354,
29,
1391,
63,
354,
12,
267,
1853,
29,
1457,
9,
272,
372,
1031,
819,
347,
485,
1412,
63,
2030,
8,
277,
12,
3380,
12,
2059,
63,
1391,
304,
272,
291,
14,
929,
13040,
13948,
1055,
4200,
342,
272,
291,
14,
929,
13040,
13948,
1055,
2785,
63,
1391,
63,
354,
275,
2059,
63,
1391,
272,
3380,
275,
291,
14,
5427,
63,
1457,
8,
2415,
9,
272,
2059,
63,
2972,
275,
291,
14,
929,
13040,
13948,
1055,
2972,
272,
291,
14,
929,
13040,
13948,
1055,
2224,
342,
272,
372,
3380,
12,
2059,
63,
2972,
819,
347,
5684,
63,
25215,
8,
277,
12,
1031,
304,
272,
3379,
63,
932,
275,
1031,
272,
4194,
275,
22984,
14,
362,
25264,
8,
932,
12,
5013,
2493,
889,
14,
23708,
63,
17998,
9,
272,
2059,
63,
1391,
275,
291,
14,
3799,
14,
354,
82,
14,
1222,
63,
5155,
360,
4785,
14474,
4194,
14,
22355,
9,
339,
1031,
14,
396,
275,
291,
14,
5427,
8,
932,
14,
396,
9,
272,
1031,
14,
2030,
12,
2059,
63,
2972,
275,
291,
423,
1412,
63,
2030,
8,
932,
14,
2030,
12,
2059,
63,
1391,
9,
272,
327,
437,
2059,
315,
314,
587,
8502,
12966,
370,
314,
3035,
4194,
14,
272,
1031,
14,
720,
76,
261,
275,
291,
14,
5427,
63,
1457,
8,
932,
14,
720,
76,
261,
9,
339,
340,
440,
2059,
63,
2972,
26,
489,
1978,
275,
408,
267,
1830,
511,
26,
881,
2396,
267,
312,
3369,
261,
489,
408,
489,
1031,
275,
7009,
14,
1814,
8,
881,
1978,
12,
511,
29,
932,
14,
396,
12,
2396,
29,
932,
14,
2030,
12,
312,
3369,
261,
29,
932,
14,
720,
76,
261,
9,
2541,
892,
63,
6710,
63,
932,
275,
1031,
59,
16,
61,
489,
22984,
14,
1574,
25264,
8,
5043,
63,
932,
12,
892,
63,
6710,
63,
932,
12,
22984,
14,
6845,
14,
6098,
6882,
654,
9,
2541,
372,
1031,
339,
327,
2018,
1159,
587,
8502,
1454,
18899,
340,
314,
4438,
22987,
3633,
590,
334,
69,
14,
71,
14,
272,
327,
2059,
8103,
440,
6804,
680,
272,
8129,
12910,
63,
720,
76,
261,
275,
291,
423,
15606,
63,
692,
63,
1881,
8,
932,
14,
720,
76,
261,
12,
2059,
63,
1391,
9,
339,
1978,
275,
408,
489,
2729,
63,
354,
275,
756,
489,
1830,
440,
2729,
63,
354,
436,
511,
26,
267,
2396,
489,
312,
3369,
261,
272,
408,
272,
1031,
275,
7009,
14,
1814,
8,
267,
1978,
12,
267,
2729,
63,
354,
29,
4785,
63,
1391,
12,
267,
511,
29,
932,
14,
396,
12,
267,
2396,
29,
932,
14,
2030,
12,
267,
312,
3369,
261,
29,
6051,
12910,
63,
720,
76,
261,
9,
339,
892,
63,
6710,
63,
932,
275,
1031,
59,
17,
61,
272,
22984,
14,
1574,
25264,
8,
5043,
63,
932,
12,
892,
63,
6710,
63,
932,
12,
22984,
14,
6845,
14,
6098,
6882,
654,
9,
339,
372,
1031,
819,
347,
5684,
63,
1858,
8,
277,
12,
1031,
304,
272,
3379,
63,
932,
275,
1031,
272,
4194,
275,
22984,
14,
362,
25264,
8,
932,
12,
5013,
2493,
889,
14,
23708,
63,
17998,
9,
272,
2059,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from test_base import TestBase
from tests.st.utils.docker_host import DockerHost
"""
Test calicoctl diags.
It's worth testing that the command can be executed. It's debatable whether
it's worth testing the upload.
We're not trying to assert on the contents of the diags package.
TODO We could check that the file is actually written (and doesn't just appear
in the output) and is a decent size.
TODO We could check collecting diags when calico-node is actually running.
"""
class TestDiags(TestBase):
def test_diags(self):
"""
Test that the diags command successfully creates a tar.gz file.
"""
with DockerHost('host', dind=False, start_calico=False) as host:
results = host.calicoctl("diags")
self.assertIn(".tar.gz", results)
|
apache-2.0
|
[
3,
1898,
6900,
10072,
305,
3111,
17138,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
511,
63,
1095,
492,
1379,
1563,
199,
504,
2295,
14,
270,
14,
1208,
14,
9991,
63,
1102,
492,
22067,
4965,
199,
199,
624,
199,
774,
3213,
12802,
8077,
487,
7391,
14,
199,
199,
7940,
1159,
25235,
5343,
626,
314,
1414,
883,
506,
7934,
14,
2779,
1159,
477,
13475,
461,
3775,
199,
390,
1159,
25235,
5343,
314,
5802,
14,
199,
199,
6004,
3984,
440,
9936,
370,
702,
641,
314,
4072,
402,
314,
487,
7391,
2559,
14,
199,
199,
11768,
2136,
4293,
1104,
626,
314,
570,
365,
5965,
5313,
334,
460,
3181,
1133,
2951,
7468,
199,
262,
314,
1072,
9,
436,
365,
282,
477,
2946,
1568,
14,
199,
11768,
2136,
4293,
1104,
32223,
487,
7391,
1380,
3213,
12802,
13,
932,
365,
5965,
3879,
14,
199,
624,
421,
199,
533,
1379,
1341,
7391,
8,
14440,
304,
272,
347,
511,
63,
2391,
458,
8,
277,
304,
267,
408,
267,
1379,
626,
314,
487,
7391,
1414,
8792,
8491,
282,
5330,
14,
6838,
570,
14,
267,
408,
267,
543,
22067,
4965,
360,
1102,
297,
366,
688,
29,
797,
12,
1343,
63,
915,
12802,
29,
797,
9,
465,
1591,
26,
288,
2058,
275,
1591,
14,
915,
12802,
8077,
480,
2391,
458,
531,
288,
291,
14,
4080,
9520,
5369,
14,
6838,
401,
2058,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6900,
10072,
305,
3111,
17138,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
511,
63,
1095,
492,
1379,
1563,
199,
504,
2295,
14,
270,
14,
1208,
14,
9991,
63,
1102,
492,
22067,
4965,
199,
199,
624,
199,
774,
3213,
12802,
8077,
487,
7391,
14,
199,
199,
7940,
1159,
25235,
5343,
626,
314,
1414,
883,
506,
7934,
14,
2779,
1159,
477,
13475,
461,
3775,
199,
390,
1159,
25235,
5343,
314,
5802,
14,
199,
199,
6004,
3984,
440,
9936,
370,
702,
641,
314,
4072,
402,
314,
487,
7391,
2559,
14,
199,
199,
11768,
2136,
4293,
1104,
626,
314,
570,
365,
5965,
5313,
334,
460,
3181,
1133,
2951,
7468,
199,
262,
314,
1072,
9,
436,
365,
282,
477,
2946,
1568,
14,
199,
11768,
2136,
4293,
1104,
32223,
487,
7391,
1380,
3213,
12802,
13,
932,
365,
5965,
3879,
14,
199,
624,
421,
199,
533,
1379,
1341,
7391,
8,
14440,
304,
272,
347,
511,
63,
2391,
458,
8,
277,
304,
267,
408,
267,
1379,
626,
314,
487,
7391,
1414,
8792,
8491,
282,
5330,
14,
6838,
570,
14,
267,
408,
267,
543,
22067,
4965,
360,
1102,
297,
366,
688,
29,
797,
12,
1343,
63,
915,
12802,
29,
797,
9,
465,
1591,
26,
288,
2058,
275,
1591,
14,
915,
12802,
8077,
480,
2391,
458,
531,
288,
291,
14,
4080,
9520,
5369,
14,
6838,
401,
2058,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jbonofre/beam
|
sdks/python/apache_beam/io/avroio.py
|
9
|
17237
|
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""``PTransforms`` for reading from and writing to Avro files.
Provides two read ``PTransform``s, ``ReadFromAvro`` and ``ReadAllFromAvro``,
that produces a ``PCollection`` of records.
Each record of this ``PCollection`` will contain a single record read from
an Avro file. Records that are of simple types will be mapped into
corresponding Python types. Records that are of Avro type 'RECORD' will be
mapped to Python dictionaries that comply with the schema contained in the
Avro file that contains those records. In this case, keys of each dictionary
will contain the corresponding field names and will be of type ``string``
while the values of the dictionary will be of the type defined in the
corresponding Avro schema.
For example, if schema of the Avro file is the following.
{"namespace": "example.avro","type": "record","name": "User","fields":
[{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["int", "null"]},
{"name": "favorite_color", "type": ["string", "null"]}]}
Then records generated by read transforms will be dictionaries of the
following form.
{u'name': u'Alyssa', u'favorite_number': 256, u'favorite_color': None}).
Additionally, this module provides a write ``PTransform`` ``WriteToAvro``
that can be used to write a given ``PCollection`` of Python objects to an
Avro file.
"""
import cStringIO
import os
import zlib
from functools import partial
import avro
from avro import io as avroio
from avro import datafile
from avro import schema
import apache_beam as beam
from apache_beam.io import filebasedsink
from apache_beam.io import filebasedsource
from apache_beam.io import iobase
from apache_beam.io.filesystem import CompressionTypes
from apache_beam.io.iobase import Read
from apache_beam.transforms import PTransform
__all__ = ['ReadFromAvro', 'ReadAllFromAvro', 'WriteToAvro']
class ReadFromAvro(PTransform):
"""A :class:`~apache_beam.transforms.ptransform.PTransform` for reading avro
files."""
def __init__(self, file_pattern=None, min_bundle_size=0, validate=True):
"""Initializes :class:`ReadFromAvro`.
Uses source :class:`~apache_beam.io._AvroSource` to read a set of Avro
files defined by a given file pattern.
If ``/mypath/myavrofiles*`` is a file-pattern that points to a set of Avro
files, a :class:`~apache_beam.pvalue.PCollection` for the records in
these Avro files can be created in the following manner.
.. testcode::
with beam.Pipeline() as p:
records = p | 'Read' >> beam.io.ReadFromAvro('/mypath/myavrofiles*')
.. NOTE: We're not actually interested in this error; but if we get here,
it means that the way of calling this transform hasn't changed.
.. testoutput::
:hide:
Traceback (most recent call last):
...
IOError: No files found based on the file pattern
Each record of this :class:`~apache_beam.pvalue.PCollection` will contain
a single record read from a source. Records that are of simple types will be
mapped into corresponding Python types. Records that are of Avro type
``RECORD`` will be mapped to Python dictionaries that comply with the schema
contained in the Avro file that contains those records. In this case, keys
of each dictionary will contain the corresponding field names and will be of
type :class:`str` while the values of the dictionary will be of the type
defined in the corresponding Avro schema.
For example, if schema of the Avro file is the following. ::
{
"namespace": "example.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "name",
"type": "string"},
{"name": "favorite_number",
"type": ["int", "null"]},
{"name": "favorite_color",
"type": ["string", "null"]}
]
}
Then records generated by :class:`~apache_beam.io._AvroSource` will be
dictionaries of the following form. ::
{u'name': u'Alyssa', u'favorite_number': 256, u'favorite_color': None}).
Args:
file_pattern (str): the file glob to read
min_bundle_size (int): the minimum size in bytes, to be considered when
splitting the input into bundles.
validate (bool): flag to verify that the files exist during the pipeline
creation time.
"""
super(ReadFromAvro, self).__init__()
self._source = _AvroSource(file_pattern, min_bundle_size, validate=validate)
def expand(self, pvalue):
return pvalue.pipeline | Read(self._source)
def display_data(self):
return {'source_dd': self._source}
class ReadAllFromAvro(PTransform):
"""A ``PTransform`` for reading ``PCollection`` of Avro files.
Uses source '_AvroSource' to read a ``PCollection`` of Avro files or
file patterns and produce a ``PCollection`` of Avro records.
"""
DEFAULT_DESIRED_BUNDLE_SIZE = 64 * 1024 * 1024 # 64MB
def __init__(self, min_bundle_size=0,
desired_bundle_size=DEFAULT_DESIRED_BUNDLE_SIZE):
"""Initializes ``ReadAllFromAvro``.
Args:
min_bundle_size: the minimum size in bytes, to be considered when
splitting the input into bundles.
desired_bundle_size: the desired size in bytes, to be considered when
splitting the input into bundles.
"""
source_from_file = partial(
_create_avro_source, min_bundle_size=min_bundle_size)
self._read_all_files = filebasedsource.ReadAllFiles(
True, CompressionTypes.AUTO, desired_bundle_size, min_bundle_size,
source_from_file)
def expand(self, pvalue):
return pvalue | 'ReadAllFiles' >> self._read_all_files
class _AvroUtils(object):
@staticmethod
def read_meta_data_from_file(f):
"""Reads metadata from a given Avro file.
Args:
f: Avro file to read.
Returns:
a tuple containing the codec, schema, and the sync marker of the Avro
file.
Raises:
ValueError: if the file does not start with the byte sequence defined in
the specification.
"""
if f.tell() > 0:
f.seek(0)
decoder = avroio.BinaryDecoder(f)
header = avroio.DatumReader().read_data(datafile.META_SCHEMA,
datafile.META_SCHEMA, decoder)
if header.get('magic') != datafile.MAGIC:
raise ValueError('Not an Avro file. File header should start with %s but'
'started with %s instead.', datafile.MAGIC,
header.get('magic'))
meta = header['meta']
if datafile.CODEC_KEY in meta:
codec = meta[datafile.CODEC_KEY]
else:
codec = 'null'
schema_string = meta[datafile.SCHEMA_KEY]
sync_marker = header['sync']
return codec, schema_string, sync_marker
@staticmethod
def read_block_from_file(f, codec, schema, expected_sync_marker):
"""Reads a block from a given Avro file.
Args:
f: Avro file to read.
codec: The codec to use for block-level decompression.
Supported codecs: 'null', 'deflate', 'snappy'
schema: Avro Schema definition represented as JSON string.
expected_sync_marker: Avro synchronization marker. If the block's sync
marker does not match with this parameter then ValueError is thrown.
Returns:
A single _AvroBlock.
Raises:
ValueError: If the block cannot be read properly because the file doesn't
match the specification.
"""
offset = f.tell()
decoder = avroio.BinaryDecoder(f)
num_records = decoder.read_long()
block_size = decoder.read_long()
block_bytes = decoder.read(block_size)
sync_marker = decoder.read(len(expected_sync_marker))
if sync_marker != expected_sync_marker:
raise ValueError('Unexpected sync marker (actual "%s" vs expected "%s"). '
'Maybe the underlying avro file is corrupted?',
sync_marker, expected_sync_marker)
size = f.tell() - offset
return _AvroBlock(block_bytes, num_records, codec, schema, offset, size)
@staticmethod
def advance_file_past_next_sync_marker(f, sync_marker):
buf_size = 10000
data = f.read(buf_size)
while data:
pos = data.find(sync_marker)
if pos >= 0:
# Adjusting the current position to the ending position of the sync
# marker.
backtrack = len(data) - pos - len(sync_marker)
f.seek(-1 * backtrack, os.SEEK_CUR)
return True
else:
if f.tell() >= len(sync_marker):
# Backtracking in case we partially read the sync marker during the
# previous read. We only have to backtrack if there are at least
# len(sync_marker) bytes before current position. We only have to
# backtrack (len(sync_marker) - 1) bytes.
f.seek(-1 * (len(sync_marker) - 1), os.SEEK_CUR)
data = f.read(buf_size)
def _create_avro_source(file_pattern=None, min_bundle_size=None):
return _AvroSource(
file_pattern=file_pattern, min_bundle_size=min_bundle_size,
validate=False)
class _AvroBlock(object):
"""Represents a block of an Avro file."""
def __init__(self, block_bytes, num_records, codec, schema_string,
offset, size):
# Decompress data early on (if needed) and thus decrease the number of
# parallel copies of the data in memory at any given in time during
# block iteration.
self._decompressed_block_bytes = self._decompress_bytes(block_bytes, codec)
self._num_records = num_records
self._schema = schema.parse(schema_string)
self._offset = offset
self._size = size
def size(self):
return self._size
def offset(self):
return self._offset
@staticmethod
def _decompress_bytes(data, codec):
if codec == 'null':
return data
elif codec == 'deflate':
# zlib.MAX_WBITS is the window size. '-' sign indicates that this is
# raw data (without headers). See zlib and Avro documentations for more
# details.
return zlib.decompress(data, -zlib.MAX_WBITS)
elif codec == 'snappy':
# Snappy is an optional avro codec.
# See Snappy and Avro documentation for more details.
try:
import snappy
except ImportError:
raise ValueError('Snappy does not seem to be installed.')
# Compressed data includes a 4-byte CRC32 checksum which we verify.
# We take care to avoid extra copies of data while slicing large objects
# by use of a buffer.
result = snappy.decompress(buffer(data)[:-4])
avroio.BinaryDecoder(cStringIO.StringIO(data[-4:])).check_crc32(result)
return result
else:
raise ValueError('Unknown codec: %r', codec)
def num_records(self):
return self._num_records
def records(self):
decoder = avroio.BinaryDecoder(
cStringIO.StringIO(self._decompressed_block_bytes))
reader = avroio.DatumReader(
writers_schema=self._schema, readers_schema=self._schema)
current_record = 0
while current_record < self._num_records:
yield reader.read(decoder)
current_record += 1
class _AvroSource(filebasedsource.FileBasedSource):
"""A source for reading Avro files.
``_AvroSource`` is implemented using the file-based source framework available
in module 'filebasedsource'. Hence please refer to module 'filebasedsource'
to fully understand how this source implements operations common to all
file-based sources such as file-pattern expansion and splitting into bundles
for parallel processing.
"""
def read_records(self, file_name, range_tracker):
next_block_start = -1
def split_points_unclaimed(stop_position):
if next_block_start >= stop_position:
# Next block starts at or after the suggested stop position. Hence
# there will not be split points to be claimed for the range ending at
# suggested stop position.
return 0
return iobase.RangeTracker.SPLIT_POINTS_UNKNOWN
range_tracker.set_split_points_unclaimed_callback(split_points_unclaimed)
start_offset = range_tracker.start_position()
if start_offset is None:
start_offset = 0
with self.open_file(file_name) as f:
codec, schema_string, sync_marker = _AvroUtils.read_meta_data_from_file(
f)
# We have to start at current position if previous bundle ended at the
# end of a sync marker.
start_offset = max(0, start_offset - len(sync_marker))
f.seek(start_offset)
_AvroUtils.advance_file_past_next_sync_marker(f, sync_marker)
while range_tracker.try_claim(f.tell()):
block = _AvroUtils.read_block_from_file(f, codec, schema_string,
sync_marker)
next_block_start = block.offset() + block.size()
for record in block.records():
yield record
class WriteToAvro(beam.transforms.PTransform):
"""A ``PTransform`` for writing avro files."""
def __init__(self,
file_path_prefix,
schema,
codec='deflate',
file_name_suffix='',
num_shards=0,
shard_name_template=None,
mime_type='application/x-avro'):
"""Initialize a WriteToAvro transform.
Args:
file_path_prefix: The file path to write to. The files written will begin
with this prefix, followed by a shard identifier (see num_shards), and
end in a common extension, if given by file_name_suffix. In most cases,
only this argument is specified and num_shards, shard_name_template, and
file_name_suffix use default values.
schema: The schema to use, as returned by avro.schema.parse
codec: The codec to use for block-level compression. Any string supported
by the Avro specification is accepted (for example 'null').
file_name_suffix: Suffix for the files written.
num_shards: The number of files (shards) used for output. If not set, the
service will decide on the optimal number of shards.
Constraining the number of shards is likely to reduce
the performance of a pipeline. Setting this value is not recommended
unless you require a specific number of output files.
shard_name_template: A template string containing placeholders for
the shard number and shard count. When constructing a filename for a
particular shard number, the upper-case letters 'S' and 'N' are
replaced with the 0-padded shard number and shard count respectively.
This argument can be '' in which case it behaves as if num_shards was
set to 1 and only one file will be generated. The default pattern used
is '-SSSSS-of-NNNNN' if None is passed as the shard_name_template.
mime_type: The MIME type to use for the produced files, if the filesystem
supports specifying MIME types.
Returns:
A WriteToAvro transform usable for writing.
"""
self._sink = _AvroSink(file_path_prefix, schema, codec, file_name_suffix,
num_shards, shard_name_template, mime_type)
def expand(self, pcoll):
return pcoll | beam.io.iobase.Write(self._sink)
def display_data(self):
return {'sink_dd': self._sink}
class _AvroSink(filebasedsink.FileBasedSink):
"""A sink to avro files."""
def __init__(self,
file_path_prefix,
schema,
codec,
file_name_suffix,
num_shards,
shard_name_template,
mime_type):
super(_AvroSink, self).__init__(
file_path_prefix,
file_name_suffix=file_name_suffix,
num_shards=num_shards,
shard_name_template=shard_name_template,
coder=None,
mime_type=mime_type,
# Compression happens at the block level using the supplied codec, and
# not at the file level.
compression_type=CompressionTypes.UNCOMPRESSED)
self._schema = schema
self._codec = codec
def open(self, temp_path):
file_handle = super(_AvroSink, self).open(temp_path)
return avro.datafile.DataFileWriter(
file_handle, avro.io.DatumWriter(), self._schema, self._codec)
def write_record(self, writer, value):
writer.append(value)
def display_data(self):
res = super(self.__class__, self).display_data()
res['codec'] = str(self._codec)
res['schema'] = str(self._schema)
return res
|
apache-2.0
|
[
3,
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
1040,
48,
3188,
3351,
1040,
367,
7664,
687,
436,
3575,
370,
16599,
293,
1584,
14,
199,
199,
17473,
2877,
1586,
1124,
48,
6939,
1040,
83,
12,
1124,
3284,
2532,
6651,
293,
1040,
436,
1124,
3284,
2422,
2532,
6651,
293,
4542,
199,
9099,
16904,
282,
1124,
48,
7768,
1040,
402,
5767,
14,
199,
22321,
2777,
402,
642,
1124,
48,
7768,
1040,
911,
1395,
282,
2849,
2777,
1586,
687,
199,
290,
16599,
293,
570,
14,
799,
3692,
626,
787,
402,
3486,
2943,
911,
506,
9994,
1901,
199,
989,
31137,
2018,
2943,
14,
799,
3692,
626,
787,
402,
16599,
293,
730,
283,
15060,
7,
911,
506,
199,
11663,
370,
2018,
11196,
626,
1013,
590,
543,
314,
4177,
10470,
315,
314,
199,
6651,
293,
570,
626,
3509,
5204,
5767,
14,
1010,
642,
1930,
12,
2883,
402,
1924,
2600,
199,
14117,
1395,
314,
5226,
901,
1561,
436,
911,
506,
402,
730,
1124,
875,
1040,
199,
6710,
314,
1338,
402,
314,
2600,
911,
506,
402,
314,
730,
3247,
315,
314,
199,
989,
31137,
16599,
293,
4177,
14,
199,
199,
1858,
2893,
12,
340,
4177,
402,
314,
16599,
293,
570,
365,
314,
2569,
14,
199,
6641,
3251,
582,
298,
2694,
14,
1214,
293,
2266,
466,
582,
298,
3059,
2266,
354,
582,
298,
1899,
2266,
955,
582,
199,
59,
6641,
354,
582,
298,
354,
401,
298,
466,
582,
298,
875,
6018,
199,
6641,
354,
582,
298,
23874,
63,
1955,
401,
221,
298,
466,
582,
2097,
442,
401,
298,
2307,
19057,
199,
6641,
354,
582,
298,
23874,
63,
2326,
401,
298,
466,
582,
2097,
875,
401,
298,
2307,
27635,
9420,
199,
199,
28226,
5767,
4046,
701,
1586,
18501,
911,
506,
11196,
402,
314,
199,
21589,
1824,
14,
199,
91,
85,
7,
354,
356,
399,
7,
33,
590,
28023,
297,
399,
7,
23874,
63,
1955,
356,
7633,
12,
399,
7,
23874,
63,
2326,
356,
488,
21385,
199,
199,
2767,
22565,
12,
642,
859,
6571,
282,
2218,
1124,
48,
6939,
1040,
1124,
3534,
1378,
6651,
293,
1040,
199,
9099,
883,
506,
1202,
370,
2218,
282,
1627,
1124,
48,
7768,
1040,
402,
2018,
2251,
370,
376,
199,
6651,
293,
570,
14,
199,
624,
199,
199,
646,
15073,
199,
646,
747,
199,
646,
12472,
199,
504,
9143,
492,
7417,
199,
199,
646,
2289,
293,
199,
504,
2289,
293,
492,
5890,
465,
2289,
293,
2308,
199,
504,
2289,
293,
492,
666,
493,
199,
504,
2289,
293,
492,
4177,
199,
199,
646,
17098,
63,
14529,
465,
17453,
199,
504,
17098,
63,
14529,
14,
2308,
492,
570,
1095,
795,
2292,
199,
504,
17098,
63,
14529,
14,
2308,
492,
570,
1095,
795,
616,
199,
504,
17098,
63,
14529,
14,
2308,
492,
5890,
1095,
199,
504,
17098,
63,
14529,
14,
2308,
14,
11381,
492,
3599,
1941,
4100,
199,
504,
17098,
63,
14529,
14,
2308,
14,
2308,
1095,
492,
5574,
199,
504,
17098,
63,
14529,
14,
15133,
492,
510,
6939,
199,
199,
363,
452,
363,
275,
788,
3284,
2532,
6651,
293,
297,
283,
3284,
2422,
2532,
6651,
293,
297,
283,
3534,
1378,
6651,
293,
418,
421,
199,
533,
5574,
2532,
6651,
293,
8,
48,
6939,
304,
523,
408,
33,
520,
533,
6054,
3796,
63,
14529,
14,
15133,
14,
80,
4711,
14,
48,
6939,
64,
367,
7664,
2289,
293,
523,
1584,
1041,
819,
347,
636,
826,
721,
277,
12,
570,
63,
3401,
29,
403,
12,
1748,
63,
6469,
63,
890,
29,
16,
12,
4107,
29,
549,
304,
272,
408,
23489,
520,
533,
1705,
3284,
2532,
6651,
293,
2313,
339,
14911,
1350,
520,
533,
6054,
3796,
63,
14529,
14,
2308,
423,
6651,
293,
2980,
64,
370,
1586,
282,
663,
402,
16599,
293,
272,
1584,
3247,
701,
282,
1627,
570,
3851,
14,
339,
982,
1124,
15,
1662,
515,
15,
1662,
1214,
293,
1725,
10,
1040,
365,
282,
570,
13,
3401,
626,
4501,
370,
282,
663,
402,
16599,
293,
272,
1584,
12,
282,
520,
533,
6054,
3796,
63,
14529,
14,
80,
585,
14,
48,
7768,
64,
367,
314,
5767,
315,
272,
3520,
16599,
293,
1584,
883,
506,
2737,
315,
314,
2569,
30800,
14,
339,
2508,
511,
600,
447,
2541,
543,
17453,
14,
17562,
342,
465,
299,
26,
267,
5767,
275,
299,
1204,
283,
3284,
7,
4331,
17453,
14,
2308,
14,
3284,
2532,
6651,
293,
2336,
1662,
515,
15,
1662,
1214,
293,
1725,
13418,
339,
2508,
6944,
26,
2136,
3984,
440,
5965,
22201,
315,
642,
1125,
27,
1325,
340,
781,
664,
2348,
12,
2126,
652,
4910,
626,
314,
4340,
402,
6358,
642,
5793,
18699,
1133,
2896,
14,
339,
2508,
511,
1199,
447,
489,
520,
8191,
26,
2541,
15273,
334,
2786,
8058,
1240,
2061,
304,
2126,
2263,
489,
5925,
26,
3091,
1584,
1911,
4079,
641,
314,
570,
3851,
339,
7048,
2777,
402,
642,
520,
533,
6054,
3796,
63,
14529,
14,
80,
585,
14,
48,
7768,
64,
911,
1395,
272,
282,
2849,
2777,
1586,
687,
282,
1350,
14,
799,
3692,
626,
787,
402,
3486,
2943,
911,
506,
272,
9994,
1901,
5226,
2018,
2943,
14,
799,
3692,
626,
787,
402,
16599,
293,
730,
272,
1124,
15060,
1040,
911,
506,
9994,
370,
2018,
11196,
626,
1013,
590,
543,
314,
4177,
272,
10470,
315,
314,
16599,
293,
570,
626,
3509,
5204,
5767,
14
] |
[
199,
3,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
11615,
4190,
14024,
14,
221,
1666,
314,
12840,
570,
1854,
543,
199,
3,
642,
1736,
367,
4722,
2556,
12602,
4248,
12715,
14,
199,
3,
710,
14857,
12378,
642,
570,
370,
2047,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
199,
3,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
199,
3,
314,
844,
14,
221,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
259,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
1040,
48,
3188,
3351,
1040,
367,
7664,
687,
436,
3575,
370,
16599,
293,
1584,
14,
199,
199,
17473,
2877,
1586,
1124,
48,
6939,
1040,
83,
12,
1124,
3284,
2532,
6651,
293,
1040,
436,
1124,
3284,
2422,
2532,
6651,
293,
4542,
199,
9099,
16904,
282,
1124,
48,
7768,
1040,
402,
5767,
14,
199,
22321,
2777,
402,
642,
1124,
48,
7768,
1040,
911,
1395,
282,
2849,
2777,
1586,
687,
199,
290,
16599,
293,
570,
14,
799,
3692,
626,
787,
402,
3486,
2943,
911,
506,
9994,
1901,
199,
989,
31137,
2018,
2943,
14,
799,
3692,
626,
787,
402,
16599,
293,
730,
283,
15060,
7,
911,
506,
199,
11663,
370,
2018,
11196,
626,
1013,
590,
543,
314,
4177,
10470,
315,
314,
199,
6651,
293,
570,
626,
3509,
5204,
5767,
14,
1010,
642,
1930,
12,
2883,
402,
1924,
2600,
199,
14117,
1395,
314,
5226,
901,
1561,
436,
911,
506,
402,
730,
1124,
875,
1040,
199,
6710,
314,
1338,
402,
314,
2600,
911,
506,
402,
314,
730,
3247,
315,
314,
199,
989,
31137,
16599,
293,
4177,
14,
199,
199,
1858,
2893,
12,
340,
4177,
402,
314,
16599,
293,
570,
365,
314,
2569,
14,
199,
6641,
3251,
582,
298,
2694,
14,
1214,
293,
2266,
466,
582,
298,
3059,
2266,
354,
582,
298,
1899,
2266,
955,
582,
199,
59,
6641,
354,
582,
298,
354,
401,
298,
466,
582,
298,
875,
6018,
199,
6641,
354,
582,
298,
23874,
63,
1955,
401,
221,
298,
466,
582,
2097,
442,
401,
298,
2307,
19057,
199,
6641,
354,
582,
298,
23874,
63,
2326,
401,
298,
466,
582,
2097,
875,
401,
298,
2307,
27635,
9420,
199,
199,
28226,
5767,
4046,
701,
1586,
18501,
911,
506,
11196,
402,
314,
199,
21589,
1824,
14,
199,
91,
85,
7,
354,
356,
399,
7,
33,
590,
28023,
297,
399,
7,
23874,
63,
1955,
356,
7633,
12,
399,
7,
23874,
63,
2326,
356,
488,
21385,
199,
199,
2767,
22565,
12,
642,
859,
6571,
282,
2218,
1124,
48,
6939,
1040,
1124,
3534,
1378,
6651,
293,
1040,
199,
9099,
883,
506,
1202,
370,
2218,
282,
1627,
1124,
48,
7768,
1040,
402,
2018,
2251,
370,
376,
199,
6651,
293,
570,
14,
199,
624,
199,
199,
646,
15073,
199,
646,
747,
199,
646,
12472,
199,
504,
9143,
492,
7417,
199,
199,
646,
2289,
293,
199,
504,
2289,
293,
492,
5890,
465,
2289,
293,
2308,
199,
504,
2289,
293,
492,
666,
493,
199,
504,
2289,
293,
492,
4177,
199,
199,
646,
17098,
63,
14529,
465,
17453,
199,
504,
17098,
63,
14529,
14,
2308,
492,
570,
1095,
795,
2292,
199,
504,
17098,
63,
14529,
14,
2308,
492,
570,
1095,
795,
616,
199,
504,
17098,
63,
14529,
14,
2308,
492,
5890,
1095,
199,
504,
17098,
63,
14529,
14,
2308,
14,
11381,
492,
3599,
1941,
4100,
199,
504,
17098,
63,
14529,
14,
2308,
14,
2308,
1095,
492,
5574,
199,
504,
17098,
63,
14529,
14,
15133,
492,
510,
6939,
199,
199,
363,
452,
363,
275,
788,
3284,
2532,
6651,
293,
297,
283,
3284,
2422,
2532,
6651,
293,
297,
283,
3534,
1378,
6651,
293,
418,
421,
199,
533,
5574,
2532,
6651,
293,
8,
48,
6939,
304,
523,
408,
33,
520,
533,
6054,
3796,
63,
14529,
14,
15133,
14,
80,
4711,
14,
48,
6939,
64,
367,
7664,
2289,
293,
523,
1584,
1041,
819,
347,
636,
826,
721,
277,
12,
570,
63,
3401,
29,
403,
12,
1748,
63,
6469,
63,
890,
29,
16,
12,
4107,
29,
549,
304,
272,
408,
23489,
520,
533,
1705,
3284,
2532,
6651,
293,
2313,
339,
14911,
1350,
520,
533,
6054,
3796,
63,
14529,
14,
2308,
423,
6651,
293,
2980,
64,
370,
1586,
282,
663,
402,
16599,
293,
272,
1584,
3247,
701,
282,
1627,
570,
3851,
14,
339,
982,
1124,
15,
1662,
515,
15,
1662,
1214,
293,
1725,
10,
1040,
365,
282,
570,
13,
3401,
626,
4501,
370,
282,
663,
402,
16599,
293,
272,
1584,
12,
282,
520,
533,
6054,
3796,
63,
14529,
14,
80,
585,
14,
48,
7768,
64,
367,
314,
5767,
315,
272,
3520,
16599,
293,
1584,
883,
506,
2737,
315,
314,
2569,
30800,
14,
339,
2508,
511,
600,
447,
2541,
543,
17453,
14,
17562,
342,
465,
299,
26,
267,
5767,
275,
299,
1204,
283,
3284,
7,
4331,
17453,
14,
2308,
14,
3284,
2532,
6651,
293,
2336,
1662,
515,
15,
1662,
1214,
293,
1725,
13418,
339,
2508,
6944,
26,
2136,
3984,
440,
5965,
22201,
315,
642,
1125,
27,
1325,
340,
781,
664,
2348,
12,
2126,
652,
4910,
626,
314,
4340,
402,
6358,
642,
5793,
18699,
1133,
2896,
14,
339,
2508,
511,
1199,
447,
489,
520,
8191,
26,
2541,
15273,
334,
2786,
8058,
1240,
2061,
304,
2126,
2263,
489,
5925,
26,
3091,
1584,
1911,
4079,
641,
314,
570,
3851,
339,
7048,
2777,
402,
642,
520,
533,
6054,
3796,
63,
14529,
14,
80,
585,
14,
48,
7768,
64,
911,
1395,
272,
282,
2849,
2777,
1586,
687,
282,
1350,
14,
799,
3692,
626,
787,
402,
3486,
2943,
911,
506,
272,
9994,
1901,
5226,
2018,
2943,
14,
799,
3692,
626,
787,
402,
16599,
293,
730,
272,
1124,
15060,
1040,
911,
506,
9994,
370,
2018,
11196,
626,
1013,
590,
543,
314,
4177,
272,
10470,
315,
314,
16599,
293,
570,
626,
3509,
5204,
5767,
14,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rogerscristo/BotFWD
|
env/lib/python3.6/site-packages/telegram/vendor/ptb_urllib3/urllib3/exceptions.py
|
8
|
6849
|
from __future__ import absolute_import
from .packages.six.moves.http_client import (
IncompleteRead as httplib_IncompleteRead
)
# Base Exceptions
class HTTPError(Exception):
"Base exception used by this module."
pass
class HTTPWarning(Warning):
"Base warning used by this module."
pass
class PoolError(HTTPError):
"Base exception for errors caused within a pool."
def __init__(self, pool, message):
self.pool = pool
HTTPError.__init__(self, "%s: %s" % (pool, message))
def __reduce__(self):
# For pickling purposes.
return self.__class__, (None, None)
class RequestError(PoolError):
"Base exception for PoolErrors that have associated URLs."
def __init__(self, pool, url, message):
self.url = url
PoolError.__init__(self, pool, message)
def __reduce__(self):
# For pickling purposes.
return self.__class__, (None, self.url, None)
class SSLError(HTTPError):
"Raised when SSL certificate fails in an HTTPS connection."
pass
class ProxyError(HTTPError):
"Raised when the connection to a proxy fails."
pass
class DecodeError(HTTPError):
"Raised when automatic decoding based on Content-Type fails."
pass
class ProtocolError(HTTPError):
"Raised when something unexpected happens mid-request/response."
pass
#: Renamed to ProtocolError but aliased for backwards compatibility.
ConnectionError = ProtocolError
# Leaf Exceptions
class MaxRetryError(RequestError):
"""Raised when the maximum number of retries is exceeded.
:param pool: The connection pool
:type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
:param string url: The requested Url
:param exceptions.Exception reason: The underlying error
"""
def __init__(self, pool, url, reason=None):
self.reason = reason
message = "Max retries exceeded with url: %s (Caused by %r)" % (
url, reason)
RequestError.__init__(self, pool, url, message)
class HostChangedError(RequestError):
"Raised when an existing pool gets a request for a foreign host."
def __init__(self, pool, url, retries=3):
message = "Tried to open a foreign host with url: %s" % url
RequestError.__init__(self, pool, url, message)
self.retries = retries
class TimeoutStateError(HTTPError):
""" Raised when passing an invalid state to a timeout """
pass
class TimeoutError(HTTPError):
""" Raised when a socket timeout error occurs.
Catching this error will catch both :exc:`ReadTimeoutErrors
<ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
"""
pass
class ReadTimeoutError(TimeoutError, RequestError):
"Raised when a socket timeout occurs while receiving data from a server"
pass
# This timeout error does not have a URL attached and needs to inherit from the
# base HTTPError
class ConnectTimeoutError(TimeoutError):
"Raised when a socket timeout occurs while connecting to a server"
pass
class NewConnectionError(ConnectTimeoutError, PoolError):
"Raised when we fail to establish a new connection. Usually ECONNREFUSED."
pass
class EmptyPoolError(PoolError):
"Raised when a pool runs out of connections and no more are allowed."
pass
class ClosedPoolError(PoolError):
"Raised when a request enters a pool after the pool has been closed."
pass
class LocationValueError(ValueError, HTTPError):
"Raised when there is something wrong with a given URL input."
pass
class LocationParseError(LocationValueError):
"Raised when get_host or similar fails to parse the URL input."
def __init__(self, location):
message = "Failed to parse: %s" % location
HTTPError.__init__(self, message)
self.location = location
class ResponseError(HTTPError):
"Used as a container for an error reason supplied in a MaxRetryError."
GENERIC_ERROR = 'too many error responses'
SPECIFIC_ERROR = 'too many {status_code} error responses'
class SecurityWarning(HTTPWarning):
"Warned when perfoming security reducing actions"
pass
class SubjectAltNameWarning(SecurityWarning):
"Warned when connecting to a host with a certificate missing a SAN."
pass
class InsecureRequestWarning(SecurityWarning):
"Warned when making an unverified HTTPS request."
pass
class SystemTimeWarning(SecurityWarning):
"Warned when system time is suspected to be wrong"
pass
class InsecurePlatformWarning(SecurityWarning):
"Warned when certain SSL configuration is not available on a platform."
pass
class SNIMissingWarning(HTTPWarning):
"Warned when making a HTTPS request without SNI available."
pass
class DependencyWarning(HTTPWarning):
"""
Warned when an attempt is made to import a module with missing optional
dependencies.
"""
pass
class ResponseNotChunked(ProtocolError, ValueError):
"Response needs to be chunked in order to read it as chunks."
pass
class BodyNotHttplibCompatible(HTTPError):
"""
Body should be httplib.HTTPResponse like (have an fp attribute which
returns raw chunks) for read_chunked().
"""
pass
class IncompleteRead(HTTPError, httplib_IncompleteRead):
"""
Response length doesn't match expected Content-Length
Subclass of http_client.IncompleteRead to allow int value
for `partial` to avoid creating large objects on streamed
reads.
"""
def __init__(self, partial, expected):
super(IncompleteRead, self).__init__(partial, expected)
def __repr__(self):
return ('IncompleteRead(%i bytes read, '
'%i more expected)' % (self.partial, self.expected))
class InvalidHeader(HTTPError):
"The header provided was somehow invalid."
pass
class ProxySchemeUnknown(AssertionError, ValueError):
"ProxyManager does not support the supplied scheme"
# TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
def __init__(self, scheme):
message = "Not supported proxy scheme %s" % scheme
super(ProxySchemeUnknown, self).__init__(message)
class HeaderParsingError(HTTPError):
"Raised by assert_header_parsing, but we convert it to a log.warning statement."
def __init__(self, defects, unparsed_data):
message = '%s, unparsed data: %r' % (defects or 'Unknown', unparsed_data)
super(HeaderParsingError, self).__init__(message)
class UnrewindableBodyError(HTTPError):
"urllib3 encountered an error when trying to rewind a body"
pass
|
mit
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
202,
199,
504,
1275,
5154,
14,
4174,
14,
4912,
14,
1014,
63,
1258,
492,
334,
1128,
1010,
4883,
3284,
465,
8809,
63,
31962,
3284,
202,
199,
9,
202,
199,
3,
3523,
24873,
8065,
199,
533,
15050,
8,
1726,
304,
1128,
298,
1563,
1919,
1202,
701,
642,
859,
2122,
1128,
986,
8065,
199,
533,
3101,
3849,
8,
3849,
304,
1128,
298,
1563,
5721,
1202,
701,
642,
859,
2122,
1128,
986,
8065,
199,
533,
15553,
547,
8,
12815,
304,
1128,
298,
1563,
1919,
367,
2552,
18104,
4453,
282,
4203,
2122,
1128,
347,
636,
826,
721,
277,
12,
4203,
12,
1245,
304,
1039,
291,
14,
2293,
275,
4203,
1039,
15050,
855,
826,
721,
277,
12,
2071,
83,
26,
450,
83,
2,
450,
334,
2293,
12,
1245,
430,
2958,
347,
636,
5270,
721,
277,
304,
1039,
327,
2104,
24394,
12901,
14,
1039,
372,
291,
855,
533,
3108,
334,
403,
12,
488,
9,
8065,
199,
533,
4784,
547,
8,
5453,
547,
304,
1128,
298,
1563,
1919,
367,
15553,
9298,
626,
1172,
4568,
10867,
2122,
1128,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
304,
1039,
291,
14,
633,
275,
1166,
1039,
15553,
547,
855,
826,
721,
277,
12,
4203,
12,
1245,
9,
2958,
347,
636,
5270,
721,
277,
304,
1039,
327,
2104,
24394,
12901,
14,
1039,
372,
291,
855,
533,
3108,
334,
403,
12,
291,
14,
633,
12,
488,
9,
8065,
199,
533,
7799,
547,
8,
12815,
304,
1128,
298,
16894,
1380,
7799,
5897,
6918,
315,
376,
14147,
1950,
2122,
1128,
986,
8065,
199,
533,
12373,
547,
8,
12815,
304,
1128,
298,
16894,
1380,
314,
1950,
370,
282,
4566,
6918,
2122,
1128,
986,
8065,
199,
533,
22462,
547,
8,
12815,
304,
1128,
298,
16894,
1380,
4834,
15952,
4079,
641,
6646,
13,
804,
6918,
2122,
1128,
986,
8065,
199,
533,
30797,
8,
12815,
304,
1128,
298,
16894,
1380,
6020,
10537,
10986,
10887,
13,
1069,
15,
1310,
2122,
1128,
986,
8065,
199,
12573,
22756,
68,
370,
30797,
1325,
26642,
367,
8552,
7163,
14,
202,
199,
20349,
275,
30797,
8065,
199,
3,
27836,
24873,
2999,
199,
533,
8228,
12989,
547,
8,
19261,
304,
1128,
408,
16894,
1380,
314,
5696,
1329,
402,
10086,
365,
22007,
14,
2958,
520,
635,
4203,
26,
710,
1950,
4203,
1128,
520,
466,
4203,
26,
520,
533,
6054,
4078,
19,
14,
2105,
2293,
14,
19114,
5453,
64,
1128,
520,
635,
1059,
1166,
26,
710,
5839,
20503,
1128,
520,
635,
4967,
14,
1726,
4499,
26,
710,
8793,
1125,
2958,
408,
2958,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
4499,
29,
403,
304,
1039,
291,
14,
5764,
275,
4499,
4341,
1245,
275,
298,
4261,
10086,
22007,
543,
1166,
26,
450,
83,
334,
3630,
2972,
701,
450,
82,
2924,
450,
334,
1675,
1166,
12,
4499,
9,
4341,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
8065,
199,
533,
10891,
6970,
547,
8,
19261,
304,
1128,
298,
16894,
1380,
376,
3411,
4203,
7545,
282,
1056,
367,
282,
11608,
1591,
2122,
2958,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
10086,
29,
19,
304,
1039,
1245,
275,
298,
6948,
379,
370,
1551,
282,
11608,
1591,
543,
1166,
26,
450,
83,
2,
450,
1166,
1039,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
1039,
291,
14,
10937,
275,
10086,
8065,
199,
533,
12878,
2223,
547,
8,
12815,
304,
1128,
408,
24997,
1380,
9476,
376,
3866,
1174,
370,
282,
2653,
408,
1128,
986,
8065,
199,
533,
31886,
8,
12815,
304,
1128,
408,
24997,
1380,
282,
2838,
2653,
1125,
11058,
14,
2958,
32754,
316,
642,
1125,
911,
8579,
3865,
520,
2804,
1705,
3284,
6372,
9298,
1128,
665,
3284,
19382,
8637,
436,
520,
2804,
1705,
8631,
6372,
9298,
665,
8631,
19382,
14943,
1128,
408,
1128,
986,
8065,
199,
533,
5574,
19382,
8,
19382,
12,
4784,
547,
304,
1128,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18390,
666,
687,
282,
1654,
2,
1128,
986,
8065,
199,
3,
961,
2653,
1125,
1630,
440,
1172,
282,
2851,
10102,
436,
4839,
370,
8287,
687,
314,
202,
199,
3,
1300,
15050,
202,
199,
533,
15175,
19382,
8,
19382,
304,
1128,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18170,
370,
282,
1654,
2,
1128,
986,
8065,
199,
533,
7053,
20349,
8,
8631,
19382,
12,
15553,
547,
304,
1128,
298,
16894,
1380,
781,
2449,
370,
16873,
282,
892,
1950,
14,
24612,
662,
17489,
8279,
8558,
2122,
1128,
986,
8065,
199,
533,
9630,
5453,
547,
8,
5453,
547,
304,
1128,
298,
16894,
1380,
282,
4203,
7858,
734,
402,
6947,
436,
949,
1655,
787,
4370,
2122,
1128,
986,
8065,
199,
533,
5980,
939,
5453,
547,
8,
5453,
547,
304,
1128,
298,
16894,
1380,
282,
1056,
655,
878,
282,
4203,
2410,
314,
4203,
965,
2757,
6876,
2122,
1128,
986,
8065,
199,
533,
12625,
3393,
8,
3393,
12,
15050,
304,
1128,
298,
16894,
1380,
2337,
365,
6020,
6835,
543,
282,
1627,
2851,
1324,
2122,
1128,
986,
8065,
199,
533,
12625,
9123,
8,
6592,
3393,
304,
1128,
298,
16894,
1380,
664,
63,
1102,
503,
8545,
6918,
370,
2198,
314,
2851,
1324,
2122,
2958,
347,
636,
826,
721,
277,
12,
2909,
304,
1039,
1245,
275,
298,
4276,
370,
2198,
26,
450,
83,
2,
450,
2909,
1039,
15050,
855,
826,
721,
277,
12,
1245,
9,
4341,
291,
14,
1985,
275,
2909,
8065,
199,
533,
7232,
547,
8,
12815,
304,
1128,
298,
9167,
465,
282,
3970,
367,
376,
1125,
4499,
6841,
315,
282,
8228,
12989,
547,
2122,
1128,
22813,
18082,
63,
3170,
275,
283,
7354,
5002,
1125,
9320,
7,
1128,
428,
7236,
23380,
63,
3170,
275,
283,
7354,
5002,
469,
1205,
63,
600,
93,
1125,
9320,
7,
8065,
199,
533,
13863,
3849,
8,
2856,
3849,
304,
1128,
298,
22673,
379,
1380,
1126,
545,
14566,
6391,
295,
14713,
5445,
2,
1128,
986,
8065,
199,
533,
26793,
29171,
3849,
8,
7676,
3849,
304,
1128,
298,
22673,
379,
1380,
18170,
370,
282,
1591,
543,
282,
5897,
4124,
282,
428,
879,
2122,
1128,
986,
8065,
199,
533,
1010,
7817,
2017,
3849,
8,
7676,
3849,
304,
1128,
298,
22673,
379,
1380,
10663,
376,
625,
12949,
14147,
1056,
2122,
1128,
986,
8065,
199,
533,
6187,
1366,
3849,
8,
7676,
3849,
304
] |
[
636,
2443,
363,
492,
3679,
63,
646,
202,
199,
504,
1275,
5154,
14,
4174,
14,
4912,
14,
1014,
63,
1258,
492,
334,
1128,
1010,
4883,
3284,
465,
8809,
63,
31962,
3284,
202,
199,
9,
202,
199,
3,
3523,
24873,
8065,
199,
533,
15050,
8,
1726,
304,
1128,
298,
1563,
1919,
1202,
701,
642,
859,
2122,
1128,
986,
8065,
199,
533,
3101,
3849,
8,
3849,
304,
1128,
298,
1563,
5721,
1202,
701,
642,
859,
2122,
1128,
986,
8065,
199,
533,
15553,
547,
8,
12815,
304,
1128,
298,
1563,
1919,
367,
2552,
18104,
4453,
282,
4203,
2122,
1128,
347,
636,
826,
721,
277,
12,
4203,
12,
1245,
304,
1039,
291,
14,
2293,
275,
4203,
1039,
15050,
855,
826,
721,
277,
12,
2071,
83,
26,
450,
83,
2,
450,
334,
2293,
12,
1245,
430,
2958,
347,
636,
5270,
721,
277,
304,
1039,
327,
2104,
24394,
12901,
14,
1039,
372,
291,
855,
533,
3108,
334,
403,
12,
488,
9,
8065,
199,
533,
4784,
547,
8,
5453,
547,
304,
1128,
298,
1563,
1919,
367,
15553,
9298,
626,
1172,
4568,
10867,
2122,
1128,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
304,
1039,
291,
14,
633,
275,
1166,
1039,
15553,
547,
855,
826,
721,
277,
12,
4203,
12,
1245,
9,
2958,
347,
636,
5270,
721,
277,
304,
1039,
327,
2104,
24394,
12901,
14,
1039,
372,
291,
855,
533,
3108,
334,
403,
12,
291,
14,
633,
12,
488,
9,
8065,
199,
533,
7799,
547,
8,
12815,
304,
1128,
298,
16894,
1380,
7799,
5897,
6918,
315,
376,
14147,
1950,
2122,
1128,
986,
8065,
199,
533,
12373,
547,
8,
12815,
304,
1128,
298,
16894,
1380,
314,
1950,
370,
282,
4566,
6918,
2122,
1128,
986,
8065,
199,
533,
22462,
547,
8,
12815,
304,
1128,
298,
16894,
1380,
4834,
15952,
4079,
641,
6646,
13,
804,
6918,
2122,
1128,
986,
8065,
199,
533,
30797,
8,
12815,
304,
1128,
298,
16894,
1380,
6020,
10537,
10986,
10887,
13,
1069,
15,
1310,
2122,
1128,
986,
8065,
199,
12573,
22756,
68,
370,
30797,
1325,
26642,
367,
8552,
7163,
14,
202,
199,
20349,
275,
30797,
8065,
199,
3,
27836,
24873,
2999,
199,
533,
8228,
12989,
547,
8,
19261,
304,
1128,
408,
16894,
1380,
314,
5696,
1329,
402,
10086,
365,
22007,
14,
2958,
520,
635,
4203,
26,
710,
1950,
4203,
1128,
520,
466,
4203,
26,
520,
533,
6054,
4078,
19,
14,
2105,
2293,
14,
19114,
5453,
64,
1128,
520,
635,
1059,
1166,
26,
710,
5839,
20503,
1128,
520,
635,
4967,
14,
1726,
4499,
26,
710,
8793,
1125,
2958,
408,
2958,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
4499,
29,
403,
304,
1039,
291,
14,
5764,
275,
4499,
4341,
1245,
275,
298,
4261,
10086,
22007,
543,
1166,
26,
450,
83,
334,
3630,
2972,
701,
450,
82,
2924,
450,
334,
1675,
1166,
12,
4499,
9,
4341,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
8065,
199,
533,
10891,
6970,
547,
8,
19261,
304,
1128,
298,
16894,
1380,
376,
3411,
4203,
7545,
282,
1056,
367,
282,
11608,
1591,
2122,
2958,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
10086,
29,
19,
304,
1039,
1245,
275,
298,
6948,
379,
370,
1551,
282,
11608,
1591,
543,
1166,
26,
450,
83,
2,
450,
1166,
1039,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
1039,
291,
14,
10937,
275,
10086,
8065,
199,
533,
12878,
2223,
547,
8,
12815,
304,
1128,
408,
24997,
1380,
9476,
376,
3866,
1174,
370,
282,
2653,
408,
1128,
986,
8065,
199,
533,
31886,
8,
12815,
304,
1128,
408,
24997,
1380,
282,
2838,
2653,
1125,
11058,
14,
2958,
32754,
316,
642,
1125,
911,
8579,
3865,
520,
2804,
1705,
3284,
6372,
9298,
1128,
665,
3284,
19382,
8637,
436,
520,
2804,
1705,
8631,
6372,
9298,
665,
8631,
19382,
14943,
1128,
408,
1128,
986,
8065,
199,
533,
5574,
19382,
8,
19382,
12,
4784,
547,
304,
1128,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18390,
666,
687,
282,
1654,
2,
1128,
986,
8065,
199,
3,
961,
2653,
1125,
1630,
440,
1172,
282,
2851,
10102,
436,
4839,
370,
8287,
687,
314,
202,
199,
3,
1300,
15050,
202,
199,
533,
15175,
19382,
8,
19382,
304,
1128,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18170,
370,
282,
1654,
2,
1128,
986,
8065,
199,
533,
7053,
20349,
8,
8631,
19382,
12,
15553,
547,
304,
1128,
298,
16894,
1380,
781,
2449,
370,
16873,
282,
892,
1950,
14,
24612,
662,
17489,
8279,
8558,
2122,
1128,
986,
8065,
199,
533,
9630,
5453,
547,
8,
5453,
547,
304,
1128,
298,
16894,
1380,
282,
4203,
7858,
734,
402,
6947,
436,
949,
1655,
787,
4370,
2122,
1128,
986,
8065,
199,
533,
5980,
939,
5453,
547,
8,
5453,
547,
304,
1128,
298,
16894,
1380,
282,
1056,
655,
878,
282,
4203,
2410,
314,
4203,
965,
2757,
6876,
2122,
1128,
986,
8065,
199,
533,
12625,
3393,
8,
3393,
12,
15050,
304,
1128,
298,
16894,
1380,
2337,
365,
6020,
6835,
543,
282,
1627,
2851,
1324,
2122,
1128,
986,
8065,
199,
533,
12625,
9123,
8,
6592,
3393,
304,
1128,
298,
16894,
1380,
664,
63,
1102,
503,
8545,
6918,
370,
2198,
314,
2851,
1324,
2122,
2958,
347,
636,
826,
721,
277,
12,
2909,
304,
1039,
1245,
275,
298,
4276,
370,
2198,
26,
450,
83,
2,
450,
2909,
1039,
15050,
855,
826,
721,
277,
12,
1245,
9,
4341,
291,
14,
1985,
275,
2909,
8065,
199,
533,
7232,
547,
8,
12815,
304,
1128,
298,
9167,
465,
282,
3970,
367,
376,
1125,
4499,
6841,
315,
282,
8228,
12989,
547,
2122,
1128,
22813,
18082,
63,
3170,
275,
283,
7354,
5002,
1125,
9320,
7,
1128,
428,
7236,
23380,
63,
3170,
275,
283,
7354,
5002,
469,
1205,
63,
600,
93,
1125,
9320,
7,
8065,
199,
533,
13863,
3849,
8,
2856,
3849,
304,
1128,
298,
22673,
379,
1380,
1126,
545,
14566,
6391,
295,
14713,
5445,
2,
1128,
986,
8065,
199,
533,
26793,
29171,
3849,
8,
7676,
3849,
304,
1128,
298,
22673,
379,
1380,
18170,
370,
282,
1591,
543,
282,
5897,
4124,
282,
428,
879,
2122,
1128,
986,
8065,
199,
533,
1010,
7817,
2017,
3849,
8,
7676,
3849,
304,
1128,
298,
22673,
379,
1380,
10663,
376,
625,
12949,
14147,
1056,
2122,
1128,
986,
8065,
199,
533,
6187,
1366,
3849,
8,
7676,
3849,
304,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
burzillibus/RobHome
|
venv/lib/python2.7/site-packages/zmq/tests/test_imports.py
|
9
|
1791
|
# Copyright (C) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
import sys
from unittest import TestCase
class TestImports(TestCase):
"""Test Imports - the quickest test to ensure that we haven't
introduced version-incompatible syntax errors."""
def test_toplevel(self):
"""test toplevel import"""
import zmq
def test_core(self):
"""test core imports"""
from zmq import Context
from zmq import Socket
from zmq import Poller
from zmq import Frame
from zmq import constants
from zmq import device, proxy
from zmq import (
zmq_version,
zmq_version_info,
pyzmq_version,
pyzmq_version_info,
)
def test_devices(self):
"""test device imports"""
import zmq.devices
from zmq.devices import basedevice
from zmq.devices import monitoredqueue
from zmq.devices import monitoredqueuedevice
def test_log(self):
"""test log imports"""
import zmq.log
from zmq.log import handlers
def test_eventloop(self):
"""test eventloop imports"""
import zmq.eventloop
from zmq.eventloop import ioloop
from zmq.eventloop import zmqstream
from zmq.eventloop.minitornado.platform import auto
from zmq.eventloop.minitornado import ioloop
def test_utils(self):
"""test util imports"""
import zmq.utils
from zmq.utils import strtypes
from zmq.utils import jsonapi
def test_ssh(self):
"""test ssh imports"""
from zmq.ssh import tunnel
def test_decorators(self):
"""test decorators imports"""
from zmq.decorators import context, socket
|
mit
|
[
3,
1898,
334,
35,
9,
1611,
58,
14449,
23493,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
199,
646,
984,
199,
504,
2882,
492,
7640,
199,
199,
533,
1379,
32447,
8,
1746,
304,
272,
408,
774,
24339,
446,
314,
12530,
597,
511,
370,
4868,
626,
781,
19051,
1133,
272,
21399,
1015,
13,
31787,
6302,
2552,
1041,
339,
347,
511,
63,
13517,
8,
277,
304,
267,
408,
396,
13836,
492,
624,
267,
492,
26633,
339,
347,
511,
63,
1018,
8,
277,
304,
267,
408,
396,
6170,
8925,
624,
267,
687,
26633,
492,
9470,
267,
687,
26633,
492,
17766,
267,
687,
26633,
492,
8467,
1435,
267,
687,
26633,
492,
11726,
267,
687,
26633,
492,
5262,
267,
687,
26633,
492,
2243,
12,
4566,
267,
687,
26633,
492,
334,
288,
26633,
63,
1023,
12,
288,
26633,
63,
1023,
63,
815,
12,
288,
1134,
21290,
63,
1023,
12,
288,
1134,
21290,
63,
1023,
63,
815,
12,
267,
776,
339,
347,
511,
63,
6410,
8,
277,
304,
267,
408,
396,
2243,
8925,
624,
267,
492,
26633,
14,
6410,
267,
687,
26633,
14,
6410,
492,
1300,
1782,
267,
687,
26633,
14,
6410,
492,
23821,
1825,
267,
687,
26633,
14,
6410,
492,
23821,
1825,
1782,
339,
347,
511,
63,
793,
8,
277,
304,
267,
408,
396,
943,
8925,
624,
267,
492,
26633,
14,
793,
267,
687,
26633,
14,
793,
492,
8297,
339,
347,
511,
63,
1430,
3813,
8,
277,
304,
267,
408,
396,
1566,
3813,
8925,
624,
267,
492,
26633,
14,
1430,
3813,
267,
687,
26633,
14,
1430,
3813,
492,
5890,
3813,
267,
687,
26633,
14,
1430,
3813,
492,
26633,
1745,
267,
687,
26633,
14,
1430,
3813,
14,
77,
826,
8622,
14,
3246,
492,
2599,
267,
687,
26633,
14,
1430,
3813,
14,
77,
826,
8622,
492,
5890,
3813,
339,
347,
511,
63,
1208,
8,
277,
304,
267,
408,
396,
4884,
8925,
624,
267,
492,
26633,
14,
1208,
267,
687,
26633,
14,
1208,
492,
620,
1313,
267,
687,
26633,
14,
1208,
492,
2022,
1246,
339,
347,
511,
63,
5510,
8,
277,
304,
267,
408,
396,
8635,
8925,
624,
267,
687,
26633,
14,
5510,
492,
21496,
339,
347,
511,
63,
11582,
8,
277,
304,
267,
408,
396,
20419,
8925,
624,
267,
687,
26633,
14,
11582,
492,
1067,
12,
2838,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
35,
9,
1611,
58,
14449,
23493,
199,
3,
17484,
1334,
314,
2895,
402,
314,
22016,
6289,
844,
14,
199,
199,
646,
984,
199,
504,
2882,
492,
7640,
199,
199,
533,
1379,
32447,
8,
1746,
304,
272,
408,
774,
24339,
446,
314,
12530,
597,
511,
370,
4868,
626,
781,
19051,
1133,
272,
21399,
1015,
13,
31787,
6302,
2552,
1041,
339,
347,
511,
63,
13517,
8,
277,
304,
267,
408,
396,
13836,
492,
624,
267,
492,
26633,
339,
347,
511,
63,
1018,
8,
277,
304,
267,
408,
396,
6170,
8925,
624,
267,
687,
26633,
492,
9470,
267,
687,
26633,
492,
17766,
267,
687,
26633,
492,
8467,
1435,
267,
687,
26633,
492,
11726,
267,
687,
26633,
492,
5262,
267,
687,
26633,
492,
2243,
12,
4566,
267,
687,
26633,
492,
334,
288,
26633,
63,
1023,
12,
288,
26633,
63,
1023,
63,
815,
12,
288,
1134,
21290,
63,
1023,
12,
288,
1134,
21290,
63,
1023,
63,
815,
12,
267,
776,
339,
347,
511,
63,
6410,
8,
277,
304,
267,
408,
396,
2243,
8925,
624,
267,
492,
26633,
14,
6410,
267,
687,
26633,
14,
6410,
492,
1300,
1782,
267,
687,
26633,
14,
6410,
492,
23821,
1825,
267,
687,
26633,
14,
6410,
492,
23821,
1825,
1782,
339,
347,
511,
63,
793,
8,
277,
304,
267,
408,
396,
943,
8925,
624,
267,
492,
26633,
14,
793,
267,
687,
26633,
14,
793,
492,
8297,
339,
347,
511,
63,
1430,
3813,
8,
277,
304,
267,
408,
396,
1566,
3813,
8925,
624,
267,
492,
26633,
14,
1430,
3813,
267,
687,
26633,
14,
1430,
3813,
492,
5890,
3813,
267,
687,
26633,
14,
1430,
3813,
492,
26633,
1745,
267,
687,
26633,
14,
1430,
3813,
14,
77,
826,
8622,
14,
3246,
492,
2599,
267,
687,
26633,
14,
1430,
3813,
14,
77,
826,
8622,
492,
5890,
3813,
339,
347,
511,
63,
1208,
8,
277,
304,
267,
408,
396,
4884,
8925,
624,
267,
492,
26633,
14,
1208,
267,
687,
26633,
14,
1208,
492,
620,
1313,
267,
687,
26633,
14,
1208,
492,
2022,
1246,
339,
347,
511,
63,
5510,
8,
277,
304,
267,
408,
396,
8635,
8925,
624,
267,
687,
26633,
14,
5510,
492,
21496,
339,
347,
511,
63,
11582,
8,
277,
304,
267,
408,
396,
20419,
8925,
624,
267,
687,
26633,
14,
11582,
492,
1067,
12,
2838,
4388,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Yannig/ansible
|
lib/ansible/__init__.py
|
301
|
1224
|
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
# Note: Do not add any code to this file. The ansible module may be
# a namespace package when using Ansible-2.1+ Anything in this file may not be
# available if one of the other packages in the namespace is loaded first.
#
# This is for backwards compat. Code should be ported to get these from
# ansible.release instead of from here.
from ansible.release import __version__, __author__
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
3,
3390,
26,
4226,
440,
1050,
1263,
1233,
370,
642,
570,
14,
221,
710,
3242,
859,
1443,
506,
199,
3,
282,
3231,
2559,
1380,
1808,
2622,
13,
18,
14,
17,
11,
6184,
2127,
315,
642,
570,
1443,
440,
506,
199,
3,
2808,
340,
1373,
402,
314,
1163,
6117,
315,
314,
3231,
365,
6511,
1642,
14,
199,
3,
199,
3,
961,
365,
367,
8552,
8434,
14,
221,
5495,
1077,
506,
299,
1376,
370,
664,
3520,
687,
199,
3,
3242,
14,
3221,
3140,
402,
687,
2348,
14,
199,
504,
3242,
14,
3221,
492,
636,
1023,
3108,
636,
2502,
363,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
334,
67,
9,
6029,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
199,
3,
4155,
2803,
1655,
2366,
19,
13,
2453,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
3,
3390,
26,
4226,
440,
1050,
1263,
1233,
370,
642,
570,
14,
221,
710,
3242,
859,
1443,
506,
199,
3,
282,
3231,
2559,
1380,
1808,
2622,
13,
18,
14,
17,
11,
6184,
2127,
315,
642,
570,
1443,
440,
506,
199,
3,
2808,
340,
1373,
402,
314,
1163,
6117,
315,
314,
3231,
365,
6511,
1642,
14,
199,
3,
199,
3,
961,
365,
367,
8552,
8434,
14,
221,
5495,
1077,
506,
299,
1376,
370,
664,
3520,
687,
199,
3,
3242,
14,
3221,
3140,
402,
687,
2348,
14,
199,
504,
3242,
14,
3221,
492,
636,
1023,
3108,
636,
2502,
363,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
jakevdp/lombscargle
|
lombscargle/implementations/utils.py
|
1
|
5934
|
from __future__ import print_function, division
import numpy as np
try:
from scipy import special as scipy_special
except ImportError:
scipy_special = None
# Precomputed factorials
FACTORIALS = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800,
39916800, 479001600, 6227020800, 87178291200, 1307674368000]
def factorial(N):
"""Compute the factorial of N.
If N <= 16, use a fast lookup table; otherwise use scipy.special.factorial
"""
if N < len(FACTORIALS):
return FACTORIALS[N]
elif scipy_special is None:
raise ValueError("need scipy for computing larger factorials")
else:
return int(scipy_special.factorial(N))
def bitceil(N):
"""
Find the bit (i.e. power of 2) immediately greater than or equal to N
Note: this works for numbers up to 2 ** 64.
Roughly equivalent to int(2 ** np.ceil(np.log2(N)))
"""
# Note: for Python 2.7 and 3.x, this is faster:
# return 1 << int(N - 1).bit_length()
N = int(N) - 1
for i in [1, 2, 4, 8, 16, 32]:
N |= N >> i
return N + 1
def extirpolate(x, y, N=None, M=4):
"""
Extirpolate the values (x, y) onto an integer grid range(N),
using lagrange polynomial weights on the M nearest points.
Parameters
----------
x : array_like
array of abscissas
y : array_like
array of ordinates
N : int
number of integer bins to use. For best performance, N should be larger
than the maximum of x
M : int
number of adjoining points on which to extirpolate.
Returns
-------
yN : ndarray
N extirpolated values associated with range(N)
Example
-------
>>> rng = np.random.RandomState(0)
>>> x = 100 * rng.rand(20)
>>> y = np.sin(x)
>>> y_hat = extirpolate(x, y)
>>> x_hat = np.arange(len(y_hat))
>>> f = lambda x: np.sin(x / 10)
>>> np.allclose(np.sum(y * f(x)), np.sum(y_hat * f(x_hat)))
True
Notes
-----
This code is based on the C implementation of spread() presented in
Numerical Recipes in C, Second Edition (Press et al. 1989; p.583).
"""
if not hasattr(np.ufunc, 'at'):
raise NotImplementedError("extirpolate functionality requires numpy "
"version 1.8 or newer")
x, y = map(np.ravel, np.broadcast_arrays(x, y))
if N is None:
N = int(np.max(x) + 0.5 * M + 1)
# Now use legendre polynomial weights to populate the results array;
# This is an efficient recursive implementation (See Press et al. 1989)
result = np.zeros(N, dtype=y.dtype)
# first take care of the easy cases where x is an integer
integers = (x % 1 == 0)
np.add.at(result, x[integers].astype(int), y[integers])
x, y = x[~integers], y[~integers]
# For each remaining x, find the index describing the extirpolation range.
# i.e. ilo[i] < x[i] < ilo[i] + M with x[i] in the center,
# adjusted so that the limits are within the range 0...N
ilo = np.clip((x - M // 2).astype(int), 0, N - M)
numerator = y * np.prod(x - ilo - np.arange(M)[:, np.newaxis], 0)
denominator = factorial(M - 1)
for j in range(M):
if j > 0:
denominator *= j / (j - M)
ind = ilo + (M - 1 - j)
np.add.at(result, ind, numerator / (denominator * (x - ind)))
return result
def trig_sum(t, h, df, N, f0=0, freq_factor=1,
oversampling=5, use_fft=True, Mfft=4):
"""Compute (approximate) trigonometric sums for a number of frequencies
This routine computes weighted sine and cosine sums:
S_j = sum_i { h_i * sin(2 pi * f_j * t_i) }
C_j = sum_i { h_i * cos(2 pi * f_j * t_i) }
Where f_j = freq_factor * (f0 + j * df) for the values j in 1 ... N.
The sums can be computed either by a brute force O[N^2] method, or
by an FFT-based O[Nlog(N)] method.
Parameters
----------
t : array_like
array of input times
h : array_like
array weights for the sum
df : float
frequency spacing
N : int
number of frequency bins to return
f0 : float (optional, default=0)
The low frequency to use
freq_factor : float (optional, default=1)
Factor which multiplies the frequency
use_fft : bool
if True, use the approximate FFT algorithm to compute the result.
This uses the FFT with Press & Rybicki's Lagrangian extirpolation.
oversampling : int (default = 5)
oversampling freq_factor for the approximation; roughtly the number of
time samples across the highest-frequency sinusoid. This parameter
contains the tradeoff between accuracy and speed. Not referenced
if use_fft is False.
Mfft : int
The number of adjacent points to use in the FFT approximation.
Not referenced if use_fft is False.
Returns
-------
S, C : ndarrays
summation arrays for frequencies f = df * np.arange(1, N + 1)
"""
df *= freq_factor
f0 *= freq_factor
assert df > 0
t, h = map(np.ravel, np.broadcast_arrays(t, h))
if use_fft:
Mfft = int(Mfft)
assert(Mfft > 0)
# required size of fft is the power of 2 above the oversampling rate
Nfft = bitceil(N * oversampling)
t0 = t.min()
if f0 > 0:
h = h * np.exp(2j * np.pi * f0 * (t - t0))
tnorm = ((t - t0) * Nfft * df) % Nfft
grid = extirpolate(tnorm, h, Nfft, Mfft)
fftgrid = np.fft.ifft(grid)
if t0 != 0:
f = f0 + df * np.arange(Nfft)
fftgrid *= np.exp(2j * np.pi * t0 * f)
fftgrid = fftgrid[:N]
C = Nfft * fftgrid.real
S = Nfft * fftgrid.imag
else:
f = f0 + df * np.arange(N)
C = np.dot(h, np.cos(2 * np.pi * f * t[:, np.newaxis]))
S = np.dot(h, np.sin(2 * np.pi * f * t[:, np.newaxis]))
return S, C
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
12,
4629,
199,
646,
2680,
465,
980,
421,
199,
893,
26,
272,
687,
7026,
492,
4539,
465,
7026,
63,
6664,
199,
2590,
3545,
26,
272,
7026,
63,
6664,
275,
488,
421,
199,
3,
5543,
14378,
32618,
83,
199,
26393,
4938,
51,
275,
359,
17,
12,
413,
12,
499,
12,
1227,
12,
5504,
12,
13960,
12,
29692,
12,
959,
11189,
12,
6335,
12122,
12,
8780,
1651,
1257,
12,
650,
2789,
1299,
383,
12,
1598,
650,
1020,
6568,
383,
12,
841,
1965,
23856,
383,
12,
1227,
11385,
996,
25822,
12,
10513,
11175,
1398,
23781,
12,
21334,
2114,
1342,
10997,
1493,
61,
421,
199,
318,
32618,
8,
46,
304,
272,
408,
8564,
314,
32618,
402,
653,
14,
272,
982,
653,
2695,
3193,
12,
675,
282,
7377,
4237,
1817,
27,
4257,
675,
7026,
14,
6664,
14,
28165,
272,
408,
272,
340,
653,
665,
822,
8,
26393,
4938,
51,
304,
267,
372,
481,
3036,
726,
4938,
51,
59,
46,
61,
272,
916,
7026,
63,
6664,
365,
488,
26,
267,
746,
1722,
480,
9321,
7026,
367,
17226,
12142,
32618,
83,
531,
272,
587,
26,
267,
372,
1109,
8,
14248,
63,
6664,
14,
28165,
8,
46,
430,
421,
199,
318,
4546,
14085,
8,
46,
304,
272,
408,
272,
6668,
314,
4546,
334,
73,
14,
69,
14,
7074,
402,
499,
9,
9939,
8932,
2419,
503,
4472,
370,
653,
272,
3390,
26,
642,
5419,
367,
5579,
1536,
370,
499,
1011,
5049,
14,
272,
820,
4937,
590,
7353,
370,
1109,
8,
18,
1011,
980,
14,
14085,
8,
1590,
14,
793,
18,
8,
46,
1724,
272,
408,
272,
327,
3390,
26,
367,
2018,
499,
14,
23,
436,
650,
14,
88,
12,
642,
365,
12930,
26,
272,
327,
372,
413,
5213,
1109,
8,
46,
446,
413,
680,
2075,
63,
1267,
342,
272,
653,
275,
1109,
8,
46,
9,
446,
413,
272,
367,
284,
315,
359,
17,
12,
499,
12,
841,
12,
1695,
12,
3193,
12,
4337,
2189,
267,
653,
8901,
653,
4331,
284,
272,
372,
653,
435,
413,
421,
199,
318,
444,
280,
82,
14641,
8,
88,
12,
612,
12,
653,
29,
403,
12,
603,
29,
20,
304,
272,
408,
272,
1316,
280,
82,
14641,
314,
1338,
334,
88,
12,
612,
9,
14602,
376,
3000,
6068,
1425,
8,
46,
395,
272,
1808,
17891,
1842,
11849,
4931,
641,
314,
603,
17173,
4501,
14,
272,
3897,
272,
4143,
272,
671,
520,
1625,
63,
2930,
267,
1625,
402,
2236,
551,
19857,
305,
272,
612,
520,
1625,
63,
2930,
267,
1625,
402,
6206,
262,
2335,
272,
653,
520,
1109,
267,
1329,
402,
3000,
13341,
370,
675,
14,
2104,
5526,
10238,
12,
653,
1077,
506,
12142,
267,
2419,
314,
5696,
402,
671,
272,
603,
520,
1109,
267,
1329,
402,
1503,
904,
316,
4501,
641,
1314,
370,
444,
280,
82,
14641,
14,
339,
1803,
272,
5514,
272,
612,
46,
520,
6800,
268,
653,
444,
280,
82,
2515,
972,
1338,
4568,
543,
1425,
8,
46,
9,
339,
5679,
272,
5514,
272,
1306,
9038,
275,
980,
14,
2355,
14,
15726,
8,
16,
9,
272,
1306,
671,
275,
2948,
627,
9038,
14,
3759,
8,
1165,
9,
272,
1306,
612,
275,
980,
14,
5911,
8,
88,
9,
272,
1306,
612,
63,
8554,
275,
444,
280,
82,
14641,
8,
88,
12,
612,
9,
272,
1306,
671,
63,
8554,
275,
980,
14,
5605,
8,
552,
8,
89,
63,
8554,
430,
272,
1306,
289,
275,
2400,
671,
26,
980,
14,
5911,
8,
88,
1182,
1616,
9,
272,
1306,
980,
14,
7520,
8,
1590,
14,
1838,
8,
89,
627,
289,
8,
88,
1826,
980,
14,
1838,
8,
89,
63,
8554,
627,
289,
8,
88,
63,
8554,
1724,
272,
715,
339,
8144,
272,
9063,
272,
961,
1233,
365,
4079,
641,
314,
445,
4514,
402,
308,
8984,
342,
26568,
315,
272,
653,
27685,
799,
8233,
83,
315,
445,
12,
16707,
662,
1671,
334,
14414,
10844,
741,
14,
5851,
1407,
27,
299,
14,
16793,
680,
272,
408,
272,
340,
440,
2688,
8,
1590,
14,
18810,
12,
283,
292,
735,
267,
746,
4279,
480,
476,
280,
82,
14641,
9330,
5074,
2680,
298,
3303,
298,
1023,
413,
14,
24,
503,
15666,
531,
339,
671,
12,
612,
275,
2341,
8,
1590,
14,
11186,
12,
980,
14,
10786,
63,
10095,
8,
88,
12,
612,
430,
339,
340,
653,
365,
488,
26,
267,
653,
275,
1109,
8,
1590,
14,
988,
8,
88,
9,
435,
378,
14,
21,
627,
603,
435,
413,
9,
339,
327,
7356,
675,
15906,
264,
11849,
4931,
370,
13904,
314,
2058,
1625,
27,
272,
327,
961,
365,
376,
13402,
9133,
4514,
334,
9295,
23583,
10844,
741,
14,
5851,
1407,
9,
272,
754,
275,
980,
14,
4250,
8,
46,
12,
2152,
29,
89,
14,
2271,
9,
339,
327,
1642,
5452,
10296,
402,
314,
8837,
5560,
2382,
671,
365,
376,
3000,
272,
9446,
275,
334,
88,
450,
413,
508,
378,
9,
272,
980,
14,
525,
14,
292,
8,
1099,
12,
671,
59,
23931,
1055,
6041,
8,
442,
395,
612,
59,
23931,
566,
272,
671,
12,
612,
275,
671,
19911,
23931,
467,
612,
19911,
23931,
61,
339,
327,
2104,
1924,
7971,
671,
12,
2342,
314,
1478,
13660,
314,
444,
280,
82,
9536,
1425,
14,
272,
327,
284,
14,
69,
14,
284,
320,
59,
73,
61,
665,
671,
59,
73,
61,
665,
284,
320,
59,
73,
61,
435,
603,
543,
671,
59,
73,
61,
315,
314,
8126,
12,
272,
327,
19477,
880,
626,
314,
10976,
787,
4453,
314,
1425,
378,
1396,
46,
272,
284,
320,
275,
980,
14,
7548,
1332,
88,
446,
603,
5001,
499,
680,
6041,
8,
442,
395,
378,
12,
653,
446,
603,
9,
272,
27640,
275,
612,
627,
980,
14,
8788,
8,
88,
446,
284,
320,
446,
980,
14,
5605,
8,
45,
24517,
980,
14,
14483,
467,
378,
9,
272,
21859,
275,
32618,
8,
45,
446,
413,
9,
339,
367,
1335,
315,
1425,
8,
45,
304,
267,
340,
1335,
690,
378,
26,
288,
21859,
9000,
1335,
1182,
334,
74,
446,
603,
9,
267,
7654,
275,
284,
320,
435,
334,
45,
446,
413,
446,
1335,
9,
267,
980,
14,
525,
14,
292,
8,
1099,
12,
7654,
12,
27640,
1182,
334,
17126,
627,
334,
88,
446,
7654,
1724,
272,
372,
754,
421,
199,
318,
3229,
71,
63,
1838,
8,
84
] |
[
636,
2443,
363,
492,
870,
63,
1593,
12,
4629,
199,
646,
2680,
465,
980,
421,
199,
893,
26,
272,
687,
7026,
492,
4539,
465,
7026,
63,
6664,
199,
2590,
3545,
26,
272,
7026,
63,
6664,
275,
488,
421,
199,
3,
5543,
14378,
32618,
83,
199,
26393,
4938,
51,
275,
359,
17,
12,
413,
12,
499,
12,
1227,
12,
5504,
12,
13960,
12,
29692,
12,
959,
11189,
12,
6335,
12122,
12,
8780,
1651,
1257,
12,
650,
2789,
1299,
383,
12,
1598,
650,
1020,
6568,
383,
12,
841,
1965,
23856,
383,
12,
1227,
11385,
996,
25822,
12,
10513,
11175,
1398,
23781,
12,
21334,
2114,
1342,
10997,
1493,
61,
421,
199,
318,
32618,
8,
46,
304,
272,
408,
8564,
314,
32618,
402,
653,
14,
272,
982,
653,
2695,
3193,
12,
675,
282,
7377,
4237,
1817,
27,
4257,
675,
7026,
14,
6664,
14,
28165,
272,
408,
272,
340,
653,
665,
822,
8,
26393,
4938,
51,
304,
267,
372,
481,
3036,
726,
4938,
51,
59,
46,
61,
272,
916,
7026,
63,
6664,
365,
488,
26,
267,
746,
1722,
480,
9321,
7026,
367,
17226,
12142,
32618,
83,
531,
272,
587,
26,
267,
372,
1109,
8,
14248,
63,
6664,
14,
28165,
8,
46,
430,
421,
199,
318,
4546,
14085,
8,
46,
304,
272,
408,
272,
6668,
314,
4546,
334,
73,
14,
69,
14,
7074,
402,
499,
9,
9939,
8932,
2419,
503,
4472,
370,
653,
272,
3390,
26,
642,
5419,
367,
5579,
1536,
370,
499,
1011,
5049,
14,
272,
820,
4937,
590,
7353,
370,
1109,
8,
18,
1011,
980,
14,
14085,
8,
1590,
14,
793,
18,
8,
46,
1724,
272,
408,
272,
327,
3390,
26,
367,
2018,
499,
14,
23,
436,
650,
14,
88,
12,
642,
365,
12930,
26,
272,
327,
372,
413,
5213,
1109,
8,
46,
446,
413,
680,
2075,
63,
1267,
342,
272,
653,
275,
1109,
8,
46,
9,
446,
413,
272,
367,
284,
315,
359,
17,
12,
499,
12,
841,
12,
1695,
12,
3193,
12,
4337,
2189,
267,
653,
8901,
653,
4331,
284,
272,
372,
653,
435,
413,
421,
199,
318,
444,
280,
82,
14641,
8,
88,
12,
612,
12,
653,
29,
403,
12,
603,
29,
20,
304,
272,
408,
272,
1316,
280,
82,
14641,
314,
1338,
334,
88,
12,
612,
9,
14602,
376,
3000,
6068,
1425,
8,
46,
395,
272,
1808,
17891,
1842,
11849,
4931,
641,
314,
603,
17173,
4501,
14,
272,
3897,
272,
4143,
272,
671,
520,
1625,
63,
2930,
267,
1625,
402,
2236,
551,
19857,
305,
272,
612,
520,
1625,
63,
2930,
267,
1625,
402,
6206,
262,
2335,
272,
653,
520,
1109,
267,
1329,
402,
3000,
13341,
370,
675,
14,
2104,
5526,
10238,
12,
653,
1077,
506,
12142,
267,
2419,
314,
5696,
402,
671,
272,
603,
520,
1109,
267,
1329,
402,
1503,
904,
316,
4501,
641,
1314,
370,
444,
280,
82,
14641,
14,
339,
1803,
272,
5514,
272,
612,
46,
520,
6800,
268,
653,
444,
280,
82,
2515,
972,
1338,
4568,
543,
1425,
8,
46,
9,
339,
5679,
272,
5514,
272,
1306,
9038,
275,
980,
14,
2355,
14,
15726,
8,
16,
9,
272,
1306,
671,
275,
2948,
627,
9038,
14,
3759,
8,
1165,
9,
272,
1306,
612,
275,
980,
14,
5911,
8,
88,
9,
272,
1306,
612,
63,
8554,
275,
444,
280,
82,
14641,
8,
88,
12,
612,
9,
272,
1306,
671,
63,
8554,
275,
980,
14,
5605,
8,
552,
8,
89,
63,
8554,
430,
272,
1306,
289,
275,
2400,
671,
26,
980,
14,
5911,
8,
88,
1182,
1616,
9,
272,
1306,
980,
14,
7520,
8,
1590,
14,
1838,
8,
89,
627,
289,
8,
88,
1826,
980,
14,
1838,
8,
89,
63,
8554,
627,
289,
8,
88,
63,
8554,
1724,
272,
715,
339,
8144,
272,
9063,
272,
961,
1233,
365,
4079,
641,
314,
445,
4514,
402,
308,
8984,
342,
26568,
315,
272,
653,
27685,
799,
8233,
83,
315,
445,
12,
16707,
662,
1671,
334,
14414,
10844,
741,
14,
5851,
1407,
27,
299,
14,
16793,
680,
272,
408,
272,
340,
440,
2688,
8,
1590,
14,
18810,
12,
283,
292,
735,
267,
746,
4279,
480,
476,
280,
82,
14641,
9330,
5074,
2680,
298,
3303,
298,
1023,
413,
14,
24,
503,
15666,
531,
339,
671,
12,
612,
275,
2341,
8,
1590,
14,
11186,
12,
980,
14,
10786,
63,
10095,
8,
88,
12,
612,
430,
339,
340,
653,
365,
488,
26,
267,
653,
275,
1109,
8,
1590,
14,
988,
8,
88,
9,
435,
378,
14,
21,
627,
603,
435,
413,
9,
339,
327,
7356,
675,
15906,
264,
11849,
4931,
370,
13904,
314,
2058,
1625,
27,
272,
327,
961,
365,
376,
13402,
9133,
4514,
334,
9295,
23583,
10844,
741,
14,
5851,
1407,
9,
272,
754,
275,
980,
14,
4250,
8,
46,
12,
2152,
29,
89,
14,
2271,
9,
339,
327,
1642,
5452,
10296,
402,
314,
8837,
5560,
2382,
671,
365,
376,
3000,
272,
9446,
275,
334,
88,
450,
413,
508,
378,
9,
272,
980,
14,
525,
14,
292,
8,
1099,
12,
671,
59,
23931,
1055,
6041,
8,
442,
395,
612,
59,
23931,
566,
272,
671,
12,
612,
275,
671,
19911,
23931,
467,
612,
19911,
23931,
61,
339,
327,
2104,
1924,
7971,
671,
12,
2342,
314,
1478,
13660,
314,
444,
280,
82,
9536,
1425,
14,
272,
327,
284,
14,
69,
14,
284,
320,
59,
73,
61,
665,
671,
59,
73,
61,
665,
284,
320,
59,
73,
61,
435,
603,
543,
671,
59,
73,
61,
315,
314,
8126,
12,
272,
327,
19477,
880,
626,
314,
10976,
787,
4453,
314,
1425,
378,
1396,
46,
272,
284,
320,
275,
980,
14,
7548,
1332,
88,
446,
603,
5001,
499,
680,
6041,
8,
442,
395,
378,
12,
653,
446,
603,
9,
272,
27640,
275,
612,
627,
980,
14,
8788,
8,
88,
446,
284,
320,
446,
980,
14,
5605,
8,
45,
24517,
980,
14,
14483,
467,
378,
9,
272,
21859,
275,
32618,
8,
45,
446,
413,
9,
339,
367,
1335,
315,
1425,
8,
45,
304,
267,
340,
1335,
690,
378,
26,
288,
21859,
9000,
1335,
1182,
334,
74,
446,
603,
9,
267,
7654,
275,
284,
320,
435,
334,
45,
446,
413,
446,
1335,
9,
267,
980,
14,
525,
14,
292,
8,
1099,
12,
7654,
12,
27640,
1182,
334,
17126,
627,
334,
88,
446,
7654,
1724,
272,
372,
754,
421,
199,
318,
3229,
71,
63,
1838,
8,
84,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
GNOME/orca
|
test/keystrokes/oobase/bug_463172.py
|
4
|
4082
|
#!/usr/bin/python
"""Test to verify bug #463172 is still fixed.
OOo sbase application crashes when entering a database record.
"""
from macaroon.playback import *
sequence = MacroSequence()
######################################################################
# 1. Start oobase. Wait for the first screen of the startup wizard to
# appear.
#
sequence.append(WaitForWindowActivate("Database Wizard", None))
sequence.append(WaitForFocus("Select database", acc_role=pyatspi.ROLE_LABEL))
######################################################################
# 2. Press Return to get to the second screen of the startup wizard.
#
# BRAILLE LINE: 'soffice Application Database Wizard Dialog Database Wizard OptionPane Steps Panel Save and proceed Label'
# VISIBLE: 'Save and proceed Label', cursor=1
# SPEECH OUTPUT: 'Save and proceed label'
#
sequence.append(KeyComboAction("Return"))
sequence.append(WaitForFocus("Save and proceed", acc_role=pyatspi.ROLE_LABEL))
######################################################################
# 3. Press Tab to get to the database registration radio buttons.
#
# BRAILLE LINE: 'soffice Application Database Wizard Dialog Database Wizard OptionPane &=y Do you want the wizard to register the database in OpenOffice.org? Yes, register the database for me RadioButton'
# VISIBLE: '&=y Do you want the wizard to re', cursor=1
# SPEECH OUTPUT: 'Yes, register the database for me selected radio button'
#
sequence.append(KeyComboAction("Tab"))
sequence.append(WaitForFocus("Yes, register the database for me", acc_role=pyatspi.ROLE_RADIO_BUTTON))
######################################################################
# 4. Press down arrow to not register this database.
#
# BRAILLE LINE: 'soffice Application Database Wizard Dialog Database Wizard OptionPane &=y No, do not register the database RadioButton'
# VISIBLE: '&=y No, do not register the data', cursor=1
# SPEECH OUTPUT: 'No, do not register the database selected radio button'
#
sequence.append(KeyComboAction("Down"))
sequence.append(WaitForFocus("No, do not register the database", acc_role=pyatspi.ROLE_RADIO_BUTTON))
sequence.append(PauseAction(3000))
######################################################################
# 5. Press Return to Finish the startup wizard.
#
# BRAILLE LINE: 'soffice Application Save Dialog ScrollPane Files Table'
# VISIBLE: 'Files Table', cursor=1
# SPEECH OUTPUT: 'Save'
# SPEECH OUTPUT: 'Files table'
#
sequence.append(KeyComboAction("Return"))
sequence.append(WaitForFocus("Files", acc_role=pyatspi.ROLE_TABLE))
sequence.append(PauseAction(3000))
######################################################################
# 6. A Save dialog has appeared. Press Return to select the default name.
# A database window will appear.
#
# BRAILLE LINE: 'soffice Application New Database - OpenOffice.org Base Frame New Database - OpenOffice.org Base RootPane IconChoiceControl Tree Forms Label'
# VISIBLE: 'Forms Label', cursor=1
# SPEECH OUTPUT: 'New Database - OpenOffice.org Base frame'
# SPEECH OUTPUT: 'panel'
# SPEECH OUTPUT: 'panel'
# SPEECH OUTPUT: 'panel'
# SPEECH OUTPUT: 'Forms label'
# SPEECH OUTPUT: 'panel'
# SPEECH OUTPUT: 'Forms label'
#
sequence.append(KeyComboAction("Return"))
sequence.append(WaitForWindowActivate("New Database - OpenOffice.org Base", None))
sequence.append(WaitForFocus("IconChoiceControl", acc_role=pyatspi.ROLE_TREE))
######################################################################
# 7. Enter Alt-f, Alt-c to close the database window.
#
sequence.append(KeyComboAction("<Alt>f"))
sequence.append(WaitForFocus("New", acc_role=pyatspi.ROLE_MENU))
sequence.append(KeyComboAction("<Alt>c"))
sequence.append(WaitAction("object:property-change:accessible-name",
None,
None,
pyatspi.ROLE_ROOT_PANE,
30000))
######################################################################
# 8. Wait for things to get back to normal.
#
sequence.append(PauseAction(3000))
sequence.start()
|
lgpl-2.1
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
624,
774,
370,
4911,
6519,
327,
25245,
10419,
365,
5139,
6317,
14,
2043,
593,
27428,
308,
1095,
4223,
2467,
9030,
1380,
9509,
316,
282,
3050,
2777,
14,
199,
624,
199,
199,
504,
4497,
285,
79,
265,
14,
2802,
894,
492,
627,
199,
199,
4041,
275,
10444,
293,
5826,
342,
199,
199,
18022,
199,
3,
413,
14,
7707,
16390,
1095,
14,
13144,
367,
314,
1642,
6426,
402,
314,
14210,
12262,
370,
199,
3,
259,
7468,
14,
199,
3,
199,
4041,
14,
740,
8,
21433,
4301,
30120,
480,
7243,
644,
6281,
401,
488,
430,
199,
4041,
14,
740,
8,
21433,
17310,
480,
5446,
3050,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
13837,
430,
199,
199,
18022,
199,
3,
499,
14,
23583,
1432,
370,
664,
370,
314,
3499,
6426,
402,
314,
14210,
12262,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
8692,
644,
6281,
30631,
8692,
644,
6281,
3207,
48,
5865,
428,
6224,
510,
4822,
11063,
436,
20320,
10354,
7,
199,
3,
812,
1311,
7187,
26,
221,
283,
8229,
436,
20320,
10354,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
8229,
436,
20320,
1768,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
1767,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
8229,
436,
20320,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
13837,
430,
199,
199,
18022,
199,
3,
650,
14,
23583,
23159,
370,
664,
370,
314,
3050,
10991,
22008,
15766,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
8692,
644,
6281,
30631,
8692,
644,
6281,
3207,
48,
5865,
18415,
89,
4226,
1265,
2934,
314,
12262,
370,
2274,
314,
3050,
315,
3232,
31166,
14,
1308,
31,
29715,
12,
2274,
314,
3050,
367,
562,
13514,
4259,
7,
199,
3,
812,
1311,
7187,
26,
221,
7673,
29,
89,
4226,
1265,
2934,
314,
12262,
370,
295,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
12555,
12,
2274,
314,
3050,
367,
562,
4895,
22008,
5528,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
7690,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
12555,
12,
2274,
314,
3050,
367,
562,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
19662,
2090,
63,
13272,
430,
199,
199,
18022,
199,
3,
841,
14,
23583,
3224,
18800,
370,
440,
2274,
642,
3050,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
8692,
644,
6281,
30631,
8692,
644,
6281,
3207,
48,
5865,
18415,
89,
3091,
12,
886,
440,
2274,
314,
3050,
13514,
4259,
7,
199,
3,
812,
1311,
7187,
26,
221,
7673,
29,
89,
3091,
12,
886,
440,
2274,
314,
666,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
1944,
12,
886,
440,
2274,
314,
3050,
4895,
22008,
5528,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
3514,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
1944,
12,
886,
440,
2274,
314,
3050,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
19662,
2090,
63,
13272,
430,
199,
4041,
14,
740,
8,
30851,
3310,
8,
19962,
430,
199,
199,
18022,
199,
3,
959,
14,
23583,
1432,
370,
11711,
2453,
314,
14210,
12262,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
11063,
30631,
13916,
2827,
48,
5865,
16920,
6957,
7,
199,
3,
812,
1311,
7187,
26,
221,
283,
5535,
6957,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
8229,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
5535,
1817,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
1767,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
5535,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
8723,
430,
199,
4041,
14,
740,
8,
30851,
3310,
8,
19962,
430,
199,
199,
18022,
199,
3,
1227,
14,
437,
11063,
9592,
965,
5704,
2899,
14,
23583,
1432,
370,
3504,
314,
849,
536,
14,
199,
3,
259,
437,
3050,
4353,
911,
7468,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
7053,
8692,
446,
3232,
31166,
14,
1308,
3523,
11726,
7053,
8692,
446,
3232,
31166,
14,
1308,
3523,
12826,
48,
5865,
473,
388,
9054,
3717,
12178,
2104,
706,
10354,
7,
199,
3,
812,
1311,
7187,
26,
221,
283,
26028,
10354,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
4665,
8692,
446,
3232,
31166,
14,
1308,
3523,
2787,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
26028,
1768,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
26028,
1768,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
1767,
2237,
199,
4041,
14,
740,
8,
21433,
4301,
30120,
480,
4665,
8692,
446,
3232,
31166,
14,
1308,
3523,
401,
488,
430,
199,
4041,
14,
740,
8,
21433,
17310,
480,
8954,
9054,
3717,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
22841,
430,
199,
199,
18022,
199,
3,
1520,
14,
16401,
437,
4116,
13,
70,
12,
437,
4116,
13,
67,
370,
4002,
314,
3050,
4353,
14,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
6757,
16985,
30,
70,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
4665,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
18223,
430,
199,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
6757,
16985,
30,
67,
2237,
199,
4041,
14,
740,
8,
7536,
3310,
480,
785,
26,
1829,
13,
1461,
26,
24669,
13,
354,
401,
2574,
488,
12,
2574,
488,
12,
2574,
1134,
292,
8721,
14,
15468,
63,
5441,
63,
26685,
37,
12,
2574,
650,
993,
430,
199,
199,
18022,
199,
3,
1695,
14,
13144,
367,
7645,
370,
664,
1771,
370,
3293
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
624,
774,
370,
4911,
6519,
327,
25245,
10419,
365,
5139,
6317,
14,
2043,
593,
27428,
308,
1095,
4223,
2467,
9030,
1380,
9509,
316,
282,
3050,
2777,
14,
199,
624,
199,
199,
504,
4497,
285,
79,
265,
14,
2802,
894,
492,
627,
199,
199,
4041,
275,
10444,
293,
5826,
342,
199,
199,
18022,
199,
3,
413,
14,
7707,
16390,
1095,
14,
13144,
367,
314,
1642,
6426,
402,
314,
14210,
12262,
370,
199,
3,
259,
7468,
14,
199,
3,
199,
4041,
14,
740,
8,
21433,
4301,
30120,
480,
7243,
644,
6281,
401,
488,
430,
199,
4041,
14,
740,
8,
21433,
17310,
480,
5446,
3050,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
13837,
430,
199,
199,
18022,
199,
3,
499,
14,
23583,
1432,
370,
664,
370,
314,
3499,
6426,
402,
314,
14210,
12262,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
8692,
644,
6281,
30631,
8692,
644,
6281,
3207,
48,
5865,
428,
6224,
510,
4822,
11063,
436,
20320,
10354,
7,
199,
3,
812,
1311,
7187,
26,
221,
283,
8229,
436,
20320,
10354,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
8229,
436,
20320,
1768,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
1767,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
8229,
436,
20320,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
13837,
430,
199,
199,
18022,
199,
3,
650,
14,
23583,
23159,
370,
664,
370,
314,
3050,
10991,
22008,
15766,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
8692,
644,
6281,
30631,
8692,
644,
6281,
3207,
48,
5865,
18415,
89,
4226,
1265,
2934,
314,
12262,
370,
2274,
314,
3050,
315,
3232,
31166,
14,
1308,
31,
29715,
12,
2274,
314,
3050,
367,
562,
13514,
4259,
7,
199,
3,
812,
1311,
7187,
26,
221,
7673,
29,
89,
4226,
1265,
2934,
314,
12262,
370,
295,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
12555,
12,
2274,
314,
3050,
367,
562,
4895,
22008,
5528,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
7690,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
12555,
12,
2274,
314,
3050,
367,
562,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
19662,
2090,
63,
13272,
430,
199,
199,
18022,
199,
3,
841,
14,
23583,
3224,
18800,
370,
440,
2274,
642,
3050,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
8692,
644,
6281,
30631,
8692,
644,
6281,
3207,
48,
5865,
18415,
89,
3091,
12,
886,
440,
2274,
314,
3050,
13514,
4259,
7,
199,
3,
812,
1311,
7187,
26,
221,
7673,
29,
89,
3091,
12,
886,
440,
2274,
314,
666,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
1944,
12,
886,
440,
2274,
314,
3050,
4895,
22008,
5528,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
3514,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
1944,
12,
886,
440,
2274,
314,
3050,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
19662,
2090,
63,
13272,
430,
199,
4041,
14,
740,
8,
30851,
3310,
8,
19962,
430,
199,
199,
18022,
199,
3,
959,
14,
23583,
1432,
370,
11711,
2453,
314,
14210,
12262,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
11063,
30631,
13916,
2827,
48,
5865,
16920,
6957,
7,
199,
3,
812,
1311,
7187,
26,
221,
283,
5535,
6957,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
8229,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
5535,
1817,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
1767,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
5535,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
8723,
430,
199,
4041,
14,
740,
8,
30851,
3310,
8,
19962,
430,
199,
199,
18022,
199,
3,
1227,
14,
437,
11063,
9592,
965,
5704,
2899,
14,
23583,
1432,
370,
3504,
314,
849,
536,
14,
199,
3,
259,
437,
3050,
4353,
911,
7468,
14,
199,
3,
199,
3,
699,
2847,
1193,
906,
13587,
26,
221,
283,
1152,
11286,
301,
13515,
7053,
8692,
446,
3232,
31166,
14,
1308,
3523,
11726,
7053,
8692,
446,
3232,
31166,
14,
1308,
3523,
12826,
48,
5865,
473,
388,
9054,
3717,
12178,
2104,
706,
10354,
7,
199,
3,
812,
1311,
7187,
26,
221,
283,
26028,
10354,
297,
3920,
29,
17,
199,
3,
428,
1510,
25126,
18746,
26,
283,
4665,
8692,
446,
3232,
31166,
14,
1308,
3523,
2787,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
26028,
1768,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
7885,
7,
199,
3,
428,
1510,
25126,
18746,
26,
283,
26028,
1768,
7,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
480,
1767,
2237,
199,
4041,
14,
740,
8,
21433,
4301,
30120,
480,
4665,
8692,
446,
3232,
31166,
14,
1308,
3523,
401,
488,
430,
199,
4041,
14,
740,
8,
21433,
17310,
480,
8954,
9054,
3717,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
22841,
430,
199,
199,
18022,
199,
3,
1520,
14,
16401,
437,
4116,
13,
70,
12,
437,
4116,
13,
67,
370,
4002,
314,
3050,
4353,
14,
199,
3,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
6757,
16985,
30,
70,
2237,
199,
4041,
14,
740,
8,
21433,
17310,
480,
4665,
401,
6907,
63,
3756,
29,
647,
292,
8721,
14,
15468,
63,
18223,
430,
199,
199,
4041,
14,
740,
8,
1197,
12413,
3310,
6757,
16985,
30,
67,
2237,
199,
4041,
14,
740,
8,
7536,
3310,
480,
785,
26,
1829,
13,
1461,
26,
24669,
13,
354,
401,
2574,
488,
12,
2574,
488,
12,
2574,
1134,
292,
8721,
14,
15468,
63,
5441,
63,
26685,
37,
12,
2574,
650,
993,
430,
199,
199,
18022,
199,
3,
1695,
14,
13144,
367,
7645,
370,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
1,
1,
1,
1,
1,
1,
1
] |
todaychi/hue
|
desktop/core/ext-py/boto-2.46.1/boto/mws/connection.py
|
135
|
49808
|
# Copyright (c) 2012-2014 Andy Davidoff http://www.disruptek.com/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
import xml.sax
import hashlib
import string
import collections
from boto.connection import AWSQueryConnection
from boto.exception import BotoServerError
import boto.mws.exception
import boto.mws.response
from boto.handler import XmlHandler
from boto.compat import filter, map, six, encodebytes
__all__ = ['MWSConnection']
api_version_path = {
'Feeds': ('2009-01-01', 'Merchant', '/'),
'Reports': ('2009-01-01', 'Merchant', '/'),
'Orders': ('2013-09-01', 'SellerId', '/Orders/2013-09-01'),
'Products': ('2011-10-01', 'SellerId', '/Products/2011-10-01'),
'Sellers': ('2011-07-01', 'SellerId', '/Sellers/2011-07-01'),
'Inbound': ('2010-10-01', 'SellerId',
'/FulfillmentInboundShipment/2010-10-01'),
'Outbound': ('2010-10-01', 'SellerId',
'/FulfillmentOutboundShipment/2010-10-01'),
'Inventory': ('2010-10-01', 'SellerId',
'/FulfillmentInventory/2010-10-01'),
'Recommendations': ('2013-04-01', 'SellerId',
'/Recommendations/2013-04-01'),
'CustomerInfo': ('2014-03-01', 'SellerId',
'/CustomerInformation/2014-03-01'),
'CartInfo': ('2014-03-01', 'SellerId',
'/CartInformation/2014-03-01'),
'Subscriptions': ('2013-07-01', 'SellerId',
'/Subscriptions/2013-07-01'),
'OffAmazonPayments': ('2013-01-01', 'SellerId',
'/OffAmazonPayments/2013-01-01'),
}
content_md5 = lambda c: encodebytes(hashlib.md5(c).digest()).strip()
decorated_attrs = ('action', 'response', 'section',
'quota', 'restore', 'version')
api_call_map = {}
def add_attrs_from(func, to):
for attr in decorated_attrs:
setattr(to, attr, getattr(func, attr, None))
to.__wrapped__ = func
return to
def structured_lists(*fields):
def decorator(func):
def wrapper(self, *args, **kw):
for key, acc in [f.split('.') for f in fields]:
if key in kw:
newkey = key + '.' + acc + (acc and '.' or '')
for i in range(len(kw[key])):
kw[newkey + str(i + 1)] = kw[key][i]
kw.pop(key)
return func(self, *args, **kw)
wrapper.__doc__ = "{0}\nLists: {1}".format(func.__doc__,
', '.join(fields))
return add_attrs_from(func, to=wrapper)
return decorator
def http_body(field):
def decorator(func):
def wrapper(*args, **kw):
if any([f not in kw for f in (field, 'content_type')]):
message = "{0} requires {1} and content_type arguments for " \
"building HTTP body".format(func.action, field)
raise KeyError(message)
kw['body'] = kw.pop(field)
kw['headers'] = {
'Content-Type': kw.pop('content_type'),
'Content-MD5': content_md5(kw['body']),
}
return func(*args, **kw)
wrapper.__doc__ = "{0}\nRequired HTTP Body: " \
"{1}".format(func.__doc__, field)
return add_attrs_from(func, to=wrapper)
return decorator
def destructure_object(value, into, prefix, members=False):
if isinstance(value, boto.mws.response.ResponseElement):
destructure_object(value.__dict__, into, prefix, members=members)
elif isinstance(value, collections.Mapping):
for name in value:
if name.startswith('_'):
continue
destructure_object(value[name], into, prefix + '.' + name,
members=members)
elif isinstance(value, six.string_types):
into[prefix] = value
elif isinstance(value, collections.Iterable):
for index, element in enumerate(value):
suffix = (members and '.member.' or '.') + str(index + 1)
destructure_object(element, into, prefix + suffix,
members=members)
elif isinstance(value, bool):
into[prefix] = str(value).lower()
else:
into[prefix] = value
def structured_objects(*fields, **kwargs):
def decorator(func):
def wrapper(*args, **kw):
members = kwargs.get('members', False)
for field in filter(lambda i: i in kw, fields):
destructure_object(kw.pop(field), kw, field, members=members)
return func(*args, **kw)
wrapper.__doc__ = "{0}\nElement|Iter|Map: {1}\n" \
"(ResponseElement or anything iterable/dict-like)" \
.format(func.__doc__, ', '.join(fields))
return add_attrs_from(func, to=wrapper)
return decorator
def requires(*groups):
def decorator(func):
def requires(*args, **kw):
hasgroup = lambda group: all(key in kw for key in group)
if 1 != len(list(filter(hasgroup, groups))):
message = ' OR '.join(['+'.join(g) for g in groups])
message = "{0} requires {1} argument(s)" \
"".format(func.action, message)
raise KeyError(message)
return func(*args, **kw)
message = ' OR '.join(['+'.join(g) for g in groups])
requires.__doc__ = "{0}\nRequired: {1}".format(func.__doc__,
message)
return add_attrs_from(func, to=requires)
return decorator
def exclusive(*groups):
def decorator(func):
def wrapper(*args, **kw):
hasgroup = lambda group: all(key in kw for key in group)
if len(list(filter(hasgroup, groups))) not in (0, 1):
message = ' OR '.join(['+'.join(g) for g in groups])
message = "{0} requires either {1}" \
"".format(func.action, message)
raise KeyError(message)
return func(*args, **kw)
message = ' OR '.join(['+'.join(g) for g in groups])
wrapper.__doc__ = "{0}\nEither: {1}".format(func.__doc__,
message)
return add_attrs_from(func, to=wrapper)
return decorator
def dependent(field, *groups):
def decorator(func):
def wrapper(*args, **kw):
hasgroup = lambda group: all(key in kw for key in group)
if field in kw and not any(hasgroup(g) for g in groups):
message = ' OR '.join(['+'.join(g) for g in groups])
message = "{0} argument {1} requires {2}" \
"".format(func.action, field, message)
raise KeyError(message)
return func(*args, **kw)
message = ' OR '.join(['+'.join(g) for g in groups])
wrapper.__doc__ = "{0}\n{1} requires: {2}".format(func.__doc__,
field,
message)
return add_attrs_from(func, to=wrapper)
return decorator
def requires_some_of(*fields):
def decorator(func):
def requires(*args, **kw):
if not any(i in kw for i in fields):
message = "{0} requires at least one of {1} argument(s)" \
"".format(func.action, ', '.join(fields))
raise KeyError(message)
return func(*args, **kw)
requires.__doc__ = "{0}\nSome Required: {1}".format(func.__doc__,
', '.join(fields))
return add_attrs_from(func, to=requires)
return decorator
def boolean_arguments(*fields):
def decorator(func):
def wrapper(*args, **kw):
for field in [f for f in fields if isinstance(kw.get(f), bool)]:
kw[field] = str(kw[field]).lower()
return func(*args, **kw)
wrapper.__doc__ = "{0}\nBooleans: {1}".format(func.__doc__,
', '.join(fields))
return add_attrs_from(func, to=wrapper)
return decorator
def api_action(section, quota, restore, *api):
def decorator(func, quota=int(quota), restore=float(restore)):
version, accesskey, path = api_version_path[section]
action = ''.join(api or map(str.capitalize, func.__name__.split('_')))
def wrapper(self, *args, **kw):
kw.setdefault(accesskey, getattr(self, accesskey, None))
if kw[accesskey] is None:
message = "{0} requires {1} argument. Set the " \
"MWSConnection.{2} attribute?" \
"".format(action, accesskey, accesskey)
raise KeyError(message)
kw['Action'] = action
kw['Version'] = version
response = self._response_factory(action, connection=self)
request = dict(path=path, quota=quota, restore=restore)
return func(self, request, response, *args, **kw)
for attr in decorated_attrs:
setattr(wrapper, attr, locals().get(attr))
wrapper.__doc__ = "MWS {0}/{1} API call; quota={2} restore={3:.2f}\n" \
"{4}".format(action, version, quota, restore,
func.__doc__)
api_call_map[action] = func.__name__
return wrapper
return decorator
class MWSConnection(AWSQueryConnection):
ResponseFactory = boto.mws.response.ResponseFactory
ResponseErrorFactory = boto.mws.exception.ResponseErrorFactory
def __init__(self, *args, **kw):
kw.setdefault('host', 'mws.amazonservices.com')
self._sandboxed = kw.pop('sandbox', False)
self.Merchant = kw.pop('Merchant', None) or kw.get('SellerId')
self.SellerId = kw.pop('SellerId', None) or self.Merchant
kw = self._setup_factories(kw.pop('factory_scopes', []), **kw)
super(MWSConnection, self).__init__(*args, **kw)
def _setup_factories(self, extrascopes, **kw):
for factory, (scope, Default) in {
'response_factory':
(boto.mws.response, self.ResponseFactory),
'response_error_factory':
(boto.mws.exception, self.ResponseErrorFactory),
}.items():
if factory in kw:
setattr(self, '_' + factory, kw.pop(factory))
else:
scopes = extrascopes + [scope]
setattr(self, '_' + factory, Default(scopes=scopes))
return kw
def _sandboxify(self, path):
if not self._sandboxed:
return path
splat = path.split('/')
splat[-2] += '_Sandbox'
return '/'.join(splat)
def _required_auth_capability(self):
return ['mws']
def _post_request(self, request, params, parser, body='', headers=None):
"""Make a POST request, optionally with a content body,
and return the response, optionally as raw text.
"""
headers = headers or {}
path = self._sandboxify(request['path'])
request = self.build_base_http_request('POST', path, None, data=body,
params=params, headers=headers,
host=self.host)
try:
response = self._mexe(request, override_num_retries=None)
except BotoServerError as bs:
raise self._response_error_factory(bs.status, bs.reason, bs.body)
body = response.read()
boto.log.debug(body)
if not body:
boto.log.error('Null body %s' % body)
raise self._response_error_factory(response.status,
response.reason, body)
if response.status != 200:
boto.log.error('%s %s' % (response.status, response.reason))
boto.log.error('%s' % body)
raise self._response_error_factory(response.status,
response.reason, body)
digest = response.getheader('Content-MD5')
if digest is not None:
assert content_md5(body) == digest
contenttype = response.getheader('Content-Type')
return self._parse_response(parser, contenttype, body)
def _parse_response(self, parser, contenttype, body):
if not contenttype.startswith('text/xml'):
return body
handler = XmlHandler(parser, self)
xml.sax.parseString(body, handler)
return parser
def method_for(self, name):
"""Return the MWS API method referred to in the argument.
The named method can be in CamelCase or underlined_lower_case.
This is the complement to MWSConnection.any_call.action
"""
action = '_' in name and string.capwords(name, '_') or name
if action in api_call_map:
return getattr(self, api_call_map[action])
return None
def iter_call(self, call, *args, **kw):
"""Pass a call name as the first argument and a generator
is returned for the initial response and any continuation
call responses made using the NextToken.
"""
method = self.method_for(call)
assert method, 'No call named "{0}"'.format(call)
return self.iter_response(method(*args, **kw))
def iter_response(self, response):
"""Pass a call's response as the initial argument and a
generator is returned for the initial response and any
continuation call responses made using the NextToken.
"""
yield response
more = self.method_for(response._action + 'ByNextToken')
while more and response._result.HasNext == 'true':
response = more(NextToken=response._result.NextToken)
yield response
@requires(['FeedType'])
@boolean_arguments('PurgeAndReplace')
@http_body('FeedContent')
@structured_lists('MarketplaceIdList.Id')
@api_action('Feeds', 15, 120)
def submit_feed(self, request, response, headers=None, body='', **kw):
"""Uploads a feed for processing by Amazon MWS.
"""
headers = headers or {}
return self._post_request(request, kw, response, body=body,
headers=headers)
@structured_lists('FeedSubmissionIdList.Id', 'FeedTypeList.Type',
'FeedProcessingStatusList.Status')
@api_action('Feeds', 10, 45)
def get_feed_submission_list(self, request, response, **kw):
"""Returns a list of all feed submissions submitted in the
previous 90 days.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Feeds', 0, 0)
def get_feed_submission_list_by_next_token(self, request, response, **kw):
"""Returns a list of feed submissions using the NextToken parameter.
"""
return self._post_request(request, kw, response)
@structured_lists('FeedTypeList.Type', 'FeedProcessingStatusList.Status')
@api_action('Feeds', 10, 45)
def get_feed_submission_count(self, request, response, **kw):
"""Returns a count of the feeds submitted in the previous 90 days.
"""
return self._post_request(request, kw, response)
@structured_lists('FeedSubmissionIdList.Id', 'FeedTypeList.Type')
@api_action('Feeds', 10, 45)
def cancel_feed_submissions(self, request, response, **kw):
"""Cancels one or more feed submissions and returns a
count of the feed submissions that were canceled.
"""
return self._post_request(request, kw, response)
@requires(['FeedSubmissionId'])
@api_action('Feeds', 15, 60)
def get_feed_submission_result(self, request, response, **kw):
"""Returns the feed processing report.
"""
return self._post_request(request, kw, response)
def get_service_status(self, **kw):
"""Instruct the user on how to get service status.
"""
sections = ', '.join(map(str.lower, api_version_path.keys()))
message = "Use {0}.get_(section)_service_status(), " \
"where (section) is one of the following: " \
"{1}".format(self.__class__.__name__, sections)
raise AttributeError(message)
@requires(['ReportType'])
@structured_lists('MarketplaceIdList.Id')
@boolean_arguments('ReportOptions=ShowSalesChannel')
@api_action('Reports', 15, 60)
def request_report(self, request, response, **kw):
"""Creates a report request and submits the request to Amazon MWS.
"""
return self._post_request(request, kw, response)
@structured_lists('ReportRequestIdList.Id', 'ReportTypeList.Type',
'ReportProcessingStatusList.Status')
@api_action('Reports', 10, 45)
def get_report_request_list(self, request, response, **kw):
"""Returns a list of report requests that you can use to get the
ReportRequestId for a report.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Reports', 0, 0)
def get_report_request_list_by_next_token(self, request, response, **kw):
"""Returns a list of report requests using the NextToken,
which was supplied by a previous request to either
GetReportRequestListByNextToken or GetReportRequestList, where
the value of HasNext was true in that previous request.
"""
return self._post_request(request, kw, response)
@structured_lists('ReportTypeList.Type',
'ReportProcessingStatusList.Status')
@api_action('Reports', 10, 45)
def get_report_request_count(self, request, response, **kw):
"""Returns a count of report requests that have been submitted
to Amazon MWS for processing.
"""
return self._post_request(request, kw, response)
@api_action('Reports', 10, 45)
def cancel_report_requests(self, request, response, **kw):
"""Cancel one or more report requests, returning the count of the
canceled report requests and the report request information.
"""
return self._post_request(request, kw, response)
@boolean_arguments('Acknowledged')
@structured_lists('ReportRequestIdList.Id', 'ReportTypeList.Type')
@api_action('Reports', 10, 60)
def get_report_list(self, request, response, **kw):
"""Returns a list of reports that were created in the previous
90 days that match the query parameters.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Reports', 0, 0)
def get_report_list_by_next_token(self, request, response, **kw):
"""Returns a list of reports using the NextToken, which
was supplied by a previous request to either
GetReportListByNextToken or GetReportList, where the
value of HasNext was true in the previous call.
"""
return self._post_request(request, kw, response)
@boolean_arguments('Acknowledged')
@structured_lists('ReportTypeList.Type')
@api_action('Reports', 10, 45)
def get_report_count(self, request, response, **kw):
"""Returns a count of the reports, created in the previous 90 days,
with a status of _DONE_ and that are available for download.
"""
return self._post_request(request, kw, response)
@requires(['ReportId'])
@api_action('Reports', 15, 60)
def get_report(self, request, response, **kw):
"""Returns the contents of a report.
"""
return self._post_request(request, kw, response)
@requires(['ReportType', 'Schedule'])
@api_action('Reports', 10, 45)
def manage_report_schedule(self, request, response, **kw):
"""Creates, updates, or deletes a report request schedule for
a specified report type.
"""
return self._post_request(request, kw, response)
@structured_lists('ReportTypeList.Type')
@api_action('Reports', 10, 45)
def get_report_schedule_list(self, request, response, **kw):
"""Returns a list of order report requests that are scheduled
to be submitted to Amazon MWS for processing.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Reports', 0, 0)
def get_report_schedule_list_by_next_token(self, request, response, **kw):
"""Returns a list of report requests using the NextToken,
which was supplied by a previous request to either
GetReportScheduleListByNextToken or GetReportScheduleList,
where the value of HasNext was true in that previous request.
"""
return self._post_request(request, kw, response)
@structured_lists('ReportTypeList.Type')
@api_action('Reports', 10, 45)
def get_report_schedule_count(self, request, response, **kw):
"""Returns a count of order report requests that are scheduled
to be submitted to Amazon MWS.
"""
return self._post_request(request, kw, response)
@requires(['ReportIdList'])
@boolean_arguments('Acknowledged')
@structured_lists('ReportIdList.Id')
@api_action('Reports', 10, 45)
def update_report_acknowledgements(self, request, response, **kw):
"""Updates the acknowledged status of one or more reports.
"""
return self._post_request(request, kw, response)
@requires(['ShipFromAddress', 'InboundShipmentPlanRequestItems'])
@structured_objects('ShipFromAddress', 'InboundShipmentPlanRequestItems')
@api_action('Inbound', 30, 0.5)
def create_inbound_shipment_plan(self, request, response, **kw):
"""Returns the information required to create an inbound shipment.
"""
return self._post_request(request, kw, response)
@requires(['ShipmentId', 'InboundShipmentHeader', 'InboundShipmentItems'])
@structured_objects('InboundShipmentHeader', 'InboundShipmentItems')
@api_action('Inbound', 30, 0.5)
def create_inbound_shipment(self, request, response, **kw):
"""Creates an inbound shipment.
"""
return self._post_request(request, kw, response)
@requires(['ShipmentId'])
@structured_objects('InboundShipmentHeader', 'InboundShipmentItems')
@api_action('Inbound', 30, 0.5)
def update_inbound_shipment(self, request, response, **kw):
"""Updates an existing inbound shipment. Amazon documentation
is ambiguous as to whether the InboundShipmentHeader and
InboundShipmentItems arguments are required.
"""
return self._post_request(request, kw, response)
@requires_some_of('ShipmentIdList', 'ShipmentStatusList')
@structured_lists('ShipmentIdList.Id', 'ShipmentStatusList.Status')
@api_action('Inbound', 30, 0.5)
def list_inbound_shipments(self, request, response, **kw):
"""Returns a list of inbound shipments based on criteria that
you specify.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Inbound', 30, 0.5)
def list_inbound_shipments_by_next_token(self, request, response, **kw):
"""Returns the next page of inbound shipments using the NextToken
parameter.
"""
return self._post_request(request, kw, response)
@requires(['ShipmentId'], ['LastUpdatedAfter', 'LastUpdatedBefore'])
@api_action('Inbound', 30, 0.5)
def list_inbound_shipment_items(self, request, response, **kw):
"""Returns a list of items in a specified inbound shipment, or a
list of items that were updated within a specified time frame.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Inbound', 30, 0.5)
def list_inbound_shipment_items_by_next_token(self, request, response, **kw):
"""Returns the next page of inbound shipment items using the
NextToken parameter.
"""
return self._post_request(request, kw, response)
@api_action('Inbound', 2, 300, 'GetServiceStatus')
def get_inbound_service_status(self, request, response, **kw):
"""Returns the operational status of the Fulfillment Inbound
Shipment API section.
"""
return self._post_request(request, kw, response)
@requires(['SellerSkus'], ['QueryStartDateTime'])
@structured_lists('SellerSkus.member')
@api_action('Inventory', 30, 0.5)
def list_inventory_supply(self, request, response, **kw):
"""Returns information about the availability of a seller's
inventory.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Inventory', 30, 0.5)
def list_inventory_supply_by_next_token(self, request, response, **kw):
"""Returns the next page of information about the availability
of a seller's inventory using the NextToken parameter.
"""
return self._post_request(request, kw, response)
@api_action('Inventory', 2, 300, 'GetServiceStatus')
def get_inventory_service_status(self, request, response, **kw):
"""Returns the operational status of the Fulfillment Inventory
API section.
"""
return self._post_request(request, kw, response)
@requires(['PackageNumber'])
@api_action('Outbound', 30, 0.5)
def get_package_tracking_details(self, request, response, **kw):
"""Returns delivery tracking information for a package in
an outbound shipment for a Multi-Channel Fulfillment order.
"""
return self._post_request(request, kw, response)
@requires(['Address', 'Items'])
@structured_objects('Address', 'Items')
@api_action('Outbound', 30, 0.5)
def get_fulfillment_preview(self, request, response, **kw):
"""Returns a list of fulfillment order previews based on items
and shipping speed categories that you specify.
"""
return self._post_request(request, kw, response)
@requires(['SellerFulfillmentOrderId', 'DisplayableOrderId',
'ShippingSpeedCategory', 'DisplayableOrderDateTime',
'DestinationAddress', 'DisplayableOrderComment',
'Items'])
@structured_objects('DestinationAddress', 'Items')
@api_action('Outbound', 30, 0.5)
def create_fulfillment_order(self, request, response, **kw):
"""Requests that Amazon ship items from the seller's inventory
to a destination address.
"""
return self._post_request(request, kw, response)
@requires(['SellerFulfillmentOrderId'])
@api_action('Outbound', 30, 0.5)
def get_fulfillment_order(self, request, response, **kw):
"""Returns a fulfillment order based on a specified
SellerFulfillmentOrderId.
"""
return self._post_request(request, kw, response)
@api_action('Outbound', 30, 0.5)
def list_all_fulfillment_orders(self, request, response, **kw):
"""Returns a list of fulfillment orders fulfilled after (or
at) a specified date or by fulfillment method.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Outbound', 30, 0.5)
def list_all_fulfillment_orders_by_next_token(self, request, response, **kw):
"""Returns the next page of inbound shipment items using the
NextToken parameter.
"""
return self._post_request(request, kw, response)
@requires(['SellerFulfillmentOrderId'])
@api_action('Outbound', 30, 0.5)
def cancel_fulfillment_order(self, request, response, **kw):
"""Requests that Amazon stop attempting to fulfill an existing
fulfillment order.
"""
return self._post_request(request, kw, response)
@api_action('Outbound', 2, 300, 'GetServiceStatus')
def get_outbound_service_status(self, request, response, **kw):
"""Returns the operational status of the Fulfillment Outbound
API section.
"""
return self._post_request(request, kw, response)
@requires(['CreatedAfter'], ['LastUpdatedAfter'])
@requires(['MarketplaceId'])
@exclusive(['CreatedAfter'], ['LastUpdatedAfter'])
@dependent('CreatedBefore', ['CreatedAfter'])
@exclusive(['LastUpdatedAfter'], ['BuyerEmail'], ['SellerOrderId'])
@dependent('LastUpdatedBefore', ['LastUpdatedAfter'])
@exclusive(['CreatedAfter'], ['LastUpdatedBefore'])
@structured_objects('OrderTotal', 'ShippingAddress',
'PaymentExecutionDetail')
@structured_lists('MarketplaceId.Id', 'OrderStatus.Status',
'FulfillmentChannel.Channel', 'PaymentMethod.')
@api_action('Orders', 6, 60)
def list_orders(self, request, response, **kw):
"""Returns a list of orders created or updated during a time
frame that you specify.
"""
toggle = set(('FulfillmentChannel.Channel.1',
'OrderStatus.Status.1', 'PaymentMethod.1',
'LastUpdatedAfter', 'LastUpdatedBefore'))
for do, dont in {
'BuyerEmail': toggle.union(['SellerOrderId']),
'SellerOrderId': toggle.union(['BuyerEmail']),
}.items():
if do in kw and any(i in dont for i in kw):
message = "Don't include {0} when specifying " \
"{1}".format(' or '.join(dont), do)
raise AssertionError(message)
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Orders', 6, 60)
def list_orders_by_next_token(self, request, response, **kw):
"""Returns the next page of orders using the NextToken value
that was returned by your previous request to either
ListOrders or ListOrdersByNextToken.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderId'])
@structured_lists('AmazonOrderId.Id')
@api_action('Orders', 6, 60)
def get_order(self, request, response, **kw):
"""Returns an order for each AmazonOrderId that you specify.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderId'])
@api_action('Orders', 30, 2)
def list_order_items(self, request, response, **kw):
"""Returns order item information for an AmazonOrderId that
you specify.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Orders', 30, 2)
def list_order_items_by_next_token(self, request, response, **kw):
"""Returns the next page of order items using the NextToken
value that was returned by your previous request to either
ListOrderItems or ListOrderItemsByNextToken.
"""
return self._post_request(request, kw, response)
@api_action('Orders', 2, 300, 'GetServiceStatus')
def get_orders_service_status(self, request, response, **kw):
"""Returns the operational status of the Orders API section.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'Query'])
@api_action('Products', 20, 20)
def list_matching_products(self, request, response, **kw):
"""Returns a list of products and their attributes, ordered
by relevancy, based on a search query that you specify.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'ASINList'])
@structured_lists('ASINList.ASIN')
@api_action('Products', 20, 20)
def get_matching_product(self, request, response, **kw):
"""Returns a list of products and their attributes, based on
a list of ASIN values that you specify.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'IdType', 'IdList'])
@structured_lists('IdList.Id')
@api_action('Products', 20, 20)
def get_matching_product_for_id(self, request, response, **kw):
"""Returns a list of products and their attributes, based on
a list of Product IDs that you specify.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'SellerSKUList'])
@structured_lists('SellerSKUList.SellerSKU')
@api_action('Products', 20, 10, 'GetCompetitivePricingForSKU')
def get_competitive_pricing_for_sku(self, request, response, **kw):
"""Returns the current competitive pricing of a product,
based on the SellerSKUs and MarketplaceId that you specify.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'ASINList'])
@structured_lists('ASINList.ASIN')
@api_action('Products', 20, 10, 'GetCompetitivePricingForASIN')
def get_competitive_pricing_for_asin(self, request, response, **kw):
"""Returns the current competitive pricing of a product,
based on the ASINs and MarketplaceId that you specify.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'SellerSKUList'])
@structured_lists('SellerSKUList.SellerSKU')
@api_action('Products', 20, 5, 'GetLowestOfferListingsForSKU')
def get_lowest_offer_listings_for_sku(self, request, response, **kw):
"""Returns the lowest price offer listings for a specific
product by item condition and SellerSKUs.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'ASINList'])
@structured_lists('ASINList.ASIN')
@api_action('Products', 20, 5, 'GetLowestOfferListingsForASIN')
def get_lowest_offer_listings_for_asin(self, request, response, **kw):
"""Returns the lowest price offer listings for a specific
product by item condition and ASINs.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'SellerSKU'])
@api_action('Products', 20, 20, 'GetProductCategoriesForSKU')
def get_product_categories_for_sku(self, request, response, **kw):
"""Returns the product categories that a SellerSKU belongs to.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'ASIN'])
@api_action('Products', 20, 20, 'GetProductCategoriesForASIN')
def get_product_categories_for_asin(self, request, response, **kw):
"""Returns the product categories that an ASIN belongs to.
"""
return self._post_request(request, kw, response)
@api_action('Products', 2, 300, 'GetServiceStatus')
def get_products_service_status(self, request, response, **kw):
"""Returns the operational status of the Products API section.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'SellerSKUList'])
@structured_lists('SellerSKUList.SellerSKU')
@api_action('Products', 20, 10, 'GetMyPriceForSKU')
def get_my_price_for_sku(self, request, response, **kw):
"""Returns pricing information for your own offer listings, based on SellerSKU.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'ASINList'])
@structured_lists('ASINList.ASIN')
@api_action('Products', 20, 10, 'GetMyPriceForASIN')
def get_my_price_for_asin(self, request, response, **kw):
"""Returns pricing information for your own offer listings, based on ASIN.
"""
return self._post_request(request, kw, response)
@api_action('Sellers', 15, 60)
def list_marketplace_participations(self, request, response, **kw):
"""Returns a list of marketplaces that the seller submitting
the request can sell in, and a list of participations that
include seller-specific information in that marketplace.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Sellers', 15, 60)
def list_marketplace_participations_by_next_token(self, request, response,
**kw):
"""Returns the next page of marketplaces and participations
using the NextToken value that was returned by your
previous request to either ListMarketplaceParticipations
or ListMarketplaceParticipationsByNextToken.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId'])
@api_action('Recommendations', 5, 2)
def get_last_updated_time_for_recommendations(self, request, response,
**kw):
"""Checks whether there are active recommendations for each category
for the given marketplace, and if there are, returns the time when
recommendations were last updated for each category.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId'])
@structured_lists('CategoryQueryList.CategoryQuery')
@api_action('Recommendations', 5, 2)
def list_recommendations(self, request, response, **kw):
"""Returns your active recommendations for a specific category or for
all categories for a specific marketplace.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('Recommendations', 5, 2)
def list_recommendations_by_next_token(self, request, response, **kw):
"""Returns the next page of recommendations using the NextToken
parameter.
"""
return self._post_request(request, kw, response)
@api_action('Recommendations', 2, 300, 'GetServiceStatus')
def get_recommendations_service_status(self, request, response, **kw):
"""Returns the operational status of the Recommendations API section.
"""
return self._post_request(request, kw, response)
@api_action('CustomerInfo', 15, 12)
def list_customers(self, request, response, **kw):
"""Returns a list of customer accounts based on search criteria that
you specify.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('CustomerInfo', 50, 3)
def list_customers_by_next_token(self, request, response, **kw):
"""Returns the next page of customers using the NextToken parameter.
"""
return self._post_request(request, kw, response)
@requires(['CustomerIdList'])
@structured_lists('CustomerIdList.CustomerId')
@api_action('CustomerInfo', 15, 12)
def get_customers_for_customer_id(self, request, response, **kw):
"""Returns a list of customer accounts based on search criteria that
you specify.
"""
return self._post_request(request, kw, response)
@api_action('CustomerInfo', 2, 300, 'GetServiceStatus')
def get_customerinfo_service_status(self, request, response, **kw):
"""Returns the operational status of the Customer Information API
section.
"""
return self._post_request(request, kw, response)
@requires(['DateRangeStart'])
@api_action('CartInfo', 15, 12)
def list_carts(self, request, response, **kw):
"""Returns a list of shopping carts in your Webstore that were last
updated during the time range that you specify.
"""
return self._post_request(request, kw, response)
@requires(['NextToken'])
@api_action('CartInfo', 50, 3)
def list_carts_by_next_token(self, request, response, **kw):
"""Returns the next page of shopping carts using the NextToken
parameter.
"""
return self._post_request(request, kw, response)
@requires(['CartIdList'])
@structured_lists('CartIdList.CartId')
@api_action('CartInfo', 15, 12)
def get_carts(self, request, response, **kw):
"""Returns shopping carts based on the CartId values that you specify.
"""
return self._post_request(request, kw, response)
@api_action('CartInfo', 2, 300, 'GetServiceStatus')
def get_cartinfo_service_status(self, request, response, **kw):
"""Returns the operational status of the Cart Information API section.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'Destination'])
@structured_objects('Destination', members=True)
@api_action('Subscriptions', 25, 0.5)
def register_destination(self, request, response, **kw):
"""Specifies a new destination where you want to receive notifications.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'Destination'])
@structured_objects('Destination', members=True)
@api_action('Subscriptions', 25, 0.5)
def deregister_destination(self, request, response, **kw):
"""Removes an existing destination from the list of registered
destinations.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId'])
@api_action('Subscriptions', 25, 0.5)
def list_registered_destinations(self, request, response, **kw):
"""Lists all current destinations that you have registered.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'Destination'])
@structured_objects('Destination', members=True)
@api_action('Subscriptions', 25, 0.5)
def send_test_notification_to_destination(self, request, response, **kw):
"""Sends a test notification to an existing destination.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'Subscription'])
@structured_objects('Subscription', members=True)
@api_action('Subscriptions', 25, 0.5)
def create_subscription(self, request, response, **kw):
"""Creates a new subscription for the specified notification type
and destination.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'NotificationType', 'Destination'])
@structured_objects('Destination', members=True)
@api_action('Subscriptions', 25, 0.5)
def get_subscription(self, request, response, **kw):
"""Gets the subscription for the specified notification type and
destination.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'NotificationType', 'Destination'])
@structured_objects('Destination', members=True)
@api_action('Subscriptions', 25, 0.5)
def delete_subscription(self, request, response, **kw):
"""Deletes the subscription for the specified notification type and
destination.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId'])
@api_action('Subscriptions', 25, 0.5)
def list_subscriptions(self, request, response, **kw):
"""Returns a list of all your current subscriptions.
"""
return self._post_request(request, kw, response)
@requires(['MarketplaceId', 'Subscription'])
@structured_objects('Subscription', members=True)
@api_action('Subscriptions', 25, 0.5)
def update_subscription(self, request, response, **kw):
"""Updates the subscription for the specified notification type and
destination.
"""
return self._post_request(request, kw, response)
@api_action('Subscriptions', 2, 300, 'GetServiceStatus')
def get_subscriptions_service_status(self, request, response, **kw):
"""Returns the operational status of the Subscriptions API section.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderReferenceId', 'OrderReferenceAttributes'])
@structured_objects('OrderReferenceAttributes')
@api_action('OffAmazonPayments', 10, 1)
def set_order_reference_details(self, request, response, **kw):
"""Sets order reference details such as the order total and a
description for the order.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderReferenceId'])
@api_action('OffAmazonPayments', 20, 2)
def get_order_reference_details(self, request, response, **kw):
"""Returns details about the Order Reference object and its current
state.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderReferenceId'])
@api_action('OffAmazonPayments', 10, 1)
def confirm_order_reference(self, request, response, **kw):
"""Confirms that the order reference is free of constraints and all
required information has been set on the order reference.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderReferenceId'])
@api_action('OffAmazonPayments', 10, 1)
def cancel_order_reference(self, request, response, **kw):
"""Cancel an order reference; all authorizations associated with
this order reference are also closed.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderReferenceId'])
@api_action('OffAmazonPayments', 10, 1)
def close_order_reference(self, request, response, **kw):
"""Confirms that an order reference has been fulfilled (fully
or partially) and that you do not expect to create any new
authorizations on this order reference.
"""
return self._post_request(request, kw, response)
@requires(['AmazonOrderReferenceId', 'AuthorizationReferenceId',
'AuthorizationAmount'])
@structured_objects('AuthorizationAmount')
@api_action('OffAmazonPayments', 10, 1)
def authorize(self, request, response, **kw):
"""Reserves a specified amount against the payment method(s) stored in
the order reference.
"""
return self._post_request(request, kw, response)
@requires(['AmazonAuthorizationId'])
@api_action('OffAmazonPayments', 20, 2)
def get_authorization_details(self, request, response, **kw):
"""Returns the status of a particular authorization and the total
amount captured on the authorization.
"""
return self._post_request(request, kw, response)
@requires(['AmazonAuthorizationId', 'CaptureReferenceId', 'CaptureAmount'])
@structured_objects('CaptureAmount')
@api_action('OffAmazonPayments', 10, 1)
def capture(self, request, response, **kw):
"""Captures funds from an authorized payment instrument.
"""
return self._post_request(request, kw, response)
@requires(['AmazonCaptureId'])
@api_action('OffAmazonPayments', 20, 2)
def get_capture_details(self, request, response, **kw):
"""Returns the status of a particular capture and the total amount
refunded on the capture.
"""
return self._post_request(request, kw, response)
@requires(['AmazonAuthorizationId'])
@api_action('OffAmazonPayments', 10, 1)
def close_authorization(self, request, response, **kw):
"""Closes an authorization.
"""
return self._post_request(request, kw, response)
@requires(['AmazonCaptureId', 'RefundReferenceId', 'RefundAmount'])
@structured_objects('RefundAmount')
@api_action('OffAmazonPayments', 10, 1)
def refund(self, request, response, **kw):
"""Refunds a previously captured amount.
"""
return self._post_request(request, kw, response)
@requires(['AmazonRefundId'])
@api_action('OffAmazonPayments', 20, 2)
def get_refund_details(self, request, response, **kw):
"""Returns the status of a particular refund.
"""
return self._post_request(request, kw, response)
@api_action('OffAmazonPayments', 2, 300, 'GetServiceStatus')
def get_offamazonpayments_service_status(self, request, response, **kw):
"""Returns the operational status of the Off-Amazon Payments API
section.
"""
return self._post_request(request, kw, response)
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
6029,
13,
7280,
6061,
89,
20232,
1997,
1455,
921,
1544,
14,
2297,
5505,
266,
75,
14,
957,
15,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
646,
2748,
14,
14338,
199,
646,
8337,
199,
646,
1059,
199,
646,
5055,
199,
504,
6055,
14,
2105,
492,
10168,
3227,
3225,
199,
504,
6055,
14,
1971,
492,
24411,
17692,
199,
646,
6055,
14,
77,
3569,
14,
1971,
199,
646,
6055,
14,
77,
3569,
14,
1310,
199,
504,
6055,
14,
2232,
492,
24881,
2461,
199,
504,
6055,
14,
5819,
492,
2457,
12,
2341,
12,
3816,
12,
3752,
2394,
199,
199,
363,
452,
363,
275,
788,
45,
5035,
3225,
418,
199,
199,
1246,
63,
1023,
63,
515,
275,
469,
272,
283,
3456,
5923,
356,
3777,
661,
8664,
13,
614,
13,
614,
297,
283,
16797,
26938,
297,
1994,
659,
272,
283,
497,
5203,
356,
3698,
661,
8664,
13,
614,
13,
614,
297,
283,
16797,
26938,
297,
1994,
659,
272,
283,
4738,
83,
356,
3322,
661,
6965,
13,
1643,
13,
614,
297,
283,
20920,
1435,
1304,
297,
1994,
4738,
83,
15,
6965,
13,
1643,
13,
614,
659,
272,
283,
29631,
356,
3515,
661,
8128,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
1994,
29631,
15,
8128,
13,
709,
13,
614,
659,
272,
283,
20920,
29099,
356,
3698,
661,
8128,
13,
1780,
13,
614,
297,
283,
20920,
1435,
1304,
297,
1994,
20920,
29099,
15,
8128,
13,
1780,
13,
614,
659,
272,
283,
607,
3556,
356,
3698,
661,
6542,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19590,
22503,
434,
607,
3556,
2662,
18968,
15,
6542,
13,
709,
13,
614,
659,
272,
283,
2204,
3556,
356,
3515,
661,
6542,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19590,
22503,
434,
2204,
3556,
2662,
18968,
15,
6542,
13,
709,
13,
614,
659,
272,
283,
19304,
356,
260,
661,
6542,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19590,
22503,
434,
19304,
15,
6542,
13,
709,
13,
614,
659,
272,
283,
497,
14447,
1298,
356,
257,
661,
6965,
13,
966,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
497,
14447,
1298,
15,
6965,
13,
966,
13,
614,
659,
272,
283,
17025,
2354,
356,
420,
661,
7280,
13,
1644,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
17025,
4935,
15,
7280,
13,
1644,
13,
614,
659,
272,
283,
31667,
2354,
356,
3515,
661,
7280,
13,
1644,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
31667,
4935,
15,
7280,
13,
1644,
13,
614,
659,
272,
283,
19120,
83,
356,
258,
661,
6965,
13,
1780,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19120,
83,
15,
6965,
13,
1780,
13,
614,
659,
272,
283,
5195,
33,
8872,
10517,
1470,
356,
661,
6965,
13,
614,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
5195,
33,
8872,
10517,
1470,
15,
6965,
13,
614,
13,
614,
659,
199,
93,
199,
1317,
63,
1064,
21,
275,
2400,
286,
26,
3752,
2394,
8,
24722,
14,
1064,
21,
8,
67,
680,
5671,
8801,
1913,
342,
199,
29299,
63,
3288,
275,
661,
1287,
297,
283,
1310,
297,
283,
2792,
297,
673,
283,
8848,
297,
283,
8011,
297,
283,
1023,
358,
199,
1246,
63,
1250,
63,
1130,
275,
1052,
421,
199,
318,
1050,
63,
3288,
63,
504,
8,
1532,
12,
370,
304,
272,
367,
1921,
315,
16225,
63,
3288,
26,
267,
5371,
8,
475,
12,
1921,
12,
2519,
8,
1532,
12,
1921,
12,
488,
430,
272,
370,
855,
9130,
363,
275,
2562,
272,
372,
370,
421,
199,
318,
21781,
63,
6717,
2031,
955,
304,
339,
347,
7531,
8,
1532,
304,
398,
347,
4975,
8,
277,
12,
627,
589,
12,
1011,
829,
304,
288,
367,
790,
12,
6907,
315,
359,
70,
14,
1294,
7563,
367,
289,
315,
1504,
2189,
355,
340,
790,
315,
4775,
26,
490,
892,
498,
275,
790,
435,
7815,
435,
6907,
435,
334,
5470,
436,
7815,
503,
4074,
490,
367,
284,
315,
1425,
8,
552,
8,
829,
59,
498,
18710,
717,
4775,
59,
1222,
498,
435,
620,
8,
73,
435,
413,
1874,
275,
4775,
59,
498,
1527,
73,
61,
490,
4775,
14,
1935,
8,
498,
9,
288,
372,
2562,
8,
277,
12,
627,
589,
12,
1011,
829,
9,
267,
4975,
855,
1301,
363,
275,
5310,
16,
4988,
78,
15116,
26,
469,
17,
5469,
908,
8,
1532,
855,
1301,
3108,
8962,
1656,
1987,
904,
8,
955,
430,
267,
372,
1050,
63,
3288,
63,
504,
8,
1532,
12,
370,
29,
5029,
9,
272,
372,
7531,
421,
199,
318,
1455,
63,
2030,
8,
698,
304,
339,
347,
7531,
8,
1532,
304,
398,
347,
4975,
2031,
589,
12,
1011,
829,
304,
288,
340,
1263,
779,
70,
440,
315,
4775,
367,
289,
315,
334,
698,
12,
283,
1317,
63,
466,
358,
4682,
355
] |
[
1898,
334,
67,
9,
6029,
13,
7280,
6061,
89,
20232,
1997,
1455,
921,
1544,
14,
2297,
5505,
266,
75,
14,
957,
15,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
646,
2748,
14,
14338,
199,
646,
8337,
199,
646,
1059,
199,
646,
5055,
199,
504,
6055,
14,
2105,
492,
10168,
3227,
3225,
199,
504,
6055,
14,
1971,
492,
24411,
17692,
199,
646,
6055,
14,
77,
3569,
14,
1971,
199,
646,
6055,
14,
77,
3569,
14,
1310,
199,
504,
6055,
14,
2232,
492,
24881,
2461,
199,
504,
6055,
14,
5819,
492,
2457,
12,
2341,
12,
3816,
12,
3752,
2394,
199,
199,
363,
452,
363,
275,
788,
45,
5035,
3225,
418,
199,
199,
1246,
63,
1023,
63,
515,
275,
469,
272,
283,
3456,
5923,
356,
3777,
661,
8664,
13,
614,
13,
614,
297,
283,
16797,
26938,
297,
1994,
659,
272,
283,
497,
5203,
356,
3698,
661,
8664,
13,
614,
13,
614,
297,
283,
16797,
26938,
297,
1994,
659,
272,
283,
4738,
83,
356,
3322,
661,
6965,
13,
1643,
13,
614,
297,
283,
20920,
1435,
1304,
297,
1994,
4738,
83,
15,
6965,
13,
1643,
13,
614,
659,
272,
283,
29631,
356,
3515,
661,
8128,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
1994,
29631,
15,
8128,
13,
709,
13,
614,
659,
272,
283,
20920,
29099,
356,
3698,
661,
8128,
13,
1780,
13,
614,
297,
283,
20920,
1435,
1304,
297,
1994,
20920,
29099,
15,
8128,
13,
1780,
13,
614,
659,
272,
283,
607,
3556,
356,
3698,
661,
6542,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19590,
22503,
434,
607,
3556,
2662,
18968,
15,
6542,
13,
709,
13,
614,
659,
272,
283,
2204,
3556,
356,
3515,
661,
6542,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19590,
22503,
434,
2204,
3556,
2662,
18968,
15,
6542,
13,
709,
13,
614,
659,
272,
283,
19304,
356,
260,
661,
6542,
13,
709,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19590,
22503,
434,
19304,
15,
6542,
13,
709,
13,
614,
659,
272,
283,
497,
14447,
1298,
356,
257,
661,
6965,
13,
966,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
497,
14447,
1298,
15,
6965,
13,
966,
13,
614,
659,
272,
283,
17025,
2354,
356,
420,
661,
7280,
13,
1644,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
17025,
4935,
15,
7280,
13,
1644,
13,
614,
659,
272,
283,
31667,
2354,
356,
3515,
661,
7280,
13,
1644,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
31667,
4935,
15,
7280,
13,
1644,
13,
614,
659,
272,
283,
19120,
83,
356,
258,
661,
6965,
13,
1780,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
19120,
83,
15,
6965,
13,
1780,
13,
614,
659,
272,
283,
5195,
33,
8872,
10517,
1470,
356,
661,
6965,
13,
614,
13,
614,
297,
283,
20920,
1435,
1304,
297,
2079,
1994,
5195,
33,
8872,
10517,
1470,
15,
6965,
13,
614,
13,
614,
659,
199,
93,
199,
1317,
63,
1064,
21,
275,
2400,
286,
26,
3752,
2394,
8,
24722,
14,
1064,
21,
8,
67,
680,
5671,
8801,
1913,
342,
199,
29299,
63,
3288,
275,
661,
1287,
297,
283,
1310,
297,
283,
2792,
297,
673,
283,
8848,
297,
283,
8011,
297,
283,
1023,
358,
199,
1246,
63,
1250,
63,
1130,
275,
1052,
421,
199,
318,
1050,
63,
3288,
63,
504,
8,
1532,
12,
370,
304,
272,
367,
1921,
315,
16225,
63,
3288,
26,
267,
5371,
8,
475,
12,
1921,
12,
2519,
8,
1532,
12,
1921,
12,
488,
430,
272,
370,
855,
9130,
363,
275,
2562,
272,
372,
370,
421,
199,
318,
21781,
63,
6717,
2031,
955,
304,
339,
347,
7531,
8,
1532,
304,
398,
347,
4975,
8,
277,
12,
627,
589,
12,
1011,
829,
304,
288,
367,
790,
12,
6907,
315,
359,
70,
14,
1294,
7563,
367,
289,
315,
1504,
2189,
355,
340,
790,
315,
4775,
26,
490,
892,
498,
275,
790,
435,
7815,
435,
6907,
435,
334,
5470,
436,
7815,
503,
4074,
490,
367,
284,
315,
1425,
8,
552,
8,
829,
59,
498,
18710,
717,
4775,
59,
1222,
498,
435,
620,
8,
73,
435,
413,
1874,
275,
4775,
59,
498,
1527,
73,
61,
490,
4775,
14,
1935,
8,
498,
9,
288,
372,
2562,
8,
277,
12,
627,
589,
12,
1011,
829,
9,
267,
4975,
855,
1301,
363,
275,
5310,
16,
4988,
78,
15116,
26,
469,
17,
5469,
908,
8,
1532,
855,
1301,
3108,
8962,
1656,
1987,
904,
8,
955,
430,
267,
372,
1050,
63,
3288,
63,
504,
8,
1532,
12,
370,
29,
5029,
9,
272,
372,
7531,
421,
199,
318,
1455,
63,
2030,
8,
698,
304,
339,
347,
7531,
8,
1532,
304,
398,
347,
4975,
2031,
589,
12,
1011,
829,
304,
288,
340,
1263,
779,
70,
440,
315,
4775,
367,
289,
315,
334,
698,
12,
283,
1317,
63,
466,
358,
4682,
355,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
gabrielfalcao/lettuce
|
tests/integration/lib/Django-1.3/django/contrib/admin/sites.py
|
70
|
17393
|
import re
from django import http, template
from django.contrib.admin import ModelAdmin, actions
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.contenttypes import views as contenttype_views
from django.views.decorators.csrf import csrf_protect
from django.db.models.base import ModelBase
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
from django.utils.functional import update_wrapper
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
from django.views.decorators.cache import never_cache
from django.conf import settings
LOGIN_FORM_KEY = 'this_is_the_login_form'
class AlreadyRegistered(Exception):
pass
class NotRegistered(Exception):
pass
class AdminSite(object):
"""
An AdminSite object encapsulates an instance of the Django admin application, ready
to be hooked in to your URLconf. Models are registered with the AdminSite using the
register() method, and the get_urls() method can then be used to access Django view
functions that present a full admin interface for the collection of registered
models.
"""
login_form = None
index_template = None
app_index_template = None
login_template = None
logout_template = None
password_change_template = None
password_change_done_template = None
def __init__(self, name=None, app_name='admin'):
self._registry = {} # model_class class -> admin_class instance
self.root_path = None
if name is None:
self.name = 'admin'
else:
self.name = name
self.app_name = app_name
self._actions = {'delete_selected': actions.delete_selected}
self._global_actions = self._actions.copy()
def register(self, model_or_iterable, admin_class=None, **options):
"""
Registers the given model(s) with the given admin class.
The model(s) should be Model classes, not instances.
If an admin class isn't given, it will use ModelAdmin (the default
admin options). If keyword arguments are given -- e.g., list_display --
they'll be applied as options to the admin class.
If a model is already registered, this will raise AlreadyRegistered.
If a model is abstract, this will raise ImproperlyConfigured.
"""
if not admin_class:
admin_class = ModelAdmin
# Don't import the humongous validation code unless required
if admin_class and settings.DEBUG:
from django.contrib.admin.validation import validate
else:
validate = lambda model, adminclass: None
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model._meta.abstract:
raise ImproperlyConfigured('The model %s is abstract, so it '
'cannot be registered with admin.' % model.__name__)
if model in self._registry:
raise AlreadyRegistered('The model %s is already registered' % model.__name__)
# If we got **options then dynamically construct a subclass of
# admin_class with those **options.
if options:
# For reasons I don't quite understand, without a __module__
# the created class appears to "live" in the wrong place,
# which causes issues later on.
options['__module__'] = __name__
admin_class = type("%sAdmin" % model.__name__, (admin_class,), options)
# Validate (which might be a no-op)
validate(admin_class, model)
# Instantiate the admin class to save in the registry
self._registry[model] = admin_class(model, self)
def unregister(self, model_or_iterable):
"""
Unregisters the given model(s).
If a model isn't already registered, this will raise NotRegistered.
"""
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model not in self._registry:
raise NotRegistered('The model %s is not registered' % model.__name__)
del self._registry[model]
def add_action(self, action, name=None):
"""
Register an action to be available globally.
"""
name = name or action.__name__
self._actions[name] = action
self._global_actions[name] = action
def disable_action(self, name):
"""
Disable a globally-registered action. Raises KeyError for invalid names.
"""
del self._actions[name]
def get_action(self, name):
"""
Explicitally get a registered global action wheather it's enabled or
not. Raises KeyError for invalid names.
"""
return self._global_actions[name]
@property
def actions(self):
"""
Get all the enabled actions as an iterable of (name, func).
"""
return self._actions.iteritems()
def has_permission(self, request):
"""
Returns True if the given HttpRequest has permission to view
*at least one* page in the admin site.
"""
return request.user.is_active and request.user.is_staff
def check_dependencies(self):
"""
Check that all things needed to run the admin have been correctly installed.
The default implementation checks that LogEntry, ContentType and the
auth context processor are installed.
"""
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
if not LogEntry._meta.installed:
raise ImproperlyConfigured("Put 'django.contrib.admin' in your "
"INSTALLED_APPS setting in order to use the admin application.")
if not ContentType._meta.installed:
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
"your INSTALLED_APPS setting in order to use the admin application.")
if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or
'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS):
raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' "
"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
def admin_view(self, view, cacheable=False):
"""
Decorator to create an admin view attached to this ``AdminSite``. This
wraps the view and provides permission checking by calling
``self.has_permission``.
You'll want to use this from within ``AdminSite.get_urls()``:
class MyAdminSite(AdminSite):
def get_urls(self):
from django.conf.urls.defaults import patterns, url
urls = super(MyAdminSite, self).get_urls()
urls += patterns('',
url(r'^my_view/$', self.admin_view(some_view))
)
return urls
By default, admin_views are marked non-cacheable using the
``never_cache`` decorator. If the view can be safely cached, set
cacheable=True.
"""
def inner(request, *args, **kwargs):
if not self.has_permission(request):
return self.login(request)
return view(request, *args, **kwargs)
if not cacheable:
inner = never_cache(inner)
# We add csrf_protect here so this function can be used as a utility
# function for any view, without having to repeat 'csrf_protect'.
if not getattr(view, 'csrf_exempt', False):
inner = csrf_protect(inner)
return update_wrapper(inner, view)
def get_urls(self):
from django.conf.urls.defaults import patterns, url, include
if settings.DEBUG:
self.check_dependencies()
def wrap(view, cacheable=False):
def wrapper(*args, **kwargs):
return self.admin_view(view, cacheable)(*args, **kwargs)
return update_wrapper(wrapper, view)
# Admin-site-wide views.
urlpatterns = patterns('',
url(r'^$',
wrap(self.index),
name='index'),
url(r'^logout/$',
wrap(self.logout),
name='logout'),
url(r'^password_change/$',
wrap(self.password_change, cacheable=True),
name='password_change'),
url(r'^password_change/done/$',
wrap(self.password_change_done, cacheable=True),
name='password_change_done'),
url(r'^jsi18n/$',
wrap(self.i18n_javascript, cacheable=True),
name='jsi18n'),
url(r'^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$',
wrap(contenttype_views.shortcut)),
url(r'^(?P<app_label>\w+)/$',
wrap(self.app_index),
name='app_list')
)
# Add in each model's views.
for model, model_admin in self._registry.iteritems():
urlpatterns += patterns('',
url(r'^%s/%s/' % (model._meta.app_label, model._meta.module_name),
include(model_admin.urls))
)
return urlpatterns
@property
def urls(self):
return self.get_urls(), self.app_name, self.name
def password_change(self, request):
"""
Handles the "change password" task -- both form display and validation.
"""
from django.contrib.auth.views import password_change
if self.root_path is not None:
url = '%spassword_change/done/' % self.root_path
else:
url = reverse('admin:password_change_done', current_app=self.name)
defaults = {
'current_app': self.name,
'post_change_redirect': url
}
if self.password_change_template is not None:
defaults['template_name'] = self.password_change_template
return password_change(request, **defaults)
def password_change_done(self, request, extra_context=None):
"""
Displays the "success" page after a password change.
"""
from django.contrib.auth.views import password_change_done
defaults = {
'current_app': self.name,
'extra_context': extra_context or {},
}
if self.password_change_done_template is not None:
defaults['template_name'] = self.password_change_done_template
return password_change_done(request, **defaults)
def i18n_javascript(self, request):
"""
Displays the i18n JavaScript that the Django admin requires.
This takes into account the USE_I18N setting. If it's set to False, the
generated JavaScript will be leaner and faster.
"""
if settings.USE_I18N:
from django.views.i18n import javascript_catalog
else:
from django.views.i18n import null_javascript_catalog as javascript_catalog
return javascript_catalog(request, packages=['django.conf', 'django.contrib.admin'])
@never_cache
def logout(self, request, extra_context=None):
"""
Logs out the user for the given HttpRequest.
This should *not* assume the user is already logged in.
"""
from django.contrib.auth.views import logout
defaults = {
'current_app': self.name,
'extra_context': extra_context or {},
}
if self.logout_template is not None:
defaults['template_name'] = self.logout_template
return logout(request, **defaults)
@never_cache
def login(self, request, extra_context=None):
"""
Displays the login form for the given HttpRequest.
"""
from django.contrib.auth.views import login
context = {
'title': _('Log in'),
'root_path': self.root_path,
'app_path': request.get_full_path(),
REDIRECT_FIELD_NAME: request.get_full_path(),
}
context.update(extra_context or {})
defaults = {
'extra_context': context,
'current_app': self.name,
'authentication_form': self.login_form or AdminAuthenticationForm,
'template_name': self.login_template or 'admin/login.html',
}
return login(request, **defaults)
@never_cache
def index(self, request, extra_context=None):
"""
Displays the main admin index page, which lists all of the installed
apps that have been registered in this site.
"""
app_dict = {}
user = request.user
for model, model_admin in self._registry.items():
app_label = model._meta.app_label
has_module_perms = user.has_module_perms(app_label)
if has_module_perms:
perms = model_admin.get_model_perms(request)
# Check whether user has any perm for this module.
# If so, add the module to the model_list.
if True in perms.values():
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'admin_url': mark_safe('%s/%s/' % (app_label, model.__name__.lower())),
'perms': perms,
}
if app_label in app_dict:
app_dict[app_label]['models'].append(model_dict)
else:
app_dict[app_label] = {
'name': app_label.title(),
'app_url': app_label + '/',
'has_module_perms': has_module_perms,
'models': [model_dict],
}
# Sort the apps alphabetically.
app_list = app_dict.values()
app_list.sort(key=lambda x: x['name'])
# Sort the models alphabetically within each app.
for app in app_list:
app['models'].sort(key=lambda x: x['name'])
context = {
'title': _('Site administration'),
'app_list': app_list,
'root_path': self.root_path,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.name)
return render_to_response(self.index_template or 'admin/index.html', context,
context_instance=context_instance
)
def app_index(self, request, app_label, extra_context=None):
user = request.user
has_module_perms = user.has_module_perms(app_label)
app_dict = {}
for model, model_admin in self._registry.items():
if app_label == model._meta.app_label:
if has_module_perms:
perms = model_admin.get_model_perms(request)
# Check whether user has any perm for this module.
# If so, add the module to the model_list.
if True in perms.values():
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'admin_url': '%s/' % model.__name__.lower(),
'perms': perms,
}
if app_dict:
app_dict['models'].append(model_dict),
else:
# First time around, now that we know there's
# something to display, add in the necessary meta
# information.
app_dict = {
'name': app_label.title(),
'app_url': '',
'has_module_perms': has_module_perms,
'models': [model_dict],
}
if not app_dict:
raise http.Http404('The requested admin page does not exist.')
# Sort the models alphabetically within each app.
app_dict['models'].sort(key=lambda x: x['name'])
context = {
'title': _('%s administration') % capfirst(app_label),
'app_list': [app_dict],
'root_path': self.root_path,
}
context.update(extra_context or {})
context_instance = template.RequestContext(request, current_app=self.name)
return render_to_response(self.app_index_template or ('admin/%s/app_index.html' % app_label,
'admin/app_index.html'), context,
context_instance=context_instance
)
# This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site.
site = AdminSite()
|
gpl-3.0
|
[
646,
295,
199,
504,
1639,
492,
1455,
12,
1978,
199,
504,
1639,
14,
2828,
14,
2113,
492,
30093,
12,
5445,
199,
504,
1639,
14,
2828,
14,
2113,
14,
3351,
492,
9516,
10348,
2821,
199,
504,
1639,
14,
2828,
14,
1178,
492,
820,
7458,
4168,
63,
8609,
63,
2339,
199,
504,
1639,
14,
2828,
14,
10778,
492,
6858,
465,
1564,
466,
63,
4196,
199,
504,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
18292,
199,
504,
1639,
14,
697,
14,
992,
14,
1095,
492,
5822,
1563,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
17469,
492,
3795,
63,
475,
63,
1310,
199,
504,
1639,
14,
1208,
14,
15481,
492,
1678,
63,
5029,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
504,
1639,
14,
1208,
14,
505,
492,
4021,
2246,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
4196,
14,
11582,
14,
1637,
492,
7078,
63,
1637,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
17208,
63,
3516,
63,
3078,
275,
283,
3749,
63,
374,
63,
1589,
63,
2886,
63,
964,
7,
199,
199,
533,
21086,
20341,
8,
1726,
304,
272,
986,
199,
199,
533,
2832,
20341,
8,
1726,
304,
272,
986,
199,
199,
533,
9516,
8972,
8,
785,
304,
272,
408,
272,
1626,
9516,
8972,
909,
22667,
15409,
376,
1256,
402,
314,
5634,
4628,
4223,
12,
10144,
272,
370,
506,
5759,
379,
315,
370,
2195,
2851,
2190,
14,
29941,
787,
7264,
543,
314,
9516,
8972,
1808,
314,
272,
2274,
342,
1083,
12,
436,
314,
664,
63,
3603,
342,
1083,
883,
2066,
506,
1202,
370,
2879,
5634,
2455,
272,
3423,
626,
3451,
282,
2615,
4628,
3217,
367,
314,
3245,
402,
7264,
272,
1709,
14,
272,
408,
272,
4676,
63,
964,
275,
488,
272,
1478,
63,
1160,
275,
488,
272,
1145,
63,
1080,
63,
1160,
275,
488,
272,
4676,
63,
1160,
275,
488,
272,
22079,
63,
1160,
275,
488,
272,
2505,
63,
1461,
63,
1160,
275,
488,
272,
2505,
63,
1461,
63,
4456,
63,
1160,
275,
488,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
1145,
63,
354,
534,
2113,
735,
267,
291,
423,
5189,
275,
1052,
327,
1402,
63,
533,
1021,
1035,
4628,
63,
533,
1256,
267,
291,
14,
1231,
63,
515,
275,
488,
267,
340,
536,
365,
488,
26,
288,
291,
14,
354,
275,
283,
2113,
7,
267,
587,
26,
288,
291,
14,
354,
275,
536,
267,
291,
14,
571,
63,
354,
275,
1145,
63,
354,
267,
291,
423,
3723,
275,
791,
1807,
63,
5511,
356,
5445,
14,
1807,
63,
5511,
93,
267,
291,
423,
2966,
63,
3723,
275,
291,
423,
3723,
14,
1574,
342,
339,
347,
2274,
8,
277,
12,
1402,
63,
269,
63,
8147,
12,
4628,
63,
533,
29,
403,
12,
1011,
1419,
304,
267,
408,
267,
5044,
14186,
314,
1627,
1402,
8,
83,
9,
543,
314,
1627,
4628,
1021,
14,
398,
710,
1402,
8,
83,
9,
1077,
506,
5822,
3992,
12,
440,
4454,
14,
398,
982,
376,
4628,
1021,
5712,
1133,
1627,
12,
652,
911,
675,
30093,
334,
1589,
849,
267,
4628,
1511,
680,
982,
4252,
2368,
787,
1627,
1553,
325,
14,
71,
2020,
769,
63,
2918,
1553,
267,
2985,
7171,
506,
6781,
465,
1511,
370,
314,
4628,
1021,
14,
398,
982,
282,
1402,
365,
2575,
7264,
12,
642,
911,
746,
21086,
20341,
14,
398,
982,
282,
1402,
365,
9006,
12,
642,
911,
746,
11897,
14,
267,
408,
267,
340,
440,
4628,
63,
533,
26,
288,
4628,
63,
533,
275,
30093,
398,
327,
7529,
1133,
492,
314,
394,
453,
951,
1785,
6411,
1233,
7444,
1415,
267,
340,
4628,
63,
533,
436,
2202,
14,
5287,
26,
288,
687,
1639,
14,
2828,
14,
2113,
14,
6136,
492,
4107,
267,
587,
26,
288,
4107,
275,
2400,
1402,
12,
4628,
533,
26,
488,
398,
340,
1228,
8,
1238,
63,
269,
63,
8147,
12,
5822,
1563,
304,
288,
1402,
63,
269,
63,
8147,
275,
359,
1238,
63,
269,
63,
8147,
61,
267,
367,
1402,
315,
1402,
63,
269,
63,
8147,
26,
288,
340,
1402,
423,
2024,
14,
6198,
26,
355,
746,
11897,
360,
1918,
1402,
450,
83,
365,
9006,
12,
880,
652,
283,
1993,
283,
11250,
506,
7264,
543,
4628,
3530,
450,
1402,
855,
354,
3368,
953,
340,
1402,
315,
291,
423,
5189,
26,
355,
746,
21086,
20341,
360,
1918,
1402,
450,
83,
365,
2575,
7264,
7,
450,
1402,
855,
354,
3368,
953,
327,
982,
781,
4788,
1011,
1419,
2066,
18774,
6982,
282,
5516,
402,
288,
327,
4628,
63,
533,
543,
5204,
1011,
1419,
14,
288,
340,
1511,
26,
355,
327,
2104,
14872,
473,
2793,
1133,
18794,
20647,
12,
1928,
282,
636,
578,
363,
355,
327,
314,
2737,
1021,
11337,
370,
298,
6442,
2,
315,
314,
6835,
4192,
12,
355,
327,
1314,
14486,
10876,
2945,
641,
14,
355,
1511,
13742,
578,
17501,
275,
636,
354,
363,
355,
4628,
63,
533,
275,
730,
3647,
83,
4880,
2,
450,
1402,
855,
354,
3108,
334,
2113,
63,
533,
4706,
1511,
9,
953,
327,
12134,
334,
6777,
5594,
506,
282,
949,
13,
411,
9,
288,
4107,
8,
2113,
63,
533,
12,
1402,
9,
953,
327,
32092,
314,
4628,
1021,
370,
3354,
315,
314,
7086,
288,
291,
423,
5189,
59,
1238,
61,
275,
4628,
63,
533,
8,
1238,
12,
291,
9,
339,
347,
24369,
8,
277,
12,
1402,
63,
269,
63,
8147,
304,
267,
408,
267,
1910,
30792,
314,
1627,
1402,
8,
83,
680,
398,
982,
282,
1402,
5712,
1133,
2575,
7264,
12,
642,
911,
746,
2832,
20341,
14,
267,
408,
267,
340,
1228,
8,
1238,
63,
269,
63,
8147,
12,
5822,
1563,
304,
288,
1402,
63,
269,
63,
8147,
275,
359,
1238,
63,
269,
63,
8147,
61,
267,
367,
1402,
315,
1402,
63,
269,
63,
8147,
26,
288,
340,
1402,
440,
315,
291,
423,
5189,
26,
355,
746,
2832,
20341,
360,
1918,
1402,
450,
83,
365,
440,
7264,
7,
450,
1402,
855,
354,
3368,
288,
2150,
291,
423,
5189,
59,
1238,
61,
339,
347,
1050,
63,
1287,
8,
277,
12,
1595,
12,
536,
29,
403,
304,
267,
408,
267,
11828,
376,
1595,
370,
506,
2808,
26662,
14,
267,
408,
267
] |
[
295,
199,
504,
1639,
492,
1455,
12,
1978,
199,
504,
1639,
14,
2828,
14,
2113,
492,
30093,
12,
5445,
199,
504,
1639,
14,
2828,
14,
2113,
14,
3351,
492,
9516,
10348,
2821,
199,
504,
1639,
14,
2828,
14,
1178,
492,
820,
7458,
4168,
63,
8609,
63,
2339,
199,
504,
1639,
14,
2828,
14,
10778,
492,
6858,
465,
1564,
466,
63,
4196,
199,
504,
1639,
14,
4196,
14,
11582,
14,
10088,
492,
19213,
63,
18292,
199,
504,
1639,
14,
697,
14,
992,
14,
1095,
492,
5822,
1563,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
17469,
492,
3795,
63,
475,
63,
1310,
199,
504,
1639,
14,
1208,
14,
15481,
492,
1678,
63,
5029,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
504,
1639,
14,
1208,
14,
505,
492,
4021,
2246,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
4196,
14,
11582,
14,
1637,
492,
7078,
63,
1637,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
17208,
63,
3516,
63,
3078,
275,
283,
3749,
63,
374,
63,
1589,
63,
2886,
63,
964,
7,
199,
199,
533,
21086,
20341,
8,
1726,
304,
272,
986,
199,
199,
533,
2832,
20341,
8,
1726,
304,
272,
986,
199,
199,
533,
9516,
8972,
8,
785,
304,
272,
408,
272,
1626,
9516,
8972,
909,
22667,
15409,
376,
1256,
402,
314,
5634,
4628,
4223,
12,
10144,
272,
370,
506,
5759,
379,
315,
370,
2195,
2851,
2190,
14,
29941,
787,
7264,
543,
314,
9516,
8972,
1808,
314,
272,
2274,
342,
1083,
12,
436,
314,
664,
63,
3603,
342,
1083,
883,
2066,
506,
1202,
370,
2879,
5634,
2455,
272,
3423,
626,
3451,
282,
2615,
4628,
3217,
367,
314,
3245,
402,
7264,
272,
1709,
14,
272,
408,
272,
4676,
63,
964,
275,
488,
272,
1478,
63,
1160,
275,
488,
272,
1145,
63,
1080,
63,
1160,
275,
488,
272,
4676,
63,
1160,
275,
488,
272,
22079,
63,
1160,
275,
488,
272,
2505,
63,
1461,
63,
1160,
275,
488,
272,
2505,
63,
1461,
63,
4456,
63,
1160,
275,
488,
339,
347,
636,
826,
721,
277,
12,
536,
29,
403,
12,
1145,
63,
354,
534,
2113,
735,
267,
291,
423,
5189,
275,
1052,
327,
1402,
63,
533,
1021,
1035,
4628,
63,
533,
1256,
267,
291,
14,
1231,
63,
515,
275,
488,
267,
340,
536,
365,
488,
26,
288,
291,
14,
354,
275,
283,
2113,
7,
267,
587,
26,
288,
291,
14,
354,
275,
536,
267,
291,
14,
571,
63,
354,
275,
1145,
63,
354,
267,
291,
423,
3723,
275,
791,
1807,
63,
5511,
356,
5445,
14,
1807,
63,
5511,
93,
267,
291,
423,
2966,
63,
3723,
275,
291,
423,
3723,
14,
1574,
342,
339,
347,
2274,
8,
277,
12,
1402,
63,
269,
63,
8147,
12,
4628,
63,
533,
29,
403,
12,
1011,
1419,
304,
267,
408,
267,
5044,
14186,
314,
1627,
1402,
8,
83,
9,
543,
314,
1627,
4628,
1021,
14,
398,
710,
1402,
8,
83,
9,
1077,
506,
5822,
3992,
12,
440,
4454,
14,
398,
982,
376,
4628,
1021,
5712,
1133,
1627,
12,
652,
911,
675,
30093,
334,
1589,
849,
267,
4628,
1511,
680,
982,
4252,
2368,
787,
1627,
1553,
325,
14,
71,
2020,
769,
63,
2918,
1553,
267,
2985,
7171,
506,
6781,
465,
1511,
370,
314,
4628,
1021,
14,
398,
982,
282,
1402,
365,
2575,
7264,
12,
642,
911,
746,
21086,
20341,
14,
398,
982,
282,
1402,
365,
9006,
12,
642,
911,
746,
11897,
14,
267,
408,
267,
340,
440,
4628,
63,
533,
26,
288,
4628,
63,
533,
275,
30093,
398,
327,
7529,
1133,
492,
314,
394,
453,
951,
1785,
6411,
1233,
7444,
1415,
267,
340,
4628,
63,
533,
436,
2202,
14,
5287,
26,
288,
687,
1639,
14,
2828,
14,
2113,
14,
6136,
492,
4107,
267,
587,
26,
288,
4107,
275,
2400,
1402,
12,
4628,
533,
26,
488,
398,
340,
1228,
8,
1238,
63,
269,
63,
8147,
12,
5822,
1563,
304,
288,
1402,
63,
269,
63,
8147,
275,
359,
1238,
63,
269,
63,
8147,
61,
267,
367,
1402,
315,
1402,
63,
269,
63,
8147,
26,
288,
340,
1402,
423,
2024,
14,
6198,
26,
355,
746,
11897,
360,
1918,
1402,
450,
83,
365,
9006,
12,
880,
652,
283,
1993,
283,
11250,
506,
7264,
543,
4628,
3530,
450,
1402,
855,
354,
3368,
953,
340,
1402,
315,
291,
423,
5189,
26,
355,
746,
21086,
20341,
360,
1918,
1402,
450,
83,
365,
2575,
7264,
7,
450,
1402,
855,
354,
3368,
953,
327,
982,
781,
4788,
1011,
1419,
2066,
18774,
6982,
282,
5516,
402,
288,
327,
4628,
63,
533,
543,
5204,
1011,
1419,
14,
288,
340,
1511,
26,
355,
327,
2104,
14872,
473,
2793,
1133,
18794,
20647,
12,
1928,
282,
636,
578,
363,
355,
327,
314,
2737,
1021,
11337,
370,
298,
6442,
2,
315,
314,
6835,
4192,
12,
355,
327,
1314,
14486,
10876,
2945,
641,
14,
355,
1511,
13742,
578,
17501,
275,
636,
354,
363,
355,
4628,
63,
533,
275,
730,
3647,
83,
4880,
2,
450,
1402,
855,
354,
3108,
334,
2113,
63,
533,
4706,
1511,
9,
953,
327,
12134,
334,
6777,
5594,
506,
282,
949,
13,
411,
9,
288,
4107,
8,
2113,
63,
533,
12,
1402,
9,
953,
327,
32092,
314,
4628,
1021,
370,
3354,
315,
314,
7086,
288,
291,
423,
5189,
59,
1238,
61,
275,
4628,
63,
533,
8,
1238,
12,
291,
9,
339,
347,
24369,
8,
277,
12,
1402,
63,
269,
63,
8147,
304,
267,
408,
267,
1910,
30792,
314,
1627,
1402,
8,
83,
680,
398,
982,
282,
1402,
5712,
1133,
2575,
7264,
12,
642,
911,
746,
2832,
20341,
14,
267,
408,
267,
340,
1228,
8,
1238,
63,
269,
63,
8147,
12,
5822,
1563,
304,
288,
1402,
63,
269,
63,
8147,
275,
359,
1238,
63,
269,
63,
8147,
61,
267,
367,
1402,
315,
1402,
63,
269,
63,
8147,
26,
288,
340,
1402,
440,
315,
291,
423,
5189,
26,
355,
746,
2832,
20341,
360,
1918,
1402,
450,
83,
365,
440,
7264,
7,
450,
1402,
855,
354,
3368,
288,
2150,
291,
423,
5189,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
17zuoye/luigi
|
luigi/contrib/hdfs/snakebite_client.py
|
1
|
10933
|
# -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
A luigi file system client that wraps around snakebite
Originally written by Alan Brenner <alan@magnetic.com> github.com/alanbbr
"""
from luigi.contrib.hdfs import config as hdfs_config
from luigi.contrib.hdfs import error as hdfs_error
from luigi.contrib.hdfs import hadoopcli_clients as hdfs_hadoopcli_clients
from luigi import six
import luigi.contrib.target
import logging
import datetime
import os
logger = logging.getLogger('luigi-interface')
class SnakebiteHdfsClient(hdfs_hadoopcli_clients.HdfsClient):
"""
A hdfs client using snakebite. Since Snakebite has a python API, it'll be
about 100 times faster than the hadoop cli client, which does shell out to
a java program on each file system operation.
"""
def __init__(self):
super(SnakebiteHdfsClient, self).__init__()
self._bite = None
self.pid = -1
@staticmethod
def list_path(path):
if isinstance(path, list) or isinstance(path, tuple):
return path
if isinstance(path, str) or isinstance(path, unicode):
return [path, ]
return [str(path), ]
def get_bite(self):
"""
If Luigi has forked, we have a different PID, and need to reconnect.
"""
config = hdfs_config.hdfs()
if self.pid != os.getpid() or not self._bite:
client_kwargs = dict(filter(
lambda k_v: k_v[1] is not None and k_v[1] != '', six.iteritems({
'hadoop_version': config.client_version,
'effective_user': config.effective_user,
})
))
if config.snakebite_autoconfig:
"""
This is fully backwards compatible with the vanilla Client and can be used for a non HA cluster as well.
This client tries to read ``${HADOOP_PATH}/conf/hdfs-site.xml`` to get the address of the namenode.
The behaviour is the same as Client.
"""
from snakebite.client import AutoConfigClient
self._bite = AutoConfigClient(**client_kwargs)
else:
from snakebite.client import Client
self._bite = Client(config.namenode_host, config.namenode_port, **client_kwargs)
return self._bite
def exists(self, path):
"""
Use snakebite.test to check file existence.
:param path: path to test
:type path: string
:return: boolean, True if path exists in HDFS
"""
try:
return self.get_bite().test(path, exists=True)
except Exception as err: # IGNORE:broad-except
raise hdfs_error.HDFSCliError("snakebite.test", -1, str(err), repr(err))
def rename(self, path, dest):
"""
Use snakebite.rename, if available.
:param path: source file(s)
:type path: either a string or sequence of strings
:param dest: destination file (single input) or directory (multiple)
:type dest: string
:return: list of renamed items
"""
parts = dest.rstrip('/').split('/')
if len(parts) > 1:
dir_path = '/'.join(parts[0:-1])
if not self.exists(dir_path):
self.mkdir(dir_path, parents=True)
return list(self.get_bite().rename(self.list_path(path), dest))
def rename_dont_move(self, path, dest):
"""
Use snakebite.rename_dont_move, if available.
:param path: source path (single input)
:type path: string
:param dest: destination path
:type dest: string
:return: True if succeeded
:raises: snakebite.errors.FileAlreadyExistsException
"""
from snakebite.errors import FileAlreadyExistsException
try:
self.get_bite().rename2(path, dest, overwriteDest=False)
return True
except FileAlreadyExistsException:
return False
def remove(self, path, recursive=True, skip_trash=False):
"""
Use snakebite.delete, if available.
:param path: delete-able file(s) or directory(ies)
:type path: either a string or a sequence of strings
:param recursive: delete directories trees like \*nix: rm -r
:type recursive: boolean, default is True
:param skip_trash: do or don't move deleted items into the trash first
:type skip_trash: boolean, default is False (use trash)
:return: list of deleted items
"""
return list(self.get_bite().delete(self.list_path(path), recurse=recursive))
def chmod(self, path, permissions, recursive=False):
"""
Use snakebite.chmod, if available.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param permissions: \*nix style permission number
:type permissions: octal
:param recursive: change just listed entry(ies) or all in directories
:type recursive: boolean, default is False
:return: list of all changed items
"""
if type(permissions) == str:
permissions = int(permissions, 8)
return list(self.get_bite().chmod(self.list_path(path),
permissions, recursive))
def chown(self, path, owner, group, recursive=False):
"""
Use snakebite.chown/chgrp, if available.
One of owner or group must be set. Just setting group calls chgrp.
:param path: update-able file(s)
:type path: either a string or sequence of strings
:param owner: new owner, can be blank
:type owner: string
:param group: new group, can be blank
:type group: string
:param recursive: change just listed entry(ies) or all in directories
:type recursive: boolean, default is False
:return: list of all changed items
"""
bite = self.get_bite()
if owner:
if group:
return all(bite.chown(self.list_path(path), "%s:%s" % (owner, group),
recurse=recursive))
return all(bite.chown(self.list_path(path), owner, recurse=recursive))
return list(bite.chgrp(self.list_path(path), group, recurse=recursive))
def count(self, path):
"""
Use snakebite.count, if available.
:param path: directory to count the contents of
:type path: string
:return: dictionary with content_size, dir_count and file_count keys
"""
try:
res = self.get_bite().count(self.list_path(path)).next()
dir_count = res['directoryCount']
file_count = res['fileCount']
content_size = res['spaceConsumed']
except StopIteration:
dir_count = file_count = content_size = 0
return {'content_size': content_size, 'dir_count': dir_count,
'file_count': file_count}
def get(self, path, local_destination):
"""
Use snakebite.copyToLocal, if available.
:param path: HDFS file
:type path: string
:param local_destination: path on the system running Luigi
:type local_destination: string
"""
return list(self.get_bite().copyToLocal(self.list_path(path),
local_destination))
def mkdir(self, path, parents=True, mode=0o755, raise_if_exists=False):
"""
Use snakebite.mkdir, if available.
Snakebite's mkdir method allows control over full path creation, so by
default, tell it to build a full path to work like ``hadoop fs -mkdir``.
:param path: HDFS path to create
:type path: string
:param parents: create any missing parent directories
:type parents: boolean, default is True
:param mode: \*nix style owner/group/other permissions
:type mode: octal, default 0755
"""
result = list(self.get_bite().mkdir(self.list_path(path),
create_parent=parents, mode=mode))
if raise_if_exists and "ile exists" in result[0].get('error', ''):
raise luigi.target.FileAlreadyExists("%s exists" % (path, ))
return result
def listdir(self, path, ignore_directories=False, ignore_files=False,
include_size=False, include_type=False, include_time=False,
recursive=False):
"""
Use snakebite.ls to get the list of items in a directory.
:param path: the directory to list
:type path: string
:param ignore_directories: if True, do not yield directory entries
:type ignore_directories: boolean, default is False
:param ignore_files: if True, do not yield file entries
:type ignore_files: boolean, default is False
:param include_size: include the size in bytes of the current item
:type include_size: boolean, default is False (do not include)
:param include_type: include the type (d or f) of the current item
:type include_type: boolean, default is False (do not include)
:param include_time: include the last modification time of the current item
:type include_time: boolean, default is False (do not include)
:param recursive: list subdirectory contents
:type recursive: boolean, default is False (do not recurse)
:return: yield with a string, or if any of the include_* settings are
true, a tuple starting with the path, and include_* items in order
"""
bite = self.get_bite()
for entry in bite.ls(self.list_path(path), recurse=recursive):
if ignore_directories and entry['file_type'] == 'd':
continue
if ignore_files and entry['file_type'] == 'f':
continue
rval = [entry['path'], ]
if include_size:
rval.append(entry['length'])
if include_type:
rval.append(entry['file_type'])
if include_time:
rval.append(datetime.datetime.fromtimestamp(entry['modification_time'] / 1000))
if len(rval) > 1:
yield tuple(rval)
else:
yield rval[0]
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6029,
13,
7806,
428,
555,
3338,
14840,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
199,
33,
19485,
570,
2656,
1890,
626,
14018,
6818,
6895,
1728,
66,
1175,
199,
199,
12834,
1183,
5313,
701,
437,
1502,
699,
828,
1372,
665,
279,
290,
32,
5615,
685,
764,
14,
957,
30,
12869,
14,
957,
15,
279,
290,
2501,
82,
199,
624,
421,
199,
504,
19485,
14,
2828,
14,
19055,
492,
1101,
465,
394,
10434,
63,
888,
199,
504,
19485,
14,
2828,
14,
19055,
492,
1125,
465,
394,
10434,
63,
705,
199,
504,
19485,
14,
2828,
14,
19055,
492,
29252,
2764,
63,
14555,
465,
394,
10434,
63,
15449,
2764,
63,
14555,
199,
504,
19485,
492,
3816,
199,
646,
19485,
14,
2828,
14,
1375,
199,
646,
2050,
199,
646,
2197,
199,
646,
747,
199,
199,
2921,
275,
2050,
14,
5572,
360,
26795,
13,
3266,
358,
421,
199,
533,
428,
78,
1728,
66,
1175,
40,
10434,
3041,
8,
19055,
63,
15449,
2764,
63,
14555,
14,
40,
10434,
3041,
304,
272,
408,
272,
437,
394,
10434,
1890,
1808,
6895,
1728,
66,
1175,
14,
9336,
428,
78,
1728,
66,
1175,
965,
282,
2366,
3261,
12,
652,
7171,
506,
272,
3595,
2948,
5431,
12930,
2419,
314,
29252,
5053,
1890,
12,
1314,
1630,
5218,
734,
370,
272,
282,
12120,
2240,
641,
1924,
570,
2656,
3439,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
20821,
1728,
66,
1175,
40,
10434,
3041,
12,
291,
2843,
826,
4533,
267,
291,
423,
66,
1175,
275,
488,
267,
291,
14,
3150,
275,
446,
17,
339,
768,
4639,
272,
347,
769,
63,
515,
8,
515,
304,
267,
340,
1228,
8,
515,
12,
769,
9,
503,
1228,
8,
515,
12,
2008,
304,
288,
372,
931,
267,
340,
1228,
8,
515,
12,
620,
9,
503,
1228,
8,
515,
12,
2649,
304,
288,
372,
359,
515,
12,
1622,
267,
372,
359,
495,
8,
515,
395,
1622,
339,
347,
664,
63,
66,
1175,
8,
277,
304,
267,
408,
267,
982,
30936,
13721,
965,
14926,
379,
12,
781,
1172,
282,
3365,
20674,
12,
436,
1929,
370,
30882,
14,
267,
408,
267,
1101,
275,
394,
10434,
63,
888,
14,
19055,
342,
267,
340,
291,
14,
3150,
1137,
747,
14,
17829,
342,
503,
440,
291,
423,
66,
1175,
26,
288,
1890,
63,
958,
275,
1211,
8,
1541,
8,
355,
2400,
1022,
63,
86,
26,
1022,
63,
86,
59,
17,
61,
365,
440,
488,
436,
1022,
63,
86,
59,
17,
61,
1137,
3260,
3816,
14,
4611,
2561,
490,
283,
15449,
63,
1023,
356,
1101,
14,
1258,
63,
1023,
12,
490,
283,
20427,
63,
751,
356,
1101,
14,
20427,
63,
751,
12,
355,
3828,
288,
5082,
288,
340,
1101,
14,
21415,
66,
1175,
63,
2495,
888,
26,
355,
408,
355,
961,
365,
9999,
8552,
9025,
543,
314,
20744,
6165,
6810,
436,
883,
506,
1202,
367,
282,
2222,
16100,
4350,
465,
5521,
14,
355,
961,
1890,
11275,
370,
1586,
1124,
10545,
40,
1554,
47,
1938,
63,
3243,
5995,
2190,
15,
19055,
13,
2124,
14,
1652,
1040,
370,
664,
314,
2287,
402,
314,
536,
932,
14,
355,
710,
13942,
365,
314,
2011,
465,
6810,
14,
355,
408,
355,
687,
6895,
1728,
66,
1175,
14,
1258,
492,
9195,
2028,
3041,
355,
291,
423,
66,
1175,
275,
9195,
2028,
3041,
3682,
1258,
63,
958,
9,
288,
587,
26,
355,
687,
6895,
1728,
66,
1175,
14,
1258,
492,
6810,
355,
291,
423,
66,
1175,
275,
6810,
8,
888,
14,
354,
932,
63,
1102,
12,
1101,
14,
354,
932,
63,
719,
12,
1011,
1258,
63,
958,
9,
267,
372,
291,
423,
66,
1175,
339,
347,
3495,
8,
277,
12,
931,
304,
267,
408,
267,
3645,
6895,
1728,
66,
1175,
14,
396,
370,
1104,
570,
23780,
14,
398,
520,
635,
931,
26,
931,
370,
511,
267,
520,
466,
931,
26,
1059,
267,
520,
1107,
26,
5046,
12,
715,
340,
931,
3495,
315,
24521,
51,
267,
408,
267,
862,
26,
288,
372,
291,
14,
362,
63,
66,
1175,
1252,
396,
8,
515,
12,
3495,
29,
549,
9,
267,
871,
2186,
465,
2329,
26,
259,
327,
27499,
5788,
26,
29047,
13,
2590,
288,
746,
394,
10434,
63,
705,
14,
30165,
5153,
317,
547,
480,
21415,
66,
1175,
14,
396,
401,
446,
17,
12,
620,
8,
1508,
395,
4700,
8,
1508,
430,
339,
347,
11441,
8,
277,
12,
931,
12,
2053,
304,
267,
408,
267,
3645,
6895,
1728,
66,
1175,
14,
8165,
12,
340,
2808,
14,
398,
520,
635,
931,
26,
1350,
570,
8,
83,
9,
267,
520,
466,
931,
26,
1902,
282,
1059,
503,
3414,
402,
3326,
267,
520,
635,
2053,
26,
5724,
570,
334,
4780,
1324,
9,
503,
2082,
334,
6048,
9,
267,
520,
466,
2053,
26,
1059,
267,
520,
1107,
26,
769,
402,
17864,
2974,
267,
408,
267,
4184,
275,
2053,
14,
6735,
2336,
1959,
1294,
7825,
267,
340,
822,
8,
4181,
9,
690,
413,
26,
288,
2935,
63,
515,
275,
20538,
904,
8,
4181,
59,
16,
6809,
17,
566,
288,
340,
440,
291,
14,
2444,
8,
694,
63,
515,
304,
355,
291,
14,
8215,
8,
694,
63,
515,
12,
8623,
29,
549,
9,
267,
372,
769,
8,
277,
14,
362,
63,
66,
1175,
1252,
8165,
8,
277,
14,
513,
63,
515,
8,
515,
395,
2053,
430,
339,
347,
11441,
63,
18671,
63,
1185,
8,
277,
12,
931,
12,
2053,
304,
267,
408,
267,
3645,
6895,
1728,
66,
1175,
14
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
6029,
13,
7806,
428,
555,
3338,
14840,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
624,
199,
33,
19485,
570,
2656,
1890,
626,
14018,
6818,
6895,
1728,
66,
1175,
199,
199,
12834,
1183,
5313,
701,
437,
1502,
699,
828,
1372,
665,
279,
290,
32,
5615,
685,
764,
14,
957,
30,
12869,
14,
957,
15,
279,
290,
2501,
82,
199,
624,
421,
199,
504,
19485,
14,
2828,
14,
19055,
492,
1101,
465,
394,
10434,
63,
888,
199,
504,
19485,
14,
2828,
14,
19055,
492,
1125,
465,
394,
10434,
63,
705,
199,
504,
19485,
14,
2828,
14,
19055,
492,
29252,
2764,
63,
14555,
465,
394,
10434,
63,
15449,
2764,
63,
14555,
199,
504,
19485,
492,
3816,
199,
646,
19485,
14,
2828,
14,
1375,
199,
646,
2050,
199,
646,
2197,
199,
646,
747,
199,
199,
2921,
275,
2050,
14,
5572,
360,
26795,
13,
3266,
358,
421,
199,
533,
428,
78,
1728,
66,
1175,
40,
10434,
3041,
8,
19055,
63,
15449,
2764,
63,
14555,
14,
40,
10434,
3041,
304,
272,
408,
272,
437,
394,
10434,
1890,
1808,
6895,
1728,
66,
1175,
14,
9336,
428,
78,
1728,
66,
1175,
965,
282,
2366,
3261,
12,
652,
7171,
506,
272,
3595,
2948,
5431,
12930,
2419,
314,
29252,
5053,
1890,
12,
1314,
1630,
5218,
734,
370,
272,
282,
12120,
2240,
641,
1924,
570,
2656,
3439,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
20821,
1728,
66,
1175,
40,
10434,
3041,
12,
291,
2843,
826,
4533,
267,
291,
423,
66,
1175,
275,
488,
267,
291,
14,
3150,
275,
446,
17,
339,
768,
4639,
272,
347,
769,
63,
515,
8,
515,
304,
267,
340,
1228,
8,
515,
12,
769,
9,
503,
1228,
8,
515,
12,
2008,
304,
288,
372,
931,
267,
340,
1228,
8,
515,
12,
620,
9,
503,
1228,
8,
515,
12,
2649,
304,
288,
372,
359,
515,
12,
1622,
267,
372,
359,
495,
8,
515,
395,
1622,
339,
347,
664,
63,
66,
1175,
8,
277,
304,
267,
408,
267,
982,
30936,
13721,
965,
14926,
379,
12,
781,
1172,
282,
3365,
20674,
12,
436,
1929,
370,
30882,
14,
267,
408,
267,
1101,
275,
394,
10434,
63,
888,
14,
19055,
342,
267,
340,
291,
14,
3150,
1137,
747,
14,
17829,
342,
503,
440,
291,
423,
66,
1175,
26,
288,
1890,
63,
958,
275,
1211,
8,
1541,
8,
355,
2400,
1022,
63,
86,
26,
1022,
63,
86,
59,
17,
61,
365,
440,
488,
436,
1022,
63,
86,
59,
17,
61,
1137,
3260,
3816,
14,
4611,
2561,
490,
283,
15449,
63,
1023,
356,
1101,
14,
1258,
63,
1023,
12,
490,
283,
20427,
63,
751,
356,
1101,
14,
20427,
63,
751,
12,
355,
3828,
288,
5082,
288,
340,
1101,
14,
21415,
66,
1175,
63,
2495,
888,
26,
355,
408,
355,
961,
365,
9999,
8552,
9025,
543,
314,
20744,
6165,
6810,
436,
883,
506,
1202,
367,
282,
2222,
16100,
4350,
465,
5521,
14,
355,
961,
1890,
11275,
370,
1586,
1124,
10545,
40,
1554,
47,
1938,
63,
3243,
5995,
2190,
15,
19055,
13,
2124,
14,
1652,
1040,
370,
664,
314,
2287,
402,
314,
536,
932,
14,
355,
710,
13942,
365,
314,
2011,
465,
6810,
14,
355,
408,
355,
687,
6895,
1728,
66,
1175,
14,
1258,
492,
9195,
2028,
3041,
355,
291,
423,
66,
1175,
275,
9195,
2028,
3041,
3682,
1258,
63,
958,
9,
288,
587,
26,
355,
687,
6895,
1728,
66,
1175,
14,
1258,
492,
6810,
355,
291,
423,
66,
1175,
275,
6810,
8,
888,
14,
354,
932,
63,
1102,
12,
1101,
14,
354,
932,
63,
719,
12,
1011,
1258,
63,
958,
9,
267,
372,
291,
423,
66,
1175,
339,
347,
3495,
8,
277,
12,
931,
304,
267,
408,
267,
3645,
6895,
1728,
66,
1175,
14,
396,
370,
1104,
570,
23780,
14,
398,
520,
635,
931,
26,
931,
370,
511,
267,
520,
466,
931,
26,
1059,
267,
520,
1107,
26,
5046,
12,
715,
340,
931,
3495,
315,
24521,
51,
267,
408,
267,
862,
26,
288,
372,
291,
14,
362,
63,
66,
1175,
1252,
396,
8,
515,
12,
3495,
29,
549,
9,
267,
871,
2186,
465,
2329,
26,
259,
327,
27499,
5788,
26,
29047,
13,
2590,
288,
746,
394,
10434,
63,
705,
14,
30165,
5153,
317,
547,
480,
21415,
66,
1175,
14,
396,
401,
446,
17,
12,
620,
8,
1508,
395,
4700,
8,
1508,
430,
339,
347,
11441,
8,
277,
12,
931,
12,
2053,
304,
267,
408,
267,
3645,
6895,
1728,
66,
1175,
14,
8165,
12,
340,
2808,
14,
398,
520,
635,
931,
26,
1350,
570,
8,
83,
9,
267,
520,
466,
931,
26,
1902,
282,
1059,
503,
3414,
402,
3326,
267,
520,
635,
2053,
26,
5724,
570,
334,
4780,
1324,
9,
503,
2082,
334,
6048,
9,
267,
520,
466,
2053,
26,
1059,
267,
520,
1107,
26,
769,
402,
17864,
2974,
267,
408,
267,
4184,
275,
2053,
14,
6735,
2336,
1959,
1294,
7825,
267,
340,
822,
8,
4181,
9,
690,
413,
26,
288,
2935,
63,
515,
275,
20538,
904,
8,
4181,
59,
16,
6809,
17,
566,
288,
340,
440,
291,
14,
2444,
8,
694,
63,
515,
304,
355,
291,
14,
8215,
8,
694,
63,
515,
12,
8623,
29,
549,
9,
267,
372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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
johnkitten/FinalProject
|
tailbone/geoip/__init__.py
|
34
|
1044
|
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from tailbone import as_json
from tailbone import BaseHandler
from tailbone import DEBUG
import webapp2
class GeoIPHandler(BaseHandler):
@as_json
def get(self):
resp = {}
for x in ["Country", "Region", "City", "CityLatLong"]:
k = "X-AppEngine-" + x
resp[x] = self.request.headers.get(k)
resp["IP"] = self.request.remote_addr
return resp
app = webapp2.WSGIApplication([
(r".*", GeoIPHandler),
], debug=DEBUG)
|
apache-2.0
|
[
3,
1898,
6171,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
9483,
21134,
492,
465,
63,
1001,
199,
504,
9483,
21134,
492,
3523,
2461,
199,
504,
9483,
21134,
492,
10990,
199,
199,
646,
24812,
18,
199,
199,
533,
18378,
2461,
8,
1563,
2461,
304,
523,
768,
305,
63,
1001,
523,
347,
664,
8,
277,
304,
272,
3085,
275,
1052,
272,
367,
671,
315,
2097,
17393,
401,
298,
10708,
401,
298,
17024,
401,
298,
17024,
22510,
9551,
6229,
489,
1022,
275,
298,
56,
13,
2640,
8524,
23245,
435,
671,
489,
3085,
59,
88,
61,
275,
291,
14,
1069,
14,
2139,
14,
362,
8,
75,
9,
272,
3085,
905,
1772,
937,
275,
291,
14,
1069,
14,
3846,
63,
2697,
272,
372,
3085,
199,
199,
571,
275,
24812,
18,
14,
16828,
5039,
779,
523,
334,
82,
1674,
14421,
18378,
2461,
395,
523,
2156,
3105,
29,
5287,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
6171,
4475,
3277,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
504,
9483,
21134,
492,
465,
63,
1001,
199,
504,
9483,
21134,
492,
3523,
2461,
199,
504,
9483,
21134,
492,
10990,
199,
199,
646,
24812,
18,
199,
199,
533,
18378,
2461,
8,
1563,
2461,
304,
523,
768,
305,
63,
1001,
523,
347,
664,
8,
277,
304,
272,
3085,
275,
1052,
272,
367,
671,
315,
2097,
17393,
401,
298,
10708,
401,
298,
17024,
401,
298,
17024,
22510,
9551,
6229,
489,
1022,
275,
298,
56,
13,
2640,
8524,
23245,
435,
671,
489,
3085,
59,
88,
61,
275,
291,
14,
1069,
14,
2139,
14,
362,
8,
75,
9,
272,
3085,
905,
1772,
937,
275,
291,
14,
1069,
14,
3846,
63,
2697,
272,
372,
3085,
199,
199,
571,
275,
24812,
18,
14,
16828,
5039,
779,
523,
334,
82,
1674,
14421,
18378,
2461,
395,
523,
2156,
3105,
29,
5287,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
hryamzik/ansible
|
lib/ansible/modules/system/make.py
|
30
|
4659
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2015, Linus Unnebäck <linus@folkdatorn.se>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: make
short_description: Run targets in a Makefile
requirements: [ make ]
version_added: "2.1"
author: Linus Unnebäck (@LinusU) <linus@folkdatorn.se>
description:
- Run targets in a Makefile.
options:
target:
description:
- The target to run
params:
description:
- Any extra parameters to pass to make
chdir:
description:
- cd into this directory before running make
required: true
file:
description:
- Use file as a Makefile
version_added: 2.5
'''
EXAMPLES = '''
# Build the default target
- make:
chdir: /home/ubuntu/cool-project
# Run `install` target as root
- make:
chdir: /home/ubuntu/cool-project
target: install
become: yes
# Pass in extra arguments to build
- make:
chdir: /home/ubuntu/cool-project
target: all
params:
NUM_THREADS: 4
BACKEND: lapack
# Pass a file as a Makefile
- make:
chdir: /home/ubuntu/cool-project
target: all
file: /some-project/Makefile
'''
# TODO: Disabled the RETURN as it was breaking docs building. Someone needs to
# fix this
RETURN = '''# '''
from ansible.module_utils.six import iteritems
from ansible.module_utils.basic import AnsibleModule
def run_command(command, module, check_rc=True):
"""
Run a command using the module, return
the result code and std{err,out} content.
:param command: list of command arguments
:param module: Ansible make module instance
:return: return code, stdout content, stderr content
"""
rc, out, err = module.run_command(command, check_rc=check_rc, cwd=module.params['chdir'])
return rc, sanitize_output(out), sanitize_output(err)
def sanitize_output(output):
"""
Sanitize the output string before we
pass it to module.fail_json. Defaults
the string to empty if it is None, else
strips trailing newlines.
:param output: output to sanitize
:return: sanitized output
"""
if output is None:
return ''
else:
return output.rstrip("\r\n")
def main():
module = AnsibleModule(
supports_check_mode=True,
argument_spec=dict(
target=dict(required=False, default=None, type='str'),
params=dict(required=False, default=None, type='dict'),
chdir=dict(required=True, default=None, type='path'),
file=dict(required=False, default=None, type='path')
),
)
# Build up the invocation of `make` we are going to use
make_path = module.get_bin_path('make', True)
make_target = module.params['target']
if module.params['params'] is not None:
make_parameters = [k + '=' + str(v) for k, v in iteritems(module.params['params'])]
else:
make_parameters = []
if module.params['file'] is not None:
base_command = [make_path, "--file", module.params['file'], make_target]
else:
base_command = [make_path, make_target]
base_command.extend(make_parameters)
# Check if the target is already up to date
rc, out, err = run_command(base_command + ['--question'], module, check_rc=False)
if module.check_mode:
# If we've been asked to do a dry run, we only need
# to report whether or not the target is up to date
changed = (rc != 0)
else:
if rc == 0:
# The target is up to date, so we don't have to
# do anything
changed = False
else:
# The target isn't upd to date, so we need to run it
rc, out, err = run_command(base_command, module)
changed = True
# We don't report the return code, as if this module failed
# we would be calling fail_json from run_command, so even if
# we had a non-zero return code, we did not fail. However, if
# we report a non-zero return code here, we will be marked as
# failed regardless of what we signal using the failed= kwarg.
module.exit_json(
changed=changed,
failed=False,
stdout=out,
stderr=err,
target=module.params['target'],
params=module.params['params'],
chdir=module.params['chdir'],
file=module.params['file']
)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
29730,
527,
1910,
685,
66,
13733,
346,
665,
472,
527,
32,
5900,
25606,
707,
78,
14,
261,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
1852,
199,
3612,
63,
1802,
26,
3378,
4545,
315,
282,
20618,
199,
7538,
26,
359,
1852,
1622,
199,
1023,
63,
3270,
26,
298,
18,
14,
17,
2,
199,
2502,
26,
29730,
527,
1910,
685,
66,
13733,
346,
8593,
27889,
527,
53,
9,
665,
472,
527,
32,
5900,
25606,
707,
78,
14,
261,
30,
199,
1802,
26,
523,
446,
3378,
4545,
315,
282,
20618,
14,
199,
1419,
26,
523,
1347,
26,
272,
1369,
26,
489,
446,
710,
1347,
370,
1255,
523,
1862,
26,
272,
1369,
26,
489,
446,
6184,
2402,
2633,
370,
986,
370,
1852,
523,
13097,
26,
272,
1369,
26,
489,
446,
12829,
1901,
642,
2082,
2544,
3879,
1852,
272,
1415,
26,
2549,
523,
570,
26,
272,
1369,
26,
489,
446,
3645,
570,
465,
282,
20618,
272,
1015,
63,
3270,
26,
499,
14,
21,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
6516,
314,
849,
1347,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
199,
199,
3,
3378,
658,
3174,
64,
1347,
465,
1738,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
272,
1347,
26,
3907,
523,
8649,
26,
9456,
199,
199,
3,
8325,
315,
2402,
2368,
370,
1900,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
272,
1347,
26,
1006,
272,
1862,
26,
489,
11576,
63,
16103,
51,
26,
841,
489,
22658,
3902,
26,
1127,
1389,
199,
199,
3,
8325,
282,
570,
465,
282,
20618,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
272,
1347,
26,
1006,
272,
570,
26,
1182,
3972,
13,
1715,
15,
19878,
199,
2344,
199,
199,
3,
3254,
26,
5289,
1909,
314,
24646,
465,
652,
1990,
27485,
9149,
10015,
14,
6601,
368,
4839,
370,
199,
3,
5325,
642,
199,
9677,
275,
1449,
3,
1449,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
10849,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
421,
199,
318,
1255,
63,
1531,
8,
1531,
12,
859,
12,
1104,
63,
1195,
29,
549,
304,
272,
408,
272,
3378,
282,
1414,
1808,
314,
859,
12,
372,
272,
314,
754,
1233,
436,
2418,
91,
1508,
12,
548,
93,
1564,
14,
339,
520,
635,
1414,
26,
769,
402,
1414,
2368,
272,
520,
635,
859,
26,
2622,
1852,
859,
1256,
272,
520,
1107,
26,
372,
1233,
12,
3839,
1564,
12,
4635,
1564,
272,
408,
272,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
8,
1531,
12,
1104,
63,
1195,
29,
1074,
63,
1195,
12,
8288,
29,
578,
14,
1162,
459,
8563,
1105,
272,
372,
4819,
12,
21077,
63,
1199,
8,
548,
395,
21077,
63,
1199,
8,
1508,
9,
421,
199,
318,
21077,
63,
1199,
8,
1199,
304,
272,
408,
272,
428,
12531,
314,
1072,
1059,
2544,
781,
272,
986,
652,
370,
859,
14,
1633,
63,
1001,
14,
7827,
272,
314,
1059,
370,
2701,
340,
652,
365,
488,
12,
587,
272,
32384,
8520,
14930,
14,
339,
520,
635,
1072,
26,
1072,
370,
21077,
272,
520,
1107,
26,
31734,
1072,
272,
408,
272,
340,
1072,
365,
488,
26,
267,
372,
2125,
272,
587,
26,
267,
372,
1072,
14,
6735,
4582,
82,
60,
78,
531,
421,
199,
318,
2446,
837,
272,
859,
275,
6953,
8,
267,
5171,
63,
1074,
63,
632,
29,
549,
12,
267,
1423,
63,
1650,
29,
807,
8,
288,
1347,
29,
807,
8,
2427,
29,
797,
12,
849,
29,
403,
12,
730,
534,
495,
659,
288,
1862,
29,
807,
8,
2427,
29,
797,
12,
849,
29,
403,
12,
730,
534,
807,
659,
288,
13097,
29,
807,
8,
2427,
29,
549,
12,
849,
29,
403,
12,
730,
534,
515,
659,
288,
570,
29,
807,
8,
2427,
29,
797,
12,
849,
29,
403,
12,
730,
534,
515,
358,
267,
2318,
272,
776,
272,
327,
6516,
1536,
314,
19569,
402,
658,
1875,
64,
781,
787,
9995,
370,
675,
272,
1852,
63,
515,
275,
859,
14,
362,
63,
1393,
63,
515,
360,
1875,
297,
715,
9,
272,
1852,
63,
1375,
275,
859,
14,
1162,
459,
1375,
418,
272,
340,
859,
14,
1162,
459,
1162,
418,
365,
440,
488,
26,
267,
1852,
63,
3214,
275,
359,
75,
435,
14051,
435,
620,
8,
86,
9,
367,
1022,
12,
373,
315,
10849,
8,
578,
14,
1162,
459,
1162,
24437,
272,
587,
26,
267,
1852,
63,
3214,
275,
942,
339,
340,
859,
14,
1162,
459,
493,
418,
365,
440,
488,
26,
267,
1300,
63,
1531,
275,
359,
1875,
63,
515,
12,
4320,
493,
401,
859,
14,
1162,
459,
493,
995,
1852,
63,
1375,
61,
272,
587,
26,
267,
1300,
63,
1531,
275,
359,
1875,
63,
515,
12,
1852,
63,
1375,
61,
272,
1300,
63,
1531,
14,
2880,
8,
1875,
63,
3214,
9,
339,
327,
2670,
340,
314,
1347,
365,
2575,
1536,
370,
1434,
272,
4819,
12,
734,
12,
2329,
275,
1255,
63,
1531,
8,
1095,
63,
1531,
435,
14574,
4790,
995,
859,
12,
1104,
63,
1195,
29,
797,
9,
272,
340,
859,
14,
1074,
63,
632,
26,
267,
327,
982,
781,
9064,
2757,
20864,
370,
886,
282,
9951,
1255,
12,
781,
1454,
1929,
267,
327,
370,
3622,
3775,
503,
440,
314,
1347,
365,
1536,
370,
1434,
267,
2896,
275,
334,
1195,
1137,
378,
9,
272,
587,
26,
267,
340,
4819,
508,
378,
26,
288,
327,
710,
1347,
365,
1536,
370,
1434
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6900,
12,
29730,
527,
1910,
685,
66,
13733,
346,
665,
472,
527,
32,
5900,
25606,
707,
78,
14,
261,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
1852,
199,
3612,
63,
1802,
26,
3378,
4545,
315,
282,
20618,
199,
7538,
26,
359,
1852,
1622,
199,
1023,
63,
3270,
26,
298,
18,
14,
17,
2,
199,
2502,
26,
29730,
527,
1910,
685,
66,
13733,
346,
8593,
27889,
527,
53,
9,
665,
472,
527,
32,
5900,
25606,
707,
78,
14,
261,
30,
199,
1802,
26,
523,
446,
3378,
4545,
315,
282,
20618,
14,
199,
1419,
26,
523,
1347,
26,
272,
1369,
26,
489,
446,
710,
1347,
370,
1255,
523,
1862,
26,
272,
1369,
26,
489,
446,
6184,
2402,
2633,
370,
986,
370,
1852,
523,
13097,
26,
272,
1369,
26,
489,
446,
12829,
1901,
642,
2082,
2544,
3879,
1852,
272,
1415,
26,
2549,
523,
570,
26,
272,
1369,
26,
489,
446,
3645,
570,
465,
282,
20618,
272,
1015,
63,
3270,
26,
499,
14,
21,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
6516,
314,
849,
1347,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
199,
199,
3,
3378,
658,
3174,
64,
1347,
465,
1738,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
272,
1347,
26,
3907,
523,
8649,
26,
9456,
199,
199,
3,
8325,
315,
2402,
2368,
370,
1900,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
272,
1347,
26,
1006,
272,
1862,
26,
489,
11576,
63,
16103,
51,
26,
841,
489,
22658,
3902,
26,
1127,
1389,
199,
199,
3,
8325,
282,
570,
465,
282,
20618,
199,
13,
1852,
26,
272,
13097,
26,
1182,
4219,
15,
21151,
15,
18499,
13,
1715,
272,
1347,
26,
1006,
272,
570,
26,
1182,
3972,
13,
1715,
15,
19878,
199,
2344,
199,
199,
3,
3254,
26,
5289,
1909,
314,
24646,
465,
652,
1990,
27485,
9149,
10015,
14,
6601,
368,
4839,
370,
199,
3,
5325,
642,
199,
9677,
275,
1449,
3,
1449,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4174,
492,
10849,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
421,
199,
318,
1255,
63,
1531,
8,
1531,
12,
859,
12,
1104,
63,
1195,
29,
549,
304,
272,
408,
272,
3378,
282,
1414,
1808,
314,
859,
12,
372,
272,
314,
754,
1233,
436,
2418,
91,
1508,
12,
548,
93,
1564,
14,
339,
520,
635,
1414,
26,
769,
402,
1414,
2368,
272,
520,
635,
859,
26,
2622,
1852,
859,
1256,
272,
520,
1107,
26,
372,
1233,
12,
3839,
1564,
12,
4635,
1564,
272,
408,
272,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
8,
1531,
12,
1104,
63,
1195,
29,
1074,
63,
1195,
12,
8288,
29,
578,
14,
1162,
459,
8563,
1105,
272,
372,
4819,
12,
21077,
63,
1199,
8,
548,
395,
21077,
63,
1199,
8,
1508,
9,
421,
199,
318,
21077,
63,
1199,
8,
1199,
304,
272,
408,
272,
428,
12531,
314,
1072,
1059,
2544,
781,
272,
986,
652,
370,
859,
14,
1633,
63,
1001,
14,
7827,
272,
314,
1059,
370,
2701,
340,
652,
365,
488,
12,
587,
272,
32384,
8520,
14930,
14,
339,
520,
635,
1072,
26,
1072,
370,
21077,
272,
520,
1107,
26,
31734,
1072,
272,
408,
272,
340,
1072,
365,
488,
26,
267,
372,
2125,
272,
587,
26,
267,
372,
1072,
14,
6735,
4582,
82,
60,
78,
531,
421,
199,
318,
2446,
837,
272,
859,
275,
6953,
8,
267,
5171,
63,
1074,
63,
632,
29,
549,
12,
267,
1423,
63,
1650,
29,
807,
8,
288,
1347,
29,
807,
8,
2427,
29,
797,
12,
849,
29,
403,
12,
730,
534,
495,
659,
288,
1862,
29,
807,
8,
2427,
29,
797,
12,
849,
29,
403,
12,
730,
534,
807,
659,
288,
13097,
29,
807,
8,
2427,
29,
549,
12,
849,
29,
403,
12,
730,
534,
515,
659,
288,
570,
29,
807,
8,
2427,
29,
797,
12,
849,
29,
403,
12,
730,
534,
515,
358,
267,
2318,
272,
776,
272,
327,
6516,
1536,
314,
19569,
402,
658,
1875,
64,
781,
787,
9995,
370,
675,
272,
1852,
63,
515,
275,
859,
14,
362,
63,
1393,
63,
515,
360,
1875,
297,
715,
9,
272,
1852,
63,
1375,
275,
859,
14,
1162,
459,
1375,
418,
272,
340,
859,
14,
1162,
459,
1162,
418,
365,
440,
488,
26,
267,
1852,
63,
3214,
275,
359,
75,
435,
14051,
435,
620,
8,
86,
9,
367,
1022,
12,
373,
315,
10849,
8,
578,
14,
1162,
459,
1162,
24437,
272,
587,
26,
267,
1852,
63,
3214,
275,
942,
339,
340,
859,
14,
1162,
459,
493,
418,
365,
440,
488,
26,
267,
1300,
63,
1531,
275,
359,
1875,
63,
515,
12,
4320,
493,
401,
859,
14,
1162,
459,
493,
995,
1852,
63,
1375,
61,
272,
587,
26,
267,
1300,
63,
1531,
275,
359,
1875,
63,
515,
12,
1852,
63,
1375,
61,
272,
1300,
63,
1531,
14,
2880,
8,
1875,
63,
3214,
9,
339,
327,
2670,
340,
314,
1347,
365,
2575,
1536,
370,
1434,
272,
4819,
12,
734,
12,
2329,
275,
1255,
63,
1531,
8,
1095,
63,
1531,
435,
14574,
4790,
995,
859,
12,
1104,
63,
1195,
29,
797,
9,
272,
340,
859,
14,
1074,
63,
632,
26,
267,
327,
982,
781,
9064,
2757,
20864,
370,
886,
282,
9951,
1255,
12,
781,
1454,
1929,
267,
327,
370,
3622,
3775,
503,
440,
314,
1347,
365,
1536,
370,
1434,
267,
2896,
275,
334,
1195,
1137,
378,
9,
272,
587,
26,
267,
340,
4819,
508,
378,
26,
288,
327,
710,
1347,
365,
1536,
370,
1434,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
smaty1/shadowsocks
|
shadowsocks/encrypt.py
|
990
|
5180
|
#!/usr/bin/env python
#
# Copyright 2012-2015 clowwindy
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import, division, print_function, \
with_statement
import os
import sys
import hashlib
import logging
from shadowsocks import common
from shadowsocks.crypto import rc4_md5, openssl, sodium, table
method_supported = {}
method_supported.update(rc4_md5.ciphers)
method_supported.update(openssl.ciphers)
method_supported.update(sodium.ciphers)
method_supported.update(table.ciphers)
def random_string(length):
return os.urandom(length)
cached_keys = {}
def try_cipher(key, method=None):
Encryptor(key, method)
def EVP_BytesToKey(password, key_len, iv_len):
# equivalent to OpenSSL's EVP_BytesToKey() with count 1
# so that we make the same key and iv as nodejs version
cached_key = '%s-%d-%d' % (password, key_len, iv_len)
r = cached_keys.get(cached_key, None)
if r:
return r
m = []
i = 0
while len(b''.join(m)) < (key_len + iv_len):
md5 = hashlib.md5()
data = password
if i > 0:
data = m[i - 1] + password
md5.update(data)
m.append(md5.digest())
i += 1
ms = b''.join(m)
key = ms[:key_len]
iv = ms[key_len:key_len + iv_len]
cached_keys[cached_key] = (key, iv)
return key, iv
class Encryptor(object):
def __init__(self, key, method):
self.key = key
self.method = method
self.iv = None
self.iv_sent = False
self.cipher_iv = b''
self.decipher = None
method = method.lower()
self._method_info = self.get_method_info(method)
if self._method_info:
self.cipher = self.get_cipher(key, method, 1,
random_string(self._method_info[1]))
else:
logging.error('method %s not supported' % method)
sys.exit(1)
def get_method_info(self, method):
method = method.lower()
m = method_supported.get(method)
return m
def iv_len(self):
return len(self.cipher_iv)
def get_cipher(self, password, method, op, iv):
password = common.to_bytes(password)
m = self._method_info
if m[0] > 0:
key, iv_ = EVP_BytesToKey(password, m[0], m[1])
else:
# key_length == 0 indicates we should use the key directly
key, iv = password, b''
iv = iv[:m[1]]
if op == 1:
# this iv is for cipher not decipher
self.cipher_iv = iv[:m[1]]
return m[2](method, key, iv, op)
def encrypt(self, buf):
if len(buf) == 0:
return buf
if self.iv_sent:
return self.cipher.update(buf)
else:
self.iv_sent = True
return self.cipher_iv + self.cipher.update(buf)
def decrypt(self, buf):
if len(buf) == 0:
return buf
if self.decipher is None:
decipher_iv_len = self._method_info[1]
decipher_iv = buf[:decipher_iv_len]
self.decipher = self.get_cipher(self.key, self.method, 0,
iv=decipher_iv)
buf = buf[decipher_iv_len:]
if len(buf) == 0:
return buf
return self.decipher.update(buf)
def encrypt_all(password, method, op, data):
result = []
method = method.lower()
(key_len, iv_len, m) = method_supported[method]
if key_len > 0:
key, _ = EVP_BytesToKey(password, key_len, iv_len)
else:
key = password
if op:
iv = random_string(iv_len)
result.append(iv)
else:
iv = data[:iv_len]
data = data[iv_len:]
cipher = m(method, key, iv, op)
result.append(cipher.update(data))
return b''.join(result)
CIPHERS_TO_TEST = [
'aes-128-cfb',
'aes-256-cfb',
'rc4-md5',
'salsa20',
'chacha20',
'table',
]
def test_encryptor():
from os import urandom
plain = urandom(10240)
for method in CIPHERS_TO_TEST:
logging.warn(method)
encryptor = Encryptor(b'key', method)
decryptor = Encryptor(b'key', method)
cipher = encryptor.encrypt(plain)
plain2 = decryptor.decrypt(cipher)
assert plain == plain2
def test_encrypt_all():
from os import urandom
plain = urandom(10240)
for method in CIPHERS_TO_TEST:
logging.warn(method)
cipher = encrypt_all(b'key', method, 1, plain)
plain2 = encrypt_all(b'key', method, 0, cipher)
assert plain == plain2
if __name__ == '__main__':
test_encrypt_all()
test_encryptor()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
6029,
13,
7806,
286,
674,
11530,
89,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
971,
272,
543,
63,
6242,
199,
199,
646,
747,
199,
646,
984,
199,
646,
8337,
199,
646,
2050,
199,
199,
504,
15084,
21234,
492,
2863,
199,
504,
15084,
21234,
14,
10316,
492,
4819,
20,
63,
1064,
21,
12,
1551,
4266,
12,
880,
12980,
12,
1817,
421,
199,
765,
63,
4946,
275,
1052,
199,
765,
63,
4946,
14,
873,
8,
1195,
20,
63,
1064,
21,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
14837,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1152,
12980,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1224,
14,
27426,
9,
421,
199,
318,
2196,
63,
875,
8,
1267,
304,
272,
372,
747,
14,
22776,
8,
1267,
9,
421,
199,
5245,
63,
1612,
275,
1052,
421,
199,
318,
862,
63,
9231,
8,
498,
12,
1083,
29,
403,
304,
272,
3447,
4997,
269,
8,
498,
12,
1083,
9,
421,
199,
318,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
304,
272,
327,
7353,
370,
14296,
1159,
662,
14159,
63,
5571,
1378,
1197,
342,
543,
2338,
413,
272,
327,
880,
626,
781,
1852,
314,
2011,
790,
436,
18831,
465,
1031,
3596,
1015,
272,
6328,
63,
498,
275,
1543,
83,
3295,
68,
3295,
68,
7,
450,
334,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
9,
272,
519,
275,
6328,
63,
1612,
14,
362,
8,
5245,
63,
498,
12,
488,
9,
272,
340,
519,
26,
267,
372,
519,
272,
333,
275,
942,
272,
284,
275,
378,
272,
1830,
822,
8,
66,
17067,
904,
8,
77,
430,
665,
334,
498,
63,
552,
435,
18831,
63,
552,
304,
267,
6128,
21,
275,
8337,
14,
1064,
21,
342,
267,
666,
275,
2505,
267,
340,
284,
690,
378,
26,
288,
666,
275,
333,
59,
73,
446,
413,
61,
435,
2505,
267,
6128,
21,
14,
873,
8,
576,
9,
267,
333,
14,
740,
8,
1064,
21,
14,
5671,
1012,
267,
284,
847,
413,
272,
6605,
275,
330,
17067,
904,
8,
77,
9,
272,
790,
275,
6605,
1491,
498,
63,
552,
61,
272,
18831,
275,
6605,
59,
498,
63,
552,
26,
498,
63,
552,
435,
18831,
63,
552,
61,
272,
6328,
63,
1612,
59,
5245,
63,
498,
61,
275,
334,
498,
12,
18831,
9,
272,
372,
790,
12,
18831,
421,
199,
533,
3447,
4997,
269,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
790,
12,
1083,
304,
267,
291,
14,
498,
275,
790,
267,
291,
14,
765,
275,
1083,
267,
291,
14,
1003,
275,
488,
267,
291,
14,
1003,
63,
1150,
275,
756,
267,
291,
14,
9231,
63,
1003,
275,
330,
891,
267,
291,
14,
271,
9231,
275,
488,
267,
1083,
275,
1083,
14,
2325,
342,
267,
291,
423,
765,
63,
815,
275,
291,
14,
362,
63,
765,
63,
815,
8,
765,
9,
267,
340,
291,
423,
765,
63,
815,
26,
288,
291,
14,
9231,
275,
291,
14,
362,
63,
9231,
8,
498,
12,
1083,
12,
413,
12,
5101,
2196,
63,
875,
8,
277,
423,
765,
63,
815,
59,
17,
2459,
267,
587,
26,
288,
2050,
14,
705,
360,
765,
450,
83,
440,
3748,
7,
450,
1083,
9,
288,
984,
14,
2224,
8,
17,
9,
339,
347,
664,
63,
765,
63,
815,
8,
277,
12,
1083,
304,
267,
1083,
275,
1083,
14,
2325,
342,
267,
333,
275,
1083,
63,
4946,
14,
362,
8,
765,
9,
267,
372,
333,
339,
347,
18831,
63,
552,
8,
277,
304,
267,
372,
822,
8,
277,
14,
9231,
63,
1003,
9,
339,
347,
664,
63,
9231,
8,
277,
12,
2505,
12,
1083,
12,
1687,
12,
18831,
304,
267,
2505,
275,
2863,
14,
475,
63,
2394,
8,
2060,
9,
267,
333,
275,
291,
423,
765,
63,
815,
267,
340,
333,
59,
16,
61,
690,
378,
26,
288,
790,
12,
18831,
63,
275,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
333,
59,
16,
467,
333,
59,
17,
566,
267,
587,
26,
288,
327,
790,
63,
1267,
508,
378,
9126,
781,
1077,
675,
314,
790,
5370,
288,
790,
12,
18831,
275,
2505,
12,
330,
891,
398,
18831,
275,
18831,
1491,
77,
59,
17,
2677,
267,
340,
1687,
508,
413,
26,
288,
327,
642,
18831,
365,
367,
10830,
440,
477,
9231,
288,
291,
14,
9231,
63,
1003,
275,
18831,
1491,
77,
59,
17,
2677,
267,
372,
333,
59,
18,
8738,
765,
12,
790,
12,
18831,
12,
1687,
9,
339,
347,
14645,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
1003,
63,
1150,
26,
288,
372,
291,
14,
9231,
14,
873,
8,
1436,
9,
267,
587,
26,
288,
291,
14,
1003,
63,
1150,
275,
715,
288,
372,
291,
14,
9231,
63,
1003,
435,
291,
14,
9231,
14,
873,
8,
1436,
9,
339,
347,
20090,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
271,
9231,
365,
488,
26,
288,
477,
9231,
63,
1003,
63,
552,
275,
291,
423,
765,
63,
815,
59,
17,
61,
288,
477,
9231,
63,
1003,
275,
4123,
1491,
271,
9231,
63,
1003,
63,
552,
61,
288,
291,
14,
271,
9231,
275,
291,
14,
362
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
6029,
13,
7806,
286,
674,
11530,
89,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
199,
3,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
199,
3,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
2428,
199,
3,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
1666,
314,
199,
3,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
4204,
199,
3,
1334,
314,
844,
14,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
971,
272,
543,
63,
6242,
199,
199,
646,
747,
199,
646,
984,
199,
646,
8337,
199,
646,
2050,
199,
199,
504,
15084,
21234,
492,
2863,
199,
504,
15084,
21234,
14,
10316,
492,
4819,
20,
63,
1064,
21,
12,
1551,
4266,
12,
880,
12980,
12,
1817,
421,
199,
765,
63,
4946,
275,
1052,
199,
765,
63,
4946,
14,
873,
8,
1195,
20,
63,
1064,
21,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
14837,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1152,
12980,
14,
27426,
9,
199,
765,
63,
4946,
14,
873,
8,
1224,
14,
27426,
9,
421,
199,
318,
2196,
63,
875,
8,
1267,
304,
272,
372,
747,
14,
22776,
8,
1267,
9,
421,
199,
5245,
63,
1612,
275,
1052,
421,
199,
318,
862,
63,
9231,
8,
498,
12,
1083,
29,
403,
304,
272,
3447,
4997,
269,
8,
498,
12,
1083,
9,
421,
199,
318,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
304,
272,
327,
7353,
370,
14296,
1159,
662,
14159,
63,
5571,
1378,
1197,
342,
543,
2338,
413,
272,
327,
880,
626,
781,
1852,
314,
2011,
790,
436,
18831,
465,
1031,
3596,
1015,
272,
6328,
63,
498,
275,
1543,
83,
3295,
68,
3295,
68,
7,
450,
334,
2060,
12,
790,
63,
552,
12,
18831,
63,
552,
9,
272,
519,
275,
6328,
63,
1612,
14,
362,
8,
5245,
63,
498,
12,
488,
9,
272,
340,
519,
26,
267,
372,
519,
272,
333,
275,
942,
272,
284,
275,
378,
272,
1830,
822,
8,
66,
17067,
904,
8,
77,
430,
665,
334,
498,
63,
552,
435,
18831,
63,
552,
304,
267,
6128,
21,
275,
8337,
14,
1064,
21,
342,
267,
666,
275,
2505,
267,
340,
284,
690,
378,
26,
288,
666,
275,
333,
59,
73,
446,
413,
61,
435,
2505,
267,
6128,
21,
14,
873,
8,
576,
9,
267,
333,
14,
740,
8,
1064,
21,
14,
5671,
1012,
267,
284,
847,
413,
272,
6605,
275,
330,
17067,
904,
8,
77,
9,
272,
790,
275,
6605,
1491,
498,
63,
552,
61,
272,
18831,
275,
6605,
59,
498,
63,
552,
26,
498,
63,
552,
435,
18831,
63,
552,
61,
272,
6328,
63,
1612,
59,
5245,
63,
498,
61,
275,
334,
498,
12,
18831,
9,
272,
372,
790,
12,
18831,
421,
199,
533,
3447,
4997,
269,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
790,
12,
1083,
304,
267,
291,
14,
498,
275,
790,
267,
291,
14,
765,
275,
1083,
267,
291,
14,
1003,
275,
488,
267,
291,
14,
1003,
63,
1150,
275,
756,
267,
291,
14,
9231,
63,
1003,
275,
330,
891,
267,
291,
14,
271,
9231,
275,
488,
267,
1083,
275,
1083,
14,
2325,
342,
267,
291,
423,
765,
63,
815,
275,
291,
14,
362,
63,
765,
63,
815,
8,
765,
9,
267,
340,
291,
423,
765,
63,
815,
26,
288,
291,
14,
9231,
275,
291,
14,
362,
63,
9231,
8,
498,
12,
1083,
12,
413,
12,
5101,
2196,
63,
875,
8,
277,
423,
765,
63,
815,
59,
17,
2459,
267,
587,
26,
288,
2050,
14,
705,
360,
765,
450,
83,
440,
3748,
7,
450,
1083,
9,
288,
984,
14,
2224,
8,
17,
9,
339,
347,
664,
63,
765,
63,
815,
8,
277,
12,
1083,
304,
267,
1083,
275,
1083,
14,
2325,
342,
267,
333,
275,
1083,
63,
4946,
14,
362,
8,
765,
9,
267,
372,
333,
339,
347,
18831,
63,
552,
8,
277,
304,
267,
372,
822,
8,
277,
14,
9231,
63,
1003,
9,
339,
347,
664,
63,
9231,
8,
277,
12,
2505,
12,
1083,
12,
1687,
12,
18831,
304,
267,
2505,
275,
2863,
14,
475,
63,
2394,
8,
2060,
9,
267,
333,
275,
291,
423,
765,
63,
815,
267,
340,
333,
59,
16,
61,
690,
378,
26,
288,
790,
12,
18831,
63,
275,
662,
14159,
63,
5571,
1378,
1197,
8,
2060,
12,
333,
59,
16,
467,
333,
59,
17,
566,
267,
587,
26,
288,
327,
790,
63,
1267,
508,
378,
9126,
781,
1077,
675,
314,
790,
5370,
288,
790,
12,
18831,
275,
2505,
12,
330,
891,
398,
18831,
275,
18831,
1491,
77,
59,
17,
2677,
267,
340,
1687,
508,
413,
26,
288,
327,
642,
18831,
365,
367,
10830,
440,
477,
9231,
288,
291,
14,
9231,
63,
1003,
275,
18831,
1491,
77,
59,
17,
2677,
267,
372,
333,
59,
18,
8738,
765,
12,
790,
12,
18831,
12,
1687,
9,
339,
347,
14645,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
1003,
63,
1150,
26,
288,
372,
291,
14,
9231,
14,
873,
8,
1436,
9,
267,
587,
26,
288,
291,
14,
1003,
63,
1150,
275,
715,
288,
372,
291,
14,
9231,
63,
1003,
435,
291,
14,
9231,
14,
873,
8,
1436,
9,
339,
347,
20090,
8,
277,
12,
4123,
304,
267,
340,
822,
8,
1436,
9,
508,
378,
26,
288,
372,
4123,
267,
340,
291,
14,
271,
9231,
365,
488,
26,
288,
477,
9231,
63,
1003,
63,
552,
275,
291,
423,
765,
63,
815,
59,
17,
61,
288,
477,
9231,
63,
1003,
275,
4123,
1491,
271,
9231,
63,
1003,
63,
552,
61,
288,
291,
14,
271,
9231,
275,
291,
14,
362,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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8 -*-
# Build configuration file.
# This file is execfile()d with the current directory set to its
# containing dir.
# Note that not all possible configuration values are present in this
# autogenerated file.
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.append(os.path.abspath('.'))
# -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
from datetime import datetime
project = u'biobee.buildout'
copyright = u'%s, Serge Davidov.' % datetime.now().year
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = []
# The reST default role (used for this markup: `text`) to use for all documents
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'buildoutdoc'
# -- Options for LaTeX output -------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual])
latex_documents = [
('index',
'buildout.tex',
u'biobee.buildout Documentation',
u'', 'manual'
),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
6516,
2897,
570,
14,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
199,
3,
3035,
2935,
14,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
375,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
199,
3,
5478,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
788,
8008,
14,
832,
14,
28056,
297,
283,
8008,
14,
832,
14,
11390,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
504,
2197,
492,
2197,
199,
1715,
275,
399,
7,
17614,
19446,
14,
1506,
548,
7,
199,
7307,
275,
399,
5956,
83,
12,
3739,
303,
20232,
8822,
3530,
450,
2197,
14,
2131,
1252,
3403,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
8247,
626,
9296,
1133,
506,
5120,
315,
314,
1900,
14,
199,
3,
8618,
63,
4757,
275,
942,
199,
199,
3,
3820,
402,
6602,
12,
3847,
370,
1350,
2082,
12,
626,
9296,
1133,
506,
17543,
199,
3,
367,
1350,
1584,
14,
199,
5473,
63,
14635,
275,
942,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
23271,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
16593,
5857,
17915,
626,
11492,
543,
199,
3,
10229,
787,
5544,
283,
885,
7,
436,
283,
8008,
1301,
1370,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
314,
199,
3,
9149,
14,
221,
961,
570,
1077,
506,
282,
5417,
7016,
570,
17048,
12802,
9,
3769,
3193,
88,
975,
503,
4337,
88,
708,
199,
3,
11094,
7031,
14,
199,
3,
1360,
63,
22229,
275,
488,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
2955,
1584,
334,
10180,
465,
3449,
24405,
9,
2348,
12,
199,
3,
3847,
370,
642,
2082,
14,
9322,
787,
8876,
2410,
314,
6762,
2955,
1584,
12,
199,
3,
880,
282,
570,
4310,
298,
885,
14,
3919,
2,
911,
8970,
314,
6762,
298,
885,
14,
3919,
1674,
199,
1360,
63,
1986,
63,
515,
275,
4044,
1986,
418,
199,
199,
3,
982,
440,
3260,
282,
283,
6090,
4588,
641,
4881,
4913,
365,
11788,
737,
4036,
2034,
9048,
12,
199,
3,
1808,
314,
1627,
14053,
1475,
14,
199,
3,
1360,
63,
2019,
63,
5334
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
6516,
2897,
570,
14,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
199,
3,
3035,
2935,
14,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
3,
982,
5478,
334,
269,
4621,
370,
2213,
543,
29973,
9,
787,
315,
4573,
2082,
12,
199,
3,
1050,
3520,
6602,
370,
984,
14,
515,
2348,
14,
982,
314,
2082,
365,
3847,
370,
314,
199,
3,
3794,
1738,
12,
675,
747,
14,
515,
14,
4832,
370,
1852,
652,
3679,
12,
2839,
9164,
2348,
14,
199,
3,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
4832,
24535,
199,
199,
3,
1553,
1696,
2897,
9527,
375,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
199,
3,
5478,
17262,
543,
10229,
334,
4579,
283,
8008,
14,
832,
24915,
503,
2195,
3537,
7869,
14,
199,
5359,
275,
788,
8008,
14,
832,
14,
28056,
297,
283,
8008,
14,
832,
14,
11390,
418,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
7009,
2348,
12,
3847,
370,
642,
2082,
14,
199,
5876,
63,
515,
275,
4044,
5876,
418,
199,
199,
3,
710,
4739,
402,
1350,
6203,
14,
199,
1365,
63,
4511,
275,
1987,
8332,
7,
199,
199,
3,
710,
2644,
402,
1350,
1584,
14,
199,
3,
1365,
63,
2991,
275,
283,
1624,
13,
24,
7,
199,
199,
3,
710,
5288,
28310,
2213,
14,
199,
4133,
63,
1301,
275,
283,
1080,
7,
199,
199,
3,
1696,
2556,
3595,
314,
2199,
14,
199,
504,
2197,
492,
2197,
199,
1715,
275,
399,
7,
17614,
19446,
14,
1506,
548,
7,
199,
7307,
275,
399,
5956,
83,
12,
3739,
303,
20232,
8822,
3530,
450,
2197,
14,
2131,
1252,
3403,
199,
199,
3,
710,
2637,
367,
1564,
18392,
701,
10229,
14,
21751,
370,
3794,
199,
3,
367,
282,
769,
402,
3748,
10815,
14,
199,
3,
3671,
275,
488,
199,
199,
3,
6006,
787,
2877,
1511,
367,
15810,
1204,
8136,
25004,
1902,
12,
1265,
663,
11168,
370,
2005,
199,
3,
2222,
13,
3910,
574,
12,
2066,
652,
365,
1202,
26,
199,
3,
8136,
275,
2125,
199,
3,
19524,
12,
11168,
63,
5045,
365,
1202,
465,
314,
1475,
367,
282,
14053,
1240,
14,
199,
3,
8136,
63,
5045,
275,
1543,
34,
450,
68,
12,
450,
57,
7,
199,
199,
3,
3820,
402,
8247,
626,
9296,
1133,
506,
5120,
315,
314,
1900,
14,
199,
3,
8618,
63,
4757,
275,
942,
199,
199,
3,
3820,
402,
6602,
12,
3847,
370,
1350,
2082,
12,
626,
9296,
1133,
506,
17543,
199,
3,
367,
1350,
1584,
14,
199,
5473,
63,
14635,
275,
942,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
199,
3,
885,
63,
3756,
275,
488,
199,
199,
3,
982,
2549,
12,
26380,
911,
506,
11544,
370,
520,
1532,
26,
5423,
14,
8059,
13,
4443,
1318,
14,
199,
3,
525,
63,
1593,
63,
25510,
275,
715,
199,
199,
3,
982,
2549,
12,
314,
1453,
859,
536,
911,
506,
20247,
370,
1006,
1369,
199,
3,
4137,
16194,
334,
10180,
465,
2508,
805,
32469,
199,
3,
525,
63,
578,
63,
1247,
275,
715,
199,
199,
3,
982,
2549,
12,
3420,
2502,
436,
28966,
13502,
911,
506,
9164,
315,
314,
199,
3,
1072,
14,
9322,
787,
5525,
701,
849,
14,
199,
3,
2384,
63,
8149,
275,
756,
199,
199,
3,
710,
536,
402,
314,
14493,
334,
7093,
22437,
9,
3449,
370,
675,
14,
199,
12173,
63,
2487,
275,
283,
8008,
7,
199,
199,
3,
437,
769,
402,
5525,
13158,
367,
859,
1478,
13351,
14,
199,
3,
27555,
63,
2330,
63,
1861,
275,
942,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
23271,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
16593,
5857,
17915,
626,
11492,
543,
199,
3,
10229,
787,
5544,
283,
885,
7,
436,
283,
8008,
1301,
1370,
199,
1360,
63,
7915,
275,
283,
885,
7,
199,
199,
3,
23978,
1511,
787,
8879,
13,
6100,
436,
17551,
314,
3648,
436,
23109,
402,
282,
8879,
199,
3,
9848,
14,
221,
2104,
282,
769,
402,
1511,
2808,
367,
1924,
8879,
12,
1937,
314,
199,
3,
3794,
14,
199,
3,
1360,
63,
7915,
63,
1419,
275,
1052,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
17915,
2348,
12,
3847,
370,
642,
2082,
14,
199,
3,
1360,
63,
7915,
63,
515,
275,
942,
199,
199,
3,
710,
536,
367,
642,
663,
402,
10229,
8247,
14,
221,
982,
488,
12,
652,
4243,
370,
199,
3,
3886,
1715,
30,
373,
28,
3221,
30,
3794,
1674,
199,
3,
1360,
63,
1213,
275,
488,
199,
199,
3,
437,
18299,
2538,
367,
314,
19191,
4681,
14,
221,
3758,
365,
314,
2011,
465,
3517,
63,
1213,
14,
199,
3,
1360,
63,
3612,
63,
1213,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
6188,
370,
642,
2082,
9,
370,
4192,
737,
314,
2746,
199,
3,
402,
314,
18437,
14,
199,
3,
1360,
63,
9733,
275,
488,
199,
199,
3,
710,
536,
402,
376,
1834,
570,
334,
12541,
314,
2955,
931,
9,
370,
675,
465,
29139,
402,
314,
199,
3,
9149,
14,
221,
961,
570,
1077,
506,
282,
5417,
7016,
570,
17048,
12802,
9,
3769,
3193,
88,
975,
503,
4337,
88,
708,
199,
3,
11094,
7031,
14,
199,
3,
1360,
63,
22229,
275,
488,
199,
199,
3,
2654,
1263,
3792,
626,
1395,
3537,
2955,
1584,
334,
10180,
465,
3449,
24405,
9,
2348,
12,
199,
3,
3847,
370,
642,
2082,
14,
9322,
787,
8876,
2410,
314,
6762,
2955,
1584,
12,
199,
3,
880,
282,
570,
4310,
298,
885,
14,
3919,
2,
911,
8970,
314,
6762,
298,
885,
14,
3919,
1674,
199,
1360,
63,
1986,
63,
515,
275,
4044,
1986,
418,
199,
199,
3,
982,
440,
3260,
282,
283,
6090,
4588,
641,
4881,
4913,
365,
11788,
737,
4036,
2034,
9048,
12,
199,
3,
1808,
314,
1627,
14053,
1475,
14,
199,
3,
1360,
63,
2019,
63,
5334,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
arun6582/django
|
django/contrib/postgres/aggregates/statistics.py
|
9
|
1970
|
from django.db.models import FloatField, IntegerField
from django.db.models.aggregates import Aggregate
__all__ = [
'CovarPop', 'Corr', 'RegrAvgX', 'RegrAvgY', 'RegrCount', 'RegrIntercept',
'RegrR2', 'RegrSlope', 'RegrSXX', 'RegrSXY', 'RegrSYY', 'StatAggregate',
]
class StatAggregate(Aggregate):
def __init__(self, y, x, output_field=FloatField()):
if not x or not y:
raise ValueError('Both y and x must be provided.')
super().__init__(y=y, x=x, output_field=output_field)
self.x = x
self.y = y
self.source_expressions = self._parse_expressions(self.y, self.x)
def get_source_expressions(self):
return self.y, self.x
def set_source_expressions(self, exprs):
self.y, self.x = exprs
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
return super().resolve_expression(query, allow_joins, reuse, summarize)
class Corr(StatAggregate):
function = 'CORR'
class CovarPop(StatAggregate):
def __init__(self, y, x, sample=False):
self.function = 'COVAR_SAMP' if sample else 'COVAR_POP'
super().__init__(y, x)
class RegrAvgX(StatAggregate):
function = 'REGR_AVGX'
class RegrAvgY(StatAggregate):
function = 'REGR_AVGY'
class RegrCount(StatAggregate):
function = 'REGR_COUNT'
def __init__(self, y, x):
super().__init__(y=y, x=x, output_field=IntegerField())
def convert_value(self, value, expression, connection, context):
if value is None:
return 0
return int(value)
class RegrIntercept(StatAggregate):
function = 'REGR_INTERCEPT'
class RegrR2(StatAggregate):
function = 'REGR_R2'
class RegrSlope(StatAggregate):
function = 'REGR_SLOPE'
class RegrSXX(StatAggregate):
function = 'REGR_SXX'
class RegrSXY(StatAggregate):
function = 'REGR_SXY'
class RegrSYY(StatAggregate):
function = 'REGR_SYY'
|
bsd-3-clause
|
[
504,
1639,
14,
697,
14,
992,
492,
11140,
792,
12,
26141,
199,
504,
1639,
14,
697,
14,
992,
14,
21622,
492,
29397,
199,
199,
363,
452,
363,
275,
359,
272,
283,
967,
1391,
9606,
297,
283,
8380,
82,
297,
283,
497,
2587,
16650,
56,
297,
283,
497,
2587,
16650,
57,
297,
283,
497,
2587,
2353,
297,
283,
497,
2587,
2620,
716,
297,
272,
283,
497,
2587,
50,
18,
297,
283,
497,
2587,
51,
14363,
297,
283,
497,
2587,
51,
2483,
297,
283,
497,
2587,
51,
8195,
297,
283,
497,
2587,
4669,
57,
297,
283,
11232,
10170,
297,
199,
61,
421,
199,
533,
27673,
10170,
8,
10170,
304,
272,
347,
636,
826,
721,
277,
12,
612,
12,
671,
12,
1072,
63,
698,
29,
13019,
5109,
267,
340,
440,
671,
503,
440,
612,
26,
288,
746,
1722,
360,
18088,
612,
436,
671,
1471,
506,
2741,
2659,
267,
1613,
11027,
826,
721,
89,
29,
89,
12,
671,
29,
88,
12,
1072,
63,
698,
29,
1199,
63,
698,
9,
267,
291,
14,
88,
275,
671,
267,
291,
14,
89,
275,
612,
267,
291,
14,
1365,
63,
15264,
275,
291,
423,
1122,
63,
15264,
8,
277,
14,
89,
12,
291,
14,
88,
9,
339,
347,
664,
63,
1365,
63,
15264,
8,
277,
304,
267,
372,
291,
14,
89,
12,
291,
14,
88,
339,
347,
663,
63,
1365,
63,
15264,
8,
277,
12,
23770,
304,
267,
291,
14,
89,
12,
291,
14,
88,
275,
23770,
339,
347,
7512,
63,
5599,
8,
277,
12,
1827,
29,
403,
12,
2040,
63,
20155,
29,
549,
12,
12598,
29,
403,
12,
22301,
29,
797,
12,
367,
63,
2117,
29,
797,
304,
267,
372,
1613,
1252,
6983,
63,
5599,
8,
1131,
12,
2040,
63,
20155,
12,
12598,
12,
22301,
9,
421,
199,
533,
7499,
82,
8,
11232,
10170,
304,
272,
805,
275,
283,
18650,
50,
7,
421,
199,
533,
1849,
1391,
9606,
8,
11232,
10170,
304,
272,
347,
636,
826,
721,
277,
12,
612,
12,
671,
12,
2690,
29,
797,
304,
267,
291,
14,
1593,
275,
283,
1439,
5568,
63,
51,
7089,
7,
340,
2690,
587,
283,
1439,
5568,
63,
13531,
7,
267,
1613,
11027,
826,
721,
89,
12,
671,
9,
421,
199,
533,
799,
2587,
16650,
56,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
6087,
39,
56,
7,
421,
199,
533,
799,
2587,
16650,
57,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
6087,
15489,
7,
421,
199,
533,
799,
2587,
2353,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
8760,
7,
339,
347,
636,
826,
721,
277,
12,
612,
12,
671,
304,
267,
1613,
11027,
826,
721,
89,
29,
89,
12,
671,
29,
88,
12,
1072,
63,
698,
29,
3901,
1012,
339,
347,
3957,
63,
585,
8,
277,
12,
574,
12,
3965,
12,
1950,
12,
1067,
304,
267,
340,
574,
365,
488,
26,
288,
372,
378,
267,
372,
1109,
8,
585,
9,
421,
199,
533,
799,
2587,
2620,
716,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
3843,
7177,
7,
421,
199,
533,
799,
2587,
50,
18,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
50,
18,
7,
421,
199,
533,
799,
2587,
51,
14363,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
51,
1484,
1510,
7,
421,
199,
533,
799,
2587,
51,
2483,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
51,
2483,
7,
421,
199,
533,
799,
2587,
51,
8195,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
51,
8195,
7,
421,
199,
533,
799,
2587,
4669,
57,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
4669,
57,
7,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1639,
14,
697,
14,
992,
492,
11140,
792,
12,
26141,
199,
504,
1639,
14,
697,
14,
992,
14,
21622,
492,
29397,
199,
199,
363,
452,
363,
275,
359,
272,
283,
967,
1391,
9606,
297,
283,
8380,
82,
297,
283,
497,
2587,
16650,
56,
297,
283,
497,
2587,
16650,
57,
297,
283,
497,
2587,
2353,
297,
283,
497,
2587,
2620,
716,
297,
272,
283,
497,
2587,
50,
18,
297,
283,
497,
2587,
51,
14363,
297,
283,
497,
2587,
51,
2483,
297,
283,
497,
2587,
51,
8195,
297,
283,
497,
2587,
4669,
57,
297,
283,
11232,
10170,
297,
199,
61,
421,
199,
533,
27673,
10170,
8,
10170,
304,
272,
347,
636,
826,
721,
277,
12,
612,
12,
671,
12,
1072,
63,
698,
29,
13019,
5109,
267,
340,
440,
671,
503,
440,
612,
26,
288,
746,
1722,
360,
18088,
612,
436,
671,
1471,
506,
2741,
2659,
267,
1613,
11027,
826,
721,
89,
29,
89,
12,
671,
29,
88,
12,
1072,
63,
698,
29,
1199,
63,
698,
9,
267,
291,
14,
88,
275,
671,
267,
291,
14,
89,
275,
612,
267,
291,
14,
1365,
63,
15264,
275,
291,
423,
1122,
63,
15264,
8,
277,
14,
89,
12,
291,
14,
88,
9,
339,
347,
664,
63,
1365,
63,
15264,
8,
277,
304,
267,
372,
291,
14,
89,
12,
291,
14,
88,
339,
347,
663,
63,
1365,
63,
15264,
8,
277,
12,
23770,
304,
267,
291,
14,
89,
12,
291,
14,
88,
275,
23770,
339,
347,
7512,
63,
5599,
8,
277,
12,
1827,
29,
403,
12,
2040,
63,
20155,
29,
549,
12,
12598,
29,
403,
12,
22301,
29,
797,
12,
367,
63,
2117,
29,
797,
304,
267,
372,
1613,
1252,
6983,
63,
5599,
8,
1131,
12,
2040,
63,
20155,
12,
12598,
12,
22301,
9,
421,
199,
533,
7499,
82,
8,
11232,
10170,
304,
272,
805,
275,
283,
18650,
50,
7,
421,
199,
533,
1849,
1391,
9606,
8,
11232,
10170,
304,
272,
347,
636,
826,
721,
277,
12,
612,
12,
671,
12,
2690,
29,
797,
304,
267,
291,
14,
1593,
275,
283,
1439,
5568,
63,
51,
7089,
7,
340,
2690,
587,
283,
1439,
5568,
63,
13531,
7,
267,
1613,
11027,
826,
721,
89,
12,
671,
9,
421,
199,
533,
799,
2587,
16650,
56,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
6087,
39,
56,
7,
421,
199,
533,
799,
2587,
16650,
57,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
6087,
15489,
7,
421,
199,
533,
799,
2587,
2353,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
8760,
7,
339,
347,
636,
826,
721,
277,
12,
612,
12,
671,
304,
267,
1613,
11027,
826,
721,
89,
29,
89,
12,
671,
29,
88,
12,
1072,
63,
698,
29,
3901,
1012,
339,
347,
3957,
63,
585,
8,
277,
12,
574,
12,
3965,
12,
1950,
12,
1067,
304,
267,
340,
574,
365,
488,
26,
288,
372,
378,
267,
372,
1109,
8,
585,
9,
421,
199,
533,
799,
2587,
2620,
716,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
3843,
7177,
7,
421,
199,
533,
799,
2587,
50,
18,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
50,
18,
7,
421,
199,
533,
799,
2587,
51,
14363,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
51,
1484,
1510,
7,
421,
199,
533,
799,
2587,
51,
2483,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
51,
2483,
7,
421,
199,
533,
799,
2587,
51,
8195,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
51,
8195,
7,
421,
199,
533,
799,
2587,
4669,
57,
8,
11232,
10170,
304,
272,
805,
275,
283,
907,
3975,
63,
4669,
57,
7,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
fzadow/CATMAID
|
django/applications/catmaid/control/circles.py
|
2
|
5431
|
import json
import networkx as nx
from itertools import combinations
from collections import defaultdict
from functools import partial
from django.db import connection
from django.http import HttpResponse
from catmaid.models import UserRole
from catmaid.control.authentication import requires_user_role
from catmaid.control.skeleton import _neuronnames
def _next_circle(skeleton_set, cursor):
""" Return a dictionary of skeleton IDs in the skeleton_set vs a dictionary of connected skeletons vs how many connections."""
cursor.execute('''
SELECT tc1.skeleton_id, tc1.relation_id, tc2.skeleton_id
FROM treenode_connector tc1,
treenode_connector tc2
WHERE tc1.skeleton_id in (%s)
AND tc1.connector_id = tc2.connector_id
AND tc1.skeleton_id != tc2.skeleton_id
AND tc1.relation_id != tc2.relation_id
''' % ','.join(map(str, skeleton_set)))
connections = defaultdict(partial(defaultdict, partial(defaultdict, int)))
for row in cursor.fetchall():
connections[row[0]][row[1]][row[2]] += 1
return connections
def _clean_mins(request, cursor, project_id):
min_pre = int(request.POST.get('min_pre', -1))
min_post = int(request.POST.get('min_post', -1))
if -1 == min_pre and -1 == min_post:
raise Exception("Can't grow: not retrieving any pre or post.")
if -1 == min_pre:
min_pre = float('inf')
if -1 == min_post:
min_post = float('inf')
cursor.execute("SELECT relation_name, id FROM relation WHERE project_id = %s AND (relation_name = 'presynaptic_to' OR relation_name = 'postsynaptic_to')" % int(project_id))
relations = dict(cursor.fetchall())
mins = {}
mins[relations['presynaptic_to']] = min_post # inverted: all postsynaptic to the set
mins[relations['postsynaptic_to']] = min_pre # inverted: all presynaptic to the set
return mins, relations
@requires_user_role([UserRole.Annotate, UserRole.Browse])
def circles_of_hell(request, project_id=None):
""" Given a set of one or more skeleton IDs, find all skeletons that connect
them (n_circles=1), or that connect to others that connect them (n_circles=2), etc.
Returns a list of unique skeleton IDs that exclude the ones provided as argument.
"""
n_circles = int(request.POST.get('n_circles', 1))
if n_circles < 1:
raise Exception("Requires at least one circle.")
first_circle = set(int(v) for k,v in request.POST.iteritems() if k.startswith('skeleton_ids['))
if not first_circle:
raise Exception("No skeletons were provided.")
cursor = connection.cursor()
mins, _ = _clean_mins(request, cursor, int(project_id))
current_circle = first_circle
all_circles = first_circle
while n_circles > 0 and current_circle:
n_circles -= 1
connections = _next_circle(current_circle, cursor)
next_circle = set(skID for c in connections.itervalues() for relationID, cs in c.iteritems() for skID, count in cs.iteritems() if count >= mins[relationID])
current_circle = next_circle - all_circles
all_circles = all_circles.union(next_circle)
skeleton_ids = tuple(all_circles - first_circle)
return HttpResponse(json.dumps([skeleton_ids, _neuronnames(skeleton_ids, project_id)]))
@requires_user_role([UserRole.Annotate, UserRole.Browse])
def find_directed_paths(request, project_id=None):
""" Given a set of two or more skeleton IDs, find directed paths of connected neurons between them, for a maximum inner path length as given (i.e. origin and destination not counted). A directed path means that all edges are of the same kind, e.g. presynaptic_to. """
sources = set(int(v) for k,v in request.POST.iteritems() if k.startswith('skeleton_ids['))
if len(sources) < 2:
raise Exception('Need at least 2 skeleton IDs to find directed paths!')
path_length = int(request.POST.get('n_circles', 1))
cursor = connection.cursor()
mins, relations = _clean_mins(request, cursor, int(project_id))
presynaptic_to = relations['presynaptic_to']
graph = nx.DiGraph()
next_sources = sources
all_sources = sources
length = path_length
def rev_args(fn):
def f(arg1, arg2):
fn(arg2, arg1)
return f
# Create a graph by growing the sources
while length > 0 and next_sources:
length -= 1
next_circles = _next_circle(next_sources, cursor)
next_sources = set()
for skid1, c in next_circles.iteritems():
for relationID, targets in c.iteritems():
threshold = mins[relationID]
add_edge = graph.add_edge if relationID == presynaptic_to else rev_args(graph.add_edge)
for skid2, count in targets.iteritems():
if count < threshold:
continue
add_edge(skid1, skid2)
next_sources.add(skid2)
next_sources = next_sources - all_sources
all_sources = all_sources.union(next_sources)
# Find all directed paths between all pairs of inputs
all_paths = []
for start, end in combinations(sources, 2):
for paths in [nx.all_simple_paths(graph, start, end, path_length + 1),
nx.all_simple_paths(graph, end, start, path_length + 1)]:
for path in paths:
all_paths.append(path)
return HttpResponse(json.dumps(all_paths))
|
agpl-3.0
|
[
646,
2022,
199,
646,
24313,
465,
8484,
199,
199,
504,
7975,
492,
15821,
199,
504,
5055,
492,
10018,
199,
504,
9143,
492,
7417,
199,
199,
504,
1639,
14,
697,
492,
1950,
199,
504,
1639,
14,
1014,
492,
6183,
199,
199,
504,
6230,
391,
344,
14,
992,
492,
2876,
7422,
199,
504,
6230,
391,
344,
14,
2785,
14,
11725,
492,
5074,
63,
751,
63,
3756,
199,
504,
6230,
391,
344,
14,
2785,
14,
29250,
492,
485,
32054,
1247,
199,
199,
318,
485,
2184,
63,
11001,
8,
29250,
63,
409,
12,
3920,
304,
272,
408,
1432,
282,
2600,
402,
30537,
11449,
315,
314,
30537,
63,
409,
8118,
282,
2600,
402,
8539,
30537,
83,
8118,
4212,
5002,
6947,
1041,
272,
3920,
14,
2526,
10505,
272,
10468,
14415,
17,
14,
29250,
63,
344,
12,
14415,
17,
14,
5690,
63,
344,
12,
14415,
18,
14,
29250,
63,
344,
272,
4442,
307,
3441,
380,
63,
11815,
14415,
17,
12,
268,
307,
3441,
380,
63,
11815,
14415,
18,
272,
6038,
14415,
17,
14,
29250,
63,
344,
315,
4366,
83,
9,
489,
2401,
14415,
17,
14,
11815,
63,
344,
275,
14415,
18,
14,
11815,
63,
344,
489,
2401,
14415,
17,
14,
29250,
63,
344,
1137,
14415,
18,
14,
29250,
63,
344,
489,
2401,
14415,
17,
14,
5690,
63,
344,
1137,
14415,
18,
14,
5690,
63,
344,
272,
1449,
450,
12814,
904,
8,
1130,
8,
495,
12,
30537,
63,
409,
1724,
272,
6947,
275,
10018,
8,
6672,
8,
21501,
12,
7417,
8,
21501,
12,
1109,
1724,
272,
367,
1962,
315,
3920,
14,
10174,
837,
267,
6947,
59,
1143,
59,
16,
22235,
1143,
59,
17,
22235,
1143,
59,
18,
2677,
847,
413,
272,
372,
6947,
199,
199,
318,
485,
3118,
63,
29361,
8,
1069,
12,
3920,
12,
2199,
63,
344,
304,
272,
1748,
63,
657,
221,
275,
1109,
8,
1069,
14,
4030,
14,
362,
360,
827,
63,
657,
297,
221,
446,
17,
430,
272,
1748,
63,
1932,
275,
1109,
8,
1069,
14,
4030,
14,
362,
360,
827,
63,
1932,
297,
446,
17,
430,
339,
340,
446,
17,
508,
1748,
63,
657,
436,
446,
17,
508,
1748,
63,
1932,
26,
267,
746,
2186,
480,
6049,
1133,
20772,
26,
440,
23812,
1263,
876,
503,
2963,
2685,
272,
340,
446,
17,
508,
1748,
63,
657,
26,
267,
1748,
63,
657,
275,
2069,
360,
4904,
358,
272,
340,
446,
17,
508,
1748,
63,
1932,
26,
267,
1748,
63,
1932,
275,
2069,
360,
4904,
358,
339,
3920,
14,
2526,
480,
4859,
5850,
63,
354,
12,
1305,
4442,
5850,
6038,
2199,
63,
344,
275,
450,
83,
2401,
334,
5690,
63,
354,
275,
283,
24919,
1236,
439,
764,
63,
475,
7,
1549,
5850,
63,
354,
275,
283,
1932,
9466,
439,
764,
63,
475,
19124,
450,
1109,
8,
1715,
63,
344,
430,
272,
16109,
275,
1211,
8,
3937,
14,
10174,
1012,
272,
1748,
83,
275,
1052,
272,
1748,
83,
59,
15741,
459,
24919,
1236,
439,
764,
63,
475,
6538,
221,
275,
1748,
63,
1932,
327,
29402,
26,
1006,
2963,
9466,
439,
764,
370,
314,
663,
272,
1748,
83,
59,
15741,
459,
1932,
9466,
439,
764,
63,
475,
6538,
275,
1748,
63,
657,
327,
29402,
26,
1006,
25210,
1236,
439,
764,
370,
314,
663,
272,
372,
1748,
83,
12,
16109,
199,
199,
32,
6537,
63,
751,
63,
3756,
779,
1899,
7422,
14,
21761,
323,
12,
2876,
7422,
14,
24149,
566,
199,
318,
17990,
83,
63,
1618,
63,
72,
1697,
8,
1069,
12,
2199,
63,
344,
29,
403,
304,
272,
408,
9138,
282,
663,
402,
1373,
503,
1655,
30537,
11449,
12,
2342,
1006,
30537,
83,
626,
4907,
272,
3062,
334,
78,
63,
6092,
2978,
29,
17,
395,
503,
626,
4907,
370,
11789,
626,
4907,
3062,
334,
78,
63,
6092,
2978,
29,
18,
395,
5423,
14,
272,
1803,
282,
769,
402,
3747,
30537,
11449,
626,
5760,
314,
7869,
2741,
465,
1423,
14,
272,
408,
272,
302,
63,
6092,
2978,
275,
1109,
8,
1069,
14,
4030,
14,
362,
360,
78,
63,
6092,
2978,
297,
413,
430,
272,
340,
302,
63,
6092,
2978,
665,
413,
26,
267,
746,
2186,
480,
18153,
737,
5210,
1373,
17990,
2685,
339,
1642,
63,
11001,
275,
663,
8,
442,
8,
86,
9,
367,
1022,
12,
86,
315,
1056,
14,
4030,
14,
4611,
342,
340,
1022,
14,
2460,
360,
29250,
63,
1580,
59,
1333,
339,
340,
440,
1642,
63,
11001,
26,
267,
746,
2186,
480,
1944,
30537,
83,
4898,
2741,
2685,
339,
3920,
275,
1950,
14,
3937,
342,
272,
1748,
83,
12,
485,
275,
485,
3118,
63,
29361,
8,
1069,
12,
3920,
12,
1109,
8,
1715,
63,
344,
430,
339,
1453,
63,
11001,
275,
1642,
63,
11001,
272,
1006,
63,
6092,
2978,
275,
1642,
63,
11001,
339,
1830,
302,
63,
6092,
2978,
690,
378,
436,
1453,
63,
11001,
26,
267,
302,
63,
6092,
2978,
4862,
413,
267,
6947,
275,
485,
2184,
63,
11001,
8,
1818,
63,
11001,
12,
3920,
9,
267,
2163,
63,
11001,
275,
663,
8,
1339,
998,
367,
286,
315,
6947,
14,
13012,
342,
367,
5850,
998,
12,
7117,
315,
286,
14,
4611,
342,
367,
2386,
998,
12,
2338,
315,
7117,
14,
4611,
342,
340,
2338,
2356,
1748,
83,
59,
5690,
998,
566,
267,
1453,
63,
11001,
275,
2163,
63,
11001,
446,
1006,
63,
6092,
2978,
267,
1006,
63,
6092,
2978,
275,
1006,
63,
6092,
2978,
14,
8888,
8,
2184,
63,
11001,
9,
339,
30537,
63,
1580,
275,
2008,
8,
452,
63,
6092,
2978,
446,
1642,
63,
11001,
9,
272,
372,
6183,
8,
1001,
14,
4180,
779,
29250,
63,
1580,
12,
485,
32054,
1247,
8,
29250,
63,
1580,
12,
2199,
63,
344,
19563,
199,
199,
32,
6537,
63,
751,
63,
3756,
779,
1899,
7422,
14,
21761,
323,
12,
2876,
7422,
14,
24149,
566,
199,
318,
2342,
63,
12080,
63,
3771,
8,
1069,
12,
2199,
63,
344,
29,
403,
304,
272,
408,
9138,
282,
663,
402,
2877,
503,
1655,
30537,
11449,
12,
2342,
23667,
3792,
402,
8539,
1279,
32073,
3382,
3062,
12,
367,
282,
5696,
6506,
931,
2582,
465,
1627,
334,
73,
14,
69,
14,
6330,
436,
5724,
440,
31662,
680,
437,
23667,
931,
4910,
626,
1006,
8207,
787,
402,
314,
2011,
4928,
12,
325,
14,
71,
14,
25210,
1236,
439,
764,
63,
475,
14,
408,
339,
5274,
275,
663,
8,
442
] |
[
2022,
199,
646,
24313,
465,
8484,
199,
199,
504,
7975,
492,
15821,
199,
504,
5055,
492,
10018,
199,
504,
9143,
492,
7417,
199,
199,
504,
1639,
14,
697,
492,
1950,
199,
504,
1639,
14,
1014,
492,
6183,
199,
199,
504,
6230,
391,
344,
14,
992,
492,
2876,
7422,
199,
504,
6230,
391,
344,
14,
2785,
14,
11725,
492,
5074,
63,
751,
63,
3756,
199,
504,
6230,
391,
344,
14,
2785,
14,
29250,
492,
485,
32054,
1247,
199,
199,
318,
485,
2184,
63,
11001,
8,
29250,
63,
409,
12,
3920,
304,
272,
408,
1432,
282,
2600,
402,
30537,
11449,
315,
314,
30537,
63,
409,
8118,
282,
2600,
402,
8539,
30537,
83,
8118,
4212,
5002,
6947,
1041,
272,
3920,
14,
2526,
10505,
272,
10468,
14415,
17,
14,
29250,
63,
344,
12,
14415,
17,
14,
5690,
63,
344,
12,
14415,
18,
14,
29250,
63,
344,
272,
4442,
307,
3441,
380,
63,
11815,
14415,
17,
12,
268,
307,
3441,
380,
63,
11815,
14415,
18,
272,
6038,
14415,
17,
14,
29250,
63,
344,
315,
4366,
83,
9,
489,
2401,
14415,
17,
14,
11815,
63,
344,
275,
14415,
18,
14,
11815,
63,
344,
489,
2401,
14415,
17,
14,
29250,
63,
344,
1137,
14415,
18,
14,
29250,
63,
344,
489,
2401,
14415,
17,
14,
5690,
63,
344,
1137,
14415,
18,
14,
5690,
63,
344,
272,
1449,
450,
12814,
904,
8,
1130,
8,
495,
12,
30537,
63,
409,
1724,
272,
6947,
275,
10018,
8,
6672,
8,
21501,
12,
7417,
8,
21501,
12,
1109,
1724,
272,
367,
1962,
315,
3920,
14,
10174,
837,
267,
6947,
59,
1143,
59,
16,
22235,
1143,
59,
17,
22235,
1143,
59,
18,
2677,
847,
413,
272,
372,
6947,
199,
199,
318,
485,
3118,
63,
29361,
8,
1069,
12,
3920,
12,
2199,
63,
344,
304,
272,
1748,
63,
657,
221,
275,
1109,
8,
1069,
14,
4030,
14,
362,
360,
827,
63,
657,
297,
221,
446,
17,
430,
272,
1748,
63,
1932,
275,
1109,
8,
1069,
14,
4030,
14,
362,
360,
827,
63,
1932,
297,
446,
17,
430,
339,
340,
446,
17,
508,
1748,
63,
657,
436,
446,
17,
508,
1748,
63,
1932,
26,
267,
746,
2186,
480,
6049,
1133,
20772,
26,
440,
23812,
1263,
876,
503,
2963,
2685,
272,
340,
446,
17,
508,
1748,
63,
657,
26,
267,
1748,
63,
657,
275,
2069,
360,
4904,
358,
272,
340,
446,
17,
508,
1748,
63,
1932,
26,
267,
1748,
63,
1932,
275,
2069,
360,
4904,
358,
339,
3920,
14,
2526,
480,
4859,
5850,
63,
354,
12,
1305,
4442,
5850,
6038,
2199,
63,
344,
275,
450,
83,
2401,
334,
5690,
63,
354,
275,
283,
24919,
1236,
439,
764,
63,
475,
7,
1549,
5850,
63,
354,
275,
283,
1932,
9466,
439,
764,
63,
475,
19124,
450,
1109,
8,
1715,
63,
344,
430,
272,
16109,
275,
1211,
8,
3937,
14,
10174,
1012,
272,
1748,
83,
275,
1052,
272,
1748,
83,
59,
15741,
459,
24919,
1236,
439,
764,
63,
475,
6538,
221,
275,
1748,
63,
1932,
327,
29402,
26,
1006,
2963,
9466,
439,
764,
370,
314,
663,
272,
1748,
83,
59,
15741,
459,
1932,
9466,
439,
764,
63,
475,
6538,
275,
1748,
63,
657,
327,
29402,
26,
1006,
25210,
1236,
439,
764,
370,
314,
663,
272,
372,
1748,
83,
12,
16109,
199,
199,
32,
6537,
63,
751,
63,
3756,
779,
1899,
7422,
14,
21761,
323,
12,
2876,
7422,
14,
24149,
566,
199,
318,
17990,
83,
63,
1618,
63,
72,
1697,
8,
1069,
12,
2199,
63,
344,
29,
403,
304,
272,
408,
9138,
282,
663,
402,
1373,
503,
1655,
30537,
11449,
12,
2342,
1006,
30537,
83,
626,
4907,
272,
3062,
334,
78,
63,
6092,
2978,
29,
17,
395,
503,
626,
4907,
370,
11789,
626,
4907,
3062,
334,
78,
63,
6092,
2978,
29,
18,
395,
5423,
14,
272,
1803,
282,
769,
402,
3747,
30537,
11449,
626,
5760,
314,
7869,
2741,
465,
1423,
14,
272,
408,
272,
302,
63,
6092,
2978,
275,
1109,
8,
1069,
14,
4030,
14,
362,
360,
78,
63,
6092,
2978,
297,
413,
430,
272,
340,
302,
63,
6092,
2978,
665,
413,
26,
267,
746,
2186,
480,
18153,
737,
5210,
1373,
17990,
2685,
339,
1642,
63,
11001,
275,
663,
8,
442,
8,
86,
9,
367,
1022,
12,
86,
315,
1056,
14,
4030,
14,
4611,
342,
340,
1022,
14,
2460,
360,
29250,
63,
1580,
59,
1333,
339,
340,
440,
1642,
63,
11001,
26,
267,
746,
2186,
480,
1944,
30537,
83,
4898,
2741,
2685,
339,
3920,
275,
1950,
14,
3937,
342,
272,
1748,
83,
12,
485,
275,
485,
3118,
63,
29361,
8,
1069,
12,
3920,
12,
1109,
8,
1715,
63,
344,
430,
339,
1453,
63,
11001,
275,
1642,
63,
11001,
272,
1006,
63,
6092,
2978,
275,
1642,
63,
11001,
339,
1830,
302,
63,
6092,
2978,
690,
378,
436,
1453,
63,
11001,
26,
267,
302,
63,
6092,
2978,
4862,
413,
267,
6947,
275,
485,
2184,
63,
11001,
8,
1818,
63,
11001,
12,
3920,
9,
267,
2163,
63,
11001,
275,
663,
8,
1339,
998,
367,
286,
315,
6947,
14,
13012,
342,
367,
5850,
998,
12,
7117,
315,
286,
14,
4611,
342,
367,
2386,
998,
12,
2338,
315,
7117,
14,
4611,
342,
340,
2338,
2356,
1748,
83,
59,
5690,
998,
566,
267,
1453,
63,
11001,
275,
2163,
63,
11001,
446,
1006,
63,
6092,
2978,
267,
1006,
63,
6092,
2978,
275,
1006,
63,
6092,
2978,
14,
8888,
8,
2184,
63,
11001,
9,
339,
30537,
63,
1580,
275,
2008,
8,
452,
63,
6092,
2978,
446,
1642,
63,
11001,
9,
272,
372,
6183,
8,
1001,
14,
4180,
779,
29250,
63,
1580,
12,
485,
32054,
1247,
8,
29250,
63,
1580,
12,
2199,
63,
344,
19563,
199,
199,
32,
6537,
63,
751,
63,
3756,
779,
1899,
7422,
14,
21761,
323,
12,
2876,
7422,
14,
24149,
566,
199,
318,
2342,
63,
12080,
63,
3771,
8,
1069,
12,
2199,
63,
344,
29,
403,
304,
272,
408,
9138,
282,
663,
402,
2877,
503,
1655,
30537,
11449,
12,
2342,
23667,
3792,
402,
8539,
1279,
32073,
3382,
3062,
12,
367,
282,
5696,
6506,
931,
2582,
465,
1627,
334,
73,
14,
69,
14,
6330,
436,
5724,
440,
31662,
680,
437,
23667,
931,
4910,
626,
1006,
8207,
787,
402,
314,
2011,
4928,
12,
325,
14,
71,
14,
25210,
1236,
439,
764,
63,
475,
14,
408,
339,
5274,
275,
663,
8,
442,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
niranjan94/open-event-orga-server
|
tests/unittests/api/test_get_list_queries.py
|
8
|
5466
|
import json
import unittest
from app import current_app as app
from app.helpers.data import update_role_to_admin
from tests.unittests.api.utils import get_path, create_event
from tests.unittests.auth_helper import register, login
from tests.unittests.setup_database import Setup
from tests.unittests.utils import OpenEventTestCase
from utils_post_data import *
class TestGetListQueries(OpenEventTestCase):
"""
Test Get List Queries
"""
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'test@example.com', u'test')
update_role_to_admin({'admin_perm': 'isAdmin'}, user_id=1)
create_event(name='TestEvent0', creator_email='test@example.com')
def _post(self, path, data):
"""
send a post request to a url
"""
resp = self.app.post(
path,
data=json.dumps(data),
headers={'content-type': 'application/json'}
)
self.assertEqual(resp.status_code, 201)
return resp
def test_event_queries(self):
with app.test_request_context():
login(self.app, u'test@example.com', u'test')
path = get_path()
resp = self._post(path, POST_EVENT_DATA)
# check no return
resp = self.app.get(path + '?state=r@nd0m')
self.assertEqual(len(resp.data), 3, msg=resp.data)
# check case-insensitive search
resp = self.app.get(path + '?contains=test')
self.assertEqual(resp.status_code, 200)
self.assertEqual(len(json.loads(resp.data)), 2)
# check queryset forwarding
resp = self.app.get(path + '?contains=test&state=r@nd0m')
self.assertEqual(len(resp.data), 3)
def test_event_time_queries(self):
with app.test_request_context():
login(self.app, u'test@example.com', u'test')
path = get_path()
# Event is of Apr 16
resp = self.app.get(path + '?end_time_lt=2015-12-31T23:59:59')
self.assertEqual(len(resp.data), 3, msg=resp.data)
resp = self.app.get(path + '?start_time_gt=2015-12-31T23:59:59')
self.assertIn('TestEvent0', resp.data)
# add one more event of May 16
resp = self._post(path, POST_EVENT_DATA)
# test
resp = self.app.get(path + '?start_time_lt=2016-05-31T23:59:59')
self.assertEqual(len(json.loads(resp.data)), 2, msg=resp.data)
resp = self.app.get(path + '?end_time_gt=2016-05-01T00:00:00')
self.assertIn('"TestEvent"', resp.data)
self.assertNotIn('TestEvent0', resp.data)
def test_event_location_queries(self):
with app.test_request_context():
login(self.app, u'test@example.com', u'test')
path = get_path()
resp = self._post(path, POST_EVENT_DATA)
# check location smart queries
resp = self.app.get(path + '?location=SomeBuilding,Berlin')
self.assertIn('Berlin', resp.data)
# add another event
data = POST_EVENT_DATA.copy()
data['location_name'] = 'SomeBuilding'
data['searchable_location_name'] = 'SomeBuilding'
self._post(path, data)
# get
resp = self.app.get(path + '?location=SomeBuilding,Berlin')
self.assertEqual(resp.status_code, 200)
self.assertIn('SomeBuilding', resp.data)
self.assertIn('Berlin', resp.data)
def test_session_time_queries(self):
with app.test_request_context():
path = get_path(1, 'sessions')
resp = self._post(path, POST_SESSION_DATA)
# 2016-05-30 8:47 to 9:47
# normal
resp = self.app.get(path)
self.assertIn('TestSession', resp.data)
# check results when query exists
for _ in ['start_time_lt', 'end_time_lt']:
resp = self.app.get(path + '?%s=2014-05-12T00:00:00' % _)
self.assertNotIn('TestSession', resp.data)
resp = self.app.get(path + '?%s=2017-05-12T00:00:00' % _)
self.assertIn('TestSession', resp.data)
for _ in ['start_time_gt', 'end_time_gt']:
resp = self.app.get(path + '?%s=2018-05-12T00:00:00' % _)
self.assertNotIn('TestSession', resp.data)
resp = self.app.get(path + '?%s=2015-05-12T00:00:00' % _)
self.assertIn('TestSession', resp.data)
def test_session_order_by(self):
with app.test_request_context():
path = get_path(1, 'sessions')
self._post(path, POST_SESSION_DATA)
# 2016-05-30 8:47 to 9:47
new_data = POST_SESSION_DATA.copy()
new_data['start_time'] = '2016-05-30T10:47:37'
new_data['end_time'] = '2016-05-30T11:47:37'
self._post(path, new_data)
# check ordering
data = json.loads(self.app.get(path + '?order_by=start_time.asc').data)
self.assertEqual(data[0]['id'], 1)
self.assertEqual(data[1]['id'], 2)
# order reverse
data = json.loads(self.app.get(path + '?order_by=start_time.desc').data)
self.assertEqual(data[0]['id'], 2)
self.assertEqual(data[1]['id'], 1)
if __name__ == '__main__':
unittest.main()
|
gpl-3.0
|
[
646,
2022,
199,
646,
2882,
199,
199,
504,
1145,
492,
1453,
63,
571,
465,
1145,
199,
504,
1145,
14,
7546,
14,
576,
492,
1678,
63,
3756,
63,
475,
63,
2113,
199,
504,
2295,
14,
31053,
14,
1246,
14,
1208,
492,
664,
63,
515,
12,
1218,
63,
1430,
199,
504,
2295,
14,
31053,
14,
1178,
63,
3676,
492,
2274,
12,
4676,
199,
504,
2295,
14,
31053,
14,
2758,
63,
4659,
492,
12439,
199,
504,
2295,
14,
31053,
14,
1208,
492,
3232,
2390,
1746,
199,
504,
3778,
63,
1932,
63,
576,
492,
627,
421,
199,
533,
1379,
1002,
1296,
13611,
8,
4299,
2390,
1746,
304,
272,
408,
272,
1379,
2372,
3820,
5843,
5460,
272,
408,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
571,
275,
12439,
14,
981,
63,
571,
342,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
2274,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
1678,
63,
3756,
63,
475,
63,
2113,
3252,
2113,
63,
8220,
356,
283,
374,
4880,
2267,
922,
63,
344,
29,
17,
9,
288,
1218,
63,
1430,
8,
354,
534,
774,
2390,
16,
297,
14875,
63,
2123,
534,
396,
32,
2694,
14,
957,
358,
339,
347,
485,
1932,
8,
277,
12,
931,
12,
666,
304,
267,
408,
267,
3222,
282,
2963,
1056,
370,
282,
1166,
267,
408,
267,
3085,
275,
291,
14,
571,
14,
1932,
8,
288,
931,
12,
288,
666,
29,
1001,
14,
4180,
8,
576,
395,
288,
2323,
3713,
1317,
13,
466,
356,
283,
3578,
15,
1001,
936,
267,
776,
267,
291,
14,
629,
8,
4518,
14,
1205,
63,
600,
12,
1784,
9,
267,
372,
3085,
339,
347,
511,
63,
1430,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
4676,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
931,
275,
664,
63,
515,
342,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
8193,
63,
3998,
9,
288,
327,
1104,
949,
372,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
929,
29,
82,
32,
977,
16,
77,
358,
288,
291,
14,
629,
8,
552,
8,
4518,
14,
576,
395,
650,
12,
1499,
29,
4518,
14,
576,
9,
288,
327,
1104,
1930,
13,
15851,
2754,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
6134,
29,
396,
358,
288,
291,
14,
629,
8,
4518,
14,
1205,
63,
600,
12,
1926,
9,
288,
291,
14,
629,
8,
552,
8,
1001,
14,
3640,
8,
4518,
14,
576,
1826,
499,
9,
288,
327,
1104,
7594,
24119,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
6134,
29,
396,
6,
929,
29,
82,
32,
977,
16,
77,
358,
288,
291,
14,
629,
8,
552,
8,
4518,
14,
576,
395,
650,
9,
339,
347,
511,
63,
1430,
63,
521,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
4676,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
931,
275,
664,
63,
515,
342,
288,
327,
6763,
365,
402,
437,
2700,
3193,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
500,
63,
521,
63,
4116,
29,
7806,
13,
713,
13,
2192,
52,
1789,
26,
1427,
26,
1427,
358,
288,
291,
14,
629,
8,
552,
8,
4518,
14,
576,
395,
650,
12,
1499,
29,
4518,
14,
576,
9,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
928,
63,
521,
63,
3308,
29,
7806,
13,
713,
13,
2192,
52,
1789,
26,
1427,
26,
1427,
358,
288,
291,
14,
4080,
360,
774,
2390,
16,
297,
3085,
14,
576,
9,
288,
327,
1050,
1373,
1655,
1566,
402,
10162,
3193,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
8193,
63,
3998,
9,
288,
327,
511,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
928,
63,
521,
63,
4116,
29,
9261,
13,
1717,
13,
2192,
52,
1789,
26,
1427,
26,
1427,
358,
288,
291,
14,
629,
8,
552,
8,
1001,
14,
3640,
8,
4518,
14,
576,
1826,
499,
12,
1499,
29,
4518,
14,
576,
9,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
500,
63,
521,
63,
3308,
29,
9261,
13,
1717,
13,
614,
52,
383,
26,
383,
26,
383,
358,
288,
291,
14,
4080,
14088,
774,
2390,
6949,
3085,
14,
576,
9,
288,
291,
14,
8795,
360,
774,
2390,
16,
297,
3085,
14,
576,
9,
339,
347,
511,
63,
1430,
63,
1985,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
4676,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
931,
275,
664,
63,
515,
342,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
8193,
63,
3998,
9,
288,
327,
1104,
2909,
11179,
9212,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
1985,
29,
7700,
16461,
12,
24947,
472,
358,
288,
291,
14,
4080,
360,
24947,
472,
297,
3085,
14,
576,
9,
288,
327,
1050,
4573,
1566,
288,
666,
275,
8761,
63,
8193,
63,
3998,
14,
1574,
342,
288,
666,
459,
1985,
63,
354,
418,
275,
283,
7700,
16461,
7,
288,
666,
459,
1733,
461,
63,
1985,
63,
354,
418,
275,
283,
7700,
16461,
7,
288,
291,
423,
1932,
8,
515,
12,
666,
9,
288,
327,
664,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
1985,
29,
7700,
16461,
12,
24947,
472,
358,
288,
291,
14,
629,
8,
4518,
14,
1205,
63,
600,
12,
1926,
9,
288,
291,
14,
4080,
360,
7700,
16461,
297,
3085,
14,
576,
9,
288,
291,
14,
4080,
360,
24947,
472,
297,
3085,
14,
576,
9,
339,
347,
511,
63,
1730,
63,
521,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
931,
275,
664,
63,
515,
8,
17,
12,
283,
11676,
358,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
12763,
63,
3998,
9,
288,
327
] |
[
2022,
199,
646,
2882,
199,
199,
504,
1145,
492,
1453,
63,
571,
465,
1145,
199,
504,
1145,
14,
7546,
14,
576,
492,
1678,
63,
3756,
63,
475,
63,
2113,
199,
504,
2295,
14,
31053,
14,
1246,
14,
1208,
492,
664,
63,
515,
12,
1218,
63,
1430,
199,
504,
2295,
14,
31053,
14,
1178,
63,
3676,
492,
2274,
12,
4676,
199,
504,
2295,
14,
31053,
14,
2758,
63,
4659,
492,
12439,
199,
504,
2295,
14,
31053,
14,
1208,
492,
3232,
2390,
1746,
199,
504,
3778,
63,
1932,
63,
576,
492,
627,
421,
199,
533,
1379,
1002,
1296,
13611,
8,
4299,
2390,
1746,
304,
272,
408,
272,
1379,
2372,
3820,
5843,
5460,
272,
408,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
571,
275,
12439,
14,
981,
63,
571,
342,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
2274,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
1678,
63,
3756,
63,
475,
63,
2113,
3252,
2113,
63,
8220,
356,
283,
374,
4880,
2267,
922,
63,
344,
29,
17,
9,
288,
1218,
63,
1430,
8,
354,
534,
774,
2390,
16,
297,
14875,
63,
2123,
534,
396,
32,
2694,
14,
957,
358,
339,
347,
485,
1932,
8,
277,
12,
931,
12,
666,
304,
267,
408,
267,
3222,
282,
2963,
1056,
370,
282,
1166,
267,
408,
267,
3085,
275,
291,
14,
571,
14,
1932,
8,
288,
931,
12,
288,
666,
29,
1001,
14,
4180,
8,
576,
395,
288,
2323,
3713,
1317,
13,
466,
356,
283,
3578,
15,
1001,
936,
267,
776,
267,
291,
14,
629,
8,
4518,
14,
1205,
63,
600,
12,
1784,
9,
267,
372,
3085,
339,
347,
511,
63,
1430,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
4676,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
931,
275,
664,
63,
515,
342,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
8193,
63,
3998,
9,
288,
327,
1104,
949,
372,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
929,
29,
82,
32,
977,
16,
77,
358,
288,
291,
14,
629,
8,
552,
8,
4518,
14,
576,
395,
650,
12,
1499,
29,
4518,
14,
576,
9,
288,
327,
1104,
1930,
13,
15851,
2754,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
6134,
29,
396,
358,
288,
291,
14,
629,
8,
4518,
14,
1205,
63,
600,
12,
1926,
9,
288,
291,
14,
629,
8,
552,
8,
1001,
14,
3640,
8,
4518,
14,
576,
1826,
499,
9,
288,
327,
1104,
7594,
24119,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
6134,
29,
396,
6,
929,
29,
82,
32,
977,
16,
77,
358,
288,
291,
14,
629,
8,
552,
8,
4518,
14,
576,
395,
650,
9,
339,
347,
511,
63,
1430,
63,
521,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
4676,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
931,
275,
664,
63,
515,
342,
288,
327,
6763,
365,
402,
437,
2700,
3193,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
500,
63,
521,
63,
4116,
29,
7806,
13,
713,
13,
2192,
52,
1789,
26,
1427,
26,
1427,
358,
288,
291,
14,
629,
8,
552,
8,
4518,
14,
576,
395,
650,
12,
1499,
29,
4518,
14,
576,
9,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
928,
63,
521,
63,
3308,
29,
7806,
13,
713,
13,
2192,
52,
1789,
26,
1427,
26,
1427,
358,
288,
291,
14,
4080,
360,
774,
2390,
16,
297,
3085,
14,
576,
9,
288,
327,
1050,
1373,
1655,
1566,
402,
10162,
3193,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
8193,
63,
3998,
9,
288,
327,
511,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
928,
63,
521,
63,
4116,
29,
9261,
13,
1717,
13,
2192,
52,
1789,
26,
1427,
26,
1427,
358,
288,
291,
14,
629,
8,
552,
8,
1001,
14,
3640,
8,
4518,
14,
576,
1826,
499,
12,
1499,
29,
4518,
14,
576,
9,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
500,
63,
521,
63,
3308,
29,
9261,
13,
1717,
13,
614,
52,
383,
26,
383,
26,
383,
358,
288,
291,
14,
4080,
14088,
774,
2390,
6949,
3085,
14,
576,
9,
288,
291,
14,
8795,
360,
774,
2390,
16,
297,
3085,
14,
576,
9,
339,
347,
511,
63,
1430,
63,
1985,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
4676,
8,
277,
14,
571,
12,
399,
1133,
597,
32,
2694,
14,
957,
297,
399,
1133,
597,
358,
288,
931,
275,
664,
63,
515,
342,
288,
3085,
275,
291,
423,
1932,
8,
515,
12,
8761,
63,
8193,
63,
3998,
9,
288,
327,
1104,
2909,
11179,
9212,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
1985,
29,
7700,
16461,
12,
24947,
472,
358,
288,
291,
14,
4080,
360,
24947,
472,
297,
3085,
14,
576,
9,
288,
327,
1050,
4573,
1566,
288,
666,
275,
8761,
63,
8193,
63,
3998,
14,
1574,
342,
288,
666,
459,
1985,
63,
354,
418,
275,
283,
7700,
16461,
7,
288,
666,
459,
1733,
461,
63,
1985,
63,
354,
418,
275,
283,
7700,
16461,
7,
288,
291,
423,
1932,
8,
515,
12,
666,
9,
288,
327,
664,
288,
3085,
275,
291,
14,
571,
14,
362,
8,
515,
435,
8720,
1985,
29,
7700,
16461,
12,
24947,
472,
358,
288,
291,
14,
629,
8,
4518,
14,
1205,
63,
600,
12,
1926,
9,
288,
291,
14,
4080,
360,
7700,
16461,
297,
3085,
14,
576,
9,
288,
291,
14,
4080,
360,
24947,
472,
297,
3085,
14,
576,
9,
339,
347,
511,
63,
1730,
63,
521,
63,
10590,
8,
277,
304,
267,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
288,
931,
275,
664,
63,
515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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mbayon/TFG-MachineLearning
|
vbig/lib/python2.7/site-packages/scipy/special/tests/test_spence.py
|
26
|
1165
|
from __future__ import division, print_function, absolute_import
import numpy as np
from numpy import sqrt, log, pi
from scipy.special._testutils import FuncData
from scipy.special import spence
def test_consistency():
# Make sure the implementation of spence for real arguments
# agrees with the implementation of spence for imaginary arguments.
x = np.logspace(-30, 300, 200)
dataset = np.vstack((x + 0j, spence(x))).T
FuncData(spence, dataset, 0, 1, rtol=1e-14).check()
def test_special_points():
# Check against known values of Spence's function.
phi = (1 + sqrt(5))/2
dataset = [(1, 0),
(2, -pi**2/12),
(0.5, pi**2/12 - log(2)**2/2),
(0, pi**2/6),
(-1, pi**2/4 - 1j*pi*log(2)),
((-1 + sqrt(5))/2, pi**2/15 - log(phi)**2),
((3 - sqrt(5))/2, pi**2/10 - log(phi)**2),
(phi, -pi**2/15 + log(phi)**2/2),
# Corrected from Zagier, "The Dilogarithm Function"
((3 + sqrt(5))/2, -pi**2/10 - log(phi)**2)]
dataset = np.asarray(dataset)
FuncData(spence, dataset, 0, 1, rtol=1e-14).check()
|
mit
|
[
504,
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
492,
7452,
12,
943,
12,
6682,
199,
504,
7026,
14,
6664,
423,
396,
1208,
492,
28794,
1451,
199,
504,
7026,
14,
6664,
492,
308,
897,
301,
421,
199,
318,
511,
63,
20249,
837,
272,
327,
4155,
3238,
314,
4514,
402,
308,
897,
301,
367,
3363,
2368,
272,
327,
1839,
5710,
543,
314,
4514,
402,
308,
897,
301,
367,
30249,
2368,
14,
339,
671,
275,
980,
14,
7270,
1142,
2801,
1216,
12,
9601,
12,
1926,
9,
272,
4789,
275,
980,
14,
20221,
1332,
88,
435,
378,
74,
12,
308,
897,
301,
8,
88,
23261,
52,
272,
28794,
1451,
8,
681,
4894,
12,
4789,
12,
378,
12,
413,
12,
10561,
29,
17,
69,
13,
1079,
680,
1074,
342,
421,
199,
318,
511,
63,
6664,
63,
3438,
837,
272,
327,
2670,
6169,
6040,
1338,
402,
428,
897,
301,
1159,
805,
14,
339,
14524,
275,
334,
17,
435,
7452,
8,
21,
13342,
18,
272,
4789,
275,
3842,
17,
12,
378,
395,
2049,
334,
18,
12,
446,
1038,
538,
18,
15,
713,
395,
2049,
334,
16,
14,
21,
12,
6682,
538,
18,
15,
713,
446,
943,
8,
18,
6422,
18,
15,
18,
395,
2049,
334,
16,
12,
6682,
538,
18,
15,
22,
395,
2049,
5868,
17,
12,
6682,
538,
18,
15,
20,
446,
413,
74,
10,
1038,
10,
793,
8,
18,
1826,
2049,
334,
2801,
17,
435,
7452,
8,
21,
13342,
18,
12,
6682,
538,
18,
15,
1046,
446,
943,
8,
10909,
6422,
18,
395,
2049,
3666,
19,
446,
7452,
8,
21,
13342,
18,
12,
6682,
538,
18,
15,
709,
446,
943,
8,
10909,
6422,
18,
395,
2049,
334,
10909,
12,
446,
1038,
538,
18,
15,
1046,
435,
943,
8,
10909,
6422,
18,
15,
18,
395,
2049,
327,
7499,
7983,
687,
3107,
643,
4446,
12,
298,
1918,
3757,
793,
18327,
77,
6801,
2,
2049,
3666,
19,
435,
7452,
8,
21,
13342,
18,
12,
446,
1038,
538,
18,
15,
709,
446,
943,
8,
10909,
6422,
18,
1874,
339,
4789,
275,
980,
14,
8748,
8,
5214,
9,
272,
28794,
1451,
8,
681,
4894,
12,
4789,
12,
378,
12,
413,
12,
10561,
29,
17,
69,
13,
1079,
680,
1074,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
4629,
12,
870,
63,
1593,
12,
3679,
63,
646,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
492,
7452,
12,
943,
12,
6682,
199,
504,
7026,
14,
6664,
423,
396,
1208,
492,
28794,
1451,
199,
504,
7026,
14,
6664,
492,
308,
897,
301,
421,
199,
318,
511,
63,
20249,
837,
272,
327,
4155,
3238,
314,
4514,
402,
308,
897,
301,
367,
3363,
2368,
272,
327,
1839,
5710,
543,
314,
4514,
402,
308,
897,
301,
367,
30249,
2368,
14,
339,
671,
275,
980,
14,
7270,
1142,
2801,
1216,
12,
9601,
12,
1926,
9,
272,
4789,
275,
980,
14,
20221,
1332,
88,
435,
378,
74,
12,
308,
897,
301,
8,
88,
23261,
52,
272,
28794,
1451,
8,
681,
4894,
12,
4789,
12,
378,
12,
413,
12,
10561,
29,
17,
69,
13,
1079,
680,
1074,
342,
421,
199,
318,
511,
63,
6664,
63,
3438,
837,
272,
327,
2670,
6169,
6040,
1338,
402,
428,
897,
301,
1159,
805,
14,
339,
14524,
275,
334,
17,
435,
7452,
8,
21,
13342,
18,
272,
4789,
275,
3842,
17,
12,
378,
395,
2049,
334,
18,
12,
446,
1038,
538,
18,
15,
713,
395,
2049,
334,
16,
14,
21,
12,
6682,
538,
18,
15,
713,
446,
943,
8,
18,
6422,
18,
15,
18,
395,
2049,
334,
16,
12,
6682,
538,
18,
15,
22,
395,
2049,
5868,
17,
12,
6682,
538,
18,
15,
20,
446,
413,
74,
10,
1038,
10,
793,
8,
18,
1826,
2049,
334,
2801,
17,
435,
7452,
8,
21,
13342,
18,
12,
6682,
538,
18,
15,
1046,
446,
943,
8,
10909,
6422,
18,
395,
2049,
3666,
19,
446,
7452,
8,
21,
13342,
18,
12,
6682,
538,
18,
15,
709,
446,
943,
8,
10909,
6422,
18,
395,
2049,
334,
10909,
12,
446,
1038,
538,
18,
15,
1046,
435,
943,
8,
10909,
6422,
18,
15,
18,
395,
2049,
327,
7499,
7983,
687,
3107,
643,
4446,
12,
298,
1918,
3757,
793,
18327,
77,
6801,
2,
2049,
3666,
19,
435,
7452,
8,
21,
13342,
18,
12,
446,
1038,
538,
18,
15,
709,
446,
943,
8,
10909,
6422,
18,
1874,
339,
4789,
275,
980,
14,
8748,
8,
5214,
9,
272,
28794,
1451,
8,
681,
4894,
12,
4789,
12,
378,
12,
413,
12,
10561,
29,
17,
69,
13,
1079,
680,
1074,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
timduru/platform-external-chromium_org
|
tools/python/google/platform_utils_mac.py
|
183
|
5676
|
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Platform-specific utility methods shared by several scripts."""
import os
import subprocess
import google.path_utils
class PlatformUtility(object):
def __init__(self, base_dir):
"""Args:
base_dir: the base dir for running tests.
"""
self._base_dir = base_dir
self._httpd_cmd_string = None # used for starting/stopping httpd
self._bash = "/bin/bash"
def _UnixRoot(self):
"""Returns the path to root."""
return "/"
def GetFilesystemRoot(self):
"""Returns the root directory of the file system."""
return self._UnixRoot()
def GetTempDirectory(self):
"""Returns the file system temp directory
Note that this does not use a random subdirectory, so it's not
intrinsically secure. If you need a secure subdir, use the tempfile
package.
"""
return os.getenv("TMPDIR", "/tmp")
def FilenameToUri(self, path, use_http=False, use_ssl=False, port=8000):
"""Convert a filesystem path to a URI.
Args:
path: For an http URI, the path relative to the httpd server's
DocumentRoot; for a file URI, the full path to the file.
use_http: if True, returns a URI of the form http://127.0.0.1:8000/.
If False, returns a file:/// URI.
use_ssl: if True, returns HTTPS URL (https://127.0.0.1:8000/).
This parameter is ignored if use_http=False.
port: The port number to append when returning an HTTP URI
"""
if use_http:
protocol = 'http'
if use_ssl:
protocol = 'https'
return "%s://127.0.0.1:%d/%s" % (protocol, port, path)
return "file://" + path
def GetStartHttpdCommand(self, output_dir,
httpd_conf_path, mime_types_path,
document_root=None, apache2=False):
"""Prepares the config file and output directory to start an httpd server.
Returns a list of strings containing the server's command line+args.
Args:
output_dir: the path to the server's output directory, for log files.
It will be created if necessary.
httpd_conf_path: full path to the httpd.conf file to be used.
mime_types_path: full path to the mime.types file to be used.
document_root: full path to the DocumentRoot. If None, the DocumentRoot
from the httpd.conf file will be used. Note that the httpd.conf
file alongside this script does not specify any DocumentRoot, so if
you're using that one, be sure to specify a document_root here.
apache2: boolean if true will cause this function to return start
command for Apache 2.x as opposed to Apache 1.3.x. This flag
is ignored on Mac (but preserved here for compatibility in
function signature with win), where httpd2 is used always
"""
exe_name = "httpd"
cert_file = google.path_utils.FindUpward(self._base_dir, 'tools',
'python', 'google',
'httpd_config', 'httpd2.pem')
ssl_enabled = os.path.exists('/etc/apache2/mods-enabled/ssl.conf')
httpd_vars = {
"httpd_executable_path":
os.path.join(self._UnixRoot(), "usr", "sbin", exe_name),
"httpd_conf_path": httpd_conf_path,
"ssl_certificate_file": cert_file,
"document_root" : document_root,
"server_root": os.path.join(self._UnixRoot(), "usr"),
"mime_types_path": mime_types_path,
"output_dir": output_dir,
"ssl_mutex": "file:"+os.path.join(output_dir, "ssl_mutex"),
"user": os.environ.get("USER", "#%d" % os.geteuid()),
"lock_file": os.path.join(output_dir, "accept.lock"),
}
google.path_utils.MaybeMakeDirectory(output_dir)
# We have to wrap the command in bash
# -C: process directive before reading config files
# -c: process directive after reading config files
# Apache wouldn't run CGIs with permissions==700 unless we add
# -c User "<username>"
httpd_cmd_string = (
'%(httpd_executable_path)s'
' -f %(httpd_conf_path)s'
' -c \'TypesConfig "%(mime_types_path)s"\''
' -c \'CustomLog "%(output_dir)s/access_log.txt" common\''
' -c \'ErrorLog "%(output_dir)s/error_log.txt"\''
' -c \'PidFile "%(output_dir)s/httpd.pid"\''
' -C \'User "%(user)s"\''
' -C \'ServerRoot "%(server_root)s"\''
' -c \'LockFile "%(lock_file)s"\''
)
if document_root:
httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\''
if ssl_enabled:
httpd_cmd_string += (
' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\''
' -c \'SSLMutex "%(ssl_mutex)s"\''
)
# Save a copy of httpd_cmd_string to use for stopping httpd
self._httpd_cmd_string = httpd_cmd_string % httpd_vars
httpd_cmd = [self._bash, "-c", self._httpd_cmd_string]
return httpd_cmd
def GetStopHttpdCommand(self):
"""Returns a list of strings that contains the command line+args needed to
stop the http server used in the http tests.
This tries to fetch the pid of httpd (if available) and returns the
command to kill it. If pid is not available, kill all httpd processes
"""
if not self._httpd_cmd_string:
return ["true"] # Haven't been asked for the start cmd yet. Just pass.
# Add a sleep after the shutdown because sometimes it takes some time for
# the port to be available again.
return [self._bash, "-c", self._httpd_cmd_string + ' -k stop && sleep 5']
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
7760,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
10397,
13,
6100,
11420,
3102,
5709,
701,
9978,
10554,
1041,
199,
199,
646,
747,
199,
646,
3873,
199,
199,
646,
6233,
14,
515,
63,
1208,
421,
199,
533,
16078,
17505,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
1300,
63,
694,
304,
272,
408,
6213,
26,
268,
1300,
63,
694,
26,
314,
1300,
2935,
367,
3879,
2295,
14,
272,
408,
272,
291,
423,
1095,
63,
694,
275,
1300,
63,
694,
272,
291,
423,
21594,
63,
1760,
63,
875,
275,
488,
221,
327,
1202,
367,
6617,
15,
2379,
4073,
23913,
272,
291,
423,
16408,
275,
3286,
1393,
15,
16408,
2,
819,
347,
485,
21607,
6405,
8,
277,
304,
272,
408,
3407,
314,
931,
370,
1738,
1041,
272,
372,
10609,
819,
347,
2372,
1173,
2253,
6405,
8,
277,
304,
272,
408,
3407,
314,
1738,
2082,
402,
314,
570,
2656,
1041,
272,
372,
291,
423,
21607,
6405,
342,
819,
347,
2372,
6530,
6231,
8,
277,
304,
272,
408,
3407,
314,
570,
2656,
2388,
2082,
339,
3390,
626,
642,
1630,
440,
675,
282,
2196,
25094,
12,
880,
652,
1159,
440,
272,
31570,
262,
9916,
1183,
11153,
14,
221,
982,
1265,
1929,
282,
11153,
15488,
12,
675,
314,
5549,
272,
2559,
14,
272,
408,
272,
372,
747,
14,
12959,
480,
17983,
3022,
401,
3286,
2791,
531,
819,
347,
31167,
1378,
14014,
8,
277,
12,
931,
12,
675,
63,
1014,
29,
797,
12,
675,
63,
4266,
29,
797,
12,
1844,
29,
15214,
304,
272,
408,
7306,
282,
10036,
931,
370,
282,
9022,
14,
339,
3033,
26,
489,
931,
26,
2104,
376,
1455,
9022,
12,
314,
931,
3847,
370,
314,
23913,
1654,
1159,
881,
7543,
6405,
27,
367,
282,
570,
9022,
12,
314,
2615,
931,
370,
314,
570,
14,
489,
675,
63,
1014,
26,
340,
715,
12,
2529,
282,
9022,
402,
314,
1824,
1455,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
8083,
881,
982,
756,
12,
2529,
282,
570,
24436,
9022,
14,
489,
675,
63,
4266,
26,
340,
715,
12,
2529,
14147,
2851,
334,
2859,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
15,
680,
881,
961,
2725,
365,
5525,
340,
675,
63,
1014,
29,
797,
14,
489,
1844,
26,
710,
1844,
1329,
370,
5666,
1380,
8152,
376,
3101,
9022,
272,
408,
272,
340,
675,
63,
1014,
26,
489,
4113,
275,
283,
1014,
7,
489,
340,
675,
63,
4266,
26,
267,
4113,
275,
283,
2859,
7,
489,
372,
2071,
83,
921,
4195,
14,
16,
14,
16,
14,
17,
2689,
68,
3149,
83,
2,
450,
334,
3922,
12,
1844,
12,
931,
9,
272,
372,
298,
493,
30443,
435,
931,
819,
347,
2372,
3162,
5779,
68,
3110,
8,
277,
12,
1072,
63,
694,
12,
2574,
23913,
63,
2190,
63,
515,
12,
6660,
63,
1313,
63,
515,
12,
2574,
2213,
63,
1231,
29,
403,
12,
17098,
18,
29,
797,
304,
272,
408,
2398,
27749,
314,
1101,
570,
436,
1072,
2082,
370,
1343,
376,
23913,
1654,
14,
272,
1803,
282,
769,
402,
3326,
3035,
314,
1654,
1159,
1414,
1004,
11,
589,
14,
339,
3033,
26,
489,
1072,
63,
694,
26,
314,
931,
370,
314,
1654,
1159,
1072,
2082,
12,
367,
943,
1584,
14,
881,
2779,
911,
506,
2737,
340,
5784,
14,
489,
23913,
63,
2190,
63,
515,
26,
2615,
931,
370,
314,
23913,
14,
2190,
570,
370,
506,
1202,
14,
489,
6660,
63,
1313,
63,
515,
26,
2615,
931,
370,
314,
6660,
14,
1313,
570,
370,
506,
1202,
14,
489,
2213,
63,
1231,
26,
2615,
931,
370,
314,
7543,
6405,
14,
221,
982,
488,
12,
314,
7543,
6405,
881,
687,
314,
23913,
14,
2190,
570,
911,
506,
1202,
14,
221,
3390,
626,
314,
23913,
14,
2190,
881,
570,
3180,
2441,
642,
2884,
1630,
440,
4165,
1263,
7543,
6405,
12,
880,
340,
881,
1265,
3984,
1808,
626,
1373,
12,
506,
3238,
370,
4165,
282,
2213,
63,
1231,
2348,
14,
489,
17098,
18,
26,
5046,
340,
2549,
911,
7675,
642,
805,
370,
372,
1343,
2049,
1414,
367,
3668,
499,
14,
88,
465,
25068,
370,
3668,
413,
14,
19,
14,
88,
14,
961,
3305,
2049,
365,
5525,
641,
10444,
334,
7911,
17731,
2348,
367,
7163,
315,
2049,
805,
4955,
543,
4747,
395,
2382,
23913,
18,
365,
1202,
3544,
272,
408,
339,
14778,
63,
354,
275,
298,
21594,
2,
272,
6250,
63,
493,
275,
6233,
14,
515,
63,
1208,
14,
6591,
1721,
3079,
8,
277,
423,
1095,
63,
694,
12,
283,
2537,
297,
6163,
283,
1548,
297,
283,
3098,
297,
6163,
283,
21594,
63,
888,
297,
283,
21594,
18,
14,
13102,
358,
272,
6149,
63,
3827,
275,
747,
14,
515,
14,
2444,
2336,
6839,
15,
3796,
18,
15,
19709,
13,
3827,
15,
4266,
14,
2190,
358,
339,
23913,
63,
2936,
275,
469,
489,
298,
21594,
63,
5904,
63,
515,
582,
881,
747,
14,
515,
14,
904,
8,
277,
423,
21607,
6405,
1062,
298,
2647,
401,
298,
21457,
401,
14778,
63,
354,
395,
489,
298,
21594,
63,
2190,
63,
515,
582,
23913,
63,
2190,
63,
515,
12,
489,
298,
4266,
63,
6999,
63,
493,
582,
6250,
63,
493,
12,
489,
298,
3554,
63,
1231,
2,
520,
2213,
63,
1231,
12,
489,
298,
1000,
63,
1231,
582,
747,
14,
515,
14,
904,
8,
277,
423,
21607,
6405,
1062,
298,
2647,
1288,
489,
298,
7626,
63,
1313,
63,
515,
582,
6660,
63,
1313,
63,
515,
12,
489,
298,
1199,
63,
694,
582,
1072,
63,
694,
12,
489,
298,
4266,
63,
19078,
582,
298,
493,
5424,
11,
736,
14,
515,
14,
904,
8,
1199,
63,
694,
12,
298,
4266,
63,
19078,
1288,
489,
298,
751,
582,
747,
14,
2314,
14,
362,
480,
3791,
401,
5426,
5,
68,
2,
450,
747,
14,
31508,
1535,
4000,
489,
298,
831,
63,
493,
582,
747,
14,
515,
14,
904,
8,
1199,
63,
694,
12,
298,
5694,
14,
831,
1288,
272,
789,
339,
6233,
14,
515,
63,
1208,
14,
15586,
1235,
5483,
6231,
8,
1199,
63,
694,
9,
339,
327,
2136,
1172,
370,
4816,
314,
1414,
315,
20387
] |
[
1898,
334,
67,
9,
7760,
710,
12051,
6642,
14,
2900,
4481,
4644,
14,
199,
3,
3645,
402,
642,
1350,
1233,
365,
10413,
701,
282,
6289,
13,
2487,
4190,
626,
883,
506,
199,
3,
1911,
315,
314,
5113,
570,
14,
199,
199,
624,
10397,
13,
6100,
11420,
3102,
5709,
701,
9978,
10554,
1041,
199,
199,
646,
747,
199,
646,
3873,
199,
199,
646,
6233,
14,
515,
63,
1208,
421,
199,
533,
16078,
17505,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
1300,
63,
694,
304,
272,
408,
6213,
26,
268,
1300,
63,
694,
26,
314,
1300,
2935,
367,
3879,
2295,
14,
272,
408,
272,
291,
423,
1095,
63,
694,
275,
1300,
63,
694,
272,
291,
423,
21594,
63,
1760,
63,
875,
275,
488,
221,
327,
1202,
367,
6617,
15,
2379,
4073,
23913,
272,
291,
423,
16408,
275,
3286,
1393,
15,
16408,
2,
819,
347,
485,
21607,
6405,
8,
277,
304,
272,
408,
3407,
314,
931,
370,
1738,
1041,
272,
372,
10609,
819,
347,
2372,
1173,
2253,
6405,
8,
277,
304,
272,
408,
3407,
314,
1738,
2082,
402,
314,
570,
2656,
1041,
272,
372,
291,
423,
21607,
6405,
342,
819,
347,
2372,
6530,
6231,
8,
277,
304,
272,
408,
3407,
314,
570,
2656,
2388,
2082,
339,
3390,
626,
642,
1630,
440,
675,
282,
2196,
25094,
12,
880,
652,
1159,
440,
272,
31570,
262,
9916,
1183,
11153,
14,
221,
982,
1265,
1929,
282,
11153,
15488,
12,
675,
314,
5549,
272,
2559,
14,
272,
408,
272,
372,
747,
14,
12959,
480,
17983,
3022,
401,
3286,
2791,
531,
819,
347,
31167,
1378,
14014,
8,
277,
12,
931,
12,
675,
63,
1014,
29,
797,
12,
675,
63,
4266,
29,
797,
12,
1844,
29,
15214,
304,
272,
408,
7306,
282,
10036,
931,
370,
282,
9022,
14,
339,
3033,
26,
489,
931,
26,
2104,
376,
1455,
9022,
12,
314,
931,
3847,
370,
314,
23913,
1654,
1159,
881,
7543,
6405,
27,
367,
282,
570,
9022,
12,
314,
2615,
931,
370,
314,
570,
14,
489,
675,
63,
1014,
26,
340,
715,
12,
2529,
282,
9022,
402,
314,
1824,
1455,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
8083,
881,
982,
756,
12,
2529,
282,
570,
24436,
9022,
14,
489,
675,
63,
4266,
26,
340,
715,
12,
2529,
14147,
2851,
334,
2859,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
15,
680,
881,
961,
2725,
365,
5525,
340,
675,
63,
1014,
29,
797,
14,
489,
1844,
26,
710,
1844,
1329,
370,
5666,
1380,
8152,
376,
3101,
9022,
272,
408,
272,
340,
675,
63,
1014,
26,
489,
4113,
275,
283,
1014,
7,
489,
340,
675,
63,
4266,
26,
267,
4113,
275,
283,
2859,
7,
489,
372,
2071,
83,
921,
4195,
14,
16,
14,
16,
14,
17,
2689,
68,
3149,
83,
2,
450,
334,
3922,
12,
1844,
12,
931,
9,
272,
372,
298,
493,
30443,
435,
931,
819,
347,
2372,
3162,
5779,
68,
3110,
8,
277,
12,
1072,
63,
694,
12,
2574,
23913,
63,
2190,
63,
515,
12,
6660,
63,
1313,
63,
515,
12,
2574,
2213,
63,
1231,
29,
403,
12,
17098,
18,
29,
797,
304,
272,
408,
2398,
27749,
314,
1101,
570,
436,
1072,
2082,
370,
1343,
376,
23913,
1654,
14,
272,
1803,
282,
769,
402,
3326,
3035,
314,
1654,
1159,
1414,
1004,
11,
589,
14,
339,
3033,
26,
489,
1072,
63,
694,
26,
314,
931,
370,
314,
1654,
1159,
1072,
2082,
12,
367,
943,
1584,
14,
881,
2779,
911,
506,
2737,
340,
5784,
14,
489,
23913,
63,
2190,
63,
515,
26,
2615,
931,
370,
314,
23913,
14,
2190,
570,
370,
506,
1202,
14,
489,
6660,
63,
1313,
63,
515,
26,
2615,
931,
370,
314,
6660,
14,
1313,
570,
370,
506,
1202,
14,
489,
2213,
63,
1231,
26,
2615,
931,
370,
314,
7543,
6405,
14,
221,
982,
488,
12,
314,
7543,
6405,
881,
687,
314,
23913,
14,
2190,
570,
911,
506,
1202,
14,
221,
3390,
626,
314,
23913,
14,
2190,
881,
570,
3180,
2441,
642,
2884,
1630,
440,
4165,
1263,
7543,
6405,
12,
880,
340,
881,
1265,
3984,
1808,
626,
1373,
12,
506,
3238,
370,
4165,
282,
2213,
63,
1231,
2348,
14,
489,
17098,
18,
26,
5046,
340,
2549,
911,
7675,
642,
805,
370,
372,
1343,
2049,
1414,
367,
3668,
499,
14,
88,
465,
25068,
370,
3668,
413,
14,
19,
14,
88,
14,
961,
3305,
2049,
365,
5525,
641,
10444,
334,
7911,
17731,
2348,
367,
7163,
315,
2049,
805,
4955,
543,
4747,
395,
2382,
23913,
18,
365,
1202,
3544,
272,
408,
339,
14778,
63,
354,
275,
298,
21594,
2,
272,
6250,
63,
493,
275,
6233,
14,
515,
63,
1208,
14,
6591,
1721,
3079,
8,
277,
423,
1095,
63,
694,
12,
283,
2537,
297,
6163,
283,
1548,
297,
283,
3098,
297,
6163,
283,
21594,
63,
888,
297,
283,
21594,
18,
14,
13102,
358,
272,
6149,
63,
3827,
275,
747,
14,
515,
14,
2444,
2336,
6839,
15,
3796,
18,
15,
19709,
13,
3827,
15,
4266,
14,
2190,
358,
339,
23913,
63,
2936,
275,
469,
489,
298,
21594,
63,
5904,
63,
515,
582,
881,
747,
14,
515,
14,
904,
8,
277,
423,
21607,
6405,
1062,
298,
2647,
401,
298,
21457,
401,
14778,
63,
354,
395,
489,
298,
21594,
63,
2190,
63,
515,
582,
23913,
63,
2190,
63,
515,
12,
489,
298,
4266,
63,
6999,
63,
493,
582,
6250,
63,
493,
12,
489,
298,
3554,
63,
1231,
2,
520,
2213,
63,
1231,
12,
489,
298,
1000,
63,
1231,
582,
747,
14,
515,
14,
904,
8,
277,
423,
21607,
6405,
1062,
298,
2647,
1288,
489,
298,
7626,
63,
1313,
63,
515,
582,
6660,
63,
1313,
63,
515,
12,
489,
298,
1199,
63,
694,
582,
1072,
63,
694,
12,
489,
298,
4266,
63,
19078,
582,
298,
493,
5424,
11,
736,
14,
515,
14,
904,
8,
1199,
63,
694,
12,
298,
4266,
63,
19078,
1288,
489,
298,
751,
582,
747,
14,
2314,
14,
362,
480,
3791,
401,
5426,
5,
68,
2,
450,
747,
14,
31508,
1535,
4000,
489,
298,
831,
63,
493,
582,
747,
14,
515,
14,
904,
8,
1199,
63,
694,
12,
298,
5694,
14,
831,
1288,
272,
789,
339,
6233,
14,
515,
63,
1208,
14,
15586,
1235,
5483,
6231,
8,
1199,
63,
694,
9,
339,
327,
2136,
1172,
370,
4816,
314,
1414,
315,
20387,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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 import absolute_import
from django.template import Node, Library, TemplateSyntaxError
from django.conf import settings
from django.contrib.staticfiles.storage import staticfiles_storage
register = Library()
class MinifiedJSNode(Node):
def __init__(self, sourcefile):
self.sourcefile = sourcefile
def render(self, context):
if settings.DEBUG:
scripts = settings.JS_SPECS[self.sourcefile]['source_filenames']
else:
scripts = [settings.JS_SPECS[self.sourcefile]['output_filename']]
script_urls = [staticfiles_storage.url(script) for script in scripts]
script_tags = ['<script type="text/javascript" src="%s" charset="utf-8"></script>'
% url for url in script_urls]
return '\n'.join(script_tags)
@register.tag
def minified_js(parser, token):
try:
tag_name, sourcefile = token.split_contents()
except ValueError:
raise TemplateSyntaxError("%s tag requires an argument" % tag_name)
if not (sourcefile[0] == sourcefile[-1] and sourcefile[0] in ('"', "'")):
raise TemplateSyntaxError("%s tag should be quoted" % tag_name)
sourcefile = sourcefile[1:-1]
if sourcefile not in settings.JS_SPECS:
raise TemplateSyntaxError("%s tag invalid argument: no JS file %s"
% (tag_name, sourcefile))
return MinifiedJSNode(sourcefile)
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
504,
1639,
14,
1160,
492,
5013,
12,
11243,
12,
17762,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
18373,
14,
3494,
492,
2955,
1725,
63,
3494,
199,
199,
2683,
275,
11243,
342,
199,
199,
533,
24954,
1290,
11378,
1716,
8,
1716,
304,
272,
347,
636,
826,
721,
277,
12,
1350,
493,
304,
267,
291,
14,
32666,
275,
1350,
493,
339,
347,
3795,
8,
277,
12,
1067,
304,
267,
340,
2202,
14,
5287,
26,
288,
10554,
275,
2202,
14,
11378,
63,
14179,
3298,
59,
277,
14,
32666,
2733,
1365,
63,
10309,
418,
267,
587,
26,
288,
10554,
275,
359,
1751,
14,
11378,
63,
14179,
3298,
59,
277,
14,
32666,
2733,
1199,
63,
1501,
6538,
267,
2884,
63,
3603,
275,
359,
18373,
63,
3494,
14,
633,
8,
1579,
9,
367,
2884,
315,
10554,
61,
267,
2884,
63,
2969,
275,
12329,
1579,
730,
628,
505,
15,
9554,
2,
2928,
5961,
83,
2,
5960,
628,
1624,
13,
24,
10070,
1579,
3524,
355,
450,
1166,
367,
1166,
315,
2884,
63,
3603,
61,
267,
372,
1557,
78,
1370,
904,
8,
1579,
63,
2969,
9,
421,
199,
32,
2683,
14,
1450,
199,
318,
1748,
4541,
63,
3596,
8,
2087,
12,
1526,
304,
272,
862,
26,
267,
1947,
63,
354,
12,
1350,
493,
275,
1526,
14,
1294,
63,
4407,
342,
272,
871,
1722,
26,
267,
746,
17762,
3647,
83,
1947,
5074,
376,
1423,
2,
450,
1947,
63,
354,
9,
272,
340,
440,
334,
32666,
59,
16,
61,
508,
1350,
493,
1988,
17,
61,
436,
1350,
493,
59,
16,
61,
315,
661,
6949,
3546,
14150,
267,
746,
17762,
3647,
83,
1947,
1077,
506,
10999,
2,
450,
1947,
63,
354,
9,
339,
1350,
493,
275,
1350,
493,
59,
17,
6809,
17,
61,
272,
340,
1350,
493,
440,
315,
2202,
14,
11378,
63,
14179,
3298,
26,
267,
746,
17762,
3647,
83,
1947,
3866,
1423,
26,
949,
18001,
570,
450,
83,
2,
355,
450,
334,
1450,
63,
354,
12,
1350,
493,
430,
272,
372,
24954,
1290,
11378,
1716,
8,
32666,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
504,
1639,
14,
1160,
492,
5013,
12,
11243,
12,
17762,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
18373,
14,
3494,
492,
2955,
1725,
63,
3494,
199,
199,
2683,
275,
11243,
342,
199,
199,
533,
24954,
1290,
11378,
1716,
8,
1716,
304,
272,
347,
636,
826,
721,
277,
12,
1350,
493,
304,
267,
291,
14,
32666,
275,
1350,
493,
339,
347,
3795,
8,
277,
12,
1067,
304,
267,
340,
2202,
14,
5287,
26,
288,
10554,
275,
2202,
14,
11378,
63,
14179,
3298,
59,
277,
14,
32666,
2733,
1365,
63,
10309,
418,
267,
587,
26,
288,
10554,
275,
359,
1751,
14,
11378,
63,
14179,
3298,
59,
277,
14,
32666,
2733,
1199,
63,
1501,
6538,
267,
2884,
63,
3603,
275,
359,
18373,
63,
3494,
14,
633,
8,
1579,
9,
367,
2884,
315,
10554,
61,
267,
2884,
63,
2969,
275,
12329,
1579,
730,
628,
505,
15,
9554,
2,
2928,
5961,
83,
2,
5960,
628,
1624,
13,
24,
10070,
1579,
3524,
355,
450,
1166,
367,
1166,
315,
2884,
63,
3603,
61,
267,
372,
1557,
78,
1370,
904,
8,
1579,
63,
2969,
9,
421,
199,
32,
2683,
14,
1450,
199,
318,
1748,
4541,
63,
3596,
8,
2087,
12,
1526,
304,
272,
862,
26,
267,
1947,
63,
354,
12,
1350,
493,
275,
1526,
14,
1294,
63,
4407,
342,
272,
871,
1722,
26,
267,
746,
17762,
3647,
83,
1947,
5074,
376,
1423,
2,
450,
1947,
63,
354,
9,
272,
340,
440,
334,
32666,
59,
16,
61,
508,
1350,
493,
1988,
17,
61,
436,
1350,
493,
59,
16,
61,
315,
661,
6949,
3546,
14150,
267,
746,
17762,
3647,
83,
1947,
1077,
506,
10999,
2,
450,
1947,
63,
354,
9,
339,
1350,
493,
275,
1350,
493,
59,
17,
6809,
17,
61,
272,
340,
1350,
493,
440,
315,
2202,
14,
11378,
63,
14179,
3298,
26,
267,
746,
17762,
3647,
83,
1947,
3866,
1423,
26,
949,
18001,
570,
450,
83,
2,
355,
450,
334,
1450,
63,
354,
12,
1350,
493,
430,
272,
372,
24954,
1290,
11378,
1716,
8,
32666,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ricardogsilva/QGIS
|
python/testing/__init__.py
|
12
|
21650
|
# -*- coding: utf-8 -*-
"""
***************************************************************************
__init__.py
---------------------
Date : January 2016
Copyright : (C) 2016 by Matthias Kuhn
Email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Matthias Kuhn'
__date__ = 'January 2016'
__copyright__ = '(C) 2016, Matthias Kuhn'
import os
import sys
import difflib
import functools
import filecmp
import tempfile
from pathlib import Path
from qgis.PyQt.QtCore import QVariant, QDateTime, QDate
from qgis.core import (
QgsApplication,
QgsFeatureRequest,
QgsCoordinateReferenceSystem,
NULL,
QgsVectorLayer,
QgsRenderChecker
)
import unittest
# Get a backup, we will patch this one later
_TestCase = unittest.TestCase
unittest.util._MAX_LENGTH = 2000
class TestCase(_TestCase):
def assertLayersEqual(self, layer_expected, layer_result, **kwargs):
"""
:param layer_expected: The first layer to compare
:param layer_result: The second layer to compare
:param request: Optional, A feature request. This can be used to specify
an order by clause to make sure features are compared in
a given sequence if they don't match by default.
:keyword compare: A map of comparison options. e.g.
{ fields: { a: skip, b: { precision: 2 }, geometry: { precision: 5 } }
{ fields: { __all__: cast( str ) } }
:keyword pk: "Primary key" type field - used to match features
from the expected table to their corresponding features in the result table. If not specified
features are compared by their order in the layer (e.g. first feature compared with first feature,
etc)
"""
self.checkLayersEqual(layer_expected, layer_result, True, **kwargs)
def checkLayersEqual(self, layer_expected, layer_result, use_asserts=False, **kwargs):
"""
:param layer_expected: The first layer to compare
:param layer_result: The second layer to compare
:param use_asserts: If true, asserts are used to test conditions, if false, asserts
are not used and the function will only return False if the test fails
:param request: Optional, A feature request. This can be used to specify
an order by clause to make sure features are compared in
a given sequence if they don't match by default.
:keyword compare: A map of comparison options. e.g.
{ fields: { a: skip, b: { precision: 2 }, geometry: { precision: 5 } }
{ fields: { __all__: cast( str ) } }
:keyword pk: "Primary key" type field - used to match features
from the expected table to their corresponding features in the result table. If not specified
features are compared by their order in the layer (e.g. first feature compared with first feature,
etc)
"""
try:
request = kwargs['request']
except KeyError:
request = QgsFeatureRequest()
try:
compare = kwargs['compare']
except KeyError:
compare = {}
# Compare CRS
if 'ignore_crs_check' not in compare or not compare['ignore_crs_check']:
expected_wkt = layer_expected.dataProvider().crs().toWkt(QgsCoordinateReferenceSystem.WKT_PREFERRED)
result_wkt = layer_result.dataProvider().crs().toWkt(QgsCoordinateReferenceSystem.WKT_PREFERRED)
if use_asserts:
_TestCase.assertEqual(self, layer_expected.dataProvider().crs(), layer_result.dataProvider().crs())
elif layer_expected.dataProvider().crs() != layer_result.dataProvider().crs():
return False
# Compare features
if use_asserts:
_TestCase.assertEqual(self, layer_expected.featureCount(), layer_result.featureCount())
elif layer_expected.featureCount() != layer_result.featureCount():
return False
try:
precision = compare['geometry']['precision']
except KeyError:
precision = 14
try:
topo_equal_check = compare['geometry']['topo_equal_check']
except KeyError:
topo_equal_check = False
try:
ignore_part_order = compare['geometry']['ignore_part_order']
except KeyError:
ignore_part_order = False
try:
unordered = compare['unordered']
except KeyError:
unordered = False
if unordered:
features_expected = [f for f in layer_expected.getFeatures(request)]
for feat in layer_result.getFeatures(request):
feat_expected_equal = None
for feat_expected in features_expected:
if self.checkGeometriesEqual(feat.geometry(), feat_expected.geometry(),
feat.id(), feat_expected.id(),
False, precision, topo_equal_check, ignore_part_order) and \
self.checkAttributesEqual(feat, feat_expected, layer_expected.fields(), False, compare):
feat_expected_equal = feat_expected
break
if feat_expected_equal is not None:
features_expected.remove(feat_expected_equal)
else:
if use_asserts:
_TestCase.assertTrue(
self, False,
'Unexpected result feature: fid {}, geometry: {}, attributes: {}'.format(
feat.id(),
feat.geometry().constGet().asWkt(precision) if feat.geometry() else 'NULL',
feat.attributes())
)
else:
return False
if len(features_expected) != 0:
if use_asserts:
lst_missing = []
for feat in features_expected:
lst_missing.append('fid {}, geometry: {}, attributes: {}'.format(
feat.id(),
feat.geometry().constGet().asWkt(precision) if feat.geometry() else 'NULL',
feat.attributes())
)
_TestCase.assertTrue(self, False, 'Some expected features not found in results:\n' + '\n'.join(lst_missing))
else:
return False
return True
def sort_by_pk_or_fid(f):
if 'pk' in kwargs and kwargs['pk'] is not None:
key = kwargs['pk']
if isinstance(key, list) or isinstance(key, tuple):
return [f[k] for k in key]
else:
return f[kwargs['pk']]
else:
return f.id()
expected_features = sorted(layer_expected.getFeatures(request), key=sort_by_pk_or_fid)
result_features = sorted(layer_result.getFeatures(request), key=sort_by_pk_or_fid)
for feats in zip(expected_features, result_features):
eq = self.checkGeometriesEqual(feats[0].geometry(),
feats[1].geometry(),
feats[0].id(),
feats[1].id(),
use_asserts, precision, topo_equal_check, ignore_part_order)
if not eq and not use_asserts:
return False
eq = self.checkAttributesEqual(feats[0], feats[1], layer_expected.fields(), use_asserts, compare)
if not eq and not use_asserts:
return False
return True
def checkFilesEqual(self, filepath_expected, filepath_result, use_asserts=False):
with open(filepath_expected, 'r') as file_expected:
with open(filepath_result, 'r') as file_result:
diff = difflib.unified_diff(
file_expected.readlines(),
file_result.readlines(),
fromfile='expected',
tofile='result',
)
diff = list(diff)
eq = not len(diff)
if use_asserts:
self.assertEqual(0, len(diff), ''.join(diff))
else:
return eq
def assertFilesEqual(self, filepath_expected, filepath_result):
self.checkFilesEqual(filepath_expected, filepath_result, use_asserts=True)
def assertDirectoryEqual(self, dirpath_expected: str, dirpath_result: str):
"""
Checks whether both directories have the same content (non-recursively) and raises an assertion error if not.
"""
path_expected = Path(dirpath_expected)
path_result = Path(dirpath_result)
contents_result = list(path_result.iterdir())
contents_expected = list(path_expected.iterdir())
contents_expected = [p for p in contents_expected if p.suffix != '.png' or not p.stem.endswith('_mask')]
self.assertCountEqual([p.name if p.is_file() else p.stem for p in contents_expected], [p.name if p.is_file() else p.stem for p in contents_result], f'Directory contents mismatch in {dirpath_expected} vs {dirpath_result}')
# compare file contents
for expected_file_path in contents_expected:
if expected_file_path.is_dir():
continue
result_file_path = path_result / expected_file_path.name
if expected_file_path.suffix == '.pbf':
# vector layer, use assertLayersEqual
layer_expected = QgsVectorLayer(str(expected_file_path), 'Expected')
self.assertTrue(layer_expected.isValid())
layer_result = QgsVectorLayer(str(result_file_path), 'Result')
self.assertTrue(layer_result.isValid())
self.assertLayersEqual(layer_expected, layer_result)
elif expected_file_path.suffix == '.png':
# image file, use QgsRenderChecker
checker = QgsRenderChecker()
res = checker.compareImages(expected_file_path.stem, expected_file_path.as_posix(), result_file_path.as_posix())
self.assertTrue(res)
else:
assert False, f"Don't know how to compare {expected_file_path.suffix} files"
def assertDirectoriesEqual(self, dirpath_expected: str, dirpath_result: str):
""" Checks whether both directories have the same content (recursively) and raises an assertion error if not. """
self.assertDirectoryEqual(dirpath_expected, dirpath_result)
# recurse through subfolders
path_expected = Path(dirpath_expected)
path_result = Path(dirpath_result)
for p in path_expected.iterdir():
if p.is_dir():
self.assertDirectoriesEqual(str(p), path_result / p.stem)
def assertGeometriesEqual(self, geom0, geom1, geom0_id='geometry 1', geom1_id='geometry 2', precision=14, topo_equal_check=False, ignore_part_order=False):
self.checkGeometriesEqual(geom0, geom1, geom0_id, geom1_id, use_asserts=True, precision=precision, topo_equal_check=topo_equal_check, ignore_part_order=ignore_part_order)
def checkGeometriesEqual(self, geom0, geom1, geom0_id, geom1_id, use_asserts=False, precision=14, topo_equal_check=False, ignore_part_order=False):
""" Checks whether two geometries are the same - using either a strict check of coordinates (up to given precision)
or by using topological equality (where e.g. a polygon with clockwise is equal to a polygon with counter-clockwise
order of vertices)
.. versionadded:: 3.2
"""
if not geom0.isNull() and not geom1.isNull():
equal = geom0.constGet().asWkt(precision) == geom1.constGet().asWkt(precision)
if not equal and topo_equal_check:
equal = geom0.isGeosEqual(geom1)
if not equal and ignore_part_order and geom0.isMultipart():
equal = sorted([p.asWkt(precision) for p in geom0.constParts()]) == sorted([p.asWkt(precision) for p in geom1.constParts()])
elif geom0.isNull() and geom1.isNull():
equal = True
else:
equal = False
if use_asserts:
_TestCase.assertTrue(
self,
equal, ''
' Features (Expected fid: {}, Result fid: {}) differ in geometry with method {}: \n\n'
' At given precision ({}):\n'
' Expected geometry: {}\n'
' Result geometry: {}\n\n'
' Full precision:\n'
' Expected geometry : {}\n'
' Result geometry: {}\n\n'.format(
geom0_id,
geom1_id,
'geos' if topo_equal_check else 'wkt',
precision,
geom0.constGet().asWkt(precision) if not geom0.isNull() else 'NULL',
geom1.constGet().asWkt(precision) if not geom1.isNull() else 'NULL',
geom0.constGet().asWkt() if not geom1.isNull() else 'NULL',
geom1.constGet().asWkt() if not geom0.isNull() else 'NULL'
)
)
else:
return equal
def checkAttributesEqual(self, feat0, feat1, fields_expected, use_asserts, compare):
""" Checks whether attributes of two features are the same
.. versionadded:: 3.2
"""
for attr_expected, field_expected in zip(feat0.attributes(), fields_expected.toList()):
try:
cmp = compare['fields'][field_expected.name()]
except KeyError:
try:
cmp = compare['fields']['__all__']
except KeyError:
cmp = {}
# Skip field
if 'skip' in cmp:
continue
if use_asserts:
_TestCase.assertIn(
self,
field_expected.name().lower(),
[name.lower() for name in feat1.fields().names()])
attr_result = feat1[field_expected.name()]
field_result = [fld for fld in fields_expected.toList() if fld.name() == field_expected.name()][0]
# Cast field to a given type
isNumber = False
if 'cast' in cmp:
if cmp['cast'] == 'int':
attr_expected = int(attr_expected) if attr_expected else None
attr_result = int(attr_result) if attr_result else None
isNumber = True
if cmp['cast'] == 'float':
attr_expected = float(attr_expected) if attr_expected else None
attr_result = float(attr_result) if attr_result else None
isNumber = True
if cmp['cast'] == 'str':
if isinstance(attr_expected, QDateTime):
attr_expected = attr_expected.toString('yyyy/MM/dd hh:mm:ss')
elif isinstance(attr_expected, QDate):
attr_expected = attr_expected.toString('yyyy/MM/dd')
else:
attr_expected = str(attr_expected) if attr_expected else None
if isinstance(attr_result, QDateTime):
attr_result = attr_result.toString('yyyy/MM/dd hh:mm:ss')
elif isinstance(attr_result, QDate):
attr_result = attr_result.toString('yyyy/MM/dd')
else:
attr_result = str(attr_result) if attr_result else None
# Round field (only numeric so it works with __all__)
if 'precision' in cmp and (field_expected.type() in [QVariant.Int, QVariant.Double, QVariant.LongLong] or isNumber):
if not attr_expected == NULL:
attr_expected = round(attr_expected, cmp['precision'])
if not attr_result == NULL:
attr_result = round(attr_result, cmp['precision'])
if use_asserts:
_TestCase.assertEqual(
self,
attr_expected,
attr_result,
'Features {}/{} differ in attributes\n\n * Field expected: {} ({})\n * result : {} ({})\n\n * Expected: {} != Result : {}'.format(
feat0.id(),
feat1.id(),
field_expected.name(),
field_expected.typeName(),
field_result.name(),
field_result.typeName(),
repr(attr_expected),
repr(attr_result)
)
)
elif attr_expected != attr_result:
return False
return True
class _UnexpectedSuccess(Exception):
"""
The test was supposed to fail, but it didn't!
"""
pass
def expectedFailure(*args):
"""
Will decorate a unittest function as an expectedFailure. A function
flagged as expectedFailure will be succeed if it raises an exception.
If it does not raise an exception, this will throw an
`_UnexpectedSuccess` exception.
@expectedFailure
def my_test(self):
self.assertTrue(False)
The decorator also accepts a parameter to only expect a failure under
certain conditions.
@expectedFailure(time.localtime().tm_year < 2002)
def my_test(self):
self.assertTrue(qgisIsInvented())
"""
if hasattr(args[0], '__call__'):
# We got a function as parameter: assume usage like
# @expectedFailure
# def testfunction():
func = args[0]
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
func(*args, **kwargs)
except Exception:
pass
else:
raise _UnexpectedSuccess
return wrapper
else:
# We got a function as parameter: assume usage like
# @expectedFailure(failsOnThisPlatform)
# def testfunction():
condition = args[0]
def realExpectedFailure(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if condition:
try:
func(*args, **kwargs)
except Exception:
pass
else:
raise _UnexpectedSuccess
else:
func(*args, **kwargs)
return wrapper
return realExpectedFailure
# Patch unittest
unittest.TestCase = TestCase
unittest.expectedFailure = expectedFailure
def start_app(cleanup=True):
"""
Will start a QgsApplication and call all initialization code like
registering the providers and other infrastructure. It will not load
any plugins.
You can always get the reference to a running app by calling `QgsApplication.instance()`.
The initialization will only happen once, so it is safe to call this method repeatedly.
Parameters
----------
cleanup: Do cleanup on exit. Defaults to true.
Returns
-------
QgsApplication
A QgsApplication singleton
"""
global QGISAPP
try:
QGISAPP
except NameError:
myGuiFlag = True # All test will run qgis in gui mode
try:
sys.argv
except AttributeError:
sys.argv = ['']
# In python3 we need to convert to a bytes object (or should
# QgsApplication accept a QString instead of const char* ?)
try:
argvb = list(map(os.fsencode, sys.argv))
except AttributeError:
argvb = sys.argv
# Note: QGIS_PREFIX_PATH is evaluated in QgsApplication -
# no need to mess with it here.
QGISAPP = QgsApplication(argvb, myGuiFlag)
os.environ['QGIS_CUSTOM_CONFIG_PATH'] = tempfile.mkdtemp('', 'QGIS-PythonTestConfigPath')
QGISAPP.initQgis()
print(QGISAPP.showSettings())
def debug_log_message(message, tag, level):
print('{}({}): {}'.format(tag, level, message))
QgsApplication.instance().messageLog().messageReceived.connect(debug_log_message)
if cleanup:
import atexit
@atexit.register
def exitQgis():
QGISAPP.exitQgis()
return QGISAPP
def stop_app():
"""
Cleans up and exits QGIS
"""
global QGISAPP
QGISAPP.exitQgis()
del QGISAPP
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
17623,
272,
636,
826,
4343,
647,
272,
10652,
9858,
272,
6148,
463,
520,
17474,
20527,
7800,
272,
1898,
3322,
520,
334,
35,
9,
7800,
701,
18619,
273,
2241,
1804,
85,
6164,
272,
11426,
4483,
520,
2530,
273,
2241,
32,
1490,
5668,
14,
335,
199,
17623,
199,
10,
17997,
627,
199,
10,
257,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
221,
627,
199,
10,
257,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
221,
627,
199,
10,
257,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
258,
627,
199,
10,
257,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
15530,
627,
199,
10,
17997,
627,
199,
17623,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
14817,
273,
2241,
1804,
85,
6164,
7,
199,
363,
602,
363,
275,
283,
19825,
20527,
7800,
7,
199,
363,
7307,
363,
275,
8189,
35,
9,
7800,
12,
18619,
273,
2241,
1804,
85,
6164,
7,
199,
199,
646,
747,
199,
646,
984,
199,
646,
27070,
199,
646,
9143,
199,
646,
570,
5730,
199,
646,
5549,
199,
504,
32212,
492,
6912,
199,
199,
504,
15640,
14,
24107,
14,
10901,
492,
27875,
12,
1413,
3926,
12,
1413,
2506,
199,
504,
15640,
14,
1018,
492,
334,
272,
4888,
5039,
12,
272,
26833,
2017,
12,
272,
4888,
18017,
5083,
3989,
12,
272,
5962,
12,
272,
22507,
12,
272,
4888,
9216,
3048,
199,
9,
199,
199,
646,
2882,
199,
199,
3,
2372,
282,
6902,
12,
781,
911,
3371,
642,
1373,
2945,
199,
63,
1746,
275,
2882,
14,
1746,
199,
2796,
14,
1974,
423,
4283,
63,
9127,
275,
12293,
421,
199,
533,
7640,
1547,
1746,
304,
339,
347,
702,
16862,
591,
8,
277,
12,
4045,
63,
2062,
12,
4045,
63,
1099,
12,
1011,
958,
304,
267,
408,
267,
520,
635,
4045,
63,
2062,
26,
710,
1642,
4045,
370,
6540,
267,
520,
635,
4045,
63,
1099,
26,
710,
3499,
4045,
370,
6540,
267,
520,
635,
1056,
26,
4879,
12,
437,
3878,
1056,
14,
961,
883,
506,
1202,
370,
4165,
717,
376,
1865,
701,
8502,
370,
1852,
3238,
4534,
787,
13524,
315,
717,
282,
1627,
3414,
340,
2985,
2793,
1133,
1336,
701,
849,
14,
267,
520,
6691,
6540,
26,
437,
2341,
402,
9132,
1511,
14,
325,
14,
71,
14,
586,
469,
1504,
26,
469,
282,
26,
3372,
12,
330,
26,
469,
7151,
26,
499,
1660,
3400,
26,
469,
7151,
26,
959,
789,
789,
586,
469,
1504,
26,
469,
636,
452,
10651,
9106,
8,
620,
776,
789,
789,
267,
520,
6691,
3803,
26,
298,
14908,
790,
2,
730,
901,
446,
1202,
370,
1336,
4534,
267,
687,
314,
1420,
1817,
370,
3932,
5226,
4534,
315,
314,
754,
1817,
14,
982,
440,
2013,
267,
4534,
787,
13524,
701,
3932,
1865,
315,
314,
4045,
334,
69,
14,
71,
14,
1642,
3878,
13524,
543,
1642,
3878,
12,
267,
5423,
9,
267,
408,
267,
291,
14,
1074,
16862,
591,
8,
1897,
63,
2062,
12,
4045,
63,
1099,
12,
715,
12,
1011,
958,
9,
339,
347,
1104,
16862,
591,
8,
277,
12,
4045,
63,
2062,
12,
4045,
63,
1099,
12,
675,
63,
479,
83,
29,
797,
12,
1011,
958,
304,
267,
408,
267,
520,
635,
4045,
63,
2062,
26,
710,
1642,
4045,
370,
6540,
267,
520,
635,
4045,
63,
1099,
26,
710,
3499,
4045,
370,
6540,
267,
520,
635,
675,
63,
479,
83,
26,
982,
2549,
12,
702,
83,
787,
1202,
370,
511,
3704,
12,
340,
3055,
12,
702,
83,
267,
787,
440,
1202,
436,
314,
805,
911,
1454,
372,
756,
340,
314,
511,
6918,
267,
520,
635,
1056,
26,
4879,
12,
437,
3878,
1056,
14,
961,
883,
506,
1202,
370,
4165,
717,
376,
1865,
701,
8502,
370,
1852,
3238,
4534,
787,
13524,
315,
717,
282,
1627,
3414,
340,
2985,
2793,
1133,
1336,
701,
849,
14,
267,
520,
6691,
6540,
26,
437,
2341,
402,
9132,
1511,
14,
325,
14,
71,
14,
586,
469,
1504,
26,
469,
282,
26,
3372,
12,
330,
26,
469,
7151,
26,
499,
1660,
3400,
26,
469,
7151,
26,
959,
789,
789,
586,
469,
1504,
26,
469,
636,
452,
10651,
9106,
8,
620,
776,
789,
789,
267,
520,
6691,
3803,
26,
298,
14908,
790,
2,
730,
901,
446,
1202,
370,
1336,
4534,
267,
687,
314,
1420,
1817,
370,
3932,
5226,
4534,
315,
314,
754,
1817,
14,
982,
440,
2013,
267,
4534,
787,
13524,
701,
3932,
1865,
315,
314,
4045,
334,
69,
14,
71,
14,
1642,
3878,
13524,
543,
1642,
3878,
12,
267,
5423,
9,
267,
408,
398,
862,
26,
288,
1056,
275,
2074,
459,
1069,
418,
267,
871,
4067,
26,
288,
1056,
275,
26833,
2017,
342,
398,
862,
26,
288,
6540,
275,
2074,
459,
5785,
418,
267,
871,
4067,
26,
288,
6540,
275,
1052,
398,
327,
18955,
445,
15062,
267,
340,
283,
4247,
63,
19034,
63,
1074,
7,
440,
315,
6540,
503,
440,
6540,
459,
4247,
63,
19034,
63,
1074,
2565,
288,
1420,
63,
11412,
275,
4045,
63,
2062,
14,
27735,
1252,
19034,
1252,
475,
31810,
8,
7350,
18017,
5083,
3989,
14,
55,
12362,
63,
4225,
15849,
7387,
9,
288,
754,
63,
11412,
275,
4045,
63,
1099,
14,
27735,
1252,
19034,
1252,
475,
31810,
8,
7350,
18017,
5083,
3989,
14,
55,
12362,
63,
4225,
15849,
7387,
9,
953,
340,
675,
63,
479,
83,
26,
355,
485,
1746,
14,
629,
8,
277,
12,
4045,
63,
2062,
14,
27735,
1252,
19034,
1062,
4045,
63,
1099,
14,
27735,
1252,
19034,
1012,
288,
916,
4045,
63,
2062,
14,
27735,
1252,
19034,
342,
1137,
4045,
63,
1099,
14,
27735,
1252,
19034,
837,
355,
372,
756,
398,
327,
18955,
4534,
267,
340,
675,
63,
479,
83,
26,
288,
485,
1746,
14,
629,
8,
277,
12,
4045,
63,
2062,
14,
4445,
2353,
1062,
4045,
63,
1099,
14,
4445,
2353,
1012,
267,
916,
4045,
63,
2062,
14,
4445,
2353,
342,
1137,
4045,
63,
1099,
14,
4445,
2353,
837,
288,
372,
756,
398,
862,
26,
288,
7151,
275,
6540,
459,
7660,
2545,
6833,
418,
267,
871,
4067,
26,
288,
7151,
275,
4329,
398,
862,
26,
288,
11111,
63,
1452,
63,
1074,
275,
6540,
459,
7660,
2545,
16851,
63,
1452,
63,
1074
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
17623,
272,
636,
826,
4343,
647,
272,
10652,
9858,
272,
6148,
463,
520,
17474,
20527,
7800,
272,
1898,
3322,
520,
334,
35,
9,
7800,
701,
18619,
273,
2241,
1804,
85,
6164,
272,
11426,
4483,
520,
2530,
273,
2241,
32,
1490,
5668,
14,
335,
199,
17623,
199,
10,
17997,
627,
199,
10,
257,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
221,
627,
199,
10,
257,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
221,
627,
199,
10,
257,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
258,
627,
199,
10,
257,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
15530,
627,
199,
10,
17997,
627,
199,
17623,
199,
624,
199,
199,
363,
2502,
363,
275,
283,
14817,
273,
2241,
1804,
85,
6164,
7,
199,
363,
602,
363,
275,
283,
19825,
20527,
7800,
7,
199,
363,
7307,
363,
275,
8189,
35,
9,
7800,
12,
18619,
273,
2241,
1804,
85,
6164,
7,
199,
199,
646,
747,
199,
646,
984,
199,
646,
27070,
199,
646,
9143,
199,
646,
570,
5730,
199,
646,
5549,
199,
504,
32212,
492,
6912,
199,
199,
504,
15640,
14,
24107,
14,
10901,
492,
27875,
12,
1413,
3926,
12,
1413,
2506,
199,
504,
15640,
14,
1018,
492,
334,
272,
4888,
5039,
12,
272,
26833,
2017,
12,
272,
4888,
18017,
5083,
3989,
12,
272,
5962,
12,
272,
22507,
12,
272,
4888,
9216,
3048,
199,
9,
199,
199,
646,
2882,
199,
199,
3,
2372,
282,
6902,
12,
781,
911,
3371,
642,
1373,
2945,
199,
63,
1746,
275,
2882,
14,
1746,
199,
2796,
14,
1974,
423,
4283,
63,
9127,
275,
12293,
421,
199,
533,
7640,
1547,
1746,
304,
339,
347,
702,
16862,
591,
8,
277,
12,
4045,
63,
2062,
12,
4045,
63,
1099,
12,
1011,
958,
304,
267,
408,
267,
520,
635,
4045,
63,
2062,
26,
710,
1642,
4045,
370,
6540,
267,
520,
635,
4045,
63,
1099,
26,
710,
3499,
4045,
370,
6540,
267,
520,
635,
1056,
26,
4879,
12,
437,
3878,
1056,
14,
961,
883,
506,
1202,
370,
4165,
717,
376,
1865,
701,
8502,
370,
1852,
3238,
4534,
787,
13524,
315,
717,
282,
1627,
3414,
340,
2985,
2793,
1133,
1336,
701,
849,
14,
267,
520,
6691,
6540,
26,
437,
2341,
402,
9132,
1511,
14,
325,
14,
71,
14,
586,
469,
1504,
26,
469,
282,
26,
3372,
12,
330,
26,
469,
7151,
26,
499,
1660,
3400,
26,
469,
7151,
26,
959,
789,
789,
586,
469,
1504,
26,
469,
636,
452,
10651,
9106,
8,
620,
776,
789,
789,
267,
520,
6691,
3803,
26,
298,
14908,
790,
2,
730,
901,
446,
1202,
370,
1336,
4534,
267,
687,
314,
1420,
1817,
370,
3932,
5226,
4534,
315,
314,
754,
1817,
14,
982,
440,
2013,
267,
4534,
787,
13524,
701,
3932,
1865,
315,
314,
4045,
334,
69,
14,
71,
14,
1642,
3878,
13524,
543,
1642,
3878,
12,
267,
5423,
9,
267,
408,
267,
291,
14,
1074,
16862,
591,
8,
1897,
63,
2062,
12,
4045,
63,
1099,
12,
715,
12,
1011,
958,
9,
339,
347,
1104,
16862,
591,
8,
277,
12,
4045,
63,
2062,
12,
4045,
63,
1099,
12,
675,
63,
479,
83,
29,
797,
12,
1011,
958,
304,
267,
408,
267,
520,
635,
4045,
63,
2062,
26,
710,
1642,
4045,
370,
6540,
267,
520,
635,
4045,
63,
1099,
26,
710,
3499,
4045,
370,
6540,
267,
520,
635,
675,
63,
479,
83,
26,
982,
2549,
12,
702,
83,
787,
1202,
370,
511,
3704,
12,
340,
3055,
12,
702,
83,
267,
787,
440,
1202,
436,
314,
805,
911,
1454,
372,
756,
340,
314,
511,
6918,
267,
520,
635,
1056,
26,
4879,
12,
437,
3878,
1056,
14,
961,
883,
506,
1202,
370,
4165,
717,
376,
1865,
701,
8502,
370,
1852,
3238,
4534,
787,
13524,
315,
717,
282,
1627,
3414,
340,
2985,
2793,
1133,
1336,
701,
849,
14,
267,
520,
6691,
6540,
26,
437,
2341,
402,
9132,
1511,
14,
325,
14,
71,
14,
586,
469,
1504,
26,
469,
282,
26,
3372,
12,
330,
26,
469,
7151,
26,
499,
1660,
3400,
26,
469,
7151,
26,
959,
789,
789,
586,
469,
1504,
26,
469,
636,
452,
10651,
9106,
8,
620,
776,
789,
789,
267,
520,
6691,
3803,
26,
298,
14908,
790,
2,
730,
901,
446,
1202,
370,
1336,
4534,
267,
687,
314,
1420,
1817,
370,
3932,
5226,
4534,
315,
314,
754,
1817,
14,
982,
440,
2013,
267,
4534,
787,
13524,
701,
3932,
1865,
315,
314,
4045,
334,
69,
14,
71,
14,
1642,
3878,
13524,
543,
1642,
3878,
12,
267,
5423,
9,
267,
408,
398,
862,
26,
288,
1056,
275,
2074,
459,
1069,
418,
267,
871,
4067,
26,
288,
1056,
275,
26833,
2017,
342,
398,
862,
26,
288,
6540,
275,
2074,
459,
5785,
418,
267,
871,
4067,
26,
288,
6540,
275,
1052,
398,
327,
18955,
445,
15062,
267,
340,
283,
4247,
63,
19034,
63,
1074,
7,
440,
315,
6540,
503,
440,
6540,
459,
4247,
63,
19034,
63,
1074,
2565,
288,
1420,
63,
11412,
275,
4045,
63,
2062,
14,
27735,
1252,
19034,
1252,
475,
31810,
8,
7350,
18017,
5083,
3989,
14,
55,
12362,
63,
4225,
15849,
7387,
9,
288,
754,
63,
11412,
275,
4045,
63,
1099,
14,
27735,
1252,
19034,
1252,
475,
31810,
8,
7350,
18017,
5083,
3989,
14,
55,
12362,
63,
4225,
15849,
7387,
9,
953,
340,
675,
63,
479,
83,
26,
355,
485,
1746,
14,
629,
8,
277,
12,
4045,
63,
2062,
14,
27735,
1252,
19034,
1062,
4045,
63,
1099,
14,
27735,
1252,
19034,
1012,
288,
916,
4045,
63,
2062,
14,
27735,
1252,
19034,
342,
1137,
4045,
63,
1099,
14,
27735,
1252,
19034,
837,
355,
372,
756,
398,
327,
18955,
4534,
267,
340,
675,
63,
479,
83,
26,
288,
485,
1746,
14,
629,
8,
277,
12,
4045,
63,
2062,
14,
4445,
2353,
1062,
4045,
63,
1099,
14,
4445,
2353,
1012,
267,
916,
4045,
63,
2062,
14,
4445,
2353,
342,
1137,
4045,
63,
1099,
14,
4445,
2353,
837,
288,
372,
756,
398,
862,
26,
288,
7151,
275,
6540,
459,
7660,
2545,
6833,
418,
267,
871,
4067,
26,
288,
7151,
275,
4329,
398,
862,
26,
288,
11111,
63,
1452,
63,
1074,
275,
6540,
459,
7660,
2545,
16851,
63,
1452,
63,
1074,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
xflows/rdm
|
rdm/wrappers/rsd/rsd.py
|
2
|
7509
|
# Python interface to RSD.
#
# author: Anze Vavpetic <anze.vavpetic@ijs.si>, 2012
#
import os.path
import shutil
import logging
import re
import tempfile
from stat import S_IREAD, S_IEXEC
from subprocess import PIPE
try:
from ..security import SafePopen
except:
import os
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.sys.path.append(parent_dir)
from security import SafePopen
DEBUG = True
# Setup a logger
logger = logging.getLogger("RSD [Python]")
logger.setLevel(logging.DEBUG if DEBUG else logging.INFO)
ch = logging.StreamHandler()
formatter = logging.Formatter("%(name)s %(levelname)s: %(message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)
class RSD(object):
'''
RSD python wrapper.
'''
THIS_DIR = os.path.dirname(__file__) if os.path.dirname(__file__) else '.'
RSD_FILES = ['featurize.pl', 'process.pl', 'rules.pl']
# Generated scripts filenames
CONSTRUCT = '_construct.pl'
SAVE = '_save.pl'
SUBGROUPS = '_subgroups.pl'
SCRIPTS = [CONSTRUCT, SAVE, SUBGROUPS]
ESSENTIAL_PARAMS = {
'clauselength' : 8,
'depth' : 4,
'negation' : 'none',
'min_coverage' : 1,
'filtering' : 'true'
}
def __init__(self, verbosity=logging.NOTSET):
"""
Creates an RSD object.
:param logging: Can be DEBUG, INFO or NOTSET (default).
This controls the verbosity of the output.
"""
self.tmpdir = tempfile.mkdtemp()
self.settings = dict()
logger.setLevel(verbosity)
# Copy needed files to tmp dir
for fn in RSD.RSD_FILES:
shutil.copy("%s/%s" % (RSD.THIS_DIR, fn), self.tmpdir)
def set(self, name, value):
"""
Sets the value of setting 'name' to 'value'.
:param name: Name of the setting
:param value: Value of the setting
"""
self.settings[name] = value
def settingsAsFacts(self, settings):
"""
Parses a string of settings.
:param setting: String of settings in the form:
``set(name1, val1), set(name2, val2)...``
"""
pattern = re.compile('set\(([a-zA-Z0-9_]+),(\[a-zA-Z0-9_]+)\)')
pairs = pattern.findall(settings)
for name, val in pairs:
self.set(name, val)
def induce(self, b, filestem='default',
examples=None,
pos=None,
neg=None,
cn2sd=True,
printOutput=False):
"""
Generate features and find subgroups.
:param filestem: The base name of this experiment.
:param examples: Classified examples; can be used instead of separate pos / neg files below.
:param pos: String of positive examples.
:param neg: String of negative examples.
:param b: String with background knowledge.
:param cn2sd: Find subgroups after feature construction?
:return: a tuple ``(features, weka, rules)``, where:
- features is a set of prolog clauses of generated features,
- weka is the propositional form of the input data,
- rules is a set of generated cn2sd subgroup descriptions;
this will be an empty string if cn2sd is set to False.
:rtype: tuple
"""
# Write the inputs
self.__prepare(filestem, b, examples=examples, pos=pos, neg=neg)
# Write scripts
self.__scripts(filestem)
dumpFile = None
if not printOutput:
dumpFile = tempfile.TemporaryFile()
# Run the script
logger.info("Running RSD...")
try:
for script in RSD.SCRIPTS:
# Skip subgroup discovery part?
if script == RSD.SUBGROUPS and not cn2sd:
continue
p = SafePopen(['yap', '-s50000', '-h200000', '-L', script],
cwd=self.tmpdir,
stdout=dumpFile,
stderr=dumpFile).safe_run()
stdout_str, stderr_str = p.communicate()
logger.debug(stdout_str)
logger.debug(stderr_str)
logger.info("Done.")
# Return the rules written in the output file.
features = open('%s/%s' % (self.tmpdir, filestem + '_frs.pl')).read()
weka = open('%s/%s' % (self.tmpdir, filestem + '.arff')).read()
rules = open('%s/%s' % (self.tmpdir, filestem + '.rules')).read() if cn2sd else ''
self.__cleanup()
return (features, weka, rules)
except OSError:
raise RuntimeError("Yap compiler could not be loaded! (see http://www.dcc.fc.up.pt/~vsc/Yap/).")
def __prepare(self, filestem, b, examples=None, pos=None, neg=None):
"""
Prepares the needed files.
"""
if examples:
examplesFile = open('%s/%s.pl' % (self.tmpdir, filestem), 'w')
examplesFile.write(examples)
examplesFile.close()
elif pos and neg:
posFile = open('%s/%s.f' % (self.tmpdir, filestem), 'w')
negFile = open('%s/%s.n' % (self.tmpdir, filestem), 'w')
posFile.write(pos)
negFile.write(neg)
posFile.close()
negFile.close()
else:
raise Exception('You need to provide either a single file of classified examples or \
two files, positive and negative examples.')
bFile = open('%s/%s.b' % (self.tmpdir, filestem), 'w')
# Write settings.
for setting, val in self.settings.items():
bFile.write(':- set(%s,%s).\n' % (setting, val))
bFile.write(b)
bFile.close()
def __cleanup(self):
"""
Cleans up all the temporary files.
"""
try:
shutil.rmtree(self.tmpdir)
except:
logger.info('Problem removing temporary files. The files are probably in use.')
def __scripts(self, filestem):
"""
Generates the required scripts.
"""
script_construct = open('%s/%s' % (self.tmpdir, RSD.CONSTRUCT), 'w')
script_save = open('%s/%s' % (self.tmpdir, RSD.SAVE), 'w')
script_subgroups = open('%s/%s' % (self.tmpdir, RSD.SUBGROUPS), 'w')
# Permit the owner to execute and read this script
for fn in RSD.SCRIPTS:
os.chmod('%s/%s' % (self.tmpdir, fn), S_IREAD | S_IEXEC)
# Writes one line of script
new_script = lambda script: lambda x: script.write(x + '\n')
#
# 'Construction' script
#
w = new_script(script_construct)
w(':- initialization(main).')
w('main :-')
w('[featurize],')
w('r(%s),' % filestem)
w('w.')
script_construct.close()
#
# 'Saving' script
#
w = new_script(script_save)
w(':- initialization(main).')
w('main :-')
w('[process],')
w('r(%s),' % filestem)
w('w,')
w('w(weka, %s),' % filestem)
w('w(rsd, %s).' % filestem)
script_save.close()
#
# 'Subgroups' script
#
w = new_script(script_subgroups)
w(':- initialization(main).')
w('main :-')
w('[rules],')
w('r(%s),' % filestem)
w('i,')
w('w.')
script_subgroups.close()
|
mit
|
[
3,
2018,
3217,
370,
820,
3693,
14,
199,
3,
199,
3,
4132,
26,
1626,
806,
812,
1214,
321,
764,
665,
290,
806,
14,
86,
1214,
321,
764,
32,
73,
3596,
14,
338,
6244,
6029,
199,
3,
199,
646,
747,
14,
515,
199,
646,
5145,
199,
646,
2050,
199,
646,
295,
199,
646,
5549,
199,
504,
5672,
492,
428,
63,
41,
5670,
12,
428,
63,
41,
10276,
199,
504,
3873,
492,
22773,
199,
199,
893,
26,
272,
687,
2508,
4416,
492,
14969,
7942,
199,
2590,
26,
272,
492,
747,
272,
1676,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
272,
747,
14,
1274,
14,
515,
14,
740,
8,
1708,
63,
694,
9,
272,
687,
6391,
492,
14969,
7942,
199,
199,
5287,
275,
715,
199,
199,
3,
12439,
282,
2512,
199,
2921,
275,
2050,
14,
5572,
480,
50,
3693,
359,
4718,
12523,
199,
2921,
14,
13548,
8,
4806,
14,
5287,
340,
10990,
587,
2050,
14,
4531,
9,
199,
335,
275,
2050,
14,
22482,
342,
199,
8911,
275,
2050,
14,
7772,
480,
2840,
354,
9,
83,
2818,
20056,
9,
83,
26,
2818,
1188,
9,
83,
531,
199,
335,
14,
26076,
8,
8911,
9,
199,
2921,
14,
18826,
8,
335,
9,
199,
199,
533,
820,
3693,
8,
785,
304,
272,
1449,
272,
820,
3693,
2366,
4975,
14,
272,
1449,
272,
5749,
63,
3022,
275,
747,
14,
515,
14,
3475,
3460,
493,
3368,
340,
747,
14,
515,
14,
3475,
3460,
493,
3368,
587,
7815,
272,
820,
3693,
63,
9472,
275,
788,
11873,
300,
794,
14,
1168,
297,
283,
1412,
14,
1168,
297,
283,
4423,
14,
1168,
418,
339,
327,
17065,
10554,
6203,
272,
1868,
8893,
275,
2513,
8514,
14,
1168,
7,
272,
13950,
2524,
275,
2513,
2117,
14,
1168,
7,
272,
7605,
27544,
275,
2513,
954,
2634,
14,
1168,
7,
339,
30203,
51,
275,
359,
1864,
8893,
12,
13950,
2524,
12,
7605,
27544,
61,
339,
221,
1608,
8246,
63,
17978,
275,
469,
267,
283,
8501,
1267,
7,
520,
1695,
12,
267,
283,
4631,
7,
520,
841,
12,
267,
283,
685,
5360,
7,
520,
283,
3592,
297,
267,
283,
827,
63,
10828,
7,
520,
413,
12,
267,
283,
24133,
7,
520,
283,
2052,
7,
272,
789,
339,
347,
636,
826,
721,
277,
12,
8661,
29,
4806,
14,
4609,
3597,
304,
267,
408,
267,
10560,
376,
820,
3693,
909,
14,
953,
520,
635,
2050,
26,
6855,
506,
10990,
12,
24008,
503,
2845,
3597,
334,
885,
680,
953,
961,
13467,
314,
8661,
402,
314,
1072,
14,
398,
408,
267,
291,
14,
8616,
275,
5549,
14,
11983,
342,
267,
291,
14,
1751,
275,
1211,
342,
267,
2512,
14,
13548,
8,
9833,
9,
398,
327,
11247,
4346,
1584,
370,
3529,
2935,
267,
367,
4325,
315,
820,
3693,
14,
50,
3693,
63,
9472,
26,
288,
5145,
14,
1574,
3647,
83,
3149,
83,
2,
450,
334,
50,
3693,
14,
24571,
63,
3022,
12,
4325,
395,
291,
14,
8616,
9,
339,
347,
663,
8,
277,
12,
536,
12,
574,
304,
267,
408,
267,
10729,
314,
574,
402,
4260,
283,
354,
7,
370,
283,
585,
1370,
953,
520,
635,
536,
26,
2812,
402,
314,
4260,
288,
520,
635,
574,
26,
1594,
402,
314,
4260,
398,
408,
267,
291,
14,
1751,
59,
354,
61,
275,
574,
339,
347,
2202,
2822,
25821,
8,
277,
12,
2202,
304,
267,
408,
267,
29968,
282,
1059,
402,
2202,
14,
953,
520,
635,
4260,
26,
2624,
402,
2202,
315,
314,
1824,
26,
7846,
1124,
409,
8,
354,
17,
12,
1139,
17,
395,
663,
8,
354,
18,
12,
1139,
18,
680,
703,
1040,
398,
408,
267,
3851,
275,
295,
14,
2014,
360,
409,
24805,
779,
65,
13,
6353,
13,
58,
16,
13,
25,
22155,
395,
2961,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
63,
18096,
5942,
267,
6342,
275,
3851,
14,
6452,
8,
1751,
9,
267,
367,
536,
12,
1139,
315,
6342,
26,
288,
291,
14,
409,
8,
354,
12,
1139,
9,
339,
347,
315,
3402,
8,
277,
12,
330,
12,
1584,
563,
534,
885,
297,
2049,
7251,
29,
403,
12,
2049,
2086,
29,
403,
12,
2049,
14158,
29,
403,
12,
2049,
20087,
18,
3893,
29,
549,
12,
2049,
870,
2959,
29,
797,
304,
267,
408,
267,
7958,
4534,
436,
2342,
1007,
2634,
14,
953,
520,
635,
1584,
563,
26,
710,
1300,
536,
402,
642,
11805,
14,
288,
520,
635,
7251,
26,
8465,
2608,
1290,
7251,
27,
883,
506,
1202,
3140,
402,
7396,
2086,
1182,
14158,
1584,
5084,
14,
288,
520,
635,
2086,
26,
2624,
402,
7317,
7251,
14,
288,
520,
635,
14158,
26,
2624,
402,
6946,
7251,
14,
288,
520,
635,
330,
26,
2624,
543,
8020,
29105,
14,
288,
520,
635,
20087,
18,
3893,
26,
6668,
1007,
2634,
2410,
3878,
14538,
31,
953,
520,
1107,
26,
282,
2008,
15475,
3179,
12,
781,
7351,
12,
4713,
28616,
2382,
26,
953,
446,
4534,
365,
282,
663,
402,
557,
793,
25089,
402,
4046,
4534,
12,
288,
446,
781,
7351,
365,
314,
557,
17867,
1824,
402,
314,
1324,
666,
12,
288,
446,
4713,
365,
282,
663,
402,
4046,
20087,
18,
3893,
1007,
923,
18714,
27,
1598,
642,
911,
506,
376,
2701,
1059,
340,
20087,
18,
3893,
365,
663,
370,
756,
14,
953,
520,
4500,
26,
2008,
267,
408,
267,
327,
6990,
314,
4153,
267,
291,
855,
6726,
8,
1725,
563,
12,
330,
12,
7251,
29,
8589,
12,
2086,
29,
1712,
12,
14158,
29,
8705,
9,
398,
327,
6990,
10554,
267,
291,
855,
6429,
8,
1725,
563,
9,
398,
5461,
1173,
275,
488,
267,
340,
440,
870,
2959,
26,
288,
5461,
1173,
275,
5549,
14,
13271,
342,
398,
327,
3378,
314,
2884,
267,
2512,
14,
815,
480,
9602,
820,
3693,
12594,
267,
862,
26,
288,
367,
2884,
315,
820,
3693,
14,
10484,
51,
26,
355,
327,
8232,
1007,
923,
13172,
1777,
31,
355,
340,
2884,
508,
820,
3693,
14,
6348,
27544,
436,
440,
20087,
18,
3893,
26,
490,
1980,
355,
299,
275,
14969,
7942,
2941,
89,
439,
297,
2475,
83,
21,
993,
297,
2475,
72,
18,
5345,
297,
2475,
44,
297,
2884,
467,
2892,
8288,
29,
277,
14,
8616,
12,
2892,
3839,
29,
2724,
1173,
12,
2892,
4635,
29,
2724,
1173,
680
] |
[
2018,
3217,
370,
820,
3693,
14,
199,
3,
199,
3,
4132,
26,
1626,
806,
812,
1214,
321,
764,
665,
290,
806,
14,
86,
1214,
321,
764,
32,
73,
3596,
14,
338,
6244,
6029,
199,
3,
199,
646,
747,
14,
515,
199,
646,
5145,
199,
646,
2050,
199,
646,
295,
199,
646,
5549,
199,
504,
5672,
492,
428,
63,
41,
5670,
12,
428,
63,
41,
10276,
199,
504,
3873,
492,
22773,
199,
199,
893,
26,
272,
687,
2508,
4416,
492,
14969,
7942,
199,
2590,
26,
272,
492,
747,
272,
1676,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
29658,
272,
747,
14,
1274,
14,
515,
14,
740,
8,
1708,
63,
694,
9,
272,
687,
6391,
492,
14969,
7942,
199,
199,
5287,
275,
715,
199,
199,
3,
12439,
282,
2512,
199,
2921,
275,
2050,
14,
5572,
480,
50,
3693,
359,
4718,
12523,
199,
2921,
14,
13548,
8,
4806,
14,
5287,
340,
10990,
587,
2050,
14,
4531,
9,
199,
335,
275,
2050,
14,
22482,
342,
199,
8911,
275,
2050,
14,
7772,
480,
2840,
354,
9,
83,
2818,
20056,
9,
83,
26,
2818,
1188,
9,
83,
531,
199,
335,
14,
26076,
8,
8911,
9,
199,
2921,
14,
18826,
8,
335,
9,
199,
199,
533,
820,
3693,
8,
785,
304,
272,
1449,
272,
820,
3693,
2366,
4975,
14,
272,
1449,
272,
5749,
63,
3022,
275,
747,
14,
515,
14,
3475,
3460,
493,
3368,
340,
747,
14,
515,
14,
3475,
3460,
493,
3368,
587,
7815,
272,
820,
3693,
63,
9472,
275,
788,
11873,
300,
794,
14,
1168,
297,
283,
1412,
14,
1168,
297,
283,
4423,
14,
1168,
418,
339,
327,
17065,
10554,
6203,
272,
1868,
8893,
275,
2513,
8514,
14,
1168,
7,
272,
13950,
2524,
275,
2513,
2117,
14,
1168,
7,
272,
7605,
27544,
275,
2513,
954,
2634,
14,
1168,
7,
339,
30203,
51,
275,
359,
1864,
8893,
12,
13950,
2524,
12,
7605,
27544,
61,
339,
221,
1608,
8246,
63,
17978,
275,
469,
267,
283,
8501,
1267,
7,
520,
1695,
12,
267,
283,
4631,
7,
520,
841,
12,
267,
283,
685,
5360,
7,
520,
283,
3592,
297,
267,
283,
827,
63,
10828,
7,
520,
413,
12,
267,
283,
24133,
7,
520,
283,
2052,
7,
272,
789,
339,
347,
636,
826,
721,
277,
12,
8661,
29,
4806,
14,
4609,
3597,
304,
267,
408,
267,
10560,
376,
820,
3693,
909,
14,
953,
520,
635,
2050,
26,
6855,
506,
10990,
12,
24008,
503,
2845,
3597,
334,
885,
680,
953,
961,
13467,
314,
8661,
402,
314,
1072,
14,
398,
408,
267,
291,
14,
8616,
275,
5549,
14,
11983,
342,
267,
291,
14,
1751,
275,
1211,
342,
267,
2512,
14,
13548,
8,
9833,
9,
398,
327,
11247,
4346,
1584,
370,
3529,
2935,
267,
367,
4325,
315,
820,
3693,
14,
50,
3693,
63,
9472,
26,
288,
5145,
14,
1574,
3647,
83,
3149,
83,
2,
450,
334,
50,
3693,
14,
24571,
63,
3022,
12,
4325,
395,
291,
14,
8616,
9,
339,
347,
663,
8,
277,
12,
536,
12,
574,
304,
267,
408,
267,
10729,
314,
574,
402,
4260,
283,
354,
7,
370,
283,
585,
1370,
953,
520,
635,
536,
26,
2812,
402,
314,
4260,
288,
520,
635,
574,
26,
1594,
402,
314,
4260,
398,
408,
267,
291,
14,
1751,
59,
354,
61,
275,
574,
339,
347,
2202,
2822,
25821,
8,
277,
12,
2202,
304,
267,
408,
267,
29968,
282,
1059,
402,
2202,
14,
953,
520,
635,
4260,
26,
2624,
402,
2202,
315,
314,
1824,
26,
7846,
1124,
409,
8,
354,
17,
12,
1139,
17,
395,
663,
8,
354,
18,
12,
1139,
18,
680,
703,
1040,
398,
408,
267,
3851,
275,
295,
14,
2014,
360,
409,
24805,
779,
65,
13,
6353,
13,
58,
16,
13,
25,
22155,
395,
2961,
59,
65,
13,
6353,
13,
58,
16,
13,
25,
63,
18096,
5942,
267,
6342,
275,
3851,
14,
6452,
8,
1751,
9,
267,
367,
536,
12,
1139,
315,
6342,
26,
288,
291,
14,
409,
8,
354,
12,
1139,
9,
339,
347,
315,
3402,
8,
277,
12,
330,
12,
1584,
563,
534,
885,
297,
2049,
7251,
29,
403,
12,
2049,
2086,
29,
403,
12,
2049,
14158,
29,
403,
12,
2049,
20087,
18,
3893,
29,
549,
12,
2049,
870,
2959,
29,
797,
304,
267,
408,
267,
7958,
4534,
436,
2342,
1007,
2634,
14,
953,
520,
635,
1584,
563,
26,
710,
1300,
536,
402,
642,
11805,
14,
288,
520,
635,
7251,
26,
8465,
2608,
1290,
7251,
27,
883,
506,
1202,
3140,
402,
7396,
2086,
1182,
14158,
1584,
5084,
14,
288,
520,
635,
2086,
26,
2624,
402,
7317,
7251,
14,
288,
520,
635,
14158,
26,
2624,
402,
6946,
7251,
14,
288,
520,
635,
330,
26,
2624,
543,
8020,
29105,
14,
288,
520,
635,
20087,
18,
3893,
26,
6668,
1007,
2634,
2410,
3878,
14538,
31,
953,
520,
1107,
26,
282,
2008,
15475,
3179,
12,
781,
7351,
12,
4713,
28616,
2382,
26,
953,
446,
4534,
365,
282,
663,
402,
557,
793,
25089,
402,
4046,
4534,
12,
288,
446,
781,
7351,
365,
314,
557,
17867,
1824,
402,
314,
1324,
666,
12,
288,
446,
4713,
365,
282,
663,
402,
4046,
20087,
18,
3893,
1007,
923,
18714,
27,
1598,
642,
911,
506,
376,
2701,
1059,
340,
20087,
18,
3893,
365,
663,
370,
756,
14,
953,
520,
4500,
26,
2008,
267,
408,
267,
327,
6990,
314,
4153,
267,
291,
855,
6726,
8,
1725,
563,
12,
330,
12,
7251,
29,
8589,
12,
2086,
29,
1712,
12,
14158,
29,
8705,
9,
398,
327,
6990,
10554,
267,
291,
855,
6429,
8,
1725,
563,
9,
398,
5461,
1173,
275,
488,
267,
340,
440,
870,
2959,
26,
288,
5461,
1173,
275,
5549,
14,
13271,
342,
398,
327,
3378,
314,
2884,
267,
2512,
14,
815,
480,
9602,
820,
3693,
12594,
267,
862,
26,
288,
367,
2884,
315,
820,
3693,
14,
10484,
51,
26,
355,
327,
8232,
1007,
923,
13172,
1777,
31,
355,
340,
2884,
508,
820,
3693,
14,
6348,
27544,
436,
440,
20087,
18,
3893,
26,
490,
1980,
355,
299,
275,
14969,
7942,
2941,
89,
439,
297,
2475,
83,
21,
993,
297,
2475,
72,
18,
5345,
297,
2475,
44,
297,
2884,
467,
2892,
8288,
29,
277,
14,
8616,
12,
2892,
3839,
29,
2724,
1173,
12,
2892,
4635,
29,
2724,
1173,
680,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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~~~~~~~~~~~~
Utilities related to importing modules and symbols by name.
"""
from __future__ import absolute_import
import imp as _imp
import importlib
import os
import sys
from contextlib import contextmanager
from kombu.utils import symbol_by_name
from celery.five import reload
__all__ = [
'NotAPackage', 'qualname', 'instantiate', 'symbol_by_name', 'cwd_in_path',
'find_module', 'import_from_cwd', 'reload_from_cwd', 'module_file',
]
class NotAPackage(Exception):
pass
if sys.version_info > (3, 3): # pragma: no cover
def qualname(obj):
if not hasattr(obj, '__name__') and hasattr(obj, '__class__'):
obj = obj.__class__
q = getattr(obj, '__qualname__', None)
if '.' not in q:
q = '.'.join((obj.__module__, q))
return q
else:
def qualname(obj): # noqa
if not hasattr(obj, '__name__') and hasattr(obj, '__class__'):
obj = obj.__class__
return '.'.join((obj.__module__, obj.__name__))
def instantiate(name, *args, **kwargs):
"""Instantiate class by name.
See :func:`symbol_by_name`.
"""
return symbol_by_name(name)(*args, **kwargs)
@contextmanager
def cwd_in_path():
cwd = os.getcwd()
if cwd in sys.path:
yield
else:
sys.path.insert(0, cwd)
try:
yield cwd
finally:
try:
sys.path.remove(cwd)
except ValueError: # pragma: no cover
pass
def find_module(module, path=None, imp=None):
"""Version of :func:`imp.find_module` supporting dots."""
if imp is None:
imp = importlib.import_module
with cwd_in_path():
if '.' in module:
last = None
parts = module.split('.')
for i, part in enumerate(parts[:-1]):
mpart = imp('.'.join(parts[:i + 1]))
try:
path = mpart.__path__
except AttributeError:
raise NotAPackage(module)
last = _imp.find_module(parts[i + 1], path)
return last
return _imp.find_module(module)
def import_from_cwd(module, imp=None, package=None):
"""Import module, but make sure it finds modules
located in the current directory.
Modules located in the current directory has
precedence over modules located in `sys.path`.
"""
if imp is None:
imp = importlib.import_module
with cwd_in_path():
return imp(module, package=package)
def reload_from_cwd(module, reloader=None):
if reloader is None:
reloader = reload
with cwd_in_path():
return reloader(module)
def module_file(module):
"""Return the correct original file name of a module."""
name = module.__file__
return name[:-1] if name.endswith('.pyc') else name
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
22748,
14,
1208,
14,
646,
272,
18294,
23597,
339,
738,
17933,
4048,
370,
16306,
4621,
436,
6698,
701,
536,
14,
199,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
1742,
465,
485,
3236,
199,
646,
14802,
199,
646,
747,
199,
646,
984,
199,
199,
504,
15502,
492,
27608,
199,
199,
504,
1022,
676,
464,
14,
1208,
492,
5272,
63,
991,
63,
354,
199,
199,
504,
22748,
14,
23702,
492,
13101,
199,
199,
363,
452,
363,
275,
359,
272,
283,
1763,
1282,
564,
474,
297,
283,
537,
354,
297,
283,
3615,
18973,
297,
283,
5155,
63,
991,
63,
354,
297,
283,
6525,
63,
262,
63,
515,
297,
272,
283,
1623,
63,
578,
297,
283,
646,
63,
504,
63,
6525,
297,
283,
9233,
63,
504,
63,
6525,
297,
283,
578,
63,
493,
297,
199,
61,
421,
199,
533,
2832,
1282,
564,
474,
8,
1726,
304,
272,
986,
421,
199,
692,
984,
14,
1023,
63,
815,
690,
334,
19,
12,
650,
304,
221,
327,
11942,
26,
949,
8486,
272,
347,
6420,
354,
8,
1113,
304,
267,
340,
440,
2688,
8,
1113,
12,
2560,
354,
13766,
436,
2688,
8,
1113,
12,
2560,
533,
12168,
288,
1559,
275,
1559,
855,
533,
363,
267,
1894,
275,
2519,
8,
1113,
12,
2560,
537,
354,
7500,
488,
9,
267,
340,
7815,
440,
315,
1894,
26,
288,
1894,
275,
15671,
904,
1332,
1113,
855,
578,
3108,
1894,
430,
267,
372,
1894,
199,
2836,
26,
272,
347,
6420,
354,
8,
1113,
304,
221,
327,
8151,
267,
340,
440,
2688,
8,
1113,
12,
2560,
354,
13766,
436,
2688,
8,
1113,
12,
2560,
533,
12168,
288,
1559,
275,
1559,
855,
533,
363,
267,
372,
15671,
904,
1332,
1113,
855,
578,
3108,
1559,
855,
354,
8964,
421,
199,
318,
17321,
8,
354,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
10083,
18973,
1021,
701,
536,
14,
339,
1666,
520,
1532,
1705,
5155,
63,
991,
63,
354,
2313,
339,
408,
272,
372,
5272,
63,
991,
63,
354,
8,
354,
25967,
589,
12,
1011,
958,
9,
421,
199,
32,
14237,
199,
318,
8288,
63,
262,
63,
515,
837,
272,
8288,
275,
747,
14,
9458,
342,
272,
340,
8288,
315,
984,
14,
515,
26,
267,
1995,
272,
587,
26,
267,
984,
14,
515,
14,
3176,
8,
16,
12,
8288,
9,
267,
862,
26,
288,
1995,
8288,
267,
3753,
26,
288,
862,
26,
355,
984,
14,
515,
14,
2168,
8,
6525,
9,
288,
871,
1722,
26,
221,
327,
11942,
26,
949,
8486,
355,
986,
421,
199,
318,
2342,
63,
578,
8,
578,
12,
931,
29,
403,
12,
1742,
29,
403,
304,
272,
408,
3353,
402,
520,
1532,
1705,
3236,
14,
1623,
63,
578,
64,
21038,
21185,
1041,
272,
340,
1742,
365,
488,
26,
267,
1742,
275,
14802,
14,
646,
63,
578,
272,
543,
8288,
63,
262,
63,
515,
837,
267,
340,
7815,
315,
859,
26,
288,
2061,
275,
488,
288,
4184,
275,
859,
14,
1294,
7563,
288,
367,
284,
12,
1777,
315,
3874,
8,
4181,
4439,
17,
4682,
355,
6118,
580,
275,
1742,
5175,
1370,
904,
8,
4181,
1491,
73,
435,
413,
2459,
355,
862,
26,
490,
931,
275,
6118,
580,
855,
515,
363,
355,
871,
4281,
26,
490,
746,
2832,
1282,
564,
474,
8,
578,
9,
355,
2061,
275,
485,
3236,
14,
1623,
63,
578,
8,
4181,
59,
73,
435,
413,
467,
931,
9,
288,
372,
2061,
267,
372,
485,
3236,
14,
1623,
63,
578,
8,
578,
9,
421,
199,
318,
492,
63,
504,
63,
6525,
8,
578,
12,
1742,
29,
403,
12,
2559,
29,
403,
304,
272,
408,
6295,
859,
12,
1325,
1852,
3238,
652,
17651,
4621,
272,
16180,
315,
314,
1453,
2082,
14,
339,
18167,
16180,
315,
314,
1453,
2082,
965,
272,
13823,
1806,
4621,
16180,
315,
658,
1274,
14,
515,
2313,
272,
408,
272,
340,
1742,
365,
488,
26,
267,
1742,
275,
14802,
14,
646,
63,
578,
272,
543,
8288,
63,
262,
63,
515,
837,
267,
372,
1742,
8,
578,
12,
2559,
29,
2491,
9,
421,
199,
318,
13101,
63,
504,
63,
6525,
8,
578,
12,
295,
3422,
29,
403,
304,
272,
340,
295,
3422,
365,
488,
26,
267,
295,
3422,
275,
13101,
272,
543,
8288,
63,
262,
63,
515,
837,
267,
372,
295,
3422,
8,
578,
9,
421,
199,
318,
859,
63,
493,
8,
578,
304,
272,
408,
1767,
314,
3211,
3379,
570,
536,
402,
282,
859,
1041,
272,
536,
275,
859,
855,
493,
363,
272,
372,
536,
4439,
17,
61,
340,
536,
14,
4130,
5175,
11357,
358,
587,
536,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
22748,
14,
1208,
14,
646,
272,
18294,
23597,
339,
738,
17933,
4048,
370,
16306,
4621,
436,
6698,
701,
536,
14,
199,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
199,
646,
1742,
465,
485,
3236,
199,
646,
14802,
199,
646,
747,
199,
646,
984,
199,
199,
504,
15502,
492,
27608,
199,
199,
504,
1022,
676,
464,
14,
1208,
492,
5272,
63,
991,
63,
354,
199,
199,
504,
22748,
14,
23702,
492,
13101,
199,
199,
363,
452,
363,
275,
359,
272,
283,
1763,
1282,
564,
474,
297,
283,
537,
354,
297,
283,
3615,
18973,
297,
283,
5155,
63,
991,
63,
354,
297,
283,
6525,
63,
262,
63,
515,
297,
272,
283,
1623,
63,
578,
297,
283,
646,
63,
504,
63,
6525,
297,
283,
9233,
63,
504,
63,
6525,
297,
283,
578,
63,
493,
297,
199,
61,
421,
199,
533,
2832,
1282,
564,
474,
8,
1726,
304,
272,
986,
421,
199,
692,
984,
14,
1023,
63,
815,
690,
334,
19,
12,
650,
304,
221,
327,
11942,
26,
949,
8486,
272,
347,
6420,
354,
8,
1113,
304,
267,
340,
440,
2688,
8,
1113,
12,
2560,
354,
13766,
436,
2688,
8,
1113,
12,
2560,
533,
12168,
288,
1559,
275,
1559,
855,
533,
363,
267,
1894,
275,
2519,
8,
1113,
12,
2560,
537,
354,
7500,
488,
9,
267,
340,
7815,
440,
315,
1894,
26,
288,
1894,
275,
15671,
904,
1332,
1113,
855,
578,
3108,
1894,
430,
267,
372,
1894,
199,
2836,
26,
272,
347,
6420,
354,
8,
1113,
304,
221,
327,
8151,
267,
340,
440,
2688,
8,
1113,
12,
2560,
354,
13766,
436,
2688,
8,
1113,
12,
2560,
533,
12168,
288,
1559,
275,
1559,
855,
533,
363,
267,
372,
15671,
904,
1332,
1113,
855,
578,
3108,
1559,
855,
354,
8964,
421,
199,
318,
17321,
8,
354,
12,
627,
589,
12,
1011,
958,
304,
272,
408,
10083,
18973,
1021,
701,
536,
14,
339,
1666,
520,
1532,
1705,
5155,
63,
991,
63,
354,
2313,
339,
408,
272,
372,
5272,
63,
991,
63,
354,
8,
354,
25967,
589,
12,
1011,
958,
9,
421,
199,
32,
14237,
199,
318,
8288,
63,
262,
63,
515,
837,
272,
8288,
275,
747,
14,
9458,
342,
272,
340,
8288,
315,
984,
14,
515,
26,
267,
1995,
272,
587,
26,
267,
984,
14,
515,
14,
3176,
8,
16,
12,
8288,
9,
267,
862,
26,
288,
1995,
8288,
267,
3753,
26,
288,
862,
26,
355,
984,
14,
515,
14,
2168,
8,
6525,
9,
288,
871,
1722,
26,
221,
327,
11942,
26,
949,
8486,
355,
986,
421,
199,
318,
2342,
63,
578,
8,
578,
12,
931,
29,
403,
12,
1742,
29,
403,
304,
272,
408,
3353,
402,
520,
1532,
1705,
3236,
14,
1623,
63,
578,
64,
21038,
21185,
1041,
272,
340,
1742,
365,
488,
26,
267,
1742,
275,
14802,
14,
646,
63,
578,
272,
543,
8288,
63,
262,
63,
515,
837,
267,
340,
7815,
315,
859,
26,
288,
2061,
275,
488,
288,
4184,
275,
859,
14,
1294,
7563,
288,
367,
284,
12,
1777,
315,
3874,
8,
4181,
4439,
17,
4682,
355,
6118,
580,
275,
1742,
5175,
1370,
904,
8,
4181,
1491,
73,
435,
413,
2459,
355,
862,
26,
490,
931,
275,
6118,
580,
855,
515,
363,
355,
871,
4281,
26,
490,
746,
2832,
1282,
564,
474,
8,
578,
9,
355,
2061,
275,
485,
3236,
14,
1623,
63,
578,
8,
4181,
59,
73,
435,
413,
467,
931,
9,
288,
372,
2061,
267,
372,
485,
3236,
14,
1623,
63,
578,
8,
578,
9,
421,
199,
318,
492,
63,
504,
63,
6525,
8,
578,
12,
1742,
29,
403,
12,
2559,
29,
403,
304,
272,
408,
6295,
859,
12,
1325,
1852,
3238,
652,
17651,
4621,
272,
16180,
315,
314,
1453,
2082,
14,
339,
18167,
16180,
315,
314,
1453,
2082,
965,
272,
13823,
1806,
4621,
16180,
315,
658,
1274,
14,
515,
2313,
272,
408,
272,
340,
1742,
365,
488,
26,
267,
1742,
275,
14802,
14,
646,
63,
578,
272,
543,
8288,
63,
262,
63,
515,
837,
267,
372,
1742,
8,
578,
12,
2559,
29,
2491,
9,
421,
199,
318,
13101,
63,
504,
63,
6525,
8,
578,
12,
295,
3422,
29,
403,
304,
272,
340,
295,
3422,
365,
488,
26,
267,
295,
3422,
275,
13101,
272,
543,
8288,
63,
262,
63,
515,
837,
267,
372,
295,
3422,
8,
578,
9,
421,
199,
318,
859,
63,
493,
8,
578,
304,
272,
408,
1767,
314,
3211,
3379,
570,
536,
402,
282,
859,
1041,
272,
536,
275,
859,
855,
493,
363,
272,
372,
536,
4439,
17,
61,
340,
536,
14,
4130,
5175,
11357,
358,
587,
536,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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..','py'])
import h2o, h2o_cmd, h2o_import as h2i, h2o_glm, h2o_common, h2o_exec as h2e
import h2o_print
DO_GLM = False
LOG_MACHINE_STATS = True
print "Assumes you ran ../build_for_clone.py in this directory"
print "Using h2o-nodes.json. Also the sandbox dir"
class releaseTest(h2o_common.ReleaseCommon, unittest.TestCase):
def sub_c2_nongz_fvec_long(self):
# a kludge
h2o.setup_benchmark_log()
avgMichalSize = 237270000
bucket = 'home-0xdiag-datasets'
### importFolderPath = 'more1_1200_link'
importFolderPath = 'manyfiles-nflx'
print "Using non-gz'ed files in", importFolderPath
csvFilenameList= [
("*[1][0-4][0-9].dat", "file_50_A.dat", 50 * avgMichalSize, 1800),
# ("*[1][0-9][0-9].dat", "file_100_A.dat", 100 * avgMichalSize, 3600),
]
if LOG_MACHINE_STATS:
benchmarkLogging = ['cpu', 'disk', 'network']
else:
benchmarkLogging = []
pollTimeoutSecs = 120
retryDelaySecs = 10
for trial, (csvFilepattern, csvFilename, totalBytes, timeoutSecs) in enumerate(csvFilenameList):
csvPathname = importFolderPath + "/" + csvFilepattern
# double import still causing problems?
# (importResult, importPattern) = h2i.import_only(bucket=bucket, path=csvPathname, schema='local')
# importFullList = importResult['files']
# importFailList = importResult['fails']
# print "\n Problem if this is not empty: importFailList:", h2o.dump_json(importFailList)
# this accumulates performance stats into a benchmark log over multiple runs
# good for tracking whether we're getting slower or faster
h2o.cloudPerfH2O.change_logfile(csvFilename)
h2o.cloudPerfH2O.message("")
h2o.cloudPerfH2O.message("Parse " + csvFilename + " Start--------------------------------")
start = time.time()
parseResult = h2i.import_parse(bucket=bucket, path=csvPathname, schema='local',
hex_key=csvFilename + ".hex", timeoutSecs=timeoutSecs,
retryDelaySecs=retryDelaySecs,
pollTimeoutSecs=pollTimeoutSecs,
benchmarkLogging=benchmarkLogging)
elapsed = time.time() - start
print "Parse #", trial, "completed in", "%6.2f" % elapsed, "seconds.", \
"%d pct. of timeout" % ((elapsed*100)/timeoutSecs)
print "Parse result['destination_key']:", parseResult['destination_key']
h2o_cmd.columnInfoFromInspect(parseResult['destination_key'], exceptionOnMissingValues=False)
if totalBytes is not None:
fileMBS = (totalBytes/1e6)/elapsed
msg = '{!s} jvms, {!s}GB heap, {:s} {:s} {:6.2f} MB/sec for {:.2f} secs'.format(
len(h2o.nodes), h2o.nodes[0].java_heap_GB, csvFilepattern, csvFilename, fileMBS, elapsed)
print msg
h2o.cloudPerfH2O.message(msg)
if DO_GLM:
# output 378 can't be in this list
ignore_x = [3,4,5,6,7,8,9,10,11,14,16,17,18,19,20,424,425,426,540,541]
ignore_x = ",".join(map(lambda x: "C" + str(x+1), ignore_x))
GLMkwargs = {
'ignored_cols': ignore_x,
'family': 'binomial',
'response': 'C379',
'max_iter': 10,
'n_folds': 1,
'family': 'binomial',
'alpha': 0.2,
'lambda': 1e-5
}
# are the unparsed keys slowing down exec?
h2i.delete_keys_at_all_nodes(pattern="manyfile")
# convert to binomial
execExpr="A.hex=%s" % parseResult['destination_key']
h2e.exec_expr(execExpr=execExpr, timeoutSecs=180)
execExpr="A.hex[,%s]=(A.hex[,%s]>%s)" % ('379', '379', 15)
h2e.exec_expr(execExpr=execExpr, timeoutSecs=180)
aHack = {'destination_key': "A.hex"}
start = time.time()
glm = h2o_cmd.runGLM(parseResult=aHack, timeoutSecs=timeoutSecs, **GLMkwargs)
elapsed = time.time() - start
h2o.check_sandbox_for_errors()
h2o_glm.simpleCheckGLM(self, glm, None, **GLMkwargs)
msg = '{:d} jvms, {:d}GB heap, {:s} {:s} GLM: {:6.2f} secs'.format(
len(h2o.nodes), h2o.nodes[0].java_heap_GB, csvFilepattern, csvFilename, elapsed)
print msg
h2o.cloudPerfH2O.message(msg)
h2o_cmd.checkKeyDistribution()
#***********************************************************************
# these will be tracked individual by jenkins, which is nice
#***********************************************************************
def test_B_c2_nongz_fvec_long(self):
self.sub_c2_nongz_fvec_long()
if __name__ == '__main__':
h2o.unit_main()
|
apache-2.0
|
[
646,
2882,
12,
984,
12,
900,
199,
1274,
14,
515,
14,
2880,
2941,
14,
1673,
703,
1673,
5093,
703,
1673,
647,
1105,
199,
646,
394,
18,
79,
12,
394,
18,
79,
63,
1760,
12,
394,
18,
79,
63,
646,
465,
394,
18,
73,
12,
394,
18,
79,
63,
3528,
77,
12,
394,
18,
79,
63,
2330,
12,
394,
18,
79,
63,
1628,
465,
394,
18,
69,
199,
646,
394,
18,
79,
63,
1361,
199,
199,
1649,
63,
2226,
45,
275,
756,
199,
4947,
63,
20890,
63,
19202,
275,
715,
199,
199,
1361,
298,
9824,
940,
83,
1265,
21471,
24272,
1506,
63,
509,
63,
6311,
14,
647,
315,
642,
2082,
2,
199,
1361,
298,
10369,
394,
18,
79,
13,
2415,
14,
1001,
14,
6121,
314,
19699,
2935,
2,
199,
533,
4683,
774,
8,
72,
18,
79,
63,
2330,
14,
9625,
7844,
12,
2882,
14,
1746,
304,
272,
347,
1007,
63,
67,
18,
63,
78,
951,
90,
63,
70,
6046,
63,
2809,
8,
277,
304,
267,
327,
282,
26151,
16603,
267,
394,
18,
79,
14,
2758,
63,
11861,
63,
793,
342,
398,
12402,
45,
1158,
279,
2320,
275,
499,
1401,
1465,
993,
267,
5315,
275,
283,
4219,
13,
16,
88,
6706,
13,
12281,
7,
267,
6754,
492,
7850,
2042,
275,
283,
6878,
17,
63,
23781,
63,
1073,
7,
267,
492,
7850,
2042,
275,
283,
3479,
1725,
13,
78,
2327,
88,
7,
267,
870,
298,
10369,
2222,
13,
6838,
7,
379,
1584,
315,
401,
492,
7850,
2042,
267,
7392,
8117,
1296,
29,
359,
288,
1689,
23033,
17,
1527,
16,
13,
20,
1527,
16,
13,
25,
1055,
4616,
401,
298,
493,
63,
1400,
63,
33,
14,
4616,
401,
5238,
627,
12402,
45,
1158,
279,
2320,
12,
6155,
383,
395,
288,
327,
1689,
23033,
17,
1527,
16,
13,
25,
1527,
16,
13,
25,
1055,
4616,
401,
298,
493,
63,
1960,
63,
33,
14,
4616,
401,
2948,
627,
12402,
45,
1158,
279,
2320,
12,
15751,
395,
267,
1622,
398,
340,
5051,
63,
20890,
63,
19202,
26,
288,
12338,
14054,
275,
788,
3541,
297,
283,
4032,
297,
283,
1200,
418,
267,
587,
26,
288,
12338,
14054,
275,
942,
398,
11271,
6372,
29224,
275,
13960,
267,
7269,
10796,
29224,
275,
1616,
398,
367,
16324,
12,
334,
4737,
1173,
3401,
12,
7392,
8117,
12,
3141,
5571,
12,
2653,
29224,
9,
315,
3874,
8,
4737,
8117,
1296,
304,
355,
7392,
2042,
354,
275,
492,
7850,
2042,
435,
10609,
435,
7392,
1173,
3401,
2234,
327,
4270,
492,
5139,
25498,
8826,
31,
355,
327,
334,
646,
2889,
12,
492,
9959,
9,
275,
394,
18,
73,
14,
646,
63,
2118,
8,
4623,
29,
4623,
12,
931,
29,
4737,
2042,
354,
12,
4177,
534,
1832,
358,
355,
327,
492,
9042,
1296,
275,
492,
2889,
459,
1725,
418,
355,
327,
492,
4874,
1296,
275,
492,
2889,
459,
15762,
418,
355,
327,
870,
1867,
78,
20980,
340,
642,
365,
440,
2701,
26,
492,
4874,
1296,
6783,
394,
18,
79,
14,
2724,
63,
1001,
8,
646,
4874,
1296,
9,
2234,
327,
642,
11162,
15409,
10238,
5020,
1901,
282,
12338,
943,
1806,
3663,
7858,
8892,
327,
6954,
367,
15161,
3775,
781,
3984,
10232,
26200,
503,
12930,
355,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1461,
63,
12804,
8,
4737,
8117,
9,
355,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1188,
10804,
355,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1188,
480,
4003,
298,
435,
7392,
8117,
435,
298,
7707,
1444,
531,
2234,
1343,
275,
900,
14,
521,
342,
355,
2198,
2889,
275,
394,
18,
73,
14,
646,
63,
1122,
8,
4623,
29,
4623,
12,
931,
29,
4737,
2042,
354,
12,
4177,
534,
1832,
297,
490,
6318,
63,
498,
29,
4737,
8117,
435,
3680,
4097,
401,
2653,
29224,
29,
2593,
29224,
12,
15324,
7269,
10796,
29224,
29,
7154,
10796,
29224,
12,
490,
11271,
6372,
29224,
29,
6843,
6372,
29224,
12,
490,
12338,
14054,
29,
11861,
14054,
9,
355,
14439,
275,
900,
14,
521,
342,
446,
1343,
355,
870,
298,
4003,
327,
401,
16324,
12,
298,
12634,
315,
401,
2071,
22,
14,
18,
70,
2,
450,
14439,
12,
298,
4515,
4765,
971,
490,
2071,
68,
299,
319,
14,
402,
2653,
2,
450,
3666,
16691,
10,
1960,
2447,
2593,
29224,
9,
2234,
870,
298,
4003,
754,
459,
6881,
63,
498,
2565,
401,
2198,
2889,
459,
6881,
63,
498,
418,
355,
394,
18,
79,
63,
1760,
14,
2301,
2354,
2532,
13962,
1764,
8,
1122,
2889,
459,
6881,
63,
498,
995,
1919,
3314,
7718,
6550,
29,
797,
9,
2234,
340,
3141,
5571,
365,
440,
488,
26,
490,
570,
4567,
51,
275,
334,
2923,
5571,
15,
17,
69,
22,
2447,
16691,
490,
1499,
275,
5041,
1,
83,
93,
1335,
16092,
12,
18776,
83,
93,
6487,
13295,
12,
19850,
83,
93,
19850,
83,
93,
19850,
22,
14,
18,
70,
93,
19487,
15,
3321,
367,
469,
14010,
18,
70,
93,
20091,
1370,
908,
8,
717,
822,
8,
72,
18,
79,
14,
2415,
395,
394,
18,
79,
14,
2415,
59,
16,
1055,
6138,
63,
12492,
63,
6487,
12,
7392,
1173,
3401,
12,
7392,
8117,
12,
570,
4567,
51,
12,
14439,
9,
490,
870,
1499,
490,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1188,
8,
1328,
9,
2234,
340,
3506,
63,
2226,
45,
26,
490,
327,
1072,
650,
2277,
883,
1133,
506,
315,
642,
769,
490,
3686,
63,
88,
275,
359,
19,
12,
20,
12,
21,
12,
22,
12,
23,
12,
24,
12,
25,
12,
709,
12,
845,
12,
1079,
12,
975,
12,
1196,
12,
1085,
12,
1167,
12,
1165,
12,
21089,
12,
24398,
12,
25422,
12,
17814,
12,
21278,
61,
490,
3686,
63,
88,
275,
19089,
904,
8,
1130,
8,
2734,
671,
26,
298,
35,
2,
435,
620,
8,
88,
11,
17,
395,
3686,
63,
88,
430,
4951,
3563,
45,
958,
275,
469,
717,
283,
11996,
63,
4574,
356,
3686,
63,
88,
12,
12723,
283,
6606,
356,
283,
27578,
297,
717,
283,
1310,
356,
283,
35,
12015,
297,
12723,
283,
988,
63,
1661,
356,
1616,
12,
717,
283,
78,
63,
23437,
356,
413,
12,
12723,
283,
6606,
356,
283,
27578,
297,
717,
283,
4468,
356,
378,
14,
18,
12,
12723,
283,
2734,
356,
413,
69,
13,
21,
490,
789
] |
[
2882,
12,
984,
12,
900,
199,
1274,
14,
515,
14,
2880,
2941,
14,
1673,
703,
1673,
5093,
703,
1673,
647,
1105,
199,
646,
394,
18,
79,
12,
394,
18,
79,
63,
1760,
12,
394,
18,
79,
63,
646,
465,
394,
18,
73,
12,
394,
18,
79,
63,
3528,
77,
12,
394,
18,
79,
63,
2330,
12,
394,
18,
79,
63,
1628,
465,
394,
18,
69,
199,
646,
394,
18,
79,
63,
1361,
199,
199,
1649,
63,
2226,
45,
275,
756,
199,
4947,
63,
20890,
63,
19202,
275,
715,
199,
199,
1361,
298,
9824,
940,
83,
1265,
21471,
24272,
1506,
63,
509,
63,
6311,
14,
647,
315,
642,
2082,
2,
199,
1361,
298,
10369,
394,
18,
79,
13,
2415,
14,
1001,
14,
6121,
314,
19699,
2935,
2,
199,
533,
4683,
774,
8,
72,
18,
79,
63,
2330,
14,
9625,
7844,
12,
2882,
14,
1746,
304,
272,
347,
1007,
63,
67,
18,
63,
78,
951,
90,
63,
70,
6046,
63,
2809,
8,
277,
304,
267,
327,
282,
26151,
16603,
267,
394,
18,
79,
14,
2758,
63,
11861,
63,
793,
342,
398,
12402,
45,
1158,
279,
2320,
275,
499,
1401,
1465,
993,
267,
5315,
275,
283,
4219,
13,
16,
88,
6706,
13,
12281,
7,
267,
6754,
492,
7850,
2042,
275,
283,
6878,
17,
63,
23781,
63,
1073,
7,
267,
492,
7850,
2042,
275,
283,
3479,
1725,
13,
78,
2327,
88,
7,
267,
870,
298,
10369,
2222,
13,
6838,
7,
379,
1584,
315,
401,
492,
7850,
2042,
267,
7392,
8117,
1296,
29,
359,
288,
1689,
23033,
17,
1527,
16,
13,
20,
1527,
16,
13,
25,
1055,
4616,
401,
298,
493,
63,
1400,
63,
33,
14,
4616,
401,
5238,
627,
12402,
45,
1158,
279,
2320,
12,
6155,
383,
395,
288,
327,
1689,
23033,
17,
1527,
16,
13,
25,
1527,
16,
13,
25,
1055,
4616,
401,
298,
493,
63,
1960,
63,
33,
14,
4616,
401,
2948,
627,
12402,
45,
1158,
279,
2320,
12,
15751,
395,
267,
1622,
398,
340,
5051,
63,
20890,
63,
19202,
26,
288,
12338,
14054,
275,
788,
3541,
297,
283,
4032,
297,
283,
1200,
418,
267,
587,
26,
288,
12338,
14054,
275,
942,
398,
11271,
6372,
29224,
275,
13960,
267,
7269,
10796,
29224,
275,
1616,
398,
367,
16324,
12,
334,
4737,
1173,
3401,
12,
7392,
8117,
12,
3141,
5571,
12,
2653,
29224,
9,
315,
3874,
8,
4737,
8117,
1296,
304,
355,
7392,
2042,
354,
275,
492,
7850,
2042,
435,
10609,
435,
7392,
1173,
3401,
2234,
327,
4270,
492,
5139,
25498,
8826,
31,
355,
327,
334,
646,
2889,
12,
492,
9959,
9,
275,
394,
18,
73,
14,
646,
63,
2118,
8,
4623,
29,
4623,
12,
931,
29,
4737,
2042,
354,
12,
4177,
534,
1832,
358,
355,
327,
492,
9042,
1296,
275,
492,
2889,
459,
1725,
418,
355,
327,
492,
4874,
1296,
275,
492,
2889,
459,
15762,
418,
355,
327,
870,
1867,
78,
20980,
340,
642,
365,
440,
2701,
26,
492,
4874,
1296,
6783,
394,
18,
79,
14,
2724,
63,
1001,
8,
646,
4874,
1296,
9,
2234,
327,
642,
11162,
15409,
10238,
5020,
1901,
282,
12338,
943,
1806,
3663,
7858,
8892,
327,
6954,
367,
15161,
3775,
781,
3984,
10232,
26200,
503,
12930,
355,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1461,
63,
12804,
8,
4737,
8117,
9,
355,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1188,
10804,
355,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1188,
480,
4003,
298,
435,
7392,
8117,
435,
298,
7707,
1444,
531,
2234,
1343,
275,
900,
14,
521,
342,
355,
2198,
2889,
275,
394,
18,
73,
14,
646,
63,
1122,
8,
4623,
29,
4623,
12,
931,
29,
4737,
2042,
354,
12,
4177,
534,
1832,
297,
490,
6318,
63,
498,
29,
4737,
8117,
435,
3680,
4097,
401,
2653,
29224,
29,
2593,
29224,
12,
15324,
7269,
10796,
29224,
29,
7154,
10796,
29224,
12,
490,
11271,
6372,
29224,
29,
6843,
6372,
29224,
12,
490,
12338,
14054,
29,
11861,
14054,
9,
355,
14439,
275,
900,
14,
521,
342,
446,
1343,
355,
870,
298,
4003,
327,
401,
16324,
12,
298,
12634,
315,
401,
2071,
22,
14,
18,
70,
2,
450,
14439,
12,
298,
4515,
4765,
971,
490,
2071,
68,
299,
319,
14,
402,
2653,
2,
450,
3666,
16691,
10,
1960,
2447,
2593,
29224,
9,
2234,
870,
298,
4003,
754,
459,
6881,
63,
498,
2565,
401,
2198,
2889,
459,
6881,
63,
498,
418,
355,
394,
18,
79,
63,
1760,
14,
2301,
2354,
2532,
13962,
1764,
8,
1122,
2889,
459,
6881,
63,
498,
995,
1919,
3314,
7718,
6550,
29,
797,
9,
2234,
340,
3141,
5571,
365,
440,
488,
26,
490,
570,
4567,
51,
275,
334,
2923,
5571,
15,
17,
69,
22,
2447,
16691,
490,
1499,
275,
5041,
1,
83,
93,
1335,
16092,
12,
18776,
83,
93,
6487,
13295,
12,
19850,
83,
93,
19850,
83,
93,
19850,
22,
14,
18,
70,
93,
19487,
15,
3321,
367,
469,
14010,
18,
70,
93,
20091,
1370,
908,
8,
717,
822,
8,
72,
18,
79,
14,
2415,
395,
394,
18,
79,
14,
2415,
59,
16,
1055,
6138,
63,
12492,
63,
6487,
12,
7392,
1173,
3401,
12,
7392,
8117,
12,
570,
4567,
51,
12,
14439,
9,
490,
870,
1499,
490,
394,
18,
79,
14,
4091,
12387,
40,
18,
47,
14,
1188,
8,
1328,
9,
2234,
340,
3506,
63,
2226,
45,
26,
490,
327,
1072,
650,
2277,
883,
1133,
506,
315,
642,
769,
490,
3686,
63,
88,
275,
359,
19,
12,
20,
12,
21,
12,
22,
12,
23,
12,
24,
12,
25,
12,
709,
12,
845,
12,
1079,
12,
975,
12,
1196,
12,
1085,
12,
1167,
12,
1165,
12,
21089,
12,
24398,
12,
25422,
12,
17814,
12,
21278,
61,
490,
3686,
63,
88,
275,
19089,
904,
8,
1130,
8,
2734,
671,
26,
298,
35,
2,
435,
620,
8,
88,
11,
17,
395,
3686,
63,
88,
430,
4951,
3563,
45,
958,
275,
469,
717,
283,
11996,
63,
4574,
356,
3686,
63,
88,
12,
12723,
283,
6606,
356,
283,
27578,
297,
717,
283,
1310,
356,
283,
35,
12015,
297,
12723,
283,
988,
63,
1661,
356,
1616,
12,
717,
283,
78,
63,
23437,
356,
413,
12,
12723,
283,
6606,
356,
283,
27578,
297,
717,
283,
4468,
356,
378,
14,
18,
12,
12723,
283,
2734,
356,
413,
69,
13,
21,
490,
789,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
jarodwilson/linux-muck
|
tools/perf/scripts/python/event_analyzing_sample.py
|
4719
|
7393
|
# event_analyzing_sample.py: general event handler in python
#
# Current perf report is already very powerful with the annotation integrated,
# and this script is not trying to be as powerful as perf report, but
# providing end user/developer a flexible way to analyze the events other
# than trace points.
#
# The 2 database related functions in this script just show how to gather
# the basic information, and users can modify and write their own functions
# according to their specific requirement.
#
# The first function "show_general_events" just does a basic grouping for all
# generic events with the help of sqlite, and the 2nd one "show_pebs_ll" is
# for a x86 HW PMU event: PEBS with load latency data.
#
import os
import sys
import math
import struct
import sqlite3
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from EventClass import *
#
# If the perf.data has a big number of samples, then the insert operation
# will be very time consuming (about 10+ minutes for 10000 samples) if the
# .db database is on disk. Move the .db file to RAM based FS to speedup
# the handling, which will cut the time down to several seconds.
#
con = sqlite3.connect("/dev/shm/perf.db")
con.isolation_level = None
def trace_begin():
print "In trace_begin:\n"
#
# Will create several tables at the start, pebs_ll is for PEBS data with
# load latency info, while gen_events is for general event.
#
con.execute("""
create table if not exists gen_events (
name text,
symbol text,
comm text,
dso text
);""")
con.execute("""
create table if not exists pebs_ll (
name text,
symbol text,
comm text,
dso text,
flags integer,
ip integer,
status integer,
dse integer,
dla integer,
lat integer
);""")
#
# Create and insert event object to a database so that user could
# do more analysis with simple database commands.
#
def process_event(param_dict):
event_attr = param_dict["attr"]
sample = param_dict["sample"]
raw_buf = param_dict["raw_buf"]
comm = param_dict["comm"]
name = param_dict["ev_name"]
# Symbol and dso info are not always resolved
if (param_dict.has_key("dso")):
dso = param_dict["dso"]
else:
dso = "Unknown_dso"
if (param_dict.has_key("symbol")):
symbol = param_dict["symbol"]
else:
symbol = "Unknown_symbol"
# Create the event object and insert it to the right table in database
event = create_event(name, comm, dso, symbol, raw_buf)
insert_db(event)
def insert_db(event):
if event.ev_type == EVTYPE_GENERIC:
con.execute("insert into gen_events values(?, ?, ?, ?)",
(event.name, event.symbol, event.comm, event.dso))
elif event.ev_type == EVTYPE_PEBS_LL:
event.ip &= 0x7fffffffffffffff
event.dla &= 0x7fffffffffffffff
con.execute("insert into pebs_ll values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(event.name, event.symbol, event.comm, event.dso, event.flags,
event.ip, event.status, event.dse, event.dla, event.lat))
def trace_end():
print "In trace_end:\n"
# We show the basic info for the 2 type of event classes
show_general_events()
show_pebs_ll()
con.close()
#
# As the event number may be very big, so we can't use linear way
# to show the histogram in real number, but use a log2 algorithm.
#
def num2sym(num):
# Each number will have at least one '#'
snum = '#' * (int)(math.log(num, 2) + 1)
return snum
def show_general_events():
# Check the total record number in the table
count = con.execute("select count(*) from gen_events")
for t in count:
print "There is %d records in gen_events table" % t[0]
if t[0] == 0:
return
print "Statistics about the general events grouped by thread/symbol/dso: \n"
# Group by thread
commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)")
print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)
for row in commq:
print "%16s %8d %s" % (row[0], row[1], num2sym(row[1]))
# Group by symbol
print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)
symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)")
for row in symbolq:
print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
# Group by dso
print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74)
dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)")
for row in dsoq:
print "%40s %8d %s" % (row[0], row[1], num2sym(row[1]))
#
# This function just shows the basic info, and we could do more with the
# data in the tables, like checking the function parameters when some
# big latency events happen.
#
def show_pebs_ll():
count = con.execute("select count(*) from pebs_ll")
for t in count:
print "There is %d records in pebs_ll table" % t[0]
if t[0] == 0:
return
print "Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n"
# Group by thread
commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)")
print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)
for row in commq:
print "%16s %8d %s" % (row[0], row[1], num2sym(row[1]))
# Group by symbol
print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)
symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)")
for row in symbolq:
print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
# Group by dse
dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)")
print "\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58)
for row in dseq:
print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
# Group by latency
latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat")
print "\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58)
for row in latq:
print "%32s %8d %s" % (row[0], row[1], num2sym(row[1]))
def trace_unhandled(event_name, context, event_fields_dict):
print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
|
gpl-2.0
|
[
3,
1566,
63,
4797,
20135,
63,
3271,
14,
647,
26,
8605,
1566,
3016,
315,
2366,
199,
3,
199,
3,
9338,
8582,
3622,
365,
2575,
7437,
7074,
1893,
543,
314,
11262,
17806,
972,
12,
199,
3,
436,
642,
2884,
365,
440,
9936,
370,
506,
465,
7074,
1893,
465,
8582,
3622,
12,
1325,
199,
3,
13070,
1284,
922,
15,
11071,
282,
26841,
4340,
370,
19897,
314,
4474,
1163,
199,
3,
2419,
3307,
4501,
14,
199,
3,
199,
3,
710,
499,
3050,
4048,
3423,
315,
642,
2884,
2951,
2498,
4212,
370,
13082,
199,
3,
314,
5678,
2556,
12,
436,
4390,
883,
2811,
436,
2218,
3932,
5705,
3423,
199,
3,
7182,
370,
3932,
2488,
10685,
14,
199,
3,
199,
3,
710,
1642,
805,
298,
2384,
63,
10706,
63,
4368,
2,
2951,
1630,
282,
5678,
17786,
367,
1006,
199,
3,
7809,
4474,
543,
314,
1720,
402,
11723,
12,
436,
314,
499,
977,
1373,
298,
2384,
63,
321,
1533,
63,
914,
2,
365,
199,
3,
367,
282,
671,
1184,
869,
55,
27320,
53,
1566,
26,
19599,
11087,
543,
2248,
23967,
666,
14,
199,
3,
199,
199,
646,
747,
199,
646,
984,
199,
646,
3473,
199,
646,
2702,
199,
646,
11723,
19,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
267,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
6763,
2543,
492,
627,
199,
199,
3,
199,
3,
982,
314,
8582,
14,
576,
965,
282,
7282,
1329,
402,
5845,
12,
2066,
314,
5518,
3439,
199,
3,
911,
506,
7437,
900,
406,
26745,
334,
10254,
1616,
11,
9395,
367,
11630,
5845,
9,
340,
314,
199,
3,
1275,
697,
3050,
365,
641,
4543,
14,
14171,
314,
1275,
697,
570,
370,
30207,
4079,
27500,
370,
8112,
384,
199,
3,
314,
7252,
12,
1314,
911,
10415,
314,
900,
3224,
370,
9978,
4696,
14,
199,
3,
199,
388,
275,
11723,
19,
14,
2242,
4769,
2374,
15,
609,
77,
15,
9452,
14,
697,
531,
199,
388,
14,
20808,
63,
1896,
275,
488,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
607,
3307,
63,
5037,
3427,
78,
2,
398,
327,
267,
327,
12823,
1218,
9978,
6716,
737,
314,
1343,
12,
4837,
1533,
63,
914,
365,
367,
19599,
11087,
666,
543,
267,
327,
2248,
23967,
2256,
12,
1830,
3805,
63,
4368,
365,
367,
8605,
1566,
14,
267,
327,
267,
406,
14,
2526,
4852,
355,
1218,
1817,
340,
440,
3495,
3805,
63,
4368,
334,
717,
536,
1318,
12,
717,
5272,
1318,
12,
717,
1923,
1318,
12,
717,
25547,
1318,
355,
20682,
6141,
267,
406,
14,
2526,
4852,
355,
1218,
1817,
340,
440,
3495,
4837,
1533,
63,
914,
334,
717,
536,
1318,
12,
717,
5272,
1318,
12,
717,
1923,
1318,
12,
717,
25547,
1318,
12,
717,
3285,
3000,
12,
717,
3384,
3000,
12,
717,
2004,
3000,
12,
717,
366,
261,
3000,
12,
717,
366,
416,
3000,
12,
717,
8396,
3000,
355,
20682,
6141,
199,
199,
3,
199,
3,
2790,
436,
5518,
1566,
909,
370,
282,
3050,
880,
626,
922,
4293,
199,
3,
886,
1655,
11284,
543,
3486,
3050,
3718,
14,
199,
3,
199,
318,
2112,
63,
1430,
8,
635,
63,
807,
304,
267,
1566,
63,
962,
275,
1215,
63,
807,
905,
962,
937,
267,
2690,
258,
275,
1215,
63,
807,
905,
3271,
937,
267,
3066,
63,
1436,
259,
275,
1215,
63,
807,
905,
1773,
63,
1436,
937,
267,
1923,
755,
275,
1215,
63,
807,
905,
1404,
937,
267,
536,
755,
275,
1215,
63,
807,
905,
6857,
63,
354,
937,
398,
327,
10080,
436,
25547,
2256,
787,
440,
3544,
12152,
267,
340,
334,
635,
63,
807,
14,
1989,
63,
498,
480,
32211,
14150,
355,
25547,
275,
1215,
63,
807,
905,
32211,
937,
267,
587,
26,
355,
25547,
275,
298,
5912,
63,
32211,
2,
398,
340,
334,
635,
63,
807,
14,
1989,
63,
498,
480,
5155,
14150,
355,
5272,
275,
1215,
63,
807,
905,
5155,
937,
267,
587,
26,
355,
5272,
275,
298,
5912,
63,
5155,
2,
398,
327,
2790,
314,
1566,
909,
436,
5518,
652,
370,
314,
2451,
1817,
315,
3050,
267,
1566,
275,
1218,
63,
1430,
8,
354,
12,
1923,
12,
25547,
12,
5272,
12,
3066,
63,
1436,
9,
267,
5518,
63,
697,
8,
1430,
9,
199,
199,
318,
5518,
63,
697,
8,
1430,
304,
267,
340,
1566,
14,
6857,
63,
466,
508,
30069,
2711,
63,
29395,
26,
355,
406,
14,
2526,
480,
3176,
1901,
3805,
63,
4368,
1338,
2229,
12,
21259,
21259,
5805,
4186,
1816,
334,
1430,
14,
354,
12,
1566,
14,
5155,
12,
1566,
14,
1404,
12,
1566,
14,
32211,
430,
267,
916,
1566,
14,
6857,
63,
466,
508,
30069,
2711,
63,
1510,
11087,
63,
4464,
26,
355,
1566,
14,
711,
18415,
378,
88,
23,
15798,
12596,
70,
355,
1566,
14,
68,
416,
18415,
378,
88,
23,
15798,
12596,
70,
355,
406,
14,
2526,
480,
3176,
1901,
4837,
1533,
63,
914,
1338,
7558,
12,
21259,
21259,
21259,
21259,
21259,
21259,
21259,
21259,
5805,
4186,
717,
334,
1430,
14,
354,
12,
1566,
14,
5155,
12,
1566,
14,
1404,
12,
1566,
14,
32211,
12,
1566,
14,
2469,
12,
1816,
1566,
14,
711,
12,
1566,
14,
1205,
12,
1566,
14,
68,
261,
12,
1566,
14,
68,
416,
12,
1566,
14,
4452,
430,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
1361,
298,
607,
3307,
63,
500,
3427,
78,
2,
267,
327,
2136,
2498,
314,
5678,
2256,
367,
314,
499,
730,
402,
1566,
3992,
267,
2498,
63,
10706,
63,
4368,
342,
267,
2498,
63,
321,
1533,
63,
914,
342,
267,
406,
14,
1600,
342,
199,
199,
3,
199,
3,
3709,
314,
1566,
1329,
1443,
506,
7437,
7282,
12,
880,
781,
883,
1133,
675,
7798,
4340,
199,
3,
370,
2498,
314,
15379,
315,
3363,
1329,
12,
1325,
675,
282,
943,
18,
5563,
14,
199,
3,
199,
199,
318,
1967,
18,
3840,
8,
1507,
304,
267,
327,
7048,
1329,
911,
1172,
737,
5210,
1373,
19619,
267,
308,
1507,
275,
19619,
627,
334,
442,
5130,
3442,
14,
793,
8,
1507,
12,
499,
9,
435,
413,
9,
267,
372,
308,
1507,
199,
199,
318,
2498,
63,
10706,
63,
4368,
837
] |
[
1566,
63,
4797,
20135,
63,
3271,
14,
647,
26,
8605,
1566,
3016,
315,
2366,
199,
3,
199,
3,
9338,
8582,
3622,
365,
2575,
7437,
7074,
1893,
543,
314,
11262,
17806,
972,
12,
199,
3,
436,
642,
2884,
365,
440,
9936,
370,
506,
465,
7074,
1893,
465,
8582,
3622,
12,
1325,
199,
3,
13070,
1284,
922,
15,
11071,
282,
26841,
4340,
370,
19897,
314,
4474,
1163,
199,
3,
2419,
3307,
4501,
14,
199,
3,
199,
3,
710,
499,
3050,
4048,
3423,
315,
642,
2884,
2951,
2498,
4212,
370,
13082,
199,
3,
314,
5678,
2556,
12,
436,
4390,
883,
2811,
436,
2218,
3932,
5705,
3423,
199,
3,
7182,
370,
3932,
2488,
10685,
14,
199,
3,
199,
3,
710,
1642,
805,
298,
2384,
63,
10706,
63,
4368,
2,
2951,
1630,
282,
5678,
17786,
367,
1006,
199,
3,
7809,
4474,
543,
314,
1720,
402,
11723,
12,
436,
314,
499,
977,
1373,
298,
2384,
63,
321,
1533,
63,
914,
2,
365,
199,
3,
367,
282,
671,
1184,
869,
55,
27320,
53,
1566,
26,
19599,
11087,
543,
2248,
23967,
666,
14,
199,
3,
199,
199,
646,
747,
199,
646,
984,
199,
646,
3473,
199,
646,
2702,
199,
646,
11723,
19,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
267,
1994,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
6763,
2543,
492,
627,
199,
199,
3,
199,
3,
982,
314,
8582,
14,
576,
965,
282,
7282,
1329,
402,
5845,
12,
2066,
314,
5518,
3439,
199,
3,
911,
506,
7437,
900,
406,
26745,
334,
10254,
1616,
11,
9395,
367,
11630,
5845,
9,
340,
314,
199,
3,
1275,
697,
3050,
365,
641,
4543,
14,
14171,
314,
1275,
697,
570,
370,
30207,
4079,
27500,
370,
8112,
384,
199,
3,
314,
7252,
12,
1314,
911,
10415,
314,
900,
3224,
370,
9978,
4696,
14,
199,
3,
199,
388,
275,
11723,
19,
14,
2242,
4769,
2374,
15,
609,
77,
15,
9452,
14,
697,
531,
199,
388,
14,
20808,
63,
1896,
275,
488,
199,
199,
318,
3307,
63,
5037,
837,
199,
198,
1361,
298,
607,
3307,
63,
5037,
3427,
78,
2,
398,
327,
267,
327,
12823,
1218,
9978,
6716,
737,
314,
1343,
12,
4837,
1533,
63,
914,
365,
367,
19599,
11087,
666,
543,
267,
327,
2248,
23967,
2256,
12,
1830,
3805,
63,
4368,
365,
367,
8605,
1566,
14,
267,
327,
267,
406,
14,
2526,
4852,
355,
1218,
1817,
340,
440,
3495,
3805,
63,
4368,
334,
717,
536,
1318,
12,
717,
5272,
1318,
12,
717,
1923,
1318,
12,
717,
25547,
1318,
355,
20682,
6141,
267,
406,
14,
2526,
4852,
355,
1218,
1817,
340,
440,
3495,
4837,
1533,
63,
914,
334,
717,
536,
1318,
12,
717,
5272,
1318,
12,
717,
1923,
1318,
12,
717,
25547,
1318,
12,
717,
3285,
3000,
12,
717,
3384,
3000,
12,
717,
2004,
3000,
12,
717,
366,
261,
3000,
12,
717,
366,
416,
3000,
12,
717,
8396,
3000,
355,
20682,
6141,
199,
199,
3,
199,
3,
2790,
436,
5518,
1566,
909,
370,
282,
3050,
880,
626,
922,
4293,
199,
3,
886,
1655,
11284,
543,
3486,
3050,
3718,
14,
199,
3,
199,
318,
2112,
63,
1430,
8,
635,
63,
807,
304,
267,
1566,
63,
962,
275,
1215,
63,
807,
905,
962,
937,
267,
2690,
258,
275,
1215,
63,
807,
905,
3271,
937,
267,
3066,
63,
1436,
259,
275,
1215,
63,
807,
905,
1773,
63,
1436,
937,
267,
1923,
755,
275,
1215,
63,
807,
905,
1404,
937,
267,
536,
755,
275,
1215,
63,
807,
905,
6857,
63,
354,
937,
398,
327,
10080,
436,
25547,
2256,
787,
440,
3544,
12152,
267,
340,
334,
635,
63,
807,
14,
1989,
63,
498,
480,
32211,
14150,
355,
25547,
275,
1215,
63,
807,
905,
32211,
937,
267,
587,
26,
355,
25547,
275,
298,
5912,
63,
32211,
2,
398,
340,
334,
635,
63,
807,
14,
1989,
63,
498,
480,
5155,
14150,
355,
5272,
275,
1215,
63,
807,
905,
5155,
937,
267,
587,
26,
355,
5272,
275,
298,
5912,
63,
5155,
2,
398,
327,
2790,
314,
1566,
909,
436,
5518,
652,
370,
314,
2451,
1817,
315,
3050,
267,
1566,
275,
1218,
63,
1430,
8,
354,
12,
1923,
12,
25547,
12,
5272,
12,
3066,
63,
1436,
9,
267,
5518,
63,
697,
8,
1430,
9,
199,
199,
318,
5518,
63,
697,
8,
1430,
304,
267,
340,
1566,
14,
6857,
63,
466,
508,
30069,
2711,
63,
29395,
26,
355,
406,
14,
2526,
480,
3176,
1901,
3805,
63,
4368,
1338,
2229,
12,
21259,
21259,
5805,
4186,
1816,
334,
1430,
14,
354,
12,
1566,
14,
5155,
12,
1566,
14,
1404,
12,
1566,
14,
32211,
430,
267,
916,
1566,
14,
6857,
63,
466,
508,
30069,
2711,
63,
1510,
11087,
63,
4464,
26,
355,
1566,
14,
711,
18415,
378,
88,
23,
15798,
12596,
70,
355,
1566,
14,
68,
416,
18415,
378,
88,
23,
15798,
12596,
70,
355,
406,
14,
2526,
480,
3176,
1901,
4837,
1533,
63,
914,
1338,
7558,
12,
21259,
21259,
21259,
21259,
21259,
21259,
21259,
21259,
5805,
4186,
717,
334,
1430,
14,
354,
12,
1566,
14,
5155,
12,
1566,
14,
1404,
12,
1566,
14,
32211,
12,
1566,
14,
2469,
12,
1816,
1566,
14,
711,
12,
1566,
14,
1205,
12,
1566,
14,
68,
261,
12,
1566,
14,
68,
416,
12,
1566,
14,
4452,
430,
199,
199,
318,
3307,
63,
500,
837,
199,
198,
1361,
298,
607,
3307,
63,
500,
3427,
78,
2,
267,
327,
2136,
2498,
314,
5678,
2256,
367,
314,
499,
730,
402,
1566,
3992,
267,
2498,
63,
10706,
63,
4368,
342,
267,
2498,
63,
321,
1533,
63,
914,
342,
267,
406,
14,
1600,
342,
199,
199,
3,
199,
3,
3709,
314,
1566,
1329,
1443,
506,
7437,
7282,
12,
880,
781,
883,
1133,
675,
7798,
4340,
199,
3,
370,
2498,
314,
15379,
315,
3363,
1329,
12,
1325,
675,
282,
943,
18,
5563,
14,
199,
3,
199,
199,
318,
1967,
18,
3840,
8,
1507,
304,
267,
327,
7048,
1329,
911,
1172,
737,
5210,
1373,
19619,
267,
308,
1507,
275,
19619,
627,
334,
442,
5130,
3442,
14,
793,
8,
1507,
12,
499,
9,
435,
413,
9,
267,
372,
308,
1507,
199,
199,
318,
2498,
63,
10706,
63,
4368,
837,
0
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,
1
] |
zmathew/django-backbone
|
backbone/tests/tests.py
|
1
|
28973
|
from __future__ import unicode_literals
import datetime
from decimal import Decimal
import json
from django.contrib.auth.models import User, Permission
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.translation import ugettext as _
from backbone.tests.models import Product, Brand, Category, ExtendedProduct, DisplayFieldsProduct
from backbone.tests.backbone_api import BrandBackboneView
class TestHelper(TestCase):
def parseJsonResponse(self, response, status_code=200):
self.assertEqual(response.status_code, status_code)
self.assertEqual(response['Content-Type'], 'application/json')
data = json.loads(response.content)
return data
def create_product(self, **kwargs):
defaults = {
'name': 'Test Product',
'price': '12.32',
'sku': '12345678',
}
if 'brand' not in kwargs:
defaults['brand'] = self.create_brand()
defaults.update(kwargs)
return Product.objects.create(**defaults)
def create_extended_product(self, **kwargs):
defaults = {
'name': 'Test Product',
'price': '12.32'
}
if 'brand' not in kwargs:
defaults['brand'] = self.create_brand()
defaults.update(kwargs)
return ExtendedProduct.objects.create(**defaults)
def create_displayfields_product(self, **kwargs):
defaults = {
'name': 'Beta Product',
'price': '13.32'
}
if 'brand' not in kwargs:
defaults['brand'] = self.create_brand()
defaults.update(kwargs)
return DisplayFieldsProduct.objects.create(**defaults)
def create_brand(self, **kwargs):
defaults = {
'name': 'Test Brand',
}
defaults.update(kwargs)
return Brand.objects.create(**defaults)
def create_category(self, **kwargs):
defaults = {
'name': 'Test Category',
}
defaults.update(kwargs)
return Category.objects.create(**defaults)
class CollectionTests(TestHelper):
def test_collection_view_returns_all_products_in_order(self):
p3 = self.create_product(order=3)
p1 = self.create_product(order=1)
p2 = self.create_product(order=2)
url = reverse('backbone:tests_product')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 3)
self.assertEqual(data[0]['id'], p1.id)
self.assertEqual(data[0]['name'], p1.name)
self.assertEqual(data[1]['id'], p2.id)
self.assertEqual(data[1]['name'], p1.name)
self.assertEqual(data[2]['id'], p3.id)
self.assertEqual(data[2]['name'], p1.name)
def test_collection_view_only_returns_fields_specified_in_display_fields(self):
self.create_product()
url = reverse('backbone:tests_product')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
fields = data[0].keys()
expected_fields = [
'id', 'creation_date', 'name', 'brand', 'categories', 'price', 'order',
'is_priced_under_10', 'get_first_category_id', 'sku', 'custom2'
]
self.assertEqual(set(expected_fields), set(fields))
self.assertTrue('is_hidden' not in fields)
def test_collection_view_foreign_key_is_returned_as_id(self):
brand = self.create_brand()
self.create_product(brand=brand)
url = reverse('backbone:tests_product')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]['brand'], brand.id)
def test_collection_view_m2m_field_is_returned_as_list_of_ids(self):
cat1 = self.create_category()
cat2 = self.create_category()
p = self.create_product()
p.categories = [cat1, cat2]
url = reverse('backbone:tests_product')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]['categories'], [cat1.id, cat2.id])
def test_collection_view_with_custom_queryset(self):
p1 = self.create_product()
self.create_product(is_hidden=True) # this should not appear
url = reverse('backbone:tests_product')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]['id'], p1.id)
def test_collection_view_put_request_returns_403(self):
url = reverse('backbone:tests_product')
response = self.client.put(url)
self.assertEqual(response.status_code, 403)
def test_collection_view_delete_request_returns_403(self):
url = reverse('backbone:tests_product')
response = self.client.delete(url)
self.assertEqual(response.status_code, 403)
def test_collection_view_pagination(self):
# Brand is paginated 2 per page
p1 = self.create_brand()
p2 = self.create_brand()
p3 = self.create_brand()
url = reverse('backbone:tests_brand')
# First page
response = self.client.get(url, {'page': 1})
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 2)
self.assertEqual(data[0]['id'], p1.id)
self.assertEqual(data[1]['id'], p2.id)
# Second Page
response = self.client.get(url, {'page': 2})
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]['id'], p3.id)
def test_collection_view_page_parameter_out_of_range_returns_error(self):
url = reverse('backbone:tests_brand')
response = self.client.get(url, {'page': 2})
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, _('Invalid `page` parameter: Out of range.'))
def test_collection_view_page_parameter_not_an_integer_returns_error(self):
url = reverse('backbone:tests_brand')
response = self.client.get(url, {'page': 'abcd'})
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, _('Invalid `page` parameter: Not a valid integer.'))
def test_collection_view_that_is_not_paginated_ignores_page_parameter(self):
url = reverse('backbone:tests_product')
response = self.client.get(url, {'page': 999})
self.assertEqual(response.status_code, 200)
def test_collection_view_for_view_with_custom_url_slug(self):
brand = self.create_brand()
url = reverse('backbone:tests_brand_alternate')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
self.assertEqual(data[0]['id'], brand.id)
self.assertEqual(data[0]['custom'], 'foo')
class DetailTests(TestHelper):
def test_detail_view_returns_object_details(self):
product = self.create_product(price='3.00')
category = self.create_category()
product.categories.add(category)
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(data['id'], product.id)
self.assertEqual(data['name'], product.name)
self.assertEqual(data['brand'], product.brand.id)
self.assertEqual(data['categories'], [category.id])
self.assertEqual(data['price'], product.price)
self.assertEqual(data['order'], product.order)
# Attribute on model
self.assertEqual(data['is_priced_under_10'], True)
# Callable
self.assertEqual(data['sku'], '#: %s' % product.sku)
# Callable on admin class
self.assertEqual(data['custom2'], 'custom2: %s' % product.name)
# Callable on model
self.assertEqual(data['get_first_category_id'], category.id)
def test_detail_view_uses_display_detail_fields_when_defined(self):
display_fields_product = self.create_displayfields_product(price=111)
category = self.create_category()
display_fields_product.categories.add(category)
url = reverse('backbone:tests_displayfieldsproduct_detail', args=[display_fields_product.id])
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(data['id'], display_fields_product.id)
self.assertEqual(data['name'], display_fields_product.name)
self.assertEqual(data['brand'], display_fields_product.brand.id)
self.assertEqual(data['categories'], [category.id])
self.assertTrue('price' not in data)
self.assertTrue('order' not in data)
# Attribute on model
self.assertTrue('is_priced_under_10' not in data)
# Callable
self.assertTrue('sku' not in data)
# Callable on admin class
self.assertTrue('custom2' not in data)
# Callable on model
self.assertTrue('get_first_category_id' not in data)
self.assertEqual(len(data.keys()), 4)
def test_collection_view_uses_display_collection_fields_when_defined(self):
display_fields_product = self.create_displayfields_product(price=111)
category = self.create_category()
display_fields_product.categories.add(category)
url = reverse('backbone:tests_displayfieldsproduct')
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(len(data), 1)
data = data[0]
self.assertEqual(data['id'], display_fields_product.id)
self.assertEqual(data['name'], display_fields_product.name)
self.assertEqual(data['brand'], display_fields_product.brand.id)
self.assertEqual(data['categories'], [category.id])
self.assertTrue('price' not in data)
self.assertTrue('order' not in data)
# Attribute on model
self.assertTrue('is_priced_under_10' not in data)
# Callable
self.assertTrue('sku' not in data)
# Callable on admin class
self.assertTrue('custom2' not in data)
# Callable on model
self.assertTrue('get_first_category_id' not in data)
self.assertEqual(len(data.keys()), 4)
def test_detail_view_doesnt_return_unspecified_fields(self):
product = self.create_product()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.get(url)
data = self.parseJsonResponse(response)
fields = data.keys()
self.assertTrue('is_hidden' not in fields)
def test_detail_view_returns_404_for_invalid_id(self):
url = reverse('backbone:tests_product_detail', args=[999])
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
def test_detail_view_returns_404_for_object_not_in_custom_queryset(self):
product = self.create_product(is_hidden=True)
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
def test_detail_view_post_request_returns_403(self):
product = self.create_product()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.post(url)
self.assertEqual(response.status_code, 403)
def test_detail_view_for_view_with_custom_url_slug(self):
brand = self.create_brand()
url = reverse('backbone:tests_brand_alternate_detail', args=[brand.id])
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(data['id'], brand.id)
self.assertEqual(data['custom'], 'foo')
class AddTests(TestHelper):
def setUp(self):
self.user = User.objects.create_user(username='test', password='test', email='t@t.com')
self.client.login(username='test', password='test')
add_product = Permission.objects.get_by_natural_key('add_product', 'tests', 'product')
add_brand = Permission.objects.get_by_natural_key('add_brand', 'tests', 'brand')
self.user.user_permissions = [add_product, add_brand]
def test_post_request_on_product_collection_view_adds_product_to_db(self):
brand = self.create_brand()
cat1 = self.create_category()
cat2 = self.create_category()
data = json.dumps({
'name': 'Test',
'brand': brand.id,
'categories': [cat1.id, cat2.id],
'price': 12.34,
'order': 1,
'sale_date': '2006-10-25 14:30:59',
})
url = reverse('backbone:tests_product')
response = self.client.post(url, data, content_type='application/json')
self.assertEqual(response.status_code, 201)
self.assertEqual(Product.objects.count(), 1)
product = Product.objects.order_by('-id')[0]
self.assertEqual(product.name, 'Test')
self.assertEqual(product.brand, brand)
self.assertEqual(product.categories.count(), 2)
self.assertEqual(product.categories.all()[0], cat1)
self.assertEqual(product.categories.all()[1], cat2)
self.assertEqual(product.price, Decimal('12.34'))
self.assertEqual(product.sale_date, datetime.datetime(2006, 10, 25, 14, 30, 59))
data = self.parseJsonResponse(response, status_code=201)
self.assertEqual(data['id'], product.id)
self.assertEqual(data['name'], product.name)
self.assertEqual(data['brand'], product.brand.id)
self.assertEqual(data['categories'], [cat1.id, cat2.id])
self.assertEqual(data['price'], '12.34')
self.assertTrue(response['Location'].endswith(
reverse('backbone:tests_product_detail', args=[product.id])
))
def test_post_request_on_product_collection_view_with_invalid_json_returns_error(self):
url = reverse('backbone:tests_product')
response = self.client.post(url, 'Some invalid json', content_type='application/json')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, _('Unable to parse JSON request body.'))
def test_post_request_on_product_collection_view_with_validation_errors_returns_error_list_as_json(self):
data = json.dumps({
'name': '',
'brand': '',
'categories': [],
'price': None,
'order': '',
})
url = reverse('backbone:tests_product')
response = self.client.post(url, data, content_type='application/json')
self.assertEqual(Product.objects.count(), 0)
data = self.parseJsonResponse(response, status_code=400)
self.assertEqual(len(data), 3)
self.assertEqual(data['name'], [_('This field is required.')])
self.assertEqual(data['price'], [_('This field is required.')])
self.assertEqual(data['order'], [_('This field is required.')])
def test_post_request_on_product_collection_view_ignores_fields_not_specified(self):
brand = self.create_brand()
cat1 = self.create_category()
cat2 = self.create_category()
data = json.dumps({
'name': 'Test',
'brand': brand.id,
'categories': [cat1.id, cat2.id],
'price': 12.34,
'order': 1,
'is_hidden': True # User should not be able to alter is_hidden
})
url = reverse('backbone:tests_product')
response = self.client.post(url, data, content_type='application/json')
self.assertEqual(response.status_code, 201)
self.assertEqual(Product.objects.count(), 1)
product = Product.objects.order_by('-id')[0]
self.assertEqual(product.is_hidden, False)
def test_post_request_on_product_collection_view_when_user_not_logged_in_returns_403(self):
self.client.logout()
url = reverse('backbone:tests_product')
response = self.client.post(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
self.assertEqual(Product.objects.count(), 0)
def test_post_request_on_product_collection_view_when_user_doesnt_have_add_permission_returns_403(self):
self.client.logout()
self.user.user_permissions.clear()
self.client.login(username='test', password='test')
url = reverse('backbone:tests_product')
response = self.client.post(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
def test_post_request_on_product_collection_view_violating_field_specific_permission_returns_403(self):
brand = self.create_brand()
cat1 = self.create_category()
data = json.dumps({
'name': 'NOTALLOWED',
'brand': brand.id,
'categories': [cat1.id],
'price': 12.34,
'order': 1
})
url = reverse('backbone:tests_product')
response = self.client.post(url, data, content_type='application/json')
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
def test_post_request_on_brand_collection_view_uses_custom_model_form(self):
data = json.dumps({
'name': 'this should give an error',
})
url = reverse('backbone:tests_brand')
response = self.client.post(url, data, content_type='application/json')
self.assertEqual(Brand.objects.count(), 0)
data = self.parseJsonResponse(response, status_code=400)
self.assertEqual(len(data), 1)
self.assertEqual(data['name'], [_('Brand name must start with a capital letter.')])
def test_post_request_on_custom_url_slug_view_contains_custom_url_in_location_header(self):
data = json.dumps({
'name': 'Foo',
})
url = reverse('backbone:tests_brand_alternate')
response = self.client.post(url, data, content_type='application/json')
self.assertEqual(response.status_code, 201)
self.assertEqual(Brand.objects.count(), 1)
self.assertTrue(response['Location'].endswith(reverse(
'backbone:tests_brand_alternate_detail', args=[Brand.objects.get().id]
)))
class UpdateTests(TestHelper):
def setUp(self):
self.user = User.objects.create_user(username='test', password='test', email='t@t.com')
self.client.login(username='test', password='test')
update_product = Permission.objects.get_by_natural_key('change_product', 'tests', 'product')
update_brand = Permission.objects.get_by_natural_key('change_brand', 'tests', 'brand')
self.user.user_permissions = [update_product, update_brand]
def test_put_request_on_product_detail_view_updates_product(self):
product = self.create_product()
brand = self.create_brand()
cat1 = self.create_category()
cat2 = self.create_category()
data = json.dumps({
'name': 'Test',
'brand': brand.id,
'categories': [cat1.id, cat2.id],
'price': 56.78,
'order': 2
})
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url, data, content_type='application/json')
self.assertEqual(response.status_code, 200)
self.assertEqual(Product.objects.count(), 1)
product = Product.objects.get(id=product.id) # refresh from db
self.assertEqual(product.name, 'Test')
self.assertEqual(product.brand, brand)
self.assertEqual(product.categories.count(), 2)
self.assertEqual(product.categories.all()[0], cat1)
self.assertEqual(product.categories.all()[1], cat2)
self.assertEqual(product.price, Decimal('56.78'))
data = self.parseJsonResponse(response, status_code=200)
self.assertEqual(data['id'], product.id)
self.assertEqual(data['name'], product.name)
self.assertEqual(data['brand'], product.brand.id)
self.assertEqual(data['categories'], [cat1.id, cat2.id])
self.assertEqual(data['price'], '56.78')
def test_put_request_on_product_detail_view_with_invalid_json_returns_error(self):
product = self.create_product()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url, '', content_type='application/json')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, _('Unable to parse JSON request body.'))
response = self.client.put(url, 'Some invalid json', content_type='application/json')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, _('Unable to parse JSON request body.'))
def test_put_request_on_product_detail_view_with_validation_errors_returns_error_list_as_json(self):
product = self.create_product()
data = json.dumps({
'name': '',
'price': None,
'order': '',
})
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url, data, content_type='application/json')
self.assertEqual(Product.objects.count(), 1)
data = self.parseJsonResponse(response, status_code=400)
self.assertEqual(len(data), 3)
self.assertEqual(data['name'], [_('This field is required.')])
self.assertEqual(data['price'], [_('This field is required.')])
self.assertEqual(data['order'], [_('This field is required.')])
def test_put_request_on_product_detail_view_ignores_fields_not_specified(self):
product = self.create_product()
brand = self.create_brand()
cat1 = self.create_category()
cat2 = self.create_category()
data = json.dumps({
'name': 'Test',
'brand': brand.id,
'categories': [cat1.id, cat2.id],
'price': 12.34,
'order': 1,
'is_hidden': True # User should not be able to alter is_hidden
})
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url, data, content_type='application/json')
self.assertEqual(response.status_code, 200)
product = Product.objects.get(id=product.id) # refresh from db
self.assertEqual(product.is_hidden, False)
def test_put_request_on_product_detail_view_when_user_not_logged_in_returns_403(self):
product = self.create_product()
self.client.logout()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
def test_put_request_on_product_detail_view_when_user_doesnt_have_update_permission_returns_403(self):
product = self.create_product()
self.client.logout()
self.user.user_permissions.clear()
self.client.login(username='test', password='test')
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
def test_put_request_on_product_detail_view_violating_field_specific_permission_returns_403(self):
product = self.create_product()
brand = self.create_brand()
cat1 = self.create_category()
data = json.dumps({
'name': 'NOTALLOWED',
'brand': brand.id,
'categories': [cat1.id],
'price': 12.34,
'order': 2
})
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.put(url, data, content_type='application/json')
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
def test_put_request_on_brand_collection_view_uses_custom_model_form(self):
brand = self.create_brand()
data = json.dumps({
'name': 'this should give an error',
})
url = reverse('backbone:tests_brand_detail', args=[brand.id])
response = self.client.put(url, data, content_type='application/json')
self.assertEqual(Product.objects.count(), 0)
data = self.parseJsonResponse(response, status_code=400)
self.assertEqual(len(data), 1)
self.assertEqual(data['name'], [_('Brand name must start with a capital letter.')])
class DeleteTests(TestHelper):
def setUp(self):
self.user = User.objects.create_user(username='test', password='test', email='t@t.com')
self.client.login(username='test', password='test')
delete_product = Permission.objects.get_by_natural_key('delete_product', 'tests', 'product')
delete_brand = Permission.objects.get_by_natural_key('delete_brand', 'tests', 'brand')
self.user.user_permissions.add(delete_product, delete_brand)
def test_delete_request_on_product_deletes_the_item(self):
product = self.create_product()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.delete(url)
self.assertEqual(response.status_code, 204)
self.assertEqual(Product.objects.count(), 0)
def test_delete_request_on_product_when_user_not_logged_in_returns_403(self):
self.client.logout()
product = self.create_product()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.delete(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
self.assertEqual(Product.objects.count(), 1)
def test_delete_request_on_product_when_user_doesnt_have_delete_permission_returns_403(self):
self.client.logout()
self.user.user_permissions.clear()
self.client.login(username='test', password='test')
product = self.create_product()
url = reverse('backbone:tests_product_detail', args=[product.id])
response = self.client.delete(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
self.assertEqual(Product.objects.count(), 1)
def test_delete_request_on_brand_returns_403(self):
brand = self.create_brand()
url = reverse('backbone:tests_brand_detail', args=[brand.id])
response = self.client.delete(url)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content, _('You do not have permission to perform this action.'))
self.assertEqual(Brand.objects.count(), 1)
class InheritanceTests(TestHelper):
def test_detail_view_returns_inherited_object_details(self):
ext_product = self.create_extended_product(price='9.00')
category = self.create_category()
ext_product.categories.add(category)
url = reverse('backbone:tests_extendedproduct_detail', args=[ext_product.id])
response = self.client.get(url)
data = self.parseJsonResponse(response)
self.assertEqual(data['id'], ext_product.id)
self.assertEqual(data['name'], ext_product.name)
self.assertEqual(data['brand'], ext_product.brand.id)
self.assertEqual(data['categories'], [category.id])
self.assertEqual(data['price'], ext_product.price)
self.assertEqual(data['order'], ext_product.order)
self.assertEqual(data['description'], ext_product.description)
# Attribute on model
self.assertEqual(data['is_priced_under_10'], True)
# Callable on model
self.assertEqual(data['get_first_category_id'], category.id)
class InvalidViewTests(TestHelper):
def setUp(self):
BrandBackboneView.display_fields += ['invalid_field']
def tearDown(self):
BrandBackboneView.display_fields.remove('invalid_field')
def test_invalid_field_name_raises_attribute_error(self):
brand = self.create_brand()
url = reverse('backbone:tests_brand_detail', args=[brand.id])
try:
self.client.get(url)
except AttributeError as err:
self.assertEqual(str(err), "Invalid field: invalid_field")
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2197,
199,
504,
6107,
492,
6345,
199,
646,
2022,
199,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
12,
8779,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
199,
504,
1771,
21134,
14,
2219,
14,
992,
492,
12705,
12,
699,
3759,
12,
13573,
12,
13706,
5884,
12,
12175,
7304,
5884,
199,
504,
1771,
21134,
14,
2219,
14,
894,
21134,
63,
1246,
492,
699,
3759,
4540,
21134,
2768,
421,
199,
533,
1379,
4433,
8,
1746,
304,
339,
347,
2198,
9653,
2364,
8,
277,
12,
1177,
12,
2004,
63,
600,
29,
1840,
304,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
2004,
63,
600,
9,
267,
291,
14,
629,
8,
1310,
459,
2714,
13,
804,
995,
283,
3578,
15,
1001,
358,
267,
666,
275,
2022,
14,
3640,
8,
1310,
14,
1317,
9,
267,
372,
666,
339,
347,
1218,
63,
2558,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
12705,
297,
288,
283,
4777,
356,
283,
713,
14,
708,
297,
288,
283,
27772,
356,
283,
19542,
297,
267,
789,
267,
340,
283,
19026,
7,
440,
315,
2074,
26,
288,
4243,
459,
19026,
418,
275,
291,
14,
981,
63,
19026,
342,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
12705,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
10525,
63,
2558,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
12705,
297,
288,
283,
4777,
356,
283,
713,
14,
708,
7,
267,
789,
267,
340,
283,
19026,
7,
440,
315,
2074,
26,
288,
4243,
459,
19026,
418,
275,
291,
14,
981,
63,
19026,
342,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
13706,
5884,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
2918,
955,
63,
2558,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
21732,
12705,
297,
288,
283,
4777,
356,
283,
969,
14,
708,
7,
267,
789,
267,
340,
283,
19026,
7,
440,
315,
2074,
26,
288,
4243,
459,
19026,
418,
275,
291,
14,
981,
63,
19026,
342,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
12175,
7304,
5884,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
19026,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
699,
3759,
297,
267,
789,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
699,
3759,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
3710,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
13573,
297,
267,
789,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
13573,
14,
1462,
14,
981,
3682,
4322,
9,
421,
199,
533,
18003,
2925,
8,
774,
4433,
304,
339,
347,
511,
63,
3627,
63,
1345,
63,
5808,
63,
452,
63,
13336,
63,
262,
63,
1648,
8,
277,
304,
267,
299,
19,
275,
291,
14,
981,
63,
2558,
8,
1648,
29,
19,
9,
267,
299,
17,
275,
291,
14,
981,
63,
2558,
8,
1648,
29,
17,
9,
267,
299,
18,
275,
291,
14,
981,
63,
2558,
8,
1648,
29,
18,
9,
398,
1166,
275,
3837,
360,
894,
21134,
26,
2219,
63,
2558,
358,
267,
1177,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
666,
275,
291,
14,
1122,
9653,
2364,
8,
1310,
9,
267,
291,
14,
629,
8,
552,
8,
576,
395,
650,
9,
267,
291,
14,
629,
8,
576,
59,
16,
2733,
344,
995,
299,
17,
14,
344,
9,
267,
291,
14,
629,
8,
576,
59,
16,
2733,
354,
995,
299,
17,
14,
354,
9,
267,
291,
14,
629,
8,
576,
59,
17,
2733,
344,
995,
299,
18,
14,
344,
9,
267,
291,
14,
629,
8,
576,
59,
17,
2733,
354,
995,
299,
17,
14,
354,
9,
267,
291,
14,
629,
8,
576,
59,
18,
2733,
344,
995,
299,
19,
14,
344,
9,
267,
291,
14,
629,
8,
576,
59,
18,
2733,
354,
995,
299,
17,
14,
354,
9,
339,
347,
511,
63,
3627,
63,
1345,
63,
2118,
63,
5808,
63,
955,
63,
10085,
63,
262,
63,
2918,
63,
955,
8,
277,
304,
267,
291,
14,
981,
63,
2558,
342,
267,
1166,
275,
3837,
360,
894,
21134,
26,
2219,
63,
2558,
358,
267,
1177,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
666,
275,
291,
14,
1122,
9653,
2364,
8,
1310,
9,
267,
291,
14,
629,
8,
552,
8,
576,
395,
413,
9,
267,
1504,
275,
666,
59,
16,
1055,
1612,
342,
398,
1420,
63,
955,
275,
359,
288,
283,
344,
297,
283,
8782,
63,
602,
297,
283,
354,
297,
283,
19026,
297,
283,
8906,
297,
283,
4777,
297,
283,
1648,
297,
288,
283,
374,
63,
4777,
68,
63,
7138,
63,
709,
297,
283,
362,
63,
2246,
63,
3710,
63,
344,
297,
283,
27772,
297,
283,
4229,
18,
7,
267,
1622,
267,
291,
14,
629,
8,
409,
8,
2062,
63,
955,
395,
663,
8,
955,
430,
267,
291,
14,
1815,
360,
374,
63,
5642,
7,
440,
315,
1504,
9,
339,
347,
511,
63,
3627,
63,
1345,
63,
6846,
63,
498,
63,
374,
63,
19065,
63,
305,
63,
344,
8,
277,
304,
267,
32159,
275,
291,
14,
981,
63,
19026,
342,
267,
291,
14,
981,
63,
2558,
8,
19026,
29,
19026,
9,
267,
1166,
275,
3837,
360,
894,
21134,
26,
2219,
63,
2558,
358,
267,
1177,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
666,
275,
291,
14,
1122,
9653,
2364,
8,
1310,
9,
267,
291,
14,
629,
8,
552,
8,
576,
395,
413,
9,
267,
291,
14,
629,
8,
576,
59,
16,
2733,
19026,
995,
32159,
14,
344,
9,
339,
347,
511,
63,
3627,
63,
1345,
63,
77,
18,
77,
63,
698,
63,
374,
63,
19065,
63,
305,
63,
513,
63,
1618,
63,
1580,
8,
277,
304,
267,
6230,
17,
275,
291,
14,
981,
63,
3710,
342,
267,
6230,
18,
275,
291,
14,
981,
63,
3710,
342,
267,
299,
275
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2197,
199,
504,
6107,
492,
6345,
199,
646,
2022,
199,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
12,
8779,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
199,
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
199,
504,
1771,
21134,
14,
2219,
14,
992,
492,
12705,
12,
699,
3759,
12,
13573,
12,
13706,
5884,
12,
12175,
7304,
5884,
199,
504,
1771,
21134,
14,
2219,
14,
894,
21134,
63,
1246,
492,
699,
3759,
4540,
21134,
2768,
421,
199,
533,
1379,
4433,
8,
1746,
304,
339,
347,
2198,
9653,
2364,
8,
277,
12,
1177,
12,
2004,
63,
600,
29,
1840,
304,
267,
291,
14,
629,
8,
1310,
14,
1205,
63,
600,
12,
2004,
63,
600,
9,
267,
291,
14,
629,
8,
1310,
459,
2714,
13,
804,
995,
283,
3578,
15,
1001,
358,
267,
666,
275,
2022,
14,
3640,
8,
1310,
14,
1317,
9,
267,
372,
666,
339,
347,
1218,
63,
2558,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
12705,
297,
288,
283,
4777,
356,
283,
713,
14,
708,
297,
288,
283,
27772,
356,
283,
19542,
297,
267,
789,
267,
340,
283,
19026,
7,
440,
315,
2074,
26,
288,
4243,
459,
19026,
418,
275,
291,
14,
981,
63,
19026,
342,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
12705,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
10525,
63,
2558,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
12705,
297,
288,
283,
4777,
356,
283,
713,
14,
708,
7,
267,
789,
267,
340,
283,
19026,
7,
440,
315,
2074,
26,
288,
4243,
459,
19026,
418,
275,
291,
14,
981,
63,
19026,
342,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
13706,
5884,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
2918,
955,
63,
2558,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
21732,
12705,
297,
288,
283,
4777,
356,
283,
969,
14,
708,
7,
267,
789,
267,
340,
283,
19026,
7,
440,
315,
2074,
26,
288,
4243,
459,
19026,
418,
275,
291,
14,
981,
63,
19026,
342,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
12175,
7304,
5884,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
19026,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
699,
3759,
297,
267,
789,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
699,
3759,
14,
1462,
14,
981,
3682,
4322,
9,
339,
347,
1218,
63,
3710,
8,
277,
12,
1011,
958,
304,
267,
4243,
275,
469,
288,
283,
354,
356,
283,
774,
13573,
297,
267,
789,
267,
4243,
14,
873,
8,
958,
9,
267,
372,
13573,
14,
1462,
14,
981,
3682,
4322,
9,
421,
199,
533,
18003,
2925,
8,
774,
4433,
304,
339,
347,
511,
63,
3627,
63,
1345,
63,
5808,
63,
452,
63,
13336,
63,
262,
63,
1648,
8,
277,
304,
267,
299,
19,
275,
291,
14,
981,
63,
2558,
8,
1648,
29,
19,
9,
267,
299,
17,
275,
291,
14,
981,
63,
2558,
8,
1648,
29,
17,
9,
267,
299,
18,
275,
291,
14,
981,
63,
2558,
8,
1648,
29,
18,
9,
398,
1166,
275,
3837,
360,
894,
21134,
26,
2219,
63,
2558,
358,
267,
1177,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
666,
275,
291,
14,
1122,
9653,
2364,
8,
1310,
9,
267,
291,
14,
629,
8,
552,
8,
576,
395,
650,
9,
267,
291,
14,
629,
8,
576,
59,
16,
2733,
344,
995,
299,
17,
14,
344,
9,
267,
291,
14,
629,
8,
576,
59,
16,
2733,
354,
995,
299,
17,
14,
354,
9,
267,
291,
14,
629,
8,
576,
59,
17,
2733,
344,
995,
299,
18,
14,
344,
9,
267,
291,
14,
629,
8,
576,
59,
17,
2733,
354,
995,
299,
17,
14,
354,
9,
267,
291,
14,
629,
8,
576,
59,
18,
2733,
344,
995,
299,
19,
14,
344,
9,
267,
291,
14,
629,
8,
576,
59,
18,
2733,
354,
995,
299,
17,
14,
354,
9,
339,
347,
511,
63,
3627,
63,
1345,
63,
2118,
63,
5808,
63,
955,
63,
10085,
63,
262,
63,
2918,
63,
955,
8,
277,
304,
267,
291,
14,
981,
63,
2558,
342,
267,
1166,
275,
3837,
360,
894,
21134,
26,
2219,
63,
2558,
358,
267,
1177,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
666,
275,
291,
14,
1122,
9653,
2364,
8,
1310,
9,
267,
291,
14,
629,
8,
552,
8,
576,
395,
413,
9,
267,
1504,
275,
666,
59,
16,
1055,
1612,
342,
398,
1420,
63,
955,
275,
359,
288,
283,
344,
297,
283,
8782,
63,
602,
297,
283,
354,
297,
283,
19026,
297,
283,
8906,
297,
283,
4777,
297,
283,
1648,
297,
288,
283,
374,
63,
4777,
68,
63,
7138,
63,
709,
297,
283,
362,
63,
2246,
63,
3710,
63,
344,
297,
283,
27772,
297,
283,
4229,
18,
7,
267,
1622,
267,
291,
14,
629,
8,
409,
8,
2062,
63,
955,
395,
663,
8,
955,
430,
267,
291,
14,
1815,
360,
374,
63,
5642,
7,
440,
315,
1504,
9,
339,
347,
511,
63,
3627,
63,
1345,
63,
6846,
63,
498,
63,
374,
63,
19065,
63,
305,
63,
344,
8,
277,
304,
267,
32159,
275,
291,
14,
981,
63,
19026,
342,
267,
291,
14,
981,
63,
2558,
8,
19026,
29,
19026,
9,
267,
1166,
275,
3837,
360,
894,
21134,
26,
2219,
63,
2558,
358,
267,
1177,
275,
291,
14,
1258,
14,
362,
8,
633,
9,
267,
666,
275,
291,
14,
1122,
9653,
2364,
8,
1310,
9,
267,
291,
14,
629,
8,
552,
8,
576,
395,
413,
9,
267,
291,
14,
629,
8,
576,
59,
16,
2733,
19026,
995,
32159,
14,
344,
9,
339,
347,
511,
63,
3627,
63,
1345,
63,
77,
18,
77,
63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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ceelian/callme
|
callme/protocol.py
|
3
|
2625
|
# Copyright (c) 2009-2014, Christian Haintz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# * Neither the name of callme nor the names of its contributors
# may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class RpcRequest(object):
"""This class is used to transport the RPC Request to the server.
:keyword func_name: the rpc function name (= method name)
:keyword func_args: the arguments for the function
:keyword func_keywords: keyword arguments for the function
"""
def __init__(self, func_name, func_args, func_kwargs):
self.func_name = func_name
self.func_args = func_args
self.func_kwargs = func_kwargs
def __str__(self):
return ("<RpcRequest(func_name={0}, func_args={1}, func_kwargs={2})>"
.format(self.func_name, self.func_args, self.func_kwargs))
class RpcResponse(object):
"""This class is used to transport the RPC Response to the client.
:keyword result: the result of the rpc call on the server
"""
def __init__(self, result):
self.result = result
def __str__(self):
return "<RpcResponse(result={0})>".format(self.result)
@property
def is_exception(self):
return isinstance(self.result, BaseException)
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
8937,
13,
7280,
12,
2799,
18824,
5653,
869,
65,
442,
90,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
755,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
199,
3,
755,
6450,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
199,
3,
755,
543,
314,
4084,
14,
199,
3,
199,
3,
258,
627,
11443,
314,
536,
402,
1240,
278,
6590,
314,
1561,
402,
2399,
8417,
199,
3,
755,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
642,
199,
3,
755,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
533,
820,
2352,
2017,
8,
785,
304,
272,
408,
2765,
1021,
365,
1202,
370,
7773,
314,
11785,
4784,
370,
314,
1654,
14,
339,
520,
6691,
2562,
63,
354,
26,
314,
8985,
805,
536,
24649,
1083,
536,
9,
272,
520,
6691,
2562,
63,
589,
26,
314,
2368,
367,
314,
805,
272,
520,
6691,
2562,
63,
7511,
26,
4252,
2368,
367,
314,
805,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2562,
63,
354,
12,
2562,
63,
589,
12,
2562,
63,
958,
304,
267,
291,
14,
1532,
63,
354,
275,
2562,
63,
354,
267,
291,
14,
1532,
63,
589,
275,
2562,
63,
589,
267,
291,
14,
1532,
63,
958,
275,
2562,
63,
958,
339,
347,
636,
495,
721,
277,
304,
267,
372,
1689,
28,
15569,
2017,
8,
1532,
63,
354,
3126,
16,
1386,
2562,
63,
589,
3126,
17,
1386,
2562,
63,
958,
3126,
18,
1552,
4335,
355,
1275,
908,
8,
277,
14,
1532,
63,
354,
12,
291,
14,
1532,
63,
589,
12,
291,
14,
1532,
63,
958,
430,
421,
199,
533,
820,
2352,
2364,
8,
785,
304,
272,
408,
2765,
1021,
365,
1202,
370,
7773,
314,
11785,
7232,
370,
314,
1890,
14,
339,
520,
6691,
754,
26,
314,
754,
402,
314,
8985,
1240,
641,
314,
1654,
272,
408,
272,
347,
636,
826,
721,
277,
12,
754,
304,
267,
291,
14,
1099,
275,
754,
339,
347,
636,
495,
721,
277,
304,
267,
372,
3886,
15569,
2364,
8,
1099,
3126,
16,
1552,
23167,
908,
8,
277,
14,
1099,
9,
339,
768,
1829,
272,
347,
365,
63,
1971,
8,
277,
304,
267,
372,
1228,
8,
277,
14,
1099,
12,
25416,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1898,
334,
67,
9,
8937,
13,
7280,
12,
2799,
18824,
5653,
869,
65,
442,
90,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
755,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
199,
3,
755,
6450,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
199,
3,
755,
543,
314,
4084,
14,
199,
3,
199,
3,
258,
627,
11443,
314,
536,
402,
1240,
278,
6590,
314,
1561,
402,
2399,
8417,
199,
3,
755,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
642,
199,
3,
755,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
533,
820,
2352,
2017,
8,
785,
304,
272,
408,
2765,
1021,
365,
1202,
370,
7773,
314,
11785,
4784,
370,
314,
1654,
14,
339,
520,
6691,
2562,
63,
354,
26,
314,
8985,
805,
536,
24649,
1083,
536,
9,
272,
520,
6691,
2562,
63,
589,
26,
314,
2368,
367,
314,
805,
272,
520,
6691,
2562,
63,
7511,
26,
4252,
2368,
367,
314,
805,
272,
408,
272,
347,
636,
826,
721,
277,
12,
2562,
63,
354,
12,
2562,
63,
589,
12,
2562,
63,
958,
304,
267,
291,
14,
1532,
63,
354,
275,
2562,
63,
354,
267,
291,
14,
1532,
63,
589,
275,
2562,
63,
589,
267,
291,
14,
1532,
63,
958,
275,
2562,
63,
958,
339,
347,
636,
495,
721,
277,
304,
267,
372,
1689,
28,
15569,
2017,
8,
1532,
63,
354,
3126,
16,
1386,
2562,
63,
589,
3126,
17,
1386,
2562,
63,
958,
3126,
18,
1552,
4335,
355,
1275,
908,
8,
277,
14,
1532,
63,
354,
12,
291,
14,
1532,
63,
589,
12,
291,
14,
1532,
63,
958,
430,
421,
199,
533,
820,
2352,
2364,
8,
785,
304,
272,
408,
2765,
1021,
365,
1202,
370,
7773,
314,
11785,
7232,
370,
314,
1890,
14,
339,
520,
6691,
754,
26,
314,
754,
402,
314,
8985,
1240,
641,
314,
1654,
272,
408,
272,
347,
636,
826,
721,
277,
12,
754,
304,
267,
291,
14,
1099,
275,
754,
339,
347,
636,
495,
721,
277,
304,
267,
372,
3886,
15569,
2364,
8,
1099,
3126,
16,
1552,
23167,
908,
8,
277,
14,
1099,
9,
339,
768,
1829,
272,
347,
365,
63,
1971,
8,
277,
304,
267,
372,
1228,
8,
277,
14,
1099,
12,
25416,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Tao-Ma/gpdb
|
gpMgmt/bin/gppylib/test/regress/test_regress_pygresql.py
|
12
|
4162
|
#!/usr/bin/env python
#
# Copyright (c) Greenplum Inc 2008. All Rights Reserved.
#
""" Unittesting for pygres module
"""
import logging
import unittest
from pygresql import pg
from pygresql import pgdb
from gppylib import gplog
from gppylib.db.dbconn import *
from gppylib.db.test import skipIfDatabaseDown
logger=gplog.get_default_logger()
gplog.enable_verbose_logging()
#TODO: incomplete list.
catalog_names = ['pg_aggregate','pg_amop','pg_attrdef','pg_auth_members',
'pg_autovacuum','pg_class','pg_conversion','pg_database','pg_description',
'pg_group','pg_indexes','pg_language','pg_listener',
'pg_max_external_files','pg_opclass','pg_partition']
datatypes = {'oid':True , 'int2':True, 'regproc':True, 'text':True, 'bool':True,
'int4':True, 'float4':True, 'name':True, 'char':True, 'xid':True,
'_aclitem':True, '_text':True, '_oid':True, 'int8':True,
'int2vector':True,'oidvector':True}
@skipIfDatabaseDown()
class pygresqlTestCase(unittest.TestCase):
def test_connect(self):
dburl = DbURL()
logger.info("YO")
db = pg.DB(dbname=dburl.pgdb)
q = db.query("SELECT 1")
logger.info(q.getresult())
def test_DBI_connect(self):
logger.info("test_dbi_connect")
dburl = DbURL()
db = pgdb.connect(dburl.pguser,host=dburl.pghost,database=dburl.pgdb)
curs = db.cursor()
curs.execute("COMMIT")
curs.execute("BEGIN")
curs.execute("DROP TABLE IF EXISTS jge ")
curs.execute("CREATE TABLE jge ( a int )")
curs.execute("DROP TABLE jge")
db.commit()
def test_utilitymode(self):
db = self.setupConnection("test_utilitymode")
curs=db.cursor()
curs.execute("show gp_role")
logger.info(curs.fetchall())
curs.close()
db.close()
def test_pgcatalog_selects(self):
db = self.setupConnection("test_pgcatalog_selects")
curs=db.cursor()
for table in catalog_names:
sql = "SELECT * FROM %s LIMIT 1" % table
curs.execute(sql)
rows=curs.fetchall()
self.verifyResults(rows,curs.description)
curs.close()
db.close()
def test_nulls(self):
db = self.setupConnection("test_nulls")
curs=db.cursor()
curs.execute("BEGIN")
curs.execute("CREATE TABLE test ( a int, b text )")
curs.execute("INSERT INTO test VALUES (null,null)")
curs.execute("SELECT * FROM test")
row = curs.fetchone()
self.assertTrue(row[0] is None)
self.assertTrue(row[1] is None)
def test_createdb(self):
db = None
try:
db = self.setupConnection("test_createdb")
curs=db.cursor()
curs.execute("COMMIT")
curs.execute("CREATE DATABASE test")
curs.execute("DROP DATABASE test")
finally:
if db is not None:
db.close()
def test_vacuum(self):
db = self.setupConnection("test_vacuumdb")
curs = db.cursor()
curs.execute("COMMIT")
curs.execute("VACUUM FULL pg_catalog.pg_class")
db.close()
#------------------------------- non-test helper --------------------------------
def setupConnection(self,name):
logger.info(name)
dburl = DbURL()
dsn=str(dburl) + "::"
db = pgdb.connect(dsn=dsn)
return db
def verifyResults(self,rows,description):
for col in description:
colname = col[0]
datatype = col[1]
self.assertTrue(datatypes[datatype])
for row in rows:
for col in row:
foo = "" + str(col)
#------------------------------- Mainline --------------------------------
if __name__ == '__main__':
unittest.main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
32585,
1168,
453,
3277,
9079,
14,
2900,
5924,
5702,
14,
221,
199,
3,
199,
199,
624,
1910,
1770,
316,
367,
1134,
7266,
859,
199,
624,
199,
646,
2050,
199,
646,
2882,
421,
199,
504,
1134,
7266,
1710,
492,
10275,
199,
504,
1134,
7266,
1710,
492,
10275,
697,
199,
199,
504,
15852,
24111,
492,
15852,
793,
199,
504,
15852,
24111,
14,
697,
14,
697,
1631,
492,
627,
199,
504,
15852,
24111,
14,
697,
14,
396,
492,
3372,
3917,
7243,
3514,
199,
199,
2921,
29,
4927,
793,
14,
362,
63,
885,
63,
2921,
342,
199,
4927,
793,
14,
4296,
63,
3832,
63,
4806,
342,
421,
199,
3,
11768,
26,
221,
17110,
769,
14,
199,
7959,
63,
1247,
275,
788,
4198,
63,
7516,
1673,
4198,
63,
455,
411,
1673,
4198,
63,
962,
318,
1673,
4198,
63,
1178,
63,
6334,
297,
326,
283,
4198,
63,
2495,
15367,
19805,
1673,
4198,
63,
533,
1673,
4198,
63,
15083,
1673,
4198,
63,
4659,
1673,
4198,
63,
1802,
297,
326,
283,
4198,
63,
923,
1673,
4198,
63,
10116,
1673,
4198,
63,
3671,
1673,
4198,
63,
9799,
297,
326,
283,
4198,
63,
988,
63,
5159,
63,
1725,
1673,
4198,
63,
411,
533,
1673,
4198,
63,
5312,
418,
199,
199,
14184,
83,
275,
791,
1170,
356,
549,
2360,
283,
442,
18,
356,
549,
12,
283,
1135,
4687,
356,
549,
12,
283,
505,
356,
549,
12,
283,
2245,
356,
549,
12,
1467,
283,
442,
20,
356,
549,
12,
283,
1609,
20,
356,
549,
12,
283,
354,
356,
549,
12,
283,
1560,
356,
549,
12,
283,
21352,
356,
549,
12,
1467,
2513,
645,
317,
563,
356,
549,
12,
2513,
505,
356,
549,
12,
2513,
1170,
356,
549,
12,
283,
442,
24,
356,
549,
12,
1467,
283,
442,
18,
4106,
356,
549,
2584,
1170,
4106,
356,
549,
93,
421,
199,
32,
15118,
7243,
3514,
342,
199,
533,
1134,
7266,
1710,
1746,
8,
2796,
14,
1746,
304,
25979,
347,
511,
63,
2242,
8,
277,
304,
267,
1592,
633,
275,
28822,
2632,
342,
18418,
2512,
14,
815,
480,
57,
47,
531,
267,
1592,
275,
10275,
14,
2846,
8,
13238,
29,
697,
633,
14,
4198,
697,
9,
267,
1894,
275,
1592,
14,
1131,
480,
4859,
413,
531,
267,
2512,
14,
815,
8,
81,
14,
362,
1099,
1012,
2286,
347,
511,
63,
2846,
41,
63,
2242,
8,
277,
304,
2728,
2512,
14,
815,
480,
396,
63,
697,
73,
63,
2242,
531,
267,
1592,
633,
275,
28822,
2632,
342,
18418,
1592,
275,
10275,
697,
14,
2242,
8,
697,
633,
14,
4198,
751,
12,
1102,
29,
697,
633,
14,
4198,
1102,
12,
4659,
29,
697,
633,
14,
4198,
697,
9,
267,
18809,
275,
1592,
14,
3937,
342,
18418,
18809,
14,
2526,
480,
23446,
531,
267,
18809,
14,
2526,
480,
15947,
531,
267,
18809,
14,
2526,
480,
14764,
9934,
8036,
23875,
1335,
303,
6099,
267,
18809,
14,
2526,
480,
8366,
9934,
1335,
303,
334,
282,
1109,
776,
531,
267,
18809,
14,
2526,
480,
14764,
9934,
1335,
303,
531,
267,
1592,
14,
3543,
342,
257,
339,
347,
511,
63,
16877,
632,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
16877,
632,
531,
267,
18809,
29,
697,
14,
3937,
342,
27439,
18809,
14,
2526,
480,
2384,
15852,
63,
3756,
531,
267,
2512,
14,
815,
8,
17255,
14,
10174,
1012,
267,
18809,
14,
1600,
342,
267,
1592,
14,
1600,
342,
339,
347,
511,
63,
4198,
7959,
63,
2416,
83,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
4198,
7959,
63,
2416,
83,
531,
267,
18809,
29,
697,
14,
3937,
342,
257,
2126,
2728,
367,
1817,
315,
10594,
63,
1247,
26,
288,
3875,
275,
298,
4859,
627,
4442,
450,
83,
5138,
413,
2,
450,
1817,
288,
18809,
14,
2526,
8,
3009,
9,
288,
4730,
29,
17255,
14,
10174,
342,
288,
291,
14,
4712,
6579,
8,
3838,
12,
17255,
14,
1802,
9,
2490,
267,
18809,
14,
1600,
342,
267,
1592,
14,
1600,
342,
2378,
347,
511,
63,
24976,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
24976,
531,
18418,
18809,
29,
697,
14,
3937,
342,
2728,
18809,
14,
2526,
480,
15947,
531,
267,
18809,
14,
2526,
480,
8366,
9934,
511,
334,
282,
1109,
12,
330,
1318,
776,
531,
267,
18809,
14,
2526,
480,
10258,
12872,
511,
13992,
334,
2307,
12,
2307,
6320,
267,
18809,
14,
2526,
480,
4859,
627,
4442,
511,
531,
267,
1962,
275,
18809,
14,
11591,
342,
267,
291,
14,
1815,
8,
1143,
59,
16,
61,
365,
488,
9,
267,
291,
14,
1815,
8,
1143,
59,
17,
61,
365,
488,
9,
268,
5493,
347,
511,
63,
981,
697,
8,
277,
304,
267,
1592,
275,
488,
267,
862,
26,
288,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
981,
697,
531,
288,
18809,
29,
697,
14,
3937,
342,
260,
27180,
18809,
14,
2526,
480,
23446,
531,
288,
18809,
14,
2526,
480,
8366,
31705,
511,
531,
288,
18809,
14,
2526,
480,
14764,
31705,
511,
531,
267,
3753,
26,
288,
340,
1592,
365,
440,
488,
26,
355,
1592,
14,
1600,
342,
1467,
339,
347,
511,
63,
15367,
19805,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
15367,
19805,
697,
531,
267,
18809,
275,
1592,
14,
3937,
342,
2728,
18809,
14,
2526,
480,
23446,
531,
267,
18809,
14,
2526,
480,
26780,
53,
2639,
18530,
10275,
63,
7959,
14,
4198,
63,
533,
531,
267,
1592,
14,
1600,
342,
268,
5493,
327,
777,
18964,
2222,
13,
396,
5922,
11016,
272,
347,
3272,
3225,
8,
277,
12,
354,
304,
267,
2512,
14,
815,
8,
354,
9,
267,
1592,
633,
275,
28822,
2632,
342,
267,
366,
5167,
29,
495,
8,
697,
633,
9,
435,
27472,
2,
267,
1592,
275,
10275,
697,
14,
2242,
8,
32510,
29,
32510,
9,
267,
372,
1592,
268,
5493,
347,
4911,
6579,
8,
277,
12,
3838,
12,
1802,
304,
2728,
367,
1048,
315,
1369,
26,
288,
1048,
354,
275,
1048,
59,
16,
61,
288,
16048,
275,
1048,
59,
17,
61,
12793,
288,
291,
14,
1815,
8,
14184,
83,
59,
14184,
566,
2728,
367,
1962,
315,
4730,
26,
288,
367,
1048,
315,
1962,
26,
355,
3925
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
32585,
1168,
453,
3277,
9079,
14,
2900,
5924,
5702,
14,
221,
199,
3,
199,
199,
624,
1910,
1770,
316,
367,
1134,
7266,
859,
199,
624,
199,
646,
2050,
199,
646,
2882,
421,
199,
504,
1134,
7266,
1710,
492,
10275,
199,
504,
1134,
7266,
1710,
492,
10275,
697,
199,
199,
504,
15852,
24111,
492,
15852,
793,
199,
504,
15852,
24111,
14,
697,
14,
697,
1631,
492,
627,
199,
504,
15852,
24111,
14,
697,
14,
396,
492,
3372,
3917,
7243,
3514,
199,
199,
2921,
29,
4927,
793,
14,
362,
63,
885,
63,
2921,
342,
199,
4927,
793,
14,
4296,
63,
3832,
63,
4806,
342,
421,
199,
3,
11768,
26,
221,
17110,
769,
14,
199,
7959,
63,
1247,
275,
788,
4198,
63,
7516,
1673,
4198,
63,
455,
411,
1673,
4198,
63,
962,
318,
1673,
4198,
63,
1178,
63,
6334,
297,
326,
283,
4198,
63,
2495,
15367,
19805,
1673,
4198,
63,
533,
1673,
4198,
63,
15083,
1673,
4198,
63,
4659,
1673,
4198,
63,
1802,
297,
326,
283,
4198,
63,
923,
1673,
4198,
63,
10116,
1673,
4198,
63,
3671,
1673,
4198,
63,
9799,
297,
326,
283,
4198,
63,
988,
63,
5159,
63,
1725,
1673,
4198,
63,
411,
533,
1673,
4198,
63,
5312,
418,
199,
199,
14184,
83,
275,
791,
1170,
356,
549,
2360,
283,
442,
18,
356,
549,
12,
283,
1135,
4687,
356,
549,
12,
283,
505,
356,
549,
12,
283,
2245,
356,
549,
12,
1467,
283,
442,
20,
356,
549,
12,
283,
1609,
20,
356,
549,
12,
283,
354,
356,
549,
12,
283,
1560,
356,
549,
12,
283,
21352,
356,
549,
12,
1467,
2513,
645,
317,
563,
356,
549,
12,
2513,
505,
356,
549,
12,
2513,
1170,
356,
549,
12,
283,
442,
24,
356,
549,
12,
1467,
283,
442,
18,
4106,
356,
549,
2584,
1170,
4106,
356,
549,
93,
421,
199,
32,
15118,
7243,
3514,
342,
199,
533,
1134,
7266,
1710,
1746,
8,
2796,
14,
1746,
304,
25979,
347,
511,
63,
2242,
8,
277,
304,
267,
1592,
633,
275,
28822,
2632,
342,
18418,
2512,
14,
815,
480,
57,
47,
531,
267,
1592,
275,
10275,
14,
2846,
8,
13238,
29,
697,
633,
14,
4198,
697,
9,
267,
1894,
275,
1592,
14,
1131,
480,
4859,
413,
531,
267,
2512,
14,
815,
8,
81,
14,
362,
1099,
1012,
2286,
347,
511,
63,
2846,
41,
63,
2242,
8,
277,
304,
2728,
2512,
14,
815,
480,
396,
63,
697,
73,
63,
2242,
531,
267,
1592,
633,
275,
28822,
2632,
342,
18418,
1592,
275,
10275,
697,
14,
2242,
8,
697,
633,
14,
4198,
751,
12,
1102,
29,
697,
633,
14,
4198,
1102,
12,
4659,
29,
697,
633,
14,
4198,
697,
9,
267,
18809,
275,
1592,
14,
3937,
342,
18418,
18809,
14,
2526,
480,
23446,
531,
267,
18809,
14,
2526,
480,
15947,
531,
267,
18809,
14,
2526,
480,
14764,
9934,
8036,
23875,
1335,
303,
6099,
267,
18809,
14,
2526,
480,
8366,
9934,
1335,
303,
334,
282,
1109,
776,
531,
267,
18809,
14,
2526,
480,
14764,
9934,
1335,
303,
531,
267,
1592,
14,
3543,
342,
257,
339,
347,
511,
63,
16877,
632,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
16877,
632,
531,
267,
18809,
29,
697,
14,
3937,
342,
27439,
18809,
14,
2526,
480,
2384,
15852,
63,
3756,
531,
267,
2512,
14,
815,
8,
17255,
14,
10174,
1012,
267,
18809,
14,
1600,
342,
267,
1592,
14,
1600,
342,
339,
347,
511,
63,
4198,
7959,
63,
2416,
83,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
4198,
7959,
63,
2416,
83,
531,
267,
18809,
29,
697,
14,
3937,
342,
257,
2126,
2728,
367,
1817,
315,
10594,
63,
1247,
26,
288,
3875,
275,
298,
4859,
627,
4442,
450,
83,
5138,
413,
2,
450,
1817,
288,
18809,
14,
2526,
8,
3009,
9,
288,
4730,
29,
17255,
14,
10174,
342,
288,
291,
14,
4712,
6579,
8,
3838,
12,
17255,
14,
1802,
9,
2490,
267,
18809,
14,
1600,
342,
267,
1592,
14,
1600,
342,
2378,
347,
511,
63,
24976,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
24976,
531,
18418,
18809,
29,
697,
14,
3937,
342,
2728,
18809,
14,
2526,
480,
15947,
531,
267,
18809,
14,
2526,
480,
8366,
9934,
511,
334,
282,
1109,
12,
330,
1318,
776,
531,
267,
18809,
14,
2526,
480,
10258,
12872,
511,
13992,
334,
2307,
12,
2307,
6320,
267,
18809,
14,
2526,
480,
4859,
627,
4442,
511,
531,
267,
1962,
275,
18809,
14,
11591,
342,
267,
291,
14,
1815,
8,
1143,
59,
16,
61,
365,
488,
9,
267,
291,
14,
1815,
8,
1143,
59,
17,
61,
365,
488,
9,
268,
5493,
347,
511,
63,
981,
697,
8,
277,
304,
267,
1592,
275,
488,
267,
862,
26,
288,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
981,
697,
531,
288,
18809,
29,
697,
14,
3937,
342,
260,
27180,
18809,
14,
2526,
480,
23446,
531,
288,
18809,
14,
2526,
480,
8366,
31705,
511,
531,
288,
18809,
14,
2526,
480,
14764,
31705,
511,
531,
267,
3753,
26,
288,
340,
1592,
365,
440,
488,
26,
355,
1592,
14,
1600,
342,
1467,
339,
347,
511,
63,
15367,
19805,
8,
277,
304,
267,
1592,
275,
291,
14,
2758,
3225,
480,
396,
63,
15367,
19805,
697,
531,
267,
18809,
275,
1592,
14,
3937,
342,
2728,
18809,
14,
2526,
480,
23446,
531,
267,
18809,
14,
2526,
480,
26780,
53,
2639,
18530,
10275,
63,
7959,
14,
4198,
63,
533,
531,
267,
1592,
14,
1600,
342,
268,
5493,
327,
777,
18964,
2222,
13,
396,
5922,
11016,
272,
347,
3272,
3225,
8,
277,
12,
354,
304,
267,
2512,
14,
815,
8,
354,
9,
267,
1592,
633,
275,
28822,
2632,
342,
267,
366,
5167,
29,
495,
8,
697,
633,
9,
435,
27472,
2,
267,
1592,
275,
10275,
697,
14,
2242,
8,
32510,
29,
32510,
9,
267,
372,
1592,
268,
5493,
347,
4911,
6579,
8,
277,
12,
3838,
12,
1802,
304,
2728,
367,
1048,
315,
1369,
26,
288,
1048,
354,
275,
1048,
59,
16,
61,
288,
16048,
275,
1048,
59,
17,
61,
12793,
288,
291,
14,
1815,
8,
14184,
83,
59,
14184,
566,
2728,
367,
1962,
315,
4730,
26,
288,
367,
1048,
315,
1962,
26,
355,
3925,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
gylian/sickbeard
|
lib/requests/packages/chardet2/euckrprober.py
|
63
|
1676
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
from .mbcharsetprober import MultiByteCharSetProber
from .codingstatemachine import CodingStateMachine
from .chardistribution import EUCKRDistributionAnalysis
from .mbcssm import EUCKRSMModel
class EUCKRProber(MultiByteCharSetProber):
def __init__(self):
MultiByteCharSetProber.__init__(self)
self._mCodingSM = CodingStateMachine(EUCKRSMModel)
self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
self.reset()
def get_charset_name(self):
return "EUC-KR"
|
gpl-3.0
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
887,
6043,
19903,
492,
6879,
21312,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
504,
1275,
1560,
4972,
492,
26007,
27373,
24906,
199,
504,
1275,
887,
3919,
77,
492,
26007,
27373,
25335,
199,
199,
533,
26007,
27373,
8029,
8,
3947,
21312,
304,
272,
347,
636,
826,
721,
277,
304,
267,
6879,
21312,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
30539,
8,
23539,
27373,
25335,
9,
267,
291,
423,
77,
8580,
17606,
275,
26007,
27373,
24906,
342,
267,
291,
14,
3958,
342,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
298,
37,
13371,
13,
23063,
2,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
1303,
6956,
14,
1308,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
504,
1275,
887,
6043,
19903,
492,
6879,
21312,
199,
504,
1275,
1523,
929,
6744,
492,
30539,
199,
504,
1275,
1560,
4972,
492,
26007,
27373,
24906,
199,
504,
1275,
887,
3919,
77,
492,
26007,
27373,
25335,
199,
199,
533,
26007,
27373,
8029,
8,
3947,
21312,
304,
272,
347,
636,
826,
721,
277,
304,
267,
6879,
21312,
855,
826,
721,
277,
9,
267,
291,
423,
29633,
275,
30539,
8,
23539,
27373,
25335,
9,
267,
291,
423,
77,
8580,
17606,
275,
26007,
27373,
24906,
342,
267,
291,
14,
3958,
342,
339,
347,
664,
63,
6043,
63,
354,
8,
277,
304,
267,
372,
298,
37,
13371,
13,
23063,
2,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
piffey/ansible
|
lib/ansible/modules/remote_management/manageiq/manageiq_alert_profiles.py
|
59
|
11282
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
module: manageiq_alert_profiles
short_description: Configuration of alert profiles for ManageIQ
extends_documentation_fragment: manageiq
version_added: '2.5'
author: Elad Alfassa (ealfassa@redhat.com)
description:
- The manageiq_alert_profiles module supports adding, updating and deleting alert profiles in ManageIQ.
options:
state:
description:
- absent - alert profile should not exist,
- present - alert profile should exist,
choices: ['absent', 'present']
default: 'present'
name:
description:
- The unique alert profile name in ManageIQ.
- Required when state is "absent" or "present".
resource_type:
description:
- The resource type for the alert profile in ManageIQ. Required when state is "present".
choices: ['Vm', 'ContainerNode', 'MiqServer', 'Host', 'Storage', 'EmsCluster',
'ExtManagementSystem', 'MiddlewareServer']
alerts:
description:
- List of alert descriptions to assign to this profile.
- Required if state is "present"
notes:
description:
- Optional notes for this profile
'''
EXAMPLES = '''
- name: Add an alert profile to ManageIQ
manageiq_alert_profiles:
state: present
name: Test profile
resource_type: ContainerNode
alerts:
- Test Alert 01
- Test Alert 02
manageiq_connection:
url: 'http://127.0.0.1:3000'
username: 'admin'
password: 'smartvm'
verify_ssl: False
- name: Delete an alert profile from ManageIQ
manageiq_alert_profiles:
state: absent
name: Test profile
manageiq_connection:
url: 'http://127.0.0.1:3000'
username: 'admin'
password: 'smartvm'
verify_ssl: False
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.manageiq import ManageIQ, manageiq_argument_spec
class ManageIQAlertProfiles(object):
""" Object to execute alert profile management operations in manageiq.
"""
def __init__(self, manageiq):
self.manageiq = manageiq
self.module = self.manageiq.module
self.api_url = self.manageiq.api_url
self.client = self.manageiq.client
self.url = '{api_url}/alert_definition_profiles'.format(api_url=self.api_url)
def get_profiles(self):
""" Get all alert profiles from ManageIQ
"""
try:
response = self.client.get(self.url + '?expand=alert_definitions,resources')
except Exception as e:
self.module.fail_json(msg="Failed to query alert profiles: {error}".format(error=e))
return response.get('resources') or []
def get_alerts(self, alert_descriptions):
""" Get a list of alert hrefs from a list of alert descriptions
"""
alerts = []
for alert_description in alert_descriptions:
alert = self.manageiq.find_collection_resource_or_fail("alert_definitions",
description=alert_description)
alerts.append(alert['href'])
return alerts
def add_profile(self, profile):
""" Add a new alert profile to ManageIQ
"""
# find all alerts to add to the profile
# we do this first to fail early if one is missing.
alerts = self.get_alerts(profile['alerts'])
# build the profile dict to send to the server
profile_dict = dict(name=profile['name'],
description=profile['name'],
mode=profile['resource_type'])
if profile['notes']:
profile_dict['set_data'] = dict(notes=profile['notes'])
# send it to the server
try:
result = self.client.post(self.url, resource=profile_dict, action="create")
except Exception as e:
self.module.fail_json(msg="Creating profile failed {error}".format(error=e))
# now that it has been created, we can assign the alerts
self.assign_or_unassign(result['results'][0], alerts, "assign")
msg = "Profile {name} created successfully"
msg = msg.format(name=profile['name'])
return dict(changed=True, msg=msg)
def delete_profile(self, profile):
""" Delete an alert profile from ManageIQ
"""
try:
self.client.post(profile['href'], action="delete")
except Exception as e:
self.module.fail_json(msg="Deleting profile failed: {error}".format(error=e))
msg = "Successfuly deleted profile {name}".format(name=profile['name'])
return dict(changed=True, msg=msg)
def get_alert_href(self, alert):
""" Get an absolute href for an alert
"""
return "{url}/alert_definitions/{id}".format(url=self.api_url, id=alert['id'])
def assign_or_unassign(self, profile, resources, action):
""" Assign or unassign alerts to profile, and validate the result.
"""
alerts = [dict(href=href) for href in resources]
subcollection_url = profile['href'] + '/alert_definitions'
try:
result = self.client.post(subcollection_url, resources=alerts, action=action)
if len(result['results']) != len(alerts):
msg = "Failed to {action} alerts to profile '{name}'," +\
"expected {expected} alerts to be {action}ed," +\
"but only {changed} were {action}ed"
msg = msg.format(action=action,
name=profile['name'],
expected=len(alerts),
changed=result['results'])
self.module.fail_json(msg=msg)
except Exception as e:
msg = "Failed to {action} alerts to profile '{name}': {error}"
msg = msg.format(action=action, name=profile['name'], error=e)
self.module.fail_json(msg=msg)
return result['results']
def update_profile(self, old_profile, desired_profile):
""" Update alert profile in ManageIQ
"""
changed = False
# we need to use client.get to query the alert definitions
old_profile = self.client.get(old_profile['href'] + '?expand=alert_definitions')
# figure out which alerts we need to assign / unassign
# alerts listed by the user:
desired_alerts = set(self.get_alerts(desired_profile['alerts']))
# alert which currently exist in the profile
if 'alert_definitions' in old_profile:
# we use get_alert_href to have a direct href to the alert
existing_alerts = set([self.get_alert_href(alert) for alert in old_profile['alert_definitions']])
else:
# no alerts in this profile
existing_alerts = set()
to_add = list(desired_alerts - existing_alerts)
to_remove = list(existing_alerts - desired_alerts)
# assign / unassign the alerts, if needed
if to_remove:
self.assign_or_unassign(old_profile, to_remove, "unassign")
changed = True
if to_add:
self.assign_or_unassign(old_profile, to_add, "assign")
changed = True
# update other properties
profile_dict = dict()
if old_profile['mode'] != desired_profile['resource_type']:
# mode needs to be updated
profile_dict['mode'] = desired_profile['resource_type']
# check if notes need to be updated
old_notes = old_profile.get('set_data', {}).get('notes')
if desired_profile['notes'] != old_notes:
profile_dict['set_data'] = dict(notes=desired_profile['notes'])
if profile_dict:
# if we have any updated values
changed = True
try:
result = self.client.post(old_profile['href'],
resource=profile_dict,
action="edit")
except Exception as e:
msg = "Updating profile '{name}' failed: {error}"
msg = msg.format(name=old_profile['name'], error=e)
self.module.fail_json(msg=msg, result=result)
if changed:
msg = "Profile {name} updated successfully".format(name=desired_profile['name'])
else:
msg = "No update needed for profile {name}".format(name=desired_profile['name'])
return dict(changed=changed, msg=msg)
def main():
argument_spec = dict(
name=dict(type='str'),
resource_type=dict(type='str', choices=['Vm',
'ContainerNode',
'MiqServer',
'Host',
'Storage',
'EmsCluster',
'ExtManagementSystem',
'MiddlewareServer']),
alerts=dict(type='list'),
notes=dict(type='str'),
state=dict(default='present', choices=['present', 'absent']),
)
# add the manageiq connection arguments to the arguments
argument_spec.update(manageiq_argument_spec())
module = AnsibleModule(argument_spec=argument_spec,
required_if=[('state', 'present', ['name', 'resource_type']),
('state', 'absent', ['name'])])
state = module.params['state']
name = module.params['name']
manageiq = ManageIQ(module)
manageiq_alert_profiles = ManageIQAlertProfiles(manageiq)
existing_profile = manageiq.find_collection_resource_by("alert_definition_profiles",
name=name)
# we need to add or update the alert profile
if state == "present":
if not existing_profile:
# a profile with this name doesn't exist yet, let's create it
res_args = manageiq_alert_profiles.add_profile(module.params)
else:
# a profile with this name exists, we might need to update it
res_args = manageiq_alert_profiles.update_profile(existing_profile, module.params)
# this alert profile should not exist
if state == "absent":
# if we have an alert profile with this name, delete it
if existing_profile:
res_args = manageiq_alert_profiles.delete_profile(existing_profile)
else:
# This alert profile does not exist in ManageIQ, and that's okay
msg = "Alert profile '{name}' does not exist in ManageIQ"
msg = msg.format(name=name)
res_args = dict(changed=False, msg=msg)
module.exit_json(**res_args)
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
67,
9,
9708,
9572,
13002,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
1449,
199,
199,
578,
26,
9635,
9962,
63,
9241,
63,
11225,
199,
199,
3612,
63,
1802,
26,
11595,
402,
10459,
17390,
367,
14944,
23559,
199,
11036,
63,
9970,
63,
7677,
26,
9635,
9962,
199,
1023,
63,
3270,
26,
283,
18,
14,
21,
7,
199,
2502,
26,
13096,
350,
437,
276,
405,
65,
334,
4489,
276,
405,
65,
32,
17164,
14,
957,
9,
199,
1802,
26,
523,
446,
710,
9635,
9962,
63,
9241,
63,
11225,
859,
5171,
7791,
12,
12928,
436,
13794,
10459,
17390,
315,
14944,
23559,
14,
199,
199,
1419,
26,
523,
1174,
26,
272,
1369,
26,
489,
446,
9552,
446,
10459,
4690,
1077,
440,
2187,
12,
489,
446,
3451,
446,
10459,
4690,
1077,
2187,
12,
272,
3415,
26,
788,
5575,
297,
283,
1881,
418,
272,
849,
26,
283,
1881,
7,
523,
536,
26,
272,
1369,
26,
489,
446,
710,
3747,
10459,
4690,
536,
315,
14944,
23559,
14,
489,
446,
11105,
1380,
1174,
365,
298,
5575,
2,
503,
298,
1881,
1674,
523,
2073,
63,
466,
26,
272,
1369,
26,
489,
446,
710,
2073,
730,
367,
314,
10459,
4690,
315,
14944,
23559,
14,
11105,
1380,
1174,
365,
298,
1881,
1674,
272,
3415,
26,
788,
17402,
297,
283,
4076,
1716,
297,
283,
45,
9962,
3120,
297,
283,
4965,
297,
283,
6408,
297,
283,
37,
706,
9581,
297,
1598,
283,
4942,
14552,
3989,
297,
283,
6608,
3120,
418,
523,
31529,
26,
272,
1369,
26,
489,
446,
3820,
402,
10459,
18714,
370,
5090,
370,
642,
4690,
14,
489,
446,
11105,
340,
1174,
365,
298,
1881,
2,
523,
12681,
26,
272,
1369,
26,
489,
446,
4879,
12681,
367,
642,
4690,
199,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
2654,
376,
10459,
4690,
370,
14944,
23559,
523,
9635,
9962,
63,
9241,
63,
11225,
26,
272,
1174,
26,
3451,
272,
536,
26,
1379,
4690,
272,
2073,
63,
466,
26,
15395,
1716,
272,
31529,
26,
489,
446,
1379,
25762,
17163,
489,
446,
1379,
25762,
12497,
272,
9635,
9962,
63,
2105,
26,
489,
1166,
26,
283,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
19962,
7,
489,
3434,
26,
283,
2113,
7,
489,
2505,
26,
283,
7853,
2611,
7,
489,
4911,
63,
4266,
26,
756,
199,
199,
13,
536,
26,
8496,
376,
10459,
4690,
687,
14944,
23559,
523,
9635,
9962,
63,
9241,
63,
11225,
26,
272,
1174,
26,
9552,
272,
536,
26,
1379,
4690,
272,
9635,
9962,
63,
2105,
26,
489,
1166,
26,
283,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
19962,
7,
489,
3434,
26,
283,
2113,
7,
489,
2505,
26,
283,
7853,
2611,
7,
489,
4911,
63,
4266,
26,
756,
199,
2344,
199,
199,
9677,
275,
1449,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
9053,
9962,
492,
14944,
23559,
12,
9635,
9962,
63,
2094,
63,
1650,
421,
199,
533,
14944,
41,
14323,
5567,
30208,
8,
785,
304,
272,
408,
6935,
370,
5341,
10459,
4690,
10041,
5331,
315,
9635,
9962,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
9635,
9962,
304,
267,
291,
14,
9053,
9962,
275,
9635,
9962,
398,
291,
14,
578,
275,
291,
14,
9053,
9962,
14,
578,
267,
291,
14,
1246,
63,
633,
275,
291,
14,
9053,
9962,
14,
1246,
63,
633,
267,
291,
14,
1258,
275,
291,
14,
9053,
9962,
14,
1258,
267,
291,
14,
633,
275,
5041,
1246,
63,
633,
5995,
9241,
63,
7463,
63,
11225,
1370,
908,
8,
1246,
63,
633,
29,
277,
14,
1246,
63,
633,
9,
339,
347,
664,
63,
11225,
8,
277,
304,
267,
408,
2372,
1006,
10459,
17390,
687,
14944,
23559,
267,
408,
267,
862,
26,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
633,
435,
8720,
4441,
29,
9241,
63,
15388,
12,
4435,
358,
267,
871,
2186,
465,
325,
26,
288,
291,
14,
578,
14,
1633,
63,
1001,
8,
1328,
628,
4276,
370,
1827,
10459,
17390,
26,
469,
705,
5469,
908,
8,
705,
29,
69,
430,
267,
372,
1177,
14,
362,
360,
4435,
358,
503,
942,
339,
347,
664,
63,
24501,
8,
277,
12,
10459,
63,
21713,
304,
267,
408,
2372,
282,
769,
402,
10459,
4369,
83,
687,
282,
769,
402,
10459,
18714,
267,
408,
267,
31529,
275,
942,
267,
367,
10459,
63,
1802,
315,
10459,
63,
21713,
26,
288,
10459,
275,
291,
14,
9053,
9962,
14,
1623,
63,
3627,
63,
1927,
63,
269,
63,
1633,
480,
9241,
63,
15388,
401,
28095,
1369,
29,
9241,
63,
1802,
9,
288,
31529,
14,
740,
8,
9241,
459,
6399,
1105,
398,
372,
31529,
339,
347,
1050,
63,
2913,
8,
277,
12,
4690,
304,
267,
408,
2654,
282,
892,
10459,
4690,
370,
14944,
23559,
267,
408,
267,
327,
2342,
1006,
31529,
370,
1050,
370,
314,
4690,
267,
327,
781,
886,
642,
1642,
370,
2449,
14670,
340,
1373,
365,
4124,
14,
267,
31529,
275,
291,
14,
362,
63,
24501,
8,
2913,
459,
24501,
1105,
398,
327,
1900,
314,
4690,
1211,
370,
3222,
370,
314,
1654,
398,
4690,
63,
807,
275,
1211,
8,
354,
29,
2913,
459,
354,
995,
1169,
1369,
29,
2913,
459,
354,
995,
1169,
818,
29,
2913,
459,
1927,
63,
466,
1105,
267,
340,
4690,
459,
5983,
2565,
288,
4690,
63,
807,
459,
409,
63,
576,
418,
275,
1211,
8,
5983,
29,
2913,
459,
5983,
1105,
398,
327,
3222,
652,
370,
314,
1654,
267,
862,
26,
288,
754,
275,
291,
14,
1258,
14,
1932,
8,
277,
14,
633,
12,
2073,
29,
2913,
63,
807,
12,
1595
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
334,
67,
9,
9708,
9572,
13002,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
9387,
936,
199,
199,
8948,
275,
1449,
199,
199,
578,
26,
9635,
9962,
63,
9241,
63,
11225,
199,
199,
3612,
63,
1802,
26,
11595,
402,
10459,
17390,
367,
14944,
23559,
199,
11036,
63,
9970,
63,
7677,
26,
9635,
9962,
199,
1023,
63,
3270,
26,
283,
18,
14,
21,
7,
199,
2502,
26,
13096,
350,
437,
276,
405,
65,
334,
4489,
276,
405,
65,
32,
17164,
14,
957,
9,
199,
1802,
26,
523,
446,
710,
9635,
9962,
63,
9241,
63,
11225,
859,
5171,
7791,
12,
12928,
436,
13794,
10459,
17390,
315,
14944,
23559,
14,
199,
199,
1419,
26,
523,
1174,
26,
272,
1369,
26,
489,
446,
9552,
446,
10459,
4690,
1077,
440,
2187,
12,
489,
446,
3451,
446,
10459,
4690,
1077,
2187,
12,
272,
3415,
26,
788,
5575,
297,
283,
1881,
418,
272,
849,
26,
283,
1881,
7,
523,
536,
26,
272,
1369,
26,
489,
446,
710,
3747,
10459,
4690,
536,
315,
14944,
23559,
14,
489,
446,
11105,
1380,
1174,
365,
298,
5575,
2,
503,
298,
1881,
1674,
523,
2073,
63,
466,
26,
272,
1369,
26,
489,
446,
710,
2073,
730,
367,
314,
10459,
4690,
315,
14944,
23559,
14,
11105,
1380,
1174,
365,
298,
1881,
1674,
272,
3415,
26,
788,
17402,
297,
283,
4076,
1716,
297,
283,
45,
9962,
3120,
297,
283,
4965,
297,
283,
6408,
297,
283,
37,
706,
9581,
297,
1598,
283,
4942,
14552,
3989,
297,
283,
6608,
3120,
418,
523,
31529,
26,
272,
1369,
26,
489,
446,
3820,
402,
10459,
18714,
370,
5090,
370,
642,
4690,
14,
489,
446,
11105,
340,
1174,
365,
298,
1881,
2,
523,
12681,
26,
272,
1369,
26,
489,
446,
4879,
12681,
367,
642,
4690,
199,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
2654,
376,
10459,
4690,
370,
14944,
23559,
523,
9635,
9962,
63,
9241,
63,
11225,
26,
272,
1174,
26,
3451,
272,
536,
26,
1379,
4690,
272,
2073,
63,
466,
26,
15395,
1716,
272,
31529,
26,
489,
446,
1379,
25762,
17163,
489,
446,
1379,
25762,
12497,
272,
9635,
9962,
63,
2105,
26,
489,
1166,
26,
283,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
19962,
7,
489,
3434,
26,
283,
2113,
7,
489,
2505,
26,
283,
7853,
2611,
7,
489,
4911,
63,
4266,
26,
756,
199,
199,
13,
536,
26,
8496,
376,
10459,
4690,
687,
14944,
23559,
523,
9635,
9962,
63,
9241,
63,
11225,
26,
272,
1174,
26,
9552,
272,
536,
26,
1379,
4690,
272,
9635,
9962,
63,
2105,
26,
489,
1166,
26,
283,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
19962,
7,
489,
3434,
26,
283,
2113,
7,
489,
2505,
26,
283,
7853,
2611,
7,
489,
4911,
63,
4266,
26,
756,
199,
2344,
199,
199,
9677,
275,
1449,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
9053,
9962,
492,
14944,
23559,
12,
9635,
9962,
63,
2094,
63,
1650,
421,
199,
533,
14944,
41,
14323,
5567,
30208,
8,
785,
304,
272,
408,
6935,
370,
5341,
10459,
4690,
10041,
5331,
315,
9635,
9962,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
9635,
9962,
304,
267,
291,
14,
9053,
9962,
275,
9635,
9962,
398,
291,
14,
578,
275,
291,
14,
9053,
9962,
14,
578,
267,
291,
14,
1246,
63,
633,
275,
291,
14,
9053,
9962,
14,
1246,
63,
633,
267,
291,
14,
1258,
275,
291,
14,
9053,
9962,
14,
1258,
267,
291,
14,
633,
275,
5041,
1246,
63,
633,
5995,
9241,
63,
7463,
63,
11225,
1370,
908,
8,
1246,
63,
633,
29,
277,
14,
1246,
63,
633,
9,
339,
347,
664,
63,
11225,
8,
277,
304,
267,
408,
2372,
1006,
10459,
17390,
687,
14944,
23559,
267,
408,
267,
862,
26,
288,
1177,
275,
291,
14,
1258,
14,
362,
8,
277,
14,
633,
435,
8720,
4441,
29,
9241,
63,
15388,
12,
4435,
358,
267,
871,
2186,
465,
325,
26,
288,
291,
14,
578,
14,
1633,
63,
1001,
8,
1328,
628,
4276,
370,
1827,
10459,
17390,
26,
469,
705,
5469,
908,
8,
705,
29,
69,
430,
267,
372,
1177,
14,
362,
360,
4435,
358,
503,
942,
339,
347,
664,
63,
24501,
8,
277,
12,
10459,
63,
21713,
304,
267,
408,
2372,
282,
769,
402,
10459,
4369,
83,
687,
282,
769,
402,
10459,
18714,
267,
408,
267,
31529,
275,
942,
267,
367,
10459,
63,
1802,
315,
10459,
63,
21713,
26,
288,
10459,
275,
291,
14,
9053,
9962,
14,
1623,
63,
3627,
63,
1927,
63,
269,
63,
1633,
480,
9241,
63,
15388,
401,
28095,
1369,
29,
9241,
63,
1802,
9,
288,
31529,
14,
740,
8,
9241,
459,
6399,
1105,
398,
372,
31529,
339,
347,
1050,
63,
2913,
8,
277,
12,
4690,
304,
267,
408,
2654,
282,
892,
10459,
4690,
370,
14944,
23559,
267,
408,
267,
327,
2342,
1006,
31529,
370,
1050,
370,
314,
4690,
267,
327,
781,
886,
642,
1642,
370,
2449,
14670,
340,
1373,
365,
4124,
14,
267,
31529,
275,
291,
14,
362,
63,
24501,
8,
2913,
459,
24501,
1105,
398,
327,
1900,
314,
4690,
1211,
370,
3222,
370,
314,
1654,
398,
4690,
63,
807,
275,
1211,
8,
354,
29,
2913,
459,
354,
995,
1169,
1369,
29,
2913,
459,
354,
995,
1169,
818,
29,
2913,
459,
1927,
63,
466,
1105,
267,
340,
4690,
459,
5983,
2565,
288,
4690,
63,
807,
459,
409,
63,
576,
418,
275,
1211,
8,
5983,
29,
2913,
459,
5983,
1105,
398,
327,
3222,
652,
370,
314,
1654,
267,
862,
26,
288,
754,
275,
291,
14,
1258,
14,
1932,
8,
277,
14,
633,
12,
2073,
29,
2913,
63,
807,
12,
1595,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
gusai-francelabs/datafari
|
windows/python/Lib/site-packages/pip/_vendor/requests/packages/urllib3/packages/six.py
|
2375
|
11628
|
"""Utilities for writing code that runs on Python 2 and 3"""
#Copyright (c) 2010-2011 Benjamin Peterson
#Permission is hereby granted, free of charge, to any person obtaining a copy of
#this software and associated documentation files (the "Software"), to deal in
#the Software without restriction, including without limitation the rights to
#use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
#the Software, and to permit persons to whom the Software is furnished to do so,
#subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
#FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
#COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
#IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import operator
import sys
import types
__author__ = "Benjamin Peterson <benjamin@python.org>"
__version__ = "1.2.0" # Revision 41c74fef2ded
# True if we are running on Python 3.
PY3 = sys.version_info[0] == 3
if PY3:
string_types = str,
integer_types = int,
class_types = type,
text_type = str
binary_type = bytes
MAXSIZE = sys.maxsize
else:
string_types = basestring,
integer_types = (int, long)
class_types = (type, types.ClassType)
text_type = unicode
binary_type = str
if sys.platform.startswith("java"):
# Jython always uses 32 bits.
MAXSIZE = int((1 << 31) - 1)
else:
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
class X(object):
def __len__(self):
return 1 << 31
try:
len(X())
except OverflowError:
# 32-bit
MAXSIZE = int((1 << 31) - 1)
else:
# 64-bit
MAXSIZE = int((1 << 63) - 1)
del X
def _add_doc(func, doc):
"""Add documentation to a function."""
func.__doc__ = doc
def _import_module(name):
"""Import module, returning the module after the last dot."""
__import__(name)
return sys.modules[name]
class _LazyDescr(object):
def __init__(self, name):
self.name = name
def __get__(self, obj, tp):
result = self._resolve()
setattr(obj, self.name, result)
# This is a bit ugly, but it avoids running this again.
delattr(tp, self.name)
return result
class MovedModule(_LazyDescr):
def __init__(self, name, old, new=None):
super(MovedModule, self).__init__(name)
if PY3:
if new is None:
new = name
self.mod = new
else:
self.mod = old
def _resolve(self):
return _import_module(self.mod)
class MovedAttribute(_LazyDescr):
def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
super(MovedAttribute, self).__init__(name)
if PY3:
if new_mod is None:
new_mod = name
self.mod = new_mod
if new_attr is None:
if old_attr is None:
new_attr = name
else:
new_attr = old_attr
self.attr = new_attr
else:
self.mod = old_mod
if old_attr is None:
old_attr = name
self.attr = old_attr
def _resolve(self):
module = _import_module(self.mod)
return getattr(module, self.attr)
class _MovedItems(types.ModuleType):
"""Lazy loading of moved objects"""
_moved_attributes = [
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
MovedAttribute("reduce", "__builtin__", "functools"),
MovedAttribute("StringIO", "StringIO", "io"),
MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
MovedModule("builtins", "__builtin__"),
MovedModule("configparser", "ConfigParser"),
MovedModule("copyreg", "copy_reg"),
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
MovedModule("http_cookies", "Cookie", "http.cookies"),
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
MovedModule("html_parser", "HTMLParser", "html.parser"),
MovedModule("http_client", "httplib", "http.client"),
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
MovedModule("cPickle", "cPickle", "pickle"),
MovedModule("queue", "Queue"),
MovedModule("reprlib", "repr"),
MovedModule("socketserver", "SocketServer"),
MovedModule("tkinter", "Tkinter"),
MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
MovedModule("tkinter_colorchooser", "tkColorChooser",
"tkinter.colorchooser"),
MovedModule("tkinter_commondialog", "tkCommonDialog",
"tkinter.commondialog"),
MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
MovedModule("tkinter_font", "tkFont", "tkinter.font"),
MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
"tkinter.simpledialog"),
MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
MovedModule("winreg", "_winreg"),
]
for attr in _moved_attributes:
setattr(_MovedItems, attr.name, attr)
del attr
moves = sys.modules[__name__ + ".moves"] = _MovedItems("moves")
def add_move(move):
"""Add an item to six.moves."""
setattr(_MovedItems, move.name, move)
def remove_move(name):
"""Remove item from six.moves."""
try:
delattr(_MovedItems, name)
except AttributeError:
try:
del moves.__dict__[name]
except KeyError:
raise AttributeError("no such move, %r" % (name,))
if PY3:
_meth_func = "__func__"
_meth_self = "__self__"
_func_code = "__code__"
_func_defaults = "__defaults__"
_iterkeys = "keys"
_itervalues = "values"
_iteritems = "items"
else:
_meth_func = "im_func"
_meth_self = "im_self"
_func_code = "func_code"
_func_defaults = "func_defaults"
_iterkeys = "iterkeys"
_itervalues = "itervalues"
_iteritems = "iteritems"
try:
advance_iterator = next
except NameError:
def advance_iterator(it):
return it.next()
next = advance_iterator
if PY3:
def get_unbound_function(unbound):
return unbound
Iterator = object
def callable(obj):
return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
else:
def get_unbound_function(unbound):
return unbound.im_func
class Iterator(object):
def next(self):
return type(self).__next__(self)
callable = callable
_add_doc(get_unbound_function,
"""Get the function out of a possibly unbound function""")
get_method_function = operator.attrgetter(_meth_func)
get_method_self = operator.attrgetter(_meth_self)
get_function_code = operator.attrgetter(_func_code)
get_function_defaults = operator.attrgetter(_func_defaults)
def iterkeys(d):
"""Return an iterator over the keys of a dictionary."""
return iter(getattr(d, _iterkeys)())
def itervalues(d):
"""Return an iterator over the values of a dictionary."""
return iter(getattr(d, _itervalues)())
def iteritems(d):
"""Return an iterator over the (key, value) pairs of a dictionary."""
return iter(getattr(d, _iteritems)())
if PY3:
def b(s):
return s.encode("latin-1")
def u(s):
return s
if sys.version_info[1] <= 1:
def int2byte(i):
return bytes((i,))
else:
# This is about 2x faster than the implementation above on 3.2+
int2byte = operator.methodcaller("to_bytes", 1, "big")
import io
StringIO = io.StringIO
BytesIO = io.BytesIO
else:
def b(s):
return s
def u(s):
return unicode(s, "unicode_escape")
int2byte = chr
import StringIO
StringIO = BytesIO = StringIO.StringIO
_add_doc(b, """Byte literal""")
_add_doc(u, """Text literal""")
if PY3:
import builtins
exec_ = getattr(builtins, "exec")
def reraise(tp, value, tb=None):
if value.__traceback__ is not tb:
raise value.with_traceback(tb)
raise value
print_ = getattr(builtins, "print")
del builtins
else:
def exec_(code, globs=None, locs=None):
"""Execute code in a namespace."""
if globs is None:
frame = sys._getframe(1)
globs = frame.f_globals
if locs is None:
locs = frame.f_locals
del frame
elif locs is None:
locs = globs
exec("""exec code in globs, locs""")
exec_("""def reraise(tp, value, tb=None):
raise tp, value, tb
""")
def print_(*args, **kwargs):
"""The new-style print function."""
fp = kwargs.pop("file", sys.stdout)
if fp is None:
return
def write(data):
if not isinstance(data, basestring):
data = str(data)
fp.write(data)
want_unicode = False
sep = kwargs.pop("sep", None)
if sep is not None:
if isinstance(sep, unicode):
want_unicode = True
elif not isinstance(sep, str):
raise TypeError("sep must be None or a string")
end = kwargs.pop("end", None)
if end is not None:
if isinstance(end, unicode):
want_unicode = True
elif not isinstance(end, str):
raise TypeError("end must be None or a string")
if kwargs:
raise TypeError("invalid keyword arguments to print()")
if not want_unicode:
for arg in args:
if isinstance(arg, unicode):
want_unicode = True
break
if want_unicode:
newline = unicode("\n")
space = unicode(" ")
else:
newline = "\n"
space = " "
if sep is None:
sep = space
if end is None:
end = newline
for i, arg in enumerate(args):
if i:
write(sep)
write(arg)
write(end)
_add_doc(reraise, """Reraise an exception.""")
def with_metaclass(meta, base=object):
"""Create a base class with a metaclass."""
return meta("NewBase", (base,), {})
|
apache-2.0
|
[
624,
22905,
367,
3575,
1233,
626,
7858,
641,
2018,
499,
436,
650,
624,
199,
199,
3,
7384,
334,
67,
9,
7129,
13,
8128,
26844,
16997,
262,
22912,
834,
199,
199,
3,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
402,
199,
3,
3749,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
315,
199,
3,
1589,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
370,
199,
3,
1180,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
199,
3,
1589,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
199,
3,
5875,
370,
314,
2569,
3704,
26,
199,
199,
3,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
1006,
199,
3,
16847,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
3,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
3092,
199,
3,
2707,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
199,
3,
32324,
5716,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
199,
3,
568,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
199,
3,
18389,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
4141,
14,
199,
199,
646,
4182,
199,
646,
984,
199,
646,
2943,
199,
199,
363,
2502,
363,
275,
298,
31231,
16997,
262,
22912,
834,
665,
18486,
16997,
262,
32,
1548,
14,
1308,
4335,
199,
363,
1023,
363,
275,
298,
17,
14,
18,
14,
16,
2,
221,
327,
27095,
13385,
67,
1342,
32688,
18,
770,
421,
199,
3,
715,
340,
781,
787,
3879,
641,
2018,
650,
14,
199,
4521,
19,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
650,
199,
199,
692,
7843,
19,
26,
272,
1059,
63,
1313,
275,
620,
12,
272,
3000,
63,
1313,
275,
1109,
12,
272,
1021,
63,
1313,
275,
730,
12,
272,
1318,
63,
466,
275,
620,
272,
3366,
63,
466,
275,
2783,
339,
9141,
4305,
275,
984,
14,
13634,
199,
2836,
26,
272,
1059,
63,
1313,
275,
7116,
12,
272,
3000,
63,
1313,
275,
334,
442,
12,
1846,
9,
272,
1021,
63,
1313,
275,
334,
466,
12,
2943,
14,
31165,
9,
272,
1318,
63,
466,
275,
2649,
272,
3366,
63,
466,
275,
620,
339,
340,
984,
14,
3246,
14,
2460,
480,
6138,
2349,
267,
327,
25333,
3544,
4440,
4337,
5821,
14,
267,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
272,
587,
26,
267,
327,
2779,
1159,
3962,
370,
1172,
13855,
8,
2809,
9,
1137,
13855,
8,
2713,
63,
30104,
63,
84,
680,
267,
1021,
1323,
8,
785,
304,
288,
347,
636,
552,
721,
277,
304,
355,
372,
413,
5213,
7105,
267,
862,
26,
288,
822,
8,
56,
1012,
267,
871,
23870,
26,
288,
327,
4337,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
267,
587,
26,
288,
327,
5049,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
13668,
9,
446,
413,
9,
288,
2150,
1323,
421,
199,
318,
485,
525,
63,
1301,
8,
1532,
12,
1382,
304,
272,
408,
1123,
3794,
370,
282,
805,
1041,
272,
2562,
855,
1301,
363,
275,
1382,
421,
199,
318,
485,
646,
63,
578,
8,
354,
304,
272,
408,
6295,
859,
12,
8152,
314,
859,
2410,
314,
2061,
6308,
1041,
272,
636,
646,
721,
354,
9,
272,
372,
984,
14,
3112,
59,
354,
61,
421,
199,
533,
485,
14269,
28782,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
636,
362,
721,
277,
12,
1559,
12,
9253,
304,
267,
754,
275,
291,
423,
6983,
342,
267,
5371,
8,
1113,
12,
291,
14,
354,
12,
754,
9,
267,
327,
961,
365,
282,
4546,
23761,
12,
1325,
652,
23674,
3879,
642,
4020,
14,
267,
24358,
8,
683,
12,
291,
14,
354,
9,
267,
372,
754,
421,
199,
533,
11147,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
12,
892,
29,
403,
304,
267,
1613,
8,
20774,
2377,
12,
291,
2843,
826,
721,
354,
9,
267,
340,
7843,
19,
26,
288,
340,
892,
365,
488,
26,
355,
892,
275,
536,
288,
291,
14,
1494,
275,
892,
267,
587,
26,
288,
291,
14,
1494,
275,
2269,
339,
347,
485,
6983,
8,
277,
304,
267,
372,
485,
646,
63,
578,
8,
277,
14,
1494,
9,
421,
199,
533,
8863,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
63,
1494,
12,
892,
63,
1494,
12,
2269,
63,
962,
29,
403,
12,
892,
63,
962,
29,
403,
304,
267,
1613,
8,
20774,
1646,
12,
291,
2843,
826,
721,
354,
9,
267,
340,
7843,
19,
26,
288,
340,
892,
63,
1494,
365,
488,
26,
355,
892,
63,
1494,
275,
536,
288,
291,
14,
1494,
275,
892,
63,
1494,
288,
340,
892,
63,
962,
365,
488,
26,
355,
340,
2269,
63,
962,
365,
488,
26,
490,
892,
63,
962,
275,
536,
355,
587,
26,
490,
892,
63,
962,
275,
2269,
63,
962,
288,
291,
14,
962,
275,
892,
63,
962,
267,
587,
26,
288,
291,
14,
1494,
275,
2269,
63,
1494,
288,
340,
2269,
63,
962,
365,
488,
26,
355,
2269,
63,
962,
275,
536,
288,
291,
14,
962,
275,
2269,
63,
962,
339,
347,
485,
6983,
8,
277,
304,
267,
859,
275,
485,
646,
63,
578,
8,
277,
14,
1494,
9,
267,
372,
2519,
8,
578,
12,
291,
14,
962,
9,
4388,
199,
533,
485,
20774,
7412,
8,
1313,
14,
21820,
304,
272,
408,
14269,
8697,
402,
12155,
2251,
624,
421,
199,
63,
3539,
63,
2987,
275,
359,
272,
8863,
480,
67,
6424,
401,
298,
67,
6424,
401,
298,
2308,
401,
298,
6424,
1288,
272,
8863,
480,
1541,
401,
298,
17691,
401,
298,
10372,
401,
298,
73,
1541,
401,
298,
1541,
1288,
272,
8863,
480,
1210,
401,
4396,
5351,
13915,
298
] |
[
22905,
367,
3575,
1233,
626,
7858,
641,
2018,
499,
436,
650,
624,
199,
199,
3,
7384,
334,
67,
9,
7129,
13,
8128,
26844,
16997,
262,
22912,
834,
199,
199,
3,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
402,
199,
3,
3749,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
315,
199,
3,
1589,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
370,
199,
3,
1180,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
199,
3,
1589,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
199,
3,
5875,
370,
314,
2569,
3704,
26,
199,
199,
3,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
1006,
199,
3,
16847,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
3,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
3092,
199,
3,
2707,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
199,
3,
32324,
5716,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
199,
3,
568,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
199,
3,
18389,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
4141,
14,
199,
199,
646,
4182,
199,
646,
984,
199,
646,
2943,
199,
199,
363,
2502,
363,
275,
298,
31231,
16997,
262,
22912,
834,
665,
18486,
16997,
262,
32,
1548,
14,
1308,
4335,
199,
363,
1023,
363,
275,
298,
17,
14,
18,
14,
16,
2,
221,
327,
27095,
13385,
67,
1342,
32688,
18,
770,
421,
199,
3,
715,
340,
781,
787,
3879,
641,
2018,
650,
14,
199,
4521,
19,
275,
984,
14,
1023,
63,
815,
59,
16,
61,
508,
650,
199,
199,
692,
7843,
19,
26,
272,
1059,
63,
1313,
275,
620,
12,
272,
3000,
63,
1313,
275,
1109,
12,
272,
1021,
63,
1313,
275,
730,
12,
272,
1318,
63,
466,
275,
620,
272,
3366,
63,
466,
275,
2783,
339,
9141,
4305,
275,
984,
14,
13634,
199,
2836,
26,
272,
1059,
63,
1313,
275,
7116,
12,
272,
3000,
63,
1313,
275,
334,
442,
12,
1846,
9,
272,
1021,
63,
1313,
275,
334,
466,
12,
2943,
14,
31165,
9,
272,
1318,
63,
466,
275,
2649,
272,
3366,
63,
466,
275,
620,
339,
340,
984,
14,
3246,
14,
2460,
480,
6138,
2349,
267,
327,
25333,
3544,
4440,
4337,
5821,
14,
267,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
272,
587,
26,
267,
327,
2779,
1159,
3962,
370,
1172,
13855,
8,
2809,
9,
1137,
13855,
8,
2713,
63,
30104,
63,
84,
680,
267,
1021,
1323,
8,
785,
304,
288,
347,
636,
552,
721,
277,
304,
355,
372,
413,
5213,
7105,
267,
862,
26,
288,
822,
8,
56,
1012,
267,
871,
23870,
26,
288,
327,
4337,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
7105,
9,
446,
413,
9,
267,
587,
26,
288,
327,
5049,
13,
2075,
288,
9141,
4305,
275,
1109,
1332,
17,
5213,
13668,
9,
446,
413,
9,
288,
2150,
1323,
421,
199,
318,
485,
525,
63,
1301,
8,
1532,
12,
1382,
304,
272,
408,
1123,
3794,
370,
282,
805,
1041,
272,
2562,
855,
1301,
363,
275,
1382,
421,
199,
318,
485,
646,
63,
578,
8,
354,
304,
272,
408,
6295,
859,
12,
8152,
314,
859,
2410,
314,
2061,
6308,
1041,
272,
636,
646,
721,
354,
9,
272,
372,
984,
14,
3112,
59,
354,
61,
421,
199,
533,
485,
14269,
28782,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
536,
304,
267,
291,
14,
354,
275,
536,
339,
347,
636,
362,
721,
277,
12,
1559,
12,
9253,
304,
267,
754,
275,
291,
423,
6983,
342,
267,
5371,
8,
1113,
12,
291,
14,
354,
12,
754,
9,
267,
327,
961,
365,
282,
4546,
23761,
12,
1325,
652,
23674,
3879,
642,
4020,
14,
267,
24358,
8,
683,
12,
291,
14,
354,
9,
267,
372,
754,
421,
199,
533,
11147,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
12,
892,
29,
403,
304,
267,
1613,
8,
20774,
2377,
12,
291,
2843,
826,
721,
354,
9,
267,
340,
7843,
19,
26,
288,
340,
892,
365,
488,
26,
355,
892,
275,
536,
288,
291,
14,
1494,
275,
892,
267,
587,
26,
288,
291,
14,
1494,
275,
2269,
339,
347,
485,
6983,
8,
277,
304,
267,
372,
485,
646,
63,
578,
8,
277,
14,
1494,
9,
421,
199,
533,
8863,
1547,
14269,
28782,
304,
339,
347,
636,
826,
721,
277,
12,
536,
12,
2269,
63,
1494,
12,
892,
63,
1494,
12,
2269,
63,
962,
29,
403,
12,
892,
63,
962,
29,
403,
304,
267,
1613,
8,
20774,
1646,
12,
291,
2843,
826,
721,
354,
9,
267,
340,
7843,
19,
26,
288,
340,
892,
63,
1494,
365,
488,
26,
355,
892,
63,
1494,
275,
536,
288,
291,
14,
1494,
275,
892,
63,
1494,
288,
340,
892,
63,
962,
365,
488,
26,
355,
340,
2269,
63,
962,
365,
488,
26,
490,
892,
63,
962,
275,
536,
355,
587,
26,
490,
892,
63,
962,
275,
2269,
63,
962,
288,
291,
14,
962,
275,
892,
63,
962,
267,
587,
26,
288,
291,
14,
1494,
275,
2269,
63,
1494,
288,
340,
2269,
63,
962,
365,
488,
26,
355,
2269,
63,
962,
275,
536,
288,
291,
14,
962,
275,
2269,
63,
962,
339,
347,
485,
6983,
8,
277,
304,
267,
859,
275,
485,
646,
63,
578,
8,
277,
14,
1494,
9,
267,
372,
2519,
8,
578,
12,
291,
14,
962,
9,
4388,
199,
533,
485,
20774,
7412,
8,
1313,
14,
21820,
304,
272,
408,
14269,
8697,
402,
12155,
2251,
624,
421,
199,
63,
3539,
63,
2987,
275,
359,
272,
8863,
480,
67,
6424,
401,
298,
67,
6424,
401,
298,
2308,
401,
298,
6424,
1288,
272,
8863,
480,
1541,
401,
298,
17691,
401,
298,
10372,
401,
298,
73,
1541,
401,
298,
1541,
1288,
272,
8863,
480,
1210,
401,
4396,
5351,
13915,
298,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
kapilt/cloud-custodian
|
c7n/resources/s3.py
|
1
|
112011
|
# Copyright 2015-2017 Capital One Services, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""S3 Resource Manager
Filters:
The generic Values filters (jmespath) expression and Or filter are
available with all resources, including buckets, we include several
additonal bucket data (Tags, Replication, Acl, Policy) as keys within
a bucket representation.
Actions:
encrypt-keys
Scan all keys in a bucket and optionally encrypt them in place.
global-grants
Check bucket acls for global grants
encryption-policy
Attach an encryption required policy to a bucket, this will break
applications that are not using encryption, including aws log
delivery.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import functools
import json
import itertools
import logging
import math
import os
import time
import ssl
import six
from botocore.client import Config
from botocore.exceptions import ClientError
from collections import defaultdict
from concurrent.futures import as_completed
from dateutil.parser import parse as parse_date
try:
from urllib3.exceptions import SSLError
except ImportError:
from botocore.vendored.requests.packages.urllib3.exceptions import SSLError
from c7n.actions import (
ActionRegistry, BaseAction, PutMetric, RemovePolicyBase)
from c7n.exceptions import PolicyValidationError
from c7n.filters import (
FilterRegistry, Filter, CrossAccountAccessFilter, MetricsFilter,
ValueFilter)
from c7n.manager import resources
from c7n import query
from c7n.resources.securityhub import PostFinding
from c7n.tags import RemoveTag, Tag, TagActionFilter, TagDelayedAction
from c7n.utils import (
chunks, local_session, set_annotation, type_schema, filter_empty,
dumps, format_string_values, get_account_alias_from_sts)
log = logging.getLogger('custodian.s3')
filters = FilterRegistry('s3.filters')
actions = ActionRegistry('s3.actions')
filters.register('marked-for-op', TagActionFilter)
actions.register('put-metric', PutMetric)
MAX_COPY_SIZE = 1024 * 1024 * 1024 * 2
@resources.register('s3')
class S3(query.QueryResourceManager):
class resource_type(query.TypeInfo):
service = 's3'
arn_type = ''
enum_spec = ('list_buckets', 'Buckets[]', None)
detail_spec = ('list_objects', 'Bucket', 'Contents[]')
name = id = 'Name'
date = 'CreationDate'
dimension = 'BucketName'
config_type = 'AWS::S3::Bucket'
filter_registry = filters
action_registry = actions
def get_arns(self, resources):
return ["arn:aws:s3:::{}".format(r["Name"]) for r in resources]
def get_source(self, source_type):
if source_type == 'describe':
return DescribeS3(self)
elif source_type == 'config':
return ConfigS3(self)
else:
return super(S3, self).get_source(source_type)
@classmethod
def get_permissions(cls):
perms = ["s3:ListAllMyBuckets"]
perms.extend([n[-1] for n in S3_AUGMENT_TABLE])
return perms
class DescribeS3(query.DescribeSource):
def augment(self, buckets):
with self.manager.executor_factory(
max_workers=min((10, len(buckets) + 1))) as w:
results = w.map(
assemble_bucket,
zip(itertools.repeat(self.manager.session_factory), buckets))
results = list(filter(None, results))
return results
def get_resources(self, bucket_names):
return [{'Name': b} for b in bucket_names]
class ConfigS3(query.ConfigSource):
def get_query_params(self, query):
q = super(ConfigS3, self).get_query_params(query)
if 'expr' in q:
q['expr'] = q['expr'].replace('select ', 'select awsRegion, ')
return q
def load_resource(self, item):
resource = super(ConfigS3, self).load_resource(item)
cfg = item['supplementaryConfiguration']
# aka standard
if 'awsRegion' in item and item['awsRegion'] != 'us-east-1':
resource['Location'] = {'LocationConstraint': item['awsRegion']}
else:
resource['Location'] = {}
# owner is under acl per describe
resource.pop('Owner', None)
resource['CreationDate'] = parse_date(resource['CreationDate'])
for k, null_value in S3_CONFIG_SUPPLEMENT_NULL_MAP.items():
if cfg.get(k) == null_value:
continue
method = getattr(self, "handle_%s" % k, None)
if method is None:
raise ValueError("unhandled supplementary config %s", k)
continue
v = cfg[k]
if isinstance(cfg[k], six.string_types):
v = json.loads(cfg[k])
method(resource, v)
for el in S3_AUGMENT_TABLE:
if el[1] not in resource:
resource[el[1]] = el[2]
return resource
PERMISSION_MAP = {
'FullControl': 'FULL_CONTROL',
'Write': 'WRITE',
'WriteAcp': 'WRITE_ACP',
'Read': 'READ',
'ReadAcp': 'READ_ACP'}
GRANTEE_MAP = {
'AllUsers': "http://acs.amazonaws.com/groups/global/AllUsers",
'AuthenticatedUsers': "http://acs.amazonaws.com/groups/global/AuthenticatedUsers",
'LogDelivery': 'http://acs.amazonaws.com/groups/s3/LogDelivery'}
def handle_AccessControlList(self, resource, item_value):
# double serialized in config for some reason
if isinstance(item_value, six.string_types):
item_value = json.loads(item_value)
resource['Acl'] = {}
resource['Acl']['Owner'] = {'ID': item_value['owner']['id']}
if item_value['owner']['displayName']:
resource['Acl']['Owner']['DisplayName'] = item_value[
'owner']['displayName']
resource['Acl']['Grants'] = grants = []
for g in (item_value.get('grantList') or ()):
if 'id' not in g['grantee']:
assert g['grantee'] in self.GRANTEE_MAP, "unknown grantee %s" % g
rg = {'Type': 'Group', 'URI': self.GRANTEE_MAP[g['grantee']]}
else:
rg = {'ID': g['grantee']['id'], 'Type': 'CanonicalUser'}
if 'displayName' in g:
rg['DisplayName'] = g['displayName']
grants.append({
'Permission': self.PERMISSION_MAP[g['permission']],
'Grantee': rg,
})
def handle_BucketAccelerateConfiguration(self, resource, item_value):
# not currently auto-augmented by custodian
return
def handle_BucketLoggingConfiguration(self, resource, item_value):
if ('destinationBucketName' not in item_value or
item_value['destinationBucketName'] is None):
return {}
resource[u'Logging'] = {
'TargetBucket': item_value['destinationBucketName'],
'TargetPrefix': item_value['logFilePrefix']}
def handle_BucketLifecycleConfiguration(self, resource, item_value):
rules = []
for r in item_value.get('rules'):
rr = {}
rules.append(rr)
expiry = {}
for ek, ck in (
('Date', 'expirationDate'),
('ExpiredObjectDeleteMarker', 'expiredObjectDeleteMarker'),
('Days', 'expirationInDays')):
if ck in r and r[ck] and r[ck] != -1:
expiry[ek] = r[ck]
if expiry:
rr['Expiration'] = expiry
transitions = []
for t in (r.get('transitions') or ()):
tr = {}
for k in ('date', 'days', 'storageClass'):
if t[k]:
tr["%s%s" % (k[0].upper(), k[1:])] = t[k]
transitions.append(tr)
if transitions:
rr['Transitions'] = transitions
if r.get('abortIncompleteMultipartUpload'):
rr['AbortIncompleteMultipartUpload'] = {
'DaysAfterInitiation': r[
'abortIncompleteMultipartUpload']['daysAfterInitiation']}
if r.get('noncurrentVersionExpirationInDays'):
rr['NoncurrentVersionExpiration'] = {
'NoncurrentDays': r['noncurrentVersionExpirationInDays']}
nonc_transitions = []
for t in (r.get('noncurrentVersionTransitions') or ()):
nonc_transitions.append({
'NoncurrentDays': t['days'],
'StorageClass': t['storageClass']})
if nonc_transitions:
rr['NoncurrentVersionTransitions'] = nonc_transitions
rr['Status'] = r['status']
rr['ID'] = r['id']
if r.get('prefix'):
rr['Prefix'] = r['prefix']
if 'filter' not in r or not r['filter']:
continue
if r['filter']['predicate']:
rr['Filter'] = self.convertLifePredicate(r['filter']['predicate'])
resource['Lifecycle'] = {'Rules': rules}
def convertLifePredicate(self, p):
if p['type'] == 'LifecyclePrefixPredicate':
return {'Prefix': p['prefix']}
if p['type'] == 'LifecycleTagPredicate':
return {'Tags': [{'Key': p['tag']['key'], 'Value': p['tag']['value']}]}
if p['type'] == 'LifecycleAndOperator':
n = {}
for o in p['operands']:
ot = self.convertLifePredicate(o)
if 'Tags' in n and 'Tags' in ot:
n['Tags'].extend(ot['Tags'])
else:
n.update(ot)
return {'And': n}
raise ValueError("unknown predicate: %s" % p)
NotifyTypeMap = {
'QueueConfiguration': 'QueueConfigurations',
'LambdaConfiguration': 'LambdaFunctionConfigurations',
'CloudFunctionConfiguration': 'LambdaFunctionConfigurations',
'TopicConfiguration': 'TopicConfigurations'}
def handle_BucketNotificationConfiguration(self, resource, item_value):
d = {}
for nid, n in item_value['configurations'].items():
ninfo = {}
d.setdefault(self.NotifyTypeMap[n['type']], []).append(ninfo)
if n['type'] == 'QueueConfiguration':
ninfo['QueueArn'] = n['queueARN']
elif n['type'] == 'TopicConfiguration':
ninfo['TopicArn'] = n['topicARN']
elif n['type'] == 'LambdaConfiguration':
ninfo['LambdaFunctionArn'] = n['functionARN']
ninfo['Id'] = nid
ninfo['Events'] = n['events']
rules = []
if n['filter']:
for r in n['filter'].get('s3KeyFilter', {}).get('filterRules', []):
rules.append({'Name': r['name'], 'Value': r['value']})
if rules:
ninfo['Filter'] = {'Key': {'FilterRules': rules}}
resource['Notification'] = d
def handle_BucketReplicationConfiguration(self, resource, item_value):
d = {'Role': item_value['roleARN'], 'Rules': []}
for rid, r in item_value['rules'].items():
rule = {
'ID': rid,
'Status': r['status'],
'Prefix': r['prefix'],
'Destination': {
'Bucket': r['destinationConfig']['bucketARN']}
}
if r['destinationConfig']['storageClass']:
rule['Destination']['StorageClass'] = r['destinationConfig']['storageClass']
d['Rules'].append(rule)
resource['Replication'] = {'ReplicationConfiguration': d}
def handle_BucketPolicy(self, resource, item_value):
resource['Policy'] = item_value['policyText']
def handle_BucketTaggingConfiguration(self, resource, item_value):
resource['Tags'] = [
{"Key": k, "Value": v} for k, v in item_value['tagSets'][0]['tags'].items()]
def handle_BucketVersioningConfiguration(self, resource, item_value):
# Config defaults versioning to 'Off' for a null value
if item_value['status'] not in ('Enabled', 'Suspended'):
return
resource['Versioning'] = {'Status': item_value['status']}
if item_value['isMfaDeleteEnabled']:
resource['Versioning']['MFADelete'] = item_value[
'isMfaDeleteEnabled'].title()
def handle_BucketWebsiteConfiguration(self, resource, item_value):
website = {}
if item_value['indexDocumentSuffix']:
website['IndexDocument'] = {
'Suffix': item_value['indexDocumentSuffix']}
if item_value['errorDocument']:
website['ErrorDocument'] = {
'Key': item_value['errorDocument']}
if item_value['redirectAllRequestsTo']:
website['RedirectAllRequestsTo'] = {
'HostName': item_value['redirectAllRequestsTo']['hostName'],
'Protocol': item_value['redirectAllRequestsTo']['protocol']}
for r in item_value['routingRules']:
redirect = {}
rule = {'Redirect': redirect}
website.setdefault('RoutingRules', []).append(rule)
if 'condition' in r:
cond = {}
for ck, rk in (
('keyPrefixEquals', 'KeyPrefixEquals'),
('httpErrorCodeReturnedEquals',
'HttpErrorCodeReturnedEquals')):
if r['condition'][ck]:
cond[rk] = r['condition'][ck]
rule['Condition'] = cond
for ck, rk in (
('protocol', 'Protocol'),
('hostName', 'HostName'),
('replaceKeyPrefixWith', 'ReplaceKeyPrefixWith'),
('replaceKeyWith', 'ReplaceKeyWith'),
('httpRedirectCode', 'HttpRedirectCode')):
if r['redirect'][ck]:
redirect[rk] = r['redirect'][ck]
resource['Website'] = website
S3_CONFIG_SUPPLEMENT_NULL_MAP = {
'BucketLoggingConfiguration': u'{"destinationBucketName":null,"logFilePrefix":null}',
'BucketPolicy': u'{"policyText":null}',
'BucketVersioningConfiguration': u'{"status":"Off","isMfaDeleteEnabled":null}',
'BucketAccelerateConfiguration': u'{"status":null}',
'BucketNotificationConfiguration': u'{"configurations":{}}',
'BucketLifecycleConfiguration': None,
'AccessControlList': None,
'BucketTaggingConfiguration': None,
'BucketWebsiteConfiguration': None,
'BucketReplicationConfiguration': None
}
S3_AUGMENT_TABLE = (
('get_bucket_location', 'Location', {}, None, 's3:GetBucketLocation'),
('get_bucket_tagging', 'Tags', [], 'TagSet', 's3:GetBucketTagging'),
('get_bucket_policy', 'Policy', None, 'Policy', 's3:GetBucketPolicy'),
('get_bucket_acl', 'Acl', None, None, 's3:GetBucketAcl'),
('get_bucket_replication',
'Replication', None, None, 's3:GetReplicationConfiguration'),
('get_bucket_versioning', 'Versioning', None, None, 's3:GetBucketVersioning'),
('get_bucket_website', 'Website', None, None, 's3:GetBucketWebsite'),
('get_bucket_logging', 'Logging', None, 'LoggingEnabled', 's3:GetBucketLogging'),
('get_bucket_notification_configuration',
'Notification', None, None, 's3:GetBucketNotification'),
('get_bucket_lifecycle_configuration',
'Lifecycle', None, None, 's3:GetLifecycleConfiguration'),
# ('get_bucket_cors', 'Cors'),
)
def assemble_bucket(item):
"""Assemble a document representing all the config state around a bucket.
TODO: Refactor this, the logic here feels quite muddled.
"""
factory, b = item
s = factory()
c = s.client('s3')
# Bucket Location, Current Client Location, Default Location
b_location = c_location = location = "us-east-1"
methods = list(S3_AUGMENT_TABLE)
for minfo in methods:
m, k, default, select = minfo[:4]
try:
method = getattr(c, m)
v = method(Bucket=b['Name'])
v.pop('ResponseMetadata')
if select is not None and select in v:
v = v[select]
except (ssl.SSLError, SSLError) as e:
# Proxy issues? i assume
log.warning("Bucket ssl error %s: %s %s",
b['Name'], b.get('Location', 'unknown'),
e)
continue
except ClientError as e:
code = e.response['Error']['Code']
if code.startswith("NoSuch") or "NotFound" in code:
v = default
elif code == 'PermanentRedirect':
s = factory()
c = bucket_client(s, b)
# Requeue with the correct region given location constraint
methods.append((m, k, default, select))
continue
else:
log.warning(
"Bucket:%s unable to invoke method:%s error:%s ",
b['Name'], m, e.response['Error']['Message'])
# For auth failures, we don't bail out, continue processing if we can.
# Note this can lead to missing data, but in general is cleaner than
# failing hard, due to the common use of locked down s3 bucket policies
# that may cause issues fetching information across a fleet of buckets.
# This does mean s3 policies depending on augments should check denied
# methods annotation, generally though lacking get access to an augment means
# they won't have write access either.
# For other error types we raise and bail policy execution.
if e.response['Error']['Code'] == 'AccessDenied':
b.setdefault('c7n:DeniedMethods', []).append(m)
continue
raise
# As soon as we learn location (which generally works)
if k == 'Location' and v is not None:
b_location = v.get('LocationConstraint')
# Location == region for all cases but EU
# https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html
if b_location is None:
b_location = "us-east-1"
elif b_location == 'EU':
b_location = "eu-west-1"
v['LocationConstraint'] = 'eu-west-1'
if v and v != c_location:
c = s.client('s3', region_name=b_location)
elif c_location != location:
c = s.client('s3', region_name=location)
b[k] = v
return b
def bucket_client(session, b, kms=False):
region = get_region(b)
if kms:
# Need v4 signature for aws:kms crypto, else let the sdk decide
# based on region support.
config = Config(
signature_version='s3v4',
read_timeout=200, connect_timeout=120)
else:
config = Config(read_timeout=200, connect_timeout=120)
return session.client('s3', region_name=region, config=config)
def modify_bucket_tags(session_factory, buckets, add_tags=(), remove_tags=()):
for bucket in buckets:
client = bucket_client(local_session(session_factory), bucket)
# Bucket tags are set atomically for the set/document, we want
# to refetch against current to guard against any staleness in
# our cached representation across multiple policies or concurrent
# modifications.
if 'get_bucket_tagging' in bucket.get('c7n:DeniedMethods', []):
# avoid the additional API call if we already know that it's going
# to result in AccessDenied. The chances that the resource's perms
# would have changed between fetching the resource and acting on it
# here are pretty low-- so the check here should suffice.
log.warning(
"Unable to get new set of bucket tags needed to modify tags,"
"skipping tag action for bucket: %s" % bucket["Name"])
continue
try:
bucket['Tags'] = client.get_bucket_tagging(
Bucket=bucket['Name']).get('TagSet', [])
except ClientError as e:
if e.response['Error']['Code'] != 'NoSuchTagSet':
raise
bucket['Tags'] = []
new_tags = {t['Key']: t['Value'] for t in add_tags}
for t in bucket.get('Tags', ()):
if (t['Key'] not in new_tags and t['Key'] not in remove_tags):
new_tags[t['Key']] = t['Value']
tag_set = [{'Key': k, 'Value': v} for k, v in new_tags.items()]
try:
client.put_bucket_tagging(
Bucket=bucket['Name'], Tagging={'TagSet': tag_set})
except ClientError as e:
log.exception(
'Exception tagging bucket %s: %s', bucket['Name'], e)
continue
def get_region(b):
"""Tries to get the bucket region from Location.LocationConstraint
Special cases:
LocationConstraint EU defaults to eu-west-1
LocationConstraint null defaults to us-east-1
Args:
b (object): A bucket object
Returns:
string: an aws region string
"""
remap = {None: 'us-east-1', 'EU': 'eu-west-1'}
region = b.get('Location', {}).get('LocationConstraint')
return remap.get(region, region)
@filters.register('metrics')
class S3Metrics(MetricsFilter):
"""S3 CW Metrics need special handling for attribute/dimension
mismatch, and additional required dimension.
"""
def get_dimensions(self, resource):
dims = [{'Name': 'BucketName', 'Value': resource['Name']}]
if (self.data['name'] == 'NumberOfObjects' and
'dimensions' not in self.data):
dims.append(
{'Name': 'StorageType', 'Value': 'AllStorageTypes'})
return dims
@filters.register('cross-account')
class S3CrossAccountFilter(CrossAccountAccessFilter):
"""Filters cross-account access to S3 buckets
:example:
.. code-block:: yaml
policies:
- name: s3-acl
resource: s3
region: us-east-1
filters:
- type: cross-account
"""
permissions = ('s3:GetBucketPolicy',)
def get_accounts(self):
"""add in elb access by default
ELB Accounts by region
https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html
Redshift Accounts by region
https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#rs-db-auditing-cloud-trail-rs-acct-ids
Cloudtrail Accounts by region
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-supported-regions.html
"""
accounts = super(S3CrossAccountFilter, self).get_accounts()
return accounts.union(
[
# ELB accounts
'127311923021', # us-east-1
'033677994240', # us-east-2
'797873946194', # us-west-2
'027434742980', # us-west-1
'985666609251', # ca-central-1
'156460612806', # eu-west-1
'054676820928', # eu-central-1
'652711504416', # eu-west-2
'582318560864', # ap-northeast-1
'600734575887', # ap-northeast-2
'114774131450', # ap-southeast-1
'783225319266', # ap-southeast-2
'718504428378', # ap-south-1
'507241528517', # sa-east-1
'048591011584', # us-gov-west-1 or gov-cloud-1
'638102146993', # cn-north-1
# Redshift accounts
'368064434614', # us-east-1
'790247189693', # us-east-2
'703715109447', # us-east-1
'473191095985', # us-west-2
'408097707231', # ap-south-1
'713597048934', # ap-northeast-2
'960118270566', # ap-southeast-1
'485979073181', # ap-southeast-2
'615915377779', # ap-northeast-1
'764870610256', # ca-central-1
'434091160558', # eu-central-1
'246478207311', # eu-west-1
'885798887673', # eu-west-2
'392442076723', # sa-east-1
# Cloudtrail accounts (psa. folks should be using
# cloudtrail service in bucket policies)
'086441151436', # us-east-1
'475085895292', # us-west-2
'388731089494', # us-west-1
'113285607260', # us-west-2
'819402241893', # ca-central-1
'977081816279', # ap-south-1
'492519147666', # ap-northeast-2
'903692715234', # ap-southeast-1
'284668455005', # ap-southeast-2
'216624486486', # ap-northeast-1
'035351147821', # eu-central-1
'859597730677', # eu-west-1
'282025262664', # eu-west-2
'814480443879', # sa-east-1
])
@filters.register('global-grants')
class GlobalGrantsFilter(Filter):
"""Filters for all S3 buckets that have global-grants
*Note* by default this filter allows for read access
if the bucket has been configured as a website. This
can be disabled per the example below.
:example:
.. code-block:: yaml
policies:
- name: remove-global-grants
resource: s3
filters:
- type: global-grants
allow_website: false
actions:
- delete-global-grants
"""
schema = type_schema(
'global-grants',
allow_website={'type': 'boolean'},
operator={'type': 'string', 'enum': ['or', 'and']},
permissions={
'type': 'array', 'items': {
'type': 'string', 'enum': [
'READ', 'WRITE', 'WRITE_ACP', 'READ_ACP', 'FULL_CONTROL']}})
GLOBAL_ALL = "http://acs.amazonaws.com/groups/global/AllUsers"
AUTH_ALL = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
def process(self, buckets, event=None):
with self.executor_factory(max_workers=5) as w:
results = w.map(self.process_bucket, buckets)
results = list(filter(None, list(results)))
return results
def process_bucket(self, b):
acl = b.get('Acl', {'Grants': []})
if not acl or not acl['Grants']:
return
results = []
allow_website = self.data.get('allow_website', True)
perms = self.data.get('permissions', [])
for grant in acl['Grants']:
if 'URI' not in grant.get("Grantee", {}):
continue
if grant['Grantee']['URI'] not in [self.AUTH_ALL, self.GLOBAL_ALL]:
continue
if allow_website and grant['Permission'] == 'READ' and b['Website']:
continue
if not perms or (perms and grant['Permission'] in perms):
results.append(grant['Permission'])
if results:
set_annotation(b, 'GlobalPermissions', results)
return b
class BucketActionBase(BaseAction):
def get_permissions(self):
return self.permissions
def get_std_format_args(self, bucket):
return {
'account_id': self.manager.config.account_id,
'region': self.manager.config.region,
'bucket_name': bucket['Name'],
'bucket_region': get_region(bucket)
}
def process(self, buckets):
with self.executor_factory(max_workers=3) as w:
futures = {}
results = []
for b in buckets:
futures[w.submit(self.process_bucket, b)] = b
for f in as_completed(futures):
if f.exception():
self.log.error('error modifying bucket:%s\n%s',
b['Name'], f.exception())
results += filter(None, [f.result()])
return results
class BucketFilterBase(Filter):
def get_std_format_args(self, bucket):
return {
'account_id': self.manager.config.account_id,
'region': self.manager.config.region,
'bucket_name': bucket['Name'],
'bucket_region': get_region(bucket)
}
@S3.action_registry.register("post-finding")
class BucketFinding(PostFinding):
def format_resource(self, r):
owner = r.get("Acl", {}).get("Owner", {})
resource = {
"Type": "AwsS3Bucket",
"Id": "arn:aws:s3:::{}".format(r["Name"]),
"Region": get_region(r),
"Tags": {t["Key"]: t["Value"] for t in r.get("Tags", [])},
"Details": {"AwsS3Bucket": {"OwnerId": owner.get('ID', 'Unknown')}}
}
if "DisplayName" in owner:
resource["Details"]["AwsS3Bucket"]["OwnerName"] = owner['DisplayName']
return filter_empty(resource)
@filters.register('has-statement')
class HasStatementFilter(BucketFilterBase):
"""Find buckets with set of policy statements.
:example:
.. code-block:: yaml
policies:
- name: s3-bucket-has-statement
resource: s3
filters:
- type: has-statement
statement_ids:
- RequiredEncryptedPutObject
policies:
- name: s3-public-policy
resource: s3
filters:
- type: has-statement
statements:
- Effect: Allow
Action: 's3:*'
Principal: '*'
"""
schema = type_schema(
'has-statement',
statement_ids={'type': 'array', 'items': {'type': 'string'}},
statements={
'type': 'array',
'items': {
'type': 'object',
'properties': {
'Sid': {'type': 'string'},
'Effect': {'type': 'string', 'enum': ['Allow', 'Deny']},
'Principal': {'anyOf': [
{'type': 'string'},
{'type': 'object'}, {'type': 'array'}]},
'NotPrincipal': {
'anyOf': [{'type': 'object'}, {'type': 'array'}]},
'Action': {
'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'NotAction': {
'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'Resource': {
'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'NotResource': {
'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'Condition': {'type': 'object'}
},
'required': ['Effect']
}
})
def process(self, buckets, event=None):
return list(filter(None, map(self.process_bucket, buckets)))
def process_bucket(self, b):
p = b.get('Policy')
if p is None:
return None
p = json.loads(p)
required = list(self.data.get('statement_ids', []))
statements = p.get('Statement', [])
for s in list(statements):
if s.get('Sid') in required:
required.remove(s['Sid'])
required_statements = format_string_values(list(self.data.get('statements', [])),
**self.get_std_format_args(b))
for required_statement in required_statements:
for statement in statements:
found = 0
for key, value in required_statement.items():
if key in statement and value == statement[key]:
found += 1
if found and found == len(required_statement):
required_statements.remove(required_statement)
break
if (self.data.get('statement_ids', []) and not required) or \
(self.data.get('statements', []) and not required_statements):
return b
return None
ENCRYPTION_STATEMENT_GLOB = {
'Effect': 'Deny',
'Principal': '*',
'Action': 's3:PutObject',
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": ["AES256", "aws:kms"]}}}
@filters.register('no-encryption-statement')
class EncryptionEnabledFilter(Filter):
"""Find buckets with missing encryption policy statements.
:example:
.. code-block:: yaml
policies:
- name: s3-bucket-not-encrypted
resource: s3
filters:
- type: no-encryption-statement
"""
schema = type_schema(
'no-encryption-statement')
def get_permissions(self):
perms = self.manager.get_resource_manager('s3').get_permissions()
return perms
def process(self, buckets, event=None):
return list(filter(None, map(self.process_bucket, buckets)))
def process_bucket(self, b):
p = b.get('Policy')
if p is None:
return b
p = json.loads(p)
encryption_statement = dict(ENCRYPTION_STATEMENT_GLOB)
statements = p.get('Statement', [])
check = False
for s in list(statements):
if 'Sid' in s:
encryption_statement["Sid"] = s["Sid"]
if 'Resource' in s:
encryption_statement["Resource"] = s["Resource"]
if s == encryption_statement:
check = True
break
if check:
return None
else:
return b
@filters.register('missing-statement')
@filters.register('missing-policy-statement')
class MissingPolicyStatementFilter(Filter):
"""Find buckets missing a set of named policy statements.
:example:
.. code-block:: yaml
policies:
- name: s3-bucket-missing-statement
resource: s3
filters:
- type: missing-statement
statement_ids:
- RequiredEncryptedPutObject
"""
schema = type_schema(
'missing-policy-statement',
aliases=('missing-statement',),
statement_ids={'type': 'array', 'items': {'type': 'string'}})
def __call__(self, b):
p = b.get('Policy')
if p is None:
return b
p = json.loads(p)
required = list(self.data.get('statement_ids', []))
statements = p.get('Statement', [])
for s in list(statements):
if s.get('Sid') in required:
required.remove(s['Sid'])
if not required:
return False
return True
@filters.register('bucket-notification')
class BucketNotificationFilter(ValueFilter):
"""Filter based on bucket notification configuration.
:example:
.. code-block:: yaml
policies:
- name: delete-incorrect-notification
resource: s3
filters:
- type: bucket-notification
kind: lambda
key: Id
value: "IncorrectLambda"
op: eq
actions:
- type: delete-bucket-notification
statement_ids: matched
"""
schema = type_schema(
'bucket-notification',
required=['kind'],
kind={'type': 'string', 'enum': ['lambda', 'sns', 'sqs']},
rinherit=ValueFilter.schema)
schema_alias = False
annotation_key = 'c7n:MatchedNotificationConfigurationIds'
permissions = ('s3:GetBucketNotification',)
FIELDS = {
'lambda': 'LambdaFunctionConfigurations',
'sns': 'TopicConfigurations',
'sqs': 'QueueConfigurations'
}
def process(self, buckets, event=None):
return super(BucketNotificationFilter, self).process(buckets, event)
def __call__(self, bucket):
field = self.FIELDS[self.data['kind']]
found = False
for config in bucket.get('Notification', {}).get(field, []):
if self.match(config):
set_annotation(
bucket,
BucketNotificationFilter.annotation_key,
config['Id'])
found = True
return found
@filters.register('bucket-logging')
class BucketLoggingFilter(Filter):
"""Filter based on bucket logging configuration.
:example:
.. code-block:: yaml
policies:
- name: add-bucket-logging-if-missing
resource: s3
filters:
- type: bucket-logging
op: disabled
actions:
- type: toggle-logging
target_bucket: "{account_id}-{region}-s3-logs"
target_prefix: "{source_bucket_name}/"
policies:
- name: update-incorrect-or-missing-logging
resource: s3
filters:
- type: bucket-logging
op: not-equal
target_bucket: "{account_id}-{region}-s3-logs"
target_prefix: "{account}/{source_bucket_name}/"
actions:
- type: toggle-logging
target_bucket: "{account_id}-{region}-s3-logs"
target_prefix: "{account}/{source_bucket_name}/"
"""
schema = type_schema(
'bucket-logging',
op={'enum': ['enabled', 'disabled', 'equal', 'not-equal', 'eq', 'ne']},
required=['op'],
target_bucket={'type': 'string'},
target_prefix={'type': 'string'})
schema_alias = False
account_name = None
permissions = ("s3:GetBucketLogging", "iam:ListAccountAliases")
def process(self, buckets, event=None):
return list(filter(None, map(self.process_bucket, buckets)))
def process_bucket(self, b):
if self.match_bucket(b):
return b
def match_bucket(self, b):
op = self.data.get('op')
logging = b.get('Logging', {})
if op == 'disabled':
return logging == {}
elif op == 'enabled':
return logging != {}
if self.account_name is None:
session = local_session(self.manager.session_factory)
self.account_name = get_account_alias_from_sts(session)
variables = {
'account_id': self.manager.config.account_id,
'account': self.account_name,
'region': self.manager.config.region,
'source_bucket_name': b['Name'],
'target_bucket_name': self.data.get('target_bucket'),
'target_prefix': self.data.get('target_prefix'),
}
data = format_string_values(self.data, **variables)
target_bucket = data.get('target_bucket')
target_prefix = data.get('target_prefix', b['Name'] + '/')
target_config = {
"TargetBucket": target_bucket,
"TargetPrefix": target_prefix
} if target_bucket else {}
if op in ('not-equal', 'ne'):
return logging != target_config
else:
return logging == target_config
@actions.register('delete-bucket-notification')
class DeleteBucketNotification(BucketActionBase):
"""Action to delete S3 bucket notification configurations"""
schema = type_schema(
'delete-bucket-notification',
required=['statement_ids'],
statement_ids={'oneOf': [
{'enum': ['matched']},
{'type': 'array', 'items': {'type': 'string'}}]})
permissions = ('s3:PutBucketNotification',)
def process_bucket(self, bucket):
n = bucket['Notification']
if not n:
return
statement_ids = self.data.get('statement_ids')
if statement_ids == 'matched':
statement_ids = bucket.get(BucketNotificationFilter.annotation_key, ())
if not statement_ids:
return
cfg = defaultdict(list)
for t in six.itervalues(BucketNotificationFilter.FIELDS):
for c in n.get(t, []):
if c['Id'] not in statement_ids:
cfg[t].append(c)
client = bucket_client(local_session(self.manager.session_factory), bucket)
client.put_bucket_notification_configuration(
Bucket=bucket['Name'],
NotificationConfiguration=cfg)
@actions.register('no-op')
class NoOp(BucketActionBase):
schema = type_schema('no-op')
permissions = ('s3:ListAllMyBuckets',)
def process(self, buckets):
return None
@actions.register('set-statements')
class SetPolicyStatement(BucketActionBase):
"""Action to add or update policy statements to S3 buckets
:example:
.. code-block:: yaml
policies:
- name: force-s3-https
resource: s3
actions:
- type: set-statements
statements:
- Sid: "DenyHttp"
Effect: "Deny"
Action: "s3:GetObject"
Principal:
AWS: "*"
Resource: "arn:aws:s3:::{bucket_name}/*"
Condition:
Bool:
"aws:SecureTransport": false
"""
permissions = ('s3:PutBucketPolicy',)
schema = type_schema(
'set-statements',
**{
'statements': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'Sid': {'type': 'string'},
'Effect': {'type': 'string', 'enum': ['Allow', 'Deny']},
'Principal': {'anyOf': [{'type': 'string'},
{'type': 'object'}, {'type': 'array'}]},
'NotPrincipal': {'anyOf': [{'type': 'object'}, {'type': 'array'}]},
'Action': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'NotAction': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'Resource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'NotResource': {'anyOf': [{'type': 'string'}, {'type': 'array'}]},
'Condition': {'type': 'object'}
},
'required': ['Sid', 'Effect'],
'oneOf': [
{'required': ['Principal', 'Action', 'Resource']},
{'required': ['NotPrincipal', 'Action', 'Resource']},
{'required': ['Principal', 'NotAction', 'Resource']},
{'required': ['NotPrincipal', 'NotAction', 'Resource']},
{'required': ['Principal', 'Action', 'NotResource']},
{'required': ['NotPrincipal', 'Action', 'NotResource']},
{'required': ['Principal', 'NotAction', 'NotResource']},
{'required': ['NotPrincipal', 'NotAction', 'NotResource']}
]
}
}
}
)
def process_bucket(self, bucket):
policy = bucket.get('Policy') or '{}'
target_statements = format_string_values(
copy.deepcopy({s['Sid']: s for s in self.data.get('statements', [])}),
**self.get_std_format_args(bucket))
policy = json.loads(policy)
bucket_statements = policy.setdefault('Statement', [])
for s in bucket_statements:
if s.get('Sid') not in target_statements:
continue
if s == target_statements[s['Sid']]:
target_statements.pop(s['Sid'])
if not target_statements:
return
bucket_statements.extend(target_statements.values())
policy = json.dumps(policy)
s3 = bucket_client(local_session(self.manager.session_factory), bucket)
s3.put_bucket_policy(Bucket=bucket['Name'], Policy=policy)
return {'Name': bucket['Name'], 'Policy': policy}
@actions.register('remove-statements')
class RemovePolicyStatement(RemovePolicyBase):
"""Action to remove policy statements from S3 buckets
:example:
.. code-block:: yaml
policies:
- name: s3-remove-encrypt-put
resource: s3
filters:
- type: has-statement
statement_ids:
- RequireEncryptedPutObject
actions:
- type: remove-statements
statement_ids:
- RequiredEncryptedPutObject
"""
permissions = ("s3:PutBucketPolicy", "s3:DeleteBucketPolicy")
def process(self, buckets):
with self.executor_factory(max_workers=3) as w:
futures = {}
results = []
for b in buckets:
futures[w.submit(self.process_bucket, b)] = b
for f in as_completed(futures):
if f.exception():
b = futures[f]
self.log.error('error modifying bucket:%s\n%s',
b['Name'], f.exception())
results += filter(None, [f.result()])
return results
def process_bucket(self, bucket):
p = bucket.get('Policy')
if p is None:
return
p = json.loads(p)
statements, found = self.process_policy(
p, bucket, CrossAccountAccessFilter.annotation_key)
if not found:
return
s3 = bucket_client(local_session(self.manager.session_factory), bucket)
if not statements:
s3.delete_bucket_policy(Bucket=bucket['Name'])
else:
s3.put_bucket_policy(Bucket=bucket['Name'], Policy=json.dumps(p))
return {'Name': bucket['Name'], 'State': 'PolicyRemoved', 'Statements': found}
@actions.register('toggle-versioning')
class ToggleVersioning(BucketActionBase):
"""Action to enable/suspend versioning on a S3 bucket
Note versioning can never be disabled only suspended.
:example:
.. code-block:: yaml
policies:
- name: s3-enable-versioning
resource: s3
filters:
- or:
- type: value
key: Versioning.Status
value: Suspended
- type: value
key: Versioning.Status
value: absent
actions:
- type: toggle-versioning
enabled: true
"""
schema = type_schema(
'toggle-versioning',
enabled={'type': 'boolean'})
permissions = ("s3:PutBucketVersioning",)
def process_versioning(self, resource, state):
client = bucket_client(
local_session(self.manager.session_factory), resource)
try:
client.put_bucket_versioning(
Bucket=resource['Name'],
VersioningConfiguration={
'Status': state})
except ClientError as e:
if e.response['Error']['Code'] != 'AccessDenied':
log.error(
"Unable to put bucket versioning on bucket %s: %s" % resource['Name'], e)
raise
log.warning(
"Access Denied Bucket:%s while put bucket versioning" % resource['Name'])
# mfa delete enablement looks like it needs the serial and a current token.
def process(self, resources):
enabled = self.data.get('enabled', True)
for r in resources:
if 'Versioning' not in r or not r['Versioning']:
r['Versioning'] = {'Status': 'Suspended'}
if enabled and (
r['Versioning']['Status'] == 'Suspended'):
self.process_versioning(r, 'Enabled')
if not enabled and r['Versioning']['Status'] == 'Enabled':
self.process_versioning(r, 'Suspended')
@actions.register('toggle-logging')
class ToggleLogging(BucketActionBase):
"""Action to enable/disable logging on a S3 bucket.
Target bucket ACL must allow for WRITE and READ_ACP Permissions
Not specifying a target_prefix will default to the current bucket name.
https://docs.aws.amazon.com/AmazonS3/latest/dev/enable-logging-programming.html
:example:
.. code-block:: yaml
policies:
- name: s3-enable-logging
resource: s3
filters:
- "tag:Testing": present
actions:
- type: toggle-logging
target_bucket: log-bucket
target_prefix: logs123/
policies:
- name: s3-force-standard-logging
resource: s3
filters:
- type: bucket-logging
op: not-equal
target_bucket: "{account_id}-{region}-s3-logs"
target_prefix: "{account}/{source_bucket_name}/"
actions:
- type: toggle-logging
target_bucket: "{account_id}-{region}-s3-logs"
target_prefix: "{account}/{source_bucket_name}/"
"""
schema = type_schema(
'toggle-logging',
enabled={'type': 'boolean'},
target_bucket={'type': 'string'},
target_prefix={'type': 'string'})
permissions = ("s3:PutBucketLogging", "iam:ListAccountAliases")
def validate(self):
if self.data.get('enabled', True):
if not self.data.get('target_bucket'):
raise PolicyValidationError(
"target_bucket must be specified on %s" % (
self.manager.data,))
return self
def process(self, resources):
enabled = self.data.get('enabled', True)
# Account name for variable expansion
session = local_session(self.manager.session_factory)
account_name = get_account_alias_from_sts(session)
for r in resources:
client = bucket_client(session, r)
is_logging = bool(r.get('Logging'))
if enabled:
variables = {
'account_id': self.manager.config.account_id,
'account': account_name,
'region': self.manager.config.region,
'source_bucket_name': r['Name'],
'target_bucket_name': self.data.get('target_bucket'),
'target_prefix': self.data.get('target_prefix'),
}
data = format_string_values(self.data, **variables)
config = {
'TargetBucket': data.get('target_bucket'),
'TargetPrefix': data.get('target_prefix', r['Name'] + '/')
}
if not is_logging or r.get('Logging') != config:
client.put_bucket_logging(
Bucket=r['Name'],
BucketLoggingStatus={'LoggingEnabled': config}
)
elif not enabled and is_logging:
client.put_bucket_logging(
Bucket=r['Name'], BucketLoggingStatus={})
@actions.register('attach-encrypt')
class AttachLambdaEncrypt(BucketActionBase):
"""Action attaches lambda encryption policy to S3 bucket
supports attachment via lambda bucket notification or sns notification
to invoke lambda. a special topic value of `default` will utilize an
extant notification or create one matching the bucket name.
:example:
.. code-block:: yaml
policies:
- name: attach-lambda-encrypt
resource: s3
filters:
- type: missing-policy-statement
actions:
- type: attach-encrypt
role: arn:aws:iam::123456789012:role/my-role
"""
schema = type_schema(
'attach-encrypt',
role={'type': 'string'},
tags={'type': 'object'},
topic={'type': 'string'})
permissions = (
"s3:PutBucketNotification", "s3:GetBucketNotification",
# lambda manager uses quite a few perms to provision lambdas
# and event sources, hard to disamgibuate punt for now.
"lambda:*",
)
def __init__(self, data=None, manager=None):
self.data = data or {}
self.manager = manager
def validate(self):
if (not getattr(self.manager.config, 'dryrun', True) and
not self.data.get('role', self.manager.config.assume_role)):
raise PolicyValidationError(
"attach-encrypt: role must be specified either "
"via assume or in config on %s" % (self.manager.data,))
return self
def process(self, buckets):
from c7n.mu import LambdaManager
from c7n.ufuncs.s3crypt import get_function
account_id = self.manager.config.account_id
topic_arn = self.data.get('topic')
func = get_function(
None, self.data.get('role', self.manager.config.assume_role),
account_id=account_id, tags=self.data.get('tags'))
regions = set([get_region(b) for b in buckets])
# session managers by region
region_sessions = {}
for r in regions:
region_sessions[r] = functools.partial(
self.manager.session_factory, region=r)
# Publish function to all of our buckets regions
region_funcs = {}
for r in regions:
lambda_mgr = LambdaManager(region_sessions[r])
lambda_mgr.publish(func)
region_funcs[r] = func
with self.executor_factory(max_workers=3) as w:
results = []
futures = []
for b in buckets:
region = get_region(b)
futures.append(
w.submit(
self.process_bucket,
region_funcs[region],
b,
topic_arn,
account_id,
region_sessions[region]
))
for f in as_completed(futures):
if f.exception():
log.exception(
"Error attaching lambda-encrypt %s" % (f.exception()))
results.append(f.result())
return list(filter(None, results))
def process_bucket(self, func, bucket, topic, account_id, session_factory):
from c7n.mu import BucketSNSNotification, BucketLambdaNotification
if topic:
topic = None if topic == 'default' else topic
source = BucketSNSNotification(session_factory, bucket, topic)
else:
source = BucketLambdaNotification(
{'account_s3': account_id}, session_factory, bucket)
return source.add(func)
@actions.register('encryption-policy')
class EncryptionRequiredPolicy(BucketActionBase):
"""Action to apply an encryption policy to S3 buckets
:example:
.. code-block:: yaml
policies:
- name: s3-enforce-encryption
resource: s3
mode:
type: cloudtrail
events:
- CreateBucket
actions:
- encryption-policy
"""
permissions = ("s3:GetBucketPolicy", "s3:PutBucketPolicy")
schema = type_schema('encryption-policy')
def __init__(self, data=None, manager=None):
self.data = data or {}
self.manager = manager
def process(self, buckets):
with self.executor_factory(max_workers=3) as w:
results = w.map(self.process_bucket, buckets)
results = list(filter(None, list(results)))
return results
def process_bucket(self, b):
p = b['Policy']
if p is None:
log.info("No policy found, creating new")
p = {'Version': "2012-10-17", "Statement": []}
else:
p = json.loads(p)
encryption_sid = "RequiredEncryptedPutObject"
encryption_statement = {
'Sid': encryption_sid,
'Effect': 'Deny',
'Principal': '*',
'Action': 's3:PutObject',
"Resource": "arn:aws:s3:::%s/*" % b['Name'],
"Condition": {
# AWS Managed Keys or KMS keys, note policy language
# does not support custom kms (todo add issue)
"StringNotEquals": {
"s3:x-amz-server-side-encryption": ["AES256", "aws:kms"]}}}
statements = p.get('Statement', [])
for s in list(statements):
if s.get('Sid', '') == encryption_sid:
log.debug("Bucket:%s Found extant encrypt policy", b['Name'])
if s != encryption_statement:
log.info(
"Bucket:%s updating extant encrypt policy", b['Name'])
statements.remove(s)
else:
return
session = self.manager.session_factory()
s3 = bucket_client(session, b)
statements.append(encryption_statement)
p['Statement'] = statements
log.info('Bucket:%s attached encryption policy' % b['Name'])
try:
s3.put_bucket_policy(
Bucket=b['Name'],
Policy=json.dumps(p))
except ClientError as e:
if e.response['Error']['Code'] == 'NoSuchBucket':
return
self.log.exception(
"Error on bucket:%s putting policy\n%s error:%s",
b['Name'],
json.dumps(statements, indent=2), e)
raise
return {'Name': b['Name'], 'State': 'PolicyAttached'}
class BucketScanLog(object):
"""Offload remediated key ids to a disk file in batches
A bucket keyspace is effectively infinite, we need to store partial
results out of memory, this class provides for a json log on disk
with partial write support.
json output format:
- [list_of_serialized_keys],
- [] # Empty list of keys at end when we close the buffer
"""
def __init__(self, log_dir, name):
self.log_dir = log_dir
self.name = name
self.fh = None
self.count = 0
@property
def path(self):
return os.path.join(self.log_dir, "%s.json" % self.name)
def __enter__(self):
# Don't require output directories
if self.log_dir is None:
return
self.fh = open(self.path, 'w')
self.fh.write("[\n")
return self
def __exit__(self, exc_type=None, exc_value=None, exc_frame=None):
if self.fh is None:
return
# we need an empty marker list at end to avoid trailing commas
self.fh.write("[]")
# and close the surrounding list
self.fh.write("\n]")
self.fh.close()
if not self.count:
os.remove(self.fh.name)
self.fh = None
return False
def add(self, keys):
self.count += len(keys)
if self.fh is None:
return
self.fh.write(dumps(keys))
self.fh.write(",\n")
class ScanBucket(BucketActionBase):
permissions = ("s3:ListBucket",)
bucket_ops = {
'standard': {
'iterator': 'list_objects',
'contents_key': ['Contents'],
'key_processor': 'process_key'
},
'versioned': {
'iterator': 'list_object_versions',
'contents_key': ['Versions'],
'key_processor': 'process_version'
}
}
def __init__(self, data, manager=None):
super(ScanBucket, self).__init__(data, manager)
self.denied_buckets = set()
def get_bucket_style(self, b):
return (
b.get('Versioning', {'Status': ''}).get('Status') in (
'Enabled', 'Suspended') and 'versioned' or 'standard')
def get_bucket_op(self, b, op_name):
bucket_style = self.get_bucket_style(b)
op = self.bucket_ops[bucket_style][op_name]
if op_name == 'key_processor':
return getattr(self, op)
return op
def get_keys(self, b, key_set):
content_keys = self.get_bucket_op(b, 'contents_key')
keys = []
for ck in content_keys:
keys.extend(key_set.get(ck, []))
return keys
def process(self, buckets):
results = self._process_with_futures(self.process_bucket, buckets)
self.write_denied_buckets_file()
return results
def _process_with_futures(self, helper, buckets, max_workers=3):
results = []
with self.executor_factory(max_workers) as w:
futures = {}
for b in buckets:
futures[w.submit(helper, b)] = b
for f in as_completed(futures):
if f.exception():
b = futures[f]
self.log.error(
"Error on bucket:%s region:%s policy:%s error: %s",
b['Name'], b.get('Location', 'unknown'),
self.manager.data.get('name'), f.exception())
self.denied_buckets.add(b['Name'])
continue
result = f.result()
if result:
results.append(result)
return results
def write_denied_buckets_file(self):
if self.denied_buckets and self.manager.ctx.log_dir:
with open(
os.path.join(
self.manager.ctx.log_dir, 'denied.json'), 'w') as fh:
json.dump(list(self.denied_buckets), fh, indent=2)
self.denied_buckets = set()
def process_bucket(self, b):
log.info(
"Scanning bucket:%s visitor:%s style:%s" % (
b['Name'], self.__class__.__name__, self.get_bucket_style(b)))
s = self.manager.session_factory()
s3 = bucket_client(s, b)
# The bulk of _process_bucket function executes inline in
# calling thread/worker context, neither paginator nor
# bucketscan log should be used across worker boundary.
p = s3.get_paginator(
self.get_bucket_op(b, 'iterator')).paginate(Bucket=b['Name'])
with BucketScanLog(self.manager.ctx.log_dir, b['Name']) as key_log:
with self.executor_factory(max_workers=10) as w:
try:
return self._process_bucket(b, p, key_log, w)
except ClientError as e:
if e.response['Error']['Code'] == 'NoSuchBucket':
log.warning(
"Bucket:%s removed while scanning" % b['Name'])
return
if e.response['Error']['Code'] == 'AccessDenied':
log.warning(
"Access Denied Bucket:%s while scanning" % b['Name'])
self.denied_buckets.add(b['Name'])
return
log.exception(
"Error processing bucket:%s paginator:%s" % (
b['Name'], p))
__call__ = process_bucket
def _process_bucket(self, b, p, key_log, w):
count = 0
for key_set in p:
keys = self.get_keys(b, key_set)
count += len(keys)
futures = []
for batch in chunks(keys, size=100):
if not batch:
continue
futures.append(w.submit(self.process_chunk, batch, b))
for f in as_completed(futures):
if f.exception():
log.exception("Exception Processing bucket:%s key batch %s" % (
b['Name'], f.exception()))
continue
r = f.result()
if r:
key_log.add(r)
# Log completion at info level, progress at debug level
if key_set['IsTruncated']:
log.debug('Scan progress bucket:%s keys:%d remediated:%d ...',
b['Name'], count, key_log.count)
else:
log.info('Scan Complete bucket:%s keys:%d remediated:%d',
b['Name'], count, key_log.count)
b['KeyScanCount'] = count
b['KeyRemediated'] = key_log.count
return {
'Bucket': b['Name'], 'Remediated': key_log.count, 'Count': count}
def process_chunk(self, batch, bucket):
raise NotImplementedError()
def process_key(self, s3, key, bucket_name, info=None):
raise NotImplementedError()
def process_version(self, s3, bucket, key):
raise NotImplementedError()
@actions.register('encrypt-keys')
class EncryptExtantKeys(ScanBucket):
"""Action to encrypt unencrypted S3 objects
:example:
.. code-block:: yaml
policies:
- name: s3-encrypt-objects
resource: s3
actions:
- type: encrypt-keys
crypto: aws:kms
key-id: 9c3983be-c6cf-11e6-9d9d-cec0c932ce01
"""
permissions = (
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObjectVersion",
"s3:RestoreObject",
) + ScanBucket.permissions
schema = {
'type': 'object',
'additionalProperties': False,
'properties': {
'type': {'enum': ['encrypt-keys']},
'report-only': {'type': 'boolean'},
'glacier': {'type': 'boolean'},
'large': {'type': 'boolean'},
'crypto': {'enum': ['AES256', 'aws:kms']},
'key-id': {'type': 'string'}
},
'dependencies': {
'key-id': {
'properties': {
'crypto': {'pattern': 'aws:kms'}
},
'required': ['crypto']
}
}
}
metrics = [
('Total Keys', {'Scope': 'Account'}),
('Unencrypted', {'Scope': 'Account'})]
def __init__(self, data, manager=None):
super(EncryptExtantKeys, self).__init__(data, manager)
self.kms_id = self.data.get('key-id')
def get_permissions(self):
perms = ("s3:GetObject", "s3:GetObjectVersion")
if self.data.get('report-only'):
perms += ('s3:DeleteObject', 's3:DeleteObjectVersion',
's3:PutObject',
's3:AbortMultipartUpload',
's3:ListBucket',
's3:ListBucketVersions')
return perms
def process(self, buckets):
t = time.time()
results = super(EncryptExtantKeys, self).process(buckets)
run_time = time.time() - t
remediated_count = object_count = 0
for r in results:
object_count += r['Count']
remediated_count += r['Remediated']
self.manager.ctx.metrics.put_metric(
"Unencrypted", r['Remediated'], "Count", Scope=r['Bucket'],
buffer=True)
self.manager.ctx.metrics.put_metric(
"Unencrypted", remediated_count, "Count", Scope="Account",
buffer=True
)
self.manager.ctx.metrics.put_metric(
"Total Keys", object_count, "Count", Scope="Account",
buffer=True
)
self.manager.ctx.metrics.flush()
log.info(
("EncryptExtant Complete keys:%d "
"remediated:%d rate:%0.2f/s time:%0.2fs"),
object_count,
remediated_count,
float(object_count) / run_time if run_time else 0,
run_time)
return results
def process_chunk(self, batch, bucket):
crypto_method = self.data.get('crypto', 'AES256')
s3 = bucket_client(
local_session(self.manager.session_factory), bucket,
kms=(crypto_method == 'aws:kms'))
b = bucket['Name']
results = []
key_processor = self.get_bucket_op(bucket, 'key_processor')
for key in batch:
r = key_processor(s3, key, b)
if r:
results.append(r)
return results
def process_key(self, s3, key, bucket_name, info=None):
k = key['Key']
if info is None:
info = s3.head_object(Bucket=bucket_name, Key=k)
# If the data is already encrypted with AES256 and this request is also
# for AES256 then we don't need to do anything
if info.get('ServerSideEncryption') == 'AES256' and not self.kms_id:
return False
if info.get('ServerSideEncryption') == 'aws:kms':
# If we're not looking for a specific key any key will do.
if not self.kms_id:
return False
# If we're configured to use a specific key and the key matches
# note this is not a strict equality match.
if self.kms_id in info.get('SSEKMSKeyId', ''):
return False
if self.data.get('report-only'):
return k
storage_class = info.get('StorageClass', 'STANDARD')
if storage_class == 'GLACIER':
if not self.data.get('glacier'):
return False
if 'Restore' not in info:
# This takes multiple hours, we let the next c7n
# run take care of followups.
s3.restore_object(
Bucket=bucket_name,
Key=k,
RestoreRequest={'Days': 30})
return False
elif not restore_complete(info['Restore']):
return False
storage_class = 'STANDARD'
crypto_method = self.data.get('crypto', 'AES256')
key_id = self.data.get('key-id')
# Note on copy we lose individual object acl grants
params = {'Bucket': bucket_name,
'Key': k,
'CopySource': "/%s/%s" % (bucket_name, k),
'MetadataDirective': 'COPY',
'StorageClass': storage_class,
'ServerSideEncryption': crypto_method}
if key_id and crypto_method == 'aws:kms':
params['SSEKMSKeyId'] = key_id
if info['ContentLength'] > MAX_COPY_SIZE and self.data.get(
'large', True):
return self.process_large_file(s3, bucket_name, key, info, params)
s3.copy_object(**params)
return k
def process_version(self, s3, key, bucket_name):
info = s3.head_object(
Bucket=bucket_name,
Key=key['Key'],
VersionId=key['VersionId'])
if 'ServerSideEncryption' in info:
return False
if self.data.get('report-only'):
return key['Key'], key['VersionId']
if key['IsLatest']:
r = self.process_key(s3, key, bucket_name, info)
# Glacier request processing, wait till we have the restored object
if not r:
return r
s3.delete_object(
Bucket=bucket_name,
Key=key['Key'],
VersionId=key['VersionId'])
return key['Key'], key['VersionId']
def process_large_file(self, s3, bucket_name, key, info, params):
"""For objects over 5gb, use multipart upload to copy"""
part_size = MAX_COPY_SIZE - (1024 ** 2)
num_parts = int(math.ceil(info['ContentLength'] / part_size))
source = params.pop('CopySource')
params.pop('MetadataDirective')
if 'Metadata' in info:
params['Metadata'] = info['Metadata']
upload_id = s3.create_multipart_upload(**params)['UploadId']
params = {'Bucket': bucket_name,
'Key': key['Key'],
'UploadId': upload_id,
'CopySource': source,
'CopySourceIfMatch': info['ETag']}
def upload_part(part_num):
part_params = dict(params)
part_params['CopySourceRange'] = "bytes=%d-%d" % (
part_size * (part_num - 1),
min(part_size * part_num - 1, info['ContentLength'] - 1))
part_params['PartNumber'] = part_num
response = s3.upload_part_copy(**part_params)
return {'ETag': response['CopyPartResult']['ETag'],
'PartNumber': part_num}
try:
with self.executor_factory(max_workers=2) as w:
parts = list(w.map(upload_part, range(1, num_parts + 1)))
except Exception:
log.warning(
"Error during large key copy bucket: %s key: %s, "
"aborting upload", bucket_name, key, exc_info=True)
s3.abort_multipart_upload(
Bucket=bucket_name, Key=key['Key'], UploadId=upload_id)
raise
s3.complete_multipart_upload(
Bucket=bucket_name, Key=key['Key'], UploadId=upload_id,
MultipartUpload={'Parts': parts})
return key['Key']
def restore_complete(restore):
if ',' in restore:
ongoing, avail = restore.split(',', 1)
else:
ongoing = restore
return 'false' in ongoing
@filters.register('is-log-target')
class LogTarget(Filter):
"""Filter and return buckets are log destinations.
Not suitable for use in lambda on large accounts, This is a api
heavy process to detect scan all possible log sources.
Sources:
- elb (Access Log)
- s3 (Access Log)
- cfn (Template writes)
- cloudtrail
:example:
.. code-block:: yaml
policies:
- name: s3-log-bucket
resource: s3
filters:
- type: is-log-target
"""
schema = type_schema(
'is-log-target',
services={'type': 'array', 'items': {'enum': [
's3', 'elb', 'cloudtrail']}},
self={'type': 'boolean'},
value={'type': 'boolean'})
def get_permissions(self):
perms = self.manager.get_resource_manager('elb').get_permissions()
perms += ('elasticloadbalancing:DescribeLoadBalancerAttributes',)
return perms
def process(self, buckets, event=None):
log_buckets = set()
count = 0
services = self.data.get('services', ['elb', 's3', 'cloudtrail'])
self_log = self.data.get('self', False)
if 'elb' in services and not self_log:
for bucket, _ in self.get_elb_bucket_locations():
log_buckets.add(bucket)
count += 1
self.log.debug("Found %d elb log targets" % count)
if 's3' in services:
count = 0
for bucket, _ in self.get_s3_bucket_locations(buckets, self_log):
count += 1
log_buckets.add(bucket)
self.log.debug('Found %d s3 log targets' % count)
if 'cloudtrail' in services and not self_log:
for bucket, _ in self.get_cloud_trail_locations(buckets):
log_buckets.add(bucket)
self.log.info("Found %d log targets for %d buckets" % (
len(log_buckets), len(buckets)))
if self.data.get('value', True):
return [b for b in buckets if b['Name'] in log_buckets]
else:
return [b for b in buckets if b['Name'] not in log_buckets]
@staticmethod
def get_s3_bucket_locations(buckets, self_log=False):
"""return (bucket_name, prefix) for all s3 logging targets"""
for b in buckets:
if b.get('Logging'):
if self_log:
if b['Name'] != b['Logging']['TargetBucket']:
continue
yield (b['Logging']['TargetBucket'],
b['Logging']['TargetPrefix'])
if not self_log and b['Name'].startswith('cf-templates-'):
yield (b['Name'], '')
def get_cloud_trail_locations(self, buckets):
session = local_session(self.manager.session_factory)
client = session.client('cloudtrail')
names = set([b['Name'] for b in buckets])
for t in client.describe_trails().get('trailList', ()):
if t.get('S3BucketName') in names:
yield (t['S3BucketName'], t.get('S3KeyPrefix', ''))
def get_elb_bucket_locations(self):
elbs = self.manager.get_resource_manager('elb').resources()
get_elb_attrs = functools.partial(
_query_elb_attrs, self.manager.session_factory)
with self.executor_factory(max_workers=2) as w:
futures = []
for elb_set in chunks(elbs, 100):
futures.append(w.submit(get_elb_attrs, elb_set))
for f in as_completed(futures):
if f.exception():
log.error("Error while scanning elb log targets: %s" % (
f.exception()))
continue
for tgt in f.result():
yield tgt
def _query_elb_attrs(session_factory, elb_set):
session = local_session(session_factory)
client = session.client('elb')
log_targets = []
for e in elb_set:
try:
attrs = client.describe_load_balancer_attributes(
LoadBalancerName=e['LoadBalancerName'])[
'LoadBalancerAttributes']
if 'AccessLog' in attrs and attrs['AccessLog']['Enabled']:
log_targets.append((
attrs['AccessLog']['S3BucketName'],
attrs['AccessLog']['S3BucketPrefix']))
except Exception as err:
log.warning(
"Could not retrieve load balancer %s: %s" % (
e['LoadBalancerName'], err))
return log_targets
@actions.register('remove-website-hosting')
class RemoveWebsiteHosting(BucketActionBase):
"""Action that removes website hosting configuration."""
schema = type_schema('remove-website-hosting')
permissions = ('s3:DeleteBucketWebsite',)
def process(self, buckets):
session = local_session(self.manager.session_factory)
for bucket in buckets:
client = bucket_client(session, bucket)
client.delete_bucket_website(Bucket=bucket['Name'])
@actions.register('delete-global-grants')
class DeleteGlobalGrants(BucketActionBase):
"""Deletes global grants associated to a S3 bucket
:example:
.. code-block:: yaml
policies:
- name: s3-delete-global-grants
resource: s3
filters:
- type: global-grants
actions:
- delete-global-grants
"""
schema = type_schema(
'delete-global-grants',
grantees={'type': 'array', 'items': {'type': 'string'}})
permissions = ('s3:PutBucketAcl',)
def process(self, buckets):
with self.executor_factory(max_workers=5) as w:
return list(filter(None, list(w.map(self.process_bucket, buckets))))
def process_bucket(self, b):
grantees = self.data.get(
'grantees', [
GlobalGrantsFilter.AUTH_ALL, GlobalGrantsFilter.GLOBAL_ALL])
log.info(b)
acl = b.get('Acl', {'Grants': []})
if not acl or not acl['Grants']:
return
new_grants = []
for grant in acl['Grants']:
grantee = grant.get('Grantee', {})
if not grantee:
continue
# Yuck, 'get_bucket_acl' doesn't return the grantee type.
if 'URI' in grantee:
grantee['Type'] = 'Group'
else:
grantee['Type'] = 'CanonicalUser'
if ('URI' in grantee and
grantee['URI'] in grantees and not
(grant['Permission'] == 'READ' and b['Website'])):
# Remove this grantee.
pass
else:
new_grants.append(grant)
log.info({'Owner': acl['Owner'], 'Grants': new_grants})
c = bucket_client(self.manager.session_factory(), b)
try:
c.put_bucket_acl(
Bucket=b['Name'],
AccessControlPolicy={
'Owner': acl['Owner'], 'Grants': new_grants})
except ClientError as e:
if e.response['Error']['Code'] == 'NoSuchBucket':
return
return b
@actions.register('tag')
class BucketTag(Tag):
"""Action to create tags on a S3 bucket
:example:
.. code-block:: yaml
policies:
- name: s3-tag-region
resource: s3
region: us-east-1
filters:
- "tag:RegionName": absent
actions:
- type: tag
key: RegionName
value: us-east-1
"""
def process_resource_set(self, client, resource_set, tags):
modify_bucket_tags(self.manager.session_factory, resource_set, tags)
@actions.register('mark-for-op')
class MarkBucketForOp(TagDelayedAction):
"""Action schedules custodian to perform an action at a certain date
:example:
.. code-block:: yaml
policies:
- name: s3-encrypt
resource: s3
filters:
- type: missing-statement
statement_ids:
- RequiredEncryptedPutObject
actions:
- type: mark-for-op
op: attach-encrypt
days: 7
"""
schema = type_schema(
'mark-for-op', rinherit=TagDelayedAction.schema)
@actions.register('unmark')
@actions.register('remove-tag')
class RemoveBucketTag(RemoveTag):
"""Removes tag/tags from a S3 object
:example:
.. code-block:: yaml
policies:
- name: s3-remove-owner-tag
resource: s3
filters:
- "tag:BucketOwner": present
actions:
- type: remove-tag
tags: ['BucketOwner']
"""
def process_resource_set(self, client, resource_set, tags):
modify_bucket_tags(
self.manager.session_factory, resource_set, remove_tags=tags)
@filters.register('data-events')
class DataEvents(Filter):
schema = type_schema('data-events', state={'enum': ['present', 'absent']})
permissions = (
'cloudtrail:DescribeTrails',
'cloudtrail:GetEventSelectors')
def get_event_buckets(self, session, trails):
"""Return a mapping of bucket name to cloudtrail.
For wildcard trails the bucket name is ''.
"""
regions = {t.get('HomeRegion') for t in trails}
clients = {}
for region in regions:
clients[region] = session.client('cloudtrail', region_name=region)
event_buckets = {}
for t in trails:
for events in clients[t.get('HomeRegion')].get_event_selectors(
TrailName=t['Name']).get('EventSelectors', ()):
if 'DataResources' not in events:
continue
for data_events in events['DataResources']:
if data_events['Type'] != 'AWS::S3::Object':
continue
for b in data_events['Values']:
event_buckets[b.rsplit(':')[-1].strip('/')] = t['Name']
return event_buckets
def process(self, resources, event=None):
trails = self.manager.get_resource_manager('cloudtrail').resources()
session = local_session(self.manager.session_factory)
event_buckets = self.get_event_buckets(session, trails)
ops = {
'present': lambda x: (
x['Name'] in event_buckets or '' in event_buckets),
'absent': (
lambda x: x['Name'] not in event_buckets and ''
not in event_buckets)}
op = ops[self.data['state']]
results = []
for b in resources:
if op(b):
results.append(b)
return results
@filters.register('inventory')
class Inventory(ValueFilter):
"""Filter inventories for a bucket"""
schema = type_schema('inventory', rinherit=ValueFilter.schema)
schema_alias = False
permissions = ('s3:GetInventoryConfiguration',)
def process(self, buckets, event=None):
results = []
with self.executor_factory(max_workers=2) as w:
futures = {}
for b in buckets:
futures[w.submit(self.process_bucket, b)] = b
for f in as_completed(futures):
b = futures[f]
if f.exception():
b.setdefault('c7n:DeniedMethods', []).append('GetInventoryConfiguration')
self.log.error(
"Error processing bucket: %s error: %s",
b['Name'], f.exception())
continue
if f.result():
results.append(b)
return results
def process_bucket(self, b):
if 'c7n:inventories' not in b:
client = bucket_client(local_session(self.manager.session_factory), b)
inventories = client.list_bucket_inventory_configurations(
Bucket=b['Name']).get('InventoryConfigurationList', [])
b['c7n:inventories'] = inventories
for i in b['c7n:inventories']:
if self.match(i):
return True
@actions.register('set-inventory')
class SetInventory(BucketActionBase):
"""Configure bucket inventories for an s3 bucket.
"""
schema = type_schema(
'set-inventory',
required=['name', 'destination'],
state={'enum': ['enabled', 'disabled', 'absent']},
name={'type': 'string', 'description': 'Name of inventory'},
destination={'type': 'string', 'description': 'Name of destination bucket'},
prefix={'type': 'string', 'description': 'Destination prefix'},
encryption={'enum': ['SSES3', 'SSEKMS']},
key_id={'type': 'string', 'description': 'Optional Customer KMS KeyId for SSE-KMS'},
versions={'enum': ['All', 'Current']},
schedule={'enum': ['Daily', 'Weekly']},
format={'enum': ['CSV', 'ORC', 'Parquet']},
fields={'type': 'array', 'items': {'enum': [
'Size', 'LastModifiedDate', 'StorageClass', 'ETag',
'IsMultipartUploaded', 'ReplicationStatus', 'EncryptionStatus',
'ObjectLockRetainUntilDate', 'ObjectLockMode', 'ObjectLockLegalHoldStatus',
'IntelligentTieringAccessTier']}})
permissions = ('s3:PutInventoryConfiguration', 's3:GetInventoryConfiguration')
def process(self, buckets):
with self.executor_factory(max_workers=2) as w:
futures = {w.submit(self.process_bucket, bucket): bucket for bucket in buckets}
for future in as_completed(futures):
bucket = futures[future]
try:
future.result()
except Exception as e:
self.log.error('Message: %s Bucket: %s', e, bucket['Name'])
def process_bucket(self, b):
inventory_name = self.data.get('name')
destination = self.data.get('destination')
prefix = self.data.get('prefix', '')
schedule = self.data.get('schedule', 'Daily')
fields = self.data.get('fields', ['LastModifiedDate', 'Size'])
versions = self.data.get('versions', 'Current')
state = self.data.get('state', 'enabled')
encryption = self.data.get('encryption')
inventory_format = self.data.get('format', 'CSV')
if not prefix:
prefix = "Inventories/%s" % (self.manager.config.account_id)
client = bucket_client(local_session(self.manager.session_factory), b)
if state == 'absent':
try:
client.delete_bucket_inventory_configuration(
Bucket=b['Name'], Id=inventory_name)
except ClientError as e:
if e.response['Error']['Code'] != 'NoSuchConfiguration':
raise
return
bucket = {
'Bucket': "arn:aws:s3:::%s" % destination,
'Format': inventory_format
}
inventory = {
'Destination': {
'S3BucketDestination': bucket
},
'IsEnabled': state == 'enabled' and True or False,
'Id': inventory_name,
'OptionalFields': fields,
'IncludedObjectVersions': versions,
'Schedule': {
'Frequency': schedule
}
}
if prefix:
bucket['Prefix'] = prefix
if encryption:
bucket['Encryption'] = {encryption: {}}
if encryption == 'SSEKMS' and self.data.get('key_id'):
bucket['Encryption'] = {encryption: {
'KeyId': self.data['key_id']
}}
found = self.get_inventory_delta(client, inventory, b)
if found:
return
if found is False:
self.log.debug("updating bucket:%s inventory configuration id:%s",
b['Name'], inventory_name)
client.put_bucket_inventory_configuration(
Bucket=b['Name'], Id=inventory_name, InventoryConfiguration=inventory)
def get_inventory_delta(self, client, inventory, b):
inventories = client.list_bucket_inventory_configurations(Bucket=b['Name'])
found = None
for i in inventories.get('InventoryConfigurationList', []):
if i['Id'] != inventory['Id']:
continue
found = True
for k, v in inventory.items():
if k not in i:
found = False
continue
if isinstance(v, list):
v.sort()
i[k].sort()
if i[k] != v:
found = False
return found
@actions.register('delete')
class DeleteBucket(ScanBucket):
"""Action deletes a S3 bucket
:example:
.. code-block:: yaml
policies:
- name: delete-unencrypted-buckets
resource: s3
filters:
- type: missing-statement
statement_ids:
- RequiredEncryptedPutObject
actions:
- type: delete
remove-contents: true
"""
schema = type_schema('delete', **{'remove-contents': {'type': 'boolean'}})
permissions = ('s3:*',)
bucket_ops = {
'standard': {
'iterator': 'list_objects',
'contents_key': ['Contents'],
'key_processor': 'process_key'
},
'versioned': {
'iterator': 'list_object_versions',
'contents_key': ['Versions', 'DeleteMarkers'],
'key_processor': 'process_version'
}
}
def process_delete_enablement(self, b):
"""Prep a bucket for deletion.
Clear out any pending multi-part uploads.
Disable versioning on the bucket, so deletes don't
generate fresh deletion markers.
"""
client = bucket_client(
local_session(self.manager.session_factory), b)
# Stop replication so we can suspend versioning
if b.get('Replication') is not None:
client.delete_bucket_replication(Bucket=b['Name'])
# Suspend versioning, so we don't get new delete markers
# as we walk and delete versions
if (self.get_bucket_style(b) == 'versioned' and b['Versioning']['Status'] == 'Enabled' and
self.data.get('remove-contents', True)):
client.put_bucket_versioning(
Bucket=b['Name'],
VersioningConfiguration={'Status': 'Suspended'})
# Clear our multi-part uploads
uploads = client.get_paginator('list_multipart_uploads')
for p in uploads.paginate(Bucket=b['Name']):
for u in p.get('Uploads', ()):
client.abort_multipart_upload(
Bucket=b['Name'],
Key=u['Key'],
UploadId=u['UploadId'])
def process(self, buckets):
# might be worth sanity checking all our permissions
# on the bucket up front before disabling versioning/replication.
if self.data.get('remove-contents', True):
self._process_with_futures(self.process_delete_enablement, buckets)
self.empty_buckets(buckets)
results = self._process_with_futures(self.delete_bucket, buckets)
self.write_denied_buckets_file()
return results
def delete_bucket(self, b):
s3 = bucket_client(self.manager.session_factory(), b)
try:
self._run_api(s3.delete_bucket, Bucket=b['Name'])
except ClientError as e:
if e.response['Error']['Code'] == 'BucketNotEmpty':
self.log.error(
"Error while deleting bucket %s, bucket not empty" % (
b['Name']))
else:
raise e
def empty_buckets(self, buckets):
t = time.time()
results = super(DeleteBucket, self).process(buckets)
run_time = time.time() - t
object_count = 0
for r in results:
object_count += r['Count']
self.manager.ctx.metrics.put_metric(
"Total Keys", object_count, "Count", Scope=r['Bucket'],
buffer=True)
self.manager.ctx.metrics.put_metric(
"Total Keys", object_count, "Count", Scope="Account", buffer=True)
self.manager.ctx.metrics.flush()
log.info(
"EmptyBucket buckets:%d Complete keys:%d rate:%0.2f/s time:%0.2fs",
len(buckets), object_count,
float(object_count) / run_time if run_time else 0, run_time)
return results
def process_chunk(self, batch, bucket):
s3 = bucket_client(local_session(self.manager.session_factory), bucket)
objects = []
for key in batch:
obj = {'Key': key['Key']}
if 'VersionId' in key:
obj['VersionId'] = key['VersionId']
objects.append(obj)
results = s3.delete_objects(
Bucket=bucket['Name'], Delete={'Objects': objects}).get('Deleted', ())
if self.get_bucket_style(bucket) != 'versioned':
return results
@actions.register('configure-lifecycle')
class Lifecycle(BucketActionBase):
"""Action applies a lifecycle policy to versioned S3 buckets
The schema to supply to the rule follows the schema here:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.put_bucket_lifecycle_configuration
To delete a lifecycle rule, supply Status=absent
:example:
.. code-block:: yaml
policies:
- name: s3-apply-lifecycle
resource: s3
actions:
- type: configure-lifecycle
rules:
- ID: my-lifecycle-id
Status: Enabled
Prefix: foo/
Transitions:
- Days: 60
StorageClass: GLACIER
"""
schema = type_schema(
'configure-lifecycle',
**{
'rules': {
'type': 'array',
'items': {
'type': 'object',
'required': ['ID', 'Status'],
'additionalProperties': False,
'properties': {
'ID': {'type': 'string'},
# c7n intercepts `absent`
'Status': {'enum': ['Enabled', 'Disabled', 'absent']},
'Prefix': {'type': 'string'},
'Expiration': {
'type': 'object',
'additionalProperties': False,
'properties': {
'Date': {'type': 'string'}, # Date
'Days': {'type': 'integer'},
'ExpiredObjectDeleteMarker': {'type': 'boolean'},
},
},
'Filter': {
'type': 'object',
'minProperties': 1,
'maxProperties': 1,
'additionalProperties': False,
'properties': {
'Prefix': {'type': 'string'},
'Tag': {
'type': 'object',
'required': ['Key', 'Value'],
'additionalProperties': False,
'properties': {
'Key': {'type': 'string'},
'Value': {'type': 'string'},
},
},
'And': {
'type': 'object',
'additionalProperties': False,
'properties': {
'Prefix': {'type': 'string'},
'Tags': {
'type': 'array',
'items': {
'type': 'object',
'required': ['Key', 'Value'],
'additionalProperties': False,
'properties': {
'Key': {'type': 'string'},
'Value': {'type': 'string'},
},
},
},
},
},
},
},
'Transitions': {
'type': 'array',
'items': {
'type': 'object',
'additionalProperties': False,
'properties': {
'Date': {'type': 'string'}, # Date
'Days': {'type': 'integer'},
'StorageClass': {'type': 'string'},
},
},
},
'NoncurrentVersionTransitions': {
'type': 'array',
'items': {
'type': 'object',
'additionalProperties': False,
'properties': {
'NoncurrentDays': {'type': 'integer'},
'StorageClass': {'type': 'string'},
},
},
},
'NoncurrentVersionExpiration': {
'type': 'object',
'additionalProperties': False,
'properties': {
'NoncurrentDays': {'type': 'integer'},
},
},
'AbortIncompleteMultipartUpload': {
'type': 'object',
'additionalProperties': False,
'properties': {
'DaysAfterInitiation': {'type': 'integer'},
},
},
},
},
},
}
)
permissions = ('s3:GetLifecycleConfiguration', 's3:PutLifecycleConfiguration')
def process(self, buckets):
with self.executor_factory(max_workers=3) as w:
futures = {}
results = []
for b in buckets:
futures[w.submit(self.process_bucket, b)] = b
for future in as_completed(futures):
if future.exception():
bucket = futures[future]
self.log.error('error modifying bucket lifecycle: %s\n%s',
bucket['Name'], future.exception())
results += filter(None, [future.result()])
return results
def process_bucket(self, bucket):
s3 = bucket_client(local_session(self.manager.session_factory), bucket)
if 'get_bucket_lifecycle_configuration' in bucket.get('c7n:DeniedMethods', []):
log.warning("Access Denied Bucket:%s while reading lifecycle" % bucket['Name'])
return
# Adjust the existing lifecycle by adding/deleting/overwriting rules as necessary
config = (bucket.get('Lifecycle') or {}).get('Rules', [])
for rule in self.data['rules']:
for index, existing_rule in enumerate(config):
if rule['ID'] == existing_rule['ID']:
if rule['Status'] == 'absent':
config[index] = None
else:
config[index] = rule
break
else:
if rule['Status'] != 'absent':
config.append(rule)
# The extra `list` conversion is required for python3
config = list(filter(None, config))
try:
if not config:
s3.delete_bucket_lifecycle(Bucket=bucket['Name'])
else:
s3.put_bucket_lifecycle_configuration(
Bucket=bucket['Name'], LifecycleConfiguration={'Rules': config})
except ClientError as e:
if e.response['Error']['Code'] == 'AccessDenied':
log.warning("Access Denied Bucket:%s while applying lifecycle" % bucket['Name'])
else:
raise e
class KMSKeyResolverMixin(object):
"""Builds a dictionary of region specific ARNs"""
def __init__(self, data, manager=None):
self.arns = dict()
self.data = data
self.manager = manager
def resolve_keys(self, buckets):
if 'key' not in self.data:
return None
regions = {get_region(b) for b in buckets}
for r in regions:
client = local_session(self.manager.session_factory).client('kms', region_name=r)
try:
self.arns[r] = client.describe_key(
KeyId=self.data.get('key')
).get('KeyMetadata').get('Arn')
except ClientError as e:
self.log.error('Error resolving kms ARNs for set-bucket-encryption: %s key: %s' % (
e, self.data.get('key')))
def get_key(self, bucket):
if 'key' not in self.data:
return None
region = get_region(bucket)
key = self.arns.get(region)
if not key:
self.log.warning('Unable to resolve key %s for bucket %s in region %s',
key, bucket.get('Name'), region)
return key
@filters.register('bucket-encryption')
class BucketEncryption(KMSKeyResolverMixin, Filter):
"""Filters for S3 buckets that have bucket-encryption
:example
.. code-block:: yaml
policies:
- name: s3-bucket-encryption-AES256
resource: s3
region: us-east-1
filters:
- type: bucket-encryption
state: True
crypto: AES256
- name: s3-bucket-encryption-KMS
resource: s3
region: us-east-1
filters:
- type: bucket-encryption
state: True
crypto: aws:kms
key: alias/some/alias/key
- name: s3-bucket-encryption-off
resource: s3
region: us-east-1
filters:
- type: bucket-encryption
state: False
"""
schema = type_schema('bucket-encryption',
state={'type': 'boolean'},
crypto={'type': 'string', 'enum': ['AES256', 'aws:kms']},
key={'type': 'string'})
permissions = ('s3:GetEncryptionConfiguration', 'kms:DescribeKey')
def process(self, buckets, event=None):
self.resolve_keys(buckets)
results = []
with self.executor_factory(max_workers=2) as w:
futures = {w.submit(self.process_bucket, b): b for b in buckets}
for future in as_completed(futures):
b = futures[future]
if future.exception():
self.log.error("Message: %s Bucket: %s", future.exception(),
b['Name'])
continue
if future.result():
results.append(b)
return results
def process_bucket(self, b):
client = bucket_client(local_session(self.manager.session_factory), b)
rules = []
try:
be = client.get_bucket_encryption(Bucket=b['Name'])
b['c7n:bucket-encryption'] = be
rules = be.get('ServerSideEncryptionConfiguration', []).get('Rules', [])
except ClientError as e:
if e.response['Error']['Code'] != 'ServerSideEncryptionConfigurationNotFoundError':
raise
# default `state` to True as previous impl assumed state == True
# to preserve backwards compatibility
if self.data.get('state', True):
for sse in rules:
return self.filter_bucket(b, sse)
return False
else:
for sse in rules:
return not self.filter_bucket(b, sse)
return True
def filter_bucket(self, b, sse):
allowed = ['AES256', 'aws:kms']
key = self.get_key(b)
crypto = self.data.get('crypto')
rule = sse.get('ApplyServerSideEncryptionByDefault')
algo = rule.get('SSEAlgorithm')
if not crypto and algo in allowed:
return True
if crypto == 'AES256' and algo == 'AES256':
return True
elif crypto == 'aws:kms' and algo == 'aws:kms':
if key:
if rule.get('KMSMasterKeyID') == key:
return True
else:
return False
else:
return True
@actions.register('set-bucket-encryption')
class SetBucketEncryption(KMSKeyResolverMixin, BucketActionBase):
"""Action enables default encryption on S3 buckets
`enabled`: boolean Optional: Defaults to True
`crypto`: aws:kms | AES256` Optional: Defaults to AES256
`key`: arn, alias, or kms id key
:example:
.. code-block:: yaml
policies:
- name: s3-enable-default-encryption-kms
resource: s3
actions:
- type: set-bucket-encryption
# enabled: true <------ optional (true by default)
crypto: aws:kms
key: 1234abcd-12ab-34cd-56ef-1234567890ab
- name: s3-enable-default-encryption-kms-alias
resource: s3
actions:
- type: set-bucket-encryption
# enabled: true <------ optional (true by default)
crypto: aws:kms
key: alias/some/alias/key
- name: s3-enable-default-encryption-aes256
resource: s3
actions:
- type: set-bucket-encryption
# crypto: AES256 <----- optional (AES256 by default)
# enabled: true <------ optional (true by default)
- name: s3-disable-default-encryption
resource: s3
actions:
- type: set-bucket-encryption
enabled: false
"""
schema = {
'type': 'object',
'additionalProperties': False,
'properties': {
'type': {'enum': ['set-bucket-encryption']},
'enabled': {'type': 'boolean'},
'crypto': {'enum': ['aws:kms', 'AES256']},
'key': {'type': 'string'}
},
'dependencies': {
'key': {
'properties': {
'crypto': {'pattern': 'aws:kms'}
},
'required': ['crypto']
}
}
}
permissions = ('s3:PutEncryptionConfiguration', 's3:GetEncryptionConfiguration',
'kms:ListAliases', 'kms:DescribeKey')
def process(self, buckets):
if self.data.get('enabled', True):
self.resolve_keys(buckets)
with self.executor_factory(max_workers=3) as w:
futures = {w.submit(self.process_bucket, b): b for b in buckets}
for future in as_completed(futures):
if future.exception():
self.log.error('Message: %s Bucket: %s', future.exception(),
futures[future]['Name'])
def process_bucket(self, bucket):
s3 = bucket_client(local_session(self.manager.session_factory), bucket)
if not self.data.get('enabled', True):
s3.delete_bucket_encryption(Bucket=bucket['Name'])
return
algo = self.data.get('crypto', 'AES256')
config = {'Rules': [
{'ApplyServerSideEncryptionByDefault': {
'SSEAlgorithm': algo}}
]}
if algo == 'aws:kms':
key = self.get_key(bucket)
if not key:
raise Exception('Valid KMS Key required but does not exist')
(config['Rules'][0]['ApplyServerSideEncryptionByDefault']
['KMSMasterKeyID']) = key
s3.put_bucket_encryption(
Bucket=bucket['Name'],
ServerSideEncryptionConfiguration=config
)
|
apache-2.0
|
[
3,
1898,
6900,
13,
10680,
22516,
6910,
7309,
21813,
12,
20376,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
51,
19,
7337,
13537,
199,
199,
18053,
26,
199,
199,
1918,
7809,
13468,
4766,
334,
74,
6415,
515,
9,
3965,
436,
4236,
2457,
787,
199,
4561,
543,
1006,
5944,
12,
5893,
18655,
12,
781,
2387,
9978,
199,
350,
1741,
8125,
5315,
666,
334,
9440,
12,
16000,
1863,
12,
437,
429,
12,
18141,
9,
465,
2883,
4453,
199,
65,
5315,
6025,
14,
199,
199,
9303,
26,
421,
14645,
13,
1612,
8410,
24833,
1006,
2883,
315,
282,
5315,
436,
14190,
14645,
3062,
315,
4192,
14,
421,
2288,
13,
2587,
2285,
8410,
2670,
5315,
282,
1886,
367,
2288,
7192,
2285,
421,
14396,
13,
3185,
8410,
21328,
376,
14396,
1415,
4592,
370,
282,
5315,
12,
642,
911,
2059,
2043,
13103,
626,
787,
440,
1808,
14396,
12,
5893,
11488,
943,
2043,
18719,
14,
199,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
1331,
199,
646,
9143,
199,
646,
2022,
199,
646,
7975,
199,
646,
2050,
199,
646,
3473,
199,
646,
747,
199,
646,
900,
199,
646,
6149,
199,
199,
646,
3816,
199,
199,
504,
21199,
14,
1258,
492,
4094,
199,
504,
21199,
14,
3924,
492,
28972,
199,
199,
504,
5055,
492,
10018,
199,
504,
23002,
14,
25513,
492,
465,
63,
12634,
199,
504,
22208,
14,
2087,
492,
2198,
465,
2198,
63,
602,
199,
199,
893,
26,
272,
687,
4011,
19,
14,
3924,
492,
7799,
547,
199,
2590,
3545,
26,
272,
687,
21199,
14,
86,
500,
2908,
14,
6615,
14,
5154,
14,
4078,
19,
14,
3924,
492,
7799,
547,
421,
199,
504,
286,
23,
78,
14,
3723,
492,
334,
272,
10033,
10899,
12,
3523,
3310,
12,
16280,
11119,
12,
5852,
4845,
1563,
9,
199,
504,
286,
23,
78,
14,
3924,
492,
18141,
8172,
199,
504,
286,
23,
78,
14,
4273,
492,
334,
272,
9388,
10899,
12,
9388,
12,
28965,
6009,
3946,
4131,
12,
10072,
11818,
4131,
12,
272,
1594,
4131,
9,
199,
504,
286,
23,
78,
14,
2609,
492,
5944,
199,
504,
286,
23,
78,
492,
1827,
199,
504,
286,
23,
78,
14,
4435,
14,
4416,
16560,
492,
7711,
6591,
316,
199,
504,
286,
23,
78,
14,
2969,
492,
5852,
1931,
12,
8053,
12,
8053,
3310,
4131,
12,
8053,
10796,
379,
3310,
199,
504,
286,
23,
78,
14,
1208,
492,
334,
272,
8291,
12,
2257,
63,
1730,
12,
663,
63,
9340,
12,
730,
63,
3629,
12,
2457,
63,
1667,
12,
272,
16864,
12,
1475,
63,
875,
63,
1459,
12,
664,
63,
2048,
63,
3620,
63,
504,
63,
10329,
9,
421,
199,
793,
275,
2050,
14,
5572,
360,
29872,
79,
6268,
14,
83,
19,
358,
199,
199,
4273,
275,
9388,
10899,
360,
83,
19,
14,
4273,
358,
199,
3723,
275,
10033,
10899,
360,
83,
19,
14,
3723,
358,
199,
4273,
14,
2683,
360,
17938,
13,
509,
13,
411,
297,
8053,
3310,
4131,
9,
199,
3723,
14,
2683,
360,
524,
13,
5165,
297,
16280,
11119,
9,
199,
199,
4283,
63,
16188,
63,
4305,
275,
6619,
627,
6619,
627,
6619,
627,
499,
421,
199,
32,
4435,
14,
2683,
360,
83,
19,
358,
199,
533,
428,
19,
8,
1131,
14,
3227,
4031,
2988,
304,
339,
1021,
2073,
63,
466,
8,
1131,
14,
29136,
304,
267,
2435,
275,
283,
83,
19,
7,
267,
601,
78,
63,
466,
275,
2125,
267,
4952,
63,
1650,
275,
661,
513,
63,
15065,
297,
283,
12311,
83,
59,
4300,
488,
9,
267,
10093,
63,
1650,
275,
661,
513,
63,
1462,
297,
283,
12311,
297,
283,
11383,
8607,
358,
267,
536,
275,
1305,
275,
283,
985,
7,
267,
1434,
275,
283,
13921,
2506,
7,
267,
6240,
275,
283,
12311,
985,
7,
267,
1101,
63,
466,
275,
283,
13226,
447,
51,
19,
447,
12311,
7,
339,
2457,
63,
5189,
275,
4766,
272,
1595,
63,
5189,
275,
5445,
339,
347,
664,
63,
22476,
8,
277,
12,
5944,
304,
267,
372,
2097,
1060,
26,
7231,
26,
83,
19,
447,
26,
13536,
908,
8,
82,
905,
985,
3135,
367,
519,
315,
5944,
61,
339,
347,
664,
63,
1365,
8,
277,
12,
1350,
63,
466,
304,
267,
340,
1350,
63,
466,
508,
283,
11935,
356,
288,
372,
28571,
1235,
51,
19,
8,
277,
9,
267,
916,
1350,
63,
466,
508,
283,
888,
356,
288,
372,
4094,
51,
19,
8,
277,
9,
267,
587,
26,
288,
372,
1613,
8,
51,
19,
12,
291,
680,
362,
63,
1365,
8,
1365,
63,
466,
9,
339,
768,
3744,
272,
347,
664,
63,
6060,
8,
1886,
304,
267,
17340,
275,
2097,
83,
19,
26,
1296,
2422,
5713,
12311,
83,
937,
267,
17340,
14,
2880,
779,
78,
1988,
17,
61,
367,
302,
315,
428,
19,
63,
9331,
39,
4479,
63,
8723,
566,
267,
372,
17340,
421,
199,
533,
28571,
1235,
51,
19,
8,
1131,
14,
19506,
2980,
304,
339,
347,
18336,
434,
8,
277,
12,
18655,
304,
267,
543,
291,
14,
2609,
14,
13471,
63,
3702,
8,
355,
1390,
63,
11009,
29,
827,
1332,
709,
12,
822,
8,
15065,
9,
435,
413,
1724,
465,
336,
26,
288,
2058,
275,
336,
14,
1130,
8,
355,
22931,
63,
4623,
12,
355,
3482,
8,
17691,
14,
8755,
8,
277,
14,
2609,
14,
1730,
63,
3702,
395,
18655,
430,
288,
2058,
275,
769,
8,
1541,
8,
403,
12,
2058,
430,
288,
372,
2058,
339,
347,
664,
63,
4435,
8,
277,
12,
5315,
63,
1247,
304,
267,
372
] |
[
1898,
6900,
13,
10680,
22516,
6910,
7309,
21813,
12,
20376,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
624,
51,
19,
7337,
13537,
199,
199,
18053,
26,
199,
199,
1918,
7809,
13468,
4766,
334,
74,
6415,
515,
9,
3965,
436,
4236,
2457,
787,
199,
4561,
543,
1006,
5944,
12,
5893,
18655,
12,
781,
2387,
9978,
199,
350,
1741,
8125,
5315,
666,
334,
9440,
12,
16000,
1863,
12,
437,
429,
12,
18141,
9,
465,
2883,
4453,
199,
65,
5315,
6025,
14,
199,
199,
9303,
26,
421,
14645,
13,
1612,
8410,
24833,
1006,
2883,
315,
282,
5315,
436,
14190,
14645,
3062,
315,
4192,
14,
421,
2288,
13,
2587,
2285,
8410,
2670,
5315,
282,
1886,
367,
2288,
7192,
2285,
421,
14396,
13,
3185,
8410,
21328,
376,
14396,
1415,
4592,
370,
282,
5315,
12,
642,
911,
2059,
2043,
13103,
626,
787,
440,
1808,
14396,
12,
5893,
11488,
943,
2043,
18719,
14,
199,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
2649,
63,
5955,
199,
199,
646,
1331,
199,
646,
9143,
199,
646,
2022,
199,
646,
7975,
199,
646,
2050,
199,
646,
3473,
199,
646,
747,
199,
646,
900,
199,
646,
6149,
199,
199,
646,
3816,
199,
199,
504,
21199,
14,
1258,
492,
4094,
199,
504,
21199,
14,
3924,
492,
28972,
199,
199,
504,
5055,
492,
10018,
199,
504,
23002,
14,
25513,
492,
465,
63,
12634,
199,
504,
22208,
14,
2087,
492,
2198,
465,
2198,
63,
602,
199,
199,
893,
26,
272,
687,
4011,
19,
14,
3924,
492,
7799,
547,
199,
2590,
3545,
26,
272,
687,
21199,
14,
86,
500,
2908,
14,
6615,
14,
5154,
14,
4078,
19,
14,
3924,
492,
7799,
547,
421,
199,
504,
286,
23,
78,
14,
3723,
492,
334,
272,
10033,
10899,
12,
3523,
3310,
12,
16280,
11119,
12,
5852,
4845,
1563,
9,
199,
504,
286,
23,
78,
14,
3924,
492,
18141,
8172,
199,
504,
286,
23,
78,
14,
4273,
492,
334,
272,
9388,
10899,
12,
9388,
12,
28965,
6009,
3946,
4131,
12,
10072,
11818,
4131,
12,
272,
1594,
4131,
9,
199,
504,
286,
23,
78,
14,
2609,
492,
5944,
199,
504,
286,
23,
78,
492,
1827,
199,
504,
286,
23,
78,
14,
4435,
14,
4416,
16560,
492,
7711,
6591,
316,
199,
504,
286,
23,
78,
14,
2969,
492,
5852,
1931,
12,
8053,
12,
8053,
3310,
4131,
12,
8053,
10796,
379,
3310,
199,
504,
286,
23,
78,
14,
1208,
492,
334,
272,
8291,
12,
2257,
63,
1730,
12,
663,
63,
9340,
12,
730,
63,
3629,
12,
2457,
63,
1667,
12,
272,
16864,
12,
1475,
63,
875,
63,
1459,
12,
664,
63,
2048,
63,
3620,
63,
504,
63,
10329,
9,
421,
199,
793,
275,
2050,
14,
5572,
360,
29872,
79,
6268,
14,
83,
19,
358,
199,
199,
4273,
275,
9388,
10899,
360,
83,
19,
14,
4273,
358,
199,
3723,
275,
10033,
10899,
360,
83,
19,
14,
3723,
358,
199,
4273,
14,
2683,
360,
17938,
13,
509,
13,
411,
297,
8053,
3310,
4131,
9,
199,
3723,
14,
2683,
360,
524,
13,
5165,
297,
16280,
11119,
9,
199,
199,
4283,
63,
16188,
63,
4305,
275,
6619,
627,
6619,
627,
6619,
627,
499,
421,
199,
32,
4435,
14,
2683,
360,
83,
19,
358,
199,
533,
428,
19,
8,
1131,
14,
3227,
4031,
2988,
304,
339,
1021,
2073,
63,
466,
8,
1131,
14,
29136,
304,
267,
2435,
275,
283,
83,
19,
7,
267,
601,
78,
63,
466,
275,
2125,
267,
4952,
63,
1650,
275,
661,
513,
63,
15065,
297,
283,
12311,
83,
59,
4300,
488,
9,
267,
10093,
63,
1650,
275,
661,
513,
63,
1462,
297,
283,
12311,
297,
283,
11383,
8607,
358,
267,
536,
275,
1305,
275,
283,
985,
7,
267,
1434,
275,
283,
13921,
2506,
7,
267,
6240,
275,
283,
12311,
985,
7,
267,
1101,
63,
466,
275,
283,
13226,
447,
51,
19,
447,
12311,
7,
339,
2457,
63,
5189,
275,
4766,
272,
1595,
63,
5189,
275,
5445,
339,
347,
664,
63,
22476,
8,
277,
12,
5944,
304,
267,
372,
2097,
1060,
26,
7231,
26,
83,
19,
447,
26,
13536,
908,
8,
82,
905,
985,
3135,
367,
519,
315,
5944,
61,
339,
347,
664,
63,
1365,
8,
277,
12,
1350,
63,
466,
304,
267,
340,
1350,
63,
466,
508,
283,
11935,
356,
288,
372,
28571,
1235,
51,
19,
8,
277,
9,
267,
916,
1350,
63,
466,
508,
283,
888,
356,
288,
372,
4094,
51,
19,
8,
277,
9,
267,
587,
26,
288,
372,
1613,
8,
51,
19,
12,
291,
680,
362,
63,
1365,
8,
1365,
63,
466,
9,
339,
768,
3744,
272,
347,
664,
63,
6060,
8,
1886,
304,
267,
17340,
275,
2097,
83,
19,
26,
1296,
2422,
5713,
12311,
83,
937,
267,
17340,
14,
2880,
779,
78,
1988,
17,
61,
367,
302,
315,
428,
19,
63,
9331,
39,
4479,
63,
8723,
566,
267,
372,
17340,
421,
199,
533,
28571,
1235,
51,
19,
8,
1131,
14,
19506,
2980,
304,
339,
347,
18336,
434,
8,
277,
12,
18655,
304,
267,
543,
291,
14,
2609,
14,
13471,
63,
3702,
8,
355,
1390,
63,
11009,
29,
827,
1332,
709,
12,
822,
8,
15065,
9,
435,
413,
1724,
465,
336,
26,
288,
2058,
275,
336,
14,
1130,
8,
355,
22931,
63,
4623,
12,
355,
3482,
8,
17691,
14,
8755,
8,
277,
14,
2609,
14,
1730,
63,
3702,
395,
18655,
430,
288,
2058,
275,
769,
8,
1541,
8,
403,
12,
2058,
430,
288,
372,
2058,
339,
347,
664,
63,
4435,
8,
277,
12,
5315,
63,
1247,
304,
267,
372,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
leighpauls/k2cro4
|
third_party/android_testrunner/run_command.py
|
23
|
5845
|
#!/usr/bin/python2.4
#
#
# Copyright 2007, The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# System imports
import os
import signal
import subprocess
import threading
import time
# local imports
import errors
import logger
_abort_on_error = False
def SetAbortOnError(abort=True):
"""Sets behavior of RunCommand to throw AbortError if command process returns
a negative error code"""
global _abort_on_error
_abort_on_error = abort
def RunCommand(cmd, timeout_time=None, retry_count=3, return_output=True,
stdin_input=None):
"""Spawn and retry a subprocess to run the given shell command.
Args:
cmd: shell command to run
timeout_time: time in seconds to wait for command to run before aborting.
retry_count: number of times to retry command
return_output: if True return output of command as string. Otherwise,
direct output of command to stdout.
stdin_input: data to feed to stdin
Returns:
output of command
"""
result = None
while True:
try:
result = RunOnce(cmd, timeout_time=timeout_time,
return_output=return_output, stdin_input=stdin_input)
except errors.WaitForResponseTimedOutError:
if retry_count == 0:
raise
retry_count -= 1
logger.Log("No response for %s, retrying" % cmd)
else:
# Success
return result
def RunOnce(cmd, timeout_time=None, return_output=True, stdin_input=None):
"""Spawns a subprocess to run the given shell command.
Args:
cmd: shell command to run
timeout_time: time in seconds to wait for command to run before aborting.
return_output: if True return output of command as string. Otherwise,
direct output of command to stdout.
stdin_input: data to feed to stdin
Returns:
output of command
Raises:
errors.WaitForResponseTimedOutError if command did not complete within
timeout_time seconds.
errors.AbortError is command returned error code and SetAbortOnError is on.
"""
start_time = time.time()
so = []
pid = []
global _abort_on_error, error_occurred
error_occurred = False
def Run():
global error_occurred
if return_output:
output_dest = subprocess.PIPE
else:
# None means direct to stdout
output_dest = None
if stdin_input:
stdin_dest = subprocess.PIPE
else:
stdin_dest = None
pipe = subprocess.Popen(
cmd,
executable='/bin/bash',
stdin=stdin_dest,
stdout=output_dest,
stderr=subprocess.STDOUT,
shell=True)
pid.append(pipe.pid)
try:
output = pipe.communicate(input=stdin_input)[0]
if output is not None and len(output) > 0:
so.append(output)
except OSError, e:
logger.SilentLog("failed to retrieve stdout from: %s" % cmd)
logger.Log(e)
so.append("ERROR")
error_occurred = True
if pipe.returncode:
logger.SilentLog("Error: %s returned %d error code" %(cmd,
pipe.returncode))
error_occurred = True
t = threading.Thread(target=Run)
t.start()
break_loop = False
while not break_loop:
if not t.isAlive():
break_loop = True
# Check the timeout
if (not break_loop and timeout_time is not None
and time.time() > start_time + timeout_time):
try:
os.kill(pid[0], signal.SIGKILL)
except OSError:
# process already dead. No action required.
pass
logger.SilentLog("about to raise a timeout for: %s" % cmd)
raise errors.WaitForResponseTimedOutError
if not break_loop:
time.sleep(0.1)
t.join()
output = "".join(so)
if _abort_on_error and error_occurred:
raise errors.AbortError(msg=output)
return "".join(so)
def RunHostCommand(binary, valgrind=False):
"""Run a command on the host (opt using valgrind).
Runs the host binary and returns the exit code.
If successfull, the output (stdout and stderr) are discarded,
but printed in case of error.
The command can be run under valgrind in which case all the
output are always discarded.
Args:
binary: full path of the file to be run.
valgrind: If True the command will be run under valgrind.
Returns:
The command exit code (int)
"""
if not valgrind:
subproc = subprocess.Popen(binary, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
subproc.wait()
if subproc.returncode != 0: # In case of error print the output
print subproc.communicate()[0]
return subproc.returncode
else:
# Need the full path to valgrind to avoid other versions on the system.
subproc = subprocess.Popen(["/usr/bin/valgrind", "--tool=memcheck",
"--leak-check=yes", "-q", binary],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# Cannot rely on the retcode of valgrind. Instead look for an empty output.
valgrind_out = subproc.communicate()[0].strip()
if valgrind_out:
print valgrind_out
return 1
else:
return 0
def HasValgrind():
"""Check that /usr/bin/valgrind exists.
We look for the fullpath to avoid picking up 'alternative' valgrind
on the system.
Returns:
True if a system valgrind was found.
"""
return os.path.exists("/usr/bin/valgrind")
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1548,
18,
14,
20,
199,
3,
199,
3,
199,
3,
1898,
10219,
12,
710,
14694,
3232,
5800,
7290,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
3,
6187,
8925,
199,
646,
747,
199,
646,
4673,
199,
646,
3873,
199,
646,
5796,
199,
646,
900,
199,
199,
3,
2257,
8925,
199,
646,
2552,
199,
646,
2512,
199,
199,
63,
13845,
63,
265,
63,
705,
275,
756,
199,
199,
318,
2494,
16682,
3314,
547,
8,
13845,
29,
549,
304,
523,
408,
9899,
5953,
402,
3378,
3110,
370,
7978,
31455,
547,
340,
1414,
2112,
2529,
523,
282,
6946,
1125,
1233,
624,
523,
2288,
485,
13845,
63,
265,
63,
705,
523,
485,
13845,
63,
265,
63,
705,
275,
12004,
199,
199,
318,
3378,
3110,
8,
1760,
12,
2653,
63,
521,
29,
403,
12,
7269,
63,
835,
29,
19,
12,
372,
63,
1199,
29,
549,
12,
2049,
9009,
63,
1210,
29,
403,
304,
523,
408,
12739,
3501,
436,
7269,
282,
3873,
370,
1255,
314,
1627,
5218,
1414,
14,
819,
3033,
26,
272,
2088,
26,
5218,
1414,
370,
1255,
272,
2653,
63,
521,
26,
900,
315,
4696,
370,
3618,
367,
1414,
370,
1255,
2544,
12004,
316,
14,
272,
7269,
63,
835,
26,
1329,
402,
5431,
370,
7269,
1414,
272,
372,
63,
1199,
26,
340,
715,
372,
1072,
402,
1414,
465,
1059,
14,
6630,
12,
489,
4125,
1072,
402,
1414,
370,
3839,
14,
272,
9009,
63,
1210,
26,
666,
370,
4733,
370,
9009,
523,
1803,
26,
272,
1072,
402,
1414,
523,
408,
523,
754,
275,
488,
523,
1830,
715,
26,
272,
862,
26,
489,
754,
275,
3378,
25690,
8,
1760,
12,
2653,
63,
521,
29,
2593,
63,
521,
12,
2432,
372,
63,
1199,
29,
1107,
63,
1199,
12,
9009,
63,
1210,
29,
6626,
63,
1210,
9,
272,
871,
2552,
14,
21433,
2364,
28682,
2204,
547,
26,
489,
340,
7269,
63,
835,
508,
378,
26,
267,
746,
489,
7269,
63,
835,
4862,
413,
489,
2512,
14,
2445,
480,
1944,
1177,
367,
450,
83,
12,
7269,
316,
2,
450,
2088,
9,
272,
587,
26,
489,
327,
22318,
489,
372,
754,
199,
199,
318,
3378,
25690,
8,
1760,
12,
2653,
63,
521,
29,
403,
12,
372,
63,
1199,
29,
549,
12,
9009,
63,
1210,
29,
403,
304,
523,
408,
12739,
87,
561,
282,
3873,
370,
1255,
314,
1627,
5218,
1414,
14,
819,
3033,
26,
272,
2088,
26,
5218,
1414,
370,
1255,
272,
2653,
63,
521,
26,
900,
315,
4696,
370,
3618,
367,
1414,
370,
1255,
2544,
12004,
316,
14,
272,
372,
63,
1199,
26,
340,
715,
372,
1072,
402,
1414,
465,
1059,
14,
6630,
12,
489,
4125,
1072,
402,
1414,
370,
3839,
14,
272,
9009,
63,
1210,
26,
666,
370,
4733,
370,
9009,
523,
1803,
26,
272,
1072,
402,
1414,
523,
6218,
26,
272,
2552,
14,
21433,
2364,
28682,
2204,
547,
340,
1414,
8103,
440,
4890,
4453,
489,
2653,
63,
521,
4696,
14,
272,
2552,
14,
16682,
547,
365,
1414,
2138,
1125,
1233,
436,
2494,
16682,
3314,
547,
365,
641,
14,
523,
408,
523,
1343,
63,
521,
275,
900,
14,
521,
342,
523,
880,
275,
942,
523,
4422,
275,
942,
523,
2288,
485,
13845,
63,
265,
63,
705,
12,
1125,
63,
20051,
581,
523,
1125,
63,
20051,
581,
275,
756,
819,
347,
3378,
837,
272,
2288,
1125,
63,
20051,
581,
272,
340,
372,
63,
1199,
26,
489,
1072,
63,
2614,
275,
3873,
14,
6089,
272,
587,
26,
489,
327,
488,
4910,
4125,
370,
3839,
489,
1072,
63,
2614,
275,
488,
272,
340,
9009,
63,
1210,
26,
489,
9009,
63,
2614,
275,
3873,
14,
6089,
272,
587,
26,
489,
9009,
63,
2614,
275,
488,
272,
5200,
275,
3873,
14,
7942,
8,
267,
2088,
12,
267,
7286,
8805,
1393,
15,
16408,
297,
267,
9009,
29,
6626,
63,
2614,
12,
267,
3839,
29,
1199,
63,
2614,
12,
267,
4635,
29,
5781,
14,
13850,
12,
267,
5218,
29,
549,
9,
272,
4422,
14,
740,
8,
4990,
14,
3150,
9,
272,
862,
26,
489,
1072,
275,
5200,
14,
10664,
8,
1210,
29,
6626,
63,
1210,
2788,
16,
61,
489,
340,
1072,
365,
440,
488,
436,
822,
8,
1199,
9,
690,
378,
26,
267,
880,
14,
740,
8,
1199,
9,
272,
871,
6440,
12,
325,
26,
489,
2512,
14,
51,
441,
343,
2445,
480,
4892,
370,
8044,
3839,
687,
26,
450,
83,
2,
450,
2088,
9,
489,
2512,
14,
2445,
8,
69,
9,
489,
880,
14,
740,
480,
3170,
531,
489,
1125,
63,
20051,
581,
275,
715,
272,
340,
5200,
14,
9913,
26,
489,
2512,
14,
51,
441,
343,
2445,
480,
547,
26,
450,
83,
2138,
450,
68,
1125,
1233,
2,
2818,
1760,
12,
881,
5200,
14,
9913,
430,
489,
1125,
63,
20051,
581,
275,
715,
819,
307,
275,
5796,
14,
4436,
8,
1375,
29,
2540,
9,
523,
307,
14,
928,
342,
819,
2059,
63,
3813,
275,
756,
523,
1830,
440,
2059,
63,
3813,
26,
272,
340,
440,
307,
14,
374,
23692,
837,
489,
2059,
63,
3813,
275,
715,
339,
327,
2670,
314,
2653,
272,
340,
334,
1397,
2059,
63,
3813,
436,
2653,
63,
521,
365,
440,
488,
267,
436,
900,
14,
521,
342,
690,
1343,
63,
521,
435,
2653,
63,
521,
304,
489,
862,
26,
267,
747,
14,
8997,
8,
3150,
59,
16,
467,
4673,
14,
7864,
30691,
9,
489,
871,
6440,
26,
267,
327,
2112,
2575,
12314,
14,
3091,
1595,
1415,
14,
267,
986,
2541,
2512,
14,
51,
441,
343,
2445,
480,
10254,
370,
746,
282,
2653,
367
] |
[
2647,
15,
1393,
15,
1548,
18,
14,
20,
199,
3,
199,
3,
199,
3,
1898,
10219,
12,
710,
14694,
3232,
5800,
7290,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
199,
3,
6187,
8925,
199,
646,
747,
199,
646,
4673,
199,
646,
3873,
199,
646,
5796,
199,
646,
900,
199,
199,
3,
2257,
8925,
199,
646,
2552,
199,
646,
2512,
199,
199,
63,
13845,
63,
265,
63,
705,
275,
756,
199,
199,
318,
2494,
16682,
3314,
547,
8,
13845,
29,
549,
304,
523,
408,
9899,
5953,
402,
3378,
3110,
370,
7978,
31455,
547,
340,
1414,
2112,
2529,
523,
282,
6946,
1125,
1233,
624,
523,
2288,
485,
13845,
63,
265,
63,
705,
523,
485,
13845,
63,
265,
63,
705,
275,
12004,
199,
199,
318,
3378,
3110,
8,
1760,
12,
2653,
63,
521,
29,
403,
12,
7269,
63,
835,
29,
19,
12,
372,
63,
1199,
29,
549,
12,
2049,
9009,
63,
1210,
29,
403,
304,
523,
408,
12739,
3501,
436,
7269,
282,
3873,
370,
1255,
314,
1627,
5218,
1414,
14,
819,
3033,
26,
272,
2088,
26,
5218,
1414,
370,
1255,
272,
2653,
63,
521,
26,
900,
315,
4696,
370,
3618,
367,
1414,
370,
1255,
2544,
12004,
316,
14,
272,
7269,
63,
835,
26,
1329,
402,
5431,
370,
7269,
1414,
272,
372,
63,
1199,
26,
340,
715,
372,
1072,
402,
1414,
465,
1059,
14,
6630,
12,
489,
4125,
1072,
402,
1414,
370,
3839,
14,
272,
9009,
63,
1210,
26,
666,
370,
4733,
370,
9009,
523,
1803,
26,
272,
1072,
402,
1414,
523,
408,
523,
754,
275,
488,
523,
1830,
715,
26,
272,
862,
26,
489,
754,
275,
3378,
25690,
8,
1760,
12,
2653,
63,
521,
29,
2593,
63,
521,
12,
2432,
372,
63,
1199,
29,
1107,
63,
1199,
12,
9009,
63,
1210,
29,
6626,
63,
1210,
9,
272,
871,
2552,
14,
21433,
2364,
28682,
2204,
547,
26,
489,
340,
7269,
63,
835,
508,
378,
26,
267,
746,
489,
7269,
63,
835,
4862,
413,
489,
2512,
14,
2445,
480,
1944,
1177,
367,
450,
83,
12,
7269,
316,
2,
450,
2088,
9,
272,
587,
26,
489,
327,
22318,
489,
372,
754,
199,
199,
318,
3378,
25690,
8,
1760,
12,
2653,
63,
521,
29,
403,
12,
372,
63,
1199,
29,
549,
12,
9009,
63,
1210,
29,
403,
304,
523,
408,
12739,
87,
561,
282,
3873,
370,
1255,
314,
1627,
5218,
1414,
14,
819,
3033,
26,
272,
2088,
26,
5218,
1414,
370,
1255,
272,
2653,
63,
521,
26,
900,
315,
4696,
370,
3618,
367,
1414,
370,
1255,
2544,
12004,
316,
14,
272,
372,
63,
1199,
26,
340,
715,
372,
1072,
402,
1414,
465,
1059,
14,
6630,
12,
489,
4125,
1072,
402,
1414,
370,
3839,
14,
272,
9009,
63,
1210,
26,
666,
370,
4733,
370,
9009,
523,
1803,
26,
272,
1072,
402,
1414,
523,
6218,
26,
272,
2552,
14,
21433,
2364,
28682,
2204,
547,
340,
1414,
8103,
440,
4890,
4453,
489,
2653,
63,
521,
4696,
14,
272,
2552,
14,
16682,
547,
365,
1414,
2138,
1125,
1233,
436,
2494,
16682,
3314,
547,
365,
641,
14,
523,
408,
523,
1343,
63,
521,
275,
900,
14,
521,
342,
523,
880,
275,
942,
523,
4422,
275,
942,
523,
2288,
485,
13845,
63,
265,
63,
705,
12,
1125,
63,
20051,
581,
523,
1125,
63,
20051,
581,
275,
756,
819,
347,
3378,
837,
272,
2288,
1125,
63,
20051,
581,
272,
340,
372,
63,
1199,
26,
489,
1072,
63,
2614,
275,
3873,
14,
6089,
272,
587,
26,
489,
327,
488,
4910,
4125,
370,
3839,
489,
1072,
63,
2614,
275,
488,
272,
340,
9009,
63,
1210,
26,
489,
9009,
63,
2614,
275,
3873,
14,
6089,
272,
587,
26,
489,
9009,
63,
2614,
275,
488,
272,
5200,
275,
3873,
14,
7942,
8,
267,
2088,
12,
267,
7286,
8805,
1393,
15,
16408,
297,
267,
9009,
29,
6626,
63,
2614,
12,
267,
3839,
29,
1199,
63,
2614,
12,
267,
4635,
29,
5781,
14,
13850,
12,
267,
5218,
29,
549,
9,
272,
4422,
14,
740,
8,
4990,
14,
3150,
9,
272,
862,
26,
489,
1072,
275,
5200,
14,
10664,
8,
1210,
29,
6626,
63,
1210,
2788,
16,
61,
489,
340,
1072,
365,
440,
488,
436,
822,
8,
1199,
9,
690,
378,
26,
267,
880,
14,
740,
8,
1199,
9,
272,
871,
6440,
12,
325,
26,
489,
2512,
14,
51,
441,
343,
2445,
480,
4892,
370,
8044,
3839,
687,
26,
450,
83,
2,
450,
2088,
9,
489,
2512,
14,
2445,
8,
69,
9,
489,
880,
14,
740,
480,
3170,
531,
489,
1125,
63,
20051,
581,
275,
715,
272,
340,
5200,
14,
9913,
26,
489,
2512,
14,
51,
441,
343,
2445,
480,
547,
26,
450,
83,
2138,
450,
68,
1125,
1233,
2,
2818,
1760,
12,
881,
5200,
14,
9913,
430,
489,
1125,
63,
20051,
581,
275,
715,
819,
307,
275,
5796,
14,
4436,
8,
1375,
29,
2540,
9,
523,
307,
14,
928,
342,
819,
2059,
63,
3813,
275,
756,
523,
1830,
440,
2059,
63,
3813,
26,
272,
340,
440,
307,
14,
374,
23692,
837,
489,
2059,
63,
3813,
275,
715,
339,
327,
2670,
314,
2653,
272,
340,
334,
1397,
2059,
63,
3813,
436,
2653,
63,
521,
365,
440,
488,
267,
436,
900,
14,
521,
342,
690,
1343,
63,
521,
435,
2653,
63,
521,
304,
489,
862,
26,
267,
747,
14,
8997,
8,
3150,
59,
16,
467,
4673,
14,
7864,
30691,
9,
489,
871,
6440,
26,
267,
327,
2112,
2575,
12314,
14,
3091,
1595,
1415,
14,
267,
986,
2541,
2512,
14,
51,
441,
343,
2445,
480,
10254,
370,
746,
282,
2653,
367,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
jonathanstrong/functor
|
setup.py
|
1
|
1091
|
#!/usr/bin/env python
# Bootstrap installation of Distribute
import distribute_setup
distribute_setup.use_setuptools()
import os
from setuptools import setup
PROJECT = u'Functor'
VERSION = '0.1'
URL = ''
AUTHOR = u'Jonathan Strong'
AUTHOR_EMAIL = u'jonathan.strong@gmail.com'
DESC = "Implements a function-object pattern in Python."
def read_file(file_name):
file_path = os.path.join(
os.path.dirname(__file__),
file_name
)
return open(file_path).read()
setup(
name=PROJECT,
version=VERSION,
description=DESC,
long_description=read_file('README.md'),
author=AUTHOR,
author_email=AUTHOR_EMAIL,
url=URL,
license=read_file('LICENSE'),
namespace_packages=[],
packages=[u'functor'],
include_package_data=True,
zip_safe=False,
install_requires=[
# -*- Requirements -*-
],
entry_points = {
# -*- Entry points -*-
},
classifiers=[
# see http://pypi.python.org/pypi?:action=list_classifiers
# -*- Classifiers -*-
"Programming Language :: Python",
],
)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
27324,
7868,
12096,
402,
577,
5414,
266,
199,
646,
11207,
63,
2758,
199,
3470,
63,
2758,
14,
1180,
63,
13623,
342,
199,
199,
646,
747,
199,
199,
504,
9116,
492,
3272,
421,
199,
10797,
275,
399,
7,
19941,
630,
7,
199,
4612,
275,
283,
16,
14,
17,
7,
199,
2632,
275,
2125,
199,
27938,
275,
399,
7,
42,
265,
1619,
290,
8303,
951,
7,
199,
27938,
63,
10089,
275,
399,
7,
74,
265,
1619,
290,
14,
9370,
32,
6799,
14,
957,
7,
199,
15119,
275,
298,
29452,
282,
805,
13,
785,
3851,
315,
2018,
2122,
199,
199,
318,
1586,
63,
493,
8,
493,
63,
354,
304,
272,
570,
63,
515,
275,
747,
14,
515,
14,
904,
8,
267,
747,
14,
515,
14,
3475,
3460,
493,
10139,
267,
570,
63,
354,
267,
776,
272,
372,
1551,
8,
493,
63,
515,
680,
739,
342,
199,
199,
2758,
8,
272,
536,
29,
10797,
12,
272,
1015,
29,
4612,
12,
272,
1369,
29,
15119,
12,
272,
1846,
63,
1802,
29,
739,
63,
493,
360,
18195,
14,
1064,
659,
272,
4132,
29,
27938,
12,
272,
4132,
63,
2123,
29,
27938,
63,
10089,
12,
272,
1166,
29,
2632,
12,
272,
4190,
29,
739,
63,
493,
360,
3961,
659,
272,
3231,
63,
5154,
6034,
272,
6117,
1524,
85,
7,
7036,
630,
995,
272,
2387,
63,
2491,
63,
576,
29,
549,
12,
272,
3482,
63,
3489,
29,
797,
12,
272,
3907,
63,
6537,
1524,
267,
327,
1882,
18513,
1470,
1882,
272,
2156,
272,
2397,
63,
3438,
275,
469,
267,
327,
1882,
11855,
4501,
1882,
272,
1660,
272,
19137,
1524,
1362,
198,
3,
1937,
1455,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
31,
26,
1287,
29,
513,
63,
27628,
267,
327,
1882,
8465,
2608,
6069,
1882,
267,
298,
11411,
8466,
3800,
2018,
401,
272,
2156,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
27324,
7868,
12096,
402,
577,
5414,
266,
199,
646,
11207,
63,
2758,
199,
3470,
63,
2758,
14,
1180,
63,
13623,
342,
199,
199,
646,
747,
199,
199,
504,
9116,
492,
3272,
421,
199,
10797,
275,
399,
7,
19941,
630,
7,
199,
4612,
275,
283,
16,
14,
17,
7,
199,
2632,
275,
2125,
199,
27938,
275,
399,
7,
42,
265,
1619,
290,
8303,
951,
7,
199,
27938,
63,
10089,
275,
399,
7,
74,
265,
1619,
290,
14,
9370,
32,
6799,
14,
957,
7,
199,
15119,
275,
298,
29452,
282,
805,
13,
785,
3851,
315,
2018,
2122,
199,
199,
318,
1586,
63,
493,
8,
493,
63,
354,
304,
272,
570,
63,
515,
275,
747,
14,
515,
14,
904,
8,
267,
747,
14,
515,
14,
3475,
3460,
493,
10139,
267,
570,
63,
354,
267,
776,
272,
372,
1551,
8,
493,
63,
515,
680,
739,
342,
199,
199,
2758,
8,
272,
536,
29,
10797,
12,
272,
1015,
29,
4612,
12,
272,
1369,
29,
15119,
12,
272,
1846,
63,
1802,
29,
739,
63,
493,
360,
18195,
14,
1064,
659,
272,
4132,
29,
27938,
12,
272,
4132,
63,
2123,
29,
27938,
63,
10089,
12,
272,
1166,
29,
2632,
12,
272,
4190,
29,
739,
63,
493,
360,
3961,
659,
272,
3231,
63,
5154,
6034,
272,
6117,
1524,
85,
7,
7036,
630,
995,
272,
2387,
63,
2491,
63,
576,
29,
549,
12,
272,
3482,
63,
3489,
29,
797,
12,
272,
3907,
63,
6537,
1524,
267,
327,
1882,
18513,
1470,
1882,
272,
2156,
272,
2397,
63,
3438,
275,
469,
267,
327,
1882,
11855,
4501,
1882,
272,
1660,
272,
19137,
1524,
1362,
198,
3,
1937,
1455,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
31,
26,
1287,
29,
513,
63,
27628,
267,
327,
1882,
8465,
2608,
6069,
1882,
267,
298,
11411,
8466,
3800,
2018,
401,
272,
2156,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
joebowen/LogMyRocket_API
|
LogMyRocket/libraries/sys_packages/pycparser/pycparser/ply/lex.py
|
482
|
40739
|
# -----------------------------------------------------------------------------
# ply: lex.py
#
# Copyright (C) 2001-2011,
# David M. Beazley (Dabeaz LLC)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the David Beazley or Dabeaz LLC may be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
__version__ = "3.4"
__tabversion__ = "3.2" # Version of table file used
import re, sys, types, copy, os
# This tuple contains known string types
try:
# Python 2.6
StringTypes = (types.StringType, types.UnicodeType)
except AttributeError:
# Python 3.0
StringTypes = (str, bytes)
# Extract the code attribute of a function. Different implementations
# are for Python 2/3 compatibility.
if sys.version_info[0] < 3:
def func_code(f):
return f.func_code
else:
def func_code(f):
return f.__code__
# This regular expression is used to match valid token names
_is_identifier = re.compile(r'^[a-zA-Z0-9_]+$')
# Exception thrown when invalid token encountered and no default error
# handler is defined.
class LexError(Exception):
def __init__(self,message,s):
self.args = (message,)
self.text = s
# Token class. This class is used to represent the tokens produced.
class LexToken(object):
def __str__(self):
return "LexToken(%s,%r,%d,%d)" % (self.type,self.value,self.lineno,self.lexpos)
def __repr__(self):
return str(self)
# This object is a stand-in for a logging object created by the
# logging module.
class PlyLogger(object):
def __init__(self,f):
self.f = f
def critical(self,msg,*args,**kwargs):
self.f.write((msg % args) + "\n")
def warning(self,msg,*args,**kwargs):
self.f.write("WARNING: "+ (msg % args) + "\n")
def error(self,msg,*args,**kwargs):
self.f.write("ERROR: " + (msg % args) + "\n")
info = critical
debug = critical
# Null logger is used when no output is generated. Does nothing.
class NullLogger(object):
def __getattribute__(self,name):
return self
def __call__(self,*args,**kwargs):
return self
# -----------------------------------------------------------------------------
# === Lexing Engine ===
#
# The following Lexer class implements the lexer runtime. There are only
# a few public methods and attributes:
#
# input() - Store a new string in the lexer
# token() - Get the next token
# clone() - Clone the lexer
#
# lineno - Current line number
# lexpos - Current position in the input string
# -----------------------------------------------------------------------------
class Lexer:
def __init__(self):
self.lexre = None # Master regular expression. This is a list of
# tuples (re,findex) where re is a compiled
# regular expression and findex is a list
# mapping regex group numbers to rules
self.lexretext = None # Current regular expression strings
self.lexstatere = {} # Dictionary mapping lexer states to master regexs
self.lexstateretext = {} # Dictionary mapping lexer states to regex strings
self.lexstaterenames = {} # Dictionary mapping lexer states to symbol names
self.lexstate = "INITIAL" # Current lexer state
self.lexstatestack = [] # Stack of lexer states
self.lexstateinfo = None # State information
self.lexstateignore = {} # Dictionary of ignored characters for each state
self.lexstateerrorf = {} # Dictionary of error functions for each state
self.lexreflags = 0 # Optional re compile flags
self.lexdata = None # Actual input data (as a string)
self.lexpos = 0 # Current position in input text
self.lexlen = 0 # Length of the input text
self.lexerrorf = None # Error rule (if any)
self.lextokens = None # List of valid tokens
self.lexignore = "" # Ignored characters
self.lexliterals = "" # Literal characters that can be passed through
self.lexmodule = None # Module
self.lineno = 1 # Current line number
self.lexoptimize = 0 # Optimized mode
def clone(self,object=None):
c = copy.copy(self)
# If the object parameter has been supplied, it means we are attaching the
# lexer to a new object. In this case, we have to rebind all methods in
# the lexstatere and lexstateerrorf tables.
if object:
newtab = { }
for key, ritem in self.lexstatere.items():
newre = []
for cre, findex in ritem:
newfindex = []
for f in findex:
if not f or not f[0]:
newfindex.append(f)
continue
newfindex.append((getattr(object,f[0].__name__),f[1]))
newre.append((cre,newfindex))
newtab[key] = newre
c.lexstatere = newtab
c.lexstateerrorf = { }
for key, ef in self.lexstateerrorf.items():
c.lexstateerrorf[key] = getattr(object,ef.__name__)
c.lexmodule = object
return c
# ------------------------------------------------------------
# writetab() - Write lexer information to a table file
# ------------------------------------------------------------
def writetab(self,tabfile,outputdir=""):
if isinstance(tabfile,types.ModuleType):
return
basetabfilename = tabfile.split(".")[-1]
filename = os.path.join(outputdir,basetabfilename)+".py"
tf = open(filename,"w")
tf.write("# %s.py. This file automatically created by PLY (version %s). Don't edit!\n" % (tabfile,__version__))
tf.write("_tabversion = %s\n" % repr(__version__))
tf.write("_lextokens = %s\n" % repr(self.lextokens))
tf.write("_lexreflags = %s\n" % repr(self.lexreflags))
tf.write("_lexliterals = %s\n" % repr(self.lexliterals))
tf.write("_lexstateinfo = %s\n" % repr(self.lexstateinfo))
tabre = { }
# Collect all functions in the initial state
initial = self.lexstatere["INITIAL"]
initialfuncs = []
for part in initial:
for f in part[1]:
if f and f[0]:
initialfuncs.append(f)
for key, lre in self.lexstatere.items():
titem = []
for i in range(len(lre)):
titem.append((self.lexstateretext[key][i],_funcs_to_names(lre[i][1],self.lexstaterenames[key][i])))
tabre[key] = titem
tf.write("_lexstatere = %s\n" % repr(tabre))
tf.write("_lexstateignore = %s\n" % repr(self.lexstateignore))
taberr = { }
for key, ef in self.lexstateerrorf.items():
if ef:
taberr[key] = ef.__name__
else:
taberr[key] = None
tf.write("_lexstateerrorf = %s\n" % repr(taberr))
tf.close()
# ------------------------------------------------------------
# readtab() - Read lexer information from a tab file
# ------------------------------------------------------------
def readtab(self,tabfile,fdict):
if isinstance(tabfile,types.ModuleType):
lextab = tabfile
else:
if sys.version_info[0] < 3:
exec("import %s as lextab" % tabfile)
else:
env = { }
exec("import %s as lextab" % tabfile, env,env)
lextab = env['lextab']
if getattr(lextab,"_tabversion","0.0") != __version__:
raise ImportError("Inconsistent PLY version")
self.lextokens = lextab._lextokens
self.lexreflags = lextab._lexreflags
self.lexliterals = lextab._lexliterals
self.lexstateinfo = lextab._lexstateinfo
self.lexstateignore = lextab._lexstateignore
self.lexstatere = { }
self.lexstateretext = { }
for key,lre in lextab._lexstatere.items():
titem = []
txtitem = []
for i in range(len(lre)):
titem.append((re.compile(lre[i][0],lextab._lexreflags | re.VERBOSE),_names_to_funcs(lre[i][1],fdict)))
txtitem.append(lre[i][0])
self.lexstatere[key] = titem
self.lexstateretext[key] = txtitem
self.lexstateerrorf = { }
for key,ef in lextab._lexstateerrorf.items():
self.lexstateerrorf[key] = fdict[ef]
self.begin('INITIAL')
# ------------------------------------------------------------
# input() - Push a new string into the lexer
# ------------------------------------------------------------
def input(self,s):
# Pull off the first character to see if s looks like a string
c = s[:1]
if not isinstance(c,StringTypes):
raise ValueError("Expected a string")
self.lexdata = s
self.lexpos = 0
self.lexlen = len(s)
# ------------------------------------------------------------
# begin() - Changes the lexing state
# ------------------------------------------------------------
def begin(self,state):
if not state in self.lexstatere:
raise ValueError("Undefined state")
self.lexre = self.lexstatere[state]
self.lexretext = self.lexstateretext[state]
self.lexignore = self.lexstateignore.get(state,"")
self.lexerrorf = self.lexstateerrorf.get(state,None)
self.lexstate = state
# ------------------------------------------------------------
# push_state() - Changes the lexing state and saves old on stack
# ------------------------------------------------------------
def push_state(self,state):
self.lexstatestack.append(self.lexstate)
self.begin(state)
# ------------------------------------------------------------
# pop_state() - Restores the previous state
# ------------------------------------------------------------
def pop_state(self):
self.begin(self.lexstatestack.pop())
# ------------------------------------------------------------
# current_state() - Returns the current lexing state
# ------------------------------------------------------------
def current_state(self):
return self.lexstate
# ------------------------------------------------------------
# skip() - Skip ahead n characters
# ------------------------------------------------------------
def skip(self,n):
self.lexpos += n
# ------------------------------------------------------------
# opttoken() - Return the next token from the Lexer
#
# Note: This function has been carefully implemented to be as fast
# as possible. Don't make changes unless you really know what
# you are doing
# ------------------------------------------------------------
def token(self):
# Make local copies of frequently referenced attributes
lexpos = self.lexpos
lexlen = self.lexlen
lexignore = self.lexignore
lexdata = self.lexdata
while lexpos < lexlen:
# This code provides some short-circuit code for whitespace, tabs, and other ignored characters
if lexdata[lexpos] in lexignore:
lexpos += 1
continue
# Look for a regular expression match
for lexre,lexindexfunc in self.lexre:
m = lexre.match(lexdata,lexpos)
if not m: continue
# Create a token for return
tok = LexToken()
tok.value = m.group()
tok.lineno = self.lineno
tok.lexpos = lexpos
i = m.lastindex
func,tok.type = lexindexfunc[i]
if not func:
# If no token type was set, it's an ignored token
if tok.type:
self.lexpos = m.end()
return tok
else:
lexpos = m.end()
break
lexpos = m.end()
# If token is processed by a function, call it
tok.lexer = self # Set additional attributes useful in token rules
self.lexmatch = m
self.lexpos = lexpos
newtok = func(tok)
# Every function must return a token, if nothing, we just move to next token
if not newtok:
lexpos = self.lexpos # This is here in case user has updated lexpos.
lexignore = self.lexignore # This is here in case there was a state change
break
# Verify type of the token. If not in the token map, raise an error
if not self.lexoptimize:
if not newtok.type in self.lextokens:
raise LexError("%s:%d: Rule '%s' returned an unknown token type '%s'" % (
func_code(func).co_filename, func_code(func).co_firstlineno,
func.__name__, newtok.type),lexdata[lexpos:])
return newtok
else:
# No match, see if in literals
if lexdata[lexpos] in self.lexliterals:
tok = LexToken()
tok.value = lexdata[lexpos]
tok.lineno = self.lineno
tok.type = tok.value
tok.lexpos = lexpos
self.lexpos = lexpos + 1
return tok
# No match. Call t_error() if defined.
if self.lexerrorf:
tok = LexToken()
tok.value = self.lexdata[lexpos:]
tok.lineno = self.lineno
tok.type = "error"
tok.lexer = self
tok.lexpos = lexpos
self.lexpos = lexpos
newtok = self.lexerrorf(tok)
if lexpos == self.lexpos:
# Error method didn't change text position at all. This is an error.
raise LexError("Scanning error. Illegal character '%s'" % (lexdata[lexpos]), lexdata[lexpos:])
lexpos = self.lexpos
if not newtok: continue
return newtok
self.lexpos = lexpos
raise LexError("Illegal character '%s' at index %d" % (lexdata[lexpos],lexpos), lexdata[lexpos:])
self.lexpos = lexpos + 1
if self.lexdata is None:
raise RuntimeError("No input string given with input()")
return None
# Iterator interface
def __iter__(self):
return self
def next(self):
t = self.token()
if t is None:
raise StopIteration
return t
__next__ = next
# -----------------------------------------------------------------------------
# ==== Lex Builder ===
#
# The functions and classes below are used to collect lexing information
# and build a Lexer object from it.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# get_caller_module_dict()
#
# This function returns a dictionary containing all of the symbols defined within
# a caller further down the call stack. This is used to get the environment
# associated with the yacc() call if none was provided.
# -----------------------------------------------------------------------------
def get_caller_module_dict(levels):
try:
raise RuntimeError
except RuntimeError:
e,b,t = sys.exc_info()
f = t.tb_frame
while levels > 0:
f = f.f_back
levels -= 1
ldict = f.f_globals.copy()
if f.f_globals != f.f_locals:
ldict.update(f.f_locals)
return ldict
# -----------------------------------------------------------------------------
# _funcs_to_names()
#
# Given a list of regular expression functions, this converts it to a list
# suitable for output to a table file
# -----------------------------------------------------------------------------
def _funcs_to_names(funclist,namelist):
result = []
for f,name in zip(funclist,namelist):
if f and f[0]:
result.append((name, f[1]))
else:
result.append(f)
return result
# -----------------------------------------------------------------------------
# _names_to_funcs()
#
# Given a list of regular expression function names, this converts it back to
# functions.
# -----------------------------------------------------------------------------
def _names_to_funcs(namelist,fdict):
result = []
for n in namelist:
if n and n[0]:
result.append((fdict[n[0]],n[1]))
else:
result.append(n)
return result
# -----------------------------------------------------------------------------
# _form_master_re()
#
# This function takes a list of all of the regex components and attempts to
# form the master regular expression. Given limitations in the Python re
# module, it may be necessary to break the master regex into separate expressions.
# -----------------------------------------------------------------------------
def _form_master_re(relist,reflags,ldict,toknames):
if not relist: return []
regex = "|".join(relist)
try:
lexre = re.compile(regex,re.VERBOSE | reflags)
# Build the index to function map for the matching engine
lexindexfunc = [ None ] * (max(lexre.groupindex.values())+1)
lexindexnames = lexindexfunc[:]
for f,i in lexre.groupindex.items():
handle = ldict.get(f,None)
if type(handle) in (types.FunctionType, types.MethodType):
lexindexfunc[i] = (handle,toknames[f])
lexindexnames[i] = f
elif handle is not None:
lexindexnames[i] = f
if f.find("ignore_") > 0:
lexindexfunc[i] = (None,None)
else:
lexindexfunc[i] = (None, toknames[f])
return [(lexre,lexindexfunc)],[regex],[lexindexnames]
except Exception:
m = int(len(relist)/2)
if m == 0: m = 1
llist, lre, lnames = _form_master_re(relist[:m],reflags,ldict,toknames)
rlist, rre, rnames = _form_master_re(relist[m:],reflags,ldict,toknames)
return llist+rlist, lre+rre, lnames+rnames
# -----------------------------------------------------------------------------
# def _statetoken(s,names)
#
# Given a declaration name s of the form "t_" and a dictionary whose keys are
# state names, this function returns a tuple (states,tokenname) where states
# is a tuple of state names and tokenname is the name of the token. For example,
# calling this with s = "t_foo_bar_SPAM" might return (('foo','bar'),'SPAM')
# -----------------------------------------------------------------------------
def _statetoken(s,names):
nonstate = 1
parts = s.split("_")
for i in range(1,len(parts)):
if not parts[i] in names and parts[i] != 'ANY': break
if i > 1:
states = tuple(parts[1:i])
else:
states = ('INITIAL',)
if 'ANY' in states:
states = tuple(names)
tokenname = "_".join(parts[i:])
return (states,tokenname)
# -----------------------------------------------------------------------------
# LexerReflect()
#
# This class represents information needed to build a lexer as extracted from a
# user's input file.
# -----------------------------------------------------------------------------
class LexerReflect(object):
def __init__(self,ldict,log=None,reflags=0):
self.ldict = ldict
self.error_func = None
self.tokens = []
self.reflags = reflags
self.stateinfo = { 'INITIAL' : 'inclusive'}
self.files = {}
self.error = 0
if log is None:
self.log = PlyLogger(sys.stderr)
else:
self.log = log
# Get all of the basic information
def get_all(self):
self.get_tokens()
self.get_literals()
self.get_states()
self.get_rules()
# Validate all of the information
def validate_all(self):
self.validate_tokens()
self.validate_literals()
self.validate_rules()
return self.error
# Get the tokens map
def get_tokens(self):
tokens = self.ldict.get("tokens",None)
if not tokens:
self.log.error("No token list is defined")
self.error = 1
return
if not isinstance(tokens,(list, tuple)):
self.log.error("tokens must be a list or tuple")
self.error = 1
return
if not tokens:
self.log.error("tokens is empty")
self.error = 1
return
self.tokens = tokens
# Validate the tokens
def validate_tokens(self):
terminals = {}
for n in self.tokens:
if not _is_identifier.match(n):
self.log.error("Bad token name '%s'",n)
self.error = 1
if n in terminals:
self.log.warning("Token '%s' multiply defined", n)
terminals[n] = 1
# Get the literals specifier
def get_literals(self):
self.literals = self.ldict.get("literals","")
# Validate literals
def validate_literals(self):
try:
for c in self.literals:
if not isinstance(c,StringTypes) or len(c) > 1:
self.log.error("Invalid literal %s. Must be a single character", repr(c))
self.error = 1
continue
except TypeError:
self.log.error("Invalid literals specification. literals must be a sequence of characters")
self.error = 1
def get_states(self):
self.states = self.ldict.get("states",None)
# Build statemap
if self.states:
if not isinstance(self.states,(tuple,list)):
self.log.error("states must be defined as a tuple or list")
self.error = 1
else:
for s in self.states:
if not isinstance(s,tuple) or len(s) != 2:
self.log.error("Invalid state specifier %s. Must be a tuple (statename,'exclusive|inclusive')",repr(s))
self.error = 1
continue
name, statetype = s
if not isinstance(name,StringTypes):
self.log.error("State name %s must be a string", repr(name))
self.error = 1
continue
if not (statetype == 'inclusive' or statetype == 'exclusive'):
self.log.error("State type for state %s must be 'inclusive' or 'exclusive'",name)
self.error = 1
continue
if name in self.stateinfo:
self.log.error("State '%s' already defined",name)
self.error = 1
continue
self.stateinfo[name] = statetype
# Get all of the symbols with a t_ prefix and sort them into various
# categories (functions, strings, error functions, and ignore characters)
def get_rules(self):
tsymbols = [f for f in self.ldict if f[:2] == 't_' ]
# Now build up a list of functions and a list of strings
self.toknames = { } # Mapping of symbols to token names
self.funcsym = { } # Symbols defined as functions
self.strsym = { } # Symbols defined as strings
self.ignore = { } # Ignore strings by state
self.errorf = { } # Error functions by state
for s in self.stateinfo:
self.funcsym[s] = []
self.strsym[s] = []
if len(tsymbols) == 0:
self.log.error("No rules of the form t_rulename are defined")
self.error = 1
return
for f in tsymbols:
t = self.ldict[f]
states, tokname = _statetoken(f,self.stateinfo)
self.toknames[f] = tokname
if hasattr(t,"__call__"):
if tokname == 'error':
for s in states:
self.errorf[s] = t
elif tokname == 'ignore':
line = func_code(t).co_firstlineno
file = func_code(t).co_filename
self.log.error("%s:%d: Rule '%s' must be defined as a string",file,line,t.__name__)
self.error = 1
else:
for s in states:
self.funcsym[s].append((f,t))
elif isinstance(t, StringTypes):
if tokname == 'ignore':
for s in states:
self.ignore[s] = t
if "\\" in t:
self.log.warning("%s contains a literal backslash '\\'",f)
elif tokname == 'error':
self.log.error("Rule '%s' must be defined as a function", f)
self.error = 1
else:
for s in states:
self.strsym[s].append((f,t))
else:
self.log.error("%s not defined as a function or string", f)
self.error = 1
# Sort the functions by line number
for f in self.funcsym.values():
if sys.version_info[0] < 3:
f.sort(lambda x,y: cmp(func_code(x[1]).co_firstlineno,func_code(y[1]).co_firstlineno))
else:
# Python 3.0
f.sort(key=lambda x: func_code(x[1]).co_firstlineno)
# Sort the strings by regular expression length
for s in self.strsym.values():
if sys.version_info[0] < 3:
s.sort(lambda x,y: (len(x[1]) < len(y[1])) - (len(x[1]) > len(y[1])))
else:
# Python 3.0
s.sort(key=lambda x: len(x[1]),reverse=True)
# Validate all of the t_rules collected
def validate_rules(self):
for state in self.stateinfo:
# Validate all rules defined by functions
for fname, f in self.funcsym[state]:
line = func_code(f).co_firstlineno
file = func_code(f).co_filename
self.files[file] = 1
tokname = self.toknames[fname]
if isinstance(f, types.MethodType):
reqargs = 2
else:
reqargs = 1
nargs = func_code(f).co_argcount
if nargs > reqargs:
self.log.error("%s:%d: Rule '%s' has too many arguments",file,line,f.__name__)
self.error = 1
continue
if nargs < reqargs:
self.log.error("%s:%d: Rule '%s' requires an argument", file,line,f.__name__)
self.error = 1
continue
if not f.__doc__:
self.log.error("%s:%d: No regular expression defined for rule '%s'",file,line,f.__name__)
self.error = 1
continue
try:
c = re.compile("(?P<%s>%s)" % (fname,f.__doc__), re.VERBOSE | self.reflags)
if c.match(""):
self.log.error("%s:%d: Regular expression for rule '%s' matches empty string", file,line,f.__name__)
self.error = 1
except re.error:
_etype, e, _etrace = sys.exc_info()
self.log.error("%s:%d: Invalid regular expression for rule '%s'. %s", file,line,f.__name__,e)
if '#' in f.__doc__:
self.log.error("%s:%d. Make sure '#' in rule '%s' is escaped with '\\#'",file,line, f.__name__)
self.error = 1
# Validate all rules defined by strings
for name,r in self.strsym[state]:
tokname = self.toknames[name]
if tokname == 'error':
self.log.error("Rule '%s' must be defined as a function", name)
self.error = 1
continue
if not tokname in self.tokens and tokname.find("ignore_") < 0:
self.log.error("Rule '%s' defined for an unspecified token %s",name,tokname)
self.error = 1
continue
try:
c = re.compile("(?P<%s>%s)" % (name,r),re.VERBOSE | self.reflags)
if (c.match("")):
self.log.error("Regular expression for rule '%s' matches empty string",name)
self.error = 1
except re.error:
_etype, e, _etrace = sys.exc_info()
self.log.error("Invalid regular expression for rule '%s'. %s",name,e)
if '#' in r:
self.log.error("Make sure '#' in rule '%s' is escaped with '\\#'",name)
self.error = 1
if not self.funcsym[state] and not self.strsym[state]:
self.log.error("No rules defined for state '%s'",state)
self.error = 1
# Validate the error function
efunc = self.errorf.get(state,None)
if efunc:
f = efunc
line = func_code(f).co_firstlineno
file = func_code(f).co_filename
self.files[file] = 1
if isinstance(f, types.MethodType):
reqargs = 2
else:
reqargs = 1
nargs = func_code(f).co_argcount
if nargs > reqargs:
self.log.error("%s:%d: Rule '%s' has too many arguments",file,line,f.__name__)
self.error = 1
if nargs < reqargs:
self.log.error("%s:%d: Rule '%s' requires an argument", file,line,f.__name__)
self.error = 1
for f in self.files:
self.validate_file(f)
# -----------------------------------------------------------------------------
# validate_file()
#
# This checks to see if there are duplicated t_rulename() functions or strings
# in the parser input file. This is done using a simple regular expression
# match on each line in the given file.
# -----------------------------------------------------------------------------
def validate_file(self,filename):
import os.path
base,ext = os.path.splitext(filename)
if ext != '.py': return # No idea what the file is. Return OK
try:
f = open(filename)
lines = f.readlines()
f.close()
except IOError:
return # Couldn't find the file. Don't worry about it
fre = re.compile(r'\s*def\s+(t_[a-zA-Z_0-9]*)\(')
sre = re.compile(r'\s*(t_[a-zA-Z_0-9]*)\s*=')
counthash = { }
linen = 1
for l in lines:
m = fre.match(l)
if not m:
m = sre.match(l)
if m:
name = m.group(1)
prev = counthash.get(name)
if not prev:
counthash[name] = linen
else:
self.log.error("%s:%d: Rule %s redefined. Previously defined on line %d",filename,linen,name,prev)
self.error = 1
linen += 1
# -----------------------------------------------------------------------------
# lex(module)
#
# Build all of the regular expression rules from definitions in the supplied module
# -----------------------------------------------------------------------------
def lex(module=None,object=None,debug=0,optimize=0,lextab="lextab",reflags=0,nowarn=0,outputdir="", debuglog=None, errorlog=None):
global lexer
ldict = None
stateinfo = { 'INITIAL' : 'inclusive'}
lexobj = Lexer()
lexobj.lexoptimize = optimize
global token,input
if errorlog is None:
errorlog = PlyLogger(sys.stderr)
if debug:
if debuglog is None:
debuglog = PlyLogger(sys.stderr)
# Get the module dictionary used for the lexer
if object: module = object
if module:
_items = [(k,getattr(module,k)) for k in dir(module)]
ldict = dict(_items)
else:
ldict = get_caller_module_dict(2)
# Collect parser information from the dictionary
linfo = LexerReflect(ldict,log=errorlog,reflags=reflags)
linfo.get_all()
if not optimize:
if linfo.validate_all():
raise SyntaxError("Can't build lexer")
if optimize and lextab:
try:
lexobj.readtab(lextab,ldict)
token = lexobj.token
input = lexobj.input
lexer = lexobj
return lexobj
except ImportError:
pass
# Dump some basic debugging information
if debug:
debuglog.info("lex: tokens = %r", linfo.tokens)
debuglog.info("lex: literals = %r", linfo.literals)
debuglog.info("lex: states = %r", linfo.stateinfo)
# Build a dictionary of valid token names
lexobj.lextokens = { }
for n in linfo.tokens:
lexobj.lextokens[n] = 1
# Get literals specification
if isinstance(linfo.literals,(list,tuple)):
lexobj.lexliterals = type(linfo.literals[0])().join(linfo.literals)
else:
lexobj.lexliterals = linfo.literals
# Get the stateinfo dictionary
stateinfo = linfo.stateinfo
regexs = { }
# Build the master regular expressions
for state in stateinfo:
regex_list = []
# Add rules defined by functions first
for fname, f in linfo.funcsym[state]:
line = func_code(f).co_firstlineno
file = func_code(f).co_filename
regex_list.append("(?P<%s>%s)" % (fname,f.__doc__))
if debug:
debuglog.info("lex: Adding rule %s -> '%s' (state '%s')",fname,f.__doc__, state)
# Now add all of the simple rules
for name,r in linfo.strsym[state]:
regex_list.append("(?P<%s>%s)" % (name,r))
if debug:
debuglog.info("lex: Adding rule %s -> '%s' (state '%s')",name,r, state)
regexs[state] = regex_list
# Build the master regular expressions
if debug:
debuglog.info("lex: ==== MASTER REGEXS FOLLOW ====")
for state in regexs:
lexre, re_text, re_names = _form_master_re(regexs[state],reflags,ldict,linfo.toknames)
lexobj.lexstatere[state] = lexre
lexobj.lexstateretext[state] = re_text
lexobj.lexstaterenames[state] = re_names
if debug:
for i in range(len(re_text)):
debuglog.info("lex: state '%s' : regex[%d] = '%s'",state, i, re_text[i])
# For inclusive states, we need to add the regular expressions from the INITIAL state
for state,stype in stateinfo.items():
if state != "INITIAL" and stype == 'inclusive':
lexobj.lexstatere[state].extend(lexobj.lexstatere['INITIAL'])
lexobj.lexstateretext[state].extend(lexobj.lexstateretext['INITIAL'])
lexobj.lexstaterenames[state].extend(lexobj.lexstaterenames['INITIAL'])
lexobj.lexstateinfo = stateinfo
lexobj.lexre = lexobj.lexstatere["INITIAL"]
lexobj.lexretext = lexobj.lexstateretext["INITIAL"]
lexobj.lexreflags = reflags
# Set up ignore variables
lexobj.lexstateignore = linfo.ignore
lexobj.lexignore = lexobj.lexstateignore.get("INITIAL","")
# Set up error functions
lexobj.lexstateerrorf = linfo.errorf
lexobj.lexerrorf = linfo.errorf.get("INITIAL",None)
if not lexobj.lexerrorf:
errorlog.warning("No t_error rule is defined")
# Check state information for ignore and error rules
for s,stype in stateinfo.items():
if stype == 'exclusive':
if not s in linfo.errorf:
errorlog.warning("No error rule is defined for exclusive state '%s'", s)
if not s in linfo.ignore and lexobj.lexignore:
errorlog.warning("No ignore rule is defined for exclusive state '%s'", s)
elif stype == 'inclusive':
if not s in linfo.errorf:
linfo.errorf[s] = linfo.errorf.get("INITIAL",None)
if not s in linfo.ignore:
linfo.ignore[s] = linfo.ignore.get("INITIAL","")
# Create global versions of the token() and input() functions
token = lexobj.token
input = lexobj.input
lexer = lexobj
# If in optimize mode, we write the lextab
if lextab and optimize:
lexobj.writetab(lextab,outputdir)
return lexobj
# -----------------------------------------------------------------------------
# runmain()
#
# This runs the lexer as a main program
# -----------------------------------------------------------------------------
def runmain(lexer=None,data=None):
if not data:
try:
filename = sys.argv[1]
f = open(filename)
data = f.read()
f.close()
except IndexError:
sys.stdout.write("Reading from standard input (type EOF to end):\n")
data = sys.stdin.read()
if lexer:
_input = lexer.input
else:
_input = input
_input(data)
if lexer:
_token = lexer.token
else:
_token = token
while 1:
tok = _token()
if not tok: break
sys.stdout.write("(%s,%r,%d,%d)\n" % (tok.type, tok.value, tok.lineno,tok.lexpos))
# -----------------------------------------------------------------------------
# @TOKEN(regex)
#
# This decorator function can be used to set the regex expression on a function
# when its docstring might need to be set in an alternative way
# -----------------------------------------------------------------------------
def TOKEN(r):
def set_doc(f):
if hasattr(r,"__call__"):
f.__doc__ = r.__doc__
else:
f.__doc__ = r
return f
return set_doc
# Alternative spelling of the TOKEN decorator
Token = TOKEN
|
gpl-3.0
|
[
3,
13722,
199,
3,
299,
590,
26,
7103,
14,
647,
199,
3,
199,
3,
1898,
334,
35,
9,
12521,
13,
8128,
12,
199,
3,
20232,
603,
14,
13787,
90,
15515,
334,
36,
371,
4489,
90,
20376,
9,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
221,
199,
3,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
199,
3,
257,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
257,
199,
3,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
221,
199,
3,
257,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
257,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
257,
199,
3,
627,
11443,
314,
536,
402,
314,
20232,
13787,
90,
15515,
503,
577,
371,
4489,
90,
20376,
1443,
506,
1202,
370,
199,
3,
257,
10692,
503,
10016,
7585,
7131,
687,
642,
2032,
1928,
199,
3,
221,
2488,
6791,
5313,
4983,
14,
221,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
13722,
199,
199,
363,
1023,
363,
259,
275,
298,
19,
14,
20,
2,
199,
363,
2902,
1023,
363,
275,
298,
19,
14,
18,
2,
755,
327,
3394,
402,
1817,
570,
1202,
199,
199,
646,
295,
12,
984,
12,
2943,
12,
1331,
12,
747,
199,
199,
3,
961,
2008,
3509,
6040,
1059,
2943,
199,
893,
26,
272,
327,
2018,
499,
14,
22,
272,
2624,
4100,
275,
334,
1313,
14,
22463,
12,
2943,
14,
7087,
804,
9,
199,
2590,
4281,
26,
272,
327,
2018,
650,
14,
16,
272,
2624,
4100,
275,
334,
495,
12,
2783,
9,
199,
199,
3,
12892,
314,
1233,
2225,
402,
282,
805,
14,
18029,
640,
12591,
199,
3,
787,
367,
2018,
499,
15,
19,
7163,
14,
199,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
26,
272,
347,
2562,
63,
600,
8,
70,
304,
267,
372,
289,
14,
1532,
63,
600,
199,
2836,
26,
272,
347,
2562,
63,
600,
8,
70,
304,
267,
372,
289,
855,
600,
363,
199,
199,
3,
961,
5578,
3965,
365,
1202,
370,
1336,
1686,
1526,
1561,
199,
63,
374,
63,
5364,
275,
295,
14,
2014,
8,
82,
23811,
65,
13,
6353,
13,
58,
16,
13,
25,
22155,
9988,
199,
199,
3,
2186,
14031,
1380,
3866,
1526,
14556,
436,
949,
849,
1125,
199,
3,
3016,
365,
3247,
14,
199,
199,
533,
491,
476,
547,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1188,
12,
83,
304,
268,
291,
14,
589,
275,
334,
1188,
4258,
268,
291,
14,
505,
275,
308,
199,
199,
3,
8767,
1021,
14,
221,
961,
1021,
365,
1202,
370,
2954,
314,
4645,
13584,
14,
199,
533,
491,
476,
3264,
8,
785,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
298,
44,
476,
3264,
4042,
83,
8719,
82,
8719,
68,
8719,
68,
2924,
450,
334,
277,
14,
466,
12,
277,
14,
585,
12,
277,
14,
3469,
12,
277,
14,
25151,
9,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
620,
8,
277,
9,
199,
199,
3,
961,
909,
365,
282,
10584,
13,
262,
367,
282,
2050,
909,
2737,
701,
314,
221,
199,
3,
2050,
859,
14,
257,
199,
199,
533,
510,
590,
4455,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
70,
304,
267,
291,
14,
70,
275,
289,
272,
347,
19698,
8,
277,
12,
1328,
19166,
589,
12663,
958,
304,
267,
291,
14,
70,
14,
952,
1332,
1328,
450,
1249,
9,
435,
1867,
78,
531,
339,
347,
5721,
8,
277,
12,
1328,
19166,
589,
12663,
958,
304,
267,
291,
14,
70,
14,
952,
480,
9171,
26,
7210,
334,
1328,
450,
1249,
9,
435,
1867,
78,
531,
339,
347,
1125,
8,
277,
12,
1328,
19166,
589,
12663,
958,
304,
267,
291,
14,
70,
14,
952,
480,
3170,
26,
298,
435,
334,
1328,
450,
1249,
9,
435,
1867,
78,
531,
339,
2256,
275,
19698,
272,
3105,
275,
19698,
199,
199,
3,
12119,
2512,
365,
1202,
1380,
949,
1072,
365,
4046,
14,
12078,
6548,
14,
199,
533,
12119,
4455,
8,
785,
304,
272,
347,
636,
18480,
721,
277,
12,
354,
304,
267,
372,
291,
272,
347,
636,
1250,
721,
277,
19166,
589,
12663,
958,
304,
267,
372,
291,
199,
199,
3,
13722,
199,
3,
12788,
24768,
491,
476,
316,
12580,
24768,
199,
3,
199,
3,
710,
2569,
21125,
1021,
9031,
314,
10426,
8836,
14,
257,
6006,
787,
1454,
199,
3,
282,
9284,
4575,
3102,
436,
3004,
26,
199,
3,
199,
3,
259,
1324,
342,
3515,
446,
221,
13874,
282,
892,
1059,
315,
314,
10426,
199,
3,
259,
1526,
342,
3515,
446,
221,
2372,
314,
2163,
1526,
199,
3,
259,
7289,
342,
3515,
446,
221,
8465,
368,
314,
10426,
199,
3,
199,
3,
259,
5874,
3698,
446,
221,
9338,
1004,
1329,
199,
3,
259,
7103,
1712,
3698,
446,
221,
9338,
3421,
315,
314,
1324,
1059,
199,
3,
13722,
199,
199,
533,
21125,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
3113,
264,
275,
488,
3777,
327,
26728,
5578,
3965,
14,
961,
365,
282,
769,
402,
4228
] |
[
13722,
199,
3,
299,
590,
26,
7103,
14,
647,
199,
3,
199,
3,
1898,
334,
35,
9,
12521,
13,
8128,
12,
199,
3,
20232,
603,
14,
13787,
90,
15515,
334,
36,
371,
4489,
90,
20376,
9,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
221,
199,
3,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
4245,
12,
199,
3,
257,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
257,
199,
3,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
221,
199,
3,
257,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
257,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
257,
199,
3,
627,
11443,
314,
536,
402,
314,
20232,
13787,
90,
15515,
503,
577,
371,
4489,
90,
20376,
1443,
506,
1202,
370,
199,
3,
257,
10692,
503,
10016,
7585,
7131,
687,
642,
2032,
1928,
199,
3,
221,
2488,
6791,
5313,
4983,
14,
221,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
13722,
199,
199,
363,
1023,
363,
259,
275,
298,
19,
14,
20,
2,
199,
363,
2902,
1023,
363,
275,
298,
19,
14,
18,
2,
755,
327,
3394,
402,
1817,
570,
1202,
199,
199,
646,
295,
12,
984,
12,
2943,
12,
1331,
12,
747,
199,
199,
3,
961,
2008,
3509,
6040,
1059,
2943,
199,
893,
26,
272,
327,
2018,
499,
14,
22,
272,
2624,
4100,
275,
334,
1313,
14,
22463,
12,
2943,
14,
7087,
804,
9,
199,
2590,
4281,
26,
272,
327,
2018,
650,
14,
16,
272,
2624,
4100,
275,
334,
495,
12,
2783,
9,
199,
199,
3,
12892,
314,
1233,
2225,
402,
282,
805,
14,
18029,
640,
12591,
199,
3,
787,
367,
2018,
499,
15,
19,
7163,
14,
199,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
26,
272,
347,
2562,
63,
600,
8,
70,
304,
267,
372,
289,
14,
1532,
63,
600,
199,
2836,
26,
272,
347,
2562,
63,
600,
8,
70,
304,
267,
372,
289,
855,
600,
363,
199,
199,
3,
961,
5578,
3965,
365,
1202,
370,
1336,
1686,
1526,
1561,
199,
63,
374,
63,
5364,
275,
295,
14,
2014,
8,
82,
23811,
65,
13,
6353,
13,
58,
16,
13,
25,
22155,
9988,
199,
199,
3,
2186,
14031,
1380,
3866,
1526,
14556,
436,
949,
849,
1125,
199,
3,
3016,
365,
3247,
14,
199,
199,
533,
491,
476,
547,
8,
1726,
304,
272,
347,
636,
826,
721,
277,
12,
1188,
12,
83,
304,
268,
291,
14,
589,
275,
334,
1188,
4258,
268,
291,
14,
505,
275,
308,
199,
199,
3,
8767,
1021,
14,
221,
961,
1021,
365,
1202,
370,
2954,
314,
4645,
13584,
14,
199,
533,
491,
476,
3264,
8,
785,
304,
272,
347,
636,
495,
721,
277,
304,
267,
372,
298,
44,
476,
3264,
4042,
83,
8719,
82,
8719,
68,
8719,
68,
2924,
450,
334,
277,
14,
466,
12,
277,
14,
585,
12,
277,
14,
3469,
12,
277,
14,
25151,
9,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
620,
8,
277,
9,
199,
199,
3,
961,
909,
365,
282,
10584,
13,
262,
367,
282,
2050,
909,
2737,
701,
314,
221,
199,
3,
2050,
859,
14,
257,
199,
199,
533,
510,
590,
4455,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
70,
304,
267,
291,
14,
70,
275,
289,
272,
347,
19698,
8,
277,
12,
1328,
19166,
589,
12663,
958,
304,
267,
291,
14,
70,
14,
952,
1332,
1328,
450,
1249,
9,
435,
1867,
78,
531,
339,
347,
5721,
8,
277,
12,
1328,
19166,
589,
12663,
958,
304,
267,
291,
14,
70,
14,
952,
480,
9171,
26,
7210,
334,
1328,
450,
1249,
9,
435,
1867,
78,
531,
339,
347,
1125,
8,
277,
12,
1328,
19166,
589,
12663,
958,
304,
267,
291,
14,
70,
14,
952,
480,
3170,
26,
298,
435,
334,
1328,
450,
1249,
9,
435,
1867,
78,
531,
339,
2256,
275,
19698,
272,
3105,
275,
19698,
199,
199,
3,
12119,
2512,
365,
1202,
1380,
949,
1072,
365,
4046,
14,
12078,
6548,
14,
199,
533,
12119,
4455,
8,
785,
304,
272,
347,
636,
18480,
721,
277,
12,
354,
304,
267,
372,
291,
272,
347,
636,
1250,
721,
277,
19166,
589,
12663,
958,
304,
267,
372,
291,
199,
199,
3,
13722,
199,
3,
12788,
24768,
491,
476,
316,
12580,
24768,
199,
3,
199,
3,
710,
2569,
21125,
1021,
9031,
314,
10426,
8836,
14,
257,
6006,
787,
1454,
199,
3,
282,
9284,
4575,
3102,
436,
3004,
26,
199,
3,
199,
3,
259,
1324,
342,
3515,
446,
221,
13874,
282,
892,
1059,
315,
314,
10426,
199,
3,
259,
1526,
342,
3515,
446,
221,
2372,
314,
2163,
1526,
199,
3,
259,
7289,
342,
3515,
446,
221,
8465,
368,
314,
10426,
199,
3,
199,
3,
259,
5874,
3698,
446,
221,
9338,
1004,
1329,
199,
3,
259,
7103,
1712,
3698,
446,
221,
9338,
3421,
315,
314,
1324,
1059,
199,
3,
13722,
199,
199,
533,
21125,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
3113,
264,
275,
488,
3777,
327,
26728,
5578,
3965,
14,
961,
365,
282,
769,
402,
4228,
0
] |
[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] |
fusic-com/flask-webcache
|
tests/test_storage.py
|
1
|
12927
|
from __future__ import unicode_literals
import unittest
from datetime import timedelta, datetime
from six.moves.cPickle import dumps, loads
from six import iteritems
from flask import Flask, send_file
from werkzeug.wrappers import Response
from werkzeug.datastructures import HeaderSet
from werkzeug.contrib.cache import SimpleCache
from flask_webcache.storage import Config, Metadata, Store, Retrieval
from flask_webcache.storage import (CacheMiss, NoResourceMetadata, NoMatchingRepresentation, NotFreshEnoughForClient,
RecacheRequested)
from flask_webcache.recache import RECACHE_HEADER
from flask_webcache.utils import werkzeug_cache_get_or_add
from testutils import compare_numbers
a = Flask(__name__)
class UtilsTestCase(unittest.TestCase):
def test_config_kwargs(self):
with self.assertRaises(TypeError):
Config(foo=1)
def test_metadata_datastructure(self):
def check_metadata(m):
self.assertEquals(m.salt, 'qux')
self.assertIn('foo', m.vary)
self.assertIn('bar', m.vary)
m = Metadata(HeaderSet(('foo', 'bar')), 'qux')
check_metadata(m)
check_metadata(loads(dumps(m)))
m2 = Metadata(HeaderSet(('foo', 'bar')), 'qux')
self.assertEquals(m, m2)
m3 = Metadata(HeaderSet(('foo', 'bar')), 'notqux')
self.assertNotEquals(m2, m3)
class StorageTestCase(unittest.TestCase):
def setUp(self):
self.c = SimpleCache()
self.s = Store(self.c)
self.r = Retrieval(self.c)
def test_basic_cachability(self):
with a.test_request_context('/foo'):
self.assertFalse(self.s.should_cache_response(Response(x for x in 'foo')))
self.assertTrue(self.s.should_cache_response(Response(status=204)))
self.assertFalse(self.s.should_cache_response(Response(status=500)))
self.assertTrue(self.s.should_cache_response(Response('foo')))
self.assertTrue(self.s.should_cache_response(Response()))
r = Response()
r.vary.add('*')
self.assertFalse(self.s.should_cache_response(r))
with a.test_request_context('/foo', method='HEAD'):
self.assertFalse(self.s.should_cache_response(Response('foo')))
with a.test_request_context('/foo', method='POST'):
self.assertFalse(self.s.should_cache_response(Response('foo')))
def test_cache_control_cachability(self):
def check_response_with_cache_control(**cc):
r = Response()
for k, v in iteritems(cc):
setattr(r.cache_control, k, v)
return self.s.should_cache_response(r)
with a.test_request_context():
self.assertTrue(check_response_with_cache_control(max_age=10))
self.assertTrue(check_response_with_cache_control(must_revalidate=True))
self.assertFalse(check_response_with_cache_control(max_age=0))
self.assertFalse(check_response_with_cache_control(private=True))
self.assertFalse(check_response_with_cache_control(no_cache=True))
self.assertFalse(check_response_with_cache_control(no_store=True))
def test_expire_cachability(self):
def check_response_with_expires(dt):
r = Response()
r.expires = dt
return self.s.should_cache_response(r)
with a.test_request_context():
self.assertFalse(check_response_with_expires(datetime.utcnow() - timedelta(seconds=1)))
self.assertTrue(check_response_with_expires(datetime.utcnow() + timedelta(seconds=1)))
def test_default_cachability(self):
with a.test_request_context('/foo'):
self.assertTrue(self.s.should_cache_response(Response()))
with a.test_request_context('/foo', query_string='?bar'):
self.assertFalse(self.s.should_cache_response(Response()))
def test_x_cache_headers(self):
r = Response()
self.s.mark_cache_hit(r)
self.assertEquals(r.headers[self.s.X_CACHE_HEADER], 'hit')
self.s.mark_cache_miss(r)
self.assertEquals(r.headers[self.s.X_CACHE_HEADER], 'miss')
def test_metadata_miss(self):
with self.assertRaises(NoResourceMetadata):
with a.test_request_context('/foo'):
self.r.fetch_metadata()
def test_response_miss(self):
with self.assertRaises(NoResourceMetadata):
with a.test_request_context('/foo'):
self.r.fetch_response()
def test_store_retrieve_cycle(self):
with a.test_request_context('/foo'):
r = Response('foo')
self.s.cache_response(r)
self.assertEquals(len(self.c._cache), 2)
r2 = self.r.fetch_response()
self.assertEquals(r.data, r2.data)
def test_vary_miss(self):
with a.test_request_context('/foo', headers=(('accept-encoding', 'gzip'),)):
r = Response('foo')
r.vary.add('accept-encoding')
r.content_encoding = 'gzip'
self.s.cache_response(r)
with self.assertRaises(NoMatchingRepresentation):
with a.test_request_context('/foo'):
self.r.fetch_response()
def test_invalidation_condition(self):
with a.test_request_context('/foo', method="PUT"):
r = Response('foo')
self.assertTrue(self.s.should_invalidate_resource(r))
r = Response('foo', status=500)
self.assertFalse(self.s.should_invalidate_resource(r))
with a.test_request_context('/foo'):
r = Response('foo')
self.assertFalse(self.s.should_invalidate_resource(r))
def test_invalidation(self):
with a.test_request_context('/foo'):
r = Response('foo')
self.s.cache_response(r)
self.assertEquals(len(self.c._cache), 2)
with a.test_request_context('/foo', method="PUT"):
r = Response('foo')
self.assertTrue(self.s.should_invalidate_resource(r))
self.s.invalidate_resource()
self.assertEquals(len(self.c._cache), 1)
with self.assertRaises(CacheMiss):
with a.test_request_context('/foo'):
self.r.fetch_response()
def test_master_salt_invalidation(self):
with a.test_request_context('/foo'):
r = Response('foo')
self.s.cache_response(r)
self.assertEquals(self.r.fetch_response().data, b'foo')
self.r.config.master_salt = 'newsalt'
with self.assertRaises(NoMatchingRepresentation):
self.r.fetch_response()
def test_request_cache_controls(self):
with a.test_request_context('/foo'):
self.assertTrue(self.r.should_fetch_response())
with a.test_request_context('/foo', method='HEAD'):
self.assertTrue(self.r.should_fetch_response())
with a.test_request_context('/foo', method='POST'):
self.assertFalse(self.r.should_fetch_response())
with a.test_request_context('/foo', headers=(('cache-control', 'no-cache'),)):
self.assertFalse(self.r.should_fetch_response())
with a.test_request_context('/foo', headers=(('pragma', 'no-cache'),)):
self.assertFalse(self.r.should_fetch_response())
with a.test_request_context('/foo', headers=(('cache-control', 'max-age=0'),)):
self.assertFalse(self.r.should_fetch_response())
with a.test_request_context('/foo', headers=(('cache-control', 'max-age=5'),)):
self.assertTrue(self.r.should_fetch_response())
def test_response_freshness_seconds(self):
# this test is raced; if running it takes about a second, it might fail
r = Response()
self.assertEquals(0, self.r.response_freshness_seconds(r))
r.date = datetime.utcnow()
self.assertTrue(compare_numbers(self.s.DEFAULT_EXPIRATION_SECONDS,
self.r.response_freshness_seconds(r),
1))
r.expires = datetime.utcnow() + timedelta(seconds=345)
self.assertTrue(compare_numbers(345, self.r.response_freshness_seconds(r), 1))
r.cache_control.max_age=789
self.assertTrue(compare_numbers(789, self.r.response_freshness_seconds(r), 1))
def test_min_fresh(self):
# this test is raced; if running it takes about a second, it might fail
r = Response()
r.date = datetime.utcnow() - timedelta(seconds=100)
r.cache_control.max_age = 200
f = self.r.response_freshness_seconds(r)
with a.test_request_context('/foo', headers=(('cache-control', 'min-fresh=50'),)):
try:
self.r.verify_response_freshness_or_miss(r, f)
except CacheMiss:
self.fail('unexpected CacheMiss on reasonably fresh response')
with a.test_request_context('/foo', headers=(('cache-control', 'min-fresh=150'),)):
self.assertRaises(NotFreshEnoughForClient, self.r.verify_response_freshness_or_miss, r, f)
def test_request_cache_control_disobedience(self):
c = SimpleCache()
cfg = Config(request_controls_cache=False)
s = Store(c, cfg)
r = Retrieval(c, cfg)
with a.test_request_context('/foo', headers=(('cache-control', 'no-store'),)):
self.assertTrue(r.should_fetch_response())
with a.test_request_context('/foo', headers=(('cache-control', 'no-store'),)):
self.assertTrue(s.should_cache_response(Response()))
with a.test_request_context('/foo', headers=(('cache-control', 'no-store'),)):
self.assertTrue(s.should_cache_response(Response()))
resp = Response()
resp.date = datetime.utcnow() - timedelta(seconds=100)
resp.cache_control.max_age = 200
with a.test_request_context('/foo', headers=(('cache-control', 'min-fresh=150'),)):
f = self.r.response_freshness_seconds(resp)
try:
r.verify_response_freshness_or_miss(resp, f)
except CacheMiss:
self.fail('unexpected CacheMiss when ignoring request cache control')
def test_sequence_converted_responses(self):
with a.test_request_context('/foo'):
r = Response(f for f in 'foo')
r.make_sequence()
self.assertFalse(self.s.should_cache_response(r))
r = send_file(__file__)
r.make_sequence()
self.assertFalse(self.s.should_cache_response(r))
class RecacheTestCase(unittest.TestCase):
def setUp(self):
self.recached = False
def dispatcher(salt):
self.recached = True
self.c = SimpleCache()
cfg = Config(preemptive_recache_seconds=10, preemptive_recache_callback=dispatcher)
self.s = Store(self.c, cfg)
self.r = Retrieval(self.c, cfg)
def test_preemptive_recaching_predicate(self):
m = Metadata(HeaderSet(('foo', 'bar')), 'qux')
def mkretr(**kwargs):
return Retrieval(self.c, Config(**kwargs))
with a.test_request_context('/'):
self.assertFalse(mkretr(preemptive_recache_seconds=10).should_recache_preemptively(10, m))
self.assertFalse(mkretr(preemptive_recache_callback=lambda x: 0).should_recache_preemptively(10, m))
self.assertFalse(self.r.should_recache_preemptively(11, m))
self.assertTrue(self.r.should_recache_preemptively(10, m))
self.assertFalse(self.r.should_recache_preemptively(10, m))
self.c.clear()
self.assertTrue(self.r.should_recache_preemptively(10, m))
def test_preemptive_recaching_cache_bypass(self):
fresh = Response('foo')
with a.test_request_context('/foo'):
self.s.cache_response(fresh)
metadata = self.r.fetch_metadata()
with a.test_request_context('/foo'):
cached = self.r.fetch_response()
self.assertEquals(cached.headers[self.r.X_CACHE_HEADER], 'hit')
with a.test_request_context('/foo', headers={RECACHE_HEADER: metadata.salt}):
self.assertRaises(RecacheRequested, self.r.fetch_response)
with a.test_request_context('/foo', headers={RECACHE_HEADER: 'incorrect-salt'}):
try:
self.r.fetch_response()
except RecacheRequested:
self.fail('unexpected RecacheRequested for incorrect salt')
class UtilityTestCase(unittest.TestCase):
def setUp(self):
self.c = SimpleCache()
def test_werkzeug_cache_get_or_add_missing_key(self):
self.assertEquals('bar', werkzeug_cache_get_or_add(self.c, 'foo', 'bar', 10))
def test_werkzeug_cache_get_or_add_existing_key(self):
self.c.set('foo', 'bar')
self.assertEquals('bar', werkzeug_cache_get_or_add(self.c, 'foo', 'qux', 10))
|
mit
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
2882,
199,
504,
2197,
492,
6871,
12,
2197,
199,
504,
3816,
14,
4912,
14,
67,
12755,
492,
16864,
12,
14404,
199,
504,
3816,
492,
10849,
199,
199,
504,
7209,
492,
16704,
12,
3222,
63,
493,
199,
504,
10380,
14,
21148,
492,
7232,
199,
504,
10380,
14,
23004,
492,
10240,
1084,
199,
504,
10380,
14,
2828,
14,
1637,
492,
5870,
4437,
199,
504,
7209,
63,
2520,
1637,
14,
3494,
492,
4094,
12,
16160,
12,
13874,
12,
8747,
322,
2579,
199,
504,
7209,
63,
2520,
1637,
14,
3494,
492,
334,
4437,
5829,
83,
12,
3091,
4031,
5142,
12,
3091,
14215,
20609,
12,
2832,
38,
2107,
1327,
4937,
1858,
3041,
12,
2511,
799,
1637,
17935,
9,
199,
504,
7209,
63,
2520,
1637,
14,
264,
1637,
492,
5363,
8677,
63,
7311,
199,
504,
7209,
63,
2520,
1637,
14,
1208,
492,
10380,
63,
1637,
63,
362,
63,
269,
63,
525,
199,
199,
504,
511,
1208,
492,
6540,
63,
10548,
199,
65,
275,
16704,
3460,
354,
3368,
199,
199,
533,
17397,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
888,
63,
958,
8,
277,
304,
267,
543,
291,
14,
1855,
8,
4333,
304,
288,
4094,
8,
1421,
29,
17,
9,
339,
347,
511,
63,
2343,
63,
576,
6976,
8,
277,
304,
267,
347,
1104,
63,
2343,
8,
77,
304,
288,
291,
14,
2947,
8,
77,
14,
12597,
12,
283,
27519,
358,
288,
291,
14,
4080,
360,
1421,
297,
333,
14,
21989,
9,
288,
291,
14,
4080,
360,
1700,
297,
333,
14,
21989,
9,
267,
333,
275,
16160,
8,
2567,
1084,
4725,
1421,
297,
283,
1700,
3855,
283,
27519,
358,
267,
1104,
63,
2343,
8,
77,
9,
267,
1104,
63,
2343,
8,
3640,
8,
4180,
8,
77,
1724,
267,
333,
18,
275,
16160,
8,
2567,
1084,
4725,
1421,
297,
283,
1700,
3855,
283,
27519,
358,
267,
291,
14,
2947,
8,
77,
12,
333,
18,
9,
267,
333,
19,
275,
16160,
8,
2567,
1084,
4725,
1421,
297,
283,
1700,
3855,
283,
1397,
27519,
358,
267,
291,
14,
7418,
83,
8,
77,
18,
12,
333,
19,
9,
199,
199,
533,
10533,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
67,
275,
5870,
4437,
342,
267,
291,
14,
83,
275,
13874,
8,
277,
14,
67,
9,
267,
291,
14,
82,
275,
8747,
322,
2579,
8,
277,
14,
67,
9,
339,
347,
511,
63,
4316,
63,
20138,
3616,
8,
277,
304,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
8,
88,
367,
671,
315,
283,
1421,
7058,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
8,
1205,
29,
6686,
1724,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
8,
1205,
29,
5783,
1724,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
360,
1421,
7058,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
4059,
288,
519,
275,
7232,
342,
288,
519,
14,
21989,
14,
525,
360,
13418,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
82,
430,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
297,
1083,
534,
5211,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
360,
1421,
7058,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
297,
1083,
534,
4030,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
360,
1421,
7058,
339,
347,
511,
63,
1637,
63,
2785,
63,
20138,
3616,
8,
277,
304,
267,
347,
1104,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
3682,
2055,
304,
288,
519,
275,
7232,
342,
288,
367,
1022,
12,
373,
315,
10849,
8,
2055,
304,
355,
5371,
8,
82,
14,
1637,
63,
2785,
12,
1022,
12,
373,
9,
288,
372,
291,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
82,
9,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
837,
288,
291,
14,
1815,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
988,
63,
474,
29,
709,
430,
288,
291,
14,
1815,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
7790,
63,
264,
3502,
29,
549,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
988,
63,
474,
29,
16,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
4239,
29,
549,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
889,
63,
1637,
29,
549,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
889,
63,
1617,
29,
549,
430,
339,
347,
511,
63,
14691,
63,
20138,
3616,
8,
277,
304,
267,
347,
1104,
63,
1310,
63,
1045,
63,
12342,
8,
3583,
304,
288,
519,
275,
7232,
342,
288,
519,
14,
12342,
275,
4487,
288,
372,
291,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
82,
9,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
837,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
12342,
8,
2083,
14,
10779,
342,
446,
6871,
8,
4515,
29,
17,
1724,
288,
291,
14,
1815,
8,
1074,
63,
1310,
63,
1045,
63,
12342,
8,
2083,
14,
10779,
342,
435,
6871,
8,
4515,
29,
17,
1724,
339,
347,
511,
63,
885,
63,
20138,
3616,
8,
277,
304,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
735,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
4059,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
297,
1827,
63,
875,
534,
31,
1700,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
4059,
339,
347,
511,
63,
88,
63,
1637,
63,
2139,
8,
277,
304,
267,
519,
275
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
2882,
199,
504,
2197,
492,
6871,
12,
2197,
199,
504,
3816,
14,
4912,
14,
67,
12755,
492,
16864,
12,
14404,
199,
504,
3816,
492,
10849,
199,
199,
504,
7209,
492,
16704,
12,
3222,
63,
493,
199,
504,
10380,
14,
21148,
492,
7232,
199,
504,
10380,
14,
23004,
492,
10240,
1084,
199,
504,
10380,
14,
2828,
14,
1637,
492,
5870,
4437,
199,
504,
7209,
63,
2520,
1637,
14,
3494,
492,
4094,
12,
16160,
12,
13874,
12,
8747,
322,
2579,
199,
504,
7209,
63,
2520,
1637,
14,
3494,
492,
334,
4437,
5829,
83,
12,
3091,
4031,
5142,
12,
3091,
14215,
20609,
12,
2832,
38,
2107,
1327,
4937,
1858,
3041,
12,
2511,
799,
1637,
17935,
9,
199,
504,
7209,
63,
2520,
1637,
14,
264,
1637,
492,
5363,
8677,
63,
7311,
199,
504,
7209,
63,
2520,
1637,
14,
1208,
492,
10380,
63,
1637,
63,
362,
63,
269,
63,
525,
199,
199,
504,
511,
1208,
492,
6540,
63,
10548,
199,
65,
275,
16704,
3460,
354,
3368,
199,
199,
533,
17397,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
888,
63,
958,
8,
277,
304,
267,
543,
291,
14,
1855,
8,
4333,
304,
288,
4094,
8,
1421,
29,
17,
9,
339,
347,
511,
63,
2343,
63,
576,
6976,
8,
277,
304,
267,
347,
1104,
63,
2343,
8,
77,
304,
288,
291,
14,
2947,
8,
77,
14,
12597,
12,
283,
27519,
358,
288,
291,
14,
4080,
360,
1421,
297,
333,
14,
21989,
9,
288,
291,
14,
4080,
360,
1700,
297,
333,
14,
21989,
9,
267,
333,
275,
16160,
8,
2567,
1084,
4725,
1421,
297,
283,
1700,
3855,
283,
27519,
358,
267,
1104,
63,
2343,
8,
77,
9,
267,
1104,
63,
2343,
8,
3640,
8,
4180,
8,
77,
1724,
267,
333,
18,
275,
16160,
8,
2567,
1084,
4725,
1421,
297,
283,
1700,
3855,
283,
27519,
358,
267,
291,
14,
2947,
8,
77,
12,
333,
18,
9,
267,
333,
19,
275,
16160,
8,
2567,
1084,
4725,
1421,
297,
283,
1700,
3855,
283,
1397,
27519,
358,
267,
291,
14,
7418,
83,
8,
77,
18,
12,
333,
19,
9,
199,
199,
533,
10533,
1746,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
67,
275,
5870,
4437,
342,
267,
291,
14,
83,
275,
13874,
8,
277,
14,
67,
9,
267,
291,
14,
82,
275,
8747,
322,
2579,
8,
277,
14,
67,
9,
339,
347,
511,
63,
4316,
63,
20138,
3616,
8,
277,
304,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
8,
88,
367,
671,
315,
283,
1421,
7058,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
8,
1205,
29,
6686,
1724,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
8,
1205,
29,
5783,
1724,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
360,
1421,
7058,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
4059,
288,
519,
275,
7232,
342,
288,
519,
14,
21989,
14,
525,
360,
13418,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
82,
430,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
297,
1083,
534,
5211,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
360,
1421,
7058,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
297,
1083,
534,
4030,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
360,
1421,
7058,
339,
347,
511,
63,
1637,
63,
2785,
63,
20138,
3616,
8,
277,
304,
267,
347,
1104,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
3682,
2055,
304,
288,
519,
275,
7232,
342,
288,
367,
1022,
12,
373,
315,
10849,
8,
2055,
304,
355,
5371,
8,
82,
14,
1637,
63,
2785,
12,
1022,
12,
373,
9,
288,
372,
291,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
82,
9,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
837,
288,
291,
14,
1815,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
988,
63,
474,
29,
709,
430,
288,
291,
14,
1815,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
7790,
63,
264,
3502,
29,
549,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
988,
63,
474,
29,
16,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
4239,
29,
549,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
889,
63,
1637,
29,
549,
430,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
1637,
63,
2785,
8,
889,
63,
1617,
29,
549,
430,
339,
347,
511,
63,
14691,
63,
20138,
3616,
8,
277,
304,
267,
347,
1104,
63,
1310,
63,
1045,
63,
12342,
8,
3583,
304,
288,
519,
275,
7232,
342,
288,
519,
14,
12342,
275,
4487,
288,
372,
291,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
82,
9,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
837,
288,
291,
14,
3334,
8,
1074,
63,
1310,
63,
1045,
63,
12342,
8,
2083,
14,
10779,
342,
446,
6871,
8,
4515,
29,
17,
1724,
288,
291,
14,
1815,
8,
1074,
63,
1310,
63,
1045,
63,
12342,
8,
2083,
14,
10779,
342,
435,
6871,
8,
4515,
29,
17,
1724,
339,
347,
511,
63,
885,
63,
20138,
3616,
8,
277,
304,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
735,
288,
291,
14,
1815,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
4059,
267,
543,
282,
14,
396,
63,
1069,
63,
1100,
2336,
1421,
297,
1827,
63,
875,
534,
31,
1700,
735,
288,
291,
14,
3334,
8,
277,
14,
83,
14,
5626,
63,
1637,
63,
1310,
8,
2364,
4059,
339,
347,
511,
63,
88,
63,
1637,
63,
2139,
8,
277,
304,
267,
519,
275,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
qtekfun/htcDesire820Kernel
|
external/chromium_org/third_party/jinja2/sandbox.py
|
637
|
13445
|
# -*- coding: utf-8 -*-
"""
jinja2.sandbox
~~~~~~~~~~~~~~
Adds a sandbox layer to Jinja as it was the default behavior in the old
Jinja 1 releases. This sandbox is slightly different from Jinja 1 as the
default behavior is easier to use.
The behavior can be changed by subclassing the environment.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD.
"""
import operator
from jinja2.environment import Environment
from jinja2.exceptions import SecurityError
from jinja2._compat import string_types, function_type, method_type, \
traceback_type, code_type, frame_type, generator_type, PY2
#: maximum number of items a range may produce
MAX_RANGE = 100000
#: attributes of function objects that are considered unsafe.
UNSAFE_FUNCTION_ATTRIBUTES = set(['func_closure', 'func_code', 'func_dict',
'func_defaults', 'func_globals'])
#: unsafe method attributes. function attributes are unsafe for methods too
UNSAFE_METHOD_ATTRIBUTES = set(['im_class', 'im_func', 'im_self'])
#: unsafe generator attirbutes.
UNSAFE_GENERATOR_ATTRIBUTES = set(['gi_frame', 'gi_code'])
# On versions > python 2 the special attributes on functions are gone,
# but they remain on methods and generators for whatever reason.
if not PY2:
UNSAFE_FUNCTION_ATTRIBUTES = set()
import warnings
# make sure we don't warn in python 2.6 about stuff we don't care about
warnings.filterwarnings('ignore', 'the sets module', DeprecationWarning,
module='jinja2.sandbox')
from collections import deque
_mutable_set_types = (set,)
_mutable_mapping_types = (dict,)
_mutable_sequence_types = (list,)
# on python 2.x we can register the user collection types
try:
from UserDict import UserDict, DictMixin
from UserList import UserList
_mutable_mapping_types += (UserDict, DictMixin)
_mutable_set_types += (UserList,)
except ImportError:
pass
# if sets is still available, register the mutable set from there as well
try:
from sets import Set
_mutable_set_types += (Set,)
except ImportError:
pass
#: register Python 2.6 abstract base classes
try:
from collections import MutableSet, MutableMapping, MutableSequence
_mutable_set_types += (MutableSet,)
_mutable_mapping_types += (MutableMapping,)
_mutable_sequence_types += (MutableSequence,)
except ImportError:
pass
_mutable_spec = (
(_mutable_set_types, frozenset([
'add', 'clear', 'difference_update', 'discard', 'pop', 'remove',
'symmetric_difference_update', 'update'
])),
(_mutable_mapping_types, frozenset([
'clear', 'pop', 'popitem', 'setdefault', 'update'
])),
(_mutable_sequence_types, frozenset([
'append', 'reverse', 'insert', 'sort', 'extend', 'remove'
])),
(deque, frozenset([
'append', 'appendleft', 'clear', 'extend', 'extendleft', 'pop',
'popleft', 'remove', 'rotate'
]))
)
def safe_range(*args):
"""A range that can't generate ranges with a length of more than
MAX_RANGE items.
"""
rng = range(*args)
if len(rng) > MAX_RANGE:
raise OverflowError('range too big, maximum size for range is %d' %
MAX_RANGE)
return rng
def unsafe(f):
"""Marks a function or method as unsafe.
::
@unsafe
def delete(self):
pass
"""
f.unsafe_callable = True
return f
def is_internal_attribute(obj, attr):
"""Test if the attribute given is an internal python attribute. For
example this function returns `True` for the `func_code` attribute of
python objects. This is useful if the environment method
:meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.
>>> from jinja2.sandbox import is_internal_attribute
>>> is_internal_attribute(lambda: None, "func_code")
True
>>> is_internal_attribute((lambda x:x).func_code, 'co_code')
True
>>> is_internal_attribute(str, "upper")
False
"""
if isinstance(obj, function_type):
if attr in UNSAFE_FUNCTION_ATTRIBUTES:
return True
elif isinstance(obj, method_type):
if attr in UNSAFE_FUNCTION_ATTRIBUTES or \
attr in UNSAFE_METHOD_ATTRIBUTES:
return True
elif isinstance(obj, type):
if attr == 'mro':
return True
elif isinstance(obj, (code_type, traceback_type, frame_type)):
return True
elif isinstance(obj, generator_type):
if attr in UNSAFE_GENERATOR_ATTRIBUTES:
return True
return attr.startswith('__')
def modifies_known_mutable(obj, attr):
"""This function checks if an attribute on a builtin mutable object
(list, dict, set or deque) would modify it if called. It also supports
the "user"-versions of the objects (`sets.Set`, `UserDict.*` etc.) and
with Python 2.6 onwards the abstract base classes `MutableSet`,
`MutableMapping`, and `MutableSequence`.
>>> modifies_known_mutable({}, "clear")
True
>>> modifies_known_mutable({}, "keys")
False
>>> modifies_known_mutable([], "append")
True
>>> modifies_known_mutable([], "index")
False
If called with an unsupported object (such as unicode) `False` is
returned.
>>> modifies_known_mutable("foo", "upper")
False
"""
for typespec, unsafe in _mutable_spec:
if isinstance(obj, typespec):
return attr in unsafe
return False
class SandboxedEnvironment(Environment):
"""The sandboxed environment. It works like the regular environment but
tells the compiler to generate sandboxed code. Additionally subclasses of
this environment may override the methods that tell the runtime what
attributes or functions are safe to access.
If the template tries to access insecure code a :exc:`SecurityError` is
raised. However also other exceptions may occour during the rendering so
the caller has to ensure that all exceptions are catched.
"""
sandboxed = True
#: default callback table for the binary operators. A copy of this is
#: available on each instance of a sandboxed environment as
#: :attr:`binop_table`
default_binop_table = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.truediv,
'//': operator.floordiv,
'**': operator.pow,
'%': operator.mod
}
#: default callback table for the unary operators. A copy of this is
#: available on each instance of a sandboxed environment as
#: :attr:`unop_table`
default_unop_table = {
'+': operator.pos,
'-': operator.neg
}
#: a set of binary operators that should be intercepted. Each operator
#: that is added to this set (empty by default) is delegated to the
#: :meth:`call_binop` method that will perform the operator. The default
#: operator callback is specified by :attr:`binop_table`.
#:
#: The following binary operators are interceptable:
#: ``//``, ``%``, ``+``, ``*``, ``-``, ``/``, and ``**``
#:
#: The default operation form the operator table corresponds to the
#: builtin function. Intercepted calls are always slower than the native
#: operator call, so make sure only to intercept the ones you are
#: interested in.
#:
#: .. versionadded:: 2.6
intercepted_binops = frozenset()
#: a set of unary operators that should be intercepted. Each operator
#: that is added to this set (empty by default) is delegated to the
#: :meth:`call_unop` method that will perform the operator. The default
#: operator callback is specified by :attr:`unop_table`.
#:
#: The following unary operators are interceptable: ``+``, ``-``
#:
#: The default operation form the operator table corresponds to the
#: builtin function. Intercepted calls are always slower than the native
#: operator call, so make sure only to intercept the ones you are
#: interested in.
#:
#: .. versionadded:: 2.6
intercepted_unops = frozenset()
def intercept_unop(self, operator):
"""Called during template compilation with the name of a unary
operator to check if it should be intercepted at runtime. If this
method returns `True`, :meth:`call_unop` is excuted for this unary
operator. The default implementation of :meth:`call_unop` will use
the :attr:`unop_table` dictionary to perform the operator with the
same logic as the builtin one.
The following unary operators are interceptable: ``+`` and ``-``
Intercepted calls are always slower than the native operator call,
so make sure only to intercept the ones you are interested in.
.. versionadded:: 2.6
"""
return False
def __init__(self, *args, **kwargs):
Environment.__init__(self, *args, **kwargs)
self.globals['range'] = safe_range
self.binop_table = self.default_binop_table.copy()
self.unop_table = self.default_unop_table.copy()
def is_safe_attribute(self, obj, attr, value):
"""The sandboxed environment will call this method to check if the
attribute of an object is safe to access. Per default all attributes
starting with an underscore are considered private as well as the
special attributes of internal python objects as returned by the
:func:`is_internal_attribute` function.
"""
return not (attr.startswith('_') or is_internal_attribute(obj, attr))
def is_safe_callable(self, obj):
"""Check if an object is safely callable. Per default a function is
considered safe unless the `unsafe_callable` attribute exists and is
True. Override this method to alter the behavior, but this won't
affect the `unsafe` decorator from this module.
"""
return not (getattr(obj, 'unsafe_callable', False) or
getattr(obj, 'alters_data', False))
def call_binop(self, context, operator, left, right):
"""For intercepted binary operator calls (:meth:`intercepted_binops`)
this function is executed instead of the builtin operator. This can
be used to fine tune the behavior of certain operators.
.. versionadded:: 2.6
"""
return self.binop_table[operator](left, right)
def call_unop(self, context, operator, arg):
"""For intercepted unary operator calls (:meth:`intercepted_unops`)
this function is executed instead of the builtin operator. This can
be used to fine tune the behavior of certain operators.
.. versionadded:: 2.6
"""
return self.unop_table[operator](arg)
def getitem(self, obj, argument):
"""Subscribe an object from sandboxed code."""
try:
return obj[argument]
except (TypeError, LookupError):
if isinstance(argument, string_types):
try:
attr = str(argument)
except Exception:
pass
else:
try:
value = getattr(obj, attr)
except AttributeError:
pass
else:
if self.is_safe_attribute(obj, argument, value):
return value
return self.unsafe_undefined(obj, argument)
return self.undefined(obj=obj, name=argument)
def getattr(self, obj, attribute):
"""Subscribe an object from sandboxed code and prefer the
attribute. The attribute passed *must* be a bytestring.
"""
try:
value = getattr(obj, attribute)
except AttributeError:
try:
return obj[attribute]
except (TypeError, LookupError):
pass
else:
if self.is_safe_attribute(obj, attribute, value):
return value
return self.unsafe_undefined(obj, attribute)
return self.undefined(obj=obj, name=attribute)
def unsafe_undefined(self, obj, attribute):
"""Return an undefined object for unsafe attributes."""
return self.undefined('access to attribute %r of %r '
'object is unsafe.' % (
attribute,
obj.__class__.__name__
), name=attribute, obj=obj, exc=SecurityError)
def call(__self, __context, __obj, *args, **kwargs):
"""Call an object from sandboxed code."""
# the double prefixes are to avoid double keyword argument
# errors when proxying the call.
if not __self.is_safe_callable(__obj):
raise SecurityError('%r is not safely callable' % (__obj,))
return __context.call(__obj, *args, **kwargs)
class ImmutableSandboxedEnvironment(SandboxedEnvironment):
"""Works exactly like the regular `SandboxedEnvironment` but does not
permit modifications on the builtin mutable objects `list`, `set`, and
`dict` by using the :func:`modifies_known_mutable` function.
"""
def is_safe_attribute(self, obj, attr, value):
if not SandboxedEnvironment.is_safe_attribute(self, obj, attr, value):
return False
return not modifies_known_mutable(obj, attr)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
16647,
272,
32202,
1714,
339,
15747,
282,
19699,
4045,
370,
17300,
465,
652,
1990,
314,
849,
5953,
315,
314,
2269,
272,
17300,
413,
19015,
14,
221,
961,
19699,
365,
18023,
3365,
687,
17300,
413,
465,
314,
272,
849,
5953,
365,
14905,
370,
675,
14,
339,
710,
5953,
883,
506,
2896,
701,
24572,
314,
3734,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
14,
199,
624,
199,
646,
4182,
199,
504,
10321,
18,
14,
5418,
492,
9711,
199,
504,
10321,
18,
14,
3924,
492,
13863,
547,
199,
504,
10321,
18,
423,
5819,
492,
1059,
63,
1313,
12,
805,
63,
466,
12,
1083,
63,
466,
12,
971,
1362,
5190,
63,
466,
12,
1233,
63,
466,
12,
2787,
63,
466,
12,
4306,
63,
466,
12,
7843,
18,
421,
199,
12573,
5696,
1329,
402,
2974,
282,
1425,
1443,
7389,
199,
4283,
63,
15167,
275,
25761,
199,
199,
12573,
3004,
402,
805,
2251,
626,
787,
8652,
19293,
14,
199,
1734,
27657,
63,
15476,
63,
18166,
275,
663,
2941,
1532,
63,
13008,
297,
283,
1532,
63,
600,
297,
283,
1532,
63,
807,
297,
3303,
283,
1532,
63,
4322,
297,
283,
1532,
63,
8473,
1105,
199,
199,
12573,
19293,
1083,
3004,
14,
221,
805,
3004,
787,
19293,
367,
3102,
4634,
199,
1734,
27657,
63,
9977,
63,
18166,
275,
663,
2941,
1017,
63,
533,
297,
283,
1017,
63,
1532,
297,
283,
1017,
63,
277,
1105,
199,
199,
12573,
19293,
4306,
737,
280,
82,
464,
744,
14,
199,
1734,
27657,
63,
12795,
6467,
63,
18166,
275,
663,
2941,
6153,
63,
1943,
297,
283,
6153,
63,
600,
1105,
199,
199,
3,
4068,
5459,
690,
2366,
499,
314,
4539,
3004,
641,
3423,
787,
21737,
12,
199,
3,
1325,
2985,
5706,
641,
3102,
436,
16952,
367,
15685,
4499,
14,
199,
692,
440,
7843,
18,
26,
272,
32708,
33,
5100,
63,
15476,
63,
18166,
275,
663,
342,
199,
199,
646,
3598,
199,
199,
3,
1852,
3238,
781,
2793,
1133,
7987,
315,
2366,
499,
14,
22,
3595,
8292,
781,
2793,
1133,
10296,
3595,
199,
5451,
14,
23945,
360,
4247,
297,
283,
1589,
5951,
859,
297,
13413,
12,
717,
859,
534,
12264,
18,
14,
16647,
358,
199,
199,
504,
5055,
492,
15782,
199,
199,
63,
17404,
63,
409,
63,
1313,
275,
334,
409,
4258,
199,
63,
17404,
63,
4745,
63,
1313,
275,
334,
807,
4258,
199,
63,
17404,
63,
4041,
63,
1313,
275,
334,
513,
4258,
421,
199,
3,
641,
2366,
499,
14,
88,
781,
883,
2274,
314,
922,
3245,
2943,
199,
893,
26,
272,
687,
32241,
492,
32241,
12,
7448,
4256,
272,
687,
28639,
492,
28639,
272,
485,
17404,
63,
4745,
63,
1313,
847,
334,
30088,
12,
7448,
4256,
9,
272,
485,
17404,
63,
409,
63,
1313,
847,
334,
1899,
1296,
4258,
199,
2590,
3545,
26,
272,
986,
199,
199,
3,
340,
5951,
365,
5139,
2808,
12,
2274,
314,
17194,
663,
687,
2337,
465,
5521,
199,
893,
26,
272,
687,
5951,
492,
2494,
272,
485,
17404,
63,
409,
63,
1313,
847,
334,
1084,
4258,
199,
2590,
3545,
26,
272,
986,
199,
199,
12573,
2274,
2018,
499,
14,
22,
9006,
1300,
3992,
199,
893,
26,
272,
687,
5055,
492,
19610,
1084,
12,
29396,
12,
19610,
5826,
272,
485,
17404,
63,
409,
63,
1313,
847,
334,
17707,
1084,
4258,
272,
485,
17404,
63,
4745,
63,
1313,
847,
334,
17707,
7674,
4258,
272,
485,
17404,
63,
4041,
63,
1313,
847,
334,
17707,
5826,
4258,
199,
2590,
3545,
26,
272,
986,
199,
199,
63,
17404,
63,
1650,
275,
334,
272,
6110,
17404,
63,
409,
63,
1313,
12,
9522,
779,
267,
283,
525,
297,
283,
3584,
297,
283,
9196,
63,
873,
297,
283,
14394,
297,
283,
1935,
297,
283,
2168,
297,
267,
283,
18422,
63,
9196,
63,
873,
297,
283,
873,
7,
272,
4794,
395,
272,
6110,
17404,
63,
4745,
63,
1313,
12,
9522,
779,
267,
283,
3584,
297,
283,
1935,
297,
283,
24882,
297,
283,
5486,
297,
283,
873,
7,
272,
4794,
395,
272,
6110,
17404,
63,
4041,
63,
1313,
12,
9522,
779,
267,
283,
740,
297,
283,
4471,
297,
283,
3176,
297,
283,
3191,
297,
283,
2880,
297,
283,
2168,
7,
272,
4794,
395,
272,
334,
22983,
12,
9522,
779,
267,
283,
740,
297,
283,
740,
3039,
297,
283,
3584,
297,
283,
2880,
297,
283,
2880,
3039,
297,
283,
1935,
297,
267,
283,
25704,
297,
283,
2168,
297,
283,
12873,
7,
272,
22979,
199,
9,
421,
199,
318,
5048,
63,
1842,
2031,
589,
304,
272,
408,
33,
1425,
626,
883,
1133,
3550,
12271,
543,
282,
2582,
402,
1655,
2419,
272,
9141,
63,
15167,
2974,
14,
272,
408,
272,
9038,
275,
1425,
2031,
589,
9,
272,
340,
822,
8,
12686,
9,
690,
9141,
63,
15167,
26,
267,
746,
23870,
360,
1842,
4634,
7282,
12,
5696,
1568,
367,
1425,
365,
450,
68,
7,
450,
1169,
9141,
63,
15167,
9,
272,
372,
9038,
421,
199,
318,
19293,
8,
70,
304,
272,
408,
6470,
83,
282,
805,
503,
1083,
465,
19293,
14,
339,
3800,
398,
768,
14242,
267,
347,
3145,
8,
277,
304,
288,
986,
272,
408,
272,
289,
14,
14242,
63,
8296,
275,
715,
272,
372,
289,
421,
199,
318,
365,
63,
4672,
63,
3215,
8,
1113,
12,
1921,
304,
272,
408,
774,
340,
314,
2225,
1627,
365,
376,
5007,
2366,
2225,
14,
221,
2104,
272,
2893,
642,
805,
2529,
658,
549,
64,
367,
314,
658,
1532,
63,
600,
64,
2225,
402,
272,
2366,
2251,
14,
221,
961,
365,
2997,
340,
314,
3734,
1083,
272,
520,
5247,
6054,
29155,
379,
8263,
14,
374,
63,
3489,
63,
3215,
64,
365,
10087,
14,
339,
1306,
687,
10321,
18,
14,
16647,
492,
365,
63,
4672,
63,
3215,
272,
1306,
365,
63,
4672,
63,
3215,
8,
2734,
26,
488,
12,
298,
1532,
63,
600,
531,
272,
715,
272,
1306,
365,
63,
4672,
63,
3215,
1332,
2734,
671,
26,
88,
680,
1532,
63,
600,
12,
283,
331,
63,
600,
358,
272,
715,
272,
1306,
365,
63,
4672,
63,
3215,
8,
495,
12,
298,
4142,
531,
272,
756,
272,
408,
272,
340,
1228,
8,
1113,
12,
805,
63,
466,
304,
267,
340,
1921,
315,
32708
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
16647,
272,
32202,
1714,
339,
15747,
282,
19699,
4045,
370,
17300,
465,
652,
1990,
314,
849,
5953,
315,
314,
2269,
272,
17300,
413,
19015,
14,
221,
961,
19699,
365,
18023,
3365,
687,
17300,
413,
465,
314,
272,
849,
5953,
365,
14905,
370,
675,
14,
339,
710,
5953,
883,
506,
2896,
701,
24572,
314,
3734,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
14,
199,
624,
199,
646,
4182,
199,
504,
10321,
18,
14,
5418,
492,
9711,
199,
504,
10321,
18,
14,
3924,
492,
13863,
547,
199,
504,
10321,
18,
423,
5819,
492,
1059,
63,
1313,
12,
805,
63,
466,
12,
1083,
63,
466,
12,
971,
1362,
5190,
63,
466,
12,
1233,
63,
466,
12,
2787,
63,
466,
12,
4306,
63,
466,
12,
7843,
18,
421,
199,
12573,
5696,
1329,
402,
2974,
282,
1425,
1443,
7389,
199,
4283,
63,
15167,
275,
25761,
199,
199,
12573,
3004,
402,
805,
2251,
626,
787,
8652,
19293,
14,
199,
1734,
27657,
63,
15476,
63,
18166,
275,
663,
2941,
1532,
63,
13008,
297,
283,
1532,
63,
600,
297,
283,
1532,
63,
807,
297,
3303,
283,
1532,
63,
4322,
297,
283,
1532,
63,
8473,
1105,
199,
199,
12573,
19293,
1083,
3004,
14,
221,
805,
3004,
787,
19293,
367,
3102,
4634,
199,
1734,
27657,
63,
9977,
63,
18166,
275,
663,
2941,
1017,
63,
533,
297,
283,
1017,
63,
1532,
297,
283,
1017,
63,
277,
1105,
199,
199,
12573,
19293,
4306,
737,
280,
82,
464,
744,
14,
199,
1734,
27657,
63,
12795,
6467,
63,
18166,
275,
663,
2941,
6153,
63,
1943,
297,
283,
6153,
63,
600,
1105,
199,
199,
3,
4068,
5459,
690,
2366,
499,
314,
4539,
3004,
641,
3423,
787,
21737,
12,
199,
3,
1325,
2985,
5706,
641,
3102,
436,
16952,
367,
15685,
4499,
14,
199,
692,
440,
7843,
18,
26,
272,
32708,
33,
5100,
63,
15476,
63,
18166,
275,
663,
342,
199,
199,
646,
3598,
199,
199,
3,
1852,
3238,
781,
2793,
1133,
7987,
315,
2366,
499,
14,
22,
3595,
8292,
781,
2793,
1133,
10296,
3595,
199,
5451,
14,
23945,
360,
4247,
297,
283,
1589,
5951,
859,
297,
13413,
12,
717,
859,
534,
12264,
18,
14,
16647,
358,
199,
199,
504,
5055,
492,
15782,
199,
199,
63,
17404,
63,
409,
63,
1313,
275,
334,
409,
4258,
199,
63,
17404,
63,
4745,
63,
1313,
275,
334,
807,
4258,
199,
63,
17404,
63,
4041,
63,
1313,
275,
334,
513,
4258,
421,
199,
3,
641,
2366,
499,
14,
88,
781,
883,
2274,
314,
922,
3245,
2943,
199,
893,
26,
272,
687,
32241,
492,
32241,
12,
7448,
4256,
272,
687,
28639,
492,
28639,
272,
485,
17404,
63,
4745,
63,
1313,
847,
334,
30088,
12,
7448,
4256,
9,
272,
485,
17404,
63,
409,
63,
1313,
847,
334,
1899,
1296,
4258,
199,
2590,
3545,
26,
272,
986,
199,
199,
3,
340,
5951,
365,
5139,
2808,
12,
2274,
314,
17194,
663,
687,
2337,
465,
5521,
199,
893,
26,
272,
687,
5951,
492,
2494,
272,
485,
17404,
63,
409,
63,
1313,
847,
334,
1084,
4258,
199,
2590,
3545,
26,
272,
986,
199,
199,
12573,
2274,
2018,
499,
14,
22,
9006,
1300,
3992,
199,
893,
26,
272,
687,
5055,
492,
19610,
1084,
12,
29396,
12,
19610,
5826,
272,
485,
17404,
63,
409,
63,
1313,
847,
334,
17707,
1084,
4258,
272,
485,
17404,
63,
4745,
63,
1313,
847,
334,
17707,
7674,
4258,
272,
485,
17404,
63,
4041,
63,
1313,
847,
334,
17707,
5826,
4258,
199,
2590,
3545,
26,
272,
986,
199,
199,
63,
17404,
63,
1650,
275,
334,
272,
6110,
17404,
63,
409,
63,
1313,
12,
9522,
779,
267,
283,
525,
297,
283,
3584,
297,
283,
9196,
63,
873,
297,
283,
14394,
297,
283,
1935,
297,
283,
2168,
297,
267,
283,
18422,
63,
9196,
63,
873,
297,
283,
873,
7,
272,
4794,
395,
272,
6110,
17404,
63,
4745,
63,
1313,
12,
9522,
779,
267,
283,
3584,
297,
283,
1935,
297,
283,
24882,
297,
283,
5486,
297,
283,
873,
7,
272,
4794,
395,
272,
6110,
17404,
63,
4041,
63,
1313,
12,
9522,
779,
267,
283,
740,
297,
283,
4471,
297,
283,
3176,
297,
283,
3191,
297,
283,
2880,
297,
283,
2168,
7,
272,
4794,
395,
272,
334,
22983,
12,
9522,
779,
267,
283,
740,
297,
283,
740,
3039,
297,
283,
3584,
297,
283,
2880,
297,
283,
2880,
3039,
297,
283,
1935,
297,
267,
283,
25704,
297,
283,
2168,
297,
283,
12873,
7,
272,
22979,
199,
9,
421,
199,
318,
5048,
63,
1842,
2031,
589,
304,
272,
408,
33,
1425,
626,
883,
1133,
3550,
12271,
543,
282,
2582,
402,
1655,
2419,
272,
9141,
63,
15167,
2974,
14,
272,
408,
272,
9038,
275,
1425,
2031,
589,
9,
272,
340,
822,
8,
12686,
9,
690,
9141,
63,
15167,
26,
267,
746,
23870,
360,
1842,
4634,
7282,
12,
5696,
1568,
367,
1425,
365,
450,
68,
7,
450,
1169,
9141,
63,
15167,
9,
272,
372,
9038,
421,
199,
318,
19293,
8,
70,
304,
272,
408,
6470,
83,
282,
805,
503,
1083,
465,
19293,
14,
339,
3800,
398,
768,
14242,
267,
347,
3145,
8,
277,
304,
288,
986,
272,
408,
272,
289,
14,
14242,
63,
8296,
275,
715,
272,
372,
289,
421,
199,
318,
365,
63,
4672,
63,
3215,
8,
1113,
12,
1921,
304,
272,
408,
774,
340,
314,
2225,
1627,
365,
376,
5007,
2366,
2225,
14,
221,
2104,
272,
2893,
642,
805,
2529,
658,
549,
64,
367,
314,
658,
1532,
63,
600,
64,
2225,
402,
272,
2366,
2251,
14,
221,
961,
365,
2997,
340,
314,
3734,
1083,
272,
520,
5247,
6054,
29155,
379,
8263,
14,
374,
63,
3489,
63,
3215,
64,
365,
10087,
14,
339,
1306,
687,
10321,
18,
14,
16647,
492,
365,
63,
4672,
63,
3215,
272,
1306,
365,
63,
4672,
63,
3215,
8,
2734,
26,
488,
12,
298,
1532,
63,
600,
531,
272,
715,
272,
1306,
365,
63,
4672,
63,
3215,
1332,
2734,
671,
26,
88,
680,
1532,
63,
600,
12,
283,
331,
63,
600,
358,
272,
715,
272,
1306,
365,
63,
4672,
63,
3215,
8,
495,
12,
298,
4142,
531,
272,
756,
272,
408,
272,
340,
1228,
8,
1113,
12,
805,
63,
466,
304,
267,
340,
1921,
315,
32708,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
dralves/nixysa
|
third_party/ply-3.1/test/yacc_inf.py
|
174
|
1278
|
# -----------------------------------------------------------------------------
# yacc_inf.py
#
# Infinite recursion
# -----------------------------------------------------------------------------
import sys
if ".." not in sys.path: sys.path.insert(0,"..")
import ply.yacc as yacc
from calclex import tokens
# Parsing rules
precedence = (
('left','PLUS','MINUS'),
('left','TIMES','DIVIDE'),
('right','UMINUS'),
)
# dictionary of names
names = { }
def p_statement_assign(t):
'statement : NAME EQUALS expression'
names[t[1]] = t[3]
def p_statement_expr(t):
'statement : expression'
print(t[1])
def p_expression_binop(t):
'''expression : expression PLUS expression
| expression MINUS expression
| expression TIMES expression
| expression DIVIDE expression'''
if t[2] == '+' : t[0] = t[1] + t[3]
elif t[2] == '-': t[0] = t[1] - t[3]
elif t[2] == '*': t[0] = t[1] * t[3]
elif t[2] == '/': t[0] = t[1] / t[3]
def p_expression_uminus(t):
'expression : MINUS expression %prec UMINUS'
t[0] = -t[2]
def p_expression_group(t):
'expression : LPAREN expression RPAREN'
t[0] = t[2]
def p_error(t):
print("Syntax error at '%s'" % t.value)
yacc.yacc()
|
apache-2.0
|
[
3,
13722,
199,
3,
612,
5470,
63,
4904,
14,
647,
199,
3,
199,
3,
1010,
8005,
16189,
199,
3,
13722,
199,
646,
984,
199,
199,
692,
21777,
2,
440,
315,
984,
14,
515,
26,
984,
14,
515,
14,
3176,
8,
16,
4589,
703,
531,
199,
646,
299,
590,
14,
27319,
465,
612,
5470,
199,
199,
504,
3213,
2265,
88,
492,
4645,
199,
199,
3,
28747,
4713,
199,
19571,
275,
334,
272,
661,
3039,
1673,
27280,
1673,
18004,
659,
272,
661,
3039,
1673,
11342,
654,
1673,
1914,
5437,
37,
659,
272,
661,
1019,
1673,
2639,
568,
1668,
659,
272,
776,
199,
199,
3,
2600,
402,
1561,
199,
1247,
275,
469,
789,
199,
199,
318,
299,
63,
6242,
63,
5038,
8,
84,
304,
272,
283,
6242,
520,
13637,
27249,
3965,
7,
272,
1561,
59,
84,
59,
17,
2677,
275,
307,
59,
19,
61,
199,
199,
318,
299,
63,
6242,
63,
3684,
8,
84,
304,
272,
283,
6242,
520,
3965,
7,
272,
870,
8,
84,
59,
17,
566,
199,
199,
318,
299,
63,
5599,
63,
31451,
8,
84,
304,
272,
1449,
5599,
520,
3965,
18807,
3965,
2116,
1204,
3965,
15861,
1668,
3965,
2116,
1204,
3965,
25185,
654,
3965,
2116,
1204,
3965,
5266,
5437,
37,
3965,
2344,
272,
340,
307,
59,
18,
61,
508,
20246,
221,
520,
307,
59,
16,
61,
275,
307,
59,
17,
61,
435,
307,
59,
19,
61,
272,
916,
307,
59,
18,
61,
508,
20905,
307,
59,
16,
61,
275,
307,
59,
17,
61,
446,
307,
59,
19,
61,
272,
916,
307,
59,
18,
61,
508,
22969,
307,
59,
16,
61,
275,
307,
59,
17,
61,
627,
307,
59,
19,
61,
272,
916,
307,
59,
18,
61,
508,
20549,
307,
59,
16,
61,
275,
307,
59,
17,
61,
1182,
307,
59,
19,
61,
199,
199,
318,
299,
63,
5599,
63,
453,
262,
527,
8,
84,
304,
272,
283,
5599,
520,
15861,
1668,
3965,
450,
9218,
738,
18004,
7,
272,
307,
59,
16,
61,
275,
446,
84,
59,
18,
61,
199,
199,
318,
299,
63,
5599,
63,
923,
8,
84,
304,
272,
283,
5599,
520,
491,
22169,
3965,
820,
22169,
7,
272,
307,
59,
16,
61,
275,
307,
59,
18,
61,
199,
199,
318,
299,
63,
705,
8,
84,
304,
272,
870,
480,
16626,
1125,
737,
1543,
83,
4065,
450,
307,
14,
585,
9,
199,
199,
27319,
14,
27319,
342,
28154,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
13722,
199,
3,
612,
5470,
63,
4904,
14,
647,
199,
3,
199,
3,
1010,
8005,
16189,
199,
3,
13722,
199,
646,
984,
199,
199,
692,
21777,
2,
440,
315,
984,
14,
515,
26,
984,
14,
515,
14,
3176,
8,
16,
4589,
703,
531,
199,
646,
299,
590,
14,
27319,
465,
612,
5470,
199,
199,
504,
3213,
2265,
88,
492,
4645,
199,
199,
3,
28747,
4713,
199,
19571,
275,
334,
272,
661,
3039,
1673,
27280,
1673,
18004,
659,
272,
661,
3039,
1673,
11342,
654,
1673,
1914,
5437,
37,
659,
272,
661,
1019,
1673,
2639,
568,
1668,
659,
272,
776,
199,
199,
3,
2600,
402,
1561,
199,
1247,
275,
469,
789,
199,
199,
318,
299,
63,
6242,
63,
5038,
8,
84,
304,
272,
283,
6242,
520,
13637,
27249,
3965,
7,
272,
1561,
59,
84,
59,
17,
2677,
275,
307,
59,
19,
61,
199,
199,
318,
299,
63,
6242,
63,
3684,
8,
84,
304,
272,
283,
6242,
520,
3965,
7,
272,
870,
8,
84,
59,
17,
566,
199,
199,
318,
299,
63,
5599,
63,
31451,
8,
84,
304,
272,
1449,
5599,
520,
3965,
18807,
3965,
2116,
1204,
3965,
15861,
1668,
3965,
2116,
1204,
3965,
25185,
654,
3965,
2116,
1204,
3965,
5266,
5437,
37,
3965,
2344,
272,
340,
307,
59,
18,
61,
508,
20246,
221,
520,
307,
59,
16,
61,
275,
307,
59,
17,
61,
435,
307,
59,
19,
61,
272,
916,
307,
59,
18,
61,
508,
20905,
307,
59,
16,
61,
275,
307,
59,
17,
61,
446,
307,
59,
19,
61,
272,
916,
307,
59,
18,
61,
508,
22969,
307,
59,
16,
61,
275,
307,
59,
17,
61,
627,
307,
59,
19,
61,
272,
916,
307,
59,
18,
61,
508,
20549,
307,
59,
16,
61,
275,
307,
59,
17,
61,
1182,
307,
59,
19,
61,
199,
199,
318,
299,
63,
5599,
63,
453,
262,
527,
8,
84,
304,
272,
283,
5599,
520,
15861,
1668,
3965,
450,
9218,
738,
18004,
7,
272,
307,
59,
16,
61,
275,
446,
84,
59,
18,
61,
199,
199,
318,
299,
63,
5599,
63,
923,
8,
84,
304,
272,
283,
5599,
520,
491,
22169,
3965,
820,
22169,
7,
272,
307,
59,
16,
61,
275,
307,
59,
18,
61,
199,
199,
318,
299,
63,
705,
8,
84,
304,
272,
870,
480,
16626,
1125,
737,
1543,
83,
4065,
450,
307,
14,
585,
9,
199,
199,
27319,
14,
27319,
342,
28154,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
tkolhar/robottelo
|
robottelo/cli/location.py
|
16
|
5994
|
# -*- encoding: utf-8 -*-
# (Too many public methods) pylint: disable=R0904
"""
Usage::
hammer location [OPTIONS] SUBCOMMAND [ARG] ...
Parameters::
SUBCOMMAND subcommand
[ARG] ... subcommand arguments
Subcommands::
add-compute-resource Associate a compute resource
add-config-template Associate a configuration template
add-domain Associate a domain
add-environment Associate an environment
add-hostgroup Associate a hostgroup
add-medium Associate a medium
add-organization Associate an organization
add-smart-proxy Associate a smart proxy
add-subnet Associate a subnet
add-user Associate an user
create Create a location
delete Delete a location
info Show a location
list List all locations
remove-compute-resource Disassociate a compute resource
remove-config-template Disassociate a configuration template
remove-domain Disassociate a domain
remove-environment Disassociate an environment
remove-hostgroup Disassociate a hostgroup
remove-medium Disassociate a medium
remove-organization Disassociate an organization
remove-smart-proxy Disassociate a smart proxy
remove-subnet Disassociate a subnet
remove-user Disassociate an user
update Update a location
"""
from robottelo.cli.base import Base
class Location(Base):
"""Manipulates Foreman's Locations"""
command_base = 'location'
@classmethod
def add_compute_resource(cls, options=None):
"""Associate a compute resource"""
cls.command_sub = 'add-compute-resource'
return cls.execute(cls._construct_command(options))
@classmethod
def add_config_template(cls, options=None):
"""Associate a configuration template"""
cls.command_sub = 'add-config-template'
return cls.execute(cls._construct_command(options))
@classmethod
def add_domain(cls, options=None):
"""Associate a domain"""
cls.command_sub = 'add-domain'
return cls.execute(cls._construct_command(options))
@classmethod
def add_environment(cls, options=None):
"""Associate an environment"""
cls.command_sub = 'add-environment'
return cls.execute(cls._construct_command(options))
@classmethod
def add_hostgroup(cls, options=None):
"""Associate a hostgroup"""
cls.command_sub = 'add-hostgroup'
return cls.execute(cls._construct_command(options))
@classmethod
def add_medium(cls, options=None):
"""Associate a medium"""
cls.command_sub = 'add-medium'
return cls.execute(cls._construct_command(options))
@classmethod
def add_organization(cls, options=None):
"""Associate an organization"""
cls.command_sub = 'add-organization'
return cls.execute(cls._construct_command(options))
@classmethod
def add_smart_proxy(cls, options=None):
"""Associate a smart proxy"""
cls.command_sub = 'add-smart-proxy'
return cls.execute(cls._construct_command(options))
@classmethod
def add_subnet(cls, options=None):
"""Associate a subnet"""
cls.command_sub = 'add-subnet'
return cls.execute(cls._construct_command(options))
@classmethod
def add_user(cls, options=None):
"""Associate a user"""
cls.command_sub = 'add-user'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_compute_resource(cls, options=None):
"""Disassociate a compute resource"""
cls.command_sub = 'remove-compute-resource'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_config_template(cls, options=None):
"""Disassociate a configuration template"""
cls.command_sub = 'remove-config-template'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_domain(cls, options=None):
"""Disassociate a domain"""
cls.command_sub = 'remove-domain'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_environment(cls, options=None):
"""Disassociate an environment"""
cls.command_sub = 'remove-environment'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_hostgroup(cls, options=None):
"""Disassociate a hostgroup"""
cls.command_sub = 'remove-hostgroup'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_medium(cls, options=None):
"""Disassociate a medium"""
cls.command_sub = 'remove-medium'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_organization(cls, options=None):
"""Disassociate an organization"""
cls.command_sub = 'remove-organization'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_smart_proxy(cls, options=None):
"""Disassociate a smart proxy"""
cls.command_sub = 'remove-smart-proxy'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_subnet(cls, options=None):
"""Disassociate a subnet"""
cls.command_sub = 'remove-subnet'
return cls.execute(cls._construct_command(options))
@classmethod
def remove_user(cls, options=None):
"""Disassociate a user"""
cls.command_sub = 'remove-user'
return cls.execute(cls._construct_command(options))
|
gpl-3.0
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
334,
13749,
5002,
4575,
3102,
9,
4287,
26,
3507,
29,
50,
1643,
966,
199,
624,
199,
7692,
447,
339,
24868,
2626,
2909,
359,
8808,
61,
7605,
10761,
359,
11611,
61,
2263,
199,
199,
5976,
447,
339,
7605,
10761,
8540,
21474,
272,
359,
11611,
61,
2263,
9326,
21474,
2368,
199,
199,
2610,
4405,
447,
339,
1050,
13,
3357,
13,
1927,
3515,
24207,
323,
282,
4526,
2073,
272,
1050,
13,
888,
13,
1160,
3698,
24207,
323,
282,
2897,
1978,
272,
1050,
13,
2261,
8540,
24207,
323,
282,
2881,
272,
1050,
13,
5418,
5185,
24207,
323,
376,
3734,
272,
1050,
13,
28221,
463,
24207,
323,
282,
1591,
923,
272,
1050,
13,
14345,
8540,
24207,
323,
282,
21576,
272,
1050,
13,
9071,
4519,
24207,
323,
376,
13237,
272,
1050,
13,
7853,
13,
3280,
5185,
24207,
323,
282,
11179,
4566,
272,
1050,
13,
5327,
8540,
24207,
323,
282,
6303,
272,
1050,
13,
751,
10473,
24207,
323,
376,
922,
272,
1218,
12788,
2790,
282,
2909,
272,
3145,
12788,
8496,
282,
2909,
272,
2256,
14516,
12968,
282,
2909,
272,
769,
14516,
3820,
1006,
9918,
272,
2813,
13,
3357,
13,
1927,
755,
5289,
16021,
282,
4526,
2073,
272,
2813,
13,
888,
13,
1160,
263,
5289,
16021,
282,
2897,
1978,
272,
2813,
13,
2261,
463,
5289,
16021,
282,
2881,
272,
2813,
13,
5418,
3322,
5289,
16021,
376,
3734,
272,
2813,
13,
28221,
4519,
5289,
16021,
282,
1591,
923,
272,
2813,
13,
14345,
463,
5289,
16021,
282,
21576,
272,
2813,
13,
9071,
3698,
5289,
16021,
376,
13237,
272,
2813,
13,
7853,
13,
3280,
3322,
5289,
16021,
282,
11179,
4566,
272,
2813,
13,
5327,
463,
5289,
16021,
282,
6303,
272,
2813,
13,
751,
7861,
5289,
16021,
376,
922,
272,
1678,
12788,
6162,
282,
2909,
199,
624,
199,
199,
504,
14544,
266,
320,
14,
2764,
14,
1095,
492,
3523,
421,
199,
533,
12625,
8,
1563,
304,
272,
408,
2395,
711,
15409,
21684,
1237,
1159,
6263,
1298,
624,
339,
1414,
63,
1095,
275,
283,
1985,
7,
339,
768,
3744,
272,
347,
1050,
63,
3357,
63,
1927,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
4526,
2073,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
3357,
13,
1927,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
888,
63,
1160,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
2897,
1978,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
888,
13,
1160,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
2261,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
2881,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
2261,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
5418,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
376,
3734,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
5418,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
28221,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
1591,
923,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
28221,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
14345,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
21576,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
14345,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
9071,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
376,
13237,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
9071,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
7853,
63,
3280,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
11179,
4566,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
7853,
13,
3280,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
5327,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
6303,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
5327,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
751,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
922,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
751,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
3357,
63,
1927,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
282,
4526,
2073,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
3357,
13,
1927,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
888,
63,
1160,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
282,
2897,
1978,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
888,
13,
1160,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
2261,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
282,
2881,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
2261,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
5418,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
376,
3734,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
5418,
7,
398,
372,
843,
14,
2526,
8,
1886
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
334,
13749,
5002,
4575,
3102,
9,
4287,
26,
3507,
29,
50,
1643,
966,
199,
624,
199,
7692,
447,
339,
24868,
2626,
2909,
359,
8808,
61,
7605,
10761,
359,
11611,
61,
2263,
199,
199,
5976,
447,
339,
7605,
10761,
8540,
21474,
272,
359,
11611,
61,
2263,
9326,
21474,
2368,
199,
199,
2610,
4405,
447,
339,
1050,
13,
3357,
13,
1927,
3515,
24207,
323,
282,
4526,
2073,
272,
1050,
13,
888,
13,
1160,
3698,
24207,
323,
282,
2897,
1978,
272,
1050,
13,
2261,
8540,
24207,
323,
282,
2881,
272,
1050,
13,
5418,
5185,
24207,
323,
376,
3734,
272,
1050,
13,
28221,
463,
24207,
323,
282,
1591,
923,
272,
1050,
13,
14345,
8540,
24207,
323,
282,
21576,
272,
1050,
13,
9071,
4519,
24207,
323,
376,
13237,
272,
1050,
13,
7853,
13,
3280,
5185,
24207,
323,
282,
11179,
4566,
272,
1050,
13,
5327,
8540,
24207,
323,
282,
6303,
272,
1050,
13,
751,
10473,
24207,
323,
376,
922,
272,
1218,
12788,
2790,
282,
2909,
272,
3145,
12788,
8496,
282,
2909,
272,
2256,
14516,
12968,
282,
2909,
272,
769,
14516,
3820,
1006,
9918,
272,
2813,
13,
3357,
13,
1927,
755,
5289,
16021,
282,
4526,
2073,
272,
2813,
13,
888,
13,
1160,
263,
5289,
16021,
282,
2897,
1978,
272,
2813,
13,
2261,
463,
5289,
16021,
282,
2881,
272,
2813,
13,
5418,
3322,
5289,
16021,
376,
3734,
272,
2813,
13,
28221,
4519,
5289,
16021,
282,
1591,
923,
272,
2813,
13,
14345,
463,
5289,
16021,
282,
21576,
272,
2813,
13,
9071,
3698,
5289,
16021,
376,
13237,
272,
2813,
13,
7853,
13,
3280,
3322,
5289,
16021,
282,
11179,
4566,
272,
2813,
13,
5327,
463,
5289,
16021,
282,
6303,
272,
2813,
13,
751,
7861,
5289,
16021,
376,
922,
272,
1678,
12788,
6162,
282,
2909,
199,
624,
199,
199,
504,
14544,
266,
320,
14,
2764,
14,
1095,
492,
3523,
421,
199,
533,
12625,
8,
1563,
304,
272,
408,
2395,
711,
15409,
21684,
1237,
1159,
6263,
1298,
624,
339,
1414,
63,
1095,
275,
283,
1985,
7,
339,
768,
3744,
272,
347,
1050,
63,
3357,
63,
1927,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
4526,
2073,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
3357,
13,
1927,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
888,
63,
1160,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
2897,
1978,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
888,
13,
1160,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
2261,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
2881,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
2261,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
5418,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
376,
3734,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
5418,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
28221,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
1591,
923,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
28221,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
14345,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
21576,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
14345,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
9071,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
376,
13237,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
9071,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
7853,
63,
3280,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
11179,
4566,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
7853,
13,
3280,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
5327,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
6303,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
5327,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
1050,
63,
751,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
14889,
323,
282,
922,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
525,
13,
751,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
3357,
63,
1927,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
282,
4526,
2073,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
3357,
13,
1927,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
888,
63,
1160,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
282,
2897,
1978,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
888,
13,
1160,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
2261,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
282,
2881,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
2261,
7,
398,
372,
843,
14,
2526,
8,
1886,
423,
8514,
63,
1531,
8,
1419,
430,
339,
768,
3744,
272,
347,
2813,
63,
5418,
8,
1886,
12,
1511,
29,
403,
304,
267,
408,
2825,
16021,
376,
3734,
624,
398,
843,
14,
1531,
63,
954,
275,
283,
2168,
13,
5418,
7,
398,
372,
843,
14,
2526,
8,
1886,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
sarvex/tensorflow
|
tensorflow/lite/ios/extract_object_files.py
|
9
|
6276
|
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# Lint as: python3
"""Module for extracting object files from a compiled archive (.a) file.
This module provides functionality almost identical to the 'ar -x' command,
which extracts out all object files from a given archive file. This module
assumes the archive is in the BSD variant format used in Apple platforms.
See: https://en.wikipedia.org/wiki/Ar_(Unix)#BSD_variant
This extractor has two important differences compared to the 'ar -x' command
shipped with Xcode.
1. When there are multiple object files with the same name in a given archive,
each file is renamed so that they are all correctly extracted without
overwriting each other.
2. This module takes the destination directory as an additional parameter.
Example Usage:
archive_path = ...
dest_dir = ...
extract_object_files(archive_path, dest_dir)
"""
import hashlib
import io
import itertools
import os
import struct
from typing import Iterator, Tuple
def extract_object_files(archive_file: io.BufferedIOBase,
dest_dir: str) -> None:
"""Extracts object files from the archive path to the destination directory.
Extracts object files from the given BSD variant archive file. The extracted
files are written to the destination directory, which will be created if the
directory does not exist.
Colliding object file names are automatically renamed upon extraction in order
to avoid unintended overwriting.
Args:
archive_file: The archive file object pointing at its beginning.
dest_dir: The destination directory path in which the extracted object files
will be written. The directory will be created if it does not exist.
"""
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
_check_archive_signature(archive_file)
# Keep the extracted file names and their content hash values, in order to
# handle duplicate names correctly.
extracted_files = dict()
for name, file_content in _extract_next_file(archive_file):
digest = hashlib.md5(file_content).digest()
# Check if the name is already used. If so, come up with a different name by
# incrementing the number suffix until it finds an unused one.
# For example, if 'foo.o' is used, try 'foo_1.o', 'foo_2.o', and so on.
for final_name in _generate_modified_filenames(name):
if final_name not in extracted_files:
extracted_files[final_name] = digest
# Write the file content to the desired final path.
with open(os.path.join(dest_dir, final_name), 'wb') as object_file:
object_file.write(file_content)
break
# Skip writing this file if the same file was already extracted.
elif extracted_files[final_name] == digest:
break
def _generate_modified_filenames(filename: str) -> Iterator[str]:
"""Generates the modified filenames with incremental name suffix added.
This helper function first yields the given filename itself, and subsequently
yields modified filenames by incrementing number suffix to the basename.
Args:
filename: The original filename to be modified.
Yields:
The original filename and then modified filenames with incremental suffix.
"""
yield filename
base, ext = os.path.splitext(filename)
for name_suffix in itertools.count(1, 1):
yield '{}_{}{}'.format(base, name_suffix, ext)
def _check_archive_signature(archive_file: io.BufferedIOBase) -> None:
"""Checks if the file has the correct archive header signature.
The cursor is moved to the first available file header section after
successfully checking the signature.
Args:
archive_file: The archive file object pointing at its beginning.
Raises:
RuntimeError: The archive signature is invalid.
"""
signature = archive_file.read(8)
if signature != b'!<arch>\n':
raise RuntimeError('Invalid archive file format.')
def _extract_next_file(
archive_file: io.BufferedIOBase) -> Iterator[Tuple[str, bytes]]:
"""Extracts the next available file from the archive.
Reads the next available file header section and yields its filename and
content in bytes as a tuple. Stops when there are no more available files in
the provided archive_file.
Args:
archive_file: The archive file object, of which cursor is pointing to the
next available file header section.
Yields:
The name and content of the next available file in the given archive file.
Raises:
RuntimeError: The archive_file is in an unknown format.
"""
while True:
header = archive_file.read(60)
if not header:
return
elif len(header) < 60:
raise RuntimeError('Invalid file header format.')
# For the details of the file header format, see:
# https://en.wikipedia.org/wiki/Ar_(Unix)#File_header
# We only need the file name and the size values.
name, _, _, _, _, size, end = struct.unpack('=16s12s6s6s8s10s2s', header)
if end != b'`\n':
raise RuntimeError('Invalid file header format.')
# Convert the bytes into more natural types.
name = name.decode('ascii').strip()
size = int(size, base=10)
odd_size = size % 2 == 1
# Handle the extended filename scheme.
if name.startswith('#1/'):
filename_size = int(name[3:])
name = archive_file.read(filename_size).decode('utf-8').strip(' \x00')
size -= filename_size
file_content = archive_file.read(size)
# The file contents are always 2 byte aligned, and 1 byte is padded at the
# end in case the size is odd.
if odd_size:
archive_file.read(1)
yield (name, file_content)
|
apache-2.0
|
[
3,
1898,
499,
15385,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
3,
491,
442,
465,
26,
2366,
19,
199,
624,
2377,
367,
30137,
909,
1584,
687,
282,
10311,
6359,
17048,
65,
9,
570,
14,
199,
199,
2765,
859,
6571,
9330,
18871,
13130,
370,
314,
283,
285,
446,
88,
7,
1414,
12,
199,
6777,
5536,
83,
734,
1006,
909,
1584,
687,
282,
1627,
6359,
570,
14,
961,
859,
199,
21946,
83,
314,
6359,
365,
315,
314,
6289,
9854,
1475,
1202,
315,
21257,
10677,
14,
199,
199,
9295,
26,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1596,
2531,
21607,
28017,
15400,
63,
8759,
199,
199,
2765,
31295,
965,
2877,
11012,
15109,
13524,
370,
314,
283,
285,
446,
88,
7,
1414,
199,
3319,
1915,
543,
10602,
14,
199,
199,
17,
14,
221,
3979,
2337,
787,
3663,
909,
1584,
543,
314,
2011,
536,
315,
282,
1627,
6359,
12,
272,
1924,
570,
365,
17864,
880,
626,
2985,
787,
1006,
6657,
12509,
1928,
272,
32592,
1924,
1163,
14,
199,
199,
18,
14,
221,
961,
859,
6181,
314,
5724,
2082,
465,
376,
4722,
2725,
14,
339,
5679,
11028,
26,
339,
6359,
63,
515,
275,
2263,
272,
2053,
63,
694,
275,
2263,
272,
5536,
63,
785,
63,
1725,
8,
6404,
63,
515,
12,
2053,
63,
694,
9,
199,
624,
199,
199,
646,
8337,
199,
646,
5890,
199,
646,
7975,
199,
646,
747,
199,
646,
2702,
199,
504,
14090,
492,
25769,
12,
11634,
421,
199,
318,
5536,
63,
785,
63,
1725,
8,
6404,
63,
493,
26,
5890,
14,
23139,
23413,
12,
586,
2053,
63,
694,
26,
620,
9,
1035,
488,
26,
523,
408,
12147,
83,
909,
1584,
687,
314,
6359,
931,
370,
314,
5724,
2082,
14,
819,
12892,
83,
909,
1584,
687,
314,
1627,
6289,
9854,
6359,
570,
14,
710,
12509,
523,
1584,
787,
5313,
370,
314,
5724,
2082,
12,
1314,
911,
506,
2737,
340,
314,
523,
2082,
1630,
440,
2187,
14,
819,
3626,
317,
1098,
909,
570,
1561,
787,
5847,
17864,
12188,
19967,
315,
1865,
523,
370,
5126,
625,
262,
6943,
32592,
14,
819,
3033,
26,
272,
6359,
63,
493,
26,
710,
6359,
570,
909,
20686,
737,
2399,
9608,
14,
272,
2053,
63,
694,
26,
710,
5724,
2082,
931,
315,
1314,
314,
12509,
909,
1584,
489,
911,
506,
5313,
14,
710,
2082,
911,
506,
2737,
340,
652,
1630,
440,
2187,
14,
523,
408,
523,
340,
440,
747,
14,
515,
14,
2444,
8,
2614,
63,
694,
304,
272,
747,
14,
8347,
8,
2614,
63,
694,
9,
819,
485,
1074,
63,
6404,
63,
5233,
8,
6404,
63,
493,
9,
819,
327,
14797,
314,
12509,
570,
1561,
436,
3932,
1564,
2631,
1338,
12,
315,
1865,
370,
523,
327,
2429,
9250,
1561,
6657,
14,
523,
12509,
63,
1725,
275,
1211,
342,
819,
367,
536,
12,
570,
63,
1317,
315,
485,
5005,
63,
2184,
63,
493,
8,
6404,
63,
493,
304,
272,
10017,
275,
8337,
14,
1064,
21,
8,
493,
63,
1317,
680,
5671,
342,
339,
327,
2670,
340,
314,
536,
365,
2575,
1202,
14,
982,
880,
12,
11492,
1536,
543,
282,
3365,
536,
701,
272,
327,
11609,
316,
314,
1329,
4739,
5133,
652,
17651,
376,
9563,
1373,
14,
272,
327,
2104,
2893,
12,
340,
283,
1421,
14,
79,
7,
365,
1202,
12,
862,
283,
1421,
63,
17,
14,
79,
297,
283,
1421,
63,
18,
14,
79,
297,
436,
880,
641,
14,
272,
367,
4242,
63,
354,
315,
485,
4208,
63,
5540,
63,
10309,
8,
354,
304,
489,
340,
4242,
63,
354,
440,
315,
12509,
63,
1725,
26,
267,
12509,
63,
1725,
59,
5094,
63,
354,
61,
275,
10017,
398,
327,
6990,
314,
570,
1564,
370,
314,
6387,
4242,
931,
14,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
2614,
63,
694,
12,
4242,
63,
354,
395,
283,
6603,
358,
465,
909,
63,
493,
26,
881,
909,
63,
493,
14,
952,
8,
493,
63,
1317,
9,
267,
2059,
2541,
327,
8232,
3575,
642,
570,
340,
314,
2011,
570,
1990,
2575,
12509,
14,
489,
916,
12509,
63,
1725,
59,
5094,
63,
354,
61,
508,
10017,
26,
267,
2059,
421,
199,
318,
485,
4208,
63,
5540,
63,
10309,
8,
1501,
26,
620,
9,
1035,
25769,
59,
495,
2189,
523,
408,
20551,
314,
6042,
6203,
543,
16316,
536,
4739,
3483,
14,
819,
961,
5922,
805,
1642,
14801,
314,
1627,
1788,
6337,
12,
436,
13372,
590,
523,
14801,
6042,
6203,
701,
11609,
316,
1329,
4739,
370,
314,
9593,
14,
819,
3033,
26,
272,
1788,
26,
710,
3379,
1788,
370,
506,
6042,
14,
819,
23771,
83,
26,
272,
710,
3379,
1788,
436,
2066,
6042,
6203,
543,
16316,
4739,
14,
523,
408,
523,
1995,
1788,
819,
1300,
12,
1599,
275,
747,
14,
515,
14,
7973,
8,
1501,
9,
523,
367,
536,
63,
4511,
315,
7975,
14,
835,
8,
17,
12,
413,
304,
272,
1995,
9005,
24306,
11123,
908,
8,
1095,
12,
536,
63,
4511,
12,
1599,
9,
421,
199,
318,
485,
1074,
63,
6404,
63,
5233,
8,
6404,
63,
493,
26,
5890,
14,
23139,
23413,
9,
1035,
488,
26,
523,
408,
11834,
340,
314,
570,
965,
314,
3211,
6359,
1406,
4955,
14,
819,
710,
3920,
365,
12155,
370,
314,
1642,
2808,
570,
1406,
3420,
2410,
523,
8792,
7907,
314,
4955,
14,
819,
3033,
26,
272,
6359,
63,
493,
26,
710,
6359,
570,
909,
20686,
737,
2399,
9608,
14,
819,
6218,
26,
272,
6064,
26,
710,
6359,
4955,
365,
3866,
14,
523,
408
] |
[
1898,
499,
15385,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
3,
491,
442,
465,
26,
2366,
19,
199,
624,
2377,
367,
30137,
909,
1584,
687,
282,
10311,
6359,
17048,
65,
9,
570,
14,
199,
199,
2765,
859,
6571,
9330,
18871,
13130,
370,
314,
283,
285,
446,
88,
7,
1414,
12,
199,
6777,
5536,
83,
734,
1006,
909,
1584,
687,
282,
1627,
6359,
570,
14,
961,
859,
199,
21946,
83,
314,
6359,
365,
315,
314,
6289,
9854,
1475,
1202,
315,
21257,
10677,
14,
199,
199,
9295,
26,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1596,
2531,
21607,
28017,
15400,
63,
8759,
199,
199,
2765,
31295,
965,
2877,
11012,
15109,
13524,
370,
314,
283,
285,
446,
88,
7,
1414,
199,
3319,
1915,
543,
10602,
14,
199,
199,
17,
14,
221,
3979,
2337,
787,
3663,
909,
1584,
543,
314,
2011,
536,
315,
282,
1627,
6359,
12,
272,
1924,
570,
365,
17864,
880,
626,
2985,
787,
1006,
6657,
12509,
1928,
272,
32592,
1924,
1163,
14,
199,
199,
18,
14,
221,
961,
859,
6181,
314,
5724,
2082,
465,
376,
4722,
2725,
14,
339,
5679,
11028,
26,
339,
6359,
63,
515,
275,
2263,
272,
2053,
63,
694,
275,
2263,
272,
5536,
63,
785,
63,
1725,
8,
6404,
63,
515,
12,
2053,
63,
694,
9,
199,
624,
199,
199,
646,
8337,
199,
646,
5890,
199,
646,
7975,
199,
646,
747,
199,
646,
2702,
199,
504,
14090,
492,
25769,
12,
11634,
421,
199,
318,
5536,
63,
785,
63,
1725,
8,
6404,
63,
493,
26,
5890,
14,
23139,
23413,
12,
586,
2053,
63,
694,
26,
620,
9,
1035,
488,
26,
523,
408,
12147,
83,
909,
1584,
687,
314,
6359,
931,
370,
314,
5724,
2082,
14,
819,
12892,
83,
909,
1584,
687,
314,
1627,
6289,
9854,
6359,
570,
14,
710,
12509,
523,
1584,
787,
5313,
370,
314,
5724,
2082,
12,
1314,
911,
506,
2737,
340,
314,
523,
2082,
1630,
440,
2187,
14,
819,
3626,
317,
1098,
909,
570,
1561,
787,
5847,
17864,
12188,
19967,
315,
1865,
523,
370,
5126,
625,
262,
6943,
32592,
14,
819,
3033,
26,
272,
6359,
63,
493,
26,
710,
6359,
570,
909,
20686,
737,
2399,
9608,
14,
272,
2053,
63,
694,
26,
710,
5724,
2082,
931,
315,
1314,
314,
12509,
909,
1584,
489,
911,
506,
5313,
14,
710,
2082,
911,
506,
2737,
340,
652,
1630,
440,
2187,
14,
523,
408,
523,
340,
440,
747,
14,
515,
14,
2444,
8,
2614,
63,
694,
304,
272,
747,
14,
8347,
8,
2614,
63,
694,
9,
819,
485,
1074,
63,
6404,
63,
5233,
8,
6404,
63,
493,
9,
819,
327,
14797,
314,
12509,
570,
1561,
436,
3932,
1564,
2631,
1338,
12,
315,
1865,
370,
523,
327,
2429,
9250,
1561,
6657,
14,
523,
12509,
63,
1725,
275,
1211,
342,
819,
367,
536,
12,
570,
63,
1317,
315,
485,
5005,
63,
2184,
63,
493,
8,
6404,
63,
493,
304,
272,
10017,
275,
8337,
14,
1064,
21,
8,
493,
63,
1317,
680,
5671,
342,
339,
327,
2670,
340,
314,
536,
365,
2575,
1202,
14,
982,
880,
12,
11492,
1536,
543,
282,
3365,
536,
701,
272,
327,
11609,
316,
314,
1329,
4739,
5133,
652,
17651,
376,
9563,
1373,
14,
272,
327,
2104,
2893,
12,
340,
283,
1421,
14,
79,
7,
365,
1202,
12,
862,
283,
1421,
63,
17,
14,
79,
297,
283,
1421,
63,
18,
14,
79,
297,
436,
880,
641,
14,
272,
367,
4242,
63,
354,
315,
485,
4208,
63,
5540,
63,
10309,
8,
354,
304,
489,
340,
4242,
63,
354,
440,
315,
12509,
63,
1725,
26,
267,
12509,
63,
1725,
59,
5094,
63,
354,
61,
275,
10017,
398,
327,
6990,
314,
570,
1564,
370,
314,
6387,
4242,
931,
14,
267,
543,
1551,
8,
736,
14,
515,
14,
904,
8,
2614,
63,
694,
12,
4242,
63,
354,
395,
283,
6603,
358,
465,
909,
63,
493,
26,
881,
909,
63,
493,
14,
952,
8,
493,
63,
1317,
9,
267,
2059,
2541,
327,
8232,
3575,
642,
570,
340,
314,
2011,
570,
1990,
2575,
12509,
14,
489,
916,
12509,
63,
1725,
59,
5094,
63,
354,
61,
508,
10017,
26,
267,
2059,
421,
199,
318,
485,
4208,
63,
5540,
63,
10309,
8,
1501,
26,
620,
9,
1035,
25769,
59,
495,
2189,
523,
408,
20551,
314,
6042,
6203,
543,
16316,
536,
4739,
3483,
14,
819,
961,
5922,
805,
1642,
14801,
314,
1627,
1788,
6337,
12,
436,
13372,
590,
523,
14801,
6042,
6203,
701,
11609,
316,
1329,
4739,
370,
314,
9593,
14,
819,
3033,
26,
272,
1788,
26,
710,
3379,
1788,
370,
506,
6042,
14,
819,
23771,
83,
26,
272,
710,
3379,
1788,
436,
2066,
6042,
6203,
543,
16316,
4739,
14,
523,
408,
523,
1995,
1788,
819,
1300,
12,
1599,
275,
747,
14,
515,
14,
7973,
8,
1501,
9,
523,
367,
536,
63,
4511,
315,
7975,
14,
835,
8,
17,
12,
413,
304,
272,
1995,
9005,
24306,
11123,
908,
8,
1095,
12,
536,
63,
4511,
12,
1599,
9,
421,
199,
318,
485,
1074,
63,
6404,
63,
5233,
8,
6404,
63,
493,
26,
5890,
14,
23139,
23413,
9,
1035,
488,
26,
523,
408,
11834,
340,
314,
570,
965,
314,
3211,
6359,
1406,
4955,
14,
819,
710,
3920,
365,
12155,
370,
314,
1642,
2808,
570,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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
atdaemon/pip
|
pip/_vendor/lockfile/mkdirlockfile.py
|
536
|
3096
|
from __future__ import absolute_import, division
import time
import os
import sys
import errno
from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout,
AlreadyLocked)
class MkdirLockFile(LockBase):
"""Lock file by creating a directory."""
def __init__(self, path, threaded=True, timeout=None):
"""
>>> lock = MkdirLockFile('somefile')
>>> lock = MkdirLockFile('somefile', threaded=False)
"""
LockBase.__init__(self, path, threaded, timeout)
# Lock file itself is a directory. Place the unique file name into
# it.
self.unique_name = os.path.join(self.lock_file,
"%s.%s%s" % (self.hostname,
self.tname,
self.pid))
def acquire(self, timeout=None):
timeout = timeout if timeout is not None else self.timeout
end_time = time.time()
if timeout is not None and timeout > 0:
end_time += timeout
if timeout is None:
wait = 0.1
else:
wait = max(0, timeout / 10)
while True:
try:
os.mkdir(self.lock_file)
except OSError:
err = sys.exc_info()[1]
if err.errno == errno.EEXIST:
# Already locked.
if os.path.exists(self.unique_name):
# Already locked by me.
return
if timeout is not None and time.time() > end_time:
if timeout > 0:
raise LockTimeout("Timeout waiting to acquire"
" lock for %s" %
self.path)
else:
# Someone else has the lock.
raise AlreadyLocked("%s is already locked" %
self.path)
time.sleep(wait)
else:
# Couldn't create the lock for some other reason
raise LockFailed("failed to create %s" % self.lock_file)
else:
open(self.unique_name, "wb").close()
return
def release(self):
if not self.is_locked():
raise NotLocked("%s is not locked" % self.path)
elif not os.path.exists(self.unique_name):
raise NotMyLock("%s is locked, but not by me" % self.path)
os.unlink(self.unique_name)
os.rmdir(self.lock_file)
def is_locked(self):
return os.path.exists(self.lock_file)
def i_am_locking(self):
return (self.is_locked() and
os.path.exists(self.unique_name))
def break_lock(self):
if os.path.exists(self.lock_file):
for name in os.listdir(self.lock_file):
os.unlink(os.path.join(self.lock_file, name))
os.rmdir(self.lock_file)
|
mit
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
199,
199,
646,
900,
199,
646,
747,
199,
646,
984,
199,
646,
7554,
199,
199,
504,
1275,
492,
334,
6432,
1563,
12,
15536,
4276,
12,
2832,
22408,
12,
2832,
5713,
6432,
12,
15536,
6372,
12,
2049,
21086,
22408,
9,
421,
199,
533,
603,
75,
694,
6432,
1173,
8,
6432,
1563,
304,
272,
408,
6432,
570,
701,
6425,
282,
2082,
1041,
272,
347,
636,
826,
721,
277,
12,
931,
12,
25396,
29,
549,
12,
2653,
29,
403,
304,
267,
408,
267,
1306,
4650,
275,
603,
75,
694,
6432,
1173,
360,
3972,
493,
358,
267,
1306,
4650,
275,
603,
75,
694,
6432,
1173,
360,
3972,
493,
297,
25396,
29,
797,
9,
267,
408,
267,
15536,
1563,
855,
826,
721,
277,
12,
931,
12,
25396,
12,
2653,
9,
267,
327,
15536,
570,
6337,
365,
282,
2082,
14,
221,
10902,
314,
3747,
570,
536,
1901,
267,
327,
652,
14,
267,
291,
14,
3235,
63,
354,
275,
747,
14,
515,
14,
904,
8,
277,
14,
831,
63,
493,
12,
3147,
2071,
83,
4111,
83,
5,
83,
2,
450,
334,
277,
14,
4269,
12,
9349,
291,
14,
31383,
12,
9349,
291,
14,
3150,
430,
339,
347,
16919,
8,
277,
12,
2653,
29,
403,
304,
267,
2653,
275,
2653,
340,
2653,
365,
440,
488,
587,
291,
14,
2593,
267,
1284,
63,
521,
275,
900,
14,
521,
342,
267,
340,
2653,
365,
440,
488,
436,
2653,
690,
378,
26,
288,
1284,
63,
521,
847,
2653,
398,
340,
2653,
365,
488,
26,
288,
3618,
275,
378,
14,
17,
267,
587,
26,
288,
3618,
275,
1390,
8,
16,
12,
2653,
1182,
1616,
9,
398,
1830,
715,
26,
288,
862,
26,
355,
747,
14,
8215,
8,
277,
14,
831,
63,
493,
9,
288,
871,
6440,
26,
355,
2329,
275,
984,
14,
2804,
63,
815,
3430,
17,
61,
355,
340,
2329,
14,
7931,
508,
7554,
14,
28596,
26,
490,
327,
21086,
14233,
14,
490,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
3235,
63,
354,
304,
717,
327,
21086,
14233,
701,
562,
14,
717,
372,
490,
340,
2653,
365,
440,
488,
436,
900,
14,
521,
342,
690,
1284,
63,
521,
26,
717,
340,
2653,
690,
378,
26,
1169,
746,
15536,
6372,
480,
6372,
10923,
370,
16919,
2,
6343,
298,
4650,
367,
450,
83,
2,
450,
6343,
291,
14,
515,
9,
717,
587,
26,
1169,
327,
6601,
368,
587,
965,
314,
4650,
14,
1169,
746,
21086,
22408,
3647,
83,
365,
2575,
14233,
2,
450,
6059,
291,
14,
515,
9,
490,
900,
14,
4532,
8,
2573,
9,
355,
587,
26,
490,
327,
18615,
78,
1133,
1218,
314,
4650,
367,
2005,
1163,
4499,
490,
746,
15536,
4276,
480,
4892,
370,
1218,
450,
83,
2,
450,
291,
14,
831,
63,
493,
9,
288,
587,
26,
355,
1551,
8,
277,
14,
3235,
63,
354,
12,
298,
6603,
3471,
1600,
342,
355,
372,
339,
347,
4683,
8,
277,
304,
267,
340,
440,
291,
14,
374,
63,
9325,
837,
288,
746,
2832,
22408,
3647,
83,
365,
440,
14233,
2,
450,
291,
14,
515,
9,
267,
916,
440,
747,
14,
515,
14,
2444,
8,
277,
14,
3235,
63,
354,
304,
288,
746,
2832,
5713,
6432,
3647,
83,
365,
14233,
12,
1325,
440,
701,
562,
2,
450,
291,
14,
515,
9,
267,
747,
14,
7162,
8,
277,
14,
3235,
63,
354,
9,
267,
747,
14,
19405,
8,
277,
14,
831,
63,
493,
9,
339,
347,
365,
63,
9325,
8,
277,
304,
267,
372,
747,
14,
515,
14,
2444,
8,
277,
14,
831,
63,
493,
9,
339,
347,
284,
63,
455,
63,
24056,
8,
277,
304,
267,
372,
334,
277,
14,
374,
63,
9325,
342,
436,
355,
747,
14,
515,
14,
2444,
8,
277,
14,
3235,
63,
354,
430,
339,
347,
2059,
63,
831,
8,
277,
304,
267,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
831,
63,
493,
304,
288,
367,
536,
315,
747,
14,
7374,
8,
277,
14,
831,
63,
493,
304,
355,
747,
14,
7162,
8,
736,
14,
515,
14,
904,
8,
277,
14,
831,
63,
493,
12,
536,
430,
288,
747,
14,
19405,
8,
277,
14,
831,
63,
493,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
199,
199,
646,
900,
199,
646,
747,
199,
646,
984,
199,
646,
7554,
199,
199,
504,
1275,
492,
334,
6432,
1563,
12,
15536,
4276,
12,
2832,
22408,
12,
2832,
5713,
6432,
12,
15536,
6372,
12,
2049,
21086,
22408,
9,
421,
199,
533,
603,
75,
694,
6432,
1173,
8,
6432,
1563,
304,
272,
408,
6432,
570,
701,
6425,
282,
2082,
1041,
272,
347,
636,
826,
721,
277,
12,
931,
12,
25396,
29,
549,
12,
2653,
29,
403,
304,
267,
408,
267,
1306,
4650,
275,
603,
75,
694,
6432,
1173,
360,
3972,
493,
358,
267,
1306,
4650,
275,
603,
75,
694,
6432,
1173,
360,
3972,
493,
297,
25396,
29,
797,
9,
267,
408,
267,
15536,
1563,
855,
826,
721,
277,
12,
931,
12,
25396,
12,
2653,
9,
267,
327,
15536,
570,
6337,
365,
282,
2082,
14,
221,
10902,
314,
3747,
570,
536,
1901,
267,
327,
652,
14,
267,
291,
14,
3235,
63,
354,
275,
747,
14,
515,
14,
904,
8,
277,
14,
831,
63,
493,
12,
3147,
2071,
83,
4111,
83,
5,
83,
2,
450,
334,
277,
14,
4269,
12,
9349,
291,
14,
31383,
12,
9349,
291,
14,
3150,
430,
339,
347,
16919,
8,
277,
12,
2653,
29,
403,
304,
267,
2653,
275,
2653,
340,
2653,
365,
440,
488,
587,
291,
14,
2593,
267,
1284,
63,
521,
275,
900,
14,
521,
342,
267,
340,
2653,
365,
440,
488,
436,
2653,
690,
378,
26,
288,
1284,
63,
521,
847,
2653,
398,
340,
2653,
365,
488,
26,
288,
3618,
275,
378,
14,
17,
267,
587,
26,
288,
3618,
275,
1390,
8,
16,
12,
2653,
1182,
1616,
9,
398,
1830,
715,
26,
288,
862,
26,
355,
747,
14,
8215,
8,
277,
14,
831,
63,
493,
9,
288,
871,
6440,
26,
355,
2329,
275,
984,
14,
2804,
63,
815,
3430,
17,
61,
355,
340,
2329,
14,
7931,
508,
7554,
14,
28596,
26,
490,
327,
21086,
14233,
14,
490,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
3235,
63,
354,
304,
717,
327,
21086,
14233,
701,
562,
14,
717,
372,
490,
340,
2653,
365,
440,
488,
436,
900,
14,
521,
342,
690,
1284,
63,
521,
26,
717,
340,
2653,
690,
378,
26,
1169,
746,
15536,
6372,
480,
6372,
10923,
370,
16919,
2,
6343,
298,
4650,
367,
450,
83,
2,
450,
6343,
291,
14,
515,
9,
717,
587,
26,
1169,
327,
6601,
368,
587,
965,
314,
4650,
14,
1169,
746,
21086,
22408,
3647,
83,
365,
2575,
14233,
2,
450,
6059,
291,
14,
515,
9,
490,
900,
14,
4532,
8,
2573,
9,
355,
587,
26,
490,
327,
18615,
78,
1133,
1218,
314,
4650,
367,
2005,
1163,
4499,
490,
746,
15536,
4276,
480,
4892,
370,
1218,
450,
83,
2,
450,
291,
14,
831,
63,
493,
9,
288,
587,
26,
355,
1551,
8,
277,
14,
3235,
63,
354,
12,
298,
6603,
3471,
1600,
342,
355,
372,
339,
347,
4683,
8,
277,
304,
267,
340,
440,
291,
14,
374,
63,
9325,
837,
288,
746,
2832,
22408,
3647,
83,
365,
440,
14233,
2,
450,
291,
14,
515,
9,
267,
916,
440,
747,
14,
515,
14,
2444,
8,
277,
14,
3235,
63,
354,
304,
288,
746,
2832,
5713,
6432,
3647,
83,
365,
14233,
12,
1325,
440,
701,
562,
2,
450,
291,
14,
515,
9,
267,
747,
14,
7162,
8,
277,
14,
3235,
63,
354,
9,
267,
747,
14,
19405,
8,
277,
14,
831,
63,
493,
9,
339,
347,
365,
63,
9325,
8,
277,
304,
267,
372,
747,
14,
515,
14,
2444,
8,
277,
14,
831,
63,
493,
9,
339,
347,
284,
63,
455,
63,
24056,
8,
277,
304,
267,
372,
334,
277,
14,
374,
63,
9325,
342,
436,
355,
747,
14,
515,
14,
2444,
8,
277,
14,
3235,
63,
354,
430,
339,
347,
2059,
63,
831,
8,
277,
304,
267,
340,
747,
14,
515,
14,
2444,
8,
277,
14,
831,
63,
493,
304,
288,
367,
536,
315,
747,
14,
7374,
8,
277,
14,
831,
63,
493,
304,
355,
747,
14,
7162,
8,
736,
14,
515,
14,
904,
8,
277,
14,
831,
63,
493,
12,
536,
430,
288,
747,
14,
19405,
8,
277,
14,
831,
63,
493,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
mrquim/repository.mrquim
|
repo/script.module.unidecode/lib/unidecode/__init__.py
|
36
|
1882
|
# -*- coding: utf-8 -*-
# vi:tabstop=4:expandtab:sw=4
"""Transliterate Unicode text into plain 7-bit ASCII.
Example usage:
>>> from unidecode import unidecode:
>>> unidecode(u"\u5317\u4EB0")
"Bei Jing "
The transliteration uses a straightforward map, and doesn't have alternatives
for the same character based on language, position, or anything else.
In Python 3, a standard string object will be returned. If you need bytes, use:
>>> unidecode("Κνωσός").encode("ascii")
b'Knosos'
"""
import warnings
from sys import version_info
Cache = {}
def unidecode(string):
"""Transliterate an Unicode object into an ASCII string
>>> unidecode(u"\u5317\u4EB0")
"Bei Jing "
"""
if version_info[0] < 3 and not isinstance(string, unicode):
warnings.warn( "Argument %r is not an unicode object. "
"Passing an encoded string will likely have "
"unexpected results." % (type(string),),
RuntimeWarning, 2)
retval = []
for char in string:
codepoint = ord(char)
if codepoint < 0x80: # Basic ASCII
retval.append(str(char))
continue
if codepoint > 0xeffff:
continue # Characters in Private Use Area and above are ignored
section = codepoint >> 8 # Chop off the last two hex digits
position = codepoint % 256 # Last two hex digits
try:
table = Cache[section]
except KeyError:
try:
mod = __import__('unidecode.x%03x'%(section), [], [], ['data'])
except ImportError:
Cache[section] = None
continue # No match: ignore this character and carry on.
Cache[section] = table = mod.data
if table and len(table) > position:
retval.append( table[position] )
return ''.join(retval)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1321,
26,
6492,
29,
20,
26,
10379,
26,
3519,
29,
20,
199,
624,
3188,
4544,
323,
6140,
1318,
1901,
8971,
1520,
13,
2075,
10485,
14,
199,
199,
9846,
4503,
26,
199,
6071,
687,
625,
2655,
600,
492,
625,
2655,
600,
26,
199,
6071,
625,
2655,
600,
8,
85,
3212,
85,
15341,
60,
85,
20,
14138,
16,
531,
199,
2,
3655,
73,
1603,
316,
298,
199,
199,
1918,
1752,
5333,
1754,
4440,
282,
23669,
6688,
2341,
12,
436,
3181,
1133,
1172,
8679,
10661,
199,
509,
314,
2011,
4528,
4079,
641,
2637,
12,
3421,
12,
503,
7003,
587,
14,
199,
199,
607,
2018,
650,
12,
282,
4465,
1059,
909,
911,
506,
2138,
14,
982,
1265,
1929,
2783,
12,
675,
26,
199,
6071,
625,
2655,
600,
480,
139,
249,
17444,
140,
232,
20136,
140,
235,
25128,
3471,
2143,
480,
4371,
531,
199,
66,
7,
43,
12712,
736,
7,
199,
624,
199,
646,
3598,
199,
504,
984,
492,
1015,
63,
815,
199,
199,
4437,
275,
1052,
199,
199,
318,
625,
2655,
600,
8,
875,
304,
272,
408,
3188,
4544,
323,
376,
6140,
909,
1901,
376,
10485,
1059,
339,
1306,
625,
2655,
600,
8,
85,
3212,
85,
15341,
60,
85,
20,
14138,
16,
531,
272,
298,
3655,
73,
1603,
316,
298,
272,
408,
339,
340,
1015,
63,
815,
59,
16,
61,
665,
650,
436,
440,
1228,
8,
875,
12,
2649,
304,
267,
3598,
14,
4050,
8,
221,
298,
5201,
450,
82,
365,
440,
376,
2649,
909,
14,
298,
717,
298,
4986,
316,
376,
5737,
1059,
911,
12060,
1172,
298,
717,
298,
8953,
2058,
2122,
450,
334,
466,
8,
875,
30148,
686,
198,
14357,
3849,
12,
499,
9,
339,
9151,
275,
942,
339,
367,
1495,
315,
1059,
26,
267,
1233,
1403,
275,
6206,
8,
1560,
9,
398,
340,
1233,
1403,
665,
378,
88,
1257,
26,
327,
10082,
10485,
288,
9151,
14,
740,
8,
495,
8,
1560,
430,
288,
1980,
2728,
340,
1233,
1403,
690,
378,
1845,
4717,
26,
288,
1980,
327,
6659,
7421,
315,
18551,
3645,
26280,
436,
3432,
787,
5525,
398,
3420,
275,
1233,
1403,
4331,
1695,
257,
327,
2799,
411,
2331,
314,
2061,
2877,
6318,
7576,
267,
3421,
275,
1233,
1403,
450,
7633,
327,
15237,
2877,
6318,
7576,
398,
862,
26,
288,
1817,
275,
11977,
59,
2792,
61,
267,
871,
4067,
26,
288,
862,
26,
355,
3413,
275,
636,
646,
19734,
324,
2655,
600,
14,
88,
5,
1644,
88,
13328,
2792,
395,
990,
990,
788,
576,
1105,
288,
871,
3545,
26,
355,
11977,
59,
2792,
61,
275,
488,
355,
1980,
257,
327,
3091,
1336,
26,
3686,
642,
4528,
436,
25176,
641,
14,
953,
11977,
59,
2792,
61,
275,
1817,
275,
3413,
14,
576,
398,
340,
1817,
436,
822,
8,
1224,
9,
690,
3421,
26,
288,
9151,
14,
740,
8,
1817,
59,
3124,
61,
776,
339,
372,
6522,
904,
8,
18476,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1321,
26,
6492,
29,
20,
26,
10379,
26,
3519,
29,
20,
199,
624,
3188,
4544,
323,
6140,
1318,
1901,
8971,
1520,
13,
2075,
10485,
14,
199,
199,
9846,
4503,
26,
199,
6071,
687,
625,
2655,
600,
492,
625,
2655,
600,
26,
199,
6071,
625,
2655,
600,
8,
85,
3212,
85,
15341,
60,
85,
20,
14138,
16,
531,
199,
2,
3655,
73,
1603,
316,
298,
199,
199,
1918,
1752,
5333,
1754,
4440,
282,
23669,
6688,
2341,
12,
436,
3181,
1133,
1172,
8679,
10661,
199,
509,
314,
2011,
4528,
4079,
641,
2637,
12,
3421,
12,
503,
7003,
587,
14,
199,
199,
607,
2018,
650,
12,
282,
4465,
1059,
909,
911,
506,
2138,
14,
982,
1265,
1929,
2783,
12,
675,
26,
199,
6071,
625,
2655,
600,
480,
139,
249,
17444,
140,
232,
20136,
140,
235,
25128,
3471,
2143,
480,
4371,
531,
199,
66,
7,
43,
12712,
736,
7,
199,
624,
199,
646,
3598,
199,
504,
984,
492,
1015,
63,
815,
199,
199,
4437,
275,
1052,
199,
199,
318,
625,
2655,
600,
8,
875,
304,
272,
408,
3188,
4544,
323,
376,
6140,
909,
1901,
376,
10485,
1059,
339,
1306,
625,
2655,
600,
8,
85,
3212,
85,
15341,
60,
85,
20,
14138,
16,
531,
272,
298,
3655,
73,
1603,
316,
298,
272,
408,
339,
340,
1015,
63,
815,
59,
16,
61,
665,
650,
436,
440,
1228,
8,
875,
12,
2649,
304,
267,
3598,
14,
4050,
8,
221,
298,
5201,
450,
82,
365,
440,
376,
2649,
909,
14,
298,
717,
298,
4986,
316,
376,
5737,
1059,
911,
12060,
1172,
298,
717,
298,
8953,
2058,
2122,
450,
334,
466,
8,
875,
30148,
686,
198,
14357,
3849,
12,
499,
9,
339,
9151,
275,
942,
339,
367,
1495,
315,
1059,
26,
267,
1233,
1403,
275,
6206,
8,
1560,
9,
398,
340,
1233,
1403,
665,
378,
88,
1257,
26,
327,
10082,
10485,
288,
9151,
14,
740,
8,
495,
8,
1560,
430,
288,
1980,
2728,
340,
1233,
1403,
690,
378,
1845,
4717,
26,
288,
1980,
327,
6659,
7421,
315,
18551,
3645,
26280,
436,
3432,
787,
5525,
398,
3420,
275,
1233,
1403,
4331,
1695,
257,
327,
2799,
411,
2331,
314,
2061,
2877,
6318,
7576,
267,
3421,
275,
1233,
1403,
450,
7633,
327,
15237,
2877,
6318,
7576,
398,
862,
26,
288,
1817,
275,
11977,
59,
2792,
61,
267,
871,
4067,
26,
288,
862,
26,
355,
3413,
275,
636,
646,
19734,
324,
2655,
600,
14,
88,
5,
1644,
88,
13328,
2792,
395,
990,
990,
788,
576,
1105,
288,
871,
3545,
26,
355,
11977,
59,
2792,
61,
275,
488,
355,
1980,
257,
327,
3091,
1336,
26,
3686,
642,
4528,
436,
25176,
641,
14,
953,
11977,
59,
2792,
61,
275,
1817,
275,
3413,
14,
576,
398,
340,
1817,
436,
822,
8,
1224,
9,
690,
3421,
26,
288,
9151,
14,
740,
8,
1817,
59,
3124,
61,
776,
339,
372,
6522,
904,
8,
18476,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
GauriGNaik/servo
|
tests/wpt/web-platform-tests/tools/html5lib/html5lib/serializer/htmlserializer.py
|
423
|
12897
|
from __future__ import absolute_import, division, unicode_literals
from six import text_type
import gettext
_ = gettext.gettext
try:
from functools import reduce
except ImportError:
pass
from ..constants import voidElements, booleanAttributes, spaceCharacters
from ..constants import rcdataElements, entities, xmlEntities
from .. import utils
from xml.sax.saxutils import escape
spaceCharacters = "".join(spaceCharacters)
try:
from codecs import register_error, xmlcharrefreplace_errors
except ImportError:
unicode_encode_errors = "strict"
else:
unicode_encode_errors = "htmlentityreplace"
encode_entity_map = {}
is_ucs4 = len("\U0010FFFF") == 1
for k, v in list(entities.items()):
# skip multi-character entities
if ((is_ucs4 and len(v) > 1) or
(not is_ucs4 and len(v) > 2)):
continue
if v != "&":
if len(v) == 2:
v = utils.surrogatePairToCodepoint(v)
else:
v = ord(v)
if v not in encode_entity_map or k.islower():
# prefer < over < and similarly for &, >, etc.
encode_entity_map[v] = k
def htmlentityreplace_errors(exc):
if isinstance(exc, (UnicodeEncodeError, UnicodeTranslateError)):
res = []
codepoints = []
skip = False
for i, c in enumerate(exc.object[exc.start:exc.end]):
if skip:
skip = False
continue
index = i + exc.start
if utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])]):
codepoint = utils.surrogatePairToCodepoint(exc.object[index:index + 2])
skip = True
else:
codepoint = ord(c)
codepoints.append(codepoint)
for cp in codepoints:
e = encode_entity_map.get(cp)
if e:
res.append("&")
res.append(e)
if not e.endswith(";"):
res.append(";")
else:
res.append("&#x%s;" % (hex(cp)[2:]))
return ("".join(res), exc.end)
else:
return xmlcharrefreplace_errors(exc)
register_error(unicode_encode_errors, htmlentityreplace_errors)
del register_error
class HTMLSerializer(object):
# attribute quoting options
quote_attr_values = False
quote_char = '"'
use_best_quote_char = True
# tag syntax options
omit_optional_tags = True
minimize_boolean_attributes = True
use_trailing_solidus = False
space_before_trailing_solidus = True
# escaping options
escape_lt_in_attrs = False
escape_rcdata = False
resolve_entities = True
# miscellaneous options
alphabetical_attributes = False
inject_meta_charset = True
strip_whitespace = False
sanitize = False
options = ("quote_attr_values", "quote_char", "use_best_quote_char",
"omit_optional_tags", "minimize_boolean_attributes",
"use_trailing_solidus", "space_before_trailing_solidus",
"escape_lt_in_attrs", "escape_rcdata", "resolve_entities",
"alphabetical_attributes", "inject_meta_charset",
"strip_whitespace", "sanitize")
def __init__(self, **kwargs):
"""Initialize HTMLSerializer.
Keyword options (default given first unless specified) include:
inject_meta_charset=True|False
Whether it insert a meta element to define the character set of the
document.
quote_attr_values=True|False
Whether to quote attribute values that don't require quoting
per HTML5 parsing rules.
quote_char=u'"'|u"'"
Use given quote character for attribute quoting. Default is to
use double quote unless attribute value contains a double quote,
in which case single quotes are used instead.
escape_lt_in_attrs=False|True
Whether to escape < in attribute values.
escape_rcdata=False|True
Whether to escape characters that need to be escaped within normal
elements within rcdata elements such as style.
resolve_entities=True|False
Whether to resolve named character entities that appear in the
source tree. The XML predefined entities < > & " '
are unaffected by this setting.
strip_whitespace=False|True
Whether to remove semantically meaningless whitespace. (This
compresses all whitespace to a single space except within pre.)
minimize_boolean_attributes=True|False
Shortens boolean attributes to give just the attribute value,
for example <input disabled="disabled"> becomes <input disabled>.
use_trailing_solidus=False|True
Includes a close-tag slash at the end of the start tag of void
elements (empty elements whose end tag is forbidden). E.g. <hr/>.
space_before_trailing_solidus=True|False
Places a space immediately before the closing slash in a tag
using a trailing solidus. E.g. <hr />. Requires use_trailing_solidus.
sanitize=False|True
Strip all unsafe or unknown constructs from output.
See `html5lib user documentation`_
omit_optional_tags=True|False
Omit start/end tags that are optional.
alphabetical_attributes=False|True
Reorder attributes to be in alphabetical order.
.. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation
"""
if 'quote_char' in kwargs:
self.use_best_quote_char = False
for attr in self.options:
setattr(self, attr, kwargs.get(attr, getattr(self, attr)))
self.errors = []
self.strict = False
def encode(self, string):
assert(isinstance(string, text_type))
if self.encoding:
return string.encode(self.encoding, unicode_encode_errors)
else:
return string
def encodeStrict(self, string):
assert(isinstance(string, text_type))
if self.encoding:
return string.encode(self.encoding, "strict")
else:
return string
def serialize(self, treewalker, encoding=None):
self.encoding = encoding
in_cdata = False
self.errors = []
if encoding and self.inject_meta_charset:
from ..filters.inject_meta_charset import Filter
treewalker = Filter(treewalker, encoding)
# WhitespaceFilter should be used before OptionalTagFilter
# for maximum efficiently of this latter filter
if self.strip_whitespace:
from ..filters.whitespace import Filter
treewalker = Filter(treewalker)
if self.sanitize:
from ..filters.sanitizer import Filter
treewalker = Filter(treewalker)
if self.omit_optional_tags:
from ..filters.optionaltags import Filter
treewalker = Filter(treewalker)
# Alphabetical attributes must be last, as other filters
# could add attributes and alter the order
if self.alphabetical_attributes:
from ..filters.alphabeticalattributes import Filter
treewalker = Filter(treewalker)
for token in treewalker:
type = token["type"]
if type == "Doctype":
doctype = "<!DOCTYPE %s" % token["name"]
if token["publicId"]:
doctype += ' PUBLIC "%s"' % token["publicId"]
elif token["systemId"]:
doctype += " SYSTEM"
if token["systemId"]:
if token["systemId"].find('"') >= 0:
if token["systemId"].find("'") >= 0:
self.serializeError(_("System identifer contains both single and double quote characters"))
quote_char = "'"
else:
quote_char = '"'
doctype += " %s%s%s" % (quote_char, token["systemId"], quote_char)
doctype += ">"
yield self.encodeStrict(doctype)
elif type in ("Characters", "SpaceCharacters"):
if type == "SpaceCharacters" or in_cdata:
if in_cdata and token["data"].find("</") >= 0:
self.serializeError(_("Unexpected </ in CDATA"))
yield self.encode(token["data"])
else:
yield self.encode(escape(token["data"]))
elif type in ("StartTag", "EmptyTag"):
name = token["name"]
yield self.encodeStrict("<%s" % name)
if name in rcdataElements and not self.escape_rcdata:
in_cdata = True
elif in_cdata:
self.serializeError(_("Unexpected child element of a CDATA element"))
for (attr_namespace, attr_name), attr_value in token["data"].items():
# TODO: Add namespace support here
k = attr_name
v = attr_value
yield self.encodeStrict(' ')
yield self.encodeStrict(k)
if not self.minimize_boolean_attributes or \
(k not in booleanAttributes.get(name, tuple())
and k not in booleanAttributes.get("", tuple())):
yield self.encodeStrict("=")
if self.quote_attr_values or not v:
quote_attr = True
else:
quote_attr = reduce(lambda x, y: x or (y in v),
spaceCharacters + ">\"'=", False)
v = v.replace("&", "&")
if self.escape_lt_in_attrs:
v = v.replace("<", "<")
if quote_attr:
quote_char = self.quote_char
if self.use_best_quote_char:
if "'" in v and '"' not in v:
quote_char = '"'
elif '"' in v and "'" not in v:
quote_char = "'"
if quote_char == "'":
v = v.replace("'", "'")
else:
v = v.replace('"', """)
yield self.encodeStrict(quote_char)
yield self.encode(v)
yield self.encodeStrict(quote_char)
else:
yield self.encode(v)
if name in voidElements and self.use_trailing_solidus:
if self.space_before_trailing_solidus:
yield self.encodeStrict(" /")
else:
yield self.encodeStrict("/")
yield self.encode(">")
elif type == "EndTag":
name = token["name"]
if name in rcdataElements:
in_cdata = False
elif in_cdata:
self.serializeError(_("Unexpected child element of a CDATA element"))
yield self.encodeStrict("</%s>" % name)
elif type == "Comment":
data = token["data"]
if data.find("--") >= 0:
self.serializeError(_("Comment contains --"))
yield self.encodeStrict("<!--%s-->" % token["data"])
elif type == "Entity":
name = token["name"]
key = name + ";"
if key not in entities:
self.serializeError(_("Entity %s not recognized" % name))
if self.resolve_entities and key not in xmlEntities:
data = entities[key]
else:
data = "&%s;" % name
yield self.encodeStrict(data)
else:
self.serializeError(token["data"])
def render(self, treewalker, encoding=None):
if encoding:
return b"".join(list(self.serialize(treewalker, encoding)))
else:
return "".join(list(self.serialize(treewalker)))
def serializeError(self, data="XXX ERROR MESSAGE NEEDED"):
# XXX The idea is to make data mandatory.
self.errors.append(data)
if self.strict:
raise SerializeError
def SerializeError(Exception):
"""Error in serialized tree"""
pass
|
mpl-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
504,
3816,
492,
1318,
63,
466,
199,
199,
646,
9796,
199,
63,
275,
9796,
14,
5152,
199,
199,
893,
26,
272,
687,
9143,
492,
7114,
199,
2590,
3545,
26,
272,
986,
199,
199,
504,
2508,
5559,
492,
2309,
6255,
12,
5046,
5379,
12,
25431,
199,
504,
2508,
5559,
492,
4819,
576,
6255,
12,
9045,
12,
2748,
24672,
199,
504,
2508,
492,
3778,
199,
504,
2748,
14,
14338,
14,
14338,
1208,
492,
4772,
199,
199,
2638,
9272,
275,
10587,
904,
8,
2638,
9272,
9,
199,
199,
893,
26,
272,
687,
6010,
492,
2274,
63,
705,
12,
2748,
24253,
1814,
63,
2550,
199,
2590,
3545,
26,
272,
2649,
63,
2143,
63,
2550,
275,
298,
4768,
2,
199,
2836,
26,
272,
2649,
63,
2143,
63,
2550,
275,
298,
15575,
552,
1701,
1814,
2,
339,
3752,
63,
4502,
63,
1130,
275,
1052,
272,
365,
63,
23880,
20,
275,
822,
4582,
53,
17657,
6968,
531,
508,
413,
272,
367,
1022,
12,
373,
315,
769,
8,
8327,
14,
1744,
5109,
267,
327,
3372,
3510,
13,
10856,
9045,
267,
340,
3666,
374,
63,
23880,
20,
436,
822,
8,
86,
9,
690,
413,
9,
503,
355,
334,
1397,
365,
63,
23880,
20,
436,
822,
8,
86,
9,
690,
499,
2298,
288,
1980,
267,
340,
373,
1137,
11746,
582,
288,
340,
822,
8,
86,
9,
508,
499,
26,
355,
373,
275,
3778,
14,
16380,
12882,
1378,
3034,
1403,
8,
86,
9,
288,
587,
26,
355,
373,
275,
6206,
8,
86,
9,
288,
340,
373,
440,
315,
3752,
63,
4502,
63,
1130,
503,
1022,
14,
374,
2325,
837,
355,
327,
16602,
1253,
4116,
27,
1806,
1253,
17090,
27,
436,
8545,
590,
367,
1253,
5282,
27031,
1253,
3308,
27031,
5423,
14,
355,
3752,
63,
4502,
63,
1130,
59,
86,
61,
275,
1022,
339,
347,
30010,
552,
1701,
1814,
63,
2550,
8,
2804,
304,
267,
340,
1228,
8,
2804,
12,
334,
7087,
19994,
12,
6140,
18355,
547,
2298,
288,
522,
275,
942,
288,
1233,
3438,
275,
942,
288,
3372,
275,
756,
288,
367,
284,
12,
286,
315,
3874,
8,
2804,
14,
785,
59,
2804,
14,
928,
26,
2804,
14,
500,
4682,
355,
340,
3372,
26,
490,
3372,
275,
756,
490,
1980,
355,
1478,
275,
284,
435,
3178,
14,
928,
355,
340,
3778,
14,
374,
11762,
13095,
12882,
8,
2804,
14,
785,
59,
1080,
26,
827,
779,
2804,
14,
500,
12,
1478,
435,
499,
566,
4682,
490,
1233,
1403,
275,
3778,
14,
16380,
12882,
1378,
3034,
1403,
8,
2804,
14,
785,
59,
1080,
26,
1080,
435,
499,
566,
490,
3372,
275,
715,
355,
587,
26,
490,
1233,
1403,
275,
6206,
8,
67,
9,
355,
1233,
3438,
14,
740,
8,
19300,
9,
288,
367,
7667,
315,
1233,
3438,
26,
355,
325,
275,
3752,
63,
4502,
63,
1130,
14,
362,
8,
1850,
9,
355,
340,
325,
26,
490,
522,
14,
740,
22077,
531,
490,
522,
14,
740,
8,
69,
9,
490,
340,
440,
325,
14,
4130,
480,
27,
2349,
717,
522,
14,
740,
480,
15027,
355,
587,
26,
490,
522,
14,
740,
480,
7997,
88,
5,
83,
9426,
450,
334,
4097,
8,
1850,
2788,
18,
16720,
288,
372,
334,
25148,
904,
8,
470,
395,
3178,
14,
500,
9,
267,
587,
26,
288,
372,
2748,
24253,
1814,
63,
2550,
8,
2804,
9,
339,
2274,
63,
705,
8,
2975,
63,
2143,
63,
2550,
12,
30010,
552,
1701,
1814,
63,
2550,
9,
339,
2150,
2274,
63,
705,
421,
199,
533,
4163,
7299,
8,
785,
304,
339,
327,
2225,
18593,
1511,
272,
6313,
63,
962,
63,
1459,
275,
756,
272,
6313,
63,
1560,
275,
14788,
272,
675,
63,
7010,
63,
3513,
63,
1560,
275,
715,
339,
327,
1947,
6302,
1511,
272,
19413,
63,
4144,
63,
2969,
275,
715,
272,
24720,
63,
4871,
63,
2987,
275,
715,
272,
675,
63,
15910,
63,
18533,
527,
275,
756,
272,
4601,
63,
5182,
63,
15910,
63,
18533,
527,
275,
715,
339,
327,
21375,
1511,
272,
4772,
63,
4116,
63,
262,
63,
3288,
275,
756,
272,
4772,
63,
1195,
576,
275,
756,
272,
7512,
63,
8327,
275,
715,
339,
327,
3201,
19549,
1511,
272,
23331,
3294,
63,
2987,
275,
756,
272,
16182,
63,
2024,
63,
6043,
275,
715,
272,
6202,
63,
8506,
275,
756,
272,
21077,
275,
756,
339,
1511,
275,
1689,
3513,
63,
962,
63,
1459,
401,
298,
3513,
63,
1560,
401,
298,
1180,
63,
7010,
63,
3513,
63,
1560,
401,
2049,
298,
19007,
63,
4144,
63,
2969,
401,
298,
19333,
63,
4871,
63,
2987,
401,
2049,
298,
1180,
63,
15910,
63,
18533,
527,
401,
298,
2638,
63,
5182,
63,
15910,
63,
18533,
527,
401,
2049,
298,
3765,
63,
4116,
63,
262,
63,
3288,
401,
298,
3765,
63,
1195,
576,
401,
298,
6983,
63,
8327,
401,
2049,
298,
10305,
7570,
3294,
63,
2987,
401,
298,
14815,
63,
2024,
63,
6043,
401,
2049,
298,
1913,
63,
8506,
401,
298,
18177,
531,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
408,
9345,
4163,
7299,
14,
398,
6431,
1511,
334,
885,
1627,
1642,
7444,
2013,
9,
2387,
26,
398,
16182,
63,
2024,
63,
6043,
29,
549,
92,
797,
881,
7480,
652,
5518,
282,
3404,
1819,
370,
5627,
314,
4528,
663,
402,
314,
881,
2213,
14,
267,
6313,
63,
962,
63,
1459,
29,
549,
92,
797,
881,
7480,
370,
6313,
2225,
1338,
626,
2793,
1133,
4409,
18593,
881,
1126,
4163,
21,
6057,
4713,
14,
267,
6313,
63,
1560,
29,
85,
4065,
17018,
85,
2,
4065,
881,
3645,
1627,
6313,
4528,
367,
2225,
18593,
14,
3758,
365,
370,
881,
675,
4270,
6313,
7444,
2225,
574,
3509,
282,
4270,
6313,
12,
881,
315,
1314,
1930,
2849,
9344,
787,
1202,
3140,
14,
267,
4772,
63,
4116,
63,
262,
63,
3288,
29,
797,
92,
549,
881,
7480,
370,
4772,
665,
315,
2225,
1338,
14,
267,
4772,
63,
1195,
576,
29,
797,
92,
549,
881,
7480,
370,
4772,
4110,
626,
1929,
370,
506,
11077,
4453,
3293,
881,
4008,
4453,
4819,
576,
4008,
4066,
465,
3449,
14,
267,
7512,
63,
8327,
29,
549,
92,
797,
881,
7480,
370,
7512,
4310,
4528,
9045,
626,
7468,
315,
314,
881,
1350,
3123,
14,
710,
4692,
27684,
9045,
1253,
4116,
27,
1253,
3308
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
504,
3816,
492,
1318,
63,
466,
199,
199,
646,
9796,
199,
63,
275,
9796,
14,
5152,
199,
199,
893,
26,
272,
687,
9143,
492,
7114,
199,
2590,
3545,
26,
272,
986,
199,
199,
504,
2508,
5559,
492,
2309,
6255,
12,
5046,
5379,
12,
25431,
199,
504,
2508,
5559,
492,
4819,
576,
6255,
12,
9045,
12,
2748,
24672,
199,
504,
2508,
492,
3778,
199,
504,
2748,
14,
14338,
14,
14338,
1208,
492,
4772,
199,
199,
2638,
9272,
275,
10587,
904,
8,
2638,
9272,
9,
199,
199,
893,
26,
272,
687,
6010,
492,
2274,
63,
705,
12,
2748,
24253,
1814,
63,
2550,
199,
2590,
3545,
26,
272,
2649,
63,
2143,
63,
2550,
275,
298,
4768,
2,
199,
2836,
26,
272,
2649,
63,
2143,
63,
2550,
275,
298,
15575,
552,
1701,
1814,
2,
339,
3752,
63,
4502,
63,
1130,
275,
1052,
272,
365,
63,
23880,
20,
275,
822,
4582,
53,
17657,
6968,
531,
508,
413,
272,
367,
1022,
12,
373,
315,
769,
8,
8327,
14,
1744,
5109,
267,
327,
3372,
3510,
13,
10856,
9045,
267,
340,
3666,
374,
63,
23880,
20,
436,
822,
8,
86,
9,
690,
413,
9,
503,
355,
334,
1397,
365,
63,
23880,
20,
436,
822,
8,
86,
9,
690,
499,
2298,
288,
1980,
267,
340,
373,
1137,
11746,
582,
288,
340,
822,
8,
86,
9,
508,
499,
26,
355,
373,
275,
3778,
14,
16380,
12882,
1378,
3034,
1403,
8,
86,
9,
288,
587,
26,
355,
373,
275,
6206,
8,
86,
9,
288,
340,
373,
440,
315,
3752,
63,
4502,
63,
1130,
503,
1022,
14,
374,
2325,
837,
355,
327,
16602,
1253,
4116,
27,
1806,
1253,
17090,
27,
436,
8545,
590,
367,
1253,
5282,
27031,
1253,
3308,
27031,
5423,
14,
355,
3752,
63,
4502,
63,
1130,
59,
86,
61,
275,
1022,
339,
347,
30010,
552,
1701,
1814,
63,
2550,
8,
2804,
304,
267,
340,
1228,
8,
2804,
12,
334,
7087,
19994,
12,
6140,
18355,
547,
2298,
288,
522,
275,
942,
288,
1233,
3438,
275,
942,
288,
3372,
275,
756,
288,
367,
284,
12,
286,
315,
3874,
8,
2804,
14,
785,
59,
2804,
14,
928,
26,
2804,
14,
500,
4682,
355,
340,
3372,
26,
490,
3372,
275,
756,
490,
1980,
355,
1478,
275,
284,
435,
3178,
14,
928,
355,
340,
3778,
14,
374,
11762,
13095,
12882,
8,
2804,
14,
785,
59,
1080,
26,
827,
779,
2804,
14,
500,
12,
1478,
435,
499,
566,
4682,
490,
1233,
1403,
275,
3778,
14,
16380,
12882,
1378,
3034,
1403,
8,
2804,
14,
785,
59,
1080,
26,
1080,
435,
499,
566,
490,
3372,
275,
715,
355,
587,
26,
490,
1233,
1403,
275,
6206,
8,
67,
9,
355,
1233,
3438,
14,
740,
8,
19300,
9,
288,
367,
7667,
315,
1233,
3438,
26,
355,
325,
275,
3752,
63,
4502,
63,
1130,
14,
362,
8,
1850,
9,
355,
340,
325,
26,
490,
522,
14,
740,
22077,
531,
490,
522,
14,
740,
8,
69,
9,
490,
340,
440,
325,
14,
4130,
480,
27,
2349,
717,
522,
14,
740,
480,
15027,
355,
587,
26,
490,
522,
14,
740,
480,
7997,
88,
5,
83,
9426,
450,
334,
4097,
8,
1850,
2788,
18,
16720,
288,
372,
334,
25148,
904,
8,
470,
395,
3178,
14,
500,
9,
267,
587,
26,
288,
372,
2748,
24253,
1814,
63,
2550,
8,
2804,
9,
339,
2274,
63,
705,
8,
2975,
63,
2143,
63,
2550,
12,
30010,
552,
1701,
1814,
63,
2550,
9,
339,
2150,
2274,
63,
705,
421,
199,
533,
4163,
7299,
8,
785,
304,
339,
327,
2225,
18593,
1511,
272,
6313,
63,
962,
63,
1459,
275,
756,
272,
6313,
63,
1560,
275,
14788,
272,
675,
63,
7010,
63,
3513,
63,
1560,
275,
715,
339,
327,
1947,
6302,
1511,
272,
19413,
63,
4144,
63,
2969,
275,
715,
272,
24720,
63,
4871,
63,
2987,
275,
715,
272,
675,
63,
15910,
63,
18533,
527,
275,
756,
272,
4601,
63,
5182,
63,
15910,
63,
18533,
527,
275,
715,
339,
327,
21375,
1511,
272,
4772,
63,
4116,
63,
262,
63,
3288,
275,
756,
272,
4772,
63,
1195,
576,
275,
756,
272,
7512,
63,
8327,
275,
715,
339,
327,
3201,
19549,
1511,
272,
23331,
3294,
63,
2987,
275,
756,
272,
16182,
63,
2024,
63,
6043,
275,
715,
272,
6202,
63,
8506,
275,
756,
272,
21077,
275,
756,
339,
1511,
275,
1689,
3513,
63,
962,
63,
1459,
401,
298,
3513,
63,
1560,
401,
298,
1180,
63,
7010,
63,
3513,
63,
1560,
401,
2049,
298,
19007,
63,
4144,
63,
2969,
401,
298,
19333,
63,
4871,
63,
2987,
401,
2049,
298,
1180,
63,
15910,
63,
18533,
527,
401,
298,
2638,
63,
5182,
63,
15910,
63,
18533,
527,
401,
2049,
298,
3765,
63,
4116,
63,
262,
63,
3288,
401,
298,
3765,
63,
1195,
576,
401,
298,
6983,
63,
8327,
401,
2049,
298,
10305,
7570,
3294,
63,
2987,
401,
298,
14815,
63,
2024,
63,
6043,
401,
2049,
298,
1913,
63,
8506,
401,
298,
18177,
531,
339,
347,
636,
826,
721,
277,
12,
1011,
958,
304,
267,
408,
9345,
4163,
7299,
14,
398,
6431,
1511,
334,
885,
1627,
1642,
7444,
2013,
9,
2387,
26,
398,
16182,
63,
2024,
63,
6043,
29,
549,
92,
797,
881,
7480,
652,
5518,
282,
3404,
1819,
370,
5627,
314,
4528,
663,
402,
314,
881,
2213,
14,
267,
6313,
63,
962,
63,
1459,
29,
549,
92,
797,
881,
7480,
370,
6313,
2225,
1338,
626,
2793,
1133,
4409,
18593,
881,
1126,
4163,
21,
6057,
4713,
14,
267,
6313,
63,
1560,
29,
85,
4065,
17018,
85,
2,
4065,
881,
3645,
1627,
6313,
4528,
367,
2225,
18593,
14,
3758,
365,
370,
881,
675,
4270,
6313,
7444,
2225,
574,
3509,
282,
4270,
6313,
12,
881,
315,
1314,
1930,
2849,
9344,
787,
1202,
3140,
14,
267,
4772,
63,
4116,
63,
262,
63,
3288,
29,
797,
92,
549,
881,
7480,
370,
4772,
665,
315,
2225,
1338,
14,
267,
4772,
63,
1195,
576,
29,
797,
92,
549,
881,
7480,
370,
4772,
4110,
626,
1929,
370,
506,
11077,
4453,
3293,
881,
4008,
4453,
4819,
576,
4008,
4066,
465,
3449,
14,
267,
7512,
63,
8327,
29,
549,
92,
797,
881,
7480,
370,
7512,
4310,
4528,
9045,
626,
7468,
315,
314,
881,
1350,
3123,
14,
710,
4692,
27684,
9045,
1253,
4116,
27,
1253,
3308,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
JTarball/docker-django-polymer-starter-kit
|
docker/app/app/backend/apps/_archive/content/templatetags/navbar_tags.py
|
8
|
6027
|
from __future__ import unicode_literals
import logging
from inspect import ismethod
from django.core.urlresolvers import (reverse, resolve, NoReverseMatch,
Resolver404)
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.encoding import smart_text
from django.utils.translation import ugettext as _
from django.db.models import Model
from django import template
from django import template
from django.core.urlresolvers import reverse_lazy
from content.models import Language, Category
# Get instance of logger
logger = logging.getLogger('project_logger')
register = template.Library()
@register.simple_tag(takes_context=True)
def show_menu(context):
categories = [cat.slug for cat in Category.objects.all()]
path= context['request'].path
return {'categories': categories,'path':path}
@register.inclusion_tag('navbar.html', takes_context=True)
def show_categories(context):
categories = [cat for cat in Category.objects.all()]
path= context['request'].path
print "show_categoried --- path", path
return {'categories': categories, 'path':path}
@register.inclusion_tag('navbar.html', takes_context=True)
def show_navbar(context):
languages = [lang for lang in Language.objects.all()]
categories = [cat for cat in Category.objects.all()]
subcategories = []# [subcat for subcat in SubCategory.objects.all()]
path = context['request'].path
return { 'languages': languages, 'categories': categories, 'subcategories':subcategories, 'path':path, 'path_lang':context['path_language'], 'path_cat':context['path_category'], 'path_subcat':context['path_subcategory'] }
@register.simple_tag(takes_context=True)
def active_page(context, req):
request = context['request']
#print "path", request
#if not request:
# logger.error('Cant find request - needed for active page css')
logger.error('dsfds %s' % request.path)
return "active"
#try:
# return "active"
#return "active" if resolve(request.path_info).url_name == view_name else ""
#except Resolver404:
# return ""
@register.filter(name='is_empty')
def is_empty(value):
""" Checks whether value is empty. Should be string. """
logger.info('is_empty value:%s' % value )
if not value.strip(' '):
return True
else:
return False
CONTEXT_KEY = 'DJANGO_BREADCRUMB_LINKS'
MAX_WIDTH_BREADCRUMBS=1200
MAX_WIDTH_BREADCRUMB=200
@register.simple_tag(takes_context=True)
def render_breadcrumbs(context, *args):
"""
Render breadcrumbs html using twitter bootstrap css classes.
NOTE: Breadcrumb MUST end with a '/'
"""
if not 'request' in context:
logger.error("request object not found in context! Check if "
"'django.core.context_processors.request' is in "
"TEMPLATE_CONTEXT_PROCESSORS")
return ''
logger.info('This is path: %s' % context['request'].path)
current_app = context['request'].resolver_match.namespace
print current_app
#url = reverse(viewname="content:python", current_app=current_app)
#print url
# remove trailing /
links=[]
href=""
for url in context['request'].path.lstrip('/').rstrip('/').split('/'):
href += url + '/'
links.append((href, _(smart_text(url)) if url else url))
orig_links = links
print links
# HACK: FOR MAX LENGTH OF BREADCRUMBS for rendering
# Here we change the start to ...
if len(links) > (MAX_WIDTH_BREADCRUMBS/MAX_WIDTH_BREADCRUMB):
#logger.info('len links: %s %s', len(links), links)
#print "max ", (MAX_WIDTH_BREADCRUMBS/MAX_WIDTH_BREADCRUMB)
no_to_remove = len(links) - (MAX_WIDTH_BREADCRUMBS/MAX_WIDTH_BREADCRUMB)
#print no_to_remove
#for i in range(len(links)):
# print links[i]
href = links[no_to_remove-1][0]
del links[0:no_to_remove]
links.insert(0, (href, "..."))
if not links: return ''
return mark_safe(template.loader.render_to_string(
'navbar.html', {'breadcrumbs': links,
'breadcrumbs_total': len(orig_links)}))
# if args:
# template_path = args[0]
# else:
# template_path = 'django_bootstrap_breadcrumbs/bootstrap2.html'
# print "befor elubjkks [p"
# links = []
# for (label, viewname, view_args) in context['request'].META.get(CONTEXT_KEY, []):
# if isinstance(viewname, Model) and hasattr(
# viewname, 'get_absolute_url') and ismethod(
# viewname.get_absolute_url):
# url = viewname.get_absolute_url()
# print "fndsnflksnkfnsdjdjdjjdpopopopop"
# else:
# try:
# try:
# # 'resolver_match' introduced in Django 1.5
# current_app = context['request'].resolver_match.namespace
# logger.info('%s' % current_app)
# except AttributeError:
# try:
# resolver_match = resolve(context['request'].path)
# print resolver_match, "jkjdlsfjjlsdkjlfkjlskjfljsdljfldjslkjfkldsj"
# current_app = resolver_match.namespace
# logger.info('%s' % current_app)
# except Resolver404:
# print '404'
# current_app = None
# url = reverse(viewname=viewname, args=view_args,
# current_app=current_app)
# except NoReverseMatch:
# url = viewname
# links.append((url, _(smart_text(label)) if label else label))
# logger.warning('fdskljfldsjlkfjdkls %s' % links )
# if not links:
# return ''
# return mark_safe(template.loader.render_to_string(
# template_path, {'breadcrumbs': links,
# 'breadcrumbs_total': len(links)}))
|
isc
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2050,
199,
504,
6485,
492,
365,
765,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
334,
4471,
12,
7512,
12,
32036,
12,
4228,
26046,
5188,
9,
199,
504,
1639,
14,
1208,
14,
1360,
492,
4772,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
505,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
697,
14,
992,
492,
5822,
199,
504,
1639,
492,
1978,
199,
199,
504,
1639,
492,
1978,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
63,
6395,
199,
199,
504,
1564,
14,
992,
492,
8466,
12,
13573,
199,
199,
3,
2372,
1256,
402,
2512,
199,
2921,
275,
2050,
14,
5572,
360,
1715,
63,
2921,
358,
199,
199,
2683,
275,
1978,
14,
7424,
342,
421,
199,
32,
2683,
14,
4129,
63,
1450,
8,
31613,
63,
1100,
29,
549,
9,
199,
318,
2498,
63,
4470,
8,
1100,
304,
272,
9695,
275,
359,
3385,
14,
5464,
367,
6230,
315,
13573,
14,
1462,
14,
452,
5106,
272,
931,
29,
1067,
459,
1069,
2278,
515,
272,
372,
791,
8906,
356,
9695,
2584,
515,
356,
515,
93,
199,
199,
32,
2683,
14,
24265,
63,
1450,
360,
10927,
1700,
14,
1360,
297,
6181,
63,
1100,
29,
549,
9,
199,
318,
2498,
63,
8906,
8,
1100,
304,
272,
9695,
275,
359,
3385,
367,
6230,
315,
13573,
14,
1462,
14,
452,
5106,
272,
931,
29,
1067,
459,
1069,
2278,
515,
272,
870,
298,
2384,
63,
7206,
5299,
10894,
931,
401,
931,
272,
372,
791,
8906,
356,
9695,
12,
283,
515,
356,
515,
93,
199,
199,
32,
2683,
14,
24265,
63,
1450,
360,
10927,
1700,
14,
1360,
297,
6181,
63,
1100,
29,
549,
9,
199,
318,
2498,
63,
10927,
1700,
8,
1100,
304,
272,
10815,
275,
359,
4159,
367,
6339,
315,
8466,
14,
1462,
14,
452,
5106,
272,
9695,
275,
359,
3385,
367,
6230,
315,
13573,
14,
1462,
14,
452,
5106,
272,
1007,
8906,
275,
942,
3,
359,
954,
3385,
367,
1007,
3385,
315,
4804,
7841,
14,
1462,
14,
452,
5106,
272,
931,
275,
1067,
459,
1069,
2278,
515,
272,
372,
469,
283,
13209,
356,
10815,
12,
283,
8906,
356,
9695,
12,
283,
954,
8906,
356,
954,
8906,
12,
283,
515,
356,
515,
12,
283,
515,
63,
4159,
356,
1100,
459,
515,
63,
3671,
995,
283,
515,
63,
3385,
356,
1100,
459,
515,
63,
3710,
995,
283,
515,
63,
954,
3385,
356,
1100,
459,
515,
63,
954,
3710,
418,
789,
421,
199,
32,
2683,
14,
4129,
63,
1450,
8,
31613,
63,
1100,
29,
549,
9,
199,
318,
4702,
63,
1606,
8,
1100,
12,
2648,
304,
272,
1056,
275,
1067,
459,
1069,
418,
272,
327,
1361,
298,
515,
401,
1056,
272,
327,
692,
440,
1056,
26,
272,
327,
259,
198,
2921,
14,
705,
360,
35,
867,
2342,
1056,
446,
4346,
367,
4702,
2034,
11431,
358,
5591,
2512,
14,
705,
360,
795,
14240,
450,
83,
7,
450,
1056,
14,
515,
9,
272,
372,
298,
2682,
2,
272,
327,
893,
26,
272,
327,
259,
372,
298,
2682,
2,
267,
327,
1107,
298,
2682,
2,
340,
7512,
8,
1069,
14,
515,
63,
815,
680,
633,
63,
354,
508,
2455,
63,
354,
587,
3087,
272,
327,
2590,
26046,
5188,
26,
272,
327,
259,
372,
3087,
421,
199,
32,
2683,
14,
1541,
8,
354,
534,
374,
63,
1667,
358,
199,
318,
365,
63,
1667,
8,
585,
304,
272,
408,
13813,
3775,
574,
365,
2701,
14,
7719,
506,
1059,
14,
408,
272,
2512,
14,
815,
360,
374,
63,
1667,
574,
2689,
83,
7,
450,
574,
776,
272,
340,
440,
574,
14,
1913,
360,
18927,
267,
372,
715,
272,
587,
26,
267,
372,
756,
4388,
199,
9059,
63,
3078,
275,
283,
22848,
63,
34,
5670,
2944,
2639,
34,
63,
7916,
51,
7,
199,
199,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
29,
23781,
199,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
34,
29,
1840,
199,
199,
32,
2683,
14,
4129,
63,
1450,
8,
31613,
63,
1100,
29,
549,
9,
199,
318,
3795,
63,
66,
25972,
23135,
8,
1100,
12,
627,
589,
304,
272,
408,
272,
17769,
330,
25972,
23135,
3517,
1808,
15811,
15865,
11431,
3992,
14,
339,
6944,
26,
699,
25972,
4295,
18095,
1284,
543,
282,
7324,
272,
408,
272,
340,
440,
283,
1069,
7,
315,
1067,
26,
267,
2512,
14,
705,
480,
1069,
909,
440,
1911,
315,
1067,
1,
2670,
340,
298,
2151,
3546,
1176,
14,
1018,
14,
1100,
63,
10547,
14,
1069,
7,
365,
315,
298,
2151,
298,
7433,
63,
9059,
63,
10494,
4149,
531,
267,
372,
2125,
339,
2512,
14,
815,
360,
2765,
365,
931,
26,
450,
83,
7,
450,
1067,
459,
1069,
2278,
515,
9,
272,
1453,
63,
571,
275,
1067,
459,
1069,
2278,
7717,
63,
1431,
14,
3251,
272,
870,
1453,
63,
571,
272,
327,
633,
275,
3837,
8,
1345,
354,
628,
1317,
26,
1548,
401,
1453,
63,
571,
29,
1818,
63,
571,
9,
272,
327,
1361,
1166,
2378,
327,
2813,
8520,
1182,
23855,
6220,
9811,
272,
4369,
9287,
272,
367,
1166,
315,
1067,
459,
1069,
2278,
515,
14,
10124,
2336,
1959,
6735,
2336,
1959,
1294,
18265,
267,
4369,
847,
1166,
435,
7324,
267,
6220,
14,
740,
1332,
6399,
12,
12561,
7853,
63,
505,
8,
633,
430,
340,
1166,
587,
1166,
430,
339,
2306,
63,
4614,
275,
6220,
339,
870,
6220,
272,
327,
31697,
26,
2381,
9141,
491,
32106,
1634,
699,
5670,
2944,
2639,
11087,
367,
14066,
5591,
327,
11842,
781,
1570,
314,
1343,
370,
2263,
272,
340,
822,
8,
4614,
9,
690,
221,
334,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
15,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
34,
304,
267,
327,
2921,
14,
815,
360,
552,
6220,
26,
450,
83,
450,
83,
297,
822,
8,
4614,
395,
6220,
9,
267,
327,
1361,
298,
988,
3872,
334,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
15,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
34,
9,
267,
949,
63,
475,
63,
2168,
275,
822,
8,
4614,
9,
446,
334,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
15,
4283,
63,
11139,
63,
34
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
2050,
199,
504,
6485,
492,
365,
765,
199,
199,
504,
1639,
14,
1018,
14,
16522,
492,
334,
4471,
12,
7512,
12,
32036,
12,
4228,
26046,
5188,
9,
199,
504,
1639,
14,
1208,
14,
1360,
492,
4772,
199,
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
505,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
697,
14,
992,
492,
5822,
199,
504,
1639,
492,
1978,
199,
199,
504,
1639,
492,
1978,
199,
504,
1639,
14,
1018,
14,
16522,
492,
3837,
63,
6395,
199,
199,
504,
1564,
14,
992,
492,
8466,
12,
13573,
199,
199,
3,
2372,
1256,
402,
2512,
199,
2921,
275,
2050,
14,
5572,
360,
1715,
63,
2921,
358,
199,
199,
2683,
275,
1978,
14,
7424,
342,
421,
199,
32,
2683,
14,
4129,
63,
1450,
8,
31613,
63,
1100,
29,
549,
9,
199,
318,
2498,
63,
4470,
8,
1100,
304,
272,
9695,
275,
359,
3385,
14,
5464,
367,
6230,
315,
13573,
14,
1462,
14,
452,
5106,
272,
931,
29,
1067,
459,
1069,
2278,
515,
272,
372,
791,
8906,
356,
9695,
2584,
515,
356,
515,
93,
199,
199,
32,
2683,
14,
24265,
63,
1450,
360,
10927,
1700,
14,
1360,
297,
6181,
63,
1100,
29,
549,
9,
199,
318,
2498,
63,
8906,
8,
1100,
304,
272,
9695,
275,
359,
3385,
367,
6230,
315,
13573,
14,
1462,
14,
452,
5106,
272,
931,
29,
1067,
459,
1069,
2278,
515,
272,
870,
298,
2384,
63,
7206,
5299,
10894,
931,
401,
931,
272,
372,
791,
8906,
356,
9695,
12,
283,
515,
356,
515,
93,
199,
199,
32,
2683,
14,
24265,
63,
1450,
360,
10927,
1700,
14,
1360,
297,
6181,
63,
1100,
29,
549,
9,
199,
318,
2498,
63,
10927,
1700,
8,
1100,
304,
272,
10815,
275,
359,
4159,
367,
6339,
315,
8466,
14,
1462,
14,
452,
5106,
272,
9695,
275,
359,
3385,
367,
6230,
315,
13573,
14,
1462,
14,
452,
5106,
272,
1007,
8906,
275,
942,
3,
359,
954,
3385,
367,
1007,
3385,
315,
4804,
7841,
14,
1462,
14,
452,
5106,
272,
931,
275,
1067,
459,
1069,
2278,
515,
272,
372,
469,
283,
13209,
356,
10815,
12,
283,
8906,
356,
9695,
12,
283,
954,
8906,
356,
954,
8906,
12,
283,
515,
356,
515,
12,
283,
515,
63,
4159,
356,
1100,
459,
515,
63,
3671,
995,
283,
515,
63,
3385,
356,
1100,
459,
515,
63,
3710,
995,
283,
515,
63,
954,
3385,
356,
1100,
459,
515,
63,
954,
3710,
418,
789,
421,
199,
32,
2683,
14,
4129,
63,
1450,
8,
31613,
63,
1100,
29,
549,
9,
199,
318,
4702,
63,
1606,
8,
1100,
12,
2648,
304,
272,
1056,
275,
1067,
459,
1069,
418,
272,
327,
1361,
298,
515,
401,
1056,
272,
327,
692,
440,
1056,
26,
272,
327,
259,
198,
2921,
14,
705,
360,
35,
867,
2342,
1056,
446,
4346,
367,
4702,
2034,
11431,
358,
5591,
2512,
14,
705,
360,
795,
14240,
450,
83,
7,
450,
1056,
14,
515,
9,
272,
372,
298,
2682,
2,
272,
327,
893,
26,
272,
327,
259,
372,
298,
2682,
2,
267,
327,
1107,
298,
2682,
2,
340,
7512,
8,
1069,
14,
515,
63,
815,
680,
633,
63,
354,
508,
2455,
63,
354,
587,
3087,
272,
327,
2590,
26046,
5188,
26,
272,
327,
259,
372,
3087,
421,
199,
32,
2683,
14,
1541,
8,
354,
534,
374,
63,
1667,
358,
199,
318,
365,
63,
1667,
8,
585,
304,
272,
408,
13813,
3775,
574,
365,
2701,
14,
7719,
506,
1059,
14,
408,
272,
2512,
14,
815,
360,
374,
63,
1667,
574,
2689,
83,
7,
450,
574,
776,
272,
340,
440,
574,
14,
1913,
360,
18927,
267,
372,
715,
272,
587,
26,
267,
372,
756,
4388,
199,
9059,
63,
3078,
275,
283,
22848,
63,
34,
5670,
2944,
2639,
34,
63,
7916,
51,
7,
199,
199,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
29,
23781,
199,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
34,
29,
1840,
199,
199,
32,
2683,
14,
4129,
63,
1450,
8,
31613,
63,
1100,
29,
549,
9,
199,
318,
3795,
63,
66,
25972,
23135,
8,
1100,
12,
627,
589,
304,
272,
408,
272,
17769,
330,
25972,
23135,
3517,
1808,
15811,
15865,
11431,
3992,
14,
339,
6944,
26,
699,
25972,
4295,
18095,
1284,
543,
282,
7324,
272,
408,
272,
340,
440,
283,
1069,
7,
315,
1067,
26,
267,
2512,
14,
705,
480,
1069,
909,
440,
1911,
315,
1067,
1,
2670,
340,
298,
2151,
3546,
1176,
14,
1018,
14,
1100,
63,
10547,
14,
1069,
7,
365,
315,
298,
2151,
298,
7433,
63,
9059,
63,
10494,
4149,
531,
267,
372,
2125,
339,
2512,
14,
815,
360,
2765,
365,
931,
26,
450,
83,
7,
450,
1067,
459,
1069,
2278,
515,
9,
272,
1453,
63,
571,
275,
1067,
459,
1069,
2278,
7717,
63,
1431,
14,
3251,
272,
870,
1453,
63,
571,
272,
327,
633,
275,
3837,
8,
1345,
354,
628,
1317,
26,
1548,
401,
1453,
63,
571,
29,
1818,
63,
571,
9,
272,
327,
1361,
1166,
2378,
327,
2813,
8520,
1182,
23855,
6220,
9811,
272,
4369,
9287,
272,
367,
1166,
315,
1067,
459,
1069,
2278,
515,
14,
10124,
2336,
1959,
6735,
2336,
1959,
1294,
18265,
267,
4369,
847,
1166,
435,
7324,
267,
6220,
14,
740,
1332,
6399,
12,
12561,
7853,
63,
505,
8,
633,
430,
340,
1166,
587,
1166,
430,
339,
2306,
63,
4614,
275,
6220,
339,
870,
6220,
272,
327,
31697,
26,
2381,
9141,
491,
32106,
1634,
699,
5670,
2944,
2639,
11087,
367,
14066,
5591,
327,
11842,
781,
1570,
314,
1343,
370,
2263,
272,
340,
822,
8,
4614,
9,
690,
221,
334,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
15,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
34,
304,
267,
327,
2921,
14,
815,
360,
552,
6220,
26,
450,
83,
450,
83,
297,
822,
8,
4614,
395,
6220,
9,
267,
327,
1361,
298,
988,
3872,
334,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
15,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
34,
9,
267,
949,
63,
475,
63,
2168,
275,
822,
8,
4614,
9,
446,
334,
4283,
63,
11139,
63,
34,
5670,
2944,
2639,
11087,
15,
4283,
63,
11139,
63,
34,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
e1ven/Waymoot
|
libs/tornado-2.2/build/lib/tornado/test/testing_test.py
|
10
|
1318
|
#!/usr/bin/env python
import unittest
from tornado.testing import AsyncTestCase, LogTrapTestCase
class AsyncTestCaseTest(AsyncTestCase, LogTrapTestCase):
def test_exception_in_callback(self):
self.io_loop.add_callback(lambda: 1/0)
try:
self.wait()
self.fail("did not get expected exception")
except ZeroDivisionError:
pass
class SetUpTearDownTest(unittest.TestCase):
def test_set_up_tear_down(self):
"""
This test makes sure that AsyncTestCase calls super methods for
setUp and tearDown.
InheritBoth is a subclass of both AsyncTestCase and
SetUpTearDown, with the ordering so that the super of
AsyncTestCase will be SetUpTearDown.
"""
events = []
result = unittest.TestResult()
class SetUpTearDown(unittest.TestCase):
def setUp(self):
events.append('setUp')
def tearDown(self):
events.append('tearDown')
class InheritBoth(AsyncTestCase, SetUpTearDown):
def test(self):
events.append('test')
InheritBoth('test').run(result)
expected = ['setUp', 'test', 'tearDown']
self.assertEqual(expected, events)
if __name__ == '__main__':
unittest.main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
646,
2882,
199,
504,
12148,
14,
4776,
492,
15223,
1746,
12,
5297,
52,
1330,
1746,
199,
199,
533,
15223,
1746,
774,
8,
12807,
1746,
12,
5297,
52,
1330,
1746,
304,
272,
347,
511,
63,
1971,
63,
262,
63,
3058,
8,
277,
304,
267,
291,
14,
2308,
63,
3813,
14,
525,
63,
3058,
8,
2734,
26,
413,
15,
16,
9,
267,
862,
26,
288,
291,
14,
2573,
342,
288,
291,
14,
1633,
480,
14887,
440,
664,
1420,
1919,
531,
267,
871,
25838,
26,
288,
986,
199,
199,
533,
2494,
1721,
30711,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
409,
63,
384,
63,
266,
285,
63,
2110,
8,
277,
304,
267,
408,
267,
961,
511,
7704,
3238,
626,
15223,
1746,
4882,
1613,
3102,
367,
267,
3613,
436,
6766,
14,
398,
27502,
18088,
365,
282,
5516,
402,
3865,
15223,
1746,
436,
267,
2494,
1721,
30711,
12,
543,
314,
7794,
880,
626,
314,
1613,
402,
267,
15223,
1746,
911,
506,
2494,
1721,
30711,
14,
267,
408,
267,
4474,
275,
942,
267,
754,
275,
2882,
14,
13120,
342,
398,
1021,
2494,
1721,
30711,
8,
2796,
14,
1746,
304,
288,
347,
3613,
8,
277,
304,
355,
4474,
14,
740,
360,
5996,
358,
953,
347,
6766,
8,
277,
304,
355,
4474,
14,
740,
360,
12336,
358,
398,
1021,
27502,
18088,
8,
12807,
1746,
12,
2494,
1721,
30711,
304,
288,
347,
511,
8,
277,
304,
355,
4474,
14,
740,
360,
396,
358,
398,
27502,
18088,
360,
396,
1959,
1065,
8,
1099,
9,
267,
1420,
275,
788,
5996,
297,
283,
396,
297,
283,
12336,
418,
267,
291,
14,
629,
8,
2062,
12,
4474,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
646,
2882,
199,
504,
12148,
14,
4776,
492,
15223,
1746,
12,
5297,
52,
1330,
1746,
199,
199,
533,
15223,
1746,
774,
8,
12807,
1746,
12,
5297,
52,
1330,
1746,
304,
272,
347,
511,
63,
1971,
63,
262,
63,
3058,
8,
277,
304,
267,
291,
14,
2308,
63,
3813,
14,
525,
63,
3058,
8,
2734,
26,
413,
15,
16,
9,
267,
862,
26,
288,
291,
14,
2573,
342,
288,
291,
14,
1633,
480,
14887,
440,
664,
1420,
1919,
531,
267,
871,
25838,
26,
288,
986,
199,
199,
533,
2494,
1721,
30711,
774,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
409,
63,
384,
63,
266,
285,
63,
2110,
8,
277,
304,
267,
408,
267,
961,
511,
7704,
3238,
626,
15223,
1746,
4882,
1613,
3102,
367,
267,
3613,
436,
6766,
14,
398,
27502,
18088,
365,
282,
5516,
402,
3865,
15223,
1746,
436,
267,
2494,
1721,
30711,
12,
543,
314,
7794,
880,
626,
314,
1613,
402,
267,
15223,
1746,
911,
506,
2494,
1721,
30711,
14,
267,
408,
267,
4474,
275,
942,
267,
754,
275,
2882,
14,
13120,
342,
398,
1021,
2494,
1721,
30711,
8,
2796,
14,
1746,
304,
288,
347,
3613,
8,
277,
304,
355,
4474,
14,
740,
360,
5996,
358,
953,
347,
6766,
8,
277,
304,
355,
4474,
14,
740,
360,
12336,
358,
398,
1021,
27502,
18088,
8,
12807,
1746,
12,
2494,
1721,
30711,
304,
288,
347,
511,
8,
277,
304,
355,
4474,
14,
740,
360,
396,
358,
398,
27502,
18088,
360,
396,
1959,
1065,
8,
1099,
9,
267,
1420,
275,
788,
5996,
297,
283,
396,
297,
283,
12336,
418,
267,
291,
14,
629,
8,
2062,
12,
4474,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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:rtype: int
"""
if root == None:
return 0
self.maxSum = root.val
self.maxPathSumNode(root)
return self.maxSum
def maxPathSumNode(self, node):
if node == None:
return 0
leftSum = self.maxPathSumNode(node.left)
rightSum = self.maxPathSumNode(node.right)
self.maxSum = max(leftSum+node.val, rightSum+node.val, leftSum+node.val+rightSum, self.maxSum, node.val)
print('leftSum: %d, rightSum: %d, node.val: %d, self.maxSum: %d' % (leftSum, rightSum, node.val, self.maxSum))
ret = max(leftSum+node.val, rightSum+node.val, node.val)
print('node.val: %d, ret: %d' % (node.val, ret))
return ret
sol = Solution()
nodeString = "[-10,9,20,null,null,15,7]"
nodeString = "[1,2,3]"
nodeString = "[1,-2,-3,1,3,-2,null,-1]"
root = treeBuilder(nodeString)
traverse(root)
print(sol.maxPathSum(root))
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
3123,
492,
627,
199,
199,
533,
9274,
26,
272,
347,
1390,
2042,
6959,
8,
277,
12,
1738,
304,
267,
408,
267,
520,
466,
1738,
26,
12178,
1716,
267,
520,
4500,
26,
1109,
267,
408,
267,
340,
1738,
508,
488,
26,
288,
372,
378,
267,
291,
14,
988,
6959,
275,
1738,
14,
637,
267,
291,
14,
988,
2042,
6959,
1716,
8,
1231,
9,
267,
372,
291,
14,
988,
6959,
339,
347,
1390,
2042,
6959,
1716,
8,
277,
12,
1031,
304,
267,
340,
1031,
508,
488,
26,
288,
372,
378,
267,
3602,
6959,
275,
291,
14,
988,
2042,
6959,
1716,
8,
932,
14,
3039,
9,
267,
2451,
6959,
275,
291,
14,
988,
2042,
6959,
1716,
8,
932,
14,
1019,
9,
267,
291,
14,
988,
6959,
275,
1390,
8,
3039,
6959,
11,
932,
14,
637,
12,
2451,
6959,
11,
932,
14,
637,
12,
3602,
6959,
11,
932,
14,
637,
11,
1019,
6959,
12,
291,
14,
988,
6959,
12,
1031,
14,
637,
9,
267,
870,
360,
3039,
6959,
26,
450,
68,
12,
2451,
6959,
26,
450,
68,
12,
1031,
14,
637,
26,
450,
68,
12,
291,
14,
988,
6959,
26,
450,
68,
7,
450,
334,
3039,
6959,
12,
2451,
6959,
12,
1031,
14,
637,
12,
291,
14,
988,
6959,
430,
267,
2203,
275,
1390,
8,
3039,
6959,
11,
932,
14,
637,
12,
2451,
6959,
11,
932,
14,
637,
12,
1031,
14,
637,
9,
267,
870,
360,
932,
14,
637,
26,
450,
68,
12,
2203,
26,
450,
68,
7,
450,
334,
932,
14,
637,
12,
2203,
430,
267,
372,
2203,
199,
199,
7873,
275,
9274,
342,
199,
932,
1558,
275,
298,
1988,
709,
12,
25,
12,
1165,
12,
2307,
12,
2307,
12,
1046,
12,
23,
8480,
199,
932,
1558,
275,
7369,
17,
12,
18,
12,
19,
8480,
199,
932,
1558,
275,
7369,
17,
3057,
18,
3057,
19,
12,
17,
12,
19,
3057,
18,
12,
2307,
3057,
17,
8480,
199,
1231,
275,
3123,
6437,
8,
932,
1558,
9,
199,
23650,
8,
1231,
9,
199,
1361,
8,
7873,
14,
988,
2042,
6959,
8,
1231,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
3123,
492,
627,
199,
199,
533,
9274,
26,
272,
347,
1390,
2042,
6959,
8,
277,
12,
1738,
304,
267,
408,
267,
520,
466,
1738,
26,
12178,
1716,
267,
520,
4500,
26,
1109,
267,
408,
267,
340,
1738,
508,
488,
26,
288,
372,
378,
267,
291,
14,
988,
6959,
275,
1738,
14,
637,
267,
291,
14,
988,
2042,
6959,
1716,
8,
1231,
9,
267,
372,
291,
14,
988,
6959,
339,
347,
1390,
2042,
6959,
1716,
8,
277,
12,
1031,
304,
267,
340,
1031,
508,
488,
26,
288,
372,
378,
267,
3602,
6959,
275,
291,
14,
988,
2042,
6959,
1716,
8,
932,
14,
3039,
9,
267,
2451,
6959,
275,
291,
14,
988,
2042,
6959,
1716,
8,
932,
14,
1019,
9,
267,
291,
14,
988,
6959,
275,
1390,
8,
3039,
6959,
11,
932,
14,
637,
12,
2451,
6959,
11,
932,
14,
637,
12,
3602,
6959,
11,
932,
14,
637,
11,
1019,
6959,
12,
291,
14,
988,
6959,
12,
1031,
14,
637,
9,
267,
870,
360,
3039,
6959,
26,
450,
68,
12,
2451,
6959,
26,
450,
68,
12,
1031,
14,
637,
26,
450,
68,
12,
291,
14,
988,
6959,
26,
450,
68,
7,
450,
334,
3039,
6959,
12,
2451,
6959,
12,
1031,
14,
637,
12,
291,
14,
988,
6959,
430,
267,
2203,
275,
1390,
8,
3039,
6959,
11,
932,
14,
637,
12,
2451,
6959,
11,
932,
14,
637,
12,
1031,
14,
637,
9,
267,
870,
360,
932,
14,
637,
26,
450,
68,
12,
2203,
26,
450,
68,
7,
450,
334,
932,
14,
637,
12,
2203,
430,
267,
372,
2203,
199,
199,
7873,
275,
9274,
342,
199,
932,
1558,
275,
298,
1988,
709,
12,
25,
12,
1165,
12,
2307,
12,
2307,
12,
1046,
12,
23,
8480,
199,
932,
1558,
275,
7369,
17,
12,
18,
12,
19,
8480,
199,
932,
1558,
275,
7369,
17,
3057,
18,
3057,
19,
12,
17,
12,
19,
3057,
18,
12,
2307,
3057,
17,
8480,
199,
1231,
275,
3123,
6437,
8,
932,
1558,
9,
199,
23650,
8,
1231,
9,
199,
1361,
8,
7873,
14,
988,
2042,
6959,
8,
1231,
430,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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QLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Compatiblity namespace for sqlalchemy.sql.schema and related.
"""
from .sql.base import (
SchemaVisitor
)
from .sql.schema import (
CheckConstraint,
Column,
ColumnDefault,
Constraint,
DefaultClause,
DefaultGenerator,
FetchedValue,
ForeignKey,
ForeignKeyConstraint,
Index,
MetaData,
PassiveDefault,
PrimaryKeyConstraint,
SchemaItem,
Sequence,
Table,
ThreadLocalMetaData,
UniqueConstraint,
_get_table_key,
ColumnCollectionConstraint,
)
from .sql.naming import conv
from .sql.ddl import (
DDL,
CreateTable,
DropTable,
CreateSequence,
DropSequence,
CreateIndex,
DropIndex,
CreateSchema,
DropSchema,
_DropView,
CreateColumn,
AddConstraint,
DropConstraint,
DDLBase,
DDLElement,
_CreateDropBase,
_DDLCompiles
)
|
gpl-3.0
|
[
3,
4177,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
7280,
314,
14303,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
2404,
2159,
66,
5075,
3231,
367,
8335,
14,
3009,
14,
3629,
436,
4048,
14,
199,
199,
624,
199,
199,
504,
1275,
3009,
14,
1095,
492,
334,
272,
13268,
18324,
272,
776,
421,
199,
504,
1275,
3009,
14,
3629,
492,
334,
272,
2670,
8463,
12,
272,
4996,
12,
272,
4996,
2698,
12,
272,
25889,
12,
272,
3758,
16009,
12,
272,
3758,
7599,
12,
272,
481,
13534,
1110,
12,
272,
12718,
12,
272,
12718,
8463,
12,
272,
5499,
12,
272,
24905,
12,
272,
510,
13202,
2698,
12,
272,
26710,
1197,
8463,
12,
272,
13268,
2081,
12,
272,
10975,
12,
272,
6957,
12,
272,
11086,
5339,
25285,
12,
272,
18276,
8463,
12,
272,
485,
362,
63,
1224,
63,
498,
12,
272,
4996,
7768,
8463,
12,
272,
776,
421,
199,
504,
1275,
3009,
14,
26919,
492,
8260,
421,
199,
504,
1275,
3009,
14,
17102,
492,
334,
272,
32078,
12,
272,
2790,
3186,
12,
272,
18110,
3186,
12,
272,
2790,
5826,
12,
272,
18110,
5826,
12,
272,
2790,
2681,
12,
272,
18110,
2681,
12,
272,
2790,
6700,
12,
272,
18110,
6700,
12,
272,
485,
11070,
2768,
12,
272,
2790,
4547,
12,
272,
2654,
8463,
12,
272,
18110,
8463,
12,
272,
32078,
1563,
12,
272,
29662,
906,
968,
12,
272,
485,
2499,
11070,
1563,
12,
272,
485,
31868,
12626,
83,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4177,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
7280,
314,
14303,
11462,
436,
8417,
665,
3239,
10610,
570,
30,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
14303,
436,
365,
14286,
1334,
199,
3,
314,
10697,
844,
26,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
199,
199,
624,
2404,
2159,
66,
5075,
3231,
367,
8335,
14,
3009,
14,
3629,
436,
4048,
14,
199,
199,
624,
199,
199,
504,
1275,
3009,
14,
1095,
492,
334,
272,
13268,
18324,
272,
776,
421,
199,
504,
1275,
3009,
14,
3629,
492,
334,
272,
2670,
8463,
12,
272,
4996,
12,
272,
4996,
2698,
12,
272,
25889,
12,
272,
3758,
16009,
12,
272,
3758,
7599,
12,
272,
481,
13534,
1110,
12,
272,
12718,
12,
272,
12718,
8463,
12,
272,
5499,
12,
272,
24905,
12,
272,
510,
13202,
2698,
12,
272,
26710,
1197,
8463,
12,
272,
13268,
2081,
12,
272,
10975,
12,
272,
6957,
12,
272,
11086,
5339,
25285,
12,
272,
18276,
8463,
12,
272,
485,
362,
63,
1224,
63,
498,
12,
272,
4996,
7768,
8463,
12,
272,
776,
421,
199,
504,
1275,
3009,
14,
26919,
492,
8260,
421,
199,
504,
1275,
3009,
14,
17102,
492,
334,
272,
32078,
12,
272,
2790,
3186,
12,
272,
18110,
3186,
12,
272,
2790,
5826,
12,
272,
18110,
5826,
12,
272,
2790,
2681,
12,
272,
18110,
2681,
12,
272,
2790,
6700,
12,
272,
18110,
6700,
12,
272,
485,
11070,
2768,
12,
272,
2790,
4547,
12,
272,
2654,
8463,
12,
272,
18110,
8463,
12,
272,
32078,
1563,
12,
272,
29662,
906,
968,
12,
272,
485,
2499,
11070,
1563,
12,
272,
485,
31868,
12626,
83,
199,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ChileanVirtualObservatory/flask_endpoint
|
endpoint/run.py
|
1
|
1314
|
#This file is part of ChiVO, the Chilean Virtual Observatory
#A project sponsored by FONDEF (D11I1060)
#Copyright (C) 2015 Universidad Tecnica Federico Santa Maria Mauricio Solar
# Marcelo Mendoza
# Universidad de Chile Diego Mardones
# Pontificia Universidad Catolica Karim Pichara
# Universidad de Concepcion Ricardo Contreras
# Universidad de Santiago Victor Parada
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from app import app
app.run(debug=True)
|
gpl-3.0
|
[
3,
2765,
570,
365,
1777,
402,
2799,
73,
10662,
12,
314,
2799,
441,
290,
13311,
17985,
7297,
8658,
199,
3,
33,
2199,
308,
678,
1152,
581,
701,
481,
615,
5638,
334,
36,
845,
41,
709,
2259,
9,
199,
3,
7384,
334,
35,
9,
6900,
1910,
4380,
4148,
350,
377,
825,
12165,
65,
7949,
9910,
331,
29359,
502,
603,
27957,
16593,
300,
530,
2308,
17991,
285,
199,
3,
2476,
14960,
16794,
301,
320,
603,
500,
79,
8076,
199,
3,
7861,
1910,
4380,
4148,
350,
477,
2799,
441,
9326,
577,
1873,
1939,
603,
1005,
4548,
199,
3,
7861,
510,
265,
1428,
16521,
1910,
4380,
4148,
350,
445,
11318,
7518,
3515,
1804,
759,
77,
510,
1158,
17956,
199,
3,
7861,
1910,
4380,
4148,
350,
477,
1448,
28448,
9718,
4483,
820,
530,
1005,
79,
1448,
84,
3859,
305,
199,
3,
7861,
1910,
4380,
4148,
350,
477,
428,
4466,
14315,
8295,
6561,
630,
2235,
10641,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
12,
8217,
14,
199,
199,
504,
1145,
492,
1145,
199,
199,
571,
14,
1065,
8,
1757,
29,
549,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2765,
570,
365,
1777,
402,
2799,
73,
10662,
12,
314,
2799,
441,
290,
13311,
17985,
7297,
8658,
199,
3,
33,
2199,
308,
678,
1152,
581,
701,
481,
615,
5638,
334,
36,
845,
41,
709,
2259,
9,
199,
3,
7384,
334,
35,
9,
6900,
1910,
4380,
4148,
350,
377,
825,
12165,
65,
7949,
9910,
331,
29359,
502,
603,
27957,
16593,
300,
530,
2308,
17991,
285,
199,
3,
2476,
14960,
16794,
301,
320,
603,
500,
79,
8076,
199,
3,
7861,
1910,
4380,
4148,
350,
477,
2799,
441,
9326,
577,
1873,
1939,
603,
1005,
4548,
199,
3,
7861,
510,
265,
1428,
16521,
1910,
4380,
4148,
350,
445,
11318,
7518,
3515,
1804,
759,
77,
510,
1158,
17956,
199,
3,
7861,
1910,
4380,
4148,
350,
477,
1448,
28448,
9718,
4483,
820,
530,
1005,
79,
1448,
84,
3859,
305,
199,
3,
7861,
1910,
4380,
4148,
350,
477,
428,
4466,
14315,
8295,
6561,
630,
2235,
10641,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
199,
3,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
1015,
499,
199,
3,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
642,
2240,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
14259,
12,
12066,
11844,
12,
8226,
12,
4828,
221,
11315,
13,
10067,
12,
8217,
14,
199,
199,
504,
1145,
492,
1145,
199,
199,
571,
14,
1065,
8,
1757,
29,
549,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
neumerance/deploy
|
.venv/lib/python2.7/site-packages/django/contrib/localflavor/ca/forms.py
|
100
|
4953
|
"""
Canada-specific Form helpers
"""
from __future__ import absolute_import, unicode_literals
import re
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, CharField, Select
from django.utils.encoding import smart_text
from django.utils.translation import ugettext_lazy as _
phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
sin_re = re.compile(r"^(\d{3})-(\d{3})-(\d{3})$")
class CAPostalCodeField(CharField):
"""
Canadian postal code field.
Validates against known invalid characters: D, F, I, O, Q, U
Additionally the first character cannot be Z or W.
For more info see:
http://www.canadapost.ca/tools/pg/manual/PGaddress-e.asp#1402170
"""
default_error_messages = {
'invalid': _('Enter a postal code in the format XXX XXX.'),
}
postcode_regex = re.compile(r'^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) *(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$')
def clean(self, value):
value = super(CAPostalCodeField, self).clean(value)
if value in EMPTY_VALUES:
return ''
postcode = value.upper().strip()
m = self.postcode_regex.match(postcode)
if not m:
raise ValidationError(self.default_error_messages['invalid'])
return "%s %s" % (m.group(1), m.group(2))
class CAPhoneNumberField(Field):
"""Canadian phone number field."""
default_error_messages = {
'invalid': _('Phone numbers must be in XXX-XXX-XXXX format.'),
}
def clean(self, value):
"""Validate a phone number.
"""
super(CAPhoneNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
value = re.sub('(\(|\)|\s+)', '', smart_text(value))
m = phone_digits_re.search(value)
if m:
return '%s-%s-%s' % (m.group(1), m.group(2), m.group(3))
raise ValidationError(self.error_messages['invalid'])
class CAProvinceField(Field):
"""
A form field that validates its input is a Canadian province name or abbreviation.
It normalizes the input to the standard two-leter postal service
abbreviation for the given province.
"""
default_error_messages = {
'invalid': _('Enter a Canadian province or territory.'),
}
def clean(self, value):
super(CAProvinceField, self).clean(value)
if value in EMPTY_VALUES:
return ''
try:
value = value.strip().lower()
except AttributeError:
pass
else:
# Load data in memory only when it is required, see also #17275
from .ca_provinces import PROVINCES_NORMALIZED
try:
return PROVINCES_NORMALIZED[value.strip().lower()]
except KeyError:
pass
raise ValidationError(self.error_messages['invalid'])
class CAProvinceSelect(Select):
"""
A Select widget that uses a list of Canadian provinces and
territories as its choices.
"""
def __init__(self, attrs=None):
# Load data in memory only when it is required, see also #17275
from .ca_provinces import PROVINCE_CHOICES
super(CAProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class CASocialInsuranceNumberField(Field):
"""
A Canadian Social Insurance Number (SIN).
Checks the following rules to determine whether the number is valid:
* Conforms to the XXX-XXX-XXX format.
* Passes the check digit process "Luhn Algorithm"
See: http://en.wikipedia.org/wiki/Social_Insurance_Number
"""
default_error_messages = {
'invalid': _('Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'),
}
def clean(self, value):
super(CASocialInsuranceNumberField, self).clean(value)
if value in EMPTY_VALUES:
return ''
match = re.match(sin_re, value)
if not match:
raise ValidationError(self.error_messages['invalid'])
number = '%s-%s-%s' % (match.group(1), match.group(2), match.group(3))
check_number = '%s%s%s' % (match.group(1), match.group(2), match.group(3))
if not self.luhn_checksum_is_valid(check_number):
raise ValidationError(self.error_messages['invalid'])
return number
def luhn_checksum_is_valid(self, number):
"""
Checks to make sure that the SIN passes a luhn mod-10 checksum
See: http://en.wikipedia.org/wiki/Luhn_algorithm
"""
sum = 0
num_digits = len(number)
oddeven = num_digits & 1
for count in range(0, num_digits):
digit = int(number[count])
if not (( count & 1 ) ^ oddeven ):
digit = digit * 2
if digit > 9:
digit = digit - 9
sum = sum + digit
return ( (sum % 10) == 0 )
|
apache-2.0
|
[
624,
199,
6049,
10641,
13,
6100,
8204,
10897,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
5024,
12,
12064,
12,
9496,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
505,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
9339,
63,
7022,
63,
264,
275,
295,
14,
2014,
8,
82,
4289,
5169,
17,
13,
31,
5547,
2961,
68,
91,
19,
1552,
1988,
4537,
11843,
2961,
68,
91,
19,
1552,
1988,
4537,
11843,
2961,
68,
91,
20,
1552,
9988,
199,
5911,
63,
264,
275,
295,
14,
2014,
8,
82,
16136,
2961,
68,
91,
19,
1552,
13,
2961,
68,
91,
19,
1552,
13,
2961,
68,
91,
19,
1552,
22550,
199,
199,
533,
445,
1282,
941,
279,
3034,
792,
8,
2183,
304,
272,
408,
272,
445,
6738,
6268,
2963,
279,
1233,
901,
14,
339,
4821,
2335,
6169,
6040,
3866,
4110,
26,
577,
12,
481,
12,
473,
12,
593,
12,
1413,
12,
738,
272,
25448,
314,
1642,
4528,
3913,
506,
3107,
503,
644,
14,
272,
2104,
1655,
2256,
1937,
26,
272,
1455,
921,
1544,
14,
2425,
350,
439,
941,
14,
696,
15,
2537,
15,
4198,
15,
9285,
15,
11115,
1562,
13,
69,
14,
20222,
3,
29840,
11010,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
2963,
279,
1233,
315,
314,
1475,
5787,
5787,
8038,
272,
789,
339,
2963,
600,
63,
3821,
275,
295,
14,
2014,
8,
82,
4289,
779,
1217,
2089,
39,
22313,
14307,
16237,
3311,
840,
54,
8195,
7272,
68,
59,
1217,
2089,
39,
22313,
14307,
16237,
3311,
840,
54,
24648,
566,
627,
2961,
68,
59,
1217,
2089,
39,
22313,
14307,
16237,
3311,
840,
54,
24648,
7272,
68,
9,
9988,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
574,
275,
1613,
8,
8549,
941,
279,
3034,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
2963,
600,
275,
574,
14,
4142,
1252,
1913,
342,
267,
333,
275,
291,
14,
1932,
600,
63,
3821,
14,
1431,
8,
1932,
600,
9,
267,
340,
440,
333,
26,
288,
746,
8505,
8,
277,
14,
885,
63,
705,
63,
3431,
459,
3197,
1105,
267,
372,
2071,
83,
450,
83,
2,
450,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
430,
199,
199,
533,
445,
1282,
72,
368,
3259,
792,
8,
792,
304,
272,
408,
6049,
65,
6268,
14617,
1329,
901,
1041,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
15199,
5579,
1471,
506,
315,
5787,
13,
13933,
13,
6873,
1475,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
408,
12584,
282,
14617,
1329,
14,
267,
408,
267,
1613,
8,
8549,
72,
368,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
574,
275,
295,
14,
954,
360,
2961,
8,
6113,
9,
6113,
83,
14705,
3260,
11179,
63,
505,
8,
585,
430,
267,
333,
275,
14617,
63,
7022,
63,
264,
14,
1733,
8,
585,
9,
267,
340,
333,
26,
288,
372,
1543,
83,
3295,
83,
3295,
83,
7,
450,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
267,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
199,
199,
533,
7240,
919,
86,
2855,
792,
8,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2399,
1324,
365,
282,
445,
6738,
6268,
24074,
2855,
536,
503,
2236,
30369,
14,
272,
2779,
3293,
6491,
314,
1324,
370,
314,
4465,
2877,
13,
274,
351,
2963,
279,
2435,
272,
2236,
30369,
367,
314,
1627,
24074,
2855,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
445,
6738,
6268,
24074,
2855,
503,
2044,
26425,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
1613,
8,
3263,
919,
86,
2855,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
862,
26,
288,
574,
275,
574,
14,
1913,
1252,
2325,
342,
267,
871,
4281,
26,
288,
986,
267,
587,
26,
288,
327,
7190,
666,
315,
4402,
1454,
1380,
652,
365,
1415,
12,
1937,
2597,
327,
1196,
13643,
288,
687,
1275,
696,
63,
496,
11908,
823,
492,
3611,
54,
568,
16734,
63,
10765,
18732,
288,
862,
26,
355,
372,
3611,
54,
568,
16734,
63,
10765,
18732,
59,
585,
14,
1913,
1252,
2325,
5106,
288,
871,
4067,
26,
355,
986,
267,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
199,
199,
533,
7240,
919,
86,
2855,
5446,
8,
5446,
304,
272,
408,
272,
437,
9496,
3938,
626,
4440,
282,
769,
402,
445,
6738,
6268,
557,
11908,
823,
436,
272,
2044,
11133,
6112,
465,
2399,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
327,
7190,
666,
315,
4402,
1454,
1380,
652,
365,
1415,
12,
1937,
2597,
327,
1196,
13643,
267,
687,
1275,
696,
63,
496,
11908,
823,
492,
3611,
54,
568,
2089,
63,
16236,
267,
1613,
8,
3263,
919,
86,
2855,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
2514,
54,
568,
2089,
63,
16236,
9,
199,
199,
533,
27751,
28748,
13962,
300,
554,
3259,
792,
8,
792,
304,
272,
408,
272,
437,
445,
6738,
6268,
2002,
7180,
12062,
300,
554,
4860,
334,
51,
568,
680,
339,
13813,
314,
2569,
4713,
370,
6705,
3775,
314,
1329,
365,
1686,
26,
398,
627,
1448,
3351,
370,
314,
5787,
13,
13933,
13,
13933,
1475,
14,
267,
627,
510,
1916,
314,
1104,
10964,
2112,
298,
18176,
6164,
23823,
2,
1467,
1666,
26,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
31356,
63,
13962,
300,
554,
63,
3259,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
1686,
445,
6738,
6268,
2002,
7180,
12062
] |
[
199,
6049,
10641,
13,
6100,
8204,
10897,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1639,
14,
1018,
14,
11346,
492,
16589,
63,
15514,
199,
504,
1639,
14,
3351,
492,
8505,
199,
504,
1639,
14,
3351,
14,
955,
492,
5024,
12,
12064,
12,
9496,
199,
504,
1639,
14,
1208,
14,
2991,
492,
11179,
63,
505,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
421,
199,
9339,
63,
7022,
63,
264,
275,
295,
14,
2014,
8,
82,
4289,
5169,
17,
13,
31,
5547,
2961,
68,
91,
19,
1552,
1988,
4537,
11843,
2961,
68,
91,
19,
1552,
1988,
4537,
11843,
2961,
68,
91,
20,
1552,
9988,
199,
5911,
63,
264,
275,
295,
14,
2014,
8,
82,
16136,
2961,
68,
91,
19,
1552,
13,
2961,
68,
91,
19,
1552,
13,
2961,
68,
91,
19,
1552,
22550,
199,
199,
533,
445,
1282,
941,
279,
3034,
792,
8,
2183,
304,
272,
408,
272,
445,
6738,
6268,
2963,
279,
1233,
901,
14,
339,
4821,
2335,
6169,
6040,
3866,
4110,
26,
577,
12,
481,
12,
473,
12,
593,
12,
1413,
12,
738,
272,
25448,
314,
1642,
4528,
3913,
506,
3107,
503,
644,
14,
272,
2104,
1655,
2256,
1937,
26,
272,
1455,
921,
1544,
14,
2425,
350,
439,
941,
14,
696,
15,
2537,
15,
4198,
15,
9285,
15,
11115,
1562,
13,
69,
14,
20222,
3,
29840,
11010,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
2963,
279,
1233,
315,
314,
1475,
5787,
5787,
8038,
272,
789,
339,
2963,
600,
63,
3821,
275,
295,
14,
2014,
8,
82,
4289,
779,
1217,
2089,
39,
22313,
14307,
16237,
3311,
840,
54,
8195,
7272,
68,
59,
1217,
2089,
39,
22313,
14307,
16237,
3311,
840,
54,
24648,
566,
627,
2961,
68,
59,
1217,
2089,
39,
22313,
14307,
16237,
3311,
840,
54,
24648,
7272,
68,
9,
9988,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
574,
275,
1613,
8,
8549,
941,
279,
3034,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
2963,
600,
275,
574,
14,
4142,
1252,
1913,
342,
267,
333,
275,
291,
14,
1932,
600,
63,
3821,
14,
1431,
8,
1932,
600,
9,
267,
340,
440,
333,
26,
288,
746,
8505,
8,
277,
14,
885,
63,
705,
63,
3431,
459,
3197,
1105,
267,
372,
2071,
83,
450,
83,
2,
450,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
430,
199,
199,
533,
445,
1282,
72,
368,
3259,
792,
8,
792,
304,
272,
408,
6049,
65,
6268,
14617,
1329,
901,
1041,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
15199,
5579,
1471,
506,
315,
5787,
13,
13933,
13,
6873,
1475,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
408,
12584,
282,
14617,
1329,
14,
267,
408,
267,
1613,
8,
8549,
72,
368,
3259,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
574,
275,
295,
14,
954,
360,
2961,
8,
6113,
9,
6113,
83,
14705,
3260,
11179,
63,
505,
8,
585,
430,
267,
333,
275,
14617,
63,
7022,
63,
264,
14,
1733,
8,
585,
9,
267,
340,
333,
26,
288,
372,
1543,
83,
3295,
83,
3295,
83,
7,
450,
334,
77,
14,
923,
8,
17,
395,
333,
14,
923,
8,
18,
395,
333,
14,
923,
8,
19,
430,
267,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
199,
199,
533,
7240,
919,
86,
2855,
792,
8,
792,
304,
272,
408,
272,
437,
1824,
901,
626,
29280,
2399,
1324,
365,
282,
445,
6738,
6268,
24074,
2855,
536,
503,
2236,
30369,
14,
272,
2779,
3293,
6491,
314,
1324,
370,
314,
4465,
2877,
13,
274,
351,
2963,
279,
2435,
272,
2236,
30369,
367,
314,
1627,
24074,
2855,
14,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
445,
6738,
6268,
24074,
2855,
503,
2044,
26425,
8038,
272,
789,
339,
347,
3633,
8,
277,
12,
574,
304,
267,
1613,
8,
3263,
919,
86,
2855,
792,
12,
291,
680,
3118,
8,
585,
9,
267,
340,
574,
315,
16589,
63,
15514,
26,
288,
372,
2125,
267,
862,
26,
288,
574,
275,
574,
14,
1913,
1252,
2325,
342,
267,
871,
4281,
26,
288,
986,
267,
587,
26,
288,
327,
7190,
666,
315,
4402,
1454,
1380,
652,
365,
1415,
12,
1937,
2597,
327,
1196,
13643,
288,
687,
1275,
696,
63,
496,
11908,
823,
492,
3611,
54,
568,
16734,
63,
10765,
18732,
288,
862,
26,
355,
372,
3611,
54,
568,
16734,
63,
10765,
18732,
59,
585,
14,
1913,
1252,
2325,
5106,
288,
871,
4067,
26,
355,
986,
267,
746,
8505,
8,
277,
14,
705,
63,
3431,
459,
3197,
1105,
199,
199,
533,
7240,
919,
86,
2855,
5446,
8,
5446,
304,
272,
408,
272,
437,
9496,
3938,
626,
4440,
282,
769,
402,
445,
6738,
6268,
557,
11908,
823,
436,
272,
2044,
11133,
6112,
465,
2399,
3415,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
3290,
29,
403,
304,
267,
327,
7190,
666,
315,
4402,
1454,
1380,
652,
365,
1415,
12,
1937,
2597,
327,
1196,
13643,
267,
687,
1275,
696,
63,
496,
11908,
823,
492,
3611,
54,
568,
2089,
63,
16236,
267,
1613,
8,
3263,
919,
86,
2855,
5446,
12,
291,
2843,
826,
721,
3288,
12,
3415,
29,
2514,
54,
568,
2089,
63,
16236,
9,
199,
199,
533,
27751,
28748,
13962,
300,
554,
3259,
792,
8,
792,
304,
272,
408,
272,
437,
445,
6738,
6268,
2002,
7180,
12062,
300,
554,
4860,
334,
51,
568,
680,
339,
13813,
314,
2569,
4713,
370,
6705,
3775,
314,
1329,
365,
1686,
26,
398,
627,
1448,
3351,
370,
314,
5787,
13,
13933,
13,
13933,
1475,
14,
267,
627,
510,
1916,
314,
1104,
10964,
2112,
298,
18176,
6164,
23823,
2,
1467,
1666,
26,
1455,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
31356,
63,
13962,
300,
554,
63,
3259,
272,
408,
272,
849,
63,
705,
63,
3431,
275,
469,
267,
283,
3197,
356,
4018,
8468,
282,
1686,
445,
6738,
6268,
2002,
7180,
12062,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ddebrunner/streamsx.topology
|
test/python/spl/testtkpy/opt/python/streams/test_ec.py
|
2
|
4678
|
# coding=utf-8
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2017
# Import the SPL decorators
from streamsx.spl import spl
import streamsx.ec as ec
import pickle
#------------------------------------------------------------------
# Test Execution Context (streamsx.ex) functions
#------------------------------------------------------------------
def spl_namespace():
return "com.ibm.streamsx.topology.pytest.pyec"
@spl.filter()
class PyTestOperatorContext(object):
def __init__(self, domain_id, instance_id, job_id, pe_id, channel, local_channel, max_channels, local_max_channels):
self.enter_called = False
self.exit_called = False
self.domain_id = domain_id
self.instance_id = instance_id
self.job_id = job_id
self.pe_id = pe_id
self.channel = channel
self.local_channel = local_channel
self.max_channels = max_channels
self.local_max_channels = local_max_channels
if not self.check():
raise AssertionError("PyTestOperatorContext")
def same(self, expect, got):
if expect != got:
print("Expected", expect, "Got", got)
return False
return True
def check(self):
ok = self.same(self.domain_id, ec.domain_id())
ok = ok and self.same(self.instance_id, ec.instance_id())
ok = ok and self.same(self.job_id, ec.job_id())
ok = ok and self.same(self.pe_id, ec.pe_id())
ok = ok and self.same(self.channel, ec.channel(self))
ok = ok and self.same(self.local_channel, ec.local_channel(self))
ok = ok and self.same(self.max_channels, ec.max_channels(self))
ok = ok and self.same(self.local_max_channels, ec.local_max_channels(self))
return ok
def __call__(self, *tuple):
if not self.enter_called:
raise AssertionError("__enter__() was not called")
if self.exit_called:
raise AssertionError("__exit__() was called before shutdown")
return self.check()
def __enter__(self):
self.enter_called = True
def __exit__(self, exception_type, exception_value, traceback):
self.exit_called = True
@spl.filter()
class PyTestMetrics(object):
def __init__(self):
ok = True
self.c = ec.CustomMetric(self, "C1")
ok = ok and self.check_metric(self.c, "C1", None, ec.MetricKind.Counter, 0)
c2 = ec.CustomMetric(self, "C2", "This is C2")
ok = ok and self.check_metric(c2, "C2", "This is C2", ec.MetricKind.Counter, 0)
c3 = ec.CustomMetric(self, "C3", initialValue=8123)
ok = ok and self.check_metric(c3, "C3", None, ec.MetricKind.Counter, 8123)
g1 = ec.CustomMetric(self, "G1", kind=ec.MetricKind.Gauge)
ok = ok and self.check_metric(g1, "G1", None, ec.MetricKind.Gauge, 0)
g2 = ec.CustomMetric(self, "G2", kind='Gauge', initialValue=-214)
ok = ok and self.check_metric(g2, "G2", None, ec.MetricKind.Gauge, -214)
g2.value = 89
ok = ok and self.check_metric(g2, "G2", None, ec.MetricKind.Gauge, 89)
g2X = ec.CustomMetric(self, "G2", kind='Gauge', initialValue=-214)
ok = ok and self.check_metric(g2, "G2", None, ec.MetricKind.Gauge, 89)
ok = ok and self.check_metric(g2X, "G2", None, ec.MetricKind.Gauge, 89)
if not ok:
raise AssertionError("Failed metrics!")
# Test a metric cannot be pickled
try:
pm = pickle.dumps(g2)
raise AssertionError("Was able to pickle metric:" + pm)
except pickle.PicklingError:
pass
def __call__(self, *tuple):
ok= True
cv = self.c.value
self.c += 7
ok = ok and self.check_metric(self.c, "C1", None, ec.MetricKind.Counter, cv + 7)
self.c.value += 13
ok = ok and self.check_metric(self.c, "C1", None, ec.MetricKind.Counter, cv + 7 + 13)
self.c.value -= 8
ok = ok and self.check_metric(self.c, "C1", None, ec.MetricKind.Counter, cv + 7 + 13 - 8)
return ok
def check_metric(self, m, n, desc, k, v):
if n != m.name:
print(n, "!=", m.name)
return False
if desc is not None:
if desc != m.description:
print(desc, "!=", m.description)
return False
if k != m.kind:
print(k, "!=", m.kind)
return False
if v != m.value:
print("m.value", v, "!=", m.value)
return False
if v != int(m):
print("int(m)", v, "!=", int(m))
return False
return True
|
apache-2.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
3,
3909,
26570,
83,
446,
16158,
402,
26202,
199,
3,
1898,
26202,
22304,
14,
9708,
199,
199,
3,
3161,
314,
428,
2749,
20419,
199,
504,
2547,
12915,
14,
15276,
492,
23168,
199,
646,
2547,
12915,
14,
825,
465,
7062,
199,
646,
5927,
199,
199,
7656,
306,
199,
3,
1379,
28573,
9470,
334,
11231,
88,
14,
476,
9,
3423,
199,
7656,
306,
199,
199,
318,
23168,
63,
3251,
837,
272,
372,
298,
957,
14,
19870,
14,
11231,
88,
14,
10775,
14,
4462,
14,
647,
825,
2,
199,
199,
32,
15276,
14,
1541,
342,
199,
533,
1611,
774,
7961,
2998,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
2881,
63,
344,
12,
1256,
63,
344,
12,
3906,
63,
344,
12,
4837,
63,
344,
12,
3623,
12,
2257,
63,
2775,
12,
1390,
63,
6324,
12,
2257,
63,
988,
63,
6324,
304,
267,
291,
14,
4200,
63,
3527,
275,
756,
267,
291,
14,
2224,
63,
3527,
275,
756,
267,
291,
14,
2261,
63,
344,
275,
2881,
63,
344,
267,
291,
14,
842,
63,
344,
275,
1256,
63,
344,
267,
291,
14,
2423,
63,
344,
275,
3906,
63,
344,
267,
291,
14,
321,
63,
344,
275,
4837,
63,
344,
267,
291,
14,
2775,
275,
3623,
267,
291,
14,
1832,
63,
2775,
275,
2257,
63,
2775,
267,
291,
14,
988,
63,
6324,
275,
1390,
63,
6324,
267,
291,
14,
1832,
63,
988,
63,
6324,
275,
2257,
63,
988,
63,
6324,
267,
340,
440,
291,
14,
1074,
837,
1467,
746,
9070,
480,
2713,
774,
7961,
2998,
531,
339,
347,
2011,
8,
277,
12,
4282,
12,
4788,
304,
267,
340,
4282,
1137,
4788,
26,
288,
870,
480,
6964,
401,
4282,
12,
298,
13662,
401,
4788,
9,
288,
372,
756,
267,
372,
715,
339,
347,
1104,
8,
277,
304,
267,
4112,
275,
291,
14,
7191,
8,
277,
14,
2261,
63,
344,
12,
7062,
14,
2261,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
842,
63,
344,
12,
7062,
14,
842,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
2423,
63,
344,
12,
7062,
14,
2423,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
321,
63,
344,
12,
7062,
14,
321,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
2775,
12,
7062,
14,
2775,
8,
277,
430,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
1832,
63,
2775,
12,
7062,
14,
1832,
63,
2775,
8,
277,
430,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
988,
63,
6324,
12,
7062,
14,
988,
63,
6324,
8,
277,
430,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
1832,
63,
988,
63,
6324,
12,
7062,
14,
1832,
63,
988,
63,
6324,
8,
277,
430,
267,
372,
4112,
15567,
347,
636,
1250,
721,
277,
12,
627,
2960,
304,
267,
340,
440,
291,
14,
4200,
63,
3527,
26,
288,
746,
9070,
16232,
4200,
4533,
1990,
440,
2797,
531,
267,
340,
291,
14,
2224,
63,
3527,
26,
288,
746,
9070,
16232,
2224,
4533,
1990,
2797,
2544,
12842,
531,
267,
372,
291,
14,
1074,
342,
339,
347,
636,
4200,
721,
277,
304,
267,
291,
14,
4200,
63,
3527,
275,
715,
339,
347,
636,
2224,
721,
277,
12,
1919,
63,
466,
12,
1919,
63,
585,
12,
5190,
304,
267,
291,
14,
2224,
63,
3527,
275,
715,
199,
199,
32,
15276,
14,
1541,
342,
199,
533,
1611,
774,
17213,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
4112,
275,
715,
267,
291,
14,
67,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
35,
17,
531,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
277,
14,
67,
12,
298,
35,
17,
401,
488,
12,
7062,
14,
11119,
13028,
14,
11348,
12,
378,
9,
267,
286,
18,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
35,
18,
401,
298,
2765,
365,
445,
18,
531,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
67,
18,
12,
298,
35,
18,
401,
298,
2765,
365,
445,
18,
401,
7062,
14,
11119,
13028,
14,
11348,
12,
378,
9,
398,
286,
19,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
35,
19,
401,
2536,
1110,
29,
24,
4288,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
67,
19,
12,
298,
35,
19,
401,
488,
12,
7062,
14,
11119,
13028,
14,
11348,
12,
1695,
4288,
9,
398,
486,
17,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
39,
17,
401,
4928,
29,
825,
14,
11119,
13028,
14,
39,
30949,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
17,
12,
298,
39,
17,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
378,
9,
398,
486,
18,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
39,
18,
401,
4928,
534,
39,
30949,
297,
2536,
1110,
4022,
6886,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
446,
6886,
9,
398,
486,
18,
14,
585,
275,
17838,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
17838,
9,
398,
486,
18,
56,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
39,
18,
401,
4928,
534,
39,
30949,
297,
2536,
1110,
4022,
6886,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
17838,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
56,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
17838,
9,
2728,
340,
440,
4112,
26,
288,
746,
9070,
480,
4276,
7186,
9124,
398,
327,
1379,
282,
6370,
3913,
506,
18731,
267,
862,
26,
288,
14207,
275,
5927,
14,
4180,
8,
71,
18,
9,
288,
746,
9070,
480,
55,
305,
7688,
370,
5927
] |
[
2803,
29,
1624,
13,
24,
199,
3,
3909,
26570,
83,
446,
16158,
402,
26202,
199,
3,
1898,
26202,
22304,
14,
9708,
199,
199,
3,
3161,
314,
428,
2749,
20419,
199,
504,
2547,
12915,
14,
15276,
492,
23168,
199,
646,
2547,
12915,
14,
825,
465,
7062,
199,
646,
5927,
199,
199,
7656,
306,
199,
3,
1379,
28573,
9470,
334,
11231,
88,
14,
476,
9,
3423,
199,
7656,
306,
199,
199,
318,
23168,
63,
3251,
837,
272,
372,
298,
957,
14,
19870,
14,
11231,
88,
14,
10775,
14,
4462,
14,
647,
825,
2,
199,
199,
32,
15276,
14,
1541,
342,
199,
533,
1611,
774,
7961,
2998,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
2881,
63,
344,
12,
1256,
63,
344,
12,
3906,
63,
344,
12,
4837,
63,
344,
12,
3623,
12,
2257,
63,
2775,
12,
1390,
63,
6324,
12,
2257,
63,
988,
63,
6324,
304,
267,
291,
14,
4200,
63,
3527,
275,
756,
267,
291,
14,
2224,
63,
3527,
275,
756,
267,
291,
14,
2261,
63,
344,
275,
2881,
63,
344,
267,
291,
14,
842,
63,
344,
275,
1256,
63,
344,
267,
291,
14,
2423,
63,
344,
275,
3906,
63,
344,
267,
291,
14,
321,
63,
344,
275,
4837,
63,
344,
267,
291,
14,
2775,
275,
3623,
267,
291,
14,
1832,
63,
2775,
275,
2257,
63,
2775,
267,
291,
14,
988,
63,
6324,
275,
1390,
63,
6324,
267,
291,
14,
1832,
63,
988,
63,
6324,
275,
2257,
63,
988,
63,
6324,
267,
340,
440,
291,
14,
1074,
837,
1467,
746,
9070,
480,
2713,
774,
7961,
2998,
531,
339,
347,
2011,
8,
277,
12,
4282,
12,
4788,
304,
267,
340,
4282,
1137,
4788,
26,
288,
870,
480,
6964,
401,
4282,
12,
298,
13662,
401,
4788,
9,
288,
372,
756,
267,
372,
715,
339,
347,
1104,
8,
277,
304,
267,
4112,
275,
291,
14,
7191,
8,
277,
14,
2261,
63,
344,
12,
7062,
14,
2261,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
842,
63,
344,
12,
7062,
14,
842,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
2423,
63,
344,
12,
7062,
14,
2423,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
321,
63,
344,
12,
7062,
14,
321,
63,
344,
1012,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
2775,
12,
7062,
14,
2775,
8,
277,
430,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
1832,
63,
2775,
12,
7062,
14,
1832,
63,
2775,
8,
277,
430,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
988,
63,
6324,
12,
7062,
14,
988,
63,
6324,
8,
277,
430,
267,
4112,
275,
4112,
436,
291,
14,
7191,
8,
277,
14,
1832,
63,
988,
63,
6324,
12,
7062,
14,
1832,
63,
988,
63,
6324,
8,
277,
430,
267,
372,
4112,
15567,
347,
636,
1250,
721,
277,
12,
627,
2960,
304,
267,
340,
440,
291,
14,
4200,
63,
3527,
26,
288,
746,
9070,
16232,
4200,
4533,
1990,
440,
2797,
531,
267,
340,
291,
14,
2224,
63,
3527,
26,
288,
746,
9070,
16232,
2224,
4533,
1990,
2797,
2544,
12842,
531,
267,
372,
291,
14,
1074,
342,
339,
347,
636,
4200,
721,
277,
304,
267,
291,
14,
4200,
63,
3527,
275,
715,
339,
347,
636,
2224,
721,
277,
12,
1919,
63,
466,
12,
1919,
63,
585,
12,
5190,
304,
267,
291,
14,
2224,
63,
3527,
275,
715,
199,
199,
32,
15276,
14,
1541,
342,
199,
533,
1611,
774,
17213,
8,
785,
304,
272,
347,
636,
826,
721,
277,
304,
267,
4112,
275,
715,
267,
291,
14,
67,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
35,
17,
531,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
277,
14,
67,
12,
298,
35,
17,
401,
488,
12,
7062,
14,
11119,
13028,
14,
11348,
12,
378,
9,
267,
286,
18,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
35,
18,
401,
298,
2765,
365,
445,
18,
531,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
67,
18,
12,
298,
35,
18,
401,
298,
2765,
365,
445,
18,
401,
7062,
14,
11119,
13028,
14,
11348,
12,
378,
9,
398,
286,
19,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
35,
19,
401,
2536,
1110,
29,
24,
4288,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
67,
19,
12,
298,
35,
19,
401,
488,
12,
7062,
14,
11119,
13028,
14,
11348,
12,
1695,
4288,
9,
398,
486,
17,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
39,
17,
401,
4928,
29,
825,
14,
11119,
13028,
14,
39,
30949,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
17,
12,
298,
39,
17,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
378,
9,
398,
486,
18,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
39,
18,
401,
4928,
534,
39,
30949,
297,
2536,
1110,
4022,
6886,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
446,
6886,
9,
398,
486,
18,
14,
585,
275,
17838,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
17838,
9,
398,
486,
18,
56,
275,
7062,
14,
7223,
11119,
8,
277,
12,
298,
39,
18,
401,
4928,
534,
39,
30949,
297,
2536,
1110,
4022,
6886,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
17838,
9,
267,
4112,
275,
4112,
436,
291,
14,
1074,
63,
5165,
8,
71,
18,
56,
12,
298,
39,
18,
401,
488,
12,
7062,
14,
11119,
13028,
14,
39,
30949,
12,
17838,
9,
2728,
340,
440,
4112,
26,
288,
746,
9070,
480,
4276,
7186,
9124,
398,
327,
1379,
282,
6370,
3913,
506,
18731,
267,
862,
26,
288,
14207,
275,
5927,
14,
4180,
8,
71,
18,
9,
288,
746,
9070,
480,
55,
305,
7688,
370,
5927,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Vixionar/django
|
django/test/testcases.py
|
9
|
57187
|
from __future__ import unicode_literals
import difflib
import errno
import json
import os
import posixpath
import socket
import sys
import threading
import unittest
import warnings
from collections import Counter
from contextlib import contextmanager
from copy import copy
from functools import wraps
from unittest.util import safe_repr
from django.apps import apps
from django.conf import settings
from django.core import mail
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.handlers.wsgi import WSGIHandler, get_path_info
from django.core.management import call_command
from django.core.management.color import no_style
from django.core.management.sql import emit_post_migrate_signal
from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer
from django.core.urlresolvers import clear_url_caches, set_urlconf
from django.db import DEFAULT_DB_ALIAS, connection, connections, transaction
from django.forms.fields import CharField
from django.http import QueryDict
from django.test.client import Client
from django.test.html import HTMLParseError, parse_html
from django.test.signals import setting_changed, template_rendered
from django.test.utils import (
CaptureQueriesContext, ContextList, compare_xml, modify_settings,
override_settings,
)
from django.utils import six
from django.utils.decorators import classproperty
from django.utils.deprecation import (
RemovedInDjango20Warning, RemovedInDjango110Warning,
)
from django.utils.encoding import force_text
from django.utils.six.moves.urllib.parse import (
unquote, urlparse, urlsplit, urlunsplit,
)
from django.utils.six.moves.urllib.request import url2pathname
from django.views.static import serve
__all__ = ('TestCase', 'TransactionTestCase',
'SimpleTestCase', 'skipIfDBFeature', 'skipUnlessDBFeature')
def to_list(value):
"""
Puts value into a list if it's not already one.
Returns an empty list if value is None.
"""
if value is None:
value = []
elif not isinstance(value, list):
value = [value]
return value
def assert_and_parse_html(self, html, user_msg, msg):
try:
dom = parse_html(html)
except HTMLParseError as e:
standardMsg = '%s\n%s' % (msg, e.msg)
self.fail(self._formatMessage(user_msg, standardMsg))
return dom
class _AssertNumQueriesContext(CaptureQueriesContext):
def __init__(self, test_case, num, connection):
self.test_case = test_case
self.num = num
super(_AssertNumQueriesContext, self).__init__(connection)
def __exit__(self, exc_type, exc_value, traceback):
super(_AssertNumQueriesContext, self).__exit__(exc_type, exc_value, traceback)
if exc_type is not None:
return
executed = len(self)
self.test_case.assertEqual(
executed, self.num,
"%d queries executed, %d expected\nCaptured queries were:\n%s" % (
executed, self.num,
'\n'.join(
query['sql'] for query in self.captured_queries
)
)
)
class _AssertTemplateUsedContext(object):
def __init__(self, test_case, template_name):
self.test_case = test_case
self.template_name = template_name
self.rendered_templates = []
self.rendered_template_names = []
self.context = ContextList()
def on_template_render(self, sender, signal, template, context, **kwargs):
self.rendered_templates.append(template)
self.rendered_template_names.append(template.name)
self.context.append(copy(context))
def test(self):
return self.template_name in self.rendered_template_names
def message(self):
return '%s was not rendered.' % self.template_name
def __enter__(self):
template_rendered.connect(self.on_template_render)
return self
def __exit__(self, exc_type, exc_value, traceback):
template_rendered.disconnect(self.on_template_render)
if exc_type is not None:
return
if not self.test():
message = self.message()
if len(self.rendered_templates) == 0:
message += ' No template was rendered.'
else:
message += ' Following templates were rendered: %s' % (
', '.join(self.rendered_template_names))
self.test_case.fail(message)
class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext):
def test(self):
return self.template_name not in self.rendered_template_names
def message(self):
return '%s was rendered.' % self.template_name
class _CursorFailure(object):
def __init__(self, cls_name, wrapped):
self.cls_name = cls_name
self.wrapped = wrapped
def __call__(self):
raise AssertionError(
"Database queries aren't allowed in SimpleTestCase. "
"Either use TestCase or TransactionTestCase to ensure proper test isolation or "
"set %s.allow_database_queries to True to silence this failure." % self.cls_name
)
class SimpleTestCase(unittest.TestCase):
# The class we'll use for the test client self.client.
# Can be overridden in derived classes.
client_class = Client
_overridden_settings = None
_modified_settings = None
# Tests shouldn't be allowed to query the database since
# this base class doesn't enforce any isolation.
allow_database_queries = False
@classmethod
def setUpClass(cls):
super(SimpleTestCase, cls).setUpClass()
if cls._overridden_settings:
cls._cls_overridden_context = override_settings(**cls._overridden_settings)
cls._cls_overridden_context.enable()
if cls._modified_settings:
cls._cls_modified_context = modify_settings(cls._modified_settings)
cls._cls_modified_context.enable()
if not cls.allow_database_queries:
for alias in connections:
connection = connections[alias]
connection.cursor = _CursorFailure(cls.__name__, connection.cursor)
@classmethod
def tearDownClass(cls):
if not cls.allow_database_queries:
for alias in connections:
connection = connections[alias]
connection.cursor = connection.cursor.wrapped
if hasattr(cls, '_cls_modified_context'):
cls._cls_modified_context.disable()
delattr(cls, '_cls_modified_context')
if hasattr(cls, '_cls_overridden_context'):
cls._cls_overridden_context.disable()
delattr(cls, '_cls_overridden_context')
super(SimpleTestCase, cls).tearDownClass()
def __call__(self, result=None):
"""
Wrapper around default __call__ method to perform common Django test
set up. This means that user-defined Test Cases aren't required to
include a call to super().setUp().
"""
testMethod = getattr(self, self._testMethodName)
skipped = (getattr(self.__class__, "__unittest_skip__", False) or
getattr(testMethod, "__unittest_skip__", False))
if not skipped:
try:
self._pre_setup()
except Exception:
result.addError(self, sys.exc_info())
return
super(SimpleTestCase, self).__call__(result)
if not skipped:
try:
self._post_teardown()
except Exception:
result.addError(self, sys.exc_info())
return
def _pre_setup(self):
"""Performs any pre-test setup. This includes:
* Creating a test client.
* If the class has a 'urls' attribute, replace ROOT_URLCONF with it.
* Clearing the mail test outbox.
"""
self.client = self.client_class()
self._urlconf_setup()
mail.outbox = []
def _urlconf_setup(self):
if hasattr(self, 'urls'):
warnings.warn(
"SimpleTestCase.urls is deprecated and will be removed in "
"Django 1.10. Use @override_settings(ROOT_URLCONF=...) "
"in %s instead." % self.__class__.__name__,
RemovedInDjango110Warning, stacklevel=2)
set_urlconf(None)
self._old_root_urlconf = settings.ROOT_URLCONF
settings.ROOT_URLCONF = self.urls
clear_url_caches()
def _post_teardown(self):
"""Performs any post-test things. This includes:
* Putting back the original ROOT_URLCONF if it was changed.
"""
self._urlconf_teardown()
def _urlconf_teardown(self):
if hasattr(self, '_old_root_urlconf'):
set_urlconf(None)
settings.ROOT_URLCONF = self._old_root_urlconf
clear_url_caches()
def settings(self, **kwargs):
"""
A context manager that temporarily sets a setting and reverts to the original value when exiting the context.
"""
return override_settings(**kwargs)
def modify_settings(self, **kwargs):
"""
A context manager that temporarily applies changes a list setting and
reverts back to the original value when exiting the context.
"""
return modify_settings(**kwargs)
def assertRedirects(self, response, expected_url, status_code=302,
target_status_code=200, host=None, msg_prefix='',
fetch_redirect_response=True):
"""Asserts that a response redirected to a specific URL, and that the
redirect URL can be loaded.
Note that assertRedirects won't work for external links since it uses
TestClient to do a request (use fetch_redirect_response=False to check
such links without fetching them).
"""
if host is not None:
warnings.warn(
"The host argument is deprecated and no longer used by assertRedirects",
RemovedInDjango20Warning, stacklevel=2
)
if msg_prefix:
msg_prefix += ": "
if hasattr(response, 'redirect_chain'):
# The request was a followed redirect
self.assertTrue(len(response.redirect_chain) > 0,
msg_prefix + "Response didn't redirect as expected: Response"
" code was %d (expected %d)" %
(response.status_code, status_code))
self.assertEqual(response.redirect_chain[0][1], status_code,
msg_prefix + "Initial response didn't redirect as expected:"
" Response code was %d (expected %d)" %
(response.redirect_chain[0][1], status_code))
url, status_code = response.redirect_chain[-1]
scheme, netloc, path, query, fragment = urlsplit(url)
self.assertEqual(response.status_code, target_status_code,
msg_prefix + "Response didn't redirect as expected: Final"
" Response code was %d (expected %d)" %
(response.status_code, target_status_code))
else:
# Not a followed redirect
self.assertEqual(response.status_code, status_code,
msg_prefix + "Response didn't redirect as expected: Response"
" code was %d (expected %d)" %
(response.status_code, status_code))
url = response.url
scheme, netloc, path, query, fragment = urlsplit(url)
if fetch_redirect_response:
redirect_response = response.client.get(path, QueryDict(query),
secure=(scheme == 'https'))
# Get the redirection page, using the same client that was used
# to obtain the original response.
self.assertEqual(redirect_response.status_code, target_status_code,
msg_prefix + "Couldn't retrieve redirection page '%s':"
" response code was %d (expected %d)" %
(path, redirect_response.status_code, target_status_code))
if url != expected_url:
# For temporary backwards compatibility, try to compare with a relative url
e_scheme, e_netloc, e_path, e_query, e_fragment = urlsplit(expected_url)
relative_url = urlunsplit(('', '', e_path, e_query, e_fragment))
if url == relative_url:
warnings.warn(
"assertRedirects had to strip the scheme and domain from the "
"expected URL, as it was always added automatically to URLs "
"before Django 1.9. Please update your expected URLs by "
"removing the scheme and domain.",
RemovedInDjango20Warning, stacklevel=2)
expected_url = relative_url
self.assertEqual(url, expected_url,
msg_prefix + "Response redirected to '%s', expected '%s'" %
(url, expected_url))
def _assert_contains(self, response, text, status_code, msg_prefix, html):
# If the response supports deferred rendering and hasn't been rendered
# yet, then ensure that it does get rendered before proceeding further.
if (hasattr(response, 'render') and callable(response.render)
and not response.is_rendered):
response.render()
if msg_prefix:
msg_prefix += ": "
self.assertEqual(response.status_code, status_code,
msg_prefix + "Couldn't retrieve content: Response code was %d"
" (expected %d)" % (response.status_code, status_code))
if response.streaming:
content = b''.join(response.streaming_content)
else:
content = response.content
if not isinstance(text, bytes) or html:
text = force_text(text, encoding=response.charset)
content = content.decode(response.charset)
text_repr = "'%s'" % text
else:
text_repr = repr(text)
if html:
content = assert_and_parse_html(self, content, None,
"Response's content is not valid HTML:")
text = assert_and_parse_html(self, text, None,
"Second argument is not valid HTML:")
real_count = content.count(text)
return (text_repr, real_count, msg_prefix)
def assertContains(self, response, text, count=None, status_code=200,
msg_prefix='', html=False):
"""
Asserts that a response indicates that some content was retrieved
successfully, (i.e., the HTTP status code was as expected), and that
``text`` occurs ``count`` times in the content of the response.
If ``count`` is None, the count doesn't matter - the assertion is true
if the text occurs at least once in the response.
"""
text_repr, real_count, msg_prefix = self._assert_contains(
response, text, status_code, msg_prefix, html)
if count is not None:
self.assertEqual(real_count, count,
msg_prefix + "Found %d instances of %s in response"
" (expected %d)" % (real_count, text_repr, count))
else:
self.assertTrue(real_count != 0,
msg_prefix + "Couldn't find %s in response" % text_repr)
def assertNotContains(self, response, text, status_code=200,
msg_prefix='', html=False):
"""
Asserts that a response indicates that some content was retrieved
successfully, (i.e., the HTTP status code was as expected), and that
``text`` doesn't occurs in the content of the response.
"""
text_repr, real_count, msg_prefix = self._assert_contains(
response, text, status_code, msg_prefix, html)
self.assertEqual(real_count, 0,
msg_prefix + "Response should not contain %s" % text_repr)
def assertFormError(self, response, form, field, errors, msg_prefix=''):
"""
Asserts that a form used to render the response has a specific field
error.
"""
if msg_prefix:
msg_prefix += ": "
# Put context(s) into a list to simplify processing.
contexts = to_list(response.context)
if not contexts:
self.fail(msg_prefix + "Response did not use any contexts to "
"render the response")
# Put error(s) into a list to simplify processing.
errors = to_list(errors)
# Search all contexts for the error.
found_form = False
for i, context in enumerate(contexts):
if form not in context:
continue
found_form = True
for err in errors:
if field:
if field in context[form].errors:
field_errors = context[form].errors[field]
self.assertTrue(err in field_errors,
msg_prefix + "The field '%s' on form '%s' in"
" context %d does not contain the error '%s'"
" (actual errors: %s)" %
(field, form, i, err, repr(field_errors)))
elif field in context[form].fields:
self.fail(msg_prefix + "The field '%s' on form '%s'"
" in context %d contains no errors" %
(field, form, i))
else:
self.fail(msg_prefix + "The form '%s' in context %d"
" does not contain the field '%s'" %
(form, i, field))
else:
non_field_errors = context[form].non_field_errors()
self.assertTrue(err in non_field_errors,
msg_prefix + "The form '%s' in context %d does not"
" contain the non-field error '%s'"
" (actual errors: %s)" %
(form, i, err, non_field_errors))
if not found_form:
self.fail(msg_prefix + "The form '%s' was not used to render the"
" response" % form)
def assertFormsetError(self, response, formset, form_index, field, errors,
msg_prefix=''):
"""
Asserts that a formset used to render the response has a specific error.
For field errors, specify the ``form_index`` and the ``field``.
For non-field errors, specify the ``form_index`` and the ``field`` as
None.
For non-form errors, specify ``form_index`` as None and the ``field``
as None.
"""
# Add punctuation to msg_prefix
if msg_prefix:
msg_prefix += ": "
# Put context(s) into a list to simplify processing.
contexts = to_list(response.context)
if not contexts:
self.fail(msg_prefix + 'Response did not use any contexts to '
'render the response')
# Put error(s) into a list to simplify processing.
errors = to_list(errors)
# Search all contexts for the error.
found_formset = False
for i, context in enumerate(contexts):
if formset not in context:
continue
found_formset = True
for err in errors:
if field is not None:
if field in context[formset].forms[form_index].errors:
field_errors = context[formset].forms[form_index].errors[field]
self.assertTrue(err in field_errors,
msg_prefix + "The field '%s' on formset '%s', "
"form %d in context %d does not contain the "
"error '%s' (actual errors: %s)" %
(field, formset, form_index, i, err,
repr(field_errors)))
elif field in context[formset].forms[form_index].fields:
self.fail(msg_prefix + "The field '%s' "
"on formset '%s', form %d in "
"context %d contains no errors" %
(field, formset, form_index, i))
else:
self.fail(msg_prefix + "The formset '%s', form %d in "
"context %d does not contain the field '%s'" %
(formset, form_index, i, field))
elif form_index is not None:
non_field_errors = context[formset].forms[form_index].non_field_errors()
self.assertFalse(len(non_field_errors) == 0,
msg_prefix + "The formset '%s', form %d in "
"context %d does not contain any non-field "
"errors." % (formset, form_index, i))
self.assertTrue(err in non_field_errors,
msg_prefix + "The formset '%s', form %d "
"in context %d does not contain the "
"non-field error '%s' "
"(actual errors: %s)" %
(formset, form_index, i, err,
repr(non_field_errors)))
else:
non_form_errors = context[formset].non_form_errors()
self.assertFalse(len(non_form_errors) == 0,
msg_prefix + "The formset '%s' in "
"context %d does not contain any "
"non-form errors." % (formset, i))
self.assertTrue(err in non_form_errors,
msg_prefix + "The formset '%s' in context "
"%d does not contain the "
"non-form error '%s' (actual errors: %s)" %
(formset, i, err, repr(non_form_errors)))
if not found_formset:
self.fail(msg_prefix + "The formset '%s' was not used to render "
"the response" % formset)
def _assert_template_used(self, response, template_name, msg_prefix):
if response is None and template_name is None:
raise TypeError('response and/or template_name argument must be provided')
if msg_prefix:
msg_prefix += ": "
if template_name is not None and response is not None and not hasattr(response, 'templates'):
raise ValueError(
"assertTemplateUsed() and assertTemplateNotUsed() are only "
"usable on responses fetched using the Django test Client."
)
if not hasattr(response, 'templates') or (response is None and template_name):
if response:
template_name = response
response = None
# use this template with context manager
return template_name, None, msg_prefix
template_names = [t.name for t in response.templates if t.name is not
None]
return None, template_names, msg_prefix
def assertTemplateUsed(self, response=None, template_name=None, msg_prefix='', count=None):
"""
Asserts that the template with the provided name was used in rendering
the response. Also usable as context manager.
"""
context_mgr_template, template_names, msg_prefix = self._assert_template_used(
response, template_name, msg_prefix)
if context_mgr_template:
# Use assertTemplateUsed as context manager.
return _AssertTemplateUsedContext(self, context_mgr_template)
if not template_names:
self.fail(msg_prefix + "No templates used to render the response")
self.assertTrue(template_name in template_names,
msg_prefix + "Template '%s' was not a template used to render"
" the response. Actual template(s) used: %s" %
(template_name, ', '.join(template_names)))
if count is not None:
self.assertEqual(template_names.count(template_name), count,
msg_prefix + "Template '%s' was expected to be rendered %d "
"time(s) but was actually rendered %d time(s)." %
(template_name, count, template_names.count(template_name)))
def assertTemplateNotUsed(self, response=None, template_name=None, msg_prefix=''):
"""
Asserts that the template with the provided name was NOT used in
rendering the response. Also usable as context manager.
"""
context_mgr_template, template_names, msg_prefix = self._assert_template_used(
response, template_name, msg_prefix)
if context_mgr_template:
# Use assertTemplateNotUsed as context manager.
return _AssertTemplateNotUsedContext(self, context_mgr_template)
self.assertFalse(template_name in template_names,
msg_prefix + "Template '%s' was used unexpectedly in rendering"
" the response" % template_name)
@contextmanager
def _assert_raises_message_cm(self, expected_exception, expected_message):
with self.assertRaises(expected_exception) as cm:
yield cm
self.assertIn(expected_message, str(cm.exception))
def assertRaisesMessage(self, expected_exception, expected_message, *args, **kwargs):
"""
Asserts that expected_message is found in the the message of a raised
exception.
Args:
expected_exception: Exception class expected to be raised.
expected_message: expected error message string value.
args: Function to be called and extra positional args.
kwargs: Extra kwargs.
"""
# callable_obj was a documented kwarg in Django 1.8 and older.
callable_obj = kwargs.pop('callable_obj', None)
if callable_obj:
warnings.warn(
'The callable_obj kwarg is deprecated. Pass the callable '
'as a positional argument instead.', RemovedInDjango20Warning
)
elif len(args):
callable_obj = args[0]
args = args[1:]
cm = self._assert_raises_message_cm(expected_exception, expected_message)
# Assertion used in context manager fashion.
if callable_obj is None:
return cm
# Assertion was passed a callable.
with cm:
callable_obj(*args, **kwargs)
def assertFieldOutput(self, fieldclass, valid, invalid, field_args=None,
field_kwargs=None, empty_value=''):
"""
Asserts that a form field behaves correctly with various inputs.
Args:
fieldclass: the class of the field to be tested.
valid: a dictionary mapping valid inputs to their expected
cleaned values.
invalid: a dictionary mapping invalid inputs to one or more
raised error messages.
field_args: the args passed to instantiate the field
field_kwargs: the kwargs passed to instantiate the field
empty_value: the expected clean output for inputs in empty_values
"""
if field_args is None:
field_args = []
if field_kwargs is None:
field_kwargs = {}
required = fieldclass(*field_args, **field_kwargs)
optional = fieldclass(*field_args,
**dict(field_kwargs, required=False))
# test valid inputs
for input, output in valid.items():
self.assertEqual(required.clean(input), output)
self.assertEqual(optional.clean(input), output)
# test invalid inputs
for input, errors in invalid.items():
with self.assertRaises(ValidationError) as context_manager:
required.clean(input)
self.assertEqual(context_manager.exception.messages, errors)
with self.assertRaises(ValidationError) as context_manager:
optional.clean(input)
self.assertEqual(context_manager.exception.messages, errors)
# test required inputs
error_required = [force_text(required.error_messages['required'])]
for e in required.empty_values:
with self.assertRaises(ValidationError) as context_manager:
required.clean(e)
self.assertEqual(context_manager.exception.messages,
error_required)
self.assertEqual(optional.clean(e), empty_value)
# test that max_length and min_length are always accepted
if issubclass(fieldclass, CharField):
field_kwargs.update({'min_length': 2, 'max_length': 20})
self.assertIsInstance(fieldclass(*field_args, **field_kwargs),
fieldclass)
def assertHTMLEqual(self, html1, html2, msg=None):
"""
Asserts that two HTML snippets are semantically the same.
Whitespace in most cases is ignored, and attribute ordering is not
significant. The passed-in arguments must be valid HTML.
"""
dom1 = assert_and_parse_html(self, html1, msg,
'First argument is not valid HTML:')
dom2 = assert_and_parse_html(self, html2, msg,
'Second argument is not valid HTML:')
if dom1 != dom2:
standardMsg = '%s != %s' % (
safe_repr(dom1, True), safe_repr(dom2, True))
diff = ('\n' + '\n'.join(difflib.ndiff(
six.text_type(dom1).splitlines(),
six.text_type(dom2).splitlines())))
standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
def assertHTMLNotEqual(self, html1, html2, msg=None):
"""Asserts that two HTML snippets are not semantically equivalent."""
dom1 = assert_and_parse_html(self, html1, msg,
'First argument is not valid HTML:')
dom2 = assert_and_parse_html(self, html2, msg,
'Second argument is not valid HTML:')
if dom1 == dom2:
standardMsg = '%s == %s' % (
safe_repr(dom1, True), safe_repr(dom2, True))
self.fail(self._formatMessage(msg, standardMsg))
def assertInHTML(self, needle, haystack, count=None, msg_prefix=''):
needle = assert_and_parse_html(self, needle, None,
'First argument is not valid HTML:')
haystack = assert_and_parse_html(self, haystack, None,
'Second argument is not valid HTML:')
real_count = haystack.count(needle)
if count is not None:
self.assertEqual(real_count, count,
msg_prefix + "Found %d instances of '%s' in response"
" (expected %d)" % (real_count, needle, count))
else:
self.assertTrue(real_count != 0,
msg_prefix + "Couldn't find '%s' in response" % needle)
def assertJSONEqual(self, raw, expected_data, msg=None):
"""
Asserts that the JSON fragments raw and expected_data are equal.
Usual JSON non-significant whitespace rules apply as the heavyweight
is delegated to the json library.
"""
try:
data = json.loads(raw)
except ValueError:
self.fail("First argument is not valid JSON: %r" % raw)
if isinstance(expected_data, six.string_types):
try:
expected_data = json.loads(expected_data)
except ValueError:
self.fail("Second argument is not valid JSON: %r" % expected_data)
self.assertEqual(data, expected_data, msg=msg)
def assertJSONNotEqual(self, raw, expected_data, msg=None):
"""
Asserts that the JSON fragments raw and expected_data are not equal.
Usual JSON non-significant whitespace rules apply as the heavyweight
is delegated to the json library.
"""
try:
data = json.loads(raw)
except ValueError:
self.fail("First argument is not valid JSON: %r" % raw)
if isinstance(expected_data, six.string_types):
try:
expected_data = json.loads(expected_data)
except ValueError:
self.fail("Second argument is not valid JSON: %r" % expected_data)
self.assertNotEqual(data, expected_data, msg=msg)
def assertXMLEqual(self, xml1, xml2, msg=None):
"""
Asserts that two XML snippets are semantically the same.
Whitespace in most cases is ignored, and attribute ordering is not
significant. The passed-in arguments must be valid XML.
"""
try:
result = compare_xml(xml1, xml2)
except Exception as e:
standardMsg = 'First or second argument is not valid XML\n%s' % e
self.fail(self._formatMessage(msg, standardMsg))
else:
if not result:
standardMsg = '%s != %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
diff = ('\n' + '\n'.join(
difflib.ndiff(
six.text_type(xml1).splitlines(),
six.text_type(xml2).splitlines(),
)
))
standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
def assertXMLNotEqual(self, xml1, xml2, msg=None):
"""
Asserts that two XML snippets are not semantically equivalent.
Whitespace in most cases is ignored, and attribute ordering is not
significant. The passed-in arguments must be valid XML.
"""
try:
result = compare_xml(xml1, xml2)
except Exception as e:
standardMsg = 'First or second argument is not valid XML\n%s' % e
self.fail(self._formatMessage(msg, standardMsg))
else:
if result:
standardMsg = '%s == %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
self.fail(self._formatMessage(msg, standardMsg))
class TransactionTestCase(SimpleTestCase):
# Subclasses can ask for resetting of auto increment sequence before each
# test case
reset_sequences = False
# Subclasses can enable only a subset of apps for faster tests
available_apps = None
# Subclasses can define fixtures which will be automatically installed.
fixtures = None
# If transactions aren't available, Django will serialize the database
# contents into a fixture during setup and flush and reload them
# during teardown (as flush does not restore data from migrations).
# This can be slow; this flag allows enabling on a per-case basis.
serialized_rollback = False
# Since tests will be wrapped in a transaction, or serialized if they
# are not available, we allow queries to be run.
allow_database_queries = True
def _pre_setup(self):
"""Performs any pre-test setup. This includes:
* If the class has an 'available_apps' attribute, restricting the app
registry to these applications, then firing post_migrate -- it must
run with the correct set of applications for the test case.
* If the class has a 'fixtures' attribute, installing these fixtures.
"""
super(TransactionTestCase, self)._pre_setup()
if self.available_apps is not None:
apps.set_available_apps(self.available_apps)
setting_changed.send(sender=settings._wrapped.__class__,
setting='INSTALLED_APPS',
value=self.available_apps,
enter=True)
for db_name in self._databases_names(include_mirrors=False):
emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name)
try:
self._fixture_setup()
except Exception:
if self.available_apps is not None:
apps.unset_available_apps()
setting_changed.send(sender=settings._wrapped.__class__,
setting='INSTALLED_APPS',
value=settings.INSTALLED_APPS,
enter=False)
raise
@classmethod
def _databases_names(cls, include_mirrors=True):
# If the test case has a multi_db=True flag, act on all databases,
# including mirrors or not. Otherwise, just on the default DB.
if getattr(cls, 'multi_db', False):
return [alias for alias in connections
if include_mirrors or not connections[alias].settings_dict['TEST']['MIRROR']]
else:
return [DEFAULT_DB_ALIAS]
def _reset_sequences(self, db_name):
conn = connections[db_name]
if conn.features.supports_sequence_reset:
sql_list = conn.ops.sequence_reset_by_name_sql(
no_style(), conn.introspection.sequence_list())
if sql_list:
with transaction.atomic(using=db_name):
cursor = conn.cursor()
for sql in sql_list:
cursor.execute(sql)
def _fixture_setup(self):
for db_name in self._databases_names(include_mirrors=False):
# Reset sequences
if self.reset_sequences:
self._reset_sequences(db_name)
# If we need to provide replica initial data from migrated apps,
# then do so.
if self.serialized_rollback and hasattr(connections[db_name], "_test_serialized_contents"):
if self.available_apps is not None:
apps.unset_available_apps()
connections[db_name].creation.deserialize_db_from_string(
connections[db_name]._test_serialized_contents
)
if self.available_apps is not None:
apps.set_available_apps(self.available_apps)
if self.fixtures:
# We have to use this slightly awkward syntax due to the fact
# that we're using *args and **kwargs together.
call_command('loaddata', *self.fixtures,
**{'verbosity': 0, 'database': db_name})
def _should_reload_connections(self):
return True
def _post_teardown(self):
"""Performs any post-test things. This includes:
* Flushing the contents of the database, to leave a clean slate. If
the class has an 'available_apps' attribute, post_migrate isn't fired.
* Force-closing the connection, so the next test gets a clean cursor.
"""
try:
self._fixture_teardown()
super(TransactionTestCase, self)._post_teardown()
if self._should_reload_connections():
# Some DB cursors include SQL statements as part of cursor
# creation. If you have a test that does a rollback, the effect
# of these statements is lost, which can affect the operation of
# tests (e.g., losing a timezone setting causing objects to be
# created with the wrong time). To make sure this doesn't
# happen, get a clean connection at the start of every test.
for conn in connections.all():
conn.close()
finally:
if self.available_apps is not None:
apps.unset_available_apps()
setting_changed.send(sender=settings._wrapped.__class__,
setting='INSTALLED_APPS',
value=settings.INSTALLED_APPS,
enter=False)
def _fixture_teardown(self):
# Allow TRUNCATE ... CASCADE and don't emit the post_migrate signal
# when flushing only a subset of the apps
for db_name in self._databases_names(include_mirrors=False):
# Flush the database
inhibit_post_migrate = (
self.available_apps is not None
or (
# Inhibit the post_migrate signal when using serialized
# rollback to avoid trying to recreate the serialized data.
self.serialized_rollback and
hasattr(connections[db_name], '_test_serialized_contents')
)
)
call_command('flush', verbosity=0, interactive=False,
database=db_name, reset_sequences=False,
allow_cascade=self.available_apps is not None,
inhibit_post_migrate=inhibit_post_migrate)
def assertQuerysetEqual(self, qs, values, transform=repr, ordered=True, msg=None):
items = six.moves.map(transform, qs)
if not ordered:
return self.assertEqual(Counter(items), Counter(values), msg=msg)
values = list(values)
# For example qs.iterator() could be passed as qs, but it does not
# have 'ordered' attribute.
if len(values) > 1 and hasattr(qs, 'ordered') and not qs.ordered:
raise ValueError("Trying to compare non-ordered queryset "
"against more than one ordered values")
return self.assertEqual(list(items), values, msg=msg)
def assertNumQueries(self, num, func=None, *args, **kwargs):
using = kwargs.pop("using", DEFAULT_DB_ALIAS)
conn = connections[using]
context = _AssertNumQueriesContext(self, num, conn)
if func is None:
return context
with context:
func(*args, **kwargs)
def connections_support_transactions():
"""
Returns True if all connections support transactions.
"""
return all(conn.features.supports_transactions
for conn in connections.all())
class TestCase(TransactionTestCase):
"""
Similar to TransactionTestCase, but uses `transaction.atomic()` to achieve
test isolation.
In most situation, TestCase should be prefered to TransactionTestCase as
it allows faster execution. However, there are some situations where using
TransactionTestCase might be necessary (e.g. testing some transactional
behavior).
On database backends with no transaction support, TestCase behaves as
TransactionTestCase.
"""
@classmethod
def _enter_atomics(cls):
"""Helper method to open atomic blocks for multiple databases"""
atomics = {}
for db_name in cls._databases_names():
atomics[db_name] = transaction.atomic(using=db_name)
atomics[db_name].__enter__()
return atomics
@classmethod
def _rollback_atomics(cls, atomics):
"""Rollback atomic blocks opened through the previous method"""
for db_name in reversed(cls._databases_names()):
transaction.set_rollback(True, using=db_name)
atomics[db_name].__exit__(None, None, None)
@classmethod
def setUpClass(cls):
super(TestCase, cls).setUpClass()
if not connections_support_transactions():
return
cls.cls_atomics = cls._enter_atomics()
if cls.fixtures:
for db_name in cls._databases_names(include_mirrors=False):
try:
call_command('loaddata', *cls.fixtures, **{
'verbosity': 0,
'commit': False,
'database': db_name,
})
except Exception:
cls._rollback_atomics(cls.cls_atomics)
raise
try:
cls.setUpTestData()
except Exception:
cls._rollback_atomics(cls.cls_atomics)
raise
@classmethod
def tearDownClass(cls):
if connections_support_transactions():
cls._rollback_atomics(cls.cls_atomics)
for conn in connections.all():
conn.close()
super(TestCase, cls).tearDownClass()
@classmethod
def setUpTestData(cls):
"""Load initial data for the TestCase"""
pass
def _should_reload_connections(self):
if connections_support_transactions():
return False
return super(TestCase, self)._should_reload_connections()
def _fixture_setup(self):
if not connections_support_transactions():
# If the backend does not support transactions, we should reload
# class data before each test
self.setUpTestData()
return super(TestCase, self)._fixture_setup()
assert not self.reset_sequences, 'reset_sequences cannot be used on TestCase instances'
self.atomics = self._enter_atomics()
def _fixture_teardown(self):
if not connections_support_transactions():
return super(TestCase, self)._fixture_teardown()
self._rollback_atomics(self.atomics)
class CheckCondition(object):
"""Descriptor class for deferred condition checking"""
def __init__(self, cond_func):
self.cond_func = cond_func
def __get__(self, obj, objtype):
return self.cond_func()
def _deferredSkip(condition, reason):
def decorator(test_func):
if not (isinstance(test_func, type) and
issubclass(test_func, unittest.TestCase)):
@wraps(test_func)
def skip_wrapper(*args, **kwargs):
if condition():
raise unittest.SkipTest(reason)
return test_func(*args, **kwargs)
test_item = skip_wrapper
else:
# Assume a class is decorated
test_item = test_func
test_item.__unittest_skip__ = CheckCondition(condition)
test_item.__unittest_skip_why__ = reason
return test_item
return decorator
def skipIfDBFeature(*features):
"""
Skip a test if a database has at least one of the named features.
"""
return _deferredSkip(
lambda: any(getattr(connection.features, feature, False) for feature in features),
"Database has feature(s) %s" % ", ".join(features)
)
def skipUnlessDBFeature(*features):
"""
Skip a test unless a database has all the named features.
"""
return _deferredSkip(
lambda: not all(getattr(connection.features, feature, False) for feature in features),
"Database doesn't support feature(s): %s" % ", ".join(features)
)
def skipUnlessAnyDBFeature(*features):
"""
Skip a test unless a database has any of the named features.
"""
return _deferredSkip(
lambda: not any(getattr(connection.features, feature, False) for feature in features),
"Database doesn't support any of the feature(s): %s" % ", ".join(features)
)
class QuietWSGIRequestHandler(WSGIRequestHandler):
"""
Just a regular WSGIRequestHandler except it doesn't log to the standard
output any of the requests received, so as to not clutter the output for
the tests' results.
"""
def log_message(*args):
pass
class FSFilesHandler(WSGIHandler):
"""
WSGI middleware that intercepts calls to a directory, as defined by one of
the *_ROOT settings, and serves those files, publishing them under *_URL.
"""
def __init__(self, application):
self.application = application
self.base_url = urlparse(self.get_base_url())
super(FSFilesHandler, self).__init__()
def _should_handle(self, path):
"""
Checks if the path should be handled. Ignores the path if:
* the host is provided as part of the base_url
* the request's path isn't under the media path (or equal)
"""
return path.startswith(self.base_url[2]) and not self.base_url[1]
def file_path(self, url):
"""
Returns the relative path to the file on disk for the given URL.
"""
relative_url = url[len(self.base_url[2]):]
return url2pathname(relative_url)
def get_response(self, request):
from django.http import Http404
if self._should_handle(request.path):
try:
return self.serve(request)
except Http404:
pass
return super(FSFilesHandler, self).get_response(request)
def serve(self, request):
os_rel_path = self.file_path(request.path)
os_rel_path = posixpath.normpath(unquote(os_rel_path))
# Emulate behavior of django.contrib.staticfiles.views.serve() when it
# invokes staticfiles' finders functionality.
# TODO: Modify if/when that internal API is refactored
final_rel_path = os_rel_path.replace('\\', '/').lstrip('/')
return serve(request, final_rel_path, document_root=self.get_base_dir())
def __call__(self, environ, start_response):
if not self._should_handle(get_path_info(environ)):
return self.application(environ, start_response)
return super(FSFilesHandler, self).__call__(environ, start_response)
class _StaticFilesHandler(FSFilesHandler):
"""
Handler for serving static files. A private class that is meant to be used
solely as a convenience by LiveServerThread.
"""
def get_base_dir(self):
return settings.STATIC_ROOT
def get_base_url(self):
return settings.STATIC_URL
class _MediaFilesHandler(FSFilesHandler):
"""
Handler for serving the media files. A private class that is meant to be
used solely as a convenience by LiveServerThread.
"""
def get_base_dir(self):
return settings.MEDIA_ROOT
def get_base_url(self):
return settings.MEDIA_URL
class LiveServerThread(threading.Thread):
"""
Thread for running a live http server while the tests are running.
"""
def __init__(self, host, possible_ports, static_handler, connections_override=None):
self.host = host
self.port = None
self.possible_ports = possible_ports
self.is_ready = threading.Event()
self.error = None
self.static_handler = static_handler
self.connections_override = connections_override
super(LiveServerThread, self).__init__()
def run(self):
"""
Sets up the live server and databases, and then loops over handling
http requests.
"""
if self.connections_override:
# Override this thread's database connections with the ones
# provided by the main thread.
for alias, conn in self.connections_override.items():
connections[alias] = conn
try:
# Create the handler for serving static and media files
handler = self.static_handler(_MediaFilesHandler(WSGIHandler()))
# Go through the list of possible ports, hoping that we can find
# one that is free to use for the WSGI server.
for index, port in enumerate(self.possible_ports):
try:
self.httpd = self._create_server(port)
except socket.error as e:
if (index + 1 < len(self.possible_ports) and
e.errno == errno.EADDRINUSE):
# This port is already in use, so we go on and try with
# the next one in the list.
continue
else:
# Either none of the given ports are free or the error
# is something else than "Address already in use". So
# we let that error bubble up to the main thread.
raise
else:
# A free port was found.
self.port = port
break
self.httpd.set_app(handler)
self.is_ready.set()
self.httpd.serve_forever()
except Exception as e:
self.error = e
self.is_ready.set()
def _create_server(self, port):
return WSGIServer((self.host, port), QuietWSGIRequestHandler)
def terminate(self):
if hasattr(self, 'httpd'):
# Stop the WSGI server
self.httpd.shutdown()
self.httpd.server_close()
class LiveServerTestCase(TransactionTestCase):
"""
Does basically the same as TransactionTestCase but also launches a live
http server in a separate thread so that the tests may use another testing
framework, such as Selenium for example, instead of the built-in dummy
client.
Note that it inherits from TransactionTestCase instead of TestCase because
the threads do not share the same transactions (unless if using in-memory
sqlite) and each thread needs to commit all their transactions so that the
other thread can see the changes.
"""
static_handler = _StaticFilesHandler
@classproperty
def live_server_url(cls):
return 'http://%s:%s' % (
cls.server_thread.host, cls.server_thread.port)
@classmethod
def setUpClass(cls):
super(LiveServerTestCase, cls).setUpClass()
connections_override = {}
for conn in connections.all():
# If using in-memory sqlite databases, pass the connections to
# the server thread.
if conn.vendor == 'sqlite' and conn.is_in_memory_db(conn.settings_dict['NAME']):
# Explicitly enable thread-shareability for this connection
conn.allow_thread_sharing = True
connections_override[conn.alias] = conn
# Launch the live server's thread
specified_address = os.environ.get(
'DJANGO_LIVE_TEST_SERVER_ADDRESS', 'localhost:8081')
# The specified ports may be of the form '8000-8010,8080,9200-9300'
# i.e. a comma-separated list of ports or ranges of ports, so we break
# it down into a detailed list of all possible ports.
possible_ports = []
try:
host, port_ranges = specified_address.split(':')
for port_range in port_ranges.split(','):
# A port range can be of either form: '8000' or '8000-8010'.
extremes = list(map(int, port_range.split('-')))
assert len(extremes) in [1, 2]
if len(extremes) == 1:
# Port range of the form '8000'
possible_ports.append(extremes[0])
else:
# Port range of the form '8000-8010'
for port in range(extremes[0], extremes[1] + 1):
possible_ports.append(port)
except Exception:
msg = 'Invalid address ("%s") for live server.' % specified_address
six.reraise(ImproperlyConfigured, ImproperlyConfigured(msg), sys.exc_info()[2])
cls.server_thread = cls._create_server_thread(host, possible_ports, connections_override)
cls.server_thread.daemon = True
cls.server_thread.start()
# Wait for the live server to be ready
cls.server_thread.is_ready.wait()
if cls.server_thread.error:
# Clean up behind ourselves, since tearDownClass won't get called in
# case of errors.
cls._tearDownClassInternal()
raise cls.server_thread.error
@classmethod
def _create_server_thread(cls, host, possible_ports, connections_override):
return LiveServerThread(
host,
possible_ports,
cls.static_handler,
connections_override=connections_override,
)
@classmethod
def _tearDownClassInternal(cls):
# There may not be a 'server_thread' attribute if setUpClass() for some
# reasons has raised an exception.
if hasattr(cls, 'server_thread'):
# Terminate the live server's thread
cls.server_thread.terminate()
cls.server_thread.join()
# Restore sqlite in-memory database connections' non-shareability
for conn in connections.all():
if conn.vendor == 'sqlite' and conn.is_in_memory_db(conn.settings_dict['NAME']):
conn.allow_thread_sharing = False
@classmethod
def tearDownClass(cls):
cls._tearDownClassInternal()
super(LiveServerTestCase, cls).tearDownClass()
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
27070,
199,
646,
7554,
199,
646,
2022,
199,
646,
747,
199,
646,
15454,
199,
646,
2838,
199,
646,
984,
199,
646,
5796,
199,
646,
2882,
199,
646,
3598,
199,
504,
5055,
492,
14427,
199,
504,
15502,
492,
27608,
199,
504,
1331,
492,
1331,
199,
504,
9143,
492,
14018,
199,
504,
2882,
14,
1974,
492,
5048,
63,
2722,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
492,
6016,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
12,
8505,
199,
504,
1639,
14,
1018,
14,
5586,
14,
6508,
492,
9279,
2461,
12,
664,
63,
515,
63,
815,
199,
504,
1639,
14,
1018,
14,
8110,
492,
1240,
63,
1531,
199,
504,
1639,
14,
1018,
14,
8110,
14,
2326,
492,
949,
63,
2487,
199,
504,
1639,
14,
1018,
14,
8110,
14,
3009,
492,
8689,
63,
1932,
63,
8462,
63,
4653,
199,
504,
1639,
14,
1018,
14,
5871,
14,
1095,
1014,
492,
9279,
11149,
12,
644,
28732,
199,
504,
1639,
14,
1018,
14,
16522,
492,
5436,
63,
633,
63,
17595,
12,
663,
63,
21801,
199,
504,
1639,
14,
697,
492,
6186,
63,
2846,
63,
12644,
12,
1950,
12,
6947,
12,
6008,
199,
504,
1639,
14,
3351,
14,
955,
492,
12064,
199,
504,
1639,
14,
1014,
492,
8133,
2141,
199,
504,
1639,
14,
396,
14,
1258,
492,
6810,
199,
504,
1639,
14,
396,
14,
1360,
492,
4163,
9123,
12,
2198,
63,
1360,
199,
504,
1639,
14,
396,
14,
10458,
492,
4260,
63,
2489,
12,
1978,
63,
16841,
199,
504,
1639,
14,
396,
14,
1208,
492,
334,
272,
29828,
13611,
2998,
12,
9470,
1296,
12,
6540,
63,
1652,
12,
2811,
63,
1751,
12,
272,
4278,
63,
1751,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
11582,
492,
1021,
1829,
199,
504,
1639,
14,
1208,
14,
15383,
492,
334,
272,
23687,
1165,
3849,
12,
23687,
6019,
3849,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1122,
492,
334,
272,
14342,
12,
7097,
12,
29596,
12,
1166,
30038,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1069,
492,
1166,
18,
12445,
199,
504,
1639,
14,
4196,
14,
1986,
492,
14062,
199,
199,
363,
452,
363,
275,
661,
1746,
297,
283,
10161,
1746,
297,
1779,
283,
17968,
297,
283,
15118,
18093,
297,
283,
22424,
358,
421,
199,
318,
370,
63,
513,
8,
585,
304,
272,
408,
272,
510,
14608,
574,
1901,
282,
769,
340,
652,
1159,
440,
2575,
1373,
14,
272,
1803,
376,
2701,
769,
340,
574,
365,
488,
14,
272,
408,
272,
340,
574,
365,
488,
26,
267,
574,
275,
942,
272,
916,
440,
1228,
8,
585,
12,
769,
304,
267,
574,
275,
359,
585,
61,
272,
372,
574,
421,
199,
318,
702,
63,
460,
63,
1122,
63,
1360,
8,
277,
12,
3517,
12,
922,
63,
1328,
12,
1499,
304,
272,
862,
26,
267,
8266,
275,
2198,
63,
1360,
8,
1360,
9,
272,
871,
4163,
9123,
465,
325,
26,
267,
20563,
275,
1543,
83,
60,
78,
5,
83,
7,
450,
334,
1328,
12,
325,
14,
1328,
9,
267,
291,
14,
1633,
8,
277,
423,
29097,
8,
751,
63,
1328,
12,
20563,
430,
272,
372,
8266,
421,
199,
533,
485,
9699,
5667,
13611,
2998,
8,
16640,
13611,
2998,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
2546,
12,
1967,
12,
1950,
304,
267,
291,
14,
396,
63,
2546,
275,
511,
63,
2546,
267,
291,
14,
1507,
275,
1967,
267,
1613,
1547,
9699,
5667,
13611,
2998,
12,
291,
2843,
826,
721,
2105,
9,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
5190,
304,
267,
1613,
1547,
9699,
5667,
13611,
2998,
12,
291,
2843,
2224,
721,
2804,
63,
466,
12,
3178,
63,
585,
12,
5190,
9,
267,
340,
3178,
63,
466,
365,
440,
488,
26,
288,
372,
267,
7934,
275,
822,
8,
277,
9,
267,
291,
14,
396,
63,
2546,
14,
629,
8,
288,
7934,
12,
291,
14,
1507,
12,
288,
2071,
68,
9212,
7934,
12,
450,
68,
1420,
60,
78,
13519,
3297,
9212,
4898,
3427,
78,
5,
83,
2,
450,
334,
355,
7934,
12,
291,
14,
1507,
12,
355,
1557,
78,
1370,
904,
8,
490,
1827,
459,
3009,
418,
367,
1827,
315,
291,
14,
28345,
63,
10590,
355,
776,
288,
776,
267,
776,
421,
199,
533,
485,
9699,
4231,
9167,
2998,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
2546,
12,
1978,
63,
354,
304,
267,
291,
14,
396,
63,
2546,
275,
511,
63,
2546,
267,
291,
14,
1160,
63,
354,
275,
1978,
63,
354,
267,
291,
14,
16841,
63,
5876,
275,
942,
267,
291,
14,
16841,
63,
1160,
63,
1247,
275,
942,
267,
291,
14,
1100,
275,
9470,
1296,
342,
339,
347,
641,
63,
1160,
63,
3352,
8,
277,
12,
8904,
12,
4673,
12,
1978,
12,
1067,
12,
1011,
958,
304,
267,
291,
14,
16841,
63,
5876,
14,
740,
8,
1160,
9,
267,
291,
14,
16841,
63,
1160,
63,
1247,
14,
740,
8,
1160,
14,
354,
9,
267,
291,
14,
1100,
14,
740,
8,
1574,
8,
1100,
430,
339,
347,
511,
8,
277,
304,
267,
372,
291,
14,
1160,
63,
354,
315,
291,
14,
16841,
63,
1160,
63,
1247,
339,
347,
1245,
8,
277,
304,
267,
372,
1543,
83,
1990,
440,
8018,
3530,
450,
291,
14,
1160,
63,
354,
339,
347,
636,
4200,
721,
277,
304,
267,
1978,
63,
16841,
14,
2242,
8,
277,
14,
265,
63,
1160,
63,
3352,
9,
267,
372,
291,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
5190,
304,
267,
1978,
63,
16841,
14,
10673,
8,
277,
14,
265,
63,
1160,
63,
3352,
9,
267,
340,
3178,
63,
466,
365,
440,
488,
26,
288,
372,
398,
340,
440,
291,
14,
396,
837,
288,
1245,
275,
291,
14,
1188,
342,
288,
340,
822,
8,
277,
14,
16841,
63,
5876,
9,
508,
378,
26,
355,
1245,
847,
283,
3091,
1978,
1990,
8018,
3530,
288
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
27070,
199,
646,
7554,
199,
646,
2022,
199,
646,
747,
199,
646,
15454,
199,
646,
2838,
199,
646,
984,
199,
646,
5796,
199,
646,
2882,
199,
646,
3598,
199,
504,
5055,
492,
14427,
199,
504,
15502,
492,
27608,
199,
504,
1331,
492,
1331,
199,
504,
9143,
492,
14018,
199,
504,
2882,
14,
1974,
492,
5048,
63,
2722,
199,
199,
504,
1639,
14,
5181,
492,
8686,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
492,
6016,
199,
504,
1639,
14,
1018,
14,
3924,
492,
11897,
12,
8505,
199,
504,
1639,
14,
1018,
14,
5586,
14,
6508,
492,
9279,
2461,
12,
664,
63,
515,
63,
815,
199,
504,
1639,
14,
1018,
14,
8110,
492,
1240,
63,
1531,
199,
504,
1639,
14,
1018,
14,
8110,
14,
2326,
492,
949,
63,
2487,
199,
504,
1639,
14,
1018,
14,
8110,
14,
3009,
492,
8689,
63,
1932,
63,
8462,
63,
4653,
199,
504,
1639,
14,
1018,
14,
5871,
14,
1095,
1014,
492,
9279,
11149,
12,
644,
28732,
199,
504,
1639,
14,
1018,
14,
16522,
492,
5436,
63,
633,
63,
17595,
12,
663,
63,
21801,
199,
504,
1639,
14,
697,
492,
6186,
63,
2846,
63,
12644,
12,
1950,
12,
6947,
12,
6008,
199,
504,
1639,
14,
3351,
14,
955,
492,
12064,
199,
504,
1639,
14,
1014,
492,
8133,
2141,
199,
504,
1639,
14,
396,
14,
1258,
492,
6810,
199,
504,
1639,
14,
396,
14,
1360,
492,
4163,
9123,
12,
2198,
63,
1360,
199,
504,
1639,
14,
396,
14,
10458,
492,
4260,
63,
2489,
12,
1978,
63,
16841,
199,
504,
1639,
14,
396,
14,
1208,
492,
334,
272,
29828,
13611,
2998,
12,
9470,
1296,
12,
6540,
63,
1652,
12,
2811,
63,
1751,
12,
272,
4278,
63,
1751,
12,
199,
9,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
11582,
492,
1021,
1829,
199,
504,
1639,
14,
1208,
14,
15383,
492,
334,
272,
23687,
1165,
3849,
12,
23687,
6019,
3849,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1122,
492,
334,
272,
14342,
12,
7097,
12,
29596,
12,
1166,
30038,
12,
199,
9,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
14,
4078,
14,
1069,
492,
1166,
18,
12445,
199,
504,
1639,
14,
4196,
14,
1986,
492,
14062,
199,
199,
363,
452,
363,
275,
661,
1746,
297,
283,
10161,
1746,
297,
1779,
283,
17968,
297,
283,
15118,
18093,
297,
283,
22424,
358,
421,
199,
318,
370,
63,
513,
8,
585,
304,
272,
408,
272,
510,
14608,
574,
1901,
282,
769,
340,
652,
1159,
440,
2575,
1373,
14,
272,
1803,
376,
2701,
769,
340,
574,
365,
488,
14,
272,
408,
272,
340,
574,
365,
488,
26,
267,
574,
275,
942,
272,
916,
440,
1228,
8,
585,
12,
769,
304,
267,
574,
275,
359,
585,
61,
272,
372,
574,
421,
199,
318,
702,
63,
460,
63,
1122,
63,
1360,
8,
277,
12,
3517,
12,
922,
63,
1328,
12,
1499,
304,
272,
862,
26,
267,
8266,
275,
2198,
63,
1360,
8,
1360,
9,
272,
871,
4163,
9123,
465,
325,
26,
267,
20563,
275,
1543,
83,
60,
78,
5,
83,
7,
450,
334,
1328,
12,
325,
14,
1328,
9,
267,
291,
14,
1633,
8,
277,
423,
29097,
8,
751,
63,
1328,
12,
20563,
430,
272,
372,
8266,
421,
199,
533,
485,
9699,
5667,
13611,
2998,
8,
16640,
13611,
2998,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
2546,
12,
1967,
12,
1950,
304,
267,
291,
14,
396,
63,
2546,
275,
511,
63,
2546,
267,
291,
14,
1507,
275,
1967,
267,
1613,
1547,
9699,
5667,
13611,
2998,
12,
291,
2843,
826,
721,
2105,
9,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
5190,
304,
267,
1613,
1547,
9699,
5667,
13611,
2998,
12,
291,
2843,
2224,
721,
2804,
63,
466,
12,
3178,
63,
585,
12,
5190,
9,
267,
340,
3178,
63,
466,
365,
440,
488,
26,
288,
372,
267,
7934,
275,
822,
8,
277,
9,
267,
291,
14,
396,
63,
2546,
14,
629,
8,
288,
7934,
12,
291,
14,
1507,
12,
288,
2071,
68,
9212,
7934,
12,
450,
68,
1420,
60,
78,
13519,
3297,
9212,
4898,
3427,
78,
5,
83,
2,
450,
334,
355,
7934,
12,
291,
14,
1507,
12,
355,
1557,
78,
1370,
904,
8,
490,
1827,
459,
3009,
418,
367,
1827,
315,
291,
14,
28345,
63,
10590,
355,
776,
288,
776,
267,
776,
421,
199,
533,
485,
9699,
4231,
9167,
2998,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
511,
63,
2546,
12,
1978,
63,
354,
304,
267,
291,
14,
396,
63,
2546,
275,
511,
63,
2546,
267,
291,
14,
1160,
63,
354,
275,
1978,
63,
354,
267,
291,
14,
16841,
63,
5876,
275,
942,
267,
291,
14,
16841,
63,
1160,
63,
1247,
275,
942,
267,
291,
14,
1100,
275,
9470,
1296,
342,
339,
347,
641,
63,
1160,
63,
3352,
8,
277,
12,
8904,
12,
4673,
12,
1978,
12,
1067,
12,
1011,
958,
304,
267,
291,
14,
16841,
63,
5876,
14,
740,
8,
1160,
9,
267,
291,
14,
16841,
63,
1160,
63,
1247,
14,
740,
8,
1160,
14,
354,
9,
267,
291,
14,
1100,
14,
740,
8,
1574,
8,
1100,
430,
339,
347,
511,
8,
277,
304,
267,
372,
291,
14,
1160,
63,
354,
315,
291,
14,
16841,
63,
1160,
63,
1247,
339,
347,
1245,
8,
277,
304,
267,
372,
1543,
83,
1990,
440,
8018,
3530,
450,
291,
14,
1160,
63,
354,
339,
347,
636,
4200,
721,
277,
304,
267,
1978,
63,
16841,
14,
2242,
8,
277,
14,
265,
63,
1160,
63,
3352,
9,
267,
372,
291,
339,
347,
636,
2224,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
5190,
304,
267,
1978,
63,
16841,
14,
10673,
8,
277,
14,
265,
63,
1160,
63,
3352,
9,
267,
340,
3178,
63,
466,
365,
440,
488,
26,
288,
372,
398,
340,
440,
291,
14,
396,
837,
288,
1245,
275,
291,
14,
1188,
342,
288,
340,
822,
8,
277,
14,
16841,
63,
5876,
9,
508,
378,
26,
355,
1245,
847,
283,
3091,
1978,
1990,
8018,
3530,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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Status
SUCCESS = 0
IN_PROGRESS = 1
FAIL = 2
# Status Messages
F_BASIC_INFORMATION_MISSING = 'Missing title and/or author.'
F_COULD_NOT_FIND_ASIN = 'Could not find ASIN.'
F_COULD_NOT_FIND_GOODREADS_PAGE = 'Could not find Goodreads page.'
F_LOCAL_BOOK_NOT_FOUND = 'Local book not found.'
F_NO_APPROPRIATE_LOCAL_BOOK_FOUND = 'No local book of the chosen formats was found.'
F_COULD_NOT_PARSE_GOODREADS_DATA = 'Could not parse Goodreads data.'
F_UNABLE_TO_PARSE_BOOK = 'Unable to parse book.'
F_REMOVE_LOCAL_XRAY = 'Unable to remove local x-ray.'
F_PREFS_NOT_OVERWRITE_LOCAL_XRAY = 'Local x-ray found. Your preferences are set to not ovewrite if one already exists.'
F_UNABLE_TO_CREATE_XRAY = 'Unable to create x-ray.'
F_UNABLE_TO_WRITE_XRAY = 'Unable to write x-ray.'
F_UNABLE_TO_SEND_XRAY = 'Unable to send x-ray.'
F_PREFS_NOT_OVERWRITE_DEVICE_XRAY = ('Device already has x-ray for this book. Your preferences are set to not ovewrite '
'if one already exists.')
F_REMOVE_LOCAL_AUTHOR_PROFILE = 'Unable to remove local author profile.'
F_PREFS_NOT_OVERWRITE_LOCAL_AUTHOR_PROFILE = ('Local author profile found. Your preferences are set to not ovewrite if '
'one already exists.')
F_UNABLE_TO_CREATE_AUTHOR_PROFILE = 'Unable to create author profile.'
F_UNABLE_TO_WRITE_AUTHOR_PROFILE = 'Unable to write author profile.'
F_UNABLE_TO_SEND_AUTHOR_PROFILE = 'Unable to send author profile.'
F_PREFS_NOT_OVERWRITE_DEVICE_AUTHOR_PROFILE = ('Device already has author profile for this book. Your preferences are '
'set to not ovewrite if one already exists.')
F_REMOVE_LOCAL_START_ACTIONS = 'Unable to remove local start actions.'
F_PREFS_NOT_OVERWRITE_LOCAL_START_ACTIONS = ('Local start actions found. Your preferences are set to not ovewrite if '
'one already exists.')
F_UNABLE_TO_CREATE_START_ACTIONS = 'Unable to create start actions.'
F_UNABLE_TO_WRITE_START_ACTIONS = 'Unable to write start actions.'
F_UNABLE_TO_SEND_START_ACTIONS = 'Unable to send start actions.'
F_PREFS_NOT_OVERWRITE_DEVICE_START_ACTIONS = ('Device already has start actions for this book. Your preferences are set '
'to not ovewrite if one already exists.')
F_REMOVE_LOCAL_END_ACTIONS = 'Unable to remove local end actions.'
F_PREFS_NOT_OVERWRITE_LOCAL_END_ACTIONS = ('Local end actions found. Your preferences are set to not ovewrite if one '
'already exists.')
F_UNABLE_TO_CREATE_END_ACTIONS = 'Unable to create end actions.'
F_UNABLE_TO_WRITE_END_ACTIONS = 'Unable to write end actions.'
F_UNABLE_TO_SEND_END_ACTIONS = 'Unable to send end actions.'
F_PREFS_NOT_OVERWRITE_DEVICE_END_ACTIONS = ('Device already has end actions for this book. Your preferences are set to '
'not ovewrite if one already exists.')
F_BOOK_NOT_ON_DEVICE = 'None of the passing formats are on the device.'
F_PREFS_SET_TO_NOT_CREATE_XRAY = ('No local x-ray found. Your preferences are set to not create '
'one if one is not already found when sending to device.')
F_UNABLE_TO_UPDATE_ASIN = 'Unable to update ASIN in book on device.'
def __init__(self, status=None, message=None):
self._status = status
self._message = message
@property
def status(self):
return self._status
@status.setter
def status(self, val):
self._status = val
@property
def message(self):
return self._message
@message.setter
def message(self, val):
self._message = val
def set(self, status, message):
'''Sets both status and status message'''
self._status = status
self._message = message
|
gpl-3.0
|
[
3,
1205,
63,
815,
14,
647,
202,
199,
2344,
40,
8250,
2004,
2556,
2344,
2999,
199,
533,
9795,
2354,
8,
785,
304,
1128,
1449,
2543,
370,
10266,
6719,
2004,
2556,
2344,
2958,
327,
9795,
1128,
28364,
275,
378,
1128,
1621,
63,
24547,
275,
413,
1128,
10341,
275,
499,
2958,
327,
9795,
27377,
1128,
481,
63,
27271,
63,
21583,
63,
18701,
275,
283,
7718,
2538,
436,
15,
269,
4132,
3530,
1128,
481,
63,
1439,
28969,
63,
4609,
63,
27087,
63,
1179,
568,
275,
283,
6531,
440,
2342,
4319,
568,
3530,
1128,
481,
63,
1439,
28969,
63,
4609,
63,
27087,
63,
17316,
36,
5670,
51,
63,
12898,
275,
283,
6531,
440,
2342,
22311,
15656,
2034,
3530,
1128,
481,
63,
7486,
63,
21155,
63,
4609,
63,
13945,
275,
283,
5339,
6719,
440,
1911,
3530,
1128,
481,
63,
2826,
63,
1282,
2514,
20076,
1951,
63,
7486,
63,
21155,
63,
13945,
275,
283,
1944,
2257,
6719,
402,
314,
12414,
6752,
1990,
1911,
3530,
1128,
481,
63,
1439,
28969,
63,
4609,
63,
23354,
63,
17316,
36,
5670,
51,
63,
3998,
275,
283,
6531,
440,
2198,
22311,
15656,
666,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
23354,
63,
21155,
275,
283,
6005,
370,
2198,
6719,
3530,
1128,
481,
63,
25856,
63,
7486,
63,
56,
2847,
57,
275,
283,
6005,
370,
2813,
2257,
671,
13,
803,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
56,
2847,
57,
275,
283,
5339,
671,
13,
803,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
1373,
2575,
3495,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
56,
2847,
57,
275,
283,
6005,
370,
1218,
671,
13,
803,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
56,
2847,
57,
275,
283,
6005,
370,
2218,
671,
13,
803,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
56,
2847,
57,
275,
283,
6005,
370,
3222,
671,
13,
803,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
56,
2847,
57,
275,
661,
2510,
2575,
965,
671,
13,
803,
367,
642,
6719,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
283,
202,
1460,
283,
692,
1373,
2575,
3495,
2659,
1128,
481,
63,
25856,
63,
7486,
63,
27938,
63,
16632,
275,
283,
6005,
370,
2813,
2257,
4132,
4690,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
27938,
63,
16632,
275,
661,
5339,
4132,
4690,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
283,
202,
8179,
283,
368,
2575,
3495,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
27938,
63,
16632,
275,
283,
6005,
370,
1218,
4132,
4690,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
27938,
63,
16632,
275,
283,
6005,
370,
2218,
4132,
4690,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
27938,
63,
16632,
275,
283,
6005,
370,
3222,
4132,
4690,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
27938,
63,
16632,
275,
661,
2510,
2575,
965,
4132,
4690,
367,
642,
6719,
14,
19519,
23453,
787,
283,
202,
8962,
283,
409,
370,
440,
312,
432,
952,
340,
1373,
2575,
3495,
2659,
1128,
481,
63,
25856,
63,
7486,
63,
7363,
63,
25194,
275,
283,
6005,
370,
2813,
2257,
1343,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
7363,
63,
25194,
275,
661,
5339,
1343,
5445,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
283,
202,
1740,
283,
368,
2575,
3495,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
7363,
63,
25194,
275,
283,
6005,
370,
1218,
1343,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
7363,
63,
25194,
275,
283,
6005,
370,
2218,
1343,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
7363,
63,
25194,
275,
283,
6005,
370,
3222,
1343,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
7363,
63,
25194,
275,
661,
2510,
2575,
965,
1343,
5445,
367,
642,
6719,
14,
19519,
23453,
787,
663,
283,
202,
8179,
283,
475,
440,
312,
432,
952,
340,
1373,
2575,
3495,
2659,
1128,
481,
63,
25856,
63,
7486,
63,
3902,
63,
25194,
275,
283,
6005,
370,
2813,
2257,
1284,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
3902,
63,
25194,
275,
661,
5339,
1284,
5445,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
1373,
283,
202,
6901,
283,
14039,
3495,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
3902,
63,
25194,
275,
283,
6005,
370,
1218,
1284,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
3902,
63,
25194,
275,
283,
6005,
370,
2218,
1284,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
3902,
63,
25194,
275,
283,
6005,
370,
3222,
1284,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
3902,
63,
25194,
275,
661,
2510,
2575,
965,
1284,
5445,
367,
642,
6719,
14,
19519,
23453,
787,
663,
370,
283,
202,
6059,
283,
1397,
312,
432,
952,
340,
1373,
2575,
3495,
2659,
1128,
481,
63,
21155,
63,
4609,
63,
615,
63,
10555,
275,
283,
403,
402,
314,
9476,
6752,
787,
641,
314,
2243,
3530,
1128,
481,
63,
4225,
7079,
63,
3597,
63,
2566,
63,
4609,
63,
8366,
63,
56,
2847,
57,
275,
661,
1944,
2257,
671,
13,
803,
1911,
14,
19519,
23453,
787,
663,
370,
440,
1218,
283,
202,
4228,
283,
368,
340,
1373,
365,
440,
2575,
1911,
1380,
10209,
370,
2243,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10383,
63,
1179,
568,
275,
283,
6005,
370,
1678,
4319,
568,
315,
6719,
641,
2243,
3530,
2958,
347,
636,
826,
721,
277,
12,
2004,
29,
403,
12,
1245,
29,
403,
304,
1039,
291,
423,
1205,
275,
2004,
1039,
291,
423,
1188,
275,
1245,
2958,
768,
1829,
1128,
347,
2004,
8,
277,
304,
1039,
372,
291,
423,
1205,
2958,
768,
1205,
14,
8345,
1128,
347,
2004,
8,
277,
12,
1139,
304
] |
[
1205,
63,
815,
14,
647,
202,
199,
2344,
40,
8250,
2004,
2556,
2344,
2999,
199,
533,
9795,
2354,
8,
785,
304,
1128,
1449,
2543,
370,
10266,
6719,
2004,
2556,
2344,
2958,
327,
9795,
1128,
28364,
275,
378,
1128,
1621,
63,
24547,
275,
413,
1128,
10341,
275,
499,
2958,
327,
9795,
27377,
1128,
481,
63,
27271,
63,
21583,
63,
18701,
275,
283,
7718,
2538,
436,
15,
269,
4132,
3530,
1128,
481,
63,
1439,
28969,
63,
4609,
63,
27087,
63,
1179,
568,
275,
283,
6531,
440,
2342,
4319,
568,
3530,
1128,
481,
63,
1439,
28969,
63,
4609,
63,
27087,
63,
17316,
36,
5670,
51,
63,
12898,
275,
283,
6531,
440,
2342,
22311,
15656,
2034,
3530,
1128,
481,
63,
7486,
63,
21155,
63,
4609,
63,
13945,
275,
283,
5339,
6719,
440,
1911,
3530,
1128,
481,
63,
2826,
63,
1282,
2514,
20076,
1951,
63,
7486,
63,
21155,
63,
13945,
275,
283,
1944,
2257,
6719,
402,
314,
12414,
6752,
1990,
1911,
3530,
1128,
481,
63,
1439,
28969,
63,
4609,
63,
23354,
63,
17316,
36,
5670,
51,
63,
3998,
275,
283,
6531,
440,
2198,
22311,
15656,
666,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
23354,
63,
21155,
275,
283,
6005,
370,
2198,
6719,
3530,
1128,
481,
63,
25856,
63,
7486,
63,
56,
2847,
57,
275,
283,
6005,
370,
2813,
2257,
671,
13,
803,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
56,
2847,
57,
275,
283,
5339,
671,
13,
803,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
1373,
2575,
3495,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
56,
2847,
57,
275,
283,
6005,
370,
1218,
671,
13,
803,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
56,
2847,
57,
275,
283,
6005,
370,
2218,
671,
13,
803,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
56,
2847,
57,
275,
283,
6005,
370,
3222,
671,
13,
803,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
56,
2847,
57,
275,
661,
2510,
2575,
965,
671,
13,
803,
367,
642,
6719,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
283,
202,
1460,
283,
692,
1373,
2575,
3495,
2659,
1128,
481,
63,
25856,
63,
7486,
63,
27938,
63,
16632,
275,
283,
6005,
370,
2813,
2257,
4132,
4690,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
27938,
63,
16632,
275,
661,
5339,
4132,
4690,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
283,
202,
8179,
283,
368,
2575,
3495,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
27938,
63,
16632,
275,
283,
6005,
370,
1218,
4132,
4690,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
27938,
63,
16632,
275,
283,
6005,
370,
2218,
4132,
4690,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
27938,
63,
16632,
275,
283,
6005,
370,
3222,
4132,
4690,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
27938,
63,
16632,
275,
661,
2510,
2575,
965,
4132,
4690,
367,
642,
6719,
14,
19519,
23453,
787,
283,
202,
8962,
283,
409,
370,
440,
312,
432,
952,
340,
1373,
2575,
3495,
2659,
1128,
481,
63,
25856,
63,
7486,
63,
7363,
63,
25194,
275,
283,
6005,
370,
2813,
2257,
1343,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
7363,
63,
25194,
275,
661,
5339,
1343,
5445,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
283,
202,
1740,
283,
368,
2575,
3495,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
7363,
63,
25194,
275,
283,
6005,
370,
1218,
1343,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
7363,
63,
25194,
275,
283,
6005,
370,
2218,
1343,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
7363,
63,
25194,
275,
283,
6005,
370,
3222,
1343,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
7363,
63,
25194,
275,
661,
2510,
2575,
965,
1343,
5445,
367,
642,
6719,
14,
19519,
23453,
787,
663,
283,
202,
8179,
283,
475,
440,
312,
432,
952,
340,
1373,
2575,
3495,
2659,
1128,
481,
63,
25856,
63,
7486,
63,
3902,
63,
25194,
275,
283,
6005,
370,
2813,
2257,
1284,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
7486,
63,
3902,
63,
25194,
275,
661,
5339,
1284,
5445,
1911,
14,
19519,
23453,
787,
663,
370,
440,
312,
432,
952,
340,
1373,
283,
202,
6901,
283,
14039,
3495,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
8366,
63,
3902,
63,
25194,
275,
283,
6005,
370,
1218,
1284,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10387,
63,
3902,
63,
25194,
275,
283,
6005,
370,
2218,
1284,
5445,
3530,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
20469,
63,
3902,
63,
25194,
275,
283,
6005,
370,
3222,
1284,
5445,
3530,
1128,
481,
63,
4225,
7079,
63,
4609,
63,
14336,
10387,
63,
10555,
63,
3902,
63,
25194,
275,
661,
2510,
2575,
965,
1284,
5445,
367,
642,
6719,
14,
19519,
23453,
787,
663,
370,
283,
202,
6059,
283,
1397,
312,
432,
952,
340,
1373,
2575,
3495,
2659,
1128,
481,
63,
21155,
63,
4609,
63,
615,
63,
10555,
275,
283,
403,
402,
314,
9476,
6752,
787,
641,
314,
2243,
3530,
1128,
481,
63,
4225,
7079,
63,
3597,
63,
2566,
63,
4609,
63,
8366,
63,
56,
2847,
57,
275,
661,
1944,
2257,
671,
13,
803,
1911,
14,
19519,
23453,
787,
663,
370,
440,
1218,
283,
202,
4228,
283,
368,
340,
1373,
365,
440,
2575,
1911,
1380,
10209,
370,
2243,
2659,
1128,
481,
63,
1734,
2617,
63,
2566,
63,
10383,
63,
1179,
568,
275,
283,
6005,
370,
1678,
4319,
568,
315,
6719,
641,
2243,
3530,
2958,
347,
636,
826,
721,
277,
12,
2004,
29,
403,
12,
1245,
29,
403,
304,
1039,
291,
423,
1205,
275,
2004,
1039,
291,
423,
1188,
275,
1245,
2958,
768,
1829,
1128,
347,
2004,
8,
277,
304,
1039,
372,
291,
423,
1205,
2958,
768,
1205,
14,
8345,
1128,
347,
2004,
8,
277,
12,
1139,
304,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
mollel/bank
|
Admin/assets/jquery-file-upload/server/gae-python/main.py
|
223
|
5173
|
# -*- coding: utf-8 -*-
#
# jQuery File Upload Plugin GAE Python Example 2.0
# https://github.com/blueimp/jQuery-File-Upload
#
# Copyright 2011, Sebastian Tschan
# https://blueimp.net
#
# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT
#
from __future__ import with_statement
from google.appengine.api import files, images
from google.appengine.ext import blobstore, deferred
from google.appengine.ext.webapp import blobstore_handlers
import json, re, urllib, webapp2
WEBSITE = 'http://blueimp.github.com/jQuery-File-Upload/'
MIN_FILE_SIZE = 1 # bytes
MAX_FILE_SIZE = 5000000 # bytes
IMAGE_TYPES = re.compile('image/(gif|p?jpeg|(x-)?png)')
ACCEPT_FILE_TYPES = IMAGE_TYPES
THUMBNAIL_MODIFICATOR = '=s80' # max width / height
EXPIRATION_TIME = 300 # seconds
def cleanup(blob_keys):
blobstore.delete(blob_keys)
class UploadHandler(webapp2.RequestHandler):
def initialize(self, request, response):
super(UploadHandler, self).initialize(request, response)
self.response.headers['Access-Control-Allow-Origin'] = '*'
self.response.headers[
'Access-Control-Allow-Methods'
] = 'OPTIONS, HEAD, GET, POST, PUT, DELETE'
def validate(self, file):
if file['size'] < MIN_FILE_SIZE:
file['error'] = 'File is too small'
elif file['size'] > MAX_FILE_SIZE:
file['error'] = 'File is too big'
elif not ACCEPT_FILE_TYPES.match(file['type']):
file['error'] = 'Filetype not allowed'
else:
return True
return False
def get_file_size(self, file):
file.seek(0, 2) # Seek to the end of the file
size = file.tell() # Get the position of EOF
file.seek(0) # Reset the file position to the beginning
return size
def write_blob(self, data, info):
blob = files.blobstore.create(
mime_type=info['type'],
_blobinfo_uploaded_filename=info['name']
)
with files.open(blob, 'a') as f:
f.write(data)
files.finalize(blob)
return files.blobstore.get_blob_key(blob)
def handle_upload(self):
results = []
blob_keys = []
for name, fieldStorage in self.request.POST.items():
if type(fieldStorage) is unicode:
continue
result = {}
result['name'] = re.sub(r'^.*\\', '',
fieldStorage.filename)
result['type'] = fieldStorage.type
result['size'] = self.get_file_size(fieldStorage.file)
if self.validate(result):
blob_key = str(
self.write_blob(fieldStorage.value, result)
)
blob_keys.append(blob_key)
result['delete_type'] = 'DELETE'
result['delete_url'] = self.request.host_url +\
'/?key=' + urllib.quote(blob_key, '')
if (IMAGE_TYPES.match(result['type'])):
try:
result['url'] = images.get_serving_url(
blob_key,
secure_url=self.request.host_url\
.startswith('https')
)
result['thumbnail_url'] = result['url'] +\
THUMBNAIL_MODIFICATOR
except: # Could not get an image serving url
pass
if not 'url' in result:
result['url'] = self.request.host_url +\
'/' + blob_key + '/' + urllib.quote(
result['name'].encode('utf-8'), '')
results.append(result)
deferred.defer(
cleanup,
blob_keys,
_countdown=EXPIRATION_TIME
)
return results
def options(self):
pass
def head(self):
pass
def get(self):
self.redirect(WEBSITE)
def post(self):
if (self.request.get('_method') == 'DELETE'):
return self.delete()
result = {'files': self.handle_upload()}
s = json.dumps(result, separators=(',',':'))
redirect = self.request.get('redirect')
if redirect:
return self.redirect(str(
redirect.replace('%s', urllib.quote(s, ''), 1)
))
if 'application/json' in self.request.headers.get('Accept'):
self.response.headers['Content-Type'] = 'application/json'
self.response.write(s)
def delete(self):
blobstore.delete(self.request.get('key') or '')
class DownloadHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self, key, filename):
if not blobstore.get(key):
self.error(404)
else:
# Cache for the expiration time:
self.response.headers['Cache-Control'] =\
'public,max-age=%d' % EXPIRATION_TIME
self.send_blob(key, save_as=filename)
app = webapp2.WSGIApplication(
[
('/', UploadHandler),
('/([^/]+)/([^/]+)', DownloadHandler)
],
debug=True
)
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1335,
3227,
3814,
19149,
11349,
598,
12500,
2018,
5679,
499,
14,
16,
199,
3,
4178,
921,
5031,
14,
957,
15,
6304,
3236,
15,
74,
3227,
13,
1173,
13,
10301,
199,
3,
199,
3,
1898,
7760,
12,
428,
2871,
1810,
5653,
377,
83,
11984,
199,
3,
4178,
921,
6304,
3236,
14,
846,
199,
3,
199,
3,
3909,
1334,
314,
10697,
4190,
26,
199,
3,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
13965,
199,
3,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
6233,
14,
15358,
14,
1246,
492,
1584,
12,
5935,
199,
504,
6233,
14,
15358,
14,
832,
492,
9182,
1617,
12,
12309,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
9182,
1617,
63,
5586,
199,
646,
2022,
12,
295,
12,
4011,
12,
24812,
18,
199,
199,
13166,
7917,
275,
283,
1014,
921,
6304,
3236,
14,
5031,
14,
957,
15,
74,
3227,
13,
1173,
13,
10301,
4805,
199,
4896,
63,
3817,
63,
4305,
275,
413,
327,
2783,
199,
4283,
63,
3817,
63,
4305,
275,
959,
3273,
327,
2783,
199,
9438,
63,
7893,
275,
295,
14,
2014,
360,
1569,
7985,
14513,
92,
80,
31,
14230,
92,
8,
88,
13,
5547,
4524,
5942,
199,
13089,
63,
3817,
63,
7893,
275,
25228,
63,
7893,
199,
2080,
2639,
18273,
6593,
63,
16422,
23380,
6467,
275,
26143,
83,
1257,
7,
327,
1390,
3462,
1182,
4569,
199,
25632,
23743,
63,
4961,
275,
9601,
327,
4696,
199,
199,
318,
9058,
8,
6582,
63,
1612,
304,
272,
9182,
1617,
14,
1807,
8,
6582,
63,
1612,
9,
199,
199,
533,
19149,
2461,
8,
22632,
18,
14,
11149,
304,
339,
347,
8265,
8,
277,
12,
1056,
12,
1177,
304,
267,
1613,
8,
10301,
2461,
12,
291,
680,
8489,
8,
1069,
12,
1177,
9,
267,
291,
14,
1310,
14,
2139,
459,
3946,
13,
3717,
13,
7852,
13,
12834,
418,
275,
13626,
267,
291,
14,
1310,
14,
2139,
59,
288,
283,
3946,
13,
3717,
13,
7852,
13,
10385,
7,
267,
1622,
275,
283,
8808,
12,
13053,
12,
9576,
12,
8761,
12,
18337,
12,
15137,
7,
2286,
347,
4107,
8,
277,
12,
570,
304,
267,
340,
570,
459,
890,
418,
665,
15861,
63,
3817,
63,
4305,
26,
288,
570,
459,
705,
418,
275,
283,
1173,
365,
4634,
7425,
7,
267,
916,
570,
459,
890,
418,
690,
9141,
63,
3817,
63,
4305,
26,
288,
570,
459,
705,
418,
275,
283,
1173,
365,
4634,
7282,
7,
267,
916,
440,
28538,
63,
3817,
63,
7893,
14,
1431,
8,
493,
459,
466,
9090,
288,
570,
459,
705,
418,
275,
283,
1173,
466,
440,
4370,
7,
267,
587,
26,
288,
372,
715,
267,
372,
756,
2286,
347,
664,
63,
493,
63,
890,
8,
277,
12,
570,
304,
267,
570,
14,
5507,
8,
16,
12,
499,
9,
327,
1666,
75,
370,
314,
1284,
402,
314,
570,
267,
1568,
275,
570,
14,
9974,
342,
327,
2372,
314,
3421,
402,
9027,
267,
570,
14,
5507,
8,
16,
9,
327,
15510,
314,
570,
3421,
370,
314,
9608,
267,
372,
1568,
2286,
347,
2218,
63,
6582,
8,
277,
12,
666,
12,
2256,
304,
267,
9182,
275,
1584,
14,
6582,
1617,
14,
981,
8,
288,
6660,
63,
466,
29,
815,
459,
466,
995,
288,
485,
6582,
815,
63,
19044,
63,
1501,
29,
815,
459,
354,
418,
267,
776,
267,
543,
1584,
14,
1490,
8,
6582,
12,
283,
65,
358,
465,
289,
26,
288,
289,
14,
952,
8,
576,
9,
267,
1584,
14,
14450,
8,
6582,
9,
267,
372,
1584,
14,
6582,
1617,
14,
362,
63,
6582,
63,
498,
8,
6582,
9,
2286,
347,
2429,
63,
5064,
8,
277,
304,
267,
2058,
275,
942,
267,
9182,
63,
1612,
275,
942,
267,
367,
536,
12,
901,
6408,
315,
291,
14,
1069,
14,
4030,
14,
1744,
837,
288,
340,
730,
8,
698,
6408,
9,
365,
2649,
26,
355,
1980,
288,
754,
275,
1052,
288,
754,
459,
354,
418,
275,
295,
14,
954,
8,
82,
4289,
2795,
1103,
297,
3260,
355,
901,
6408,
14,
1501,
9,
288,
754,
459,
466,
418,
275,
901,
6408,
14,
466,
288,
754,
459,
890,
418,
275,
291,
14,
362,
63,
493,
63,
890,
8,
698,
6408,
14,
493,
9,
288,
340,
291,
14,
3502,
8,
1099,
304,
355,
9182,
63,
498,
275,
620,
8,
490,
291,
14,
952,
63,
6582,
8,
698,
6408,
14,
585,
12,
754,
9,
355,
776,
355,
9182,
63,
1612,
14,
740,
8,
6582,
63,
498,
9,
355,
754,
459,
1807,
63,
466,
418,
275,
283,
7014,
7,
355,
754,
459,
1807,
63,
633,
418,
275,
291,
14,
1069,
14,
1102,
63,
633,
17992,
490,
1994,
31,
498,
534,
435,
4011,
14,
3513,
8,
6582,
63,
498,
12,
4074,
355,
340,
334,
9438,
63,
7893,
14,
1431,
8,
1099,
459,
466,
26536,
490,
862,
26,
717,
754,
459,
633,
418,
275,
5935,
14,
362,
63,
14717,
63,
633,
8,
1169,
9182,
63,
498,
12,
1169,
11153,
63,
633,
29,
277,
14,
1069,
14,
1102,
63,
633,
60,
1816,
1275,
2460,
360,
2859,
358,
717,
776,
717,
754,
459,
8311,
63,
633,
418,
275,
754,
459,
633,
418,
17992,
1169,
4221,
2639,
18273,
6593,
63,
16422,
23380,
6467,
490,
871,
26,
327,
18615,
440,
664,
376,
1834,
22701,
1166,
717,
986,
355,
340,
440,
283,
633,
7,
315,
754,
26,
490,
754,
459,
633,
418,
275,
291,
14,
1069,
14,
1102,
63,
633,
17992,
717,
7324,
435,
9182,
63,
498,
435,
7324,
435,
4011,
14,
3513,
8,
1169,
754,
459,
354,
2278,
2143,
360,
1624,
13,
24,
659,
4074,
288,
2058,
14,
740,
8,
1099,
9,
267,
12309,
14,
11610,
8,
288,
9058,
12,
288,
9182,
63,
1612,
12,
288,
485,
835,
2110,
29,
25632,
23743,
63,
4961,
267,
776,
267,
372,
2058,
2286,
347,
1511,
8,
277,
304,
267,
986,
5493,
347,
4854,
8,
277,
304,
267,
986,
2286,
347,
664,
8,
277,
304,
267,
291,
14,
4876,
8,
13166,
7917,
9,
2286,
347,
2963,
8,
277,
304,
267,
340,
334,
277,
14,
1069,
14,
362,
6412,
765,
358,
508,
283,
7014,
735,
288,
372,
291,
14,
1807,
342,
267,
754,
275,
791,
1725,
356,
291,
14,
2479,
63,
5064,
12737,
267
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1335,
3227,
3814,
19149,
11349,
598,
12500,
2018,
5679,
499,
14,
16,
199,
3,
4178,
921,
5031,
14,
957,
15,
6304,
3236,
15,
74,
3227,
13,
1173,
13,
10301,
199,
3,
199,
3,
1898,
7760,
12,
428,
2871,
1810,
5653,
377,
83,
11984,
199,
3,
4178,
921,
6304,
3236,
14,
846,
199,
3,
199,
3,
3909,
1334,
314,
10697,
4190,
26,
199,
3,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
13965,
199,
3,
199,
199,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
504,
6233,
14,
15358,
14,
1246,
492,
1584,
12,
5935,
199,
504,
6233,
14,
15358,
14,
832,
492,
9182,
1617,
12,
12309,
199,
504,
6233,
14,
15358,
14,
832,
14,
22632,
492,
9182,
1617,
63,
5586,
199,
646,
2022,
12,
295,
12,
4011,
12,
24812,
18,
199,
199,
13166,
7917,
275,
283,
1014,
921,
6304,
3236,
14,
5031,
14,
957,
15,
74,
3227,
13,
1173,
13,
10301,
4805,
199,
4896,
63,
3817,
63,
4305,
275,
413,
327,
2783,
199,
4283,
63,
3817,
63,
4305,
275,
959,
3273,
327,
2783,
199,
9438,
63,
7893,
275,
295,
14,
2014,
360,
1569,
7985,
14513,
92,
80,
31,
14230,
92,
8,
88,
13,
5547,
4524,
5942,
199,
13089,
63,
3817,
63,
7893,
275,
25228,
63,
7893,
199,
2080,
2639,
18273,
6593,
63,
16422,
23380,
6467,
275,
26143,
83,
1257,
7,
327,
1390,
3462,
1182,
4569,
199,
25632,
23743,
63,
4961,
275,
9601,
327,
4696,
199,
199,
318,
9058,
8,
6582,
63,
1612,
304,
272,
9182,
1617,
14,
1807,
8,
6582,
63,
1612,
9,
199,
199,
533,
19149,
2461,
8,
22632,
18,
14,
11149,
304,
339,
347,
8265,
8,
277,
12,
1056,
12,
1177,
304,
267,
1613,
8,
10301,
2461,
12,
291,
680,
8489,
8,
1069,
12,
1177,
9,
267,
291,
14,
1310,
14,
2139,
459,
3946,
13,
3717,
13,
7852,
13,
12834,
418,
275,
13626,
267,
291,
14,
1310,
14,
2139,
59,
288,
283,
3946,
13,
3717,
13,
7852,
13,
10385,
7,
267,
1622,
275,
283,
8808,
12,
13053,
12,
9576,
12,
8761,
12,
18337,
12,
15137,
7,
2286,
347,
4107,
8,
277,
12,
570,
304,
267,
340,
570,
459,
890,
418,
665,
15861,
63,
3817,
63,
4305,
26,
288,
570,
459,
705,
418,
275,
283,
1173,
365,
4634,
7425,
7,
267,
916,
570,
459,
890,
418,
690,
9141,
63,
3817,
63,
4305,
26,
288,
570,
459,
705,
418,
275,
283,
1173,
365,
4634,
7282,
7,
267,
916,
440,
28538,
63,
3817,
63,
7893,
14,
1431,
8,
493,
459,
466,
9090,
288,
570,
459,
705,
418,
275,
283,
1173,
466,
440,
4370,
7,
267,
587,
26,
288,
372,
715,
267,
372,
756,
2286,
347,
664,
63,
493,
63,
890,
8,
277,
12,
570,
304,
267,
570,
14,
5507,
8,
16,
12,
499,
9,
327,
1666,
75,
370,
314,
1284,
402,
314,
570,
267,
1568,
275,
570,
14,
9974,
342,
327,
2372,
314,
3421,
402,
9027,
267,
570,
14,
5507,
8,
16,
9,
327,
15510,
314,
570,
3421,
370,
314,
9608,
267,
372,
1568,
2286,
347,
2218,
63,
6582,
8,
277,
12,
666,
12,
2256,
304,
267,
9182,
275,
1584,
14,
6582,
1617,
14,
981,
8,
288,
6660,
63,
466,
29,
815,
459,
466,
995,
288,
485,
6582,
815,
63,
19044,
63,
1501,
29,
815,
459,
354,
418,
267,
776,
267,
543,
1584,
14,
1490,
8,
6582,
12,
283,
65,
358,
465,
289,
26,
288,
289,
14,
952,
8,
576,
9,
267,
1584,
14,
14450,
8,
6582,
9,
267,
372,
1584,
14,
6582,
1617,
14,
362,
63,
6582,
63,
498,
8,
6582,
9,
2286,
347,
2429,
63,
5064,
8,
277,
304,
267,
2058,
275,
942,
267,
9182,
63,
1612,
275,
942,
267,
367,
536,
12,
901,
6408,
315,
291,
14,
1069,
14,
4030,
14,
1744,
837,
288,
340,
730,
8,
698,
6408,
9,
365,
2649,
26,
355,
1980,
288,
754,
275,
1052,
288,
754,
459,
354,
418,
275,
295,
14,
954,
8,
82,
4289,
2795,
1103,
297,
3260,
355,
901,
6408,
14,
1501,
9,
288,
754,
459,
466,
418,
275,
901,
6408,
14,
466,
288,
754,
459,
890,
418,
275,
291,
14,
362,
63,
493,
63,
890,
8,
698,
6408,
14,
493,
9,
288,
340,
291,
14,
3502,
8,
1099,
304,
355,
9182,
63,
498,
275,
620,
8,
490,
291,
14,
952,
63,
6582,
8,
698,
6408,
14,
585,
12,
754,
9,
355,
776,
355,
9182,
63,
1612,
14,
740,
8,
6582,
63,
498,
9,
355,
754,
459,
1807,
63,
466,
418,
275,
283,
7014,
7,
355,
754,
459,
1807,
63,
633,
418,
275,
291,
14,
1069,
14,
1102,
63,
633,
17992,
490,
1994,
31,
498,
534,
435,
4011,
14,
3513,
8,
6582,
63,
498,
12,
4074,
355,
340,
334,
9438,
63,
7893,
14,
1431,
8,
1099,
459,
466,
26536,
490,
862,
26,
717,
754,
459,
633,
418,
275,
5935,
14,
362,
63,
14717,
63,
633,
8,
1169,
9182,
63,
498,
12,
1169,
11153,
63,
633,
29,
277,
14,
1069,
14,
1102,
63,
633,
60,
1816,
1275,
2460,
360,
2859,
358,
717,
776,
717,
754,
459,
8311,
63,
633,
418,
275,
754,
459,
633,
418,
17992,
1169,
4221,
2639,
18273,
6593,
63,
16422,
23380,
6467,
490,
871,
26,
327,
18615,
440,
664,
376,
1834,
22701,
1166,
717,
986,
355,
340,
440,
283,
633,
7,
315,
754,
26,
490,
754,
459,
633,
418,
275,
291,
14,
1069,
14,
1102,
63,
633,
17992,
717,
7324,
435,
9182,
63,
498,
435,
7324,
435,
4011,
14,
3513,
8,
1169,
754,
459,
354,
2278,
2143,
360,
1624,
13,
24,
659,
4074,
288,
2058,
14,
740,
8,
1099,
9,
267,
12309,
14,
11610,
8,
288,
9058,
12,
288,
9182,
63,
1612,
12,
288,
485,
835,
2110,
29,
25632,
23743,
63,
4961,
267,
776,
267,
372,
2058,
2286,
347,
1511,
8,
277,
304,
267,
986,
5493,
347,
4854,
8,
277,
304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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
jtyr/ansible-modules-core
|
cloud/docker/docker_login.py
|
14
|
10768
|
#!/usr/bin/python
#
# (c) 2016 Olaf Kilian <olaf.kilian@symanex.com>
# Chris Houseknecht, <house@redhat.com>
# James Tanner, <jtanner@redhat.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
DOCUMENTATION = '''
---
module: docker_login
short_description: Log into a Docker registry.
version_added: "2.0"
description:
- Provides functionality similar to the "docker login" command.
- Authenticate with a docker registry and add the credentials to your local Docker config file. Adding the
credentials to the config files allows future connections to the registry using tools such as Ansible's Docker
modules, the Docker CLI and docker-py without needing to provide credentials.
- Running in check mode will perform the authentication without updating the config file.
options:
registry_url:
required: False
description:
- The registry URL.
default: "https://index.docker.io/v1/"
aliases:
- registry
- url
username:
description:
- The username for the registry account
required: True
password:
description:
- The plaintext password for the registry account
required: True
email:
required: False
description:
- "The email address for the registry account. NOTE: private registries may not require this,
but Docker Hub requires it."
default: None
reauthorize:
required: False
description:
- Refresh exiting authentication found in the configuration file.
default: no
choices: ['yes', 'no']
aliases:
- reauth
config_path:
description:
- Custom path to the Docker CLI configuration file.
default: ~/.docker/config.json
required: False
aliases:
- self.config_path
- dockercfg_path
state:
version_added: '2.3'
description:
- This controls the current state of the user. C(present) will login in a user, C(absent) will log him out.
- To logout you only need the registry server, which defaults to DockerHub.
- Before 2.1 you could ONLY log in.
- docker does not support 'logout' with a custom config file.
choices: ['present', 'absent']
default: 'present'
required: False
extends_documentation_fragment:
- docker
requirements:
- "python >= 2.6"
- "docker-py >= 1.7.0"
- "Docker API >= 1.20"
- 'Only to be able to logout (state=absent): the docker command line utility'
authors:
- "Olaf Kilian <olaf.kilian@symanex.com>"
- "Chris Houseknecht (@chouseknecht)"
- "James Tanner (@jctanner)"
'''
EXAMPLES = '''
- name: Log into DockerHub
docker_login:
username: docker
password: rekcod
email: docker@docker.io
- name: Log into private registry and force re-authorization
docker_login:
registry: your.private.registry.io
username: yourself
password: secrets3
reauthorize: yes
- name: Log into DockerHub using a custom config file
docker_login:
username: docker
password: rekcod
email: docker@docker.io
config_path: /tmp/.mydockercfg
- name: Log out of DockerHub
docker_login:
state: absent
email: docker@docker.com
'''
RETURN = '''
login_results:
description: Results from the login.
returned: when state='present'
type: dict
sample: {
"email": "testuer@yahoo.com",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"serveraddress": "localhost:5000",
"username": "testuser"
}
'''
import base64
from ansible.module_utils.docker_common import *
class LoginManager(DockerBaseClass):
def __init__(self, client, results):
super(LoginManager, self).__init__()
self.client = client
self.results = results
parameters = self.client.module.params
self.check_mode = self.client.check_mode
self.registry_url = parameters.get('registry_url')
self.username = parameters.get('username')
self.password = parameters.get('password')
self.email = parameters.get('email')
self.reauthorize = parameters.get('reauthorize')
self.config_path = parameters.get('config_path')
if parameters['state'] == 'present':
self.login()
else:
self.logout()
def fail(self, msg):
self.client.fail(msg)
def login(self):
'''
Log into the registry with provided username/password. On success update the config
file with the new authorization.
:return: None
'''
if self.email and not re.match(EMAIL_REGEX, self.email):
self.fail("Parameter error: the email address appears to be incorrect. Expecting it to match "
"/%s/" % (EMAIL_REGEX))
self.results['actions'].append("Logged into %s" % (self.registry_url))
self.log("Log into %s with username %s" % (self.registry_url, self.username))
try:
response = self.client.login(
self.username,
password=self.password,
email=self.email,
registry=self.registry_url,
reauth=self.reauthorize,
dockercfg_path=self.config_path
)
except Exception as exc:
self.fail("Logging into %s for user %s failed - %s" % (self.registry_url, self.username, str(exc)))
self.results['login_result'] = response
if not self.check_mode:
self.update_config_file()
def logout(self):
'''
Log out of the registry. On success update the config file.
TODO: port to API once docker.py supports this.
:return: None
'''
cmd = "%s logout " % self.client.module.get_bin_path('docker', True)
#TODO: docker does not support config file in logout, restore this when they do
#if self.config_path and self.config_file_exists(self.config_path):
# cmd += "--config '%s' " % self.config_path
cmd += "'%s'" % self.registry_url
(rc, out, err) = self.client.module.run_command(cmd)
if rc != 0:
self.fail("Could not log out: %s" % err)
def config_file_exists(self, path):
if os.path.exists(path):
self.log("Configuration file %s exists" % (path))
return True
self.log("Configuration file %s not found." % (path))
return False
def create_config_file(self, path):
'''
Create a config file with a JSON blob containing an auths key.
:return: None
'''
self.log("Creating docker config file %s" % (path))
config_path_dir = os.path.dirname(path)
if not os.path.exists(config_path_dir):
try:
os.makedirs(config_path_dir)
except Exception as exc:
self.fail("Error: failed to create %s - %s" % (config_path_dir, str(exc)))
self.write_config(path, dict(auths=dict()))
def write_config(self, path, config):
try:
json.dump(config, open(path, "w"), indent=5, sort_keys=True)
except Exception as exc:
self.fail("Error: failed to write config to %s - %s" % (path, str(exc)))
def update_config_file(self):
'''
If the authorization not stored in the config file or reauthorize is True,
update the config file with the new authorization.
:return: None
'''
path = os.path.expanduser(self.config_path)
if not self.config_file_exists(path):
self.create_config_file(path)
try:
# read the existing config
config = json.load(open(path, "r"))
except ValueError:
self.log("Error reading config from %s" % (path))
config = dict()
if not config.get('auths'):
self.log("Adding auths dict to config.")
config['auths'] = dict()
if not config['auths'].get(self.registry_url):
self.log("Adding registry_url %s to auths." % (self.registry_url))
config['auths'][self.registry_url] = dict()
encoded_credentials = dict(
auth=base64.b64encode(self.username + b':' + self.password),
email=self.email
)
if config['auths'][self.registry_url] != encoded_credentials or self.reauthorize:
# Update the config file with the new authorization
config['auths'][self.registry_url] = encoded_credentials
self.log("Updating config file %s with new authorization for %s" % (path, self.registry_url))
self.results['actions'].append("Updated config file %s with new authorization for %s" % (
path, self.registry_url))
self.results['changed'] = True
self.write_config(path, config)
def main():
argument_spec=dict(
registry_url=dict(type='str', required=False, default=DEFAULT_DOCKER_REGISTRY, aliases=['registry', 'url']),
username=dict(type='str', required=False),
password=dict(type='str', required=False, no_log=True),
email=dict(type='str'),
reauthorize=dict(type='bool', default=False, aliases=['reauth']),
state=dict(type='str', default='present', choices=['present', 'absent']),
config_path=dict(type='str', default='~/.docker/config.json', aliases=['self.config_path', 'dockercfg_path']),
)
required_if = [
('state', 'present', ['username', 'password']),
]
client = AnsibleDockerClient(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=required_if
)
results = dict(
changed=False,
actions=[],
login_result={}
)
if module.params['state'] == 'present' and module.params['registry_url'] == DEFAULT_DOCKER_REGISTRY and not module.params['email']:
module.fail_json(msg="'email' is required when loging into DockerHub")
LoginManager(client, results)
if 'actions' in results:
del results['actions']
client.module.exit_json(**results)
# import module snippets
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
334,
67,
9,
7800,
593,
416,
70,
1804,
1638,
290,
665,
393,
2756,
14,
75,
1638,
290,
32,
1786,
1237,
476,
14,
957,
30,
199,
3,
3515,
2799,
5719,
869,
7130,
75,
685,
335,
84,
12,
665,
6740,
32,
17164,
14,
957,
30,
199,
3,
3515,
1603,
14015,
377,
5161,
12,
665,
26002,
5161,
32,
17164,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
12424,
63,
2886,
199,
3612,
63,
1802,
26,
5297,
1901,
282,
22067,
7086,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
1802,
26,
272,
446,
21552,
9330,
8545,
370,
314,
298,
9991,
4676,
2,
1414,
14,
272,
446,
3590,
7672,
543,
282,
12424,
7086,
436,
1050,
314,
6235,
370,
2195,
2257,
22067,
1101,
570,
14,
12934,
314,
489,
6235,
370,
314,
1101,
1584,
6127,
6466,
6947,
370,
314,
7086,
1808,
7249,
4066,
465,
2622,
1159,
22067,
489,
4621,
12,
314,
22067,
14214,
436,
12424,
13,
647,
1928,
1929,
316,
370,
5647,
6235,
14,
272,
446,
26848,
315,
1104,
818,
911,
5147,
314,
6299,
1928,
12928,
314,
1101,
570,
14,
199,
1419,
26,
523,
7086,
63,
633,
26,
272,
1415,
26,
756,
272,
1369,
26,
489,
446,
710,
7086,
2851,
14,
272,
849,
26,
298,
2859,
921,
1080,
14,
9991,
14,
2308,
15,
86,
17,
6687,
272,
5481,
26,
489,
446,
7086,
489,
446,
1166,
523,
3434,
26,
272,
1369,
26,
489,
446,
710,
3434,
367,
314,
7086,
2933,
272,
1415,
26,
715,
523,
2505,
26,
272,
1369,
26,
489,
446,
710,
18577,
2505,
367,
314,
7086,
2933,
272,
1415,
26,
715,
523,
3031,
26,
272,
1415,
26,
756,
272,
1369,
26,
489,
446,
298,
1918,
3031,
2287,
367,
314,
7086,
2933,
14,
6944,
26,
5726,
25483,
1996,
1443,
440,
4409,
642,
12,
267,
1325,
22067,
869,
456,
5074,
652,
2122,
272,
849,
26,
488,
523,
295,
14204,
26,
272,
1415,
26,
756,
272,
1369,
26,
489,
446,
30345,
24234,
6299,
1911,
315,
314,
2897,
570,
14,
272,
849,
26,
949,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
272,
5481,
26,
489,
446,
295,
1178,
523,
1101,
63,
515,
26,
272,
1369,
26,
489,
446,
8388,
931,
370,
314,
22067,
14214,
2897,
570,
14,
272,
849,
26,
25975,
9991,
15,
888,
14,
1001,
272,
1415,
26,
756,
272,
5481,
26,
489,
446,
291,
14,
888,
63,
515,
489,
446,
12424,
4128,
63,
515,
523,
1174,
26,
272,
1015,
63,
3270,
26,
283,
18,
14,
19,
7,
272,
1369,
26,
489,
446,
961,
13467,
314,
1453,
1174,
402,
314,
922,
14,
445,
8,
1881,
9,
911,
4676,
315,
282,
922,
12,
445,
8,
5575,
9,
911,
943,
26457,
734,
14,
489,
446,
4005,
22079,
1265,
1454,
1929,
314,
7086,
1654,
12,
1314,
4243,
370,
22067,
15338,
14,
489,
446,
21467,
499,
14,
17,
1265,
4293,
5258,
6084,
943,
315,
14,
489,
446,
12424,
1630,
440,
2291,
283,
11646,
7,
543,
282,
3537,
1101,
570,
14,
272,
3415,
26,
788,
1881,
297,
283,
5575,
418,
272,
849,
26,
283,
1881,
7,
272,
1415,
26,
756,
199,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
12424,
199,
7538,
26,
272,
446,
298,
1548,
2356,
499,
14,
22,
2,
272,
446,
298,
9991,
13,
647,
2356,
413,
14,
23,
14,
16,
2,
272,
446,
298,
31463,
3261,
2356,
413,
14,
1165,
2,
272,
446,
283,
5903,
370,
506,
7688,
370,
22079,
334,
929,
29,
5575,
304,
314,
12424,
1414,
1004,
11420,
7,
199,
8149,
26,
272,
446,
298,
47,
416,
70,
1804,
1638,
290,
665,
393,
2756,
14,
75,
1638,
290,
32,
1786,
1237,
476,
14,
957,
4335,
272,
446,
298,
1049,
5719,
869,
7130,
75,
685,
335,
84,
8593,
335,
7130,
75,
685,
335,
84,
2924,
272,
446,
298,
42,
14015,
377,
5161,
8593,
74,
319,
5161,
2924,
199,
2344,
199,
199,
8918,
275,
1449,
199,
199,
13,
536,
26,
5297,
1901,
22067,
15338,
523,
12424,
63,
2886,
26,
272,
3434,
26,
12424,
272,
2505,
26,
295,
75,
7889,
272,
3031,
26,
12424,
32,
9991,
14,
2308,
199,
199,
13,
536,
26,
5297,
1901,
5726,
7086,
436,
3542,
295,
13,
15846,
523,
12424,
63,
2886,
26,
272,
7086,
26,
2195,
14,
4239,
14,
5189,
14,
2308,
272,
3434,
26,
28225,
272,
2505,
26,
25563,
19,
272,
295,
14204,
26,
9456,
199,
199,
13,
536,
26,
5297,
1901,
22067,
15338,
1808,
282,
3537,
1101,
570,
523,
12424,
63,
2886,
26,
272,
3434,
26,
12424,
272,
2505,
26,
295,
75,
7889,
272,
3031,
26,
12424,
32,
9991,
14,
2308,
272,
1101,
63,
515,
26,
1182,
2791,
8083,
1662,
9991,
4128,
199,
199,
13,
536,
26,
5297,
734,
402,
22067,
15338,
523,
12424,
63,
2886,
26,
272,
1174,
26,
9552,
272,
3031,
26,
12424,
32,
9991,
14,
957,
199,
2344,
199,
199,
9677,
275,
1449,
199,
2886,
63,
2604,
26,
272,
1369,
26,
24288,
687,
314,
4676,
14,
272,
2138,
26,
1380,
1174,
534,
1881,
7,
272,
730,
26,
1211,
272,
2690,
26,
469,
267,
298,
2123,
582,
298,
396,
14262,
32,
27231,
14,
957,
401,
267,
298,
2060,
582,
298,
7041,
63,
22917,
19679,
63,
568,
63,
2826,
63,
4947,
63,
14472,
401,
267
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
334,
67,
9,
7800,
593,
416,
70,
1804,
1638,
290,
665,
393,
2756,
14,
75,
1638,
290,
32,
1786,
1237,
476,
14,
957,
30,
199,
3,
3515,
2799,
5719,
869,
7130,
75,
685,
335,
84,
12,
665,
6740,
32,
17164,
14,
957,
30,
199,
3,
3515,
1603,
14015,
377,
5161,
12,
665,
26002,
5161,
32,
17164,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
2622,
199,
3,
199,
3,
2622,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
199,
3,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
2622,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
199,
3,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
199,
3,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
199,
3,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
199,
3,
3180,
543,
2622,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
12424,
63,
2886,
199,
3612,
63,
1802,
26,
5297,
1901,
282,
22067,
7086,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
1802,
26,
272,
446,
21552,
9330,
8545,
370,
314,
298,
9991,
4676,
2,
1414,
14,
272,
446,
3590,
7672,
543,
282,
12424,
7086,
436,
1050,
314,
6235,
370,
2195,
2257,
22067,
1101,
570,
14,
12934,
314,
489,
6235,
370,
314,
1101,
1584,
6127,
6466,
6947,
370,
314,
7086,
1808,
7249,
4066,
465,
2622,
1159,
22067,
489,
4621,
12,
314,
22067,
14214,
436,
12424,
13,
647,
1928,
1929,
316,
370,
5647,
6235,
14,
272,
446,
26848,
315,
1104,
818,
911,
5147,
314,
6299,
1928,
12928,
314,
1101,
570,
14,
199,
1419,
26,
523,
7086,
63,
633,
26,
272,
1415,
26,
756,
272,
1369,
26,
489,
446,
710,
7086,
2851,
14,
272,
849,
26,
298,
2859,
921,
1080,
14,
9991,
14,
2308,
15,
86,
17,
6687,
272,
5481,
26,
489,
446,
7086,
489,
446,
1166,
523,
3434,
26,
272,
1369,
26,
489,
446,
710,
3434,
367,
314,
7086,
2933,
272,
1415,
26,
715,
523,
2505,
26,
272,
1369,
26,
489,
446,
710,
18577,
2505,
367,
314,
7086,
2933,
272,
1415,
26,
715,
523,
3031,
26,
272,
1415,
26,
756,
272,
1369,
26,
489,
446,
298,
1918,
3031,
2287,
367,
314,
7086,
2933,
14,
6944,
26,
5726,
25483,
1996,
1443,
440,
4409,
642,
12,
267,
1325,
22067,
869,
456,
5074,
652,
2122,
272,
849,
26,
488,
523,
295,
14204,
26,
272,
1415,
26,
756,
272,
1369,
26,
489,
446,
30345,
24234,
6299,
1911,
315,
314,
2897,
570,
14,
272,
849,
26,
949,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
272,
5481,
26,
489,
446,
295,
1178,
523,
1101,
63,
515,
26,
272,
1369,
26,
489,
446,
8388,
931,
370,
314,
22067,
14214,
2897,
570,
14,
272,
849,
26,
25975,
9991,
15,
888,
14,
1001,
272,
1415,
26,
756,
272,
5481,
26,
489,
446,
291,
14,
888,
63,
515,
489,
446,
12424,
4128,
63,
515,
523,
1174,
26,
272,
1015,
63,
3270,
26,
283,
18,
14,
19,
7,
272,
1369,
26,
489,
446,
961,
13467,
314,
1453,
1174,
402,
314,
922,
14,
445,
8,
1881,
9,
911,
4676,
315,
282,
922,
12,
445,
8,
5575,
9,
911,
943,
26457,
734,
14,
489,
446,
4005,
22079,
1265,
1454,
1929,
314,
7086,
1654,
12,
1314,
4243,
370,
22067,
15338,
14,
489,
446,
21467,
499,
14,
17,
1265,
4293,
5258,
6084,
943,
315,
14,
489,
446,
12424,
1630,
440,
2291,
283,
11646,
7,
543,
282,
3537,
1101,
570,
14,
272,
3415,
26,
788,
1881,
297,
283,
5575,
418,
272,
849,
26,
283,
1881,
7,
272,
1415,
26,
756,
199,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
12424,
199,
7538,
26,
272,
446,
298,
1548,
2356,
499,
14,
22,
2,
272,
446,
298,
9991,
13,
647,
2356,
413,
14,
23,
14,
16,
2,
272,
446,
298,
31463,
3261,
2356,
413,
14,
1165,
2,
272,
446,
283,
5903,
370,
506,
7688,
370,
22079,
334,
929,
29,
5575,
304,
314,
12424,
1414,
1004,
11420,
7,
199,
8149,
26,
272,
446,
298,
47,
416,
70,
1804,
1638,
290,
665,
393,
2756,
14,
75,
1638,
290,
32,
1786,
1237,
476,
14,
957,
4335,
272,
446,
298,
1049,
5719,
869,
7130,
75,
685,
335,
84,
8593,
335,
7130,
75,
685,
335,
84,
2924,
272,
446,
298,
42,
14015,
377,
5161,
8593,
74,
319,
5161,
2924,
199,
2344,
199,
199,
8918,
275,
1449,
199,
199,
13,
536,
26,
5297,
1901,
22067,
15338,
523,
12424,
63,
2886,
26,
272,
3434,
26,
12424,
272,
2505,
26,
295,
75,
7889,
272,
3031,
26,
12424,
32,
9991,
14,
2308,
199,
199,
13,
536,
26,
5297,
1901,
5726,
7086,
436,
3542,
295,
13,
15846,
523,
12424,
63,
2886,
26,
272,
7086,
26,
2195,
14,
4239,
14,
5189,
14,
2308,
272,
3434,
26,
28225,
272,
2505,
26,
25563,
19,
272,
295,
14204,
26,
9456,
199,
199,
13,
536,
26,
5297,
1901,
22067,
15338,
1808,
282,
3537,
1101,
570,
523,
12424,
63,
2886,
26,
272,
3434,
26,
12424,
272,
2505,
26,
295,
75,
7889,
272,
3031,
26,
12424,
32,
9991,
14,
2308,
272,
1101,
63,
515,
26,
1182,
2791,
8083,
1662,
9991,
4128,
199,
199,
13,
536,
26,
5297,
734,
402,
22067,
15338,
523,
12424,
63,
2886,
26,
272,
1174,
26,
9552,
272,
3031,
26,
12424,
32,
9991,
14,
957,
199,
2344,
199,
199,
9677,
275,
1449,
199,
2886,
63,
2604,
26,
272,
1369,
26,
24288,
687,
314,
4676,
14,
272,
2138,
26,
1380,
1174,
534,
1881,
7,
272,
730,
26,
1211,
272,
2690,
26,
469,
267,
298,
2123,
582,
298,
396,
14262,
32,
27231,
14,
957,
401,
267,
298,
2060,
582,
298,
7041,
63,
22917,
19679,
63,
568,
63,
2826,
63,
4947,
63,
14472,
401,
267,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Lingotek/filesystem-connector
|
python3/ltk/git_auto.py
|
2
|
3755
|
# Python 2
# from ConfigParser import ConfigParser, NoOptionError
# End Python 2
# Python 3
from configparser import ConfigParser, NoOptionError
# End Python 3
from ltk.constants import CONF_DIR, CONF_FN, SYSTEM_FILE, ERROR_FN
import sys
import os.path
import codecs
from git import Repo
from git import RemoteProgress
import os
try:
import pexpect
except: pass
import binascii
from ltk.utils import error
class Git_Auto:
def __init__(self, path):
self.path = path
self.join = os.path.join
self.repo_is_defined = False
self.repo_directory = ""
self.config_file_name, self.conf_parser = self.init_config_file()
def init_config_file(self):
config_file_name = os.path.join(self.path, CONF_DIR, CONF_FN)
conf_parser = ConfigParser()
conf_parser.read(config_file_name)
return config_file_name, conf_parser
def repo_exists(self, repo_directory=os.getcwd()):
while repo_directory and repo_directory != "" and not (os.path.isdir(repo_directory + os.sep+".git")):
repo_directory = repo_directory.split(os.sep)[:-1]
repo_directory = (os.sep).join(repo_directory)
if not repo_directory or repo_directory == "":
error("No Git repository found for the current directory.")
return False
else:
self.repo_directory = repo_directory
self.initialize_repo()
return True
def initialize_repo(self, directory=None):
if not directory:
self.repo = Repo(self.repo_directory)
else:
self.repo = Repo(directory)
self.repo_is_defined = True
def add_file(self, file_name):
if self.repo_is_defined:
if(self.repo_exists()):
self.repo.git.add(file_name)
def commit(self, message):
if self.repo_is_defined:
if(self.repo_exists()):
message.rstrip(' ')
self.repo.index.commit(message)
def encrypt(self, password):
# Python 2
# password = codecs.encode(password, 'base64')
# End Python 2
# Python 3
password = bytes(password, 'utf-8')
password = codecs.encode(password, 'base64')
password = str(password, 'utf-8')
# End Python 3
return password
def push(self, username=None, password=None):
username = self.conf_parser.get('main', 'git_username')
password = self.conf_parser.get('main', 'git_password')
if not self.repo_is_defined:
if not (self.repo_exists()):
error("No Git repository found for the current directory.")
return
try:
g = pexpect.spawnu('git push')
except:
try:
self.repo.git.push()
print("Push was successful")
except Exception as e:
error("Git push failed!")
print(type(e))
return
try:
g.logfile_read = sys.stdout
while True:
i = g.expect([u'Username for .*', u'Password for .*', pexpect.EOF])
if(i == 0):
g.send(username+'\n')
elif(i == 1):
# Python 2
# g.send(codecs.decode(password, 'base64')+'\n')
# End Python 2
# Python 3
g.send(str(codecs.decode(password.encode(), 'base64'), 'utf-8')+'\n')
# End Python 3
else:
break
except Exception as e:
print("Notice: Auto-credentials currently not operational")
'''
# if 'nt' not in os.name:
# g = pexpect.spawnu('git push')
# else:
# try:
# g = winpexpect.winspawn('git push')
# except:
# error("Push failed! Please confirm that the winpexpect module is up to date.")
# return
# g.logfile_read = sys.stdout
# if not username: username = ''
# if not password: password = ''
# while True:
# i = g.expect([u'Username for .*', u'Password for .*', pexpect.EOF])
# if(i == 0):
# g.send(username+'\n')
# elif(i == 1):
# # Python 2
# # g.send(codecs.decode(password, 'base64')+'\n')
# # End Python 2
# # Python 3
# g.send(str(codecs.decode(password.encode(), 'base64'), 'utf-8')+'\n')
# # End Python 3
# else:
# break
'''
|
mit
|
[
3,
2018,
499,
199,
3,
687,
14196,
492,
14196,
12,
3091,
16546,
199,
3,
9599,
2018,
499,
199,
3,
2018,
650,
199,
504,
21230,
492,
14196,
12,
3091,
16546,
199,
3,
9599,
2018,
650,
199,
504,
634,
2663,
14,
5559,
492,
6392,
63,
3022,
12,
6392,
63,
4963,
12,
20859,
63,
3817,
12,
12539,
63,
4963,
199,
646,
984,
199,
646,
747,
14,
515,
199,
646,
6010,
199,
504,
6135,
492,
20069,
199,
504,
6135,
492,
17283,
11504,
199,
646,
747,
199,
893,
26,
199,
198,
646,
28855,
199,
2590,
26,
986,
199,
646,
14755,
199,
504,
634,
2663,
14,
1208,
492,
1125,
199,
199,
533,
12579,
63,
3358,
26,
199,
198,
318,
636,
826,
721,
277,
12,
931,
304,
507,
198,
277,
14,
515,
275,
931,
507,
198,
277,
14,
904,
275,
747,
14,
515,
14,
904,
507,
198,
277,
14,
3417,
63,
374,
63,
4037,
275,
756,
507,
198,
277,
14,
3417,
63,
3619,
275,
3087,
507,
198,
277,
14,
888,
63,
493,
63,
354,
12,
291,
14,
2190,
63,
2087,
275,
291,
14,
826,
63,
888,
63,
493,
342,
421,
198,
318,
4205,
63,
888,
63,
493,
8,
277,
304,
507,
198,
888,
63,
493,
63,
354,
275,
747,
14,
515,
14,
904,
8,
277,
14,
515,
12,
6392,
63,
3022,
12,
6392,
63,
4963,
9,
507,
198,
2190,
63,
2087,
275,
14196,
342,
507,
198,
2190,
63,
2087,
14,
739,
8,
888,
63,
493,
63,
354,
9,
507,
198,
1107,
1101,
63,
493,
63,
354,
12,
3743,
63,
2087,
421,
198,
318,
3831,
63,
2444,
8,
277,
12,
3831,
63,
3619,
29,
736,
14,
9458,
5109,
507,
198,
6710,
3831,
63,
3619,
436,
3831,
63,
3619,
1137,
3087,
436,
440,
334,
736,
14,
515,
14,
6027,
8,
3417,
63,
3619,
435,
747,
14,
4127,
24878,
3187,
14150,
686,
198,
3417,
63,
3619,
275,
3831,
63,
3619,
14,
1294,
8,
736,
14,
4127,
31280,
17,
61,
686,
198,
3417,
63,
3619,
275,
334,
736,
14,
4127,
680,
904,
8,
3417,
63,
3619,
9,
507,
198,
692,
440,
3831,
63,
3619,
503,
3831,
63,
3619,
508,
10812,
686,
198,
705,
480,
1944,
12579,
7611,
1911,
367,
314,
1453,
2082,
2685,
686,
198,
1107,
756,
507,
198,
2836,
26,
686,
198,
277,
14,
3417,
63,
3619,
275,
3831,
63,
3619,
686,
198,
277,
14,
8489,
63,
3417,
342,
686,
198,
1107,
715,
421,
198,
318,
8265,
63,
3417,
8,
277,
12,
2082,
29,
403,
304,
507,
198,
692,
440,
2082,
26,
686,
198,
277,
14,
3417,
275,
20069,
8,
277,
14,
3417,
63,
3619,
9,
507,
198,
2836,
26,
686,
198,
277,
14,
3417,
275,
20069,
8,
3619,
9,
507,
198,
277,
14,
3417,
63,
374,
63,
4037,
275,
715,
421,
198,
318,
1050,
63,
493,
8,
277,
12,
570,
63,
354,
304,
507,
198,
692,
291,
14,
3417,
63,
374,
63,
4037,
26,
686,
198,
692,
8,
277,
14,
3417,
63,
2444,
5109,
1585,
198,
277,
14,
3417,
14,
3187,
14,
525,
8,
493,
63,
354,
9,
421,
198,
318,
5532,
8,
277,
12,
1245,
304,
507,
198,
692,
291,
14,
3417,
63,
374,
63,
4037,
26,
686,
198,
692,
8,
277,
14,
3417,
63,
2444,
5109,
1585,
198,
1188,
14,
6735,
360,
5320,
1585,
198,
277,
14,
3417,
14,
1080,
14,
3543,
8,
1188,
9,
421,
198,
318,
14645,
8,
277,
12,
2505,
304,
507,
198,
3,
2018,
499,
507,
198,
3,
2505,
275,
6010,
14,
2143,
8,
2060,
12,
283,
1095,
772,
358,
507,
198,
3,
9599,
2018,
499,
507,
198,
3,
2018,
650,
507,
198,
2060,
275,
2783,
8,
2060,
12,
283,
1624,
13,
24,
358,
507,
198,
2060,
275,
6010,
14,
2143,
8,
2060,
12,
283,
1095,
772,
358,
507,
198,
2060,
275,
620,
8,
2060,
12,
283,
1624,
13,
24,
358,
507,
198,
3,
9599,
2018,
650,
507,
198,
1107,
2505,
421,
198,
318,
6675,
8,
277,
12,
3434,
29,
403,
12,
2505,
29,
403,
304,
507,
198,
2473,
275,
291,
14,
2190,
63,
2087,
14,
362,
360,
973,
297,
283,
3187,
63,
2473,
358,
507,
198,
2060,
275,
291,
14,
2190,
63,
2087,
14,
362,
360,
973,
297,
283,
3187,
63,
2060,
358,
507,
198,
692,
440,
291,
14,
3417,
63,
374,
63,
4037,
26,
686,
198,
692,
440,
334,
277,
14,
3417,
63,
2444,
5109,
1585,
198,
705,
480,
1944,
12579,
7611,
1911,
367,
314,
1453,
2082,
2685,
1585,
198,
1107,
507,
198,
893,
26,
686,
198,
71,
275,
28855,
14,
10212,
85,
360,
3187,
6675,
358,
507,
198,
2590,
26,
686,
198,
893,
26,
1585,
198,
277,
14,
3417,
14,
3187,
14,
5335,
342,
1585,
198,
1361,
480,
10731,
1990,
9512,
531,
686,
198,
2590,
2186,
465,
325,
26,
1585,
198,
705,
480,
14686,
6675,
3405,
9124,
1585,
198,
1361,
8,
466,
8,
69,
430,
686,
198,
1107,
507,
198,
893,
26,
686,
198,
71,
14,
12804,
63,
739,
275,
984,
14,
2703,
686,
198,
6710,
715,
26,
1585,
198,
73,
275,
486,
14,
4921,
779,
85,
7,
13355,
367,
1275,
7693,
399,
7,
6139,
367,
1275,
7693,
28855,
14,
13178,
566,
1585,
198,
692,
8,
73,
508,
378,
304,
1871,
198,
71,
14,
2254,
8,
2473,
19192,
78,
358,
1585,
198,
4164,
8,
73,
508,
413,
304,
1871,
198,
3,
2018,
499,
1871,
198,
3,
486,
14,
2254,
8,
8933,
14,
2708,
8,
2060,
12,
283,
1095,
772,
358,
19192,
78,
358,
1871,
198,
3,
9599,
2018,
499,
1871,
198,
3,
2018,
650,
1871,
198,
71,
14,
2254,
8,
495,
8,
8933,
14,
2708,
8,
2060,
14,
2143,
1062,
283,
1095,
772,
659,
283,
1624,
13,
24,
358,
19192,
78,
358,
1871,
198,
3,
9599,
2018,
650,
1585,
198,
2836,
26,
1871,
198,
4785,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
1361,
480,
1944,
3548,
26,
9195,
13,
6942,
5544,
440,
3439,
279,
531,
507,
198,
2344,
507,
198,
3,
340,
283,
343,
7,
440,
315,
747,
14,
354,
26,
507,
198,
3,
221,
198,
71,
275,
28855,
14,
10212,
85,
360,
3187,
6675,
358,
507,
198,
3,
587,
26,
507,
198,
3,
221,
198,
893,
26,
507,
198,
3,
22427,
198,
71,
275,
4747,
16531,
1764,
14,
2676,
10212,
360
] |
[
2018,
499,
199,
3,
687,
14196,
492,
14196,
12,
3091,
16546,
199,
3,
9599,
2018,
499,
199,
3,
2018,
650,
199,
504,
21230,
492,
14196,
12,
3091,
16546,
199,
3,
9599,
2018,
650,
199,
504,
634,
2663,
14,
5559,
492,
6392,
63,
3022,
12,
6392,
63,
4963,
12,
20859,
63,
3817,
12,
12539,
63,
4963,
199,
646,
984,
199,
646,
747,
14,
515,
199,
646,
6010,
199,
504,
6135,
492,
20069,
199,
504,
6135,
492,
17283,
11504,
199,
646,
747,
199,
893,
26,
199,
198,
646,
28855,
199,
2590,
26,
986,
199,
646,
14755,
199,
504,
634,
2663,
14,
1208,
492,
1125,
199,
199,
533,
12579,
63,
3358,
26,
199,
198,
318,
636,
826,
721,
277,
12,
931,
304,
507,
198,
277,
14,
515,
275,
931,
507,
198,
277,
14,
904,
275,
747,
14,
515,
14,
904,
507,
198,
277,
14,
3417,
63,
374,
63,
4037,
275,
756,
507,
198,
277,
14,
3417,
63,
3619,
275,
3087,
507,
198,
277,
14,
888,
63,
493,
63,
354,
12,
291,
14,
2190,
63,
2087,
275,
291,
14,
826,
63,
888,
63,
493,
342,
421,
198,
318,
4205,
63,
888,
63,
493,
8,
277,
304,
507,
198,
888,
63,
493,
63,
354,
275,
747,
14,
515,
14,
904,
8,
277,
14,
515,
12,
6392,
63,
3022,
12,
6392,
63,
4963,
9,
507,
198,
2190,
63,
2087,
275,
14196,
342,
507,
198,
2190,
63,
2087,
14,
739,
8,
888,
63,
493,
63,
354,
9,
507,
198,
1107,
1101,
63,
493,
63,
354,
12,
3743,
63,
2087,
421,
198,
318,
3831,
63,
2444,
8,
277,
12,
3831,
63,
3619,
29,
736,
14,
9458,
5109,
507,
198,
6710,
3831,
63,
3619,
436,
3831,
63,
3619,
1137,
3087,
436,
440,
334,
736,
14,
515,
14,
6027,
8,
3417,
63,
3619,
435,
747,
14,
4127,
24878,
3187,
14150,
686,
198,
3417,
63,
3619,
275,
3831,
63,
3619,
14,
1294,
8,
736,
14,
4127,
31280,
17,
61,
686,
198,
3417,
63,
3619,
275,
334,
736,
14,
4127,
680,
904,
8,
3417,
63,
3619,
9,
507,
198,
692,
440,
3831,
63,
3619,
503,
3831,
63,
3619,
508,
10812,
686,
198,
705,
480,
1944,
12579,
7611,
1911,
367,
314,
1453,
2082,
2685,
686,
198,
1107,
756,
507,
198,
2836,
26,
686,
198,
277,
14,
3417,
63,
3619,
275,
3831,
63,
3619,
686,
198,
277,
14,
8489,
63,
3417,
342,
686,
198,
1107,
715,
421,
198,
318,
8265,
63,
3417,
8,
277,
12,
2082,
29,
403,
304,
507,
198,
692,
440,
2082,
26,
686,
198,
277,
14,
3417,
275,
20069,
8,
277,
14,
3417,
63,
3619,
9,
507,
198,
2836,
26,
686,
198,
277,
14,
3417,
275,
20069,
8,
3619,
9,
507,
198,
277,
14,
3417,
63,
374,
63,
4037,
275,
715,
421,
198,
318,
1050,
63,
493,
8,
277,
12,
570,
63,
354,
304,
507,
198,
692,
291,
14,
3417,
63,
374,
63,
4037,
26,
686,
198,
692,
8,
277,
14,
3417,
63,
2444,
5109,
1585,
198,
277,
14,
3417,
14,
3187,
14,
525,
8,
493,
63,
354,
9,
421,
198,
318,
5532,
8,
277,
12,
1245,
304,
507,
198,
692,
291,
14,
3417,
63,
374,
63,
4037,
26,
686,
198,
692,
8,
277,
14,
3417,
63,
2444,
5109,
1585,
198,
1188,
14,
6735,
360,
5320,
1585,
198,
277,
14,
3417,
14,
1080,
14,
3543,
8,
1188,
9,
421,
198,
318,
14645,
8,
277,
12,
2505,
304,
507,
198,
3,
2018,
499,
507,
198,
3,
2505,
275,
6010,
14,
2143,
8,
2060,
12,
283,
1095,
772,
358,
507,
198,
3,
9599,
2018,
499,
507,
198,
3,
2018,
650,
507,
198,
2060,
275,
2783,
8,
2060,
12,
283,
1624,
13,
24,
358,
507,
198,
2060,
275,
6010,
14,
2143,
8,
2060,
12,
283,
1095,
772,
358,
507,
198,
2060,
275,
620,
8,
2060,
12,
283,
1624,
13,
24,
358,
507,
198,
3,
9599,
2018,
650,
507,
198,
1107,
2505,
421,
198,
318,
6675,
8,
277,
12,
3434,
29,
403,
12,
2505,
29,
403,
304,
507,
198,
2473,
275,
291,
14,
2190,
63,
2087,
14,
362,
360,
973,
297,
283,
3187,
63,
2473,
358,
507,
198,
2060,
275,
291,
14,
2190,
63,
2087,
14,
362,
360,
973,
297,
283,
3187,
63,
2060,
358,
507,
198,
692,
440,
291,
14,
3417,
63,
374,
63,
4037,
26,
686,
198,
692,
440,
334,
277,
14,
3417,
63,
2444,
5109,
1585,
198,
705,
480,
1944,
12579,
7611,
1911,
367,
314,
1453,
2082,
2685,
1585,
198,
1107,
507,
198,
893,
26,
686,
198,
71,
275,
28855,
14,
10212,
85,
360,
3187,
6675,
358,
507,
198,
2590,
26,
686,
198,
893,
26,
1585,
198,
277,
14,
3417,
14,
3187,
14,
5335,
342,
1585,
198,
1361,
480,
10731,
1990,
9512,
531,
686,
198,
2590,
2186,
465,
325,
26,
1585,
198,
705,
480,
14686,
6675,
3405,
9124,
1585,
198,
1361,
8,
466,
8,
69,
430,
686,
198,
1107,
507,
198,
893,
26,
686,
198,
71,
14,
12804,
63,
739,
275,
984,
14,
2703,
686,
198,
6710,
715,
26,
1585,
198,
73,
275,
486,
14,
4921,
779,
85,
7,
13355,
367,
1275,
7693,
399,
7,
6139,
367,
1275,
7693,
28855,
14,
13178,
566,
1585,
198,
692,
8,
73,
508,
378,
304,
1871,
198,
71,
14,
2254,
8,
2473,
19192,
78,
358,
1585,
198,
4164,
8,
73,
508,
413,
304,
1871,
198,
3,
2018,
499,
1871,
198,
3,
486,
14,
2254,
8,
8933,
14,
2708,
8,
2060,
12,
283,
1095,
772,
358,
19192,
78,
358,
1871,
198,
3,
9599,
2018,
499,
1871,
198,
3,
2018,
650,
1871,
198,
71,
14,
2254,
8,
495,
8,
8933,
14,
2708,
8,
2060,
14,
2143,
1062,
283,
1095,
772,
659,
283,
1624,
13,
24,
358,
19192,
78,
358,
1871,
198,
3,
9599,
2018,
650,
1585,
198,
2836,
26,
1871,
198,
4785,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
1361,
480,
1944,
3548,
26,
9195,
13,
6942,
5544,
440,
3439,
279,
531,
507,
198,
2344,
507,
198,
3,
340,
283,
343,
7,
440,
315,
747,
14,
354,
26,
507,
198,
3,
221,
198,
71,
275,
28855,
14,
10212,
85,
360,
3187,
6675,
358,
507,
198,
3,
587,
26,
507,
198,
3,
221,
198,
893,
26,
507,
198,
3,
22427,
198,
71,
275,
4747,
16531,
1764,
14,
2676,
10212,
360,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
arnedesmedt/dotfiles
|
.config/sublime-text-3/Packages.symlinkfollow/python-markdown/st3/markdown/extensions/wikilinks.py
|
123
|
2872
|
'''
WikiLinks Extension for Python-Markdown
======================================
Converts [[WikiLinks]] to relative links.
See <https://pythonhosted.org/Markdown/extensions/wikilinks.html>
for documentation.
Original code Copyright [Waylan Limberg](http://achinghead.com/).
All changes Copyright The Python Markdown Project
License: [BSD](http://www.opensource.org/licenses/bsd-license.php)
'''
from __future__ import absolute_import
from __future__ import unicode_literals
from . import Extension
from ..inlinepatterns import Pattern
from ..util import etree
import re
def build_url(label, base, end):
""" Build a url from the label, a base, and an end. """
clean_label = re.sub(r'([ ]+_)|(_[ ]+)|([ ]+)', '_', label)
return '%s%s%s' % (base, clean_label, end)
class WikiLinkExtension(Extension):
def __init__(self, *args, **kwargs):
self.config = {
'base_url': ['/', 'String to append to beginning or URL.'],
'end_url': ['/', 'String to append to end of URL.'],
'html_class': ['wikilink', 'CSS hook. Leave blank for none.'],
'build_url': [build_url, 'Callable formats URL from label.'],
}
super(WikiLinkExtension, self).__init__(*args, **kwargs)
def extendMarkdown(self, md, md_globals):
self.md = md
# append to end of inline patterns
WIKILINK_RE = r'\[\[([\w0-9_ -]+)\]\]'
wikilinkPattern = WikiLinks(WIKILINK_RE, self.getConfigs())
wikilinkPattern.md = md
md.inlinePatterns.add('wikilink', wikilinkPattern, "<not_strong")
class WikiLinks(Pattern):
def __init__(self, pattern, config):
super(WikiLinks, self).__init__(pattern)
self.config = config
def handleMatch(self, m):
if m.group(2).strip():
base_url, end_url, html_class = self._getMeta()
label = m.group(2).strip()
url = self.config['build_url'](label, base_url, end_url)
a = etree.Element('a')
a.text = label
a.set('href', url)
if html_class:
a.set('class', html_class)
else:
a = ''
return a
def _getMeta(self):
""" Return meta data or config data. """
base_url = self.config['base_url']
end_url = self.config['end_url']
html_class = self.config['html_class']
if hasattr(self.md, 'Meta'):
if 'wiki_base_url' in self.md.Meta:
base_url = self.md.Meta['wiki_base_url'][0]
if 'wiki_end_url' in self.md.Meta:
end_url = self.md.Meta['wiki_end_url'][0]
if 'wiki_html_class' in self.md.Meta:
html_class = self.md.Meta['wiki_html_class'][0]
return base_url, end_url, html_class
def makeExtension(*args, **kwargs):
return WikiLinkExtension(*args, **kwargs)
|
mit
|
[
2344,
199,
26198,
16974,
13282,
367,
2018,
13,
30916,
199,
2486,
23476,
199,
199,
17729,
3474,
26198,
16974,
2677,
370,
3847,
6220,
14,
199,
199,
9295,
665,
2859,
921,
1548,
24127,
14,
1308,
15,
30916,
15,
5359,
15,
5319,
382,
2292,
83,
14,
1360,
30,
199,
509,
3794,
14,
199,
199,
17286,
1233,
1898,
359,
25544,
1502,
24157,
976,
71,
8738,
1014,
921,
23302,
2993,
14,
957,
15,
680,
199,
199,
2422,
4493,
1898,
710,
2018,
24537,
7290,
199,
199,
3761,
26,
359,
15400,
8738,
1014,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
15746,
13,
1682,
14,
8624,
9,
199,
199,
2344,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
1275,
492,
13282,
199,
504,
2508,
6460,
7435,
492,
27019,
199,
504,
2508,
1974,
492,
7559,
199,
646,
295,
421,
199,
318,
1900,
63,
633,
8,
1302,
12,
1300,
12,
1284,
304,
272,
408,
6516,
282,
1166,
687,
314,
1768,
12,
282,
1300,
12,
436,
376,
1284,
14,
408,
272,
3633,
63,
1302,
275,
295,
14,
954,
8,
82,
21731,
1622,
11,
4602,
92,
1547,
59,
1622,
11,
8636,
779,
1622,
14705,
25469,
1768,
9,
272,
372,
1543,
83,
5,
83,
5,
83,
7,
450,
334,
1095,
12,
3633,
63,
1302,
12,
1284,
9,
421,
199,
533,
644,
11545,
3834,
6382,
8,
6382,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
888,
275,
469,
288,
283,
1095,
63,
633,
356,
788,
3678,
283,
1558,
370,
5666,
370,
9608,
503,
2851,
14,
995,
288,
283,
500,
63,
633,
356,
788,
3678,
283,
1558,
370,
5666,
370,
1284,
402,
2851,
14,
995,
288,
283,
1360,
63,
533,
356,
788,
5319,
382,
2292,
297,
283,
14391,
5759,
14,
28015,
4596,
367,
7179,
14,
995,
288,
283,
1506,
63,
633,
356,
359,
1506,
63,
633,
12,
283,
16410,
6752,
2851,
687,
1768,
14,
995,
267,
789,
398,
1613,
8,
26198,
3834,
6382,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
12247,
30916,
8,
277,
12,
6128,
12,
6128,
63,
8473,
304,
267,
291,
14,
1064,
275,
6128,
398,
327,
5666,
370,
1284,
402,
8308,
7970,
267,
644,
41,
43,
1193,
12394,
63,
907,
275,
519,
1154,
7023,
59,
16510,
87,
16,
13,
25,
63,
446,
18096,
7272,
6616,
267,
336,
3258,
382,
2292,
9959,
275,
644,
11545,
16974,
8,
18759,
43,
1193,
12394,
63,
907,
12,
291,
14,
362,
29123,
1012,
267,
336,
3258,
382,
2292,
9959,
14,
1064,
275,
6128,
267,
6128,
14,
6460,
25662,
14,
525,
360,
5319,
382,
2292,
297,
336,
3258,
382,
2292,
9959,
12,
3886,
1397,
63,
9370,
531,
421,
199,
533,
644,
11545,
16974,
8,
9959,
304,
272,
347,
636,
826,
721,
277,
12,
3851,
12,
1101,
304,
267,
1613,
8,
26198,
16974,
12,
291,
2843,
826,
721,
3401,
9,
267,
291,
14,
888,
275,
1101,
339,
347,
2429,
4486,
8,
277,
12,
333,
304,
267,
340,
333,
14,
923,
8,
18,
680,
1913,
837,
288,
1300,
63,
633,
12,
1284,
63,
633,
12,
3517,
63,
533,
275,
291,
423,
362,
3396,
342,
288,
1768,
275,
333,
14,
923,
8,
18,
680,
1913,
342,
288,
1166,
275,
291,
14,
888,
459,
1506,
63,
633,
21407,
1302,
12,
1300,
63,
633,
12,
1284,
63,
633,
9,
288,
282,
275,
7559,
14,
2162,
360,
65,
358,
288,
282,
14,
505,
275,
1768,
288,
282,
14,
409,
360,
6399,
297,
1166,
9,
288,
340,
3517,
63,
533,
26,
355,
282,
14,
409,
360,
533,
297,
3517,
63,
533,
9,
267,
587,
26,
288,
282,
275,
2125,
267,
372,
282,
339,
347,
485,
362,
3396,
8,
277,
304,
267,
408,
1432,
3404,
666,
503,
1101,
666,
14,
408,
267,
1300,
63,
633,
275,
291,
14,
888,
459,
1095,
63,
633,
418,
267,
1284,
63,
633,
275,
291,
14,
888,
459,
500,
63,
633,
418,
267,
3517,
63,
533,
275,
291,
14,
888,
459,
1360,
63,
533,
418,
267,
340,
2688,
8,
277,
14,
1064,
12,
283,
3396,
735,
288,
340,
283,
6797,
63,
1095,
63,
633,
7,
315,
291,
14,
1064,
14,
3396,
26,
355,
1300,
63,
633,
275,
291,
14,
1064,
14,
3396,
459,
6797,
63,
1095,
63,
633,
3488,
16,
61,
288,
340,
283,
6797,
63,
500,
63,
633,
7,
315,
291,
14,
1064,
14,
3396,
26,
355,
1284,
63,
633,
275,
291,
14,
1064,
14,
3396,
459,
6797,
63,
500,
63,
633,
3488,
16,
61,
288,
340,
283,
6797,
63,
1360,
63,
533,
7,
315,
291,
14,
1064,
14,
3396,
26,
355,
3517,
63,
533,
275,
291,
14,
1064,
14,
3396,
459,
6797,
63,
1360,
63,
533,
3488,
16,
61,
267,
372,
1300,
63,
633,
12,
1284,
63,
633,
12,
3517,
63,
533,
421,
199,
318,
1852,
6382,
2031,
589,
12,
1011,
958,
304,
272,
372,
644,
11545,
3834,
6382,
2031,
589,
12,
1011,
958,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
26198,
16974,
13282,
367,
2018,
13,
30916,
199,
2486,
23476,
199,
199,
17729,
3474,
26198,
16974,
2677,
370,
3847,
6220,
14,
199,
199,
9295,
665,
2859,
921,
1548,
24127,
14,
1308,
15,
30916,
15,
5359,
15,
5319,
382,
2292,
83,
14,
1360,
30,
199,
509,
3794,
14,
199,
199,
17286,
1233,
1898,
359,
25544,
1502,
24157,
976,
71,
8738,
1014,
921,
23302,
2993,
14,
957,
15,
680,
199,
199,
2422,
4493,
1898,
710,
2018,
24537,
7290,
199,
199,
3761,
26,
359,
15400,
8738,
1014,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
15746,
13,
1682,
14,
8624,
9,
199,
199,
2344,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
504,
1275,
492,
13282,
199,
504,
2508,
6460,
7435,
492,
27019,
199,
504,
2508,
1974,
492,
7559,
199,
646,
295,
421,
199,
318,
1900,
63,
633,
8,
1302,
12,
1300,
12,
1284,
304,
272,
408,
6516,
282,
1166,
687,
314,
1768,
12,
282,
1300,
12,
436,
376,
1284,
14,
408,
272,
3633,
63,
1302,
275,
295,
14,
954,
8,
82,
21731,
1622,
11,
4602,
92,
1547,
59,
1622,
11,
8636,
779,
1622,
14705,
25469,
1768,
9,
272,
372,
1543,
83,
5,
83,
5,
83,
7,
450,
334,
1095,
12,
3633,
63,
1302,
12,
1284,
9,
421,
199,
533,
644,
11545,
3834,
6382,
8,
6382,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
291,
14,
888,
275,
469,
288,
283,
1095,
63,
633,
356,
788,
3678,
283,
1558,
370,
5666,
370,
9608,
503,
2851,
14,
995,
288,
283,
500,
63,
633,
356,
788,
3678,
283,
1558,
370,
5666,
370,
1284,
402,
2851,
14,
995,
288,
283,
1360,
63,
533,
356,
788,
5319,
382,
2292,
297,
283,
14391,
5759,
14,
28015,
4596,
367,
7179,
14,
995,
288,
283,
1506,
63,
633,
356,
359,
1506,
63,
633,
12,
283,
16410,
6752,
2851,
687,
1768,
14,
995,
267,
789,
398,
1613,
8,
26198,
3834,
6382,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
339,
347,
12247,
30916,
8,
277,
12,
6128,
12,
6128,
63,
8473,
304,
267,
291,
14,
1064,
275,
6128,
398,
327,
5666,
370,
1284,
402,
8308,
7970,
267,
644,
41,
43,
1193,
12394,
63,
907,
275,
519,
1154,
7023,
59,
16510,
87,
16,
13,
25,
63,
446,
18096,
7272,
6616,
267,
336,
3258,
382,
2292,
9959,
275,
644,
11545,
16974,
8,
18759,
43,
1193,
12394,
63,
907,
12,
291,
14,
362,
29123,
1012,
267,
336,
3258,
382,
2292,
9959,
14,
1064,
275,
6128,
267,
6128,
14,
6460,
25662,
14,
525,
360,
5319,
382,
2292,
297,
336,
3258,
382,
2292,
9959,
12,
3886,
1397,
63,
9370,
531,
421,
199,
533,
644,
11545,
16974,
8,
9959,
304,
272,
347,
636,
826,
721,
277,
12,
3851,
12,
1101,
304,
267,
1613,
8,
26198,
16974,
12,
291,
2843,
826,
721,
3401,
9,
267,
291,
14,
888,
275,
1101,
339,
347,
2429,
4486,
8,
277,
12,
333,
304,
267,
340,
333,
14,
923,
8,
18,
680,
1913,
837,
288,
1300,
63,
633,
12,
1284,
63,
633,
12,
3517,
63,
533,
275,
291,
423,
362,
3396,
342,
288,
1768,
275,
333,
14,
923,
8,
18,
680,
1913,
342,
288,
1166,
275,
291,
14,
888,
459,
1506,
63,
633,
21407,
1302,
12,
1300,
63,
633,
12,
1284,
63,
633,
9,
288,
282,
275,
7559,
14,
2162,
360,
65,
358,
288,
282,
14,
505,
275,
1768,
288,
282,
14,
409,
360,
6399,
297,
1166,
9,
288,
340,
3517,
63,
533,
26,
355,
282,
14,
409,
360,
533,
297,
3517,
63,
533,
9,
267,
587,
26,
288,
282,
275,
2125,
267,
372,
282,
339,
347,
485,
362,
3396,
8,
277,
304,
267,
408,
1432,
3404,
666,
503,
1101,
666,
14,
408,
267,
1300,
63,
633,
275,
291,
14,
888,
459,
1095,
63,
633,
418,
267,
1284,
63,
633,
275,
291,
14,
888,
459,
500,
63,
633,
418,
267,
3517,
63,
533,
275,
291,
14,
888,
459,
1360,
63,
533,
418,
267,
340,
2688,
8,
277,
14,
1064,
12,
283,
3396,
735,
288,
340,
283,
6797,
63,
1095,
63,
633,
7,
315,
291,
14,
1064,
14,
3396,
26,
355,
1300,
63,
633,
275,
291,
14,
1064,
14,
3396,
459,
6797,
63,
1095,
63,
633,
3488,
16,
61,
288,
340,
283,
6797,
63,
500,
63,
633,
7,
315,
291,
14,
1064,
14,
3396,
26,
355,
1284,
63,
633,
275,
291,
14,
1064,
14,
3396,
459,
6797,
63,
500,
63,
633,
3488,
16,
61,
288,
340,
283,
6797,
63,
1360,
63,
533,
7,
315,
291,
14,
1064,
14,
3396,
26,
355,
3517,
63,
533,
275,
291,
14,
1064,
14,
3396,
459,
6797,
63,
1360,
63,
533,
3488,
16,
61,
267,
372,
1300,
63,
633,
12,
1284,
63,
633,
12,
3517,
63,
533,
421,
199,
318,
1852,
6382,
2031,
589,
12,
1011,
958,
304,
272,
372,
644,
11545,
3834,
6382,
2031,
589,
12,
1011,
958,
9,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
anntzer/scikit-learn
|
sklearn/ensemble/__init__.py
|
12
|
1655
|
"""
The :mod:`sklearn.ensemble` module includes ensemble-based methods for
classification, regression and anomaly detection.
"""
import typing
from ._base import BaseEnsemble
from ._forest import RandomForestClassifier
from ._forest import RandomForestRegressor
from ._forest import RandomTreesEmbedding
from ._forest import ExtraTreesClassifier
from ._forest import ExtraTreesRegressor
from ._bagging import BaggingClassifier
from ._bagging import BaggingRegressor
from ._iforest import IsolationForest
from ._weight_boosting import AdaBoostClassifier
from ._weight_boosting import AdaBoostRegressor
from ._gb import GradientBoostingClassifier
from ._gb import GradientBoostingRegressor
from ._voting import VotingClassifier
from ._voting import VotingRegressor
from ._stacking import StackingClassifier
from ._stacking import StackingRegressor
if typing.TYPE_CHECKING:
# Avoid errors in type checkers (e.g. mypy) for experimental estimators.
# TODO: remove this check once the estimator is no longer experimental.
from ._hist_gradient_boosting.gradient_boosting import ( # noqa
HistGradientBoostingRegressor, HistGradientBoostingClassifier
)
__all__ = ["BaseEnsemble",
"RandomForestClassifier", "RandomForestRegressor",
"RandomTreesEmbedding", "ExtraTreesClassifier",
"ExtraTreesRegressor", "BaggingClassifier",
"BaggingRegressor", "IsolationForest", "GradientBoostingClassifier",
"GradientBoostingRegressor", "AdaBoostClassifier",
"AdaBoostRegressor", "VotingClassifier", "VotingRegressor",
"StackingClassifier", "StackingRegressor",
]
|
bsd-3-clause
|
[
624,
199,
1918,
520,
1494,
1705,
27993,
14,
15628,
64,
859,
6952,
19965,
13,
6788,
3102,
367,
199,
14368,
12,
10864,
436,
28813,
15212,
14,
199,
624,
199,
646,
14090,
199,
199,
504,
13653,
1095,
492,
3523,
1327,
8834,
199,
504,
13653,
25736,
492,
9571,
21668,
8508,
199,
504,
13653,
25736,
492,
9571,
21668,
15155,
199,
504,
13653,
25736,
492,
9571,
28785,
27907,
199,
504,
13653,
25736,
492,
11177,
28785,
8508,
199,
504,
13653,
25736,
492,
11177,
28785,
15155,
199,
504,
13653,
19430,
1540,
492,
699,
643,
1540,
8508,
199,
504,
13653,
19430,
1540,
492,
699,
643,
1540,
15155,
199,
504,
13653,
73,
25736,
492,
6596,
10410,
21668,
199,
504,
13653,
3463,
63,
15589,
316,
492,
437,
983,
18814,
8508,
199,
504,
13653,
3463,
63,
15589,
316,
492,
437,
983,
18814,
15155,
199,
504,
13653,
4908,
492,
19603,
27175,
8508,
199,
504,
13653,
4908,
492,
19603,
27175,
15155,
199,
504,
13653,
86,
15866,
492,
812,
15866,
8508,
199,
504,
13653,
86,
15866,
492,
812,
15866,
15155,
199,
504,
13653,
2340,
316,
492,
13894,
316,
8508,
199,
504,
13653,
2340,
316,
492,
13894,
316,
15155,
199,
199,
692,
14090,
14,
2711,
63,
8936,
1206,
26,
272,
327,
19503,
2552,
315,
730,
1104,
1192,
334,
69,
14,
71,
14,
3002,
647,
9,
367,
22820,
23155,
14,
272,
327,
3254,
26,
2813,
642,
1104,
5403,
314,
8943,
365,
949,
8088,
22820,
14,
272,
687,
13653,
11141,
63,
7490,
63,
15589,
316,
14,
7490,
63,
15589,
316,
492,
334,
221,
327,
8151,
267,
869,
631,
9942,
27175,
15155,
12,
869,
631,
9942,
27175,
8508,
272,
776,
199,
199,
363,
452,
363,
275,
2097,
1563,
1327,
8834,
401,
1779,
298,
3883,
21668,
8508,
401,
298,
3883,
21668,
15155,
401,
1779,
298,
3883,
28785,
27907,
401,
298,
7426,
28785,
8508,
401,
1779,
298,
7426,
28785,
15155,
401,
298,
31641,
1540,
8508,
401,
1779,
298,
31641,
1540,
15155,
401,
298,
1831,
10410,
21668,
401,
298,
9942,
27175,
8508,
401,
1779,
298,
9942,
27175,
15155,
401,
298,
33,
983,
18814,
8508,
401,
1779,
298,
33,
983,
18814,
15155,
401,
298,
54,
15866,
8508,
401,
298,
54,
15866,
15155,
401,
1779,
298,
4851,
316,
8508,
401,
298,
4851,
316,
15155,
401,
1779,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
1918,
520,
1494,
1705,
27993,
14,
15628,
64,
859,
6952,
19965,
13,
6788,
3102,
367,
199,
14368,
12,
10864,
436,
28813,
15212,
14,
199,
624,
199,
646,
14090,
199,
199,
504,
13653,
1095,
492,
3523,
1327,
8834,
199,
504,
13653,
25736,
492,
9571,
21668,
8508,
199,
504,
13653,
25736,
492,
9571,
21668,
15155,
199,
504,
13653,
25736,
492,
9571,
28785,
27907,
199,
504,
13653,
25736,
492,
11177,
28785,
8508,
199,
504,
13653,
25736,
492,
11177,
28785,
15155,
199,
504,
13653,
19430,
1540,
492,
699,
643,
1540,
8508,
199,
504,
13653,
19430,
1540,
492,
699,
643,
1540,
15155,
199,
504,
13653,
73,
25736,
492,
6596,
10410,
21668,
199,
504,
13653,
3463,
63,
15589,
316,
492,
437,
983,
18814,
8508,
199,
504,
13653,
3463,
63,
15589,
316,
492,
437,
983,
18814,
15155,
199,
504,
13653,
4908,
492,
19603,
27175,
8508,
199,
504,
13653,
4908,
492,
19603,
27175,
15155,
199,
504,
13653,
86,
15866,
492,
812,
15866,
8508,
199,
504,
13653,
86,
15866,
492,
812,
15866,
15155,
199,
504,
13653,
2340,
316,
492,
13894,
316,
8508,
199,
504,
13653,
2340,
316,
492,
13894,
316,
15155,
199,
199,
692,
14090,
14,
2711,
63,
8936,
1206,
26,
272,
327,
19503,
2552,
315,
730,
1104,
1192,
334,
69,
14,
71,
14,
3002,
647,
9,
367,
22820,
23155,
14,
272,
327,
3254,
26,
2813,
642,
1104,
5403,
314,
8943,
365,
949,
8088,
22820,
14,
272,
687,
13653,
11141,
63,
7490,
63,
15589,
316,
14,
7490,
63,
15589,
316,
492,
334,
221,
327,
8151,
267,
869,
631,
9942,
27175,
15155,
12,
869,
631,
9942,
27175,
8508,
272,
776,
199,
199,
363,
452,
363,
275,
2097,
1563,
1327,
8834,
401,
1779,
298,
3883,
21668,
8508,
401,
298,
3883,
21668,
15155,
401,
1779,
298,
3883,
28785,
27907,
401,
298,
7426,
28785,
8508,
401,
1779,
298,
7426,
28785,
15155,
401,
298,
31641,
1540,
8508,
401,
1779,
298,
31641,
1540,
15155,
401,
298,
1831,
10410,
21668,
401,
298,
9942,
27175,
8508,
401,
1779,
298,
9942,
27175,
15155,
401,
298,
33,
983,
18814,
8508,
401,
1779,
298,
33,
983,
18814,
15155,
401,
298,
54,
15866,
8508,
401,
298,
54,
15866,
15155,
401,
1779,
298,
4851,
316,
8508,
401,
298,
4851,
316,
15155,
401,
1779,
1622,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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to verify SSL certificates in Python 2. Note, the default libraries do
*not* do certificate checking; you need to do additional work to validate
certificates yourself.
This needs the following packages installed:
* pyOpenSSL (tested with 0.13)
* ndg-httpsclient (tested with 0.3.2)
* pyasn1 (tested with 0.1.6)
You can install them with the following command:
pip install pyopenssl ndg-httpsclient pyasn1
To activate certificate checking, call
:func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code
before you begin making HTTP requests. This can be done in a ``sitecustomize``
module, or at any other time before your application begins using ``urllib3``,
like this::
try:
import urllib3.contrib.pyopenssl
urllib3.contrib.pyopenssl.inject_into_urllib3()
except ImportError:
pass
Now you can use :mod:`urllib3` as you normally would, and it will support SNI
when the required modules are installed.
Activating this module also has the positive side effect of disabling SSL/TLS
encryption in Python 2 (see `CRIME attack`_).
If you want to configure the default list of supported cipher suites, you can
set the ``urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST`` variable.
Module Variables
----------------
:var DEFAULT_SSL_CIPHER_LIST: The list of supported SSL/TLS cipher suites.
Default: ``ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:
ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS``
.. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication
.. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit)
'''
from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT
from ndg.httpsclient.subj_alt_name import SubjectAltName as BaseSubjectAltName
import OpenSSL.SSL
from pyasn1.codec.der import decoder as der_decoder
from pyasn1.type import univ, constraint
from socket import _fileobject, timeout
import ssl
import select
from cStringIO import StringIO
from .. import connection
from .. import util
__all__ = ['inject_into_urllib3', 'extract_from_urllib3']
# SNI only *really* works if we can read the subjectAltName of certificates.
HAS_SNI = SUBJ_ALT_NAME_SUPPORT
# Map from urllib3 to PyOpenSSL compatible parameter-values.
_openssl_versions = {
ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,
ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD,
}
_openssl_verify = {
ssl.CERT_NONE: OpenSSL.SSL.VERIFY_NONE,
ssl.CERT_OPTIONAL: OpenSSL.SSL.VERIFY_PEER,
ssl.CERT_REQUIRED: OpenSSL.SSL.VERIFY_PEER
+ OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
}
# A secure default.
# Sources for more information on TLS ciphers:
#
# - https://wiki.mozilla.org/Security/Server_Side_TLS
# - https://www.ssllabs.com/projects/best-practices/index.html
# - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
#
# The general intent is:
# - Prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
# - prefer ECDHE over DHE for better performance,
# - prefer any AES-GCM over any AES-CBC for better performance and security,
# - use 3DES as fallback which is secure but slow,
# - disable NULL authentication, MD5 MACs and DSS for security reasons.
DEFAULT_SSL_CIPHER_LIST = "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:" + \
"ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:" + \
"!aNULL:!MD5:!DSS"
orig_util_HAS_SNI = util.HAS_SNI
orig_connection_ssl_wrap_socket = connection.ssl_wrap_socket
def inject_into_urllib3():
'Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.'
connection.ssl_wrap_socket = ssl_wrap_socket
util.HAS_SNI = HAS_SNI
def extract_from_urllib3():
'Undo monkey-patching by :func:`inject_into_urllib3`.'
connection.ssl_wrap_socket = orig_connection_ssl_wrap_socket
util.HAS_SNI = orig_util_HAS_SNI
### Note: This is a slightly bug-fixed version of same from ndg-httpsclient.
class SubjectAltName(BaseSubjectAltName):
'''ASN.1 implementation for subjectAltNames support'''
# There is no limit to how many SAN certificates a certificate may have,
# however this needs to have some limit so we'll set an arbitrarily high
# limit.
sizeSpec = univ.SequenceOf.sizeSpec + \
constraint.ValueSizeConstraint(1, 1024)
### Note: This is a slightly bug-fixed version of same from ndg-httpsclient.
def get_subj_alt_name(peer_cert):
# Search through extensions
dns_name = []
if not SUBJ_ALT_NAME_SUPPORT:
return dns_name
general_names = SubjectAltName()
for i in range(peer_cert.get_extension_count()):
ext = peer_cert.get_extension(i)
ext_name = ext.get_short_name()
if ext_name != 'subjectAltName':
continue
# PyOpenSSL returns extension data in ASN.1 encoded form
ext_dat = ext.get_data()
decoded_dat = der_decoder.decode(ext_dat,
asn1Spec=general_names)
for name in decoded_dat:
if not isinstance(name, SubjectAltName):
continue
for entry in range(len(name)):
component = name.getComponentByPosition(entry)
if component.getName() != 'dNSName':
continue
dns_name.append(str(component.getComponent()))
return dns_name
class fileobject(_fileobject):
def _wait_for_sock(self):
rd, wd, ed = select.select([self._sock], [], [],
self._sock.gettimeout())
if not rd:
raise timeout()
def read(self, size=-1):
# Use max, disallow tiny reads in a loop as they are very inefficient.
# We never leave read() with any leftover data from a new recv() call
# in our internal buffer.
rbufsize = max(self._rbufsize, self.default_bufsize)
# Our use of StringIO rather than lists of string objects returned by
# recv() minimizes memory usage and fragmentation that occurs when
# rbufsize is large compared to the typical return value of recv().
buf = self._rbuf
buf.seek(0, 2) # seek end
if size < 0:
# Read until EOF
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
while True:
try:
data = self._sock.recv(rbufsize)
except OpenSSL.SSL.WantReadError:
self._wait_for_sock()
continue
if not data:
break
buf.write(data)
return buf.getvalue()
else:
# Read until size bytes or EOF seen, whichever comes first
buf_len = buf.tell()
if buf_len >= size:
# Already have size bytes in our buffer? Extract and return.
buf.seek(0)
rv = buf.read(size)
self._rbuf = StringIO()
self._rbuf.write(buf.read())
return rv
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
while True:
left = size - buf_len
# recv() will malloc the amount of memory given as its
# parameter even though it often returns much less data
# than that. The returned data string is short lived
# as we copy it into a StringIO and free it. This avoids
# fragmentation issues on many platforms.
try:
data = self._sock.recv(left)
except OpenSSL.SSL.WantReadError:
self._wait_for_sock()
continue
if not data:
break
n = len(data)
if n == size and not buf_len:
# Shortcut. Avoid buffer data copies when:
# - We have no data in our buffer.
# AND
# - Our call to recv returned exactly the
# number of bytes we were asked to read.
return data
if n == left:
buf.write(data)
del data # explicit free
break
assert n <= left, "recv(%d) returned %d bytes" % (left, n)
buf.write(data)
buf_len += n
del data # explicit free
#assert buf_len == buf.tell()
return buf.getvalue()
def readline(self, size=-1):
buf = self._rbuf
buf.seek(0, 2) # seek end
if buf.tell() > 0:
# check if we already have it in our buffer
buf.seek(0)
bline = buf.readline(size)
if bline.endswith('\n') or len(bline) == size:
self._rbuf = StringIO()
self._rbuf.write(buf.read())
return bline
del bline
if size < 0:
# Read until \n or EOF, whichever comes first
if self._rbufsize <= 1:
# Speed up unbuffered case
buf.seek(0)
buffers = [buf.read()]
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
data = None
recv = self._sock.recv
while True:
try:
while data != "\n":
data = recv(1)
if not data:
break
buffers.append(data)
except OpenSSL.SSL.WantReadError:
self._wait_for_sock()
continue
break
return "".join(buffers)
buf.seek(0, 2) # seek end
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
while True:
try:
data = self._sock.recv(self._rbufsize)
except OpenSSL.SSL.WantReadError:
self._wait_for_sock()
continue
if not data:
break
nl = data.find('\n')
if nl >= 0:
nl += 1
buf.write(data[:nl])
self._rbuf.write(data[nl:])
del data
break
buf.write(data)
return buf.getvalue()
else:
# Read until size bytes or \n or EOF seen, whichever comes first
buf.seek(0, 2) # seek end
buf_len = buf.tell()
if buf_len >= size:
buf.seek(0)
rv = buf.read(size)
self._rbuf = StringIO()
self._rbuf.write(buf.read())
return rv
self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
while True:
try:
data = self._sock.recv(self._rbufsize)
except OpenSSL.SSL.WantReadError:
self._wait_for_sock()
continue
if not data:
break
left = size - buf_len
# did we just receive a newline?
nl = data.find('\n', 0, left)
if nl >= 0:
nl += 1
# save the excess data to _rbuf
self._rbuf.write(data[nl:])
if buf_len:
buf.write(data[:nl])
break
else:
# Shortcut. Avoid data copy through buf when returning
# a substring of our first recv().
return data[:nl]
n = len(data)
if n == size and not buf_len:
# Shortcut. Avoid data copy through buf when
# returning exactly all of our first recv().
return data
if n >= left:
buf.write(data[:left])
self._rbuf.write(data[left:])
break
buf.write(data)
buf_len += n
#assert buf_len == buf.tell()
return buf.getvalue()
class WrappedSocket(object):
'''API-compatibility wrapper for Python OpenSSL's Connection-class.'''
def __init__(self, connection, socket):
self.connection = connection
self.socket = socket
def fileno(self):
return self.socket.fileno()
def makefile(self, mode, bufsize=-1):
return fileobject(self.connection, mode, bufsize)
def settimeout(self, timeout):
return self.socket.settimeout(timeout)
def sendall(self, data):
return self.connection.sendall(data)
def close(self):
return self.connection.shutdown()
def getpeercert(self, binary_form=False):
x509 = self.connection.get_peer_certificate()
if not x509:
return x509
if binary_form:
return OpenSSL.crypto.dump_certificate(
OpenSSL.crypto.FILETYPE_ASN1,
x509)
return {
'subject': (
(('commonName', x509.get_subject().CN),),
),
'subjectAltName': [
('DNS', value)
for value in get_subj_alt_name(x509)
]
}
def _verify_callback(cnx, x509, err_no, err_depth, return_code):
return err_no == 0
def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
ca_certs=None, server_hostname=None,
ssl_version=None):
ctx = OpenSSL.SSL.Context(_openssl_versions[ssl_version])
if certfile:
ctx.use_certificate_file(certfile)
if keyfile:
ctx.use_privatekey_file(keyfile)
if cert_reqs != ssl.CERT_NONE:
ctx.set_verify(_openssl_verify[cert_reqs], _verify_callback)
if ca_certs:
try:
ctx.load_verify_locations(ca_certs, None)
except OpenSSL.SSL.Error as e:
raise ssl.SSLError('bad ca_certs: %r' % ca_certs, e)
else:
ctx.set_default_verify_paths()
# Disable TLS compression to migitate CRIME attack (issue #309)
OP_NO_COMPRESSION = 0x20000
ctx.set_options(OP_NO_COMPRESSION)
# Set list of supported ciphersuites.
ctx.set_cipher_list(DEFAULT_SSL_CIPHER_LIST)
cnx = OpenSSL.SSL.Connection(ctx, sock)
cnx.set_tlsext_host_name(server_hostname)
cnx.set_connect_state()
while True:
try:
cnx.do_handshake()
except OpenSSL.SSL.WantReadError:
select.select([sock], [], [])
continue
except OpenSSL.SSL.Error as e:
raise ssl.SSLError('bad handshake', e)
break
return WrappedSocket(cnx, sock)
|
mit
|
[
2344,
5413,
543,
428,
16730,
32069,
4058,
367,
2018,
499,
14,
21876,
3520,
15794,
340,
1265,
3955,
199,
2930,
370,
4911,
7799,
14512,
315,
2018,
499,
14,
3390,
12,
314,
849,
8363,
886,
199,
10,
1397,
10,
886,
5897,
7907,
27,
1265,
1929,
370,
886,
4722,
1736,
370,
4107,
199,
16159,
28225,
14,
199,
199,
2765,
4839,
314,
2569,
6117,
4903,
26,
199,
199,
10,
1134,
22791,
334,
10453,
543,
378,
14,
969,
9,
199,
10,
5222,
71,
13,
1014,
551,
864,
334,
10453,
543,
378,
14,
19,
14,
18,
9,
199,
10,
1134,
6228,
17,
334,
10453,
543,
378,
14,
17,
14,
22,
9,
199,
199,
5556,
883,
3907,
3062,
543,
314,
2569,
1414,
26,
339,
7305,
3907,
1134,
14837,
5222,
71,
13,
1014,
551,
864,
1134,
6228,
17,
199,
199,
1378,
15422,
5897,
7907,
12,
1240,
199,
26,
1532,
6054,
4078,
19,
14,
2828,
14,
647,
14837,
14,
14815,
63,
9924,
63,
4078,
19,
64,
687,
2195,
2018,
1233,
199,
5182,
1265,
5386,
10663,
3101,
4145,
14,
961,
883,
506,
4224,
315,
282,
1124,
2124,
26660,
1040,
199,
578,
12,
503,
737,
1263,
1163,
900,
2544,
2195,
4223,
22241,
1808,
1124,
4078,
19,
4542,
199,
2930,
642,
447,
339,
862,
26,
267,
492,
4011,
19,
14,
2828,
14,
647,
14837,
267,
4011,
19,
14,
2828,
14,
647,
14837,
14,
14815,
63,
9924,
63,
4078,
19,
342,
272,
871,
3545,
26,
267,
986,
199,
199,
14351,
1265,
883,
675,
520,
1494,
1705,
4078,
19,
64,
465,
1265,
12252,
3955,
12,
436,
652,
911,
2291,
428,
16730,
199,
6526,
314,
1415,
4621,
787,
4903,
14,
199,
199,
13767,
86,
1958,
642,
859,
2597,
965,
314,
7317,
5366,
7763,
402,
30723,
7799,
15,
10224,
199,
15113,
315,
2018,
499,
334,
3239,
658,
2944,
3465,
23326,
18417,
680,
199,
199,
3917,
1265,
2934,
370,
7908,
314,
849,
769,
402,
3748,
10830,
24203,
12,
1265,
883,
199,
409,
314,
1124,
4078,
19,
14,
2828,
14,
647,
14837,
14,
3472,
63,
5413,
63,
35,
1772,
3452,
63,
4924,
1040,
1750,
14,
199,
199,
2377,
17198,
199,
777,
199,
199,
26,
1391,
6186,
63,
5413,
63,
35,
1772,
3452,
63,
4924,
26,
710,
769,
402,
3748,
7799,
15,
10224,
10830,
24203,
14,
272,
3758,
26,
1124,
4220,
13860,
11,
14494,
29009,
26,
13860,
11,
14494,
29009,
26,
4220,
13860,
11,
14494,
3912,
26,
13860,
11,
14494,
3912,
26,
4220,
13860,
11,
14494,
3933,
26,
13860,
11,
14494,
26,
272,
662,
7695,
40,
11,
19,
4448,
26,
13860,
11,
19,
4448,
26,
12115,
11,
14494,
29009,
26,
12115,
11,
14494,
26,
12115,
11,
19,
4448,
26,
1,
65,
8084,
26,
1,
5127,
21,
26,
1,
36,
2300,
1040,
199,
199,
703,
485,
5167,
73,
26,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
3120,
63,
985,
63,
607,
21171,
199,
703,
485,
1408,
278,
23326,
26,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
2944,
3465,
2531,
4416,
63,
16971,
390,
9,
199,
199,
2344,
199,
199,
504,
5222,
71,
14,
1014,
551,
864,
14,
4266,
63,
7866,
63,
16257,
492,
7605,
42,
63,
19600,
63,
2339,
63,
10640,
199,
504,
5222,
71,
14,
1014,
551,
864,
14,
954,
74,
63,
4478,
63,
354,
492,
26793,
29171,
465,
3523,
13528,
29171,
199,
646,
14296,
14,
5413,
199,
504,
1134,
6228,
17,
14,
9276,
14,
424,
492,
10334,
465,
16921,
63,
8813,
199,
504,
1134,
6228,
17,
14,
466,
492,
17225,
12,
5828,
199,
504,
2838,
492,
485,
493,
785,
12,
2653,
199,
646,
6149,
199,
646,
3504,
199,
504,
15073,
492,
5228,
199,
199,
504,
2508,
492,
1950,
199,
504,
2508,
492,
4884,
199,
199,
363,
452,
363,
275,
788,
14815,
63,
9924,
63,
4078,
19,
297,
283,
5005,
63,
504,
63,
4078,
19,
418,
199,
199,
3,
428,
16730,
1454,
627,
29428,
10,
5419,
340,
781,
883,
1586,
314,
5420,
29171,
402,
14512,
14,
199,
13533,
63,
8199,
41,
275,
7605,
42,
63,
19600,
63,
2339,
63,
10640,
199,
199,
3,
9672,
687,
4011,
19,
370,
1611,
22791,
9025,
2725,
13,
1459,
14,
199,
63,
14837,
63,
6234,
275,
469,
272,
6149,
14,
9583,
63,
21082,
1789,
26,
14296,
14,
5413,
14,
21082,
1789,
63,
9977,
12,
272,
6149,
14,
9583,
63,
21082,
19,
26,
14296,
14,
5413,
14,
21082,
19,
63,
9977,
12,
272,
6149,
14,
9583,
63,
10224,
86,
17,
26,
14296,
14,
5413,
14,
10224,
86,
17,
63,
9977,
12,
199,
93,
199,
63,
14837,
63,
4712,
275,
469,
272,
6149,
14,
11163,
63,
9185,
26,
14296,
14,
5413,
14,
22443,
63,
9185,
12,
272,
6149,
14,
11163,
63,
21008,
26,
14296,
14,
5413,
14,
22443,
63,
31560,
12,
272,
6149,
14,
11163,
63,
12496,
26,
14296,
14,
5413,
14,
22443,
63,
31560,
2432,
435,
14296,
14,
5413,
14,
22443,
63,
8784,
63,
4656,
63,
2826,
63,
31560,
63,
11163,
12,
199,
93,
199,
199,
3,
437,
11153,
849,
14,
199,
3,
5800,
83,
367,
1655,
2556,
641,
12213,
30377,
26,
199,
3,
199,
3,
446,
4178,
921,
6797,
14,
12102,
14,
1308,
15,
7676,
15,
3120,
63,
15414,
63,
10224,
199,
3,
446,
4178,
921,
1544,
14,
385,
914,
2101,
14,
957,
15,
6776,
15,
7010,
13,
80,
6457,
7724,
15,
1080,
14,
1360,
199,
3,
446,
4178,
921,
3577,
685,
75,
14,
278,
15,
19813,
15,
8210,
848,
316,
13,
12695,
13,
2520,
13,
5871,
13,
4266,
13,
27426,
15,
199,
3,
199,
3,
710,
8605,
21020,
365,
26,
199,
3,
446,
510,
21928,
10830,
24203,
626,
19793,
23668,
7568,
542,
1353,
1480,
334,
23520,
15,
4220,
23520,
395,
199,
3,
446,
16602,
662,
7695,
1645,
1806,
577,
1645,
367,
8034,
10238,
12,
199,
3,
446,
16602,
1263,
19093,
13,
29009,
1806,
1263,
19093,
13,
18255,
367,
8034,
10238,
436,
6391,
12,
199,
3,
446,
675,
650,
4448,
465,
9567,
1314,
365,
11153,
1325,
11999,
12,
199,
3,
446,
3507,
5962,
6299,
12,
15830,
21,
13347,
83,
436,
577,
2300,
367,
6391,
14872,
14,
199,
3472,
63,
5413,
63,
35,
1772,
3452,
63,
4924,
275,
298,
4220,
13860,
11,
14494,
29009,
26,
13860,
11,
14494,
29009,
26,
4220,
13860,
11,
14494,
3912,
26,
13860,
11,
14494,
3912,
5424,
435,
971
] |
[
5413,
543,
428,
16730,
32069,
4058,
367,
2018,
499,
14,
21876,
3520,
15794,
340,
1265,
3955,
199,
2930,
370,
4911,
7799,
14512,
315,
2018,
499,
14,
3390,
12,
314,
849,
8363,
886,
199,
10,
1397,
10,
886,
5897,
7907,
27,
1265,
1929,
370,
886,
4722,
1736,
370,
4107,
199,
16159,
28225,
14,
199,
199,
2765,
4839,
314,
2569,
6117,
4903,
26,
199,
199,
10,
1134,
22791,
334,
10453,
543,
378,
14,
969,
9,
199,
10,
5222,
71,
13,
1014,
551,
864,
334,
10453,
543,
378,
14,
19,
14,
18,
9,
199,
10,
1134,
6228,
17,
334,
10453,
543,
378,
14,
17,
14,
22,
9,
199,
199,
5556,
883,
3907,
3062,
543,
314,
2569,
1414,
26,
339,
7305,
3907,
1134,
14837,
5222,
71,
13,
1014,
551,
864,
1134,
6228,
17,
199,
199,
1378,
15422,
5897,
7907,
12,
1240,
199,
26,
1532,
6054,
4078,
19,
14,
2828,
14,
647,
14837,
14,
14815,
63,
9924,
63,
4078,
19,
64,
687,
2195,
2018,
1233,
199,
5182,
1265,
5386,
10663,
3101,
4145,
14,
961,
883,
506,
4224,
315,
282,
1124,
2124,
26660,
1040,
199,
578,
12,
503,
737,
1263,
1163,
900,
2544,
2195,
4223,
22241,
1808,
1124,
4078,
19,
4542,
199,
2930,
642,
447,
339,
862,
26,
267,
492,
4011,
19,
14,
2828,
14,
647,
14837,
267,
4011,
19,
14,
2828,
14,
647,
14837,
14,
14815,
63,
9924,
63,
4078,
19,
342,
272,
871,
3545,
26,
267,
986,
199,
199,
14351,
1265,
883,
675,
520,
1494,
1705,
4078,
19,
64,
465,
1265,
12252,
3955,
12,
436,
652,
911,
2291,
428,
16730,
199,
6526,
314,
1415,
4621,
787,
4903,
14,
199,
199,
13767,
86,
1958,
642,
859,
2597,
965,
314,
7317,
5366,
7763,
402,
30723,
7799,
15,
10224,
199,
15113,
315,
2018,
499,
334,
3239,
658,
2944,
3465,
23326,
18417,
680,
199,
199,
3917,
1265,
2934,
370,
7908,
314,
849,
769,
402,
3748,
10830,
24203,
12,
1265,
883,
199,
409,
314,
1124,
4078,
19,
14,
2828,
14,
647,
14837,
14,
3472,
63,
5413,
63,
35,
1772,
3452,
63,
4924,
1040,
1750,
14,
199,
199,
2377,
17198,
199,
777,
199,
199,
26,
1391,
6186,
63,
5413,
63,
35,
1772,
3452,
63,
4924,
26,
710,
769,
402,
3748,
7799,
15,
10224,
10830,
24203,
14,
272,
3758,
26,
1124,
4220,
13860,
11,
14494,
29009,
26,
13860,
11,
14494,
29009,
26,
4220,
13860,
11,
14494,
3912,
26,
13860,
11,
14494,
3912,
26,
4220,
13860,
11,
14494,
3933,
26,
13860,
11,
14494,
26,
272,
662,
7695,
40,
11,
19,
4448,
26,
13860,
11,
19,
4448,
26,
12115,
11,
14494,
29009,
26,
12115,
11,
14494,
26,
12115,
11,
19,
4448,
26,
1,
65,
8084,
26,
1,
5127,
21,
26,
1,
36,
2300,
1040,
199,
199,
703,
485,
5167,
73,
26,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
3120,
63,
985,
63,
607,
21171,
199,
703,
485,
1408,
278,
23326,
26,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
2944,
3465,
2531,
4416,
63,
16971,
390,
9,
199,
199,
2344,
199,
199,
504,
5222,
71,
14,
1014,
551,
864,
14,
4266,
63,
7866,
63,
16257,
492,
7605,
42,
63,
19600,
63,
2339,
63,
10640,
199,
504,
5222,
71,
14,
1014,
551,
864,
14,
954,
74,
63,
4478,
63,
354,
492,
26793,
29171,
465,
3523,
13528,
29171,
199,
646,
14296,
14,
5413,
199,
504,
1134,
6228,
17,
14,
9276,
14,
424,
492,
10334,
465,
16921,
63,
8813,
199,
504,
1134,
6228,
17,
14,
466,
492,
17225,
12,
5828,
199,
504,
2838,
492,
485,
493,
785,
12,
2653,
199,
646,
6149,
199,
646,
3504,
199,
504,
15073,
492,
5228,
199,
199,
504,
2508,
492,
1950,
199,
504,
2508,
492,
4884,
199,
199,
363,
452,
363,
275,
788,
14815,
63,
9924,
63,
4078,
19,
297,
283,
5005,
63,
504,
63,
4078,
19,
418,
199,
199,
3,
428,
16730,
1454,
627,
29428,
10,
5419,
340,
781,
883,
1586,
314,
5420,
29171,
402,
14512,
14,
199,
13533,
63,
8199,
41,
275,
7605,
42,
63,
19600,
63,
2339,
63,
10640,
199,
199,
3,
9672,
687,
4011,
19,
370,
1611,
22791,
9025,
2725,
13,
1459,
14,
199,
63,
14837,
63,
6234,
275,
469,
272,
6149,
14,
9583,
63,
21082,
1789,
26,
14296,
14,
5413,
14,
21082,
1789,
63,
9977,
12,
272,
6149,
14,
9583,
63,
21082,
19,
26,
14296,
14,
5413,
14,
21082,
19,
63,
9977,
12,
272,
6149,
14,
9583,
63,
10224,
86,
17,
26,
14296,
14,
5413,
14,
10224,
86,
17,
63,
9977,
12,
199,
93,
199,
63,
14837,
63,
4712,
275,
469,
272,
6149,
14,
11163,
63,
9185,
26,
14296,
14,
5413,
14,
22443,
63,
9185,
12,
272,
6149,
14,
11163,
63,
21008,
26,
14296,
14,
5413,
14,
22443,
63,
31560,
12,
272,
6149,
14,
11163,
63,
12496,
26,
14296,
14,
5413,
14,
22443,
63,
31560,
2432,
435,
14296,
14,
5413,
14,
22443,
63,
8784,
63,
4656,
63,
2826,
63,
31560,
63,
11163,
12,
199,
93,
199,
199,
3,
437,
11153,
849,
14,
199,
3,
5800,
83,
367,
1655,
2556,
641,
12213,
30377,
26,
199,
3,
199,
3,
446,
4178,
921,
6797,
14,
12102,
14,
1308,
15,
7676,
15,
3120,
63,
15414,
63,
10224,
199,
3,
446,
4178,
921,
1544,
14,
385,
914,
2101,
14,
957,
15,
6776,
15,
7010,
13,
80,
6457,
7724,
15,
1080,
14,
1360,
199,
3,
446,
4178,
921,
3577,
685,
75,
14,
278,
15,
19813,
15,
8210,
848,
316,
13,
12695,
13,
2520,
13,
5871,
13,
4266,
13,
27426,
15,
199,
3,
199,
3,
710,
8605,
21020,
365,
26,
199,
3,
446,
510,
21928,
10830,
24203,
626,
19793,
23668,
7568,
542,
1353,
1480,
334,
23520,
15,
4220,
23520,
395,
199,
3,
446,
16602,
662,
7695,
1645,
1806,
577,
1645,
367,
8034,
10238,
12,
199,
3,
446,
16602,
1263,
19093,
13,
29009,
1806,
1263,
19093,
13,
18255,
367,
8034,
10238,
436,
6391,
12,
199,
3,
446,
675,
650,
4448,
465,
9567,
1314,
365,
11153,
1325,
11999,
12,
199,
3,
446,
3507,
5962,
6299,
12,
15830,
21,
13347,
83,
436,
577,
2300,
367,
6391,
14872,
14,
199,
3472,
63,
5413,
63,
35,
1772,
3452,
63,
4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