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
|
|---|---|---|---|---|---|---|---|---|
erdincay/youtube-dl
|
youtube_dl/extractor/tnaflix.py
|
109
|
10280
|
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
fix_xml_ampersands,
float_or_none,
int_or_none,
parse_duration,
str_to_int,
xpath_text,
)
class TNAFlixNetworkBaseIE(InfoExtractor):
# May be overridden in descendants if necessary
_CONFIG_REGEX = [
r'flashvars\.config\s*=\s*escape\("([^"]+)"',
r'<input[^>]+name="config\d?" value="([^"]+)"',
]
_TITLE_REGEX = r'<input[^>]+name="title" value="([^"]+)"'
_DESCRIPTION_REGEX = r'<input[^>]+name="description" value="([^"]+)"'
_UPLOADER_REGEX = r'<input[^>]+name="username" value="([^"]+)"'
_VIEW_COUNT_REGEX = None
_COMMENT_COUNT_REGEX = None
_AVERAGE_RATING_REGEX = None
_CATEGORIES_REGEX = r'<li[^>]*>\s*<span[^>]+class="infoTitle"[^>]*>Categories:</span>\s*<span[^>]+class="listView"[^>]*>(.+?)</span>\s*</li>'
def _extract_thumbnails(self, flix_xml):
def get_child(elem, names):
for name in names:
child = elem.find(name)
if child is not None:
return child
timeline = get_child(flix_xml, ['timeline', 'rolloverBarImage'])
if timeline is None:
return
pattern_el = get_child(timeline, ['imagePattern', 'pattern'])
if pattern_el is None or not pattern_el.text:
return
first_el = get_child(timeline, ['imageFirst', 'first'])
last_el = get_child(timeline, ['imageLast', 'last'])
if first_el is None or last_el is None:
return
first_text = first_el.text
last_text = last_el.text
if not first_text.isdigit() or not last_text.isdigit():
return
first = int(first_text)
last = int(last_text)
if first > last:
return
width = int_or_none(xpath_text(timeline, './imageWidth', 'thumbnail width'))
height = int_or_none(xpath_text(timeline, './imageHeight', 'thumbnail height'))
return [{
'url': self._proto_relative_url(pattern_el.text.replace('#', compat_str(i)), 'http:'),
'width': width,
'height': height,
} for i in range(first, last + 1)]
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
display_id = mobj.group('display_id')
webpage = self._download_webpage(url, display_id)
cfg_url = self._proto_relative_url(self._html_search_regex(
self._CONFIG_REGEX, webpage, 'flashvars.config'), 'http:')
cfg_xml = self._download_xml(
cfg_url, display_id, 'Downloading metadata',
transform_source=fix_xml_ampersands)
formats = []
def extract_video_url(vl):
return re.sub('speed=\d+', 'speed=', vl.text)
video_link = cfg_xml.find('./videoLink')
if video_link is not None:
formats.append({
'url': extract_video_url(video_link),
'ext': xpath_text(cfg_xml, './videoConfig/type', 'type', default='flv'),
})
for item in cfg_xml.findall('./quality/item'):
video_link = item.find('./videoLink')
if video_link is None:
continue
res = item.find('res')
format_id = None if res is None else res.text
height = int_or_none(self._search_regex(
r'^(\d+)[pP]', format_id, 'height', default=None))
formats.append({
'url': self._proto_relative_url(extract_video_url(video_link), 'http:'),
'format_id': format_id,
'height': height,
})
self._sort_formats(formats)
thumbnail = self._proto_relative_url(
xpath_text(cfg_xml, './startThumb', 'thumbnail'), 'http:')
thumbnails = self._extract_thumbnails(cfg_xml)
title = self._html_search_regex(
self._TITLE_REGEX, webpage, 'title') if self._TITLE_REGEX else self._og_search_title(webpage)
age_limit = self._rta_search(webpage)
duration = parse_duration(self._html_search_meta(
'duration', webpage, 'duration', default=None))
def extract_field(pattern, name):
return self._html_search_regex(pattern, webpage, name, default=None) if pattern else None
description = extract_field(self._DESCRIPTION_REGEX, 'description')
uploader = extract_field(self._UPLOADER_REGEX, 'uploader')
view_count = str_to_int(extract_field(self._VIEW_COUNT_REGEX, 'view count'))
comment_count = str_to_int(extract_field(self._COMMENT_COUNT_REGEX, 'comment count'))
average_rating = float_or_none(extract_field(self._AVERAGE_RATING_REGEX, 'average rating'))
categories_str = extract_field(self._CATEGORIES_REGEX, 'categories')
categories = categories_str.split(', ') if categories_str is not None else []
return {
'id': video_id,
'display_id': display_id,
'title': title,
'description': description,
'thumbnail': thumbnail,
'thumbnails': thumbnails,
'duration': duration,
'age_limit': age_limit,
'uploader': uploader,
'view_count': view_count,
'comment_count': comment_count,
'average_rating': average_rating,
'categories': categories,
'formats': formats,
}
class TNAFlixIE(TNAFlixNetworkBaseIE):
_VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
_TITLE_REGEX = r'<title>(.+?) - TNAFlix Porn Videos</title>'
_DESCRIPTION_REGEX = r'<h3 itemprop="description">([^<]+)</h3>'
_UPLOADER_REGEX = r'(?s)<span[^>]+class="infoTitle"[^>]*>Uploaded By:</span>(.+?)<div'
_TESTS = [{
# anonymous uploader, no categories
'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
'md5': 'ecf3498417d09216374fc5907f9c6ec0',
'info_dict': {
'id': '553878',
'display_id': 'Carmella-Decesare-striptease',
'ext': 'mp4',
'title': 'Carmella Decesare - striptease',
'thumbnail': 're:https?://.*\.jpg$',
'duration': 91,
'age_limit': 18,
'uploader': 'Anonymous',
'categories': [],
}
}, {
# non-anonymous uploader, categories
'url': 'https://www.tnaflix.com/teen-porn/Educational-xxx-video/video6538',
'md5': '0f5d4d490dbfd117b8607054248a07c0',
'info_dict': {
'id': '6538',
'display_id': 'Educational-xxx-video',
'ext': 'mp4',
'title': 'Educational xxx video',
'description': 'md5:b4fab8f88a8621c8fabd361a173fe5b8',
'thumbnail': 're:https?://.*\.jpg$',
'duration': 164,
'age_limit': 18,
'uploader': 'bobwhite39',
'categories': ['Amateur Porn', 'Squirting Videos', 'Teen Girls 18+'],
}
}, {
'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
'only_matching': True,
}]
class EMPFlixIE(TNAFlixNetworkBaseIE):
_VALID_URL = r'https?://(?:www\.)?empflix\.com/videos/(?P<display_id>.+?)-(?P<id>[0-9]+)\.html'
_UPLOADER_REGEX = r'<span[^>]+class="infoTitle"[^>]*>Uploaded By:</span>(.+?)</li>'
_TESTS = [{
'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
'md5': 'b1bc15b6412d33902d6e5952035fcabc',
'info_dict': {
'id': '33051',
'display_id': 'Amateur-Finger-Fuck',
'ext': 'mp4',
'title': 'Amateur Finger Fuck',
'description': 'Amateur solo finger fucking.',
'thumbnail': 're:https?://.*\.jpg$',
'duration': 83,
'age_limit': 18,
'uploader': 'cwbike',
'categories': ['Amateur', 'Anal', 'Fisting', 'Home made', 'Solo'],
}
}, {
'url': 'http://www.empflix.com/videos/[AROMA][ARMD-718]-Aoi-Yoshino-Sawa-25826.html',
'only_matching': True,
}]
class MovieFapIE(TNAFlixNetworkBaseIE):
_VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<display_id>[^/]+)\.html'
_VIEW_COUNT_REGEX = r'<br>Views\s*<strong>([\d,.]+)</strong>'
_COMMENT_COUNT_REGEX = r'<span[^>]+id="comCount"[^>]*>([\d,.]+)</span>'
_AVERAGE_RATING_REGEX = r'Current Rating\s*<br>\s*<strong>([\d.]+)</strong>'
_CATEGORIES_REGEX = r'(?s)<div[^>]+id="vid_info"[^>]*>\s*<div[^>]*>.+?</div>(.*?)<br>'
_TESTS = [{
# normal, multi-format video
'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
'md5': '26624b4e2523051b550067d547615906',
'info_dict': {
'id': 'be9867c9416c19f54a4a',
'display_id': 'experienced-milf-amazing-handjob',
'ext': 'mp4',
'title': 'Experienced MILF Amazing Handjob',
'description': 'Experienced MILF giving an Amazing Handjob',
'thumbnail': 're:https?://.*\.jpg$',
'age_limit': 18,
'uploader': 'darvinfred06',
'view_count': int,
'comment_count': int,
'average_rating': float,
'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'],
}
}, {
# quirky single-format case where the extension is given as fid, but the video is really an flv
'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
'md5': 'fa56683e291fc80635907168a743c9ad',
'info_dict': {
'id': 'e5da0d3edce5404418f5',
'display_id': 'jeune-couple-russe',
'ext': 'flv',
'title': 'Jeune Couple Russe',
'description': 'Amateur',
'thumbnail': 're:https?://.*\.jpg$',
'age_limit': 18,
'uploader': 'whiskeyjar',
'view_count': int,
'comment_count': int,
'average_rating': float,
'categories': ['Amateur', 'Teen'],
}
}]
|
unlicense
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
8434,
63,
495,
199,
504,
2508,
1208,
492,
334,
272,
5325,
63,
1652,
63,
5282,
1192,
5915,
12,
272,
2069,
63,
269,
63,
3592,
12,
272,
1109,
63,
269,
63,
3592,
12,
272,
2198,
63,
5553,
12,
272,
620,
63,
475,
63,
442,
12,
272,
14462,
63,
505,
12,
199,
9,
421,
199,
533,
377,
46,
5699,
20528,
4491,
1563,
4332,
8,
18283,
304,
272,
327,
10162,
506,
10087,
315,
26061,
340,
5784,
272,
485,
5569,
63,
10710,
275,
359,
267,
519,
7,
11331,
2936,
4537,
888,
60,
83,
23440,
83,
10,
3765,
60,
480,
15710,
20415,
297,
267,
519,
7601,
1210,
25524,
354,
628,
888,
60,
68,
13472,
574,
32391,
297,
272,
1622,
272,
485,
19091,
63,
10710,
275,
519,
7601,
1210,
25524,
354,
628,
1213,
2,
574,
32391,
7,
272,
485,
17705,
63,
10710,
275,
519,
7601,
1210,
25524,
354,
628,
1802,
2,
574,
32391,
7,
272,
485,
16418,
540,
63,
10710,
275,
519,
7601,
1210,
25524,
354,
628,
2473,
2,
574,
32391,
7,
272,
485,
12058,
63,
8760,
63,
10710,
275,
488,
272,
485,
10973,
63,
8760,
63,
10710,
275,
488,
272,
485,
33,
2111,
2962,
63,
21047,
1206,
63,
10710,
275,
488,
272,
485,
35,
12649,
28743,
63,
10710,
275,
519,
7601,
317,
28959,
3072,
83,
10,
28,
3751,
25524,
533,
628,
815,
6888,
2,
28959,
30,
28731,
9919,
3751,
3072,
83,
10,
28,
3751,
25524,
533,
628,
513,
2768,
2,
28959,
13661,
11198,
15939,
3751,
3072,
83,
10,
1108,
317,
3524,
339,
347,
485,
5005,
63,
8311,
83,
8,
277,
12,
289,
20528,
63,
1652,
304,
398,
347,
664,
63,
1739,
8,
6086,
12,
1561,
304,
288,
367,
536,
315,
1561,
26,
355,
1982,
275,
6193,
14,
1623,
8,
354,
9,
355,
340,
1982,
365,
440,
488,
26,
490,
372,
1982,
398,
20780,
275,
664,
63,
1739,
8,
70,
20528,
63,
1652,
12,
788,
19369,
297,
283,
8459,
21960,
5281,
3491,
1105,
267,
340,
20780,
365,
488,
26,
288,
372,
398,
3851,
63,
352,
275,
664,
63,
1739,
8,
19369,
12,
788,
1569,
9959,
297,
283,
3401,
1105,
267,
340,
3851,
63,
352,
365,
488,
503,
440,
3851,
63,
352,
14,
505,
26,
288,
372,
398,
1642,
63,
352,
275,
664,
63,
1739,
8,
19369,
12,
788,
1569,
7147,
297,
283,
2246,
1105,
267,
2061,
63,
352,
275,
664,
63,
1739,
8,
19369,
12,
788,
1569,
6090,
297,
283,
2019,
1105,
267,
340,
1642,
63,
352,
365,
488,
503,
2061,
63,
352,
365,
488,
26,
288,
372,
398,
1642,
63,
505,
275,
1642,
63,
352,
14,
505,
267,
2061,
63,
505,
275,
2061,
63,
352,
14,
505,
267,
340,
440,
1642,
63,
505,
14,
13896,
342,
503,
440,
2061,
63,
505,
14,
13896,
837,
288,
372,
398,
1642,
275,
1109,
8,
2246,
63,
505,
9,
267,
2061,
275,
1109,
8,
2019,
63,
505,
9,
267,
340,
1642,
690,
2061,
26,
288,
372,
398,
3462,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
19369,
12,
21526,
1569,
6216,
297,
283,
8311,
3462,
1333,
267,
4569,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
19369,
12,
21526,
1569,
8436,
297,
283,
8311,
4569,
1333,
398,
372,
8910,
288,
283,
633,
356,
291,
423,
2625,
63,
6188,
63,
633,
8,
3401,
63,
352,
14,
505,
14,
1814,
7863,
297,
8434,
63,
495,
8,
73,
1826,
283,
1014,
26,
659,
288,
283,
2063,
356,
3462,
12,
288,
283,
3333,
356,
4569,
12,
267,
789,
367,
284,
315,
1425,
8,
2246,
12,
2061,
435,
413,
1874,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
14208,
275,
295,
14,
1431,
8,
277,
423,
5600,
63,
2632,
12,
1166,
9,
267,
3991,
63,
344,
275,
14208,
14,
923,
360,
344,
358,
267,
2929,
63,
344,
275,
14208,
14,
923,
360,
2918,
63,
344,
358,
398,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
2929,
63,
344,
9,
398,
4810,
63,
633,
275,
291,
423,
2625,
63,
6188,
63,
633,
8,
277,
423,
1360,
63,
1733,
63,
3821,
8,
288,
291,
423,
5569,
63,
10710,
12,
9248,
12,
283,
11331,
2936,
14,
888,
659,
283,
1014,
10993,
398,
4810,
63,
1652,
275,
291,
423,
4249,
63,
1652,
8,
288,
4810,
63,
633,
12,
2929,
63,
344,
12,
283,
18085,
3341,
297,
288,
5793,
63,
1365,
29,
970,
63,
1652,
63,
5282,
1192,
5915,
9,
398,
6752,
275,
942,
398,
347,
5536,
63,
3722,
63,
633,
8,
7300,
304,
288,
372,
295,
14,
954,
360,
7625,
9529,
68,
7386,
283,
7625,
4009,
17876,
14,
505,
9,
398,
3991,
63,
1073,
275,
4810,
63,
1652,
14,
1623,
17371,
3722,
3834,
358,
267,
340,
3991,
63,
1073,
365,
440,
488,
26,
288,
6752,
14,
740,
2561,
355,
283,
633,
356,
5536,
63,
3722,
63,
633,
8,
3722,
63,
1073,
395,
355,
283,
832,
356,
14462,
63,
505,
8,
4128,
63,
1652,
12,
21526,
3722,
2028,
15,
466,
297,
283,
466,
297,
849,
534,
22753,
659,
288,
3828,
398,
367,
1242,
315,
4810,
63,
1652,
14,
6452,
17371,
9161,
15,
1053,
735,
288,
3991,
63,
1073,
275,
1242,
14,
1623,
17371,
3722,
3834,
358,
288,
340,
3991,
63,
1073,
365,
488,
26,
355,
1980,
288,
522,
275,
1242,
14,
1623,
360,
470,
358,
288,
1475,
63,
344,
275,
488,
340,
522,
365,
488,
587,
522,
14,
505,
288,
4569,
275,
1109,
63,
269,
63,
3592,
8,
277,
423,
1733,
63,
3821,
8,
355,
519,
31344,
68,
11,
2788,
80,
48,
4300,
1475,
63,
344,
12,
283,
3333,
297,
849,
29,
403,
430,
288,
6752,
14,
740,
2561,
355,
283,
633,
356,
291,
423,
2625,
63,
6188,
63,
633,
8,
5005,
63,
3722,
63,
633,
8,
3722,
63,
1073,
395,
283,
1014,
26,
659,
355,
283,
908,
63,
344,
356,
1475,
63,
344,
12,
355,
283,
3333,
356,
4569,
12,
288,
3828,
398,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
10062,
275,
291,
423,
2625,
63,
6188,
63,
633,
8,
288,
14462,
63,
505,
8,
4128,
63,
1652,
12,
21526,
928,
2719,
4295,
297
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
8434,
63,
495,
199,
504,
2508,
1208,
492,
334,
272,
5325,
63,
1652,
63,
5282,
1192,
5915,
12,
272,
2069,
63,
269,
63,
3592,
12,
272,
1109,
63,
269,
63,
3592,
12,
272,
2198,
63,
5553,
12,
272,
620,
63,
475,
63,
442,
12,
272,
14462,
63,
505,
12,
199,
9,
421,
199,
533,
377,
46,
5699,
20528,
4491,
1563,
4332,
8,
18283,
304,
272,
327,
10162,
506,
10087,
315,
26061,
340,
5784,
272,
485,
5569,
63,
10710,
275,
359,
267,
519,
7,
11331,
2936,
4537,
888,
60,
83,
23440,
83,
10,
3765,
60,
480,
15710,
20415,
297,
267,
519,
7601,
1210,
25524,
354,
628,
888,
60,
68,
13472,
574,
32391,
297,
272,
1622,
272,
485,
19091,
63,
10710,
275,
519,
7601,
1210,
25524,
354,
628,
1213,
2,
574,
32391,
7,
272,
485,
17705,
63,
10710,
275,
519,
7601,
1210,
25524,
354,
628,
1802,
2,
574,
32391,
7,
272,
485,
16418,
540,
63,
10710,
275,
519,
7601,
1210,
25524,
354,
628,
2473,
2,
574,
32391,
7,
272,
485,
12058,
63,
8760,
63,
10710,
275,
488,
272,
485,
10973,
63,
8760,
63,
10710,
275,
488,
272,
485,
33,
2111,
2962,
63,
21047,
1206,
63,
10710,
275,
488,
272,
485,
35,
12649,
28743,
63,
10710,
275,
519,
7601,
317,
28959,
3072,
83,
10,
28,
3751,
25524,
533,
628,
815,
6888,
2,
28959,
30,
28731,
9919,
3751,
3072,
83,
10,
28,
3751,
25524,
533,
628,
513,
2768,
2,
28959,
13661,
11198,
15939,
3751,
3072,
83,
10,
1108,
317,
3524,
339,
347,
485,
5005,
63,
8311,
83,
8,
277,
12,
289,
20528,
63,
1652,
304,
398,
347,
664,
63,
1739,
8,
6086,
12,
1561,
304,
288,
367,
536,
315,
1561,
26,
355,
1982,
275,
6193,
14,
1623,
8,
354,
9,
355,
340,
1982,
365,
440,
488,
26,
490,
372,
1982,
398,
20780,
275,
664,
63,
1739,
8,
70,
20528,
63,
1652,
12,
788,
19369,
297,
283,
8459,
21960,
5281,
3491,
1105,
267,
340,
20780,
365,
488,
26,
288,
372,
398,
3851,
63,
352,
275,
664,
63,
1739,
8,
19369,
12,
788,
1569,
9959,
297,
283,
3401,
1105,
267,
340,
3851,
63,
352,
365,
488,
503,
440,
3851,
63,
352,
14,
505,
26,
288,
372,
398,
1642,
63,
352,
275,
664,
63,
1739,
8,
19369,
12,
788,
1569,
7147,
297,
283,
2246,
1105,
267,
2061,
63,
352,
275,
664,
63,
1739,
8,
19369,
12,
788,
1569,
6090,
297,
283,
2019,
1105,
267,
340,
1642,
63,
352,
365,
488,
503,
2061,
63,
352,
365,
488,
26,
288,
372,
398,
1642,
63,
505,
275,
1642,
63,
352,
14,
505,
267,
2061,
63,
505,
275,
2061,
63,
352,
14,
505,
267,
340,
440,
1642,
63,
505,
14,
13896,
342,
503,
440,
2061,
63,
505,
14,
13896,
837,
288,
372,
398,
1642,
275,
1109,
8,
2246,
63,
505,
9,
267,
2061,
275,
1109,
8,
2019,
63,
505,
9,
267,
340,
1642,
690,
2061,
26,
288,
372,
398,
3462,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
19369,
12,
21526,
1569,
6216,
297,
283,
8311,
3462,
1333,
267,
4569,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
19369,
12,
21526,
1569,
8436,
297,
283,
8311,
4569,
1333,
398,
372,
8910,
288,
283,
633,
356,
291,
423,
2625,
63,
6188,
63,
633,
8,
3401,
63,
352,
14,
505,
14,
1814,
7863,
297,
8434,
63,
495,
8,
73,
1826,
283,
1014,
26,
659,
288,
283,
2063,
356,
3462,
12,
288,
283,
3333,
356,
4569,
12,
267,
789,
367,
284,
315,
1425,
8,
2246,
12,
2061,
435,
413,
1874,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
14208,
275,
295,
14,
1431,
8,
277,
423,
5600,
63,
2632,
12,
1166,
9,
267,
3991,
63,
344,
275,
14208,
14,
923,
360,
344,
358,
267,
2929,
63,
344,
275,
14208,
14,
923,
360,
2918,
63,
344,
358,
398,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
2929,
63,
344,
9,
398,
4810,
63,
633,
275,
291,
423,
2625,
63,
6188,
63,
633,
8,
277,
423,
1360,
63,
1733,
63,
3821,
8,
288,
291,
423,
5569,
63,
10710,
12,
9248,
12,
283,
11331,
2936,
14,
888,
659,
283,
1014,
10993,
398,
4810,
63,
1652,
275,
291,
423,
4249,
63,
1652,
8,
288,
4810,
63,
633,
12,
2929,
63,
344,
12,
283,
18085,
3341,
297,
288,
5793,
63,
1365,
29,
970,
63,
1652,
63,
5282,
1192,
5915,
9,
398,
6752,
275,
942,
398,
347,
5536,
63,
3722,
63,
633,
8,
7300,
304,
288,
372,
295,
14,
954,
360,
7625,
9529,
68,
7386,
283,
7625,
4009,
17876,
14,
505,
9,
398,
3991,
63,
1073,
275,
4810,
63,
1652,
14,
1623,
17371,
3722,
3834,
358,
267,
340,
3991,
63,
1073,
365,
440,
488,
26,
288,
6752,
14,
740,
2561,
355,
283,
633,
356,
5536,
63,
3722,
63,
633,
8,
3722,
63,
1073,
395,
355,
283,
832,
356,
14462,
63,
505,
8,
4128,
63,
1652,
12,
21526,
3722,
2028,
15,
466,
297,
283,
466,
297,
849,
534,
22753,
659,
288,
3828,
398,
367,
1242,
315,
4810,
63,
1652,
14,
6452,
17371,
9161,
15,
1053,
735,
288,
3991,
63,
1073,
275,
1242,
14,
1623,
17371,
3722,
3834,
358,
288,
340,
3991,
63,
1073,
365,
488,
26,
355,
1980,
288,
522,
275,
1242,
14,
1623,
360,
470,
358,
288,
1475,
63,
344,
275,
488,
340,
522,
365,
488,
587,
522,
14,
505,
288,
4569,
275,
1109,
63,
269,
63,
3592,
8,
277,
423,
1733,
63,
3821,
8,
355,
519,
31344,
68,
11,
2788,
80,
48,
4300,
1475,
63,
344,
12,
283,
3333,
297,
849,
29,
403,
430,
288,
6752,
14,
740,
2561,
355,
283,
633,
356,
291,
423,
2625,
63,
6188,
63,
633,
8,
5005,
63,
3722,
63,
633,
8,
3722,
63,
1073,
395,
283,
1014,
26,
659,
355,
283,
908,
63,
344,
356,
1475,
63,
344,
12,
355,
283,
3333,
356,
4569,
12,
288,
3828,
398,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
10062,
275,
291,
423,
2625,
63,
6188,
63,
633,
8,
288,
14462,
63,
505,
8,
4128,
63,
1652,
12,
21526,
928,
2719,
4295,
297,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
5
|
2342
|
#!/usr/bin/env python
from ROOT import TMVA, TFile, TTree, TCut, gROOT
from os.path import isfile
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.regularizers import l2
from keras import initializations
from keras.optimizers import SGD
# Setup TMVA
TMVA.Tools.Instance()
TMVA.PyMethodBase.PyInitialize()
output = TFile.Open('TMVA.root', 'RECREATE')
factory = TMVA.Factory('TMVAClassification', output,
'!V:!Silent:Color:DrawProgressBar:Transformations=D,G:AnalysisType=multiclass')
# Load data
if not isfile('tmva_example_multiple_background.root'):
createDataMacro = gROOT.GetTutorialsDir() + '/tmva/createData.C'
print(createDataMacro)
gROOT.ProcessLine('.L {}'.format(createDataMacro))
gROOT.ProcessLine('create_MultipleBackground(4000)')
data = TFile.Open('tmva_example_multiple_background.root')
signal = data.Get('TreeS')
background0 = data.Get('TreeB0')
background1 = data.Get('TreeB1')
background2 = data.Get('TreeB2')
dataloader = TMVA.DataLoader('dataset')
for branch in signal.GetListOfBranches():
dataloader.AddVariable(branch.GetName())
dataloader.AddTree(signal, 'Signal')
dataloader.AddTree(background0, 'Background_0')
dataloader.AddTree(background1, 'Background_1')
dataloader.AddTree(background2, 'Background_2')
dataloader.PrepareTrainingAndTestTree(TCut(''),
'SplitMode=Random:NormMode=NumEvents:!V')
# Generate model
# Define initialization
def normal(shape, name=None):
return initializations.normal(shape, scale=0.05, name=name)
# Define model
model = Sequential()
model.add(Dense(32, init=normal, activation='relu', W_regularizer=l2(1e-5), input_dim=4))
#model.add(Dense(32, init=normal, activation='relu', W_regularizer=l2(1e-5)))
model.add(Dense(4, init=normal, activation='softmax'))
# Set loss and optimizer
model.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.01), metrics=['accuracy',])
# Store model to file
model.save('model.h5')
model.summary()
# Book methods
factory.BookMethod(dataloader, TMVA.Types.kFisher, 'Fisher',
'!H:!V:Fisher:VarTransform=D,G')
factory.BookMethod(dataloader, TMVA.Types.kPyKeras, "PyKeras",
'H:!V:VarTransform=D,G:FilenameModel=model.h5:NumEpochs=20:BatchSize=32')
# Run TMVA
factory.TrainAllMethods()
factory.TestAllMethods()
factory.EvaluateAllMethods()
|
lgpl-2.1
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
16547,
492,
377,
45,
15162,
12,
377,
1173,
12,
377,
3987,
12,
377,
23498,
12,
486,
5441,
199,
504,
747,
14,
515,
492,
29214,
199,
199,
504,
11708,
14,
992,
492,
3240,
9092,
199,
504,
11708,
14,
4359,
14,
1018,
492,
20847,
12,
29441,
199,
504,
11708,
14,
7898,
6315,
492,
634,
18,
199,
504,
11708,
492,
2536,
12270,
199,
504,
11708,
14,
6433,
6315,
492,
18868,
36,
199,
199,
3,
12439,
377,
45,
15162,
199,
20690,
15162,
14,
11654,
14,
3244,
342,
199,
20690,
15162,
14,
2713,
3767,
1563,
14,
2713,
9345,
342,
199,
199,
1199,
275,
377,
1173,
14,
4299,
360,
20690,
15162,
14,
1231,
297,
283,
907,
8366,
358,
199,
3702,
275,
377,
45,
15162,
14,
2927,
360,
20690,
26780,
76,
7789,
297,
1072,
12,
272,
14597,
54,
26,
1,
51,
441,
343,
26,
4117,
26,
9654,
11504,
5281,
26,
3188,
17308,
29,
36,
12,
39,
26,
13182,
804,
29,
30016,
358,
199,
199,
3,
7190,
666,
199,
692,
440,
29214,
360,
7574,
3042,
63,
2694,
63,
6048,
63,
7451,
14,
1231,
735,
272,
1218,
1451,
24673,
275,
486,
5441,
14,
1002,
52,
15888,
83,
3567,
342,
435,
1994,
7574,
3042,
15,
981,
1451,
14,
35,
7,
272,
870,
8,
981,
1451,
24673,
9,
272,
486,
5441,
14,
3498,
3049,
5175,
44,
9499,
908,
8,
981,
1451,
24673,
430,
272,
486,
5441,
14,
3498,
3049,
360,
981,
63,
8433,
14148,
8,
23641,
5942,
199,
199,
576,
275,
377,
1173,
14,
4299,
360,
7574,
3042,
63,
2694,
63,
6048,
63,
7451,
14,
1231,
358,
199,
4653,
275,
666,
14,
1002,
360,
3987,
51,
358,
199,
7451,
16,
275,
666,
14,
1002,
360,
3987,
34,
16,
358,
199,
7451,
17,
275,
666,
14,
1002,
360,
3987,
34,
17,
358,
199,
7451,
18,
275,
666,
14,
1002,
360,
3987,
34,
18,
358,
199,
199,
4616,
12201,
669,
275,
377,
45,
15162,
14,
1451,
5455,
360,
5214,
358,
199,
509,
5246,
315,
4673,
14,
1002,
30210,
12526,
397,
837,
272,
6394,
12201,
669,
14,
1123,
2773,
8,
4694,
14,
21266,
1012,
199,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
4653,
12,
283,
11274,
358,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
7451,
16,
12,
283,
14148,
63,
16,
358,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
7451,
17,
12,
283,
14148,
63,
17,
358,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
7451,
18,
12,
283,
14148,
63,
18,
358,
199,
4616,
12201,
669,
14,
22281,
20463,
3325,
774,
3987,
8,
5708,
337,
31150,
267,
283,
8862,
1385,
29,
3883,
26,
15548,
1385,
29,
5667,
11770,
26,
1,
54,
358,
199,
199,
3,
7958,
1402,
199,
199,
3,
13930,
11097,
199,
318,
3293,
8,
1392,
12,
536,
29,
403,
304,
272,
372,
2536,
12270,
14,
3302,
8,
1392,
12,
4666,
29,
16,
14,
1717,
12,
536,
29,
354,
9,
199,
199,
3,
13930,
1402,
199,
1238,
275,
3240,
9092,
342,
199,
1238,
14,
525,
8,
15327,
8,
708,
12,
4205,
29,
3302,
12,
10361,
534,
12833,
297,
644,
63,
14044,
29,
76,
18,
8,
17,
69,
13,
21,
395,
1324,
63,
3572,
29,
20,
430,
199,
3,
1238,
14,
525,
8,
15327,
8,
708,
12,
4205,
29,
3302,
12,
10361,
534,
12833,
297,
644,
63,
14044,
29,
76,
18,
8,
17,
69,
13,
21,
1724,
199,
1238,
14,
525,
8,
15327,
8,
20,
12,
4205,
29,
3302,
12,
10361,
534,
16395,
1333,
199,
199,
3,
2494,
5621,
436,
10736,
199,
1238,
14,
2014,
8,
4358,
534,
16810,
63,
20363,
1150,
7537,
297,
10736,
29,
4254,
36,
8,
7493,
29,
16,
14,
614,
395,
7186,
2968,
13374,
297,
566,
199,
199,
3,
13874,
1402,
370,
570,
199,
1238,
14,
2117,
360,
1238,
14,
72,
21,
358,
199,
1238,
14,
4705,
342,
199,
199,
3,
8944,
3102,
199,
3702,
14,
8696,
3767,
8,
4616,
12201,
669,
12,
377,
45,
15162,
14,
4100,
14,
75,
38,
2453,
281,
12,
283,
38,
2453,
281,
297,
267,
14597,
40,
26,
1,
54,
26,
38,
2453,
281,
26,
5894,
6939,
29,
36,
12,
39,
358,
199,
3702,
14,
8696,
3767,
8,
4616,
12201,
669,
12,
377,
45,
15162,
14,
4100,
14,
75,
2713,
43,
30037,
12,
298,
2713,
43,
30037,
401,
267,
283,
40,
26,
1,
54,
26,
5894,
6939,
29,
36,
12,
39,
26,
8117,
1685,
29,
1238,
14,
72,
21,
26,
5667,
29322,
83,
29,
1165,
26,
8842,
2320,
29,
708,
358,
199,
199,
3,
3378,
377,
45,
15162,
199,
3702,
14,
18591,
2422,
10385,
342,
199,
3702,
14,
12860,
10385,
342,
199,
3702,
14,
25002,
2422,
10385,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
504,
16547,
492,
377,
45,
15162,
12,
377,
1173,
12,
377,
3987,
12,
377,
23498,
12,
486,
5441,
199,
504,
747,
14,
515,
492,
29214,
199,
199,
504,
11708,
14,
992,
492,
3240,
9092,
199,
504,
11708,
14,
4359,
14,
1018,
492,
20847,
12,
29441,
199,
504,
11708,
14,
7898,
6315,
492,
634,
18,
199,
504,
11708,
492,
2536,
12270,
199,
504,
11708,
14,
6433,
6315,
492,
18868,
36,
199,
199,
3,
12439,
377,
45,
15162,
199,
20690,
15162,
14,
11654,
14,
3244,
342,
199,
20690,
15162,
14,
2713,
3767,
1563,
14,
2713,
9345,
342,
199,
199,
1199,
275,
377,
1173,
14,
4299,
360,
20690,
15162,
14,
1231,
297,
283,
907,
8366,
358,
199,
3702,
275,
377,
45,
15162,
14,
2927,
360,
20690,
26780,
76,
7789,
297,
1072,
12,
272,
14597,
54,
26,
1,
51,
441,
343,
26,
4117,
26,
9654,
11504,
5281,
26,
3188,
17308,
29,
36,
12,
39,
26,
13182,
804,
29,
30016,
358,
199,
199,
3,
7190,
666,
199,
692,
440,
29214,
360,
7574,
3042,
63,
2694,
63,
6048,
63,
7451,
14,
1231,
735,
272,
1218,
1451,
24673,
275,
486,
5441,
14,
1002,
52,
15888,
83,
3567,
342,
435,
1994,
7574,
3042,
15,
981,
1451,
14,
35,
7,
272,
870,
8,
981,
1451,
24673,
9,
272,
486,
5441,
14,
3498,
3049,
5175,
44,
9499,
908,
8,
981,
1451,
24673,
430,
272,
486,
5441,
14,
3498,
3049,
360,
981,
63,
8433,
14148,
8,
23641,
5942,
199,
199,
576,
275,
377,
1173,
14,
4299,
360,
7574,
3042,
63,
2694,
63,
6048,
63,
7451,
14,
1231,
358,
199,
4653,
275,
666,
14,
1002,
360,
3987,
51,
358,
199,
7451,
16,
275,
666,
14,
1002,
360,
3987,
34,
16,
358,
199,
7451,
17,
275,
666,
14,
1002,
360,
3987,
34,
17,
358,
199,
7451,
18,
275,
666,
14,
1002,
360,
3987,
34,
18,
358,
199,
199,
4616,
12201,
669,
275,
377,
45,
15162,
14,
1451,
5455,
360,
5214,
358,
199,
509,
5246,
315,
4673,
14,
1002,
30210,
12526,
397,
837,
272,
6394,
12201,
669,
14,
1123,
2773,
8,
4694,
14,
21266,
1012,
199,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
4653,
12,
283,
11274,
358,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
7451,
16,
12,
283,
14148,
63,
16,
358,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
7451,
17,
12,
283,
14148,
63,
17,
358,
199,
4616,
12201,
669,
14,
1123,
3987,
8,
7451,
18,
12,
283,
14148,
63,
18,
358,
199,
4616,
12201,
669,
14,
22281,
20463,
3325,
774,
3987,
8,
5708,
337,
31150,
267,
283,
8862,
1385,
29,
3883,
26,
15548,
1385,
29,
5667,
11770,
26,
1,
54,
358,
199,
199,
3,
7958,
1402,
199,
199,
3,
13930,
11097,
199,
318,
3293,
8,
1392,
12,
536,
29,
403,
304,
272,
372,
2536,
12270,
14,
3302,
8,
1392,
12,
4666,
29,
16,
14,
1717,
12,
536,
29,
354,
9,
199,
199,
3,
13930,
1402,
199,
1238,
275,
3240,
9092,
342,
199,
1238,
14,
525,
8,
15327,
8,
708,
12,
4205,
29,
3302,
12,
10361,
534,
12833,
297,
644,
63,
14044,
29,
76,
18,
8,
17,
69,
13,
21,
395,
1324,
63,
3572,
29,
20,
430,
199,
3,
1238,
14,
525,
8,
15327,
8,
708,
12,
4205,
29,
3302,
12,
10361,
534,
12833,
297,
644,
63,
14044,
29,
76,
18,
8,
17,
69,
13,
21,
1724,
199,
1238,
14,
525,
8,
15327,
8,
20,
12,
4205,
29,
3302,
12,
10361,
534,
16395,
1333,
199,
199,
3,
2494,
5621,
436,
10736,
199,
1238,
14,
2014,
8,
4358,
534,
16810,
63,
20363,
1150,
7537,
297,
10736,
29,
4254,
36,
8,
7493,
29,
16,
14,
614,
395,
7186,
2968,
13374,
297,
566,
199,
199,
3,
13874,
1402,
370,
570,
199,
1238,
14,
2117,
360,
1238,
14,
72,
21,
358,
199,
1238,
14,
4705,
342,
199,
199,
3,
8944,
3102,
199,
3702,
14,
8696,
3767,
8,
4616,
12201,
669,
12,
377,
45,
15162,
14,
4100,
14,
75,
38,
2453,
281,
12,
283,
38,
2453,
281,
297,
267,
14597,
40,
26,
1,
54,
26,
38,
2453,
281,
26,
5894,
6939,
29,
36,
12,
39,
358,
199,
3702,
14,
8696,
3767,
8,
4616,
12201,
669,
12,
377,
45,
15162,
14,
4100,
14,
75,
2713,
43,
30037,
12,
298,
2713,
43,
30037,
401,
267,
283,
40,
26,
1,
54,
26,
5894,
6939,
29,
36,
12,
39,
26,
8117,
1685,
29,
1238,
14,
72,
21,
26,
5667,
29322,
83,
29,
1165,
26,
8842,
2320,
29,
708,
358,
199,
199,
3,
3378,
377,
45,
15162,
199,
3702,
14,
18591,
2422,
10385,
342,
199,
3702,
14,
12860,
10385,
342,
199,
3702,
14,
25002,
2422,
10385,
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,
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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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
] |
TNT-Samuel/Coding-Projects
|
DNS Server/Source/Lib/idlelib/undo.py
|
7
|
11046
|
import string
from idlelib.delegator import Delegator
# tkintter import not needed because module does not create widgets,
# although many methods operate on text widget arguments.
#$ event <<redo>>
#$ win <Control-y>
#$ unix <Alt-z>
#$ event <<undo>>
#$ win <Control-z>
#$ unix <Control-z>
#$ event <<dump-undo-state>>
#$ win <Control-backslash>
#$ unix <Control-backslash>
class UndoDelegator(Delegator):
max_undo = 1000
def __init__(self):
Delegator.__init__(self)
self.reset_undo()
def setdelegate(self, delegate):
if self.delegate is not None:
self.unbind("<<undo>>")
self.unbind("<<redo>>")
self.unbind("<<dump-undo-state>>")
Delegator.setdelegate(self, delegate)
if delegate is not None:
self.bind("<<undo>>", self.undo_event)
self.bind("<<redo>>", self.redo_event)
self.bind("<<dump-undo-state>>", self.dump_event)
def dump_event(self, event):
from pprint import pprint
pprint(self.undolist[:self.pointer])
print("pointer:", self.pointer, end=' ')
print("saved:", self.saved, end=' ')
print("can_merge:", self.can_merge, end=' ')
print("get_saved():", self.get_saved())
pprint(self.undolist[self.pointer:])
return "break"
def reset_undo(self):
self.was_saved = -1
self.pointer = 0
self.undolist = []
self.undoblock = 0 # or a CommandSequence instance
self.set_saved(1)
def set_saved(self, flag):
if flag:
self.saved = self.pointer
else:
self.saved = -1
self.can_merge = False
self.check_saved()
def get_saved(self):
return self.saved == self.pointer
saved_change_hook = None
def set_saved_change_hook(self, hook):
self.saved_change_hook = hook
was_saved = -1
def check_saved(self):
is_saved = self.get_saved()
if is_saved != self.was_saved:
self.was_saved = is_saved
if self.saved_change_hook:
self.saved_change_hook()
def insert(self, index, chars, tags=None):
self.addcmd(InsertCommand(index, chars, tags))
def delete(self, index1, index2=None):
self.addcmd(DeleteCommand(index1, index2))
# Clients should call undo_block_start() and undo_block_stop()
# around a sequence of editing cmds to be treated as a unit by
# undo & redo. Nested matching calls are OK, and the inner calls
# then act like nops. OK too if no editing cmds, or only one
# editing cmd, is issued in between: if no cmds, the whole
# sequence has no effect; and if only one cmd, that cmd is entered
# directly into the undo list, as if undo_block_xxx hadn't been
# called. The intent of all that is to make this scheme easy
# to use: all the client has to worry about is making sure each
# _start() call is matched by a _stop() call.
def undo_block_start(self):
if self.undoblock == 0:
self.undoblock = CommandSequence()
self.undoblock.bump_depth()
def undo_block_stop(self):
if self.undoblock.bump_depth(-1) == 0:
cmd = self.undoblock
self.undoblock = 0
if len(cmd) > 0:
if len(cmd) == 1:
# no need to wrap a single cmd
cmd = cmd.getcmd(0)
# this blk of cmds, or single cmd, has already
# been done, so don't execute it again
self.addcmd(cmd, 0)
def addcmd(self, cmd, execute=True):
if execute:
cmd.do(self.delegate)
if self.undoblock != 0:
self.undoblock.append(cmd)
return
if self.can_merge and self.pointer > 0:
lastcmd = self.undolist[self.pointer-1]
if lastcmd.merge(cmd):
return
self.undolist[self.pointer:] = [cmd]
if self.saved > self.pointer:
self.saved = -1
self.pointer = self.pointer + 1
if len(self.undolist) > self.max_undo:
##print "truncating undo list"
del self.undolist[0]
self.pointer = self.pointer - 1
if self.saved >= 0:
self.saved = self.saved - 1
self.can_merge = True
self.check_saved()
def undo_event(self, event):
if self.pointer == 0:
self.bell()
return "break"
cmd = self.undolist[self.pointer - 1]
cmd.undo(self.delegate)
self.pointer = self.pointer - 1
self.can_merge = False
self.check_saved()
return "break"
def redo_event(self, event):
if self.pointer >= len(self.undolist):
self.bell()
return "break"
cmd = self.undolist[self.pointer]
cmd.redo(self.delegate)
self.pointer = self.pointer + 1
self.can_merge = False
self.check_saved()
return "break"
class Command:
# Base class for Undoable commands
tags = None
def __init__(self, index1, index2, chars, tags=None):
self.marks_before = {}
self.marks_after = {}
self.index1 = index1
self.index2 = index2
self.chars = chars
if tags:
self.tags = tags
def __repr__(self):
s = self.__class__.__name__
t = (self.index1, self.index2, self.chars, self.tags)
if self.tags is None:
t = t[:-1]
return s + repr(t)
def do(self, text):
pass
def redo(self, text):
pass
def undo(self, text):
pass
def merge(self, cmd):
return 0
def save_marks(self, text):
marks = {}
for name in text.mark_names():
if name != "insert" and name != "current":
marks[name] = text.index(name)
return marks
def set_marks(self, text, marks):
for name, index in marks.items():
text.mark_set(name, index)
class InsertCommand(Command):
# Undoable insert command
def __init__(self, index1, chars, tags=None):
Command.__init__(self, index1, None, chars, tags)
def do(self, text):
self.marks_before = self.save_marks(text)
self.index1 = text.index(self.index1)
if text.compare(self.index1, ">", "end-1c"):
# Insert before the final newline
self.index1 = text.index("end-1c")
text.insert(self.index1, self.chars, self.tags)
self.index2 = text.index("%s+%dc" % (self.index1, len(self.chars)))
self.marks_after = self.save_marks(text)
##sys.__stderr__.write("do: %s\n" % self)
def redo(self, text):
text.mark_set('insert', self.index1)
text.insert(self.index1, self.chars, self.tags)
self.set_marks(text, self.marks_after)
text.see('insert')
##sys.__stderr__.write("redo: %s\n" % self)
def undo(self, text):
text.mark_set('insert', self.index1)
text.delete(self.index1, self.index2)
self.set_marks(text, self.marks_before)
text.see('insert')
##sys.__stderr__.write("undo: %s\n" % self)
def merge(self, cmd):
if self.__class__ is not cmd.__class__:
return False
if self.index2 != cmd.index1:
return False
if self.tags != cmd.tags:
return False
if len(cmd.chars) != 1:
return False
if self.chars and \
self.classify(self.chars[-1]) != self.classify(cmd.chars):
return False
self.index2 = cmd.index2
self.chars = self.chars + cmd.chars
return True
alphanumeric = string.ascii_letters + string.digits + "_"
def classify(self, c):
if c in self.alphanumeric:
return "alphanumeric"
if c == "\n":
return "newline"
return "punctuation"
class DeleteCommand(Command):
# Undoable delete command
def __init__(self, index1, index2=None):
Command.__init__(self, index1, index2, None, None)
def do(self, text):
self.marks_before = self.save_marks(text)
self.index1 = text.index(self.index1)
if self.index2:
self.index2 = text.index(self.index2)
else:
self.index2 = text.index(self.index1 + " +1c")
if text.compare(self.index2, ">", "end-1c"):
# Don't delete the final newline
self.index2 = text.index("end-1c")
self.chars = text.get(self.index1, self.index2)
text.delete(self.index1, self.index2)
self.marks_after = self.save_marks(text)
##sys.__stderr__.write("do: %s\n" % self)
def redo(self, text):
text.mark_set('insert', self.index1)
text.delete(self.index1, self.index2)
self.set_marks(text, self.marks_after)
text.see('insert')
##sys.__stderr__.write("redo: %s\n" % self)
def undo(self, text):
text.mark_set('insert', self.index1)
text.insert(self.index1, self.chars)
self.set_marks(text, self.marks_before)
text.see('insert')
##sys.__stderr__.write("undo: %s\n" % self)
class CommandSequence(Command):
# Wrapper for a sequence of undoable cmds to be undone/redone
# as a unit
def __init__(self):
self.cmds = []
self.depth = 0
def __repr__(self):
s = self.__class__.__name__
strs = []
for cmd in self.cmds:
strs.append(" %r" % (cmd,))
return s + "(\n" + ",\n".join(strs) + "\n)"
def __len__(self):
return len(self.cmds)
def append(self, cmd):
self.cmds.append(cmd)
def getcmd(self, i):
return self.cmds[i]
def redo(self, text):
for cmd in self.cmds:
cmd.redo(text)
def undo(self, text):
cmds = self.cmds[:]
cmds.reverse()
for cmd in cmds:
cmd.undo(text)
def bump_depth(self, incr=1):
self.depth = self.depth + incr
return self.depth
def _undo_delegator(parent): # htest #
from tkinter import Toplevel, Text, Button
from idlelib.percolator import Percolator
undowin = Toplevel(parent)
undowin.title("Test UndoDelegator")
x, y = map(int, parent.geometry().split('+')[1:])
undowin.geometry("+%d+%d" % (x, y + 175))
text = Text(undowin, height=10)
text.pack()
text.focus_set()
p = Percolator(text)
d = UndoDelegator()
p.insertfilter(d)
undo = Button(undowin, text="Undo", command=lambda:d.undo_event(None))
undo.pack(side='left')
redo = Button(undowin, text="Redo", command=lambda:d.redo_event(None))
redo.pack(side='left')
dump = Button(undowin, text="Dump", command=lambda:d.dump_event(None))
dump.pack(side='left')
if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_undo', verbosity=2, exit=False)
from idlelib.idle_test.htest import run
run(_undo_delegator)
|
gpl-3.0
|
[
646,
1059,
199,
199,
504,
15072,
773,
14,
23684,
707,
492,
1487,
4170,
707,
199,
199,
3,
10157,
442,
351,
492,
440,
4346,
2952,
859,
1630,
440,
1218,
11114,
12,
199,
3,
22160,
5002,
3102,
19218,
641,
1318,
3938,
2368,
14,
199,
199,
3,
4,
1566,
5213,
30938,
1140,
199,
3,
4,
4747,
665,
3717,
13,
89,
30,
199,
3,
4,
16572,
665,
16985,
13,
90,
30,
199,
199,
3,
4,
1566,
5213,
11833,
1140,
199,
3,
4,
4747,
665,
3717,
13,
90,
30,
199,
3,
4,
16572,
665,
3717,
13,
90,
30,
199,
199,
3,
4,
1566,
5213,
2724,
13,
11833,
13,
929,
1140,
199,
3,
4,
4747,
665,
3717,
13,
21509,
30,
199,
3,
4,
16572,
665,
3717,
13,
21509,
30,
421,
199,
533,
738,
21175,
3896,
24934,
8,
3896,
24934,
304,
339,
1390,
63,
11833,
275,
5198,
339,
347,
636,
826,
721,
277,
304,
267,
1487,
4170,
707,
855,
826,
721,
277,
9,
267,
291,
14,
3958,
63,
11833,
342,
339,
347,
663,
15286,
8,
277,
12,
13080,
304,
267,
340,
291,
14,
15286,
365,
440,
488,
26,
288,
291,
14,
324,
3409,
6757,
28,
11833,
1140,
531,
288,
291,
14,
324,
3409,
6757,
28,
30938,
1140,
531,
288,
291,
14,
324,
3409,
6757,
28,
2724,
13,
11833,
13,
929,
1140,
531,
267,
1487,
4170,
707,
14,
409,
15286,
8,
277,
12,
13080,
9,
267,
340,
13080,
365,
440,
488,
26,
288,
291,
14,
3409,
6757,
28,
11833,
1140,
401,
291,
14,
11833,
63,
1430,
9,
288,
291,
14,
3409,
6757,
28,
30938,
1140,
401,
291,
14,
30938,
63,
1430,
9,
288,
291,
14,
3409,
6757,
28,
2724,
13,
11833,
13,
929,
1140,
401,
291,
14,
2724,
63,
1430,
9,
339,
347,
5461,
63,
1430,
8,
277,
12,
1566,
304,
267,
687,
10933,
492,
10933,
267,
10933,
8,
277,
14,
11833,
513,
1491,
277,
14,
3929,
566,
267,
870,
480,
3929,
6783,
291,
14,
3929,
12,
1284,
534,
5320,
267,
870,
480,
8420,
6783,
291,
14,
8420,
12,
1284,
534,
5320,
267,
870,
480,
2425,
63,
5628,
6783,
291,
14,
2425,
63,
5628,
12,
1284,
534,
5320,
267,
870,
480,
362,
63,
8420,
837,
401,
291,
14,
362,
63,
8420,
1012,
267,
10933,
8,
277,
14,
11833,
513,
59,
277,
14,
3929,
5728,
267,
372,
298,
4785,
2,
339,
347,
5305,
63,
11833,
8,
277,
304,
267,
291,
14,
10274,
63,
8420,
275,
446,
17,
267,
291,
14,
3929,
275,
378,
267,
291,
14,
11833,
513,
275,
942,
267,
291,
14,
11833,
1457,
275,
378,
221,
327,
503,
282,
5817,
5826,
1256,
267,
291,
14,
409,
63,
8420,
8,
17,
9,
339,
347,
663,
63,
8420,
8,
277,
12,
3305,
304,
267,
340,
3305,
26,
288,
291,
14,
8420,
275,
291,
14,
3929,
267,
587,
26,
288,
291,
14,
8420,
275,
446,
17,
267,
291,
14,
2425,
63,
5628,
275,
756,
267,
291,
14,
1074,
63,
8420,
342,
339,
347,
664,
63,
8420,
8,
277,
304,
267,
372,
291,
14,
8420,
508,
291,
14,
3929,
339,
6290,
63,
1461,
63,
3664,
275,
488,
339,
347,
663,
63,
8420,
63,
1461,
63,
3664,
8,
277,
12,
5759,
304,
267,
291,
14,
8420,
63,
1461,
63,
3664,
275,
5759,
339,
1990,
63,
8420,
275,
446,
17,
339,
347,
1104,
63,
8420,
8,
277,
304,
267,
365,
63,
8420,
275,
291,
14,
362,
63,
8420,
342,
267,
340,
365,
63,
8420,
1137,
291,
14,
10274,
63,
8420,
26,
288,
291,
14,
10274,
63,
8420,
275,
365,
63,
8420,
288,
340,
291,
14,
8420,
63,
1461,
63,
3664,
26,
355,
291,
14,
8420,
63,
1461,
63,
3664,
342,
339,
347,
5518,
8,
277,
12,
1478,
12,
8365,
12,
3762,
29,
403,
304,
267,
291,
14,
525,
1760,
8,
9971,
3110,
8,
1080,
12,
8365,
12,
3762,
430,
339,
347,
3145,
8,
277,
12,
1478,
17,
12,
1478,
18,
29,
403,
304,
267,
291,
14,
525,
1760,
8,
5392,
3110,
8,
1080,
17,
12,
1478,
18,
430,
339,
327,
6810,
83,
1077,
1240,
18172,
63,
1457,
63,
928,
342,
436,
18172,
63,
1457,
63,
2379,
342,
272,
327,
6818,
282,
3414,
402,
20401,
11465,
370,
506,
10184,
465,
282,
4137,
701,
272,
327,
18172,
1253,
295,
1117,
14,
221,
23137,
4877,
4882,
787,
9949,
12,
436,
314,
6506,
4882,
272,
327,
2066,
2454,
2839,
302,
1483,
14,
221,
9949,
4634,
340,
949,
20401,
11465,
12,
503,
1454,
1373,
272,
327,
20401,
2088,
12,
365,
21117,
315,
3382,
26,
221,
340,
949,
11465,
12,
314,
8852,
272,
327,
3414,
965,
949,
7763,
27,
436,
340,
1454,
1373,
2088,
12,
626,
2088,
365,
19138,
272,
327,
5370,
1901,
314,
18172,
769,
12,
465,
340,
18172,
63,
1457,
63,
10013,
10530,
78,
1133,
2757,
272,
327,
2797,
14,
221,
710,
21020,
402,
1006,
626,
365,
370,
1852,
642,
5687,
8837,
272,
327,
370,
675,
26,
221,
1006,
314,
1890,
965,
370,
30944,
3595,
365,
10663,
3238,
1924,
272,
327,
485,
928,
342,
1240,
365,
7838,
701,
282,
485,
2379,
342,
1240,
14,
339,
347,
18172,
63,
1457,
63,
928,
8,
277,
304,
267,
340,
291,
14,
11833,
1457,
508,
378,
26,
288,
291,
14,
11833,
1457,
275,
5817,
5826,
342,
267,
291,
14,
11833,
1457,
14,
25397,
63,
4631,
342,
339,
347,
18172,
63,
1457,
63,
2379,
8,
277,
304,
267,
340,
291,
14,
11833,
1457,
14,
25397,
63,
4631,
2801,
17,
9,
508,
378,
26,
288,
2088,
275,
291,
14,
11833,
1457,
288,
291,
14,
11833,
1457,
275,
378,
288,
340,
822,
8,
1760,
9,
690,
378,
26,
355,
340,
822,
8,
1760,
9,
508,
413,
26,
490,
327,
949,
1929,
370,
4816,
282,
2849,
2088,
490,
2088,
275,
2088,
14,
362,
1760,
8,
16,
9,
355,
327,
642,
22742,
402,
11465,
12,
503,
2849,
2088,
12,
965,
2575,
355,
327,
2757,
4224,
12,
880,
2793,
1133,
5341,
652,
4020,
355,
291,
14,
525,
1760,
8,
1760,
12,
378,
9,
339,
347,
1050,
1760,
8,
277,
12,
2088,
12,
5341,
29,
549,
304,
267,
340,
5341,
26,
288,
2088,
14,
1117,
8,
277,
14,
15286,
9,
267,
340,
291,
14,
11833,
1457,
1137,
378,
26,
288,
291,
14,
11833,
1457,
14,
740,
8,
1760,
9,
288,
372,
267
] |
[
1059,
199,
199,
504,
15072,
773,
14,
23684,
707,
492,
1487,
4170,
707,
199,
199,
3,
10157,
442,
351,
492,
440,
4346,
2952,
859,
1630,
440,
1218,
11114,
12,
199,
3,
22160,
5002,
3102,
19218,
641,
1318,
3938,
2368,
14,
199,
199,
3,
4,
1566,
5213,
30938,
1140,
199,
3,
4,
4747,
665,
3717,
13,
89,
30,
199,
3,
4,
16572,
665,
16985,
13,
90,
30,
199,
199,
3,
4,
1566,
5213,
11833,
1140,
199,
3,
4,
4747,
665,
3717,
13,
90,
30,
199,
3,
4,
16572,
665,
3717,
13,
90,
30,
199,
199,
3,
4,
1566,
5213,
2724,
13,
11833,
13,
929,
1140,
199,
3,
4,
4747,
665,
3717,
13,
21509,
30,
199,
3,
4,
16572,
665,
3717,
13,
21509,
30,
421,
199,
533,
738,
21175,
3896,
24934,
8,
3896,
24934,
304,
339,
1390,
63,
11833,
275,
5198,
339,
347,
636,
826,
721,
277,
304,
267,
1487,
4170,
707,
855,
826,
721,
277,
9,
267,
291,
14,
3958,
63,
11833,
342,
339,
347,
663,
15286,
8,
277,
12,
13080,
304,
267,
340,
291,
14,
15286,
365,
440,
488,
26,
288,
291,
14,
324,
3409,
6757,
28,
11833,
1140,
531,
288,
291,
14,
324,
3409,
6757,
28,
30938,
1140,
531,
288,
291,
14,
324,
3409,
6757,
28,
2724,
13,
11833,
13,
929,
1140,
531,
267,
1487,
4170,
707,
14,
409,
15286,
8,
277,
12,
13080,
9,
267,
340,
13080,
365,
440,
488,
26,
288,
291,
14,
3409,
6757,
28,
11833,
1140,
401,
291,
14,
11833,
63,
1430,
9,
288,
291,
14,
3409,
6757,
28,
30938,
1140,
401,
291,
14,
30938,
63,
1430,
9,
288,
291,
14,
3409,
6757,
28,
2724,
13,
11833,
13,
929,
1140,
401,
291,
14,
2724,
63,
1430,
9,
339,
347,
5461,
63,
1430,
8,
277,
12,
1566,
304,
267,
687,
10933,
492,
10933,
267,
10933,
8,
277,
14,
11833,
513,
1491,
277,
14,
3929,
566,
267,
870,
480,
3929,
6783,
291,
14,
3929,
12,
1284,
534,
5320,
267,
870,
480,
8420,
6783,
291,
14,
8420,
12,
1284,
534,
5320,
267,
870,
480,
2425,
63,
5628,
6783,
291,
14,
2425,
63,
5628,
12,
1284,
534,
5320,
267,
870,
480,
362,
63,
8420,
837,
401,
291,
14,
362,
63,
8420,
1012,
267,
10933,
8,
277,
14,
11833,
513,
59,
277,
14,
3929,
5728,
267,
372,
298,
4785,
2,
339,
347,
5305,
63,
11833,
8,
277,
304,
267,
291,
14,
10274,
63,
8420,
275,
446,
17,
267,
291,
14,
3929,
275,
378,
267,
291,
14,
11833,
513,
275,
942,
267,
291,
14,
11833,
1457,
275,
378,
221,
327,
503,
282,
5817,
5826,
1256,
267,
291,
14,
409,
63,
8420,
8,
17,
9,
339,
347,
663,
63,
8420,
8,
277,
12,
3305,
304,
267,
340,
3305,
26,
288,
291,
14,
8420,
275,
291,
14,
3929,
267,
587,
26,
288,
291,
14,
8420,
275,
446,
17,
267,
291,
14,
2425,
63,
5628,
275,
756,
267,
291,
14,
1074,
63,
8420,
342,
339,
347,
664,
63,
8420,
8,
277,
304,
267,
372,
291,
14,
8420,
508,
291,
14,
3929,
339,
6290,
63,
1461,
63,
3664,
275,
488,
339,
347,
663,
63,
8420,
63,
1461,
63,
3664,
8,
277,
12,
5759,
304,
267,
291,
14,
8420,
63,
1461,
63,
3664,
275,
5759,
339,
1990,
63,
8420,
275,
446,
17,
339,
347,
1104,
63,
8420,
8,
277,
304,
267,
365,
63,
8420,
275,
291,
14,
362,
63,
8420,
342,
267,
340,
365,
63,
8420,
1137,
291,
14,
10274,
63,
8420,
26,
288,
291,
14,
10274,
63,
8420,
275,
365,
63,
8420,
288,
340,
291,
14,
8420,
63,
1461,
63,
3664,
26,
355,
291,
14,
8420,
63,
1461,
63,
3664,
342,
339,
347,
5518,
8,
277,
12,
1478,
12,
8365,
12,
3762,
29,
403,
304,
267,
291,
14,
525,
1760,
8,
9971,
3110,
8,
1080,
12,
8365,
12,
3762,
430,
339,
347,
3145,
8,
277,
12,
1478,
17,
12,
1478,
18,
29,
403,
304,
267,
291,
14,
525,
1760,
8,
5392,
3110,
8,
1080,
17,
12,
1478,
18,
430,
339,
327,
6810,
83,
1077,
1240,
18172,
63,
1457,
63,
928,
342,
436,
18172,
63,
1457,
63,
2379,
342,
272,
327,
6818,
282,
3414,
402,
20401,
11465,
370,
506,
10184,
465,
282,
4137,
701,
272,
327,
18172,
1253,
295,
1117,
14,
221,
23137,
4877,
4882,
787,
9949,
12,
436,
314,
6506,
4882,
272,
327,
2066,
2454,
2839,
302,
1483,
14,
221,
9949,
4634,
340,
949,
20401,
11465,
12,
503,
1454,
1373,
272,
327,
20401,
2088,
12,
365,
21117,
315,
3382,
26,
221,
340,
949,
11465,
12,
314,
8852,
272,
327,
3414,
965,
949,
7763,
27,
436,
340,
1454,
1373,
2088,
12,
626,
2088,
365,
19138,
272,
327,
5370,
1901,
314,
18172,
769,
12,
465,
340,
18172,
63,
1457,
63,
10013,
10530,
78,
1133,
2757,
272,
327,
2797,
14,
221,
710,
21020,
402,
1006,
626,
365,
370,
1852,
642,
5687,
8837,
272,
327,
370,
675,
26,
221,
1006,
314,
1890,
965,
370,
30944,
3595,
365,
10663,
3238,
1924,
272,
327,
485,
928,
342,
1240,
365,
7838,
701,
282,
485,
2379,
342,
1240,
14,
339,
347,
18172,
63,
1457,
63,
928,
8,
277,
304,
267,
340,
291,
14,
11833,
1457,
508,
378,
26,
288,
291,
14,
11833,
1457,
275,
5817,
5826,
342,
267,
291,
14,
11833,
1457,
14,
25397,
63,
4631,
342,
339,
347,
18172,
63,
1457,
63,
2379,
8,
277,
304,
267,
340,
291,
14,
11833,
1457,
14,
25397,
63,
4631,
2801,
17,
9,
508,
378,
26,
288,
2088,
275,
291,
14,
11833,
1457,
288,
291,
14,
11833,
1457,
275,
378,
288,
340,
822,
8,
1760,
9,
690,
378,
26,
355,
340,
822,
8,
1760,
9,
508,
413,
26,
490,
327,
949,
1929,
370,
4816,
282,
2849,
2088,
490,
2088,
275,
2088,
14,
362,
1760,
8,
16,
9,
355,
327,
642,
22742,
402,
11465,
12,
503,
2849,
2088,
12,
965,
2575,
355,
327,
2757,
4224,
12,
880,
2793,
1133,
5341,
652,
4020,
355,
291,
14,
525,
1760,
8,
1760,
12,
378,
9,
339,
347,
1050,
1760,
8,
277,
12,
2088,
12,
5341,
29,
549,
304,
267,
340,
5341,
26,
288,
2088,
14,
1117,
8,
277,
14,
15286,
9,
267,
340,
291,
14,
11833,
1457,
1137,
378,
26,
288,
291,
14,
11833,
1457,
14,
740,
8,
1760,
9,
288,
372,
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,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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
] |
calebmadrigal/algorithms-in-python
|
heap.py
|
1
|
3668
|
"""heap.py - implementation of a heap priority queue. """
__author__ = "Caleb Madrigal"
__date__ = "2015-02-17"
import math
from enum import Enum
from autoresizelist import AutoResizeList
class HeapType(Enum):
maxheap = 1
minheap = 2
class Heap:
def __init__(self, initial_data=None, heap_type=HeapType.maxheap):
self.heap_type = heap_type
if heap_type == HeapType.maxheap:
self.comparator = lambda x, y: x > y
else:
self.comparator = lambda x, y: x < y
self.data = AutoResizeList()
if initial_data is not None:
self.build_heap(initial_data)
self._size = len(self.data)
def _left_child(self, index):
return 2*index + 1
def _right_child(self, index):
return 2*index + 2
def _parent(self, index):
return math.floor((index - 1) / 2.0)
def _is_root(self, index):
return index == 0
def _swap(self, i1, i2):
self.data[i1], self.data[i2] = self.data[i2], self.data[i1]
def build_heap(self, initial_data):
for i in initial_data:
self.data.prepend(i)
self.heap_down(0)
def heap_up(self, index):
# If we are at the root, return - we are done
if self._is_root(index):
return
# Else, compare the current node with the parent node, and if this node should be higher
# then the parent node, then swap and recursively call on the parent index
parent_index = self._parent(index)
if self.comparator(self.data[index], self.data[parent_index]):
self._swap(index, parent_index)
self.heap_up(parent_index)
def heap_down(self, index):
left_index = self._left_child(index)
right_index = self._right_child(index)
try:
left = self.data[left_index]
except IndexError:
left = None
try:
right = self.data[right_index]
except IndexError:
right = None
# Find the largest child
largest_child = left
largest_child_index = left_index
if left is not None and right is not None:
if self.comparator(right, left):
largest_child = right
largest_child_index = right_index
elif right is not None:
largest_child = right
largest_child_index = right_index
# If the largest child is not None and is higher priority than the current, then swap
# and recursively call on on the child index
if largest_child is not None and self.comparator(largest_child, self.data[index]):
self._swap(index, largest_child_index)
self.heap_down(largest_child_index)
def push(self, item):
insert_index = self._size # Insert at the end
self._size += 1
self.data[insert_index] = item
self.heap_up(insert_index)
return self
def peek(self):
return self.data[0]
def pop(self):
if len(self.data) < 1 or self.data[0] is None:
return None
# Take item from the root
item = self.data[0]
# Move the bottom-most, right-most item to the root
self.data[0] = self.data[self._size-1]
self.data[self._size-1] = None
self._size -= 1
self.heap_down(0)
return item
def size(self):
return self._size
def __repr__(self):
return str(self.data)
if __name__ == "__main__":
import unittest
testsuite = unittest.TestLoader().discover('test', pattern="*heap*")
unittest.TextTestRunner(verbosity=1).run(testsuite)
|
mit
|
[
624,
12492,
14,
647,
446,
4514,
402,
282,
13295,
7464,
4126,
14,
408,
199,
199,
363,
2502,
363,
275,
298,
35,
1895,
66,
603,
350,
322,
27074,
2,
199,
363,
602,
363,
275,
298,
7806,
13,
996,
13,
1196,
2,
199,
199,
646,
3473,
199,
504,
4952,
492,
11305,
199,
504,
28589,
890,
513,
492,
9195,
24559,
1296,
421,
199,
533,
5311,
439,
804,
8,
5081,
304,
272,
1390,
12492,
275,
413,
272,
1748,
12492,
275,
499,
421,
199,
533,
5311,
439,
26,
272,
347,
636,
826,
721,
277,
12,
2536,
63,
576,
29,
403,
12,
13295,
63,
466,
29,
19777,
804,
14,
988,
12492,
304,
267,
291,
14,
12492,
63,
466,
275,
13295,
63,
466,
267,
340,
13295,
63,
466,
508,
5311,
439,
804,
14,
988,
12492,
26,
288,
291,
14,
27417,
275,
2400,
671,
12,
612,
26,
671,
690,
612,
267,
587,
26,
288,
291,
14,
27417,
275,
2400,
671,
12,
612,
26,
671,
665,
612,
398,
291,
14,
576,
275,
9195,
24559,
1296,
342,
267,
340,
2536,
63,
576,
365,
440,
488,
26,
288,
291,
14,
1506,
63,
12492,
8,
2747,
63,
576,
9,
398,
291,
423,
890,
275,
822,
8,
277,
14,
576,
9,
339,
347,
485,
3039,
63,
1739,
8,
277,
12,
1478,
304,
267,
372,
499,
10,
1080,
435,
413,
339,
347,
485,
1019,
63,
1739,
8,
277,
12,
1478,
304,
267,
372,
499,
10,
1080,
435,
499,
339,
347,
485,
1708,
8,
277,
12,
1478,
304,
267,
372,
3473,
14,
11289,
1332,
1080,
446,
413,
9,
1182,
499,
14,
16,
9,
339,
347,
485,
374,
63,
1231,
8,
277,
12,
1478,
304,
267,
372,
1478,
508,
378,
339,
347,
485,
9286,
8,
277,
12,
284,
17,
12,
284,
18,
304,
267,
291,
14,
576,
59,
73,
17,
467,
291,
14,
576,
59,
73,
18,
61,
275,
291,
14,
576,
59,
73,
18,
467,
291,
14,
576,
59,
73,
17,
61,
339,
347,
1900,
63,
12492,
8,
277,
12,
2536,
63,
576,
304,
267,
367,
284,
315,
2536,
63,
576,
26,
288,
291,
14,
576,
14,
20637,
8,
73,
9,
288,
291,
14,
12492,
63,
2110,
8,
16,
9,
339,
347,
13295,
63,
384,
8,
277,
12,
1478,
304,
267,
327,
982,
781,
787,
737,
314,
1738,
12,
372,
446,
781,
787,
4224,
267,
340,
291,
423,
374,
63,
1231,
8,
1080,
304,
288,
372,
398,
327,
19524,
12,
6540,
314,
1453,
1031,
543,
314,
1676,
1031,
12,
436,
340,
642,
1031,
1077,
506,
10948,
267,
327,
2066,
314,
1676,
1031,
12,
2066,
11413,
436,
15035,
1240,
641,
314,
1676,
1478,
267,
1676,
63,
1080,
275,
291,
423,
1708,
8,
1080,
9,
267,
340,
291,
14,
27417,
8,
277,
14,
576,
59,
1080,
467,
291,
14,
576,
59,
1708,
63,
1080,
4682,
288,
291,
423,
9286,
8,
1080,
12,
1676,
63,
1080,
9,
288,
291,
14,
12492,
63,
384,
8,
1708,
63,
1080,
9,
339,
347,
13295,
63,
2110,
8,
277,
12,
1478,
304,
267,
3602,
63,
1080,
275,
291,
423,
3039,
63,
1739,
8,
1080,
9,
267,
2451,
63,
1080,
275,
291,
423,
1019,
63,
1739,
8,
1080,
9,
267,
862,
26,
288,
3602,
275,
291,
14,
576,
59,
3039,
63,
1080,
61,
267,
871,
7888,
26,
288,
3602,
275,
488,
267,
862,
26,
288,
2451,
275,
291,
14,
576,
59,
1019,
63,
1080,
61,
267,
871,
7888,
26,
288,
2451,
275,
488,
398,
327,
6668,
314,
17451,
1982,
267,
17451,
63,
1739,
275,
3602,
267,
17451,
63,
1739,
63,
1080,
275,
3602,
63,
1080,
267,
340,
3602,
365,
440,
488,
436,
2451,
365,
440,
488,
26,
288,
340,
291,
14,
27417,
8,
1019,
12,
3602,
304,
355,
17451,
63,
1739,
275,
2451,
355,
17451,
63,
1739,
63,
1080,
275,
2451,
63,
1080,
267,
916,
2451,
365,
440,
488,
26,
288,
17451,
63,
1739,
275,
2451,
288,
17451,
63,
1739,
63,
1080,
275,
2451,
63,
1080,
398,
327,
982,
314,
17451,
1982,
365,
440,
488,
436,
365,
10948,
7464,
2419,
314,
1453,
12,
2066,
11413,
267,
327,
436,
15035,
1240,
641,
641,
314,
1982,
1478,
267,
340,
17451,
63,
1739,
365,
440,
488,
436,
291,
14,
27417,
8,
9828,
3199,
63,
1739,
12,
291,
14,
576,
59,
1080,
4682,
288,
291,
423,
9286,
8,
1080,
12,
17451,
63,
1739,
63,
1080,
9,
288,
291,
14,
12492,
63,
2110,
8,
9828,
3199,
63,
1739,
63,
1080,
9,
339,
347,
6675,
8,
277,
12,
1242,
304,
267,
5518,
63,
1080,
275,
291,
423,
890,
221,
327,
15496,
737,
314,
1284,
267,
291,
423,
890,
847,
413,
398,
291,
14,
576,
59,
3176,
63,
1080,
61,
275,
1242,
267,
291,
14,
12492,
63,
384,
8,
3176,
63,
1080,
9,
398,
372,
291,
339,
347,
15094,
8,
277,
304,
267,
372,
291,
14,
576,
59,
16,
61,
339,
347,
4560,
8,
277,
304,
267,
340,
822,
8,
277,
14,
576,
9,
665,
413,
503,
291,
14,
576,
59,
16,
61,
365,
488,
26,
288,
372,
488,
398,
327,
18146,
1242,
687,
314,
1738,
267,
1242,
275,
291,
14,
576,
59,
16,
61,
398,
327,
14171,
314,
9048,
13,
2786,
12,
2451,
13,
2786,
1242,
370,
314,
1738,
267,
291,
14,
576,
59,
16,
61,
275,
291,
14,
576,
59,
277,
423,
890,
13,
17,
61,
267,
291,
14,
576,
59,
277,
423,
890,
13,
17,
61,
275,
488,
267,
291,
423,
890,
4862,
413,
398,
291,
14,
12492,
63,
2110,
8,
16,
9,
398,
372,
1242,
339,
347,
1568,
8,
277,
304,
267,
372,
291,
423,
890,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
620,
8,
277,
14,
576,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
492,
2882,
272,
2295,
2577,
275,
2882,
14,
15824,
1252,
18861,
360,
396,
297,
3851,
32103,
12492,
10,
531,
272,
2882,
14,
24285,
8,
9833,
29,
17,
680,
1065,
8,
14239,
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
] |
[
12492,
14,
647,
446,
4514,
402,
282,
13295,
7464,
4126,
14,
408,
199,
199,
363,
2502,
363,
275,
298,
35,
1895,
66,
603,
350,
322,
27074,
2,
199,
363,
602,
363,
275,
298,
7806,
13,
996,
13,
1196,
2,
199,
199,
646,
3473,
199,
504,
4952,
492,
11305,
199,
504,
28589,
890,
513,
492,
9195,
24559,
1296,
421,
199,
533,
5311,
439,
804,
8,
5081,
304,
272,
1390,
12492,
275,
413,
272,
1748,
12492,
275,
499,
421,
199,
533,
5311,
439,
26,
272,
347,
636,
826,
721,
277,
12,
2536,
63,
576,
29,
403,
12,
13295,
63,
466,
29,
19777,
804,
14,
988,
12492,
304,
267,
291,
14,
12492,
63,
466,
275,
13295,
63,
466,
267,
340,
13295,
63,
466,
508,
5311,
439,
804,
14,
988,
12492,
26,
288,
291,
14,
27417,
275,
2400,
671,
12,
612,
26,
671,
690,
612,
267,
587,
26,
288,
291,
14,
27417,
275,
2400,
671,
12,
612,
26,
671,
665,
612,
398,
291,
14,
576,
275,
9195,
24559,
1296,
342,
267,
340,
2536,
63,
576,
365,
440,
488,
26,
288,
291,
14,
1506,
63,
12492,
8,
2747,
63,
576,
9,
398,
291,
423,
890,
275,
822,
8,
277,
14,
576,
9,
339,
347,
485,
3039,
63,
1739,
8,
277,
12,
1478,
304,
267,
372,
499,
10,
1080,
435,
413,
339,
347,
485,
1019,
63,
1739,
8,
277,
12,
1478,
304,
267,
372,
499,
10,
1080,
435,
499,
339,
347,
485,
1708,
8,
277,
12,
1478,
304,
267,
372,
3473,
14,
11289,
1332,
1080,
446,
413,
9,
1182,
499,
14,
16,
9,
339,
347,
485,
374,
63,
1231,
8,
277,
12,
1478,
304,
267,
372,
1478,
508,
378,
339,
347,
485,
9286,
8,
277,
12,
284,
17,
12,
284,
18,
304,
267,
291,
14,
576,
59,
73,
17,
467,
291,
14,
576,
59,
73,
18,
61,
275,
291,
14,
576,
59,
73,
18,
467,
291,
14,
576,
59,
73,
17,
61,
339,
347,
1900,
63,
12492,
8,
277,
12,
2536,
63,
576,
304,
267,
367,
284,
315,
2536,
63,
576,
26,
288,
291,
14,
576,
14,
20637,
8,
73,
9,
288,
291,
14,
12492,
63,
2110,
8,
16,
9,
339,
347,
13295,
63,
384,
8,
277,
12,
1478,
304,
267,
327,
982,
781,
787,
737,
314,
1738,
12,
372,
446,
781,
787,
4224,
267,
340,
291,
423,
374,
63,
1231,
8,
1080,
304,
288,
372,
398,
327,
19524,
12,
6540,
314,
1453,
1031,
543,
314,
1676,
1031,
12,
436,
340,
642,
1031,
1077,
506,
10948,
267,
327,
2066,
314,
1676,
1031,
12,
2066,
11413,
436,
15035,
1240,
641,
314,
1676,
1478,
267,
1676,
63,
1080,
275,
291,
423,
1708,
8,
1080,
9,
267,
340,
291,
14,
27417,
8,
277,
14,
576,
59,
1080,
467,
291,
14,
576,
59,
1708,
63,
1080,
4682,
288,
291,
423,
9286,
8,
1080,
12,
1676,
63,
1080,
9,
288,
291,
14,
12492,
63,
384,
8,
1708,
63,
1080,
9,
339,
347,
13295,
63,
2110,
8,
277,
12,
1478,
304,
267,
3602,
63,
1080,
275,
291,
423,
3039,
63,
1739,
8,
1080,
9,
267,
2451,
63,
1080,
275,
291,
423,
1019,
63,
1739,
8,
1080,
9,
267,
862,
26,
288,
3602,
275,
291,
14,
576,
59,
3039,
63,
1080,
61,
267,
871,
7888,
26,
288,
3602,
275,
488,
267,
862,
26,
288,
2451,
275,
291,
14,
576,
59,
1019,
63,
1080,
61,
267,
871,
7888,
26,
288,
2451,
275,
488,
398,
327,
6668,
314,
17451,
1982,
267,
17451,
63,
1739,
275,
3602,
267,
17451,
63,
1739,
63,
1080,
275,
3602,
63,
1080,
267,
340,
3602,
365,
440,
488,
436,
2451,
365,
440,
488,
26,
288,
340,
291,
14,
27417,
8,
1019,
12,
3602,
304,
355,
17451,
63,
1739,
275,
2451,
355,
17451,
63,
1739,
63,
1080,
275,
2451,
63,
1080,
267,
916,
2451,
365,
440,
488,
26,
288,
17451,
63,
1739,
275,
2451,
288,
17451,
63,
1739,
63,
1080,
275,
2451,
63,
1080,
398,
327,
982,
314,
17451,
1982,
365,
440,
488,
436,
365,
10948,
7464,
2419,
314,
1453,
12,
2066,
11413,
267,
327,
436,
15035,
1240,
641,
641,
314,
1982,
1478,
267,
340,
17451,
63,
1739,
365,
440,
488,
436,
291,
14,
27417,
8,
9828,
3199,
63,
1739,
12,
291,
14,
576,
59,
1080,
4682,
288,
291,
423,
9286,
8,
1080,
12,
17451,
63,
1739,
63,
1080,
9,
288,
291,
14,
12492,
63,
2110,
8,
9828,
3199,
63,
1739,
63,
1080,
9,
339,
347,
6675,
8,
277,
12,
1242,
304,
267,
5518,
63,
1080,
275,
291,
423,
890,
221,
327,
15496,
737,
314,
1284,
267,
291,
423,
890,
847,
413,
398,
291,
14,
576,
59,
3176,
63,
1080,
61,
275,
1242,
267,
291,
14,
12492,
63,
384,
8,
3176,
63,
1080,
9,
398,
372,
291,
339,
347,
15094,
8,
277,
304,
267,
372,
291,
14,
576,
59,
16,
61,
339,
347,
4560,
8,
277,
304,
267,
340,
822,
8,
277,
14,
576,
9,
665,
413,
503,
291,
14,
576,
59,
16,
61,
365,
488,
26,
288,
372,
488,
398,
327,
18146,
1242,
687,
314,
1738,
267,
1242,
275,
291,
14,
576,
59,
16,
61,
398,
327,
14171,
314,
9048,
13,
2786,
12,
2451,
13,
2786,
1242,
370,
314,
1738,
267,
291,
14,
576,
59,
16,
61,
275,
291,
14,
576,
59,
277,
423,
890,
13,
17,
61,
267,
291,
14,
576,
59,
277,
423,
890,
13,
17,
61,
275,
488,
267,
291,
423,
890,
4862,
413,
398,
291,
14,
12492,
63,
2110,
8,
16,
9,
398,
372,
1242,
339,
347,
1568,
8,
277,
304,
267,
372,
291,
423,
890,
339,
347,
636,
2722,
721,
277,
304,
267,
372,
620,
8,
277,
14,
576,
9,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
492,
2882,
272,
2295,
2577,
275,
2882,
14,
15824,
1252,
18861,
360,
396,
297,
3851,
32103,
12492,
10,
531,
272,
2882,
14,
24285,
8,
9833,
29,
17,
680,
1065,
8,
14239,
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,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
RafaelOrtiz/EbookReader
|
samples/myRead/epubview/navmap.py
|
2
|
3449
|
from lxml import etree
import gtk
import logging
logging.basicConfig(level=logging.DEBUG)
_log = logging.getLogger('navmap')
class NavPoint(object):
def __init__(self, label, contentsrc, children=[]):
self._label = label
self._contentsrc = contentsrc
self._children = children
def get_label(self):
return self._label
def get_contentsrc(self):
return self._contentsrc
def get_children(self):
return self._children
class NavMap(object):
def __init__(self, opffile, ncxfile, basepath):
_log.debug('opffile: %s, ncxfile: %s, basepath: %s', opffile, ncxfile, basepath)
self._basepath = basepath
self._opffile = opffile
self._tree = etree.parse(ncxfile)
_log.debug('##################################')
_log.debug('XML: %s', etree.tostring(self._tree))
_log.debug('##################################')
self._root = self._tree.getroot()
self._gtktreestore = gtk.TreeStore(str, str)
self._flattoc = []
self._populate_flattoc()
self._populate_toc()
def _populate_flattoc(self):
tree = etree.parse(self._opffile)
root = tree.getroot()
itemmap = {}
manifest = root.find('.//{http://www.idpf.org/2007/opf}manifest')
for element in manifest.iterfind('{http://www.idpf.org/2007/opf}item'):
itemmap[element.get('id')] = element
spine = root.find('.//{http://www.idpf.org/2007/opf}spine')
for element in spine.iterfind('{http://www.idpf.org/2007/opf}itemref'):
idref = element.get('idref')
href = itemmap[idref].get('href')
self._flattoc.append(self._basepath + href)
self._opffile.close()
def _populate_toc(self):
navmap = self._root.find(
'{http://www.daisy.org/z3986/2005/ncx/}navMap')
for navpoint in navmap.iterfind(
'./{http://www.daisy.org/z3986/2005/ncx/}navPoint'):
self._process_navpoint(navpoint)
def _gettitle(self, navpoint):
text = navpoint.find('./{http://www.daisy.org/z3986/2005/ncx/}' +
'navLabel/{http://www.daisy.org/z3986/2005/ncx/}text')
return text.text
def _getcontent(self, navpoint):
_log.debug('navpoint:%s, tag:%s', navpoint, navpoint.tag)
text = navpoint.find(
'./{http://www.daisy.org/z3986/2005/ncx/}content')
return self._basepath + text.get('src')
def _process_navpoint(self, navpoint, parent=None):
title = self._gettitle(navpoint)
content = self._getcontent(navpoint)
#print title, content
iter = self._gtktreestore.append(parent, [title, content])
#self._flattoc.append((title, content))
childnavpointlist = list(navpoint.iterfind(
'./{http://www.daisy.org/z3986/2005/ncx/}navPoint'))
if len(childnavpointlist):
for childnavpoint in childnavpointlist:
self._process_navpoint(childnavpoint, parent=iter)
else:
return
def get_gtktreestore(self):
'''
Returns a GtkTreeModel representation of the
Epub table of contents
'''
return self._gtktreestore
def get_flattoc(self):
'''
Returns a flat (linear) list of files to be
rendered.
'''
return self._flattoc
#t = TocParser('/home/sayamindu/Desktop/Test/OPS/fb.ncx')
|
gpl-2.0
|
[
504,
14490,
492,
7559,
199,
646,
8116,
199,
646,
2050,
199,
199,
4806,
14,
19602,
8,
1896,
29,
4806,
14,
5287,
9,
199,
63,
793,
275,
2050,
14,
5572,
360,
10927,
1130,
358,
199,
199,
533,
653,
1214,
3428,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1768,
12,
1564,
2164,
12,
4978,
17894,
267,
291,
423,
1302,
275,
1768,
267,
291,
423,
1317,
2164,
275,
1564,
2164,
267,
291,
423,
3223,
275,
4978,
339,
347,
664,
63,
1302,
8,
277,
304,
267,
372,
291,
423,
1302,
339,
347,
664,
63,
1317,
2164,
8,
277,
304,
267,
372,
291,
423,
1317,
2164,
339,
347,
664,
63,
3223,
8,
277,
304,
267,
372,
291,
423,
3223,
421,
199,
533,
653,
1214,
2956,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1687,
70,
493,
12,
302,
11859,
493,
12,
1300,
515,
304,
421,
198,
63,
793,
14,
1757,
360,
16893,
493,
26,
450,
83,
12,
302,
11859,
493,
26,
450,
83,
12,
1300,
515,
26,
450,
83,
297,
1687,
70,
493,
12,
302,
11859,
493,
12,
1300,
515,
9,
199,
198,
277,
423,
1095,
515,
275,
1300,
515,
267,
291,
423,
16893,
493,
275,
1687,
70,
493,
267,
291,
423,
2350,
275,
7559,
14,
1122,
8,
7966,
88,
493,
9,
199,
198,
63,
793,
14,
1757,
360,
1371,
309,
358,
199,
198,
63,
793,
14,
1757,
360,
4317,
26,
450,
83,
297,
7559,
14,
14028,
8,
277,
423,
2350,
430,
199,
198,
63,
793,
14,
1757,
360,
1371,
309,
358,
267,
291,
423,
1231,
275,
291,
423,
2350,
14,
24544,
342,
267,
291,
423,
12275,
18468,
597,
720,
275,
8116,
14,
3987,
5502,
8,
495,
12,
620,
9,
267,
291,
423,
7088,
13255,
275,
942,
398,
291,
423,
13817,
63,
7088,
13255,
342,
267,
291,
423,
13817,
63,
13255,
342,
339,
347,
485,
13817,
63,
7088,
13255,
8,
277,
304,
267,
3123,
275,
7559,
14,
1122,
8,
277,
423,
16893,
493,
9,
267,
1738,
275,
3123,
14,
24544,
342,
398,
1242,
1130,
275,
1052,
267,
7712,
275,
1738,
14,
1623,
29995,
91,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
6418,
358,
267,
367,
1819,
315,
7712,
14,
1661,
1623,
11117,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
1053,
735,
288,
1242,
1130,
59,
2108,
14,
362,
360,
344,
5440,
275,
1819,
398,
2249,
1132,
275,
1738,
14,
1623,
29995,
91,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
681,
1132,
358,
267,
367,
1819,
315,
2249,
1132,
14,
1661,
1623,
11117,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
1053,
1121,
735,
288,
1305,
1121,
275,
1819,
14,
362,
360,
344,
1121,
358,
288,
4369,
275,
1242,
1130,
59,
344,
1121,
1055,
362,
360,
6399,
358,
288,
291,
423,
7088,
13255,
14,
740,
8,
277,
423,
1095,
515,
435,
4369,
9,
398,
291,
423,
16893,
493,
14,
1600,
342,
339,
347,
485,
13817,
63,
13255,
8,
277,
304,
267,
16681,
1130,
275,
291,
423,
1231,
14,
1623,
8,
355,
5041,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
10927,
2956,
358,
267,
367,
16681,
1403,
315,
16681,
1130,
14,
1661,
1623,
8,
355,
1987,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
10927,
3428,
735,
288,
291,
423,
1412,
63,
10927,
1403,
8,
10927,
1403,
9,
339,
347,
485,
362,
1213,
8,
277,
12,
16681,
1403,
304,
267,
1318,
275,
16681,
1403,
14,
1623,
5175,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
6834,
435,
355,
283,
10927,
4314,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
505,
358,
267,
372,
1318,
14,
505,
339,
347,
485,
362,
1317,
8,
277,
12,
16681,
1403,
304,
199,
198,
63,
793,
14,
1757,
360,
10927,
1403,
2689,
83,
12,
1947,
2689,
83,
297,
16681,
1403,
12,
16681,
1403,
14,
1450,
9,
267,
1318,
275,
16681,
1403,
14,
1623,
8,
355,
1987,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
1317,
358,
267,
372,
291,
423,
1095,
515,
435,
1318,
14,
362,
360,
2164,
358,
339,
347,
485,
1412,
63,
10927,
1403,
8,
277,
12,
16681,
1403,
12,
1676,
29,
403,
304,
267,
2538,
275,
291,
423,
362,
1213,
8,
10927,
1403,
9,
267,
1564,
275,
291,
423,
362,
1317,
8,
10927,
1403,
9,
398,
327,
1361,
2538,
12,
1564,
398,
2740,
275,
291,
423,
12275,
18468,
597,
720,
14,
740,
8,
1708,
12,
359,
1213,
12,
1564,
566,
267,
327,
277,
423,
7088,
13255,
14,
740,
1332,
1213,
12,
1564,
430,
398,
1982,
10927,
1403,
513,
275,
769,
8,
10927,
1403,
14,
1661,
1623,
8,
355,
1987,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
10927,
3428,
1333,
398,
340,
822,
8,
1739,
10927,
1403,
513,
304,
288,
367,
1982,
10927,
1403,
315,
1982,
10927,
1403,
513,
26,
355,
291,
423,
1412,
63,
10927,
1403,
8,
1739,
10927,
1403,
12,
1676,
29,
1661,
9,
267,
587,
26,
288,
372,
339,
347,
664,
63,
12275,
18468,
597,
720,
8,
277,
304,
267,
1449,
267,
1803,
282,
11424,
3987,
1685,
6025,
402,
314,
267,
662,
5645,
1817,
402,
4072,
267,
1449,
267,
372,
291,
423,
12275,
18468,
597,
720,
339,
347,
664,
63,
7088,
13255,
8,
277,
304,
267,
1449,
267,
1803,
282,
6829,
334,
6676,
9,
769,
402,
1584,
370,
506,
267,
8018,
14,
267,
1449,
267,
372,
291,
423,
7088,
13255,
199,
199,
3,
84,
275,
377,
679,
2842,
2336,
4219,
15,
19787,
455,
688,
85,
15,
20436,
15,
774,
15,
21665,
15,
4675,
14,
7966,
88,
358,
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
] |
[
14490,
492,
7559,
199,
646,
8116,
199,
646,
2050,
199,
199,
4806,
14,
19602,
8,
1896,
29,
4806,
14,
5287,
9,
199,
63,
793,
275,
2050,
14,
5572,
360,
10927,
1130,
358,
199,
199,
533,
653,
1214,
3428,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1768,
12,
1564,
2164,
12,
4978,
17894,
267,
291,
423,
1302,
275,
1768,
267,
291,
423,
1317,
2164,
275,
1564,
2164,
267,
291,
423,
3223,
275,
4978,
339,
347,
664,
63,
1302,
8,
277,
304,
267,
372,
291,
423,
1302,
339,
347,
664,
63,
1317,
2164,
8,
277,
304,
267,
372,
291,
423,
1317,
2164,
339,
347,
664,
63,
3223,
8,
277,
304,
267,
372,
291,
423,
3223,
421,
199,
533,
653,
1214,
2956,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1687,
70,
493,
12,
302,
11859,
493,
12,
1300,
515,
304,
421,
198,
63,
793,
14,
1757,
360,
16893,
493,
26,
450,
83,
12,
302,
11859,
493,
26,
450,
83,
12,
1300,
515,
26,
450,
83,
297,
1687,
70,
493,
12,
302,
11859,
493,
12,
1300,
515,
9,
199,
198,
277,
423,
1095,
515,
275,
1300,
515,
267,
291,
423,
16893,
493,
275,
1687,
70,
493,
267,
291,
423,
2350,
275,
7559,
14,
1122,
8,
7966,
88,
493,
9,
199,
198,
63,
793,
14,
1757,
360,
1371,
309,
358,
199,
198,
63,
793,
14,
1757,
360,
4317,
26,
450,
83,
297,
7559,
14,
14028,
8,
277,
423,
2350,
430,
199,
198,
63,
793,
14,
1757,
360,
1371,
309,
358,
267,
291,
423,
1231,
275,
291,
423,
2350,
14,
24544,
342,
267,
291,
423,
12275,
18468,
597,
720,
275,
8116,
14,
3987,
5502,
8,
495,
12,
620,
9,
267,
291,
423,
7088,
13255,
275,
942,
398,
291,
423,
13817,
63,
7088,
13255,
342,
267,
291,
423,
13817,
63,
13255,
342,
339,
347,
485,
13817,
63,
7088,
13255,
8,
277,
304,
267,
3123,
275,
7559,
14,
1122,
8,
277,
423,
16893,
493,
9,
267,
1738,
275,
3123,
14,
24544,
342,
398,
1242,
1130,
275,
1052,
267,
7712,
275,
1738,
14,
1623,
29995,
91,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
6418,
358,
267,
367,
1819,
315,
7712,
14,
1661,
1623,
11117,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
1053,
735,
288,
1242,
1130,
59,
2108,
14,
362,
360,
344,
5440,
275,
1819,
398,
2249,
1132,
275,
1738,
14,
1623,
29995,
91,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
681,
1132,
358,
267,
367,
1819,
315,
2249,
1132,
14,
1661,
1623,
11117,
1014,
921,
1544,
14,
344,
9928,
14,
1308,
15,
9488,
15,
16893,
93,
1053,
1121,
735,
288,
1305,
1121,
275,
1819,
14,
362,
360,
344,
1121,
358,
288,
4369,
275,
1242,
1130,
59,
344,
1121,
1055,
362,
360,
6399,
358,
288,
291,
423,
7088,
13255,
14,
740,
8,
277,
423,
1095,
515,
435,
4369,
9,
398,
291,
423,
16893,
493,
14,
1600,
342,
339,
347,
485,
13817,
63,
13255,
8,
277,
304,
267,
16681,
1130,
275,
291,
423,
1231,
14,
1623,
8,
355,
5041,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
10927,
2956,
358,
267,
367,
16681,
1403,
315,
16681,
1130,
14,
1661,
1623,
8,
355,
1987,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
10927,
3428,
735,
288,
291,
423,
1412,
63,
10927,
1403,
8,
10927,
1403,
9,
339,
347,
485,
362,
1213,
8,
277,
12,
16681,
1403,
304,
267,
1318,
275,
16681,
1403,
14,
1623,
5175,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
6834,
435,
355,
283,
10927,
4314,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
505,
358,
267,
372,
1318,
14,
505,
339,
347,
485,
362,
1317,
8,
277,
12,
16681,
1403,
304,
199,
198,
63,
793,
14,
1757,
360,
10927,
1403,
2689,
83,
12,
1947,
2689,
83,
297,
16681,
1403,
12,
16681,
1403,
14,
1450,
9,
267,
1318,
275,
16681,
1403,
14,
1623,
8,
355,
1987,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
1317,
358,
267,
372,
291,
423,
1095,
515,
435,
1318,
14,
362,
360,
2164,
358,
339,
347,
485,
1412,
63,
10927,
1403,
8,
277,
12,
16681,
1403,
12,
1676,
29,
403,
304,
267,
2538,
275,
291,
423,
362,
1213,
8,
10927,
1403,
9,
267,
1564,
275,
291,
423,
362,
1317,
8,
10927,
1403,
9,
398,
327,
1361,
2538,
12,
1564,
398,
2740,
275,
291,
423,
12275,
18468,
597,
720,
14,
740,
8,
1708,
12,
359,
1213,
12,
1564,
566,
267,
327,
277,
423,
7088,
13255,
14,
740,
1332,
1213,
12,
1564,
430,
398,
1982,
10927,
1403,
513,
275,
769,
8,
10927,
1403,
14,
1661,
1623,
8,
355,
1987,
5321,
1014,
921,
1544,
14,
983,
19765,
14,
1308,
15,
90,
29451,
15,
9397,
15,
7966,
88,
15,
93,
10927,
3428,
1333,
398,
340,
822,
8,
1739,
10927,
1403,
513,
304,
288,
367,
1982,
10927,
1403,
315,
1982,
10927,
1403,
513,
26,
355,
291,
423,
1412,
63,
10927,
1403,
8,
1739,
10927,
1403,
12,
1676,
29,
1661,
9,
267,
587,
26,
288,
372,
339,
347,
664,
63,
12275,
18468,
597,
720,
8,
277,
304,
267,
1449,
267,
1803,
282,
11424,
3987,
1685,
6025,
402,
314,
267,
662,
5645,
1817,
402,
4072,
267,
1449,
267,
372,
291,
423,
12275,
18468,
597,
720,
339,
347,
664,
63,
7088,
13255,
8,
277,
304,
267,
1449,
267,
1803,
282,
6829,
334,
6676,
9,
769,
402,
1584,
370,
506,
267,
8018,
14,
267,
1449,
267,
372,
291,
423,
7088,
13255,
199,
199,
3,
84,
275,
377,
679,
2842,
2336,
4219,
15,
19787,
455,
688,
85,
15,
20436,
15,
774,
15,
21665,
15,
4675,
14,
7966,
88,
358,
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,
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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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
garbled1/ansible
|
lib/ansible/utils/module_docs_fragments/eos.py
|
87
|
5493
|
#
# (c) 2015, Peter Sprygada <psprygada@ansible.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/>.
class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = """
options:
authorize:
description:
- Instructs the module to enter privileged mode on the remote device
before sending any commands. If not specified, the device will
attempt to execute all commands in non-privileged mode. If the value
is not specified in the task, the value of environment variable
C(ANSIBLE_NET_AUTHORIZE) will be used instead.
default: no
choices: ['yes', 'no']
auth_pass:
description:
- Specifies the password to use if required to enter privileged mode
on the remote device. If I(authorize) is false, then this argument
does nothing. If the value is not specified in the task, the value of
environment variable C(ANSIBLE_NET_AUTH_PASS) will be used instead.
default: none
provider:
description:
- A dict object containing connection details.
default: null
suboptions:
host:
description:
- Specifies the DNS host name or address for connecting to the remote
device over the specified transport. The value of host is used as
the destination address for the transport.
required: true
port:
description:
- Specifies the port to use when building the connection to the remote
device. This value applies to either I(cli) or I(eapi). The port
value will default to the appropriate transport common port if
none is provided in the task. (cli=22, http=80, https=443).
default: 0 (use common port)
username:
description:
- Configures the username to use to authenticate the connection to
the remote device. This value is used to authenticate
either the CLI login or the eAPI authentication depending on which
transport is used. If the value is not specified in the task, the
value of environment variable C(ANSIBLE_NET_USERNAME) will be used instead.
password:
description:
- Specifies the password to use to authenticate the connection to
the remote device. This is a common argument used for either I(cli)
or I(eapi) transports. If the value is not specified in the task, the
value of environment variable C(ANSIBLE_NET_PASSWORD) will be used instead.
default: null
timeout:
description:
- Specifies the timeout in seconds for communicating with the network device
for either connecting or sending commands. If the timeout is
exceeded before the operation is completed, the module will error.
default: 10
ssh_keyfile:
description:
- Specifies the SSH keyfile to use to authenticate the connection to
the remote device. This argument is only used for I(cli) transports.
If the value is not specified in the task, the value of environment
variable C(ANSIBLE_NET_SSH_KEYFILE) will be used instead.
authorize:
description:
- Instructs the module to enter privileged mode on the remote device
before sending any commands. If not specified, the device will
attempt to execute all commands in non-privileged mode. If the value
is not specified in the task, the value of environment variable
C(ANSIBLE_NET_AUTHORIZE) will be used instead.
default: no
choices: ['yes', 'no']
auth_pass:
description:
- Specifies the password to use if required to enter privileged mode
on the remote device. If I(authorize) is false, then this argument
does nothing. If the value is not specified in the task, the value of
environment variable C(ANSIBLE_NET_AUTH_PASS) will be used instead.
default: none
transport:
description:
- Configures the transport connection to use when connecting to the
remote device.
required: true
choices:
- eapi
- cli
default: cli
use_ssl:
description:
- Configures the I(transport) to use SSL if set to true only when the
C(transport=eapi). If the transport
argument is not eapi, this value is ignored.
default: yes
choices: ['yes', 'no']
validate_certs:
description:
- If C(no), SSL certificates will not be validated. This should only be used
on personally controlled sites using self-signed certificates. If the transport
argument is not eapi, this value is ignored.
choices: ['yes', 'no']
"""
|
gpl-3.0
|
[
3,
199,
3,
334,
67,
9,
6900,
12,
22912,
8360,
651,
71,
10641,
665,
80,
681,
651,
71,
10641,
32,
4853,
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,
421,
199,
533,
5673,
3768,
11080,
8,
785,
304,
339,
327,
9739,
1584,
3794,
7956,
272,
29970,
2594,
275,
408,
199,
1419,
26,
523,
20210,
26,
272,
1369,
26,
489,
446,
1010,
23253,
314,
859,
370,
9509,
1979,
21744,
818,
641,
314,
3982,
2243,
267,
2544,
10209,
1263,
3718,
14,
221,
982,
440,
2013,
12,
314,
2243,
911,
267,
7427,
370,
5341,
1006,
3718,
315,
2222,
13,
27672,
818,
14,
982,
314,
574,
267,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
267,
445,
8,
8490,
63,
7278,
63,
27938,
11025,
9,
911,
506,
1202,
3140,
14,
272,
849,
26,
949,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
523,
1790,
63,
1529,
26,
272,
1369,
26,
489,
446,
11015,
314,
2505,
370,
675,
340,
1415,
370,
9509,
1979,
21744,
818,
267,
641,
314,
3982,
2243,
14,
221,
982,
473,
8,
14204,
9,
365,
3055,
12,
2066,
642,
1423,
267,
1630,
6548,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
267,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
5580,
63,
6909,
9,
911,
506,
1202,
3140,
14,
272,
849,
26,
7179,
523,
5022,
26,
272,
1369,
26,
489,
446,
437,
1211,
909,
3035,
1950,
2436,
14,
272,
849,
26,
2973,
272,
26265,
26,
489,
1591,
26,
267,
1369,
26,
881,
446,
11015,
314,
10237,
1591,
536,
503,
2287,
367,
18170,
370,
314,
3982,
288,
2243,
1806,
314,
2013,
7773,
14,
221,
710,
574,
402,
1591,
365,
1202,
465,
288,
314,
5724,
2287,
367,
314,
7773,
14,
267,
1415,
26,
2549,
489,
1844,
26,
267,
1369,
26,
881,
446,
11015,
314,
1844,
370,
675,
1380,
10015,
314,
1950,
370,
314,
3982,
288,
2243,
14,
221,
961,
574,
12966,
370,
1902,
473,
8,
2764,
9,
503,
473,
8,
69,
1246,
680,
221,
710,
1844,
288,
574,
911,
849,
370,
314,
5827,
7773,
2863,
1844,
340,
288,
7179,
365,
2741,
315,
314,
2120,
14,
221,
334,
2764,
29,
1081,
12,
1455,
29,
1257,
12,
4178,
29,
16284,
680,
267,
849,
26,
378,
334,
1180,
2863,
1844,
9,
489,
3434,
26,
267,
1369,
26,
881,
446,
4094,
1482,
314,
3434,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
574,
365,
1202,
370,
12895,
288,
1902,
314,
14214,
4676,
503,
314,
325,
3735,
6299,
10298,
641,
1314,
288,
7773,
365,
1202,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
11958,
9,
911,
506,
1202,
3140,
14,
489,
2505,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
365,
282,
2863,
1423,
1202,
367,
1902,
473,
8,
2764,
9,
288,
503,
473,
8,
69,
1246,
9,
7773,
83,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
9032,
9,
911,
506,
1202,
3140,
14,
267,
849,
26,
2973,
489,
2653,
26,
267,
1369,
26,
881,
446,
11015,
314,
2653,
315,
4696,
367,
13882,
1958,
543,
314,
2784,
2243,
288,
367,
1902,
18170,
503,
10209,
3718,
14,
221,
982,
314,
2653,
365,
288,
22007,
2544,
314,
3439,
365,
9709,
12,
314,
859,
911,
1125,
14,
267,
849,
26,
1616,
489,
8635,
63,
21856,
26,
267,
1369,
26,
881,
446,
11015,
314,
12027,
25776,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
1423,
365,
1454,
1202,
367,
473,
8,
2764,
9,
7773,
83,
14,
288,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
288,
1750,
445,
8,
8490,
63,
7278,
63,
13716,
63,
3078,
3817,
9,
911,
506,
1202,
3140,
14,
489,
20210,
26,
267,
1369,
26,
881,
446,
1010,
23253,
314,
859,
370,
9509,
1979,
21744,
818,
641,
314,
3982,
2243,
288,
2544,
10209,
1263,
3718,
14,
221,
982,
440,
2013,
12,
314,
2243,
911,
288,
7427,
370,
5341,
1006,
3718,
315,
2222,
13,
27672,
818,
14,
982,
314,
574,
288,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
288,
445,
8,
8490,
63,
7278,
63,
27938,
11025,
9,
911,
506,
1202,
3140,
14,
267,
849,
26,
949,
267,
3415,
26,
788,
5066,
297,
283,
889,
418,
489,
1790,
63,
1529,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
340,
1415,
370,
9509,
1979,
21744,
818,
288,
641,
314,
3982,
2243,
14,
221,
982,
473,
8,
14204,
9,
365,
3055,
12,
2066,
642,
1423,
288,
1630,
6548,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
288,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
5580,
63,
6909,
9,
911,
506,
1202,
3140,
14,
267,
849,
26,
7179,
489,
7773,
26,
267,
1369,
26,
881,
446,
4094,
1482,
314,
7773,
1950,
370,
675,
1380,
18170,
370,
314,
288,
3982,
2243,
14,
267,
1415,
26,
2549,
267,
3415,
26,
288,
446,
325,
1246,
288,
446,
5053,
267,
849,
26,
5053,
489,
675,
63,
4266,
26
] |
[
199,
3,
334,
67,
9,
6900,
12,
22912,
8360,
651,
71,
10641,
665,
80,
681,
651,
71,
10641,
32,
4853,
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,
421,
199,
533,
5673,
3768,
11080,
8,
785,
304,
339,
327,
9739,
1584,
3794,
7956,
272,
29970,
2594,
275,
408,
199,
1419,
26,
523,
20210,
26,
272,
1369,
26,
489,
446,
1010,
23253,
314,
859,
370,
9509,
1979,
21744,
818,
641,
314,
3982,
2243,
267,
2544,
10209,
1263,
3718,
14,
221,
982,
440,
2013,
12,
314,
2243,
911,
267,
7427,
370,
5341,
1006,
3718,
315,
2222,
13,
27672,
818,
14,
982,
314,
574,
267,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
267,
445,
8,
8490,
63,
7278,
63,
27938,
11025,
9,
911,
506,
1202,
3140,
14,
272,
849,
26,
949,
272,
3415,
26,
788,
5066,
297,
283,
889,
418,
523,
1790,
63,
1529,
26,
272,
1369,
26,
489,
446,
11015,
314,
2505,
370,
675,
340,
1415,
370,
9509,
1979,
21744,
818,
267,
641,
314,
3982,
2243,
14,
221,
982,
473,
8,
14204,
9,
365,
3055,
12,
2066,
642,
1423,
267,
1630,
6548,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
267,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
5580,
63,
6909,
9,
911,
506,
1202,
3140,
14,
272,
849,
26,
7179,
523,
5022,
26,
272,
1369,
26,
489,
446,
437,
1211,
909,
3035,
1950,
2436,
14,
272,
849,
26,
2973,
272,
26265,
26,
489,
1591,
26,
267,
1369,
26,
881,
446,
11015,
314,
10237,
1591,
536,
503,
2287,
367,
18170,
370,
314,
3982,
288,
2243,
1806,
314,
2013,
7773,
14,
221,
710,
574,
402,
1591,
365,
1202,
465,
288,
314,
5724,
2287,
367,
314,
7773,
14,
267,
1415,
26,
2549,
489,
1844,
26,
267,
1369,
26,
881,
446,
11015,
314,
1844,
370,
675,
1380,
10015,
314,
1950,
370,
314,
3982,
288,
2243,
14,
221,
961,
574,
12966,
370,
1902,
473,
8,
2764,
9,
503,
473,
8,
69,
1246,
680,
221,
710,
1844,
288,
574,
911,
849,
370,
314,
5827,
7773,
2863,
1844,
340,
288,
7179,
365,
2741,
315,
314,
2120,
14,
221,
334,
2764,
29,
1081,
12,
1455,
29,
1257,
12,
4178,
29,
16284,
680,
267,
849,
26,
378,
334,
1180,
2863,
1844,
9,
489,
3434,
26,
267,
1369,
26,
881,
446,
4094,
1482,
314,
3434,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
574,
365,
1202,
370,
12895,
288,
1902,
314,
14214,
4676,
503,
314,
325,
3735,
6299,
10298,
641,
1314,
288,
7773,
365,
1202,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
11958,
9,
911,
506,
1202,
3140,
14,
489,
2505,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
365,
282,
2863,
1423,
1202,
367,
1902,
473,
8,
2764,
9,
288,
503,
473,
8,
69,
1246,
9,
7773,
83,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
288,
574,
402,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
9032,
9,
911,
506,
1202,
3140,
14,
267,
849,
26,
2973,
489,
2653,
26,
267,
1369,
26,
881,
446,
11015,
314,
2653,
315,
4696,
367,
13882,
1958,
543,
314,
2784,
2243,
288,
367,
1902,
18170,
503,
10209,
3718,
14,
221,
982,
314,
2653,
365,
288,
22007,
2544,
314,
3439,
365,
9709,
12,
314,
859,
911,
1125,
14,
267,
849,
26,
1616,
489,
8635,
63,
21856,
26,
267,
1369,
26,
881,
446,
11015,
314,
12027,
25776,
370,
675,
370,
12895,
314,
1950,
370,
288,
314,
3982,
2243,
14,
221,
961,
1423,
365,
1454,
1202,
367,
473,
8,
2764,
9,
7773,
83,
14,
288,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
288,
1750,
445,
8,
8490,
63,
7278,
63,
13716,
63,
3078,
3817,
9,
911,
506,
1202,
3140,
14,
489,
20210,
26,
267,
1369,
26,
881,
446,
1010,
23253,
314,
859,
370,
9509,
1979,
21744,
818,
641,
314,
3982,
2243,
288,
2544,
10209,
1263,
3718,
14,
221,
982,
440,
2013,
12,
314,
2243,
911,
288,
7427,
370,
5341,
1006,
3718,
315,
2222,
13,
27672,
818,
14,
982,
314,
574,
288,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
3734,
1750,
288,
445,
8,
8490,
63,
7278,
63,
27938,
11025,
9,
911,
506,
1202,
3140,
14,
267,
849,
26,
949,
267,
3415,
26,
788,
5066,
297,
283,
889,
418,
489,
1790,
63,
1529,
26,
267,
1369,
26,
881,
446,
11015,
314,
2505,
370,
675,
340,
1415,
370,
9509,
1979,
21744,
818,
288,
641,
314,
3982,
2243,
14,
221,
982,
473,
8,
14204,
9,
365,
3055,
12,
2066,
642,
1423,
288,
1630,
6548,
14,
982,
314,
574,
365,
440,
2013,
315,
314,
2120,
12,
314,
574,
402,
288,
3734,
1750,
445,
8,
8490,
63,
7278,
63,
5580,
63,
6909,
9,
911,
506,
1202,
3140,
14,
267,
849,
26,
7179,
489,
7773,
26,
267,
1369,
26,
881,
446,
4094,
1482,
314,
7773,
1950,
370,
675,
1380,
18170,
370,
314,
288,
3982,
2243,
14,
267,
1415,
26,
2549,
267,
3415,
26,
288,
446,
325,
1246,
288,
446,
5053,
267,
849,
26,
5053,
489,
675,
63,
4266,
26,
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,
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odus Add-on
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 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 General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from resources.lib.modules import trakt
from resources.lib.modules import cleangenre
from resources.lib.modules import cleantitle
from resources.lib.modules import control
from resources.lib.modules import client
from resources.lib.modules import cache
from resources.lib.modules import metacache
from resources.lib.modules import playcount
from resources.lib.modules import workers
from resources.lib.modules import views
from resources.lib.modules import utils
from resources.lib.indexers import navigator
import os,sys,re,json,urllib,urlparse,datetime
params = dict(urlparse.parse_qsl(sys.argv[2].replace('?',''))) if len(sys.argv) > 1 else dict()
action = params.get('action')
control.moderator()
class movies:
def __init__(self):
self.list = []
self.imdb_link = 'http://www.imdb.com'
self.trakt_link = 'http://api.trakt.tv'
self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
self.systime = (self.datetime).strftime('%Y%m%d%H%M%S%f')
self.year_date = (self.datetime - datetime.timedelta(days = 365)).strftime('%Y-%m-%d')
self.today_date = (self.datetime).strftime('%Y-%m-%d')
self.trakt_user = control.setting('trakt.user').strip()
self.imdb_user = control.setting('imdb.user').replace('ur', '')
self.tm_user = control.setting('tm.user')
self.fanart_tv_user = control.setting('fanart.tv.user')
self.user = str(control.setting('fanart.tv.user')) + str(control.setting('tm.user'))
self.lang = control.apiLanguage()['trakt']
self.hidecinema = control.setting('hidecinema')
self.search_link = 'http://api.trakt.tv/search/movie?limit=20&page=1&query='
self.fanart_tv_art_link = 'http://webservice.fanart.tv/v3/movies/%s'
self.fanart_tv_level_link = 'http://webservice.fanart.tv/v3/level'
self.tm_art_link = 'http://api.themoviedb.org/3/movie/%s/images?api_key=%s&language=en-US&include_image_language=en,%s,null' % ('%s', self.tm_user, self.lang)
self.tm_img_link = 'https://image.tmdb.org/t/p/w%s%s'
self.persons_link = 'http://www.imdb.com/search/name?count=100&name='
self.personlist_link = 'http://www.imdb.com/search/name?count=100&gender=male,female'
self.person_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&production_status=released&role=%s&sort=year,desc&count=40&start=1'
self.keyword_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie,documentary&num_votes=100,&release_date=,date[0]&keywords=%s&sort=moviemeter,asc&count=40&start=1'
self.oscars_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&production_status=released&groups=oscar_best_picture_winners&sort=year,desc&count=40&start=1'
self.theaters_link = 'http://www.imdb.com/search/title?title_type=feature&num_votes=1000,&release_date=date[365],date[0]&sort=release_date_us,desc&count=40&start=1'
self.year_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=100,&production_status=released&year=%s,%s&sort=moviemeter,asc&count=40&start=1'
if self.hidecinema == 'true':
self.popular_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=1000,&production_status=released&groups=top_1000&release_date=,date[90]&sort=moviemeter,asc&count=40&start=1'
self.views_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=1000,&production_status=released&sort=num_votes,desc&release_date=,date[90]&count=40&start=1'
self.featured_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=1000,&production_status=released&release_date=date[365],date[90]&sort=moviemeter,asc&count=40&start=1'
self.genre_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie,documentary&num_votes=100,&release_date=,date[90]&genres=%s&sort=moviemeter,asc&count=40&start=1'
self.language_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=100,&production_status=released&primary_language=%s&sort=moviemeter,asc&release_date=,date[90]&count=40&start=1'
self.certification_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=100,&production_status=released&certificates=us:%s&sort=moviemeter,asc&release_date=,date[90]&count=40&start=1'
self.boxoffice_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&production_status=released&sort=boxoffice_gross_us,desc&release_date=,date[90]&count=40&start=1'
else:
self.popular_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=1000,&production_status=released&groups=top_1000&sort=moviemeter,asc&count=40&start=1'
self.views_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=1000,&production_status=released&sort=num_votes,desc&count=40&start=1'
self.featured_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=1000,&production_status=released&release_date=date[365],date[60]&sort=moviemeter,asc&count=40&start=1'
self.genre_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie,documentary&num_votes=100,&release_date=,date[0]&genres=%s&sort=moviemeter,asc&count=40&start=1'
self.language_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=100,&production_status=released&primary_language=%s&sort=moviemeter,asc&count=40&start=1'
self.certification_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&num_votes=100,&production_status=released&certificates=us:%s&sort=moviemeter,asc&count=40&start=1'
self.boxoffice_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&production_status=released&sort=boxoffice_gross_us,desc&count=40&start=1'
self.added_link = 'http://www.imdb.com/search/title?title_type=feature,tv_movie&languages=en&num_votes=500,&production_status=released&release_date=%s,%s&sort=release_date,desc&count=20&start=1' % (self.year_date, self.today_date)
self.trending_link = 'http://api.trakt.tv/movies/trending?limit=40&page=1'
self.traktlists_link = 'http://api.trakt.tv/users/me/lists'
self.traktlikedlists_link = 'http://api.trakt.tv/users/likes/lists?limit=1000000'
self.traktlist_link = 'http://api.trakt.tv/users/%s/lists/%s/items'
self.traktcollection_link = 'http://api.trakt.tv/users/me/collection/movies'
self.traktwatchlist_link = 'http://api.trakt.tv/users/me/watchlist/movies'
self.traktfeatured_link = 'http://api.trakt.tv/recommendations/movies?limit=40'
self.trakthistory_link = 'http://api.trakt.tv/users/me/history/movies?limit=40&page=1'
self.imdblists_link = 'http://www.imdb.com/user/ur%s/lists?tab=all&sort=modified:desc&filter=titles' % self.imdb_user
self.imdblist_link = 'http://www.imdb.com/list/%s/?view=detail&sort=title:asc&title_type=feature,short,tv_movie,tv_special,video,documentary,game&start=1'
self.imdblist2_link = 'http://www.imdb.com/list/%s/?view=detail&sort=created:desc&title_type=feature,short,tv_movie,tv_special,video,documentary,game&start=1'
self.imdbwatchlist_link = 'http://www.imdb.com/user/ur%s/watchlist?sort=alpha,asc' % self.imdb_user
self.imdbwatchlist2_link = 'http://www.imdb.com/user/ur%s/watchlist?sort=date_added,desc' % self.imdb_user
def get(self, url, idx=True, create_directory=True):
try:
try: url = getattr(self, url + '_link')
except: pass
try: u = urlparse.urlparse(url).netloc.lower()
except: pass
if u in self.trakt_link and '/users/' in url:
try:
if url == self.trakthistory_link: raise Exception()
if not '/users/me/' in url: raise Exception()
if trakt.getActivity() > cache.timeout(self.trakt_list, url, self.trakt_user): raise Exception()
self.list = cache.get(self.trakt_list, 720, url, self.trakt_user)
except:
self.list = cache.get(self.trakt_list, 0, url, self.trakt_user)
if '/users/me/' in url and '/collection/' in url:
self.list = sorted(self.list, key=lambda k: utils.title_key(k['title']))
if idx == True: self.worker()
elif u in self.trakt_link and self.search_link in url:
self.list = cache.get(self.trakt_list, 1, url, self.trakt_user)
if idx == True: self.worker(level=0)
elif u in self.trakt_link:
self.list = cache.get(self.trakt_list, 24, url, self.trakt_user)
if idx == True: self.worker()
elif u in self.imdb_link and ('/user/' in url or '/list/' in url):
self.list = cache.get(self.imdb_list, 0, url)
if idx == True: self.worker()
elif u in self.imdb_link:
self.list = cache.get(self.imdb_list, 24, url)
if idx == True: self.worker()
if idx == True and create_directory == True: self.movieDirectory(self.list)
return self.list
except:
pass
def widget(self):
setting = control.setting('movie.widget')
if setting == '2':
self.get(self.trending_link)
elif setting == '3':
self.get(self.popular_link)
elif setting == '4':
self.get(self.theaters_link)
elif setting == '5':
self.get(self.added_link)
else:
self.get(self.featured_link)
def search(self):
navigator.navigator().addDirectoryItem(32603, 'movieSearchnew', 'search.png', 'DefaultMovies.png')
try: from sqlite3 import dbapi2 as database
except: from pysqlite2 import dbapi2 as database
dbcon = database.connect(control.searchFile)
dbcur = dbcon.cursor()
try:
dbcur.executescript("CREATE TABLE IF NOT EXISTS movies (ID Integer PRIMARY KEY AUTOINCREMENT, term);")
except:
pass
dbcur.execute("SELECT * FROM movies ORDER BY ID DESC")
lst = []
delete_option = False
for (id,term) in dbcur.fetchall():
if term not in str(lst):
delete_option = True
navigator.navigator().addDirectoryItem(term, 'movieSearchterm&name=%s' % term, 'search.png', 'DefaultMovies.png')
lst += [(term)]
dbcur.close()
if delete_option:
navigator.navigator().addDirectoryItem(32605, 'clearCacheSearch', 'tools.png', 'DefaultAddonProgram.png')
navigator.navigator().endDirectory()
def search_new(self):
control.idle()
t = control.lang(32010).encode('utf-8')
k = control.keyboard('', t) ; k.doModal()
q = k.getText() if k.isConfirmed() else None
if (q == None or q == ''): return
try: from sqlite3 import dbapi2 as database
except: from pysqlite2 import dbapi2 as database
dbcon = database.connect(control.searchFile)
dbcur = dbcon.cursor()
dbcur.execute("INSERT INTO movies VALUES (?,?)", (None,q))
dbcon.commit()
dbcur.close()
url = self.search_link + urllib.quote_plus(q)
url = '%s?action=moviePage&url=%s' % (sys.argv[0], urllib.quote_plus(url))
control.execute('Container.Update(%s)' % url)
def search_term(self, name):
control.idle()
url = self.search_link + urllib.quote_plus(name)
url = '%s?action=moviePage&url=%s' % (sys.argv[0], urllib.quote_plus(url))
control.execute('Container.Update(%s)' % url)
def person(self):
try:
control.idle()
t = control.lang(32010).encode('utf-8')
k = control.keyboard('', t) ; k.doModal()
q = k.getText() if k.isConfirmed() else None
if (q == None or q == ''): return
url = self.persons_link + urllib.quote_plus(q)
url = '%s?action=moviePersons&url=%s' % (sys.argv[0], urllib.quote_plus(url))
control.execute('Container.Update(%s)' % url)
except:
return
def genres(self):
genres = [
('Action', 'action', True),
('Adventure', 'adventure', True),
('Animation', 'animation', True),
('Anime', 'anime', False),
('Biography', 'biography', True),
('Comedy', 'comedy', True),
('Crime', 'crime', True),
('Documentary', 'documentary', True),
('Drama', 'drama', True),
('Family', 'family', True),
('Fantasy', 'fantasy', True),
('History', 'history', True),
('Horror', 'horror', True),
('Music ', 'music', True),
('Musical', 'musical', True),
('Mystery', 'mystery', True),
('Romance', 'romance', True),
('Science Fiction', 'sci_fi', True),
('Sport', 'sport', True),
('Thriller', 'thriller', True),
('War', 'war', True),
('Western', 'western', True)
]
for i in genres: self.list.append(
{
'name': cleangenre.lang(i[0], self.lang),
'url': self.genre_link % i[1] if i[2] else self.keyword_link % i[1],
'image': 'genres.png',
'action': 'movies'
})
self.addDirectory(self.list)
return self.list
def languages(self):
languages = [
('Arabic', 'ar'),
('Bosnian', 'bs'),
('Bulgarian', 'bg'),
('Chinese', 'zh'),
('Croatian', 'hr'),
('Dutch', 'nl'),
('English', 'en'),
('Finnish', 'fi'),
('French', 'fr'),
('German', 'de'),
('Greek', 'el'),
('Hebrew', 'he'),
('Hindi ', 'hi'),
('Hungarian', 'hu'),
('Icelandic', 'is'),
('Italian', 'it'),
('Japanese', 'ja'),
('Korean', 'ko'),
('Macedonian', 'mk'),
('Norwegian', 'no'),
('Persian', 'fa'),
('Polish', 'pl'),
('Portuguese', 'pt'),
('Punjabi', 'pa'),
('Romanian', 'ro'),
('Russian', 'ru'),
('Serbian', 'sr'),
('Slovenian', 'sl'),
('Spanish', 'es'),
('Swedish', 'sv'),
('Turkish', 'tr'),
('Ukrainian', 'uk')
]
for i in languages: self.list.append({'name': str(i[0]), 'url': self.language_link % i[1], 'image': 'languages.png', 'action': 'movies'})
self.addDirectory(self.list)
return self.list
def certifications(self):
certificates = ['G', 'PG', 'PG-13', 'R', 'NC-17']
for i in certificates: self.list.append({'name': str(i), 'url': self.certification_link % str(i).replace('-', '_').lower(), 'image': 'certificates.png', 'action': 'movies'})
self.addDirectory(self.list)
return self.list
def years(self):
year = (self.datetime.strftime('%Y'))
for i in range(int(year)-0, 1900, -1): self.list.append({'name': str(i), 'url': self.year_link % (str(i), str(i)), 'image': 'years.png', 'action': 'movies'})
self.addDirectory(self.list)
return self.list
def persons(self, url):
if url == None:
self.list = cache.get(self.imdb_person_list, 24, self.personlist_link)
else:
self.list = cache.get(self.imdb_person_list, 1, url)
for i in range(0, len(self.list)): self.list[i].update({'action': 'movies'})
self.addDirectory(self.list)
return self.list
def userlists(self):
try:
userlists = []
if trakt.getTraktCredentialsInfo() == False: raise Exception()
activity = trakt.getActivity()
except:
pass
try:
if trakt.getTraktCredentialsInfo() == False: raise Exception()
try:
if activity > cache.timeout(self.trakt_user_list, self.traktlists_link, self.trakt_user): raise Exception()
userlists += cache.get(self.trakt_user_list, 720, self.traktlists_link, self.trakt_user)
except:
userlists += cache.get(self.trakt_user_list, 0, self.traktlists_link, self.trakt_user)
except:
pass
try:
self.list = []
if self.imdb_user == '': raise Exception()
userlists += cache.get(self.imdb_user_list, 0, self.imdblists_link)
except:
pass
try:
self.list = []
if trakt.getTraktCredentialsInfo() == False: raise Exception()
try:
if activity > cache.timeout(self.trakt_user_list, self.traktlikedlists_link, self.trakt_user): raise Exception()
userlists += cache.get(self.trakt_user_list, 720, self.traktlikedlists_link, self.trakt_user)
except:
userlists += cache.get(self.trakt_user_list, 0, self.traktlikedlists_link, self.trakt_user)
except:
pass
self.list = userlists
for i in range(0, len(self.list)): self.list[i].update({'image': 'userlists.png', 'action': 'movies'})
self.addDirectory(self.list, queue=True)
return self.list
def trakt_list(self, url, user):
try:
q = dict(urlparse.parse_qsl(urlparse.urlsplit(url).query))
q.update({'extended': 'full'})
q = (urllib.urlencode(q)).replace('%2C', ',')
u = url.replace('?' + urlparse.urlparse(url).query, '') + '?' + q
result = trakt.getTraktAsJson(u)
items = []
for i in result:
try: items.append(i['movie'])
except: pass
if len(items) == 0:
items = result
except:
return
try:
q = dict(urlparse.parse_qsl(urlparse.urlsplit(url).query))
if not int(q['limit']) == len(items): raise Exception()
q.update({'page': str(int(q['page']) + 1)})
q = (urllib.urlencode(q)).replace('%2C', ',')
next = url.replace('?' + urlparse.urlparse(url).query, '') + '?' + q
next = next.encode('utf-8')
except:
next = ''
for item in items:
try:
title = item['title']
title = client.replaceHTMLCodes(title)
year = item['year']
year = re.sub('[^0-9]', '', str(year))
if int(year) > int((self.datetime).strftime('%Y')): raise Exception()
imdb = item['ids']['imdb']
if imdb == None or imdb == '': raise Exception()
imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))
tmdb = str(item.get('ids', {}).get('tmdb', 0))
try: premiered = item['released']
except: premiered = '0'
try: premiered = re.compile('(\d{4}-\d{2}-\d{2})').findall(premiered)[0]
except: premiered = '0'
try: genre = item['genres']
except: genre = '0'
genre = [i.title() for i in genre]
if genre == []: genre = '0'
genre = ' / '.join(genre)
try: duration = str(item['runtime'])
except: duration = '0'
if duration == None: duration = '0'
try: rating = str(item['rating'])
except: rating = '0'
if rating == None or rating == '0.0': rating = '0'
try: votes = str(item['votes'])
except: votes = '0'
try: votes = str(format(int(votes),',d'))
except: pass
if votes == None: votes = '0'
try: mpaa = item['certification']
except: mpaa = '0'
if mpaa == None: mpaa = '0'
try: plot = item['overview']
except: plot = '0'
if plot == None: plot = '0'
plot = client.replaceHTMLCodes(plot)
try: tagline = item['tagline']
except: tagline = '0'
if tagline == None: tagline = '0'
tagline = client.replaceHTMLCodes(tagline)
self.list.append({'title': title, 'originaltitle': title, 'year': year, 'premiered': premiered, 'genre': genre, 'duration': duration, 'rating': rating, 'votes': votes, 'mpaa': mpaa, 'plot': plot, 'tagline': tagline, 'imdb': imdb, 'tmdb': tmdb, 'tvdb': '0', 'poster': '0', 'next': next})
except:
pass
return self.list
def trakt_user_list(self, url, user):
try:
items = trakt.getTraktAsJson(url)
except:
pass
for item in items:
try:
try: name = item['list']['name']
except: name = item['name']
name = client.replaceHTMLCodes(name)
try: url = (trakt.slug(item['list']['user']['username']), item['list']['ids']['slug'])
except: url = ('me', item['ids']['slug'])
url = self.traktlist_link % url
url = url.encode('utf-8')
self.list.append({'name': name, 'url': url, 'context': url})
except:
pass
self.list = sorted(self.list, key=lambda k: utils.title_key(k['name']))
return self.list
def imdb_list(self, url):
try:
for i in re.findall('date\[(\d+)\]', url):
url = url.replace('date[%s]' % i, (self.datetime - datetime.timedelta(days = int(i))).strftime('%Y-%m-%d'))
def imdb_watchlist_id(url):
return client.parseDOM(client.request(url), 'meta', ret='content', attrs = {'property': 'pageId'})[0]
if url == self.imdbwatchlist_link:
url = cache.get(imdb_watchlist_id, 8640, url)
url = self.imdblist_link % url
elif url == self.imdbwatchlist2_link:
url = cache.get(imdb_watchlist_id, 8640, url)
url = self.imdblist2_link % url
result = client.request(url)
result = result.replace('\n', ' ')
items = client.parseDOM(result, 'div', attrs = {'class': 'lister-item mode-advanced'})
items += client.parseDOM(result, 'div', attrs = {'class': 'list_item.+?'})
except:
return
try:
next = client.parseDOM(result, 'a', ret='href', attrs = {'class': 'lister-page-next.+?'})
if len(next) == 0:
next = client.parseDOM(result, 'div', attrs = {'class': 'pagination'})[0]
next = zip(client.parseDOM(next, 'a', ret='href'), client.parseDOM(next, 'a'))
next = [i[0] for i in next if 'Next' in i[1]]
next = url.replace(urlparse.urlparse(url).query, urlparse.urlparse(next[0]).query)
next = client.replaceHTMLCodes(next)
next = next.encode('utf-8')
except:
next = ''
for item in items:
try:
title = client.parseDOM(item, 'a')[1]
title = client.replaceHTMLCodes(title)
title = title.encode('utf-8')
year = client.parseDOM(item, 'span', attrs = {'class': 'lister-item-year.+?'})
year += client.parseDOM(item, 'span', attrs = {'class': 'year_type'})
try: year = re.compile('(\d{4})').findall(year)[0]
except: year = '0'
year = year.encode('utf-8')
if int(year) > int((self.datetime).strftime('%Y')): raise Exception()
imdb = client.parseDOM(item, 'a', ret='href')[0]
imdb = re.findall('(tt\d*)', imdb)[0]
imdb = imdb.encode('utf-8')
try: poster = client.parseDOM(item, 'img', ret='loadlate')[0]
except: poster = '0'
if '/nopicture/' in poster: poster = '0'
poster = re.sub('(?:_SX|_SY|_UX|_UY|_CR|_AL)(?:\d+|_).+?\.', '_SX500.', poster)
poster = client.replaceHTMLCodes(poster)
poster = poster.encode('utf-8')
try: genre = client.parseDOM(item, 'span', attrs = {'class': 'genre'})[0]
except: genre = '0'
genre = ' / '.join([i.strip() for i in genre.split(',')])
if genre == '': genre = '0'
genre = client.replaceHTMLCodes(genre)
genre = genre.encode('utf-8')
try: duration = re.findall('(\d+?) min(?:s|)', item)[-1]
except: duration = '0'
duration = duration.encode('utf-8')
rating = '0'
try: rating = client.parseDOM(item, 'span', attrs = {'class': 'rating-rating'})[0]
except: pass
try: rating = client.parseDOM(rating, 'span', attrs = {'class': 'value'})[0]
except: rating = '0'
try: rating = client.parseDOM(item, 'div', ret='data-value', attrs = {'class': '.*?imdb-rating'})[0]
except: pass
if rating == '' or rating == '-': rating = '0'
rating = client.replaceHTMLCodes(rating)
rating = rating.encode('utf-8')
try: votes = client.parseDOM(item, 'div', ret='title', attrs = {'class': '.*?rating-list'})[0]
except: votes = '0'
try: votes = re.findall('\((.+?) vote(?:s|)\)', votes)[0]
except: votes = '0'
if votes == '': votes = '0'
votes = client.replaceHTMLCodes(votes)
votes = votes.encode('utf-8')
try: mpaa = client.parseDOM(item, 'span', attrs = {'class': 'certificate'})[0]
except: mpaa = '0'
if mpaa == '' or mpaa == 'NOT_RATED': mpaa = '0'
mpaa = mpaa.replace('_', '-')
mpaa = client.replaceHTMLCodes(mpaa)
mpaa = mpaa.encode('utf-8')
try: director = re.findall('Director(?:s|):(.+?)(?:\||</div>)', item)[0]
except: director = '0'
director = client.parseDOM(director, 'a')
director = ' / '.join(director)
if director == '': director = '0'
director = client.replaceHTMLCodes(director)
director = director.encode('utf-8')
try: cast = re.findall('Stars(?:s|):(.+?)(?:\||</div>)', item)[0]
except: cast = '0'
cast = client.replaceHTMLCodes(cast)
cast = cast.encode('utf-8')
cast = client.parseDOM(cast, 'a')
if cast == []: cast = '0'
plot = '0'
try: plot = client.parseDOM(item, 'p', attrs = {'class': 'text-muted'})[0]
except: pass
try: plot = client.parseDOM(item, 'div', attrs = {'class': 'item_description'})[0]
except: pass
plot = plot.rsplit('<span>', 1)[0].strip()
plot = re.sub('<.+?>|</.+?>', '', plot)
if plot == '': plot = '0'
plot = client.replaceHTMLCodes(plot)
plot = plot.encode('utf-8')
self.list.append({'title': title, 'originaltitle': title, 'year': year, 'genre': genre, 'duration': duration, 'rating': rating, 'votes': votes, 'mpaa': mpaa, 'director': director, 'cast': cast, 'plot': plot, 'tagline': '0', 'imdb': imdb, 'tmdb': '0', 'tvdb': '0', 'poster': poster, 'next': next})
except:
pass
return self.list
def imdb_person_list(self, url):
try:
result = client.request(url)
items = client.parseDOM(result, 'tr', attrs = {'class': '.+? detailed'})
except:
return
for item in items:
try:
name = client.parseDOM(item, 'a', ret='title')[0]
name = client.replaceHTMLCodes(name)
name = name.encode('utf-8')
url = client.parseDOM(item, 'a', ret='href')[0]
url = re.findall('(nm\d*)', url, re.I)[0]
url = self.person_link % url
url = client.replaceHTMLCodes(url)
url = url.encode('utf-8')
image = client.parseDOM(item, 'img', ret='src')[0]
if not ('._SX' in image or '._SY' in image): raise Exception()
image = re.sub('(?:_SX|_SY|_UX|_UY|_CR|_AL)(?:\d+|_).+?\.', '_SX500.', image)
image = client.replaceHTMLCodes(image)
image = image.encode('utf-8')
self.list.append({'name': name, 'url': url, 'image': image})
except:
pass
return self.list
def imdb_user_list(self, url):
try:
result = client.request(url)
items = client.parseDOM(result, 'div', attrs = {'class': 'list_name'})
except:
pass
for item in items:
try:
name = client.parseDOM(item, 'a')[0]
name = client.replaceHTMLCodes(name)
name = name.encode('utf-8')
url = client.parseDOM(item, 'a', ret='href')[0]
url = url.split('/list/', 1)[-1].replace('/', '')
url = self.imdblist_link % url
url = client.replaceHTMLCodes(url)
url = url.encode('utf-8')
self.list.append({'name': name, 'url': url, 'context': url})
except:
pass
self.list = sorted(self.list, key=lambda k: utils.title_key(k['name']))
return self.list
def worker(self, level=1):
self.meta = []
total = len(self.list)
self.fanart_tv_headers = {'api-key': 'NDZkZmMyN2M1MmE0YTc3MjY3NWQ4ZTMyYjdiY2E2OGU='.decode('base64')}
if not self.fanart_tv_user == '':
self.fanart_tv_headers.update({'client-key': self.fanart_tv_user})
for i in range(0, total): self.list[i].update({'metacache': False})
self.list = metacache.fetch(self.list, self.lang, self.user)
for r in range(0, total, 40):
threads = []
for i in range(r, r+40):
if i <= total: threads.append(workers.Thread(self.super_info, i))
[i.start() for i in threads]
[i.join() for i in threads]
if self.meta: metacache.insert(self.meta)
self.list = [i for i in self.list if not i['imdb'] == '0']
self.list = metacache.local(self.list, self.tm_img_link, 'poster3', 'fanart2')
if self.fanart_tv_user == '':
for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
def super_info(self, i):
try:
if self.list[i]['metacache'] == True: raise Exception()
imdb = self.list[i]['imdb']
item = trakt.getMovieSummary(imdb)
title = item.get('title')
title = client.replaceHTMLCodes(title)
originaltitle = title
year = item.get('year', 0)
year = re.sub('[^0-9]', '', str(year))
imdb = item.get('ids', {}).get('imdb', '0')
imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))
tmdb = str(item.get('ids', {}).get('tmdb', 0))
premiered = item.get('released', '0')
try: premiered = re.compile('(\d{4}-\d{2}-\d{2})').findall(premiered)[0]
except: premiered = '0'
genre = item.get('genres', [])
genre = [x.title() for x in genre]
genre = ' / '.join(genre).strip()
if not genre: genre = '0'
duration = str(item.get('Runtime', 0))
rating = item.get('rating', '0')
if not rating or rating == '0.0': rating = '0'
votes = item.get('votes', '0')
try: votes = str(format(int(votes), ',d'))
except: pass
mpaa = item.get('certification', '0')
if not mpaa: mpaa = '0'
tagline = item.get('tagline', '0')
plot = item.get('overview', '0')
people = trakt.getPeople(imdb, 'movies')
director = writer = ''
if 'crew' in people and 'directing' in people['crew']:
director = ', '.join([director['person']['name'] for director in people['crew']['directing'] if director['job'].lower() == 'director'])
if 'crew' in people and 'writing' in people['crew']:
writer = ', '.join([writer['person']['name'] for writer in people['crew']['writing'] if writer['job'].lower() in ['writer', 'screenplay', 'author']])
cast = []
for person in people.get('cast', []):
cast.append({'name': person['person']['name'], 'role': person['character']})
cast = [(person['name'], person['role']) for person in cast]
try:
if self.lang == 'en' or self.lang not in item.get('available_translations', [self.lang]): raise Exception()
trans_item = trakt.getMovieTranslation(imdb, self.lang, full=True)
title = trans_item.get('title') or title
tagline = trans_item.get('tagline') or tagline
plot = trans_item.get('overview') or plot
except:
pass
try:
artmeta = True
#if self.fanart_tv_user == '': raise Exception()
art = client.request(self.fanart_tv_art_link % imdb, headers=self.fanart_tv_headers, timeout='10', error=True)
try: art = json.loads(art)
except: artmeta = False
except:
pass
try:
poster2 = art['movieposter']
poster2 = [x for x in poster2 if x.get('lang') == self.lang][::-1] + [x for x in poster2 if x.get('lang') == 'en'][::-1] + [x for x in poster2 if x.get('lang') in ['00', '']][::-1]
poster2 = poster2[0]['url'].encode('utf-8')
except:
poster2 = '0'
try:
if 'moviebackground' in art: fanart = art['moviebackground']
else: fanart = art['moviethumb']
fanart = [x for x in fanart if x.get('lang') == self.lang][::-1] + [x for x in fanart if x.get('lang') == 'en'][::-1] + [x for x in fanart if x.get('lang') in ['00', '']][::-1]
fanart = fanart[0]['url'].encode('utf-8')
except:
fanart = '0'
try:
banner = art['moviebanner']
banner = [x for x in banner if x.get('lang') == self.lang][::-1] + [x for x in banner if x.get('lang') == 'en'][::-1] + [x for x in banner if x.get('lang') in ['00', '']][::-1]
banner = banner[0]['url'].encode('utf-8')
except:
banner = '0'
try:
if 'hdmovielogo' in art: clearlogo = art['hdmovielogo']
else: clearlogo = art['clearlogo']
clearlogo = [x for x in clearlogo if x.get('lang') == self.lang][::-1] + [x for x in clearlogo if x.get('lang') == 'en'][::-1] + [x for x in clearlogo if x.get('lang') in ['00', '']][::-1]
clearlogo = clearlogo[0]['url'].encode('utf-8')
except:
clearlogo = '0'
try:
if 'hdmovieclearart' in art: clearart = art['hdmovieclearart']
else: clearart = art['clearart']
clearart = [x for x in clearart if x.get('lang') == self.lang][::-1] + [x for x in clearart if x.get('lang') == 'en'][::-1] + [x for x in clearart if x.get('lang') in ['00', '']][::-1]
clearart = clearart[0]['url'].encode('utf-8')
except:
clearart = '0'
try:
if self.tm_user == '': raise Exception()
art2 = client.request(self.tm_art_link % imdb, timeout='10', error=True)
art2 = json.loads(art2)
except:
pass
try:
poster3 = art2['posters']
poster3 = [x for x in poster3 if x.get('iso_639_1') == self.lang] + [x for x in poster3 if x.get('iso_639_1') == 'en'] + [x for x in poster3 if x.get('iso_639_1') not in [self.lang, 'en']]
poster3 = [(x['width'], x['file_path']) for x in poster3]
poster3 = [(x[0], x[1]) if x[0] < 300 else ('300', x[1]) for x in poster3]
poster3 = self.tm_img_link % poster3[0]
poster3 = poster3.encode('utf-8')
except:
poster3 = '0'
try:
fanart2 = art2['backdrops']
fanart2 = [x for x in fanart2 if x.get('iso_639_1') == self.lang] + [x for x in fanart2 if x.get('iso_639_1') == 'en'] + [x for x in fanart2 if x.get('iso_639_1') not in [self.lang, 'en']]
fanart2 = [x for x in fanart2 if x.get('width') == 1920] + [x for x in fanart2 if x.get('width') < 1920]
fanart2 = [(x['width'], x['file_path']) for x in fanart2]
fanart2 = [(x[0], x[1]) if x[0] < 1280 else ('1280', x[1]) for x in fanart2]
fanart2 = self.tm_img_link % fanart2[0]
fanart2 = fanart2.encode('utf-8')
except:
fanart2 = '0'
item = {'title': title, 'originaltitle': originaltitle, 'year': year, 'imdb': imdb, 'tmdb': tmdb, 'poster': '0', 'poster2': poster2, 'poster3': poster3, 'banner': banner, 'fanart': fanart, 'fanart2': fanart2, 'clearlogo': clearlogo, 'clearart': clearart, 'premiered': premiered, 'genre': genre, 'duration': duration, 'rating': rating, 'votes': votes, 'mpaa': mpaa, 'director': director, 'writer': writer, 'cast': cast, 'plot': plot, 'tagline': tagline}
item = dict((k,v) for k, v in item.iteritems() if not v == '0')
self.list[i].update(item)
if artmeta == False: raise Exception()
meta = {'imdb': imdb, 'tmdb': tmdb, 'tvdb': '0', 'lang': self.lang, 'user': self.user, 'item': item}
self.meta.append(meta)
except:
pass
def movieDirectory(self, items):
if items == None or len(items) == 0: control.idle() ; sys.exit()
sysaddon = sys.argv[0]
syshandle = int(sys.argv[1])
addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')
traktCredentials = trakt.getTraktCredentialsInfo()
try: isOld = False ; control.item().getArt('type')
except: isOld = True
isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false'
indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators()
playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8')
watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')
unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')
queueMenu = control.lang(32065).encode('utf-8')
traktManagerMenu = control.lang(32070).encode('utf-8')
nextMenu = control.lang(32053).encode('utf-8')
addToLibrary = control.lang(32551).encode('utf-8')
for i in items:
try:
label = '%s (%s)' % (i['title'], i['year'])
imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year']
sysname = urllib.quote_plus('%s (%s)' % (title, year))
systitle = urllib.quote_plus(title)
meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb})
meta.update({'tmdb_id': tmdb})
meta.update({'mediatype': 'movie'})
meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(label))})
#meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb})
if not 'duration' in i: meta.update({'duration': '120'})
elif i['duration'] == '0': meta.update({'duration': '120'})
try: meta.update({'duration': str(int(meta['duration']) * 60)})
except: pass
try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
except: pass
poster = [i[x] for x in ['poster3', 'poster', 'poster2'] if i.get(x, '0') != '0']
poster = poster[0] if poster else addonPoster
meta.update({'poster': poster})
sysmeta = urllib.quote_plus(json.dumps(meta))
url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime)
sysurl = urllib.quote_plus(url)
path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb)
cm = []
cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))
try:
overlay = int(playcount.getMovieOverlay(indicators, imdb))
if overlay == 7:
cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb)))
meta.update({'playcount': 1, 'overlay': 7})
else:
cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb)))
meta.update({'playcount': 0, 'overlay': 6})
except:
pass
if traktCredentials == True:
cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb)))
cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))
if isOld == True:
cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))
cm.append((addToLibrary, 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb)))
item = control.item(label=label)
art = {}
art.update({'icon': poster, 'thumb': poster, 'poster': poster})
if 'banner' in i and not i['banner'] == '0':
art.update({'banner': i['banner']})
else:
art.update({'banner': addonBanner})
if 'clearlogo' in i and not i['clearlogo'] == '0':
art.update({'clearlogo': i['clearlogo']})
if 'clearart' in i and not i['clearart'] == '0':
art.update({'clearart': i['clearart']})
if settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0':
item.setProperty('Fanart_Image', i['fanart2'])
elif settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0':
item.setProperty('Fanart_Image', i['fanart'])
elif not addonFanart == None:
item.setProperty('Fanart_Image', addonFanart)
item.setArt(art)
item.addContextMenuItems(cm)
item.setProperty('IsPlayable', isPlayable)
item.setInfo(type='Video', infoLabels = meta)
video_streaminfo = {'codec': 'h264'}
item.addStreamInfo('video', video_streaminfo)
control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False)
except:
pass
try:
url = items[0]['next']
if url == '': raise Exception()
icon = control.addonNext()
url = '%s?action=moviePage&url=%s' % (sysaddon, urllib.quote_plus(url))
item = control.item(label=nextMenu)
item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
except:
pass
control.content(syshandle, 'movies')
control.directory(syshandle, cacheToDisc=True)
views.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})
def addDirectory(self, items, queue=False):
if items == None or len(items) == 0: control.idle() ; sys.exit()
sysaddon = sys.argv[0]
syshandle = int(sys.argv[1])
addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath()
queueMenu = control.lang(32065).encode('utf-8')
playRandom = control.lang(32535).encode('utf-8')
addToLibrary = control.lang(32551).encode('utf-8')
for i in items:
try:
name = i['name']
if i['image'].startswith('http'): thumb = i['image']
elif not artPath == None: thumb = os.path.join(artPath, i['image'])
else: thumb = addonThumb
url = '%s?action=%s' % (sysaddon, i['action'])
try: url += '&url=%s' % urllib.quote_plus(i['url'])
except: pass
cm = []
cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=movie&url=%s)' % (sysaddon, urllib.quote_plus(i['url']))))
if queue == True:
cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))
try: cm.append((addToLibrary, 'RunPlugin(%s?action=moviesToLibrary&url=%s)' % (sysaddon, urllib.quote_plus(i['context']))))
except: pass
item = control.item(label=name)
item.setArt({'icon': thumb, 'thumb': thumb})
if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
item.addContextMenuItems(cm)
control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
except:
pass
control.content(syshandle, 'addons')
control.directory(syshandle, cacheToDisc=True)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
2344,
272,
1316,
364,
527,
2654,
13,
265,
339,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
2344,
421,
199,
504,
5944,
14,
773,
14,
3112,
492,
30501,
199,
504,
5944,
14,
773,
14,
3112,
492,
15158,
621,
287,
264,
199,
504,
5944,
14,
773,
14,
3112,
492,
3633,
1213,
199,
504,
5944,
14,
773,
14,
3112,
492,
3304,
199,
504,
5944,
14,
773,
14,
3112,
492,
1890,
199,
504,
5944,
14,
773,
14,
3112,
492,
2581,
199,
504,
5944,
14,
773,
14,
3112,
492,
3404,
1637,
199,
504,
5944,
14,
773,
14,
3112,
492,
5232,
835,
199,
504,
5944,
14,
773,
14,
3112,
492,
14123,
199,
504,
5944,
14,
773,
14,
3112,
492,
6858,
199,
504,
5944,
14,
773,
14,
3112,
492,
3778,
199,
504,
5944,
14,
773,
14,
1080,
1192,
492,
12670,
24934,
199,
199,
646,
747,
12,
1274,
12,
264,
12,
1001,
12,
4078,
12,
10290,
12,
2083,
199,
199,
1162,
275,
1211,
8,
10290,
14,
1122,
63,
26714,
8,
1274,
14,
3020,
59,
18,
1055,
1814,
360,
31,
1673,
7058,
340,
822,
8,
1274,
14,
3020,
9,
690,
413,
587,
1211,
342,
199,
199,
1287,
275,
1862,
14,
362,
360,
1287,
358,
199,
199,
2785,
14,
25597,
342,
421,
199,
533,
1303,
14484,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
513,
275,
942,
398,
291,
14,
17117,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
7,
267,
291,
14,
28257,
63,
1073,
275,
283,
1014,
921,
1246,
14,
28257,
14,
6993,
7,
267,
291,
14,
2083,
275,
334,
2083,
14,
2083,
14,
10779,
342,
446,
2197,
14,
7473,
8,
8419,
275,
959,
430,
267,
291,
14,
1786,
7696,
275,
334,
277,
14,
2083,
680,
6205,
3508,
57,
5,
77,
5,
68,
5,
40,
5,
45,
5,
51,
5,
70,
358,
267,
291,
14,
3403,
63,
602,
275,
334,
277,
14,
2083,
446,
2197,
14,
7473,
8,
4899,
275,
28046,
4992,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
267,
291,
14,
8136,
63,
602,
275,
334,
277,
14,
2083,
680,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
267,
291,
14,
28257,
63,
751,
275,
3304,
14,
6031,
360,
28257,
14,
751,
1959,
1913,
342,
267,
291,
14,
17117,
63,
751,
275,
3304,
14,
6031,
360,
17117,
14,
751,
1959,
1814,
360,
300,
297,
4074,
267,
291,
14,
7574,
63,
751,
275,
3304,
14,
6031,
360,
7574,
14,
751,
358,
267,
291,
14,
24138,
63,
6993,
63,
751,
275,
3304,
14,
6031,
360,
24138,
14,
6993,
14,
751,
358,
267,
291,
14,
751,
275,
620,
8,
2785,
14,
6031,
360,
24138,
14,
6993,
14,
751,
1333,
435,
620,
8,
2785,
14,
6031,
360,
7574,
14,
751,
1333,
267,
291,
14,
4159,
275,
3304,
14,
1246,
8493,
12047,
28257,
418,
267,
291,
14,
8191,
67,
1132,
391,
275,
3304,
14,
6031,
360,
8191,
67,
1132,
391,
358,
398,
291,
14,
1733,
63,
1073,
275,
283,
1014,
921,
1246,
14,
28257,
14,
6993,
15,
1733,
15,
10888,
31,
3097,
29,
1165,
6,
1606,
29,
17,
6,
1131,
534,
267,
291,
14,
24138,
63,
6993,
63,
580,
63,
1073,
275,
283,
1014,
921,
2520,
1364,
14,
24138,
14,
6993,
15,
86,
19,
15,
20888,
3149,
83,
7,
267,
291,
14,
24138,
63,
6993,
63,
1896,
63,
1073,
275,
283,
1014,
921,
2520,
1364,
14,
24138,
14,
6993,
15,
86,
19,
15,
1896,
7,
267,
291,
14,
7574,
63,
580,
63,
1073,
275,
283,
1014,
921,
1246,
14,
1589,
573,
433,
28121,
14,
1308,
15,
19,
15,
10888,
3149,
83,
15,
4782,
31,
1246,
63,
498,
2458,
83,
6,
3671,
29,
287,
13,
1668,
6,
2613,
63,
1569,
63,
3671,
29,
287,
8719,
83,
12,
2307,
7,
450,
16651,
83,
297,
291,
14,
7574,
63,
751,
12,
291,
14,
4159,
9,
267,
291,
14,
7574,
63,
4060,
63,
1073,
275,
283,
2859,
921,
1569,
14,
7574,
697,
14,
1308,
15,
84,
15,
80,
15,
87,
5,
83,
5,
83,
7,
398,
291,
14,
32146,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
354,
31,
835,
29,
1960,
6,
354,
534,
267,
291,
14,
5484,
513,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
354,
31,
835,
29,
1960,
6,
15791,
29,
17667,
12,
771,
17667,
7,
267,
291,
14,
5484,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
1213,
31,
1213,
63,
466,
29,
4445,
12,
6993,
63,
10888,
6,
10777,
63,
1205,
29,
26267,
6,
3756,
2458,
83,
6,
3191,
29,
3403,
12,
3257,
6,
835,
29,
2167,
6,
928,
29,
17,
7,
267,
291,
14,
6691,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
1213,
31,
1213,
63,
466,
29,
4445,
12,
6993,
63,
10888,
12,
3554,
695,
6,
1507,
63,
16660,
29,
1960,
12,
6,
3221,
63,
602,
29,
12,
602,
59,
16,
61,
6,
7511,
2458,
83,
6,
3191,
29,
10888,
10011,
12,
10125,
6,
835,
29,
2167,
6,
928,
29,
17,
7,
267,
291,
14,
26737,
4291,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
1213,
31,
1213,
63,
466,
29,
4445,
12,
6993,
63,
10888,
6,
10777,
63,
1205,
29,
26267,
6,
2634,
29,
79,
22707,
63,
7010,
63,
12538,
63,
2676,
8715,
6
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
2344,
272,
1316,
364,
527,
2654,
13,
265,
339,
961,
2240,
365,
2867,
2032,
26,
1265,
883,
3604,
652,
436,
15,
269,
2811,
272,
652,
1334,
314,
2895,
402,
314,
1664,
1696,
1684,
844,
465,
3267,
701,
272,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
844,
12,
503,
272,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
339,
961,
2240,
365,
1854,
315,
314,
3661,
626,
652,
911,
506,
2997,
12,
272,
1325,
2428,
1821,
3408,
27,
1928,
2755,
314,
2478,
3750,
402,
272,
3169,
503,
3092,
2381,
437,
3115,
3104,
14,
221,
1666,
314,
272,
1664,
1696,
1684,
844,
367,
1655,
2436,
14,
339,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
1696,
1684,
844,
272,
3180,
543,
642,
2240,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
2344,
421,
199,
504,
5944,
14,
773,
14,
3112,
492,
30501,
199,
504,
5944,
14,
773,
14,
3112,
492,
15158,
621,
287,
264,
199,
504,
5944,
14,
773,
14,
3112,
492,
3633,
1213,
199,
504,
5944,
14,
773,
14,
3112,
492,
3304,
199,
504,
5944,
14,
773,
14,
3112,
492,
1890,
199,
504,
5944,
14,
773,
14,
3112,
492,
2581,
199,
504,
5944,
14,
773,
14,
3112,
492,
3404,
1637,
199,
504,
5944,
14,
773,
14,
3112,
492,
5232,
835,
199,
504,
5944,
14,
773,
14,
3112,
492,
14123,
199,
504,
5944,
14,
773,
14,
3112,
492,
6858,
199,
504,
5944,
14,
773,
14,
3112,
492,
3778,
199,
504,
5944,
14,
773,
14,
1080,
1192,
492,
12670,
24934,
199,
199,
646,
747,
12,
1274,
12,
264,
12,
1001,
12,
4078,
12,
10290,
12,
2083,
199,
199,
1162,
275,
1211,
8,
10290,
14,
1122,
63,
26714,
8,
1274,
14,
3020,
59,
18,
1055,
1814,
360,
31,
1673,
7058,
340,
822,
8,
1274,
14,
3020,
9,
690,
413,
587,
1211,
342,
199,
199,
1287,
275,
1862,
14,
362,
360,
1287,
358,
199,
199,
2785,
14,
25597,
342,
421,
199,
533,
1303,
14484,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
513,
275,
942,
398,
291,
14,
17117,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
7,
267,
291,
14,
28257,
63,
1073,
275,
283,
1014,
921,
1246,
14,
28257,
14,
6993,
7,
267,
291,
14,
2083,
275,
334,
2083,
14,
2083,
14,
10779,
342,
446,
2197,
14,
7473,
8,
8419,
275,
959,
430,
267,
291,
14,
1786,
7696,
275,
334,
277,
14,
2083,
680,
6205,
3508,
57,
5,
77,
5,
68,
5,
40,
5,
45,
5,
51,
5,
70,
358,
267,
291,
14,
3403,
63,
602,
275,
334,
277,
14,
2083,
446,
2197,
14,
7473,
8,
4899,
275,
28046,
4992,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
267,
291,
14,
8136,
63,
602,
275,
334,
277,
14,
2083,
680,
6205,
3508,
57,
3295,
77,
3295,
68,
358,
267,
291,
14,
28257,
63,
751,
275,
3304,
14,
6031,
360,
28257,
14,
751,
1959,
1913,
342,
267,
291,
14,
17117,
63,
751,
275,
3304,
14,
6031,
360,
17117,
14,
751,
1959,
1814,
360,
300,
297,
4074,
267,
291,
14,
7574,
63,
751,
275,
3304,
14,
6031,
360,
7574,
14,
751,
358,
267,
291,
14,
24138,
63,
6993,
63,
751,
275,
3304,
14,
6031,
360,
24138,
14,
6993,
14,
751,
358,
267,
291,
14,
751,
275,
620,
8,
2785,
14,
6031,
360,
24138,
14,
6993,
14,
751,
1333,
435,
620,
8,
2785,
14,
6031,
360,
7574,
14,
751,
1333,
267,
291,
14,
4159,
275,
3304,
14,
1246,
8493,
12047,
28257,
418,
267,
291,
14,
8191,
67,
1132,
391,
275,
3304,
14,
6031,
360,
8191,
67,
1132,
391,
358,
398,
291,
14,
1733,
63,
1073,
275,
283,
1014,
921,
1246,
14,
28257,
14,
6993,
15,
1733,
15,
10888,
31,
3097,
29,
1165,
6,
1606,
29,
17,
6,
1131,
534,
267,
291,
14,
24138,
63,
6993,
63,
580,
63,
1073,
275,
283,
1014,
921,
2520,
1364,
14,
24138,
14,
6993,
15,
86,
19,
15,
20888,
3149,
83,
7,
267,
291,
14,
24138,
63,
6993,
63,
1896,
63,
1073,
275,
283,
1014,
921,
2520,
1364,
14,
24138,
14,
6993,
15,
86,
19,
15,
1896,
7,
267,
291,
14,
7574,
63,
580,
63,
1073,
275,
283,
1014,
921,
1246,
14,
1589,
573,
433,
28121,
14,
1308,
15,
19,
15,
10888,
3149,
83,
15,
4782,
31,
1246,
63,
498,
2458,
83,
6,
3671,
29,
287,
13,
1668,
6,
2613,
63,
1569,
63,
3671,
29,
287,
8719,
83,
12,
2307,
7,
450,
16651,
83,
297,
291,
14,
7574,
63,
751,
12,
291,
14,
4159,
9,
267,
291,
14,
7574,
63,
4060,
63,
1073,
275,
283,
2859,
921,
1569,
14,
7574,
697,
14,
1308,
15,
84,
15,
80,
15,
87,
5,
83,
5,
83,
7,
398,
291,
14,
32146,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
354,
31,
835,
29,
1960,
6,
354,
534,
267,
291,
14,
5484,
513,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
354,
31,
835,
29,
1960,
6,
15791,
29,
17667,
12,
771,
17667,
7,
267,
291,
14,
5484,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
1213,
31,
1213,
63,
466,
29,
4445,
12,
6993,
63,
10888,
6,
10777,
63,
1205,
29,
26267,
6,
3756,
2458,
83,
6,
3191,
29,
3403,
12,
3257,
6,
835,
29,
2167,
6,
928,
29,
17,
7,
267,
291,
14,
6691,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
1213,
31,
1213,
63,
466,
29,
4445,
12,
6993,
63,
10888,
12,
3554,
695,
6,
1507,
63,
16660,
29,
1960,
12,
6,
3221,
63,
602,
29,
12,
602,
59,
16,
61,
6,
7511,
2458,
83,
6,
3191,
29,
10888,
10011,
12,
10125,
6,
835,
29,
2167,
6,
928,
29,
17,
7,
267,
291,
14,
26737,
4291,
63,
1073,
275,
283,
1014,
921,
1544,
14,
17117,
14,
957,
15,
1733,
15,
1213,
31,
1213,
63,
466,
29,
4445,
12,
6993,
63,
10888,
6,
10777,
63,
1205,
29,
26267,
6,
2634,
29,
79,
22707,
63,
7010,
63,
12538,
63,
2676,
8715,
6,
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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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
] |
eugenesan/postman
|
postman/FlickrWorker.py
|
1
|
2057
|
from BaseWorker import *
class FlickrWorker(BaseWorker):
key = '391fb6763fe0b5011cf52638067e0fed'
secret = '369f46a112452186'
def __init__(self, parent = None):
super(FlickrWorker, self).__init__(parent)
def run(self):
self.progressSignal.emit(self.stampConfig)
if not self.filesModel.count():
return
progressStep = 1.0 / self.filesModel.count()
flickrInstance = self.stampConfig['flickrInst']
for i in range(self.filesModel.count()):
self.status = 'Uploading: %s' % self.filesModel.filesList[i].filePath
self.statusSignal.emit(self.stampConfig)
imageFilename = self.filesModel.filesList[i].filePath.encode('UTF-8','ignore')
imageTitle = self.filesModel.filesList[i].title.encode('UTF-8','ignore')
imageDescription = self.filesModel.filesList[i].description.encode('UTF-8','ignore')
imageTags = self.filesModel.filesList[i].tags.encode('UTF-8','ignore')
# build space delimited tags string
tagList = ['"%s"' % tag.strip() for tag in imageTags.split(',')]
tagsString = ' '.join(tagList)
for r in range(self.retry):
try:
flickrInstance.upload(filename=imageFilename, title=imageTitle, description=imageDescription, tags=tagsString)
break
except Exception:
if r == self.retry - 1:
self.status = 'Failed'
self.statusSignal.emit(self.stampConfig)
self.doneSignal.emit(self.stampConfig)
return
self.progress += progressStep
self.progressSignal.emit(self.stampConfig)
self.status = 'Done'
self.result = True
self.statusSignal.emit(self.stampConfig)
self.doneSignal.emit(self.stampConfig)
|
gpl-3.0
|
[
504,
3523,
12678,
492,
627,
2999,
199,
533,
481,
8442,
82,
12678,
8,
1563,
12678,
304,
11787,
790,
275,
283,
16959,
4675,
1822,
2766,
771,
16,
66,
8216,
17,
2177,
21,
14622,
1257,
1822,
69,
16,
15800,
7,
1128,
7565,
275,
283,
11939,
70,
2466,
65,
6094,
2322,
9252,
22,
7,
11787,
347,
636,
826,
721,
277,
12,
1676,
275,
488,
304,
1039,
1613,
8,
38,
8442,
82,
12678,
12,
291,
2843,
826,
721,
1708,
9,
11787,
347,
1255,
8,
277,
304,
4341,
291,
14,
5734,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
13594,
340,
440,
291,
14,
1725,
1685,
14,
835,
837,
1675,
372,
4341,
6696,
7801,
275,
413,
14,
16,
1182,
291,
14,
1725,
1685,
14,
835,
342,
4341,
289,
8442,
82,
3244,
275,
291,
14,
2359,
2028,
459,
70,
8442,
82,
10083,
418,
13594,
367,
284,
315,
1425,
8,
277,
14,
1725,
1685,
14,
835,
5109,
17554,
1675,
291,
14,
1205,
275,
283,
1721,
8786,
26,
450,
83,
7,
450,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
27501,
1675,
291,
14,
1205,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
17554,
1675,
1834,
8117,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
27501,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
1675,
1834,
6888,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
1213,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
1675,
1834,
5831,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
1802,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
1675,
1834,
9440,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
2969,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
11556,
327,
1900,
4601,
21941,
3762,
1059,
1675,
1947,
1296,
275,
788,
6808,
83,
4507,
450,
1947,
14,
1913,
342,
367,
1947,
315,
1834,
9440,
14,
1294,
29972,
1675,
3762,
1558,
275,
283,
1987,
904,
8,
1450,
1296,
9,
11556,
367,
519,
315,
1425,
8,
277,
14,
7154,
304,
2628,
862,
26,
4906,
289,
8442,
82,
3244,
14,
5064,
8,
1501,
29,
1569,
8117,
12,
2538,
29,
1569,
6888,
12,
1369,
29,
1569,
5831,
12,
3762,
29,
2969,
1558,
9,
4906,
2059,
2628,
871,
2186,
26,
4906,
340,
519,
508,
291,
14,
7154,
446,
413,
26,
8282,
291,
14,
1205,
275,
283,
4276,
7,
8282,
291,
14,
1205,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
8282,
291,
14,
4456,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
8282,
372,
11556,
291,
14,
5734,
847,
6696,
7801,
1675,
291,
14,
5734,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
13594,
291,
14,
1205,
275,
283,
10759,
7,
1039,
291,
14,
1099,
275,
715,
1039,
291,
14,
1205,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
1039,
291,
14,
4456,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
8740,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
3523,
12678,
492,
627,
2999,
199,
533,
481,
8442,
82,
12678,
8,
1563,
12678,
304,
11787,
790,
275,
283,
16959,
4675,
1822,
2766,
771,
16,
66,
8216,
17,
2177,
21,
14622,
1257,
1822,
69,
16,
15800,
7,
1128,
7565,
275,
283,
11939,
70,
2466,
65,
6094,
2322,
9252,
22,
7,
11787,
347,
636,
826,
721,
277,
12,
1676,
275,
488,
304,
1039,
1613,
8,
38,
8442,
82,
12678,
12,
291,
2843,
826,
721,
1708,
9,
11787,
347,
1255,
8,
277,
304,
4341,
291,
14,
5734,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
13594,
340,
440,
291,
14,
1725,
1685,
14,
835,
837,
1675,
372,
4341,
6696,
7801,
275,
413,
14,
16,
1182,
291,
14,
1725,
1685,
14,
835,
342,
4341,
289,
8442,
82,
3244,
275,
291,
14,
2359,
2028,
459,
70,
8442,
82,
10083,
418,
13594,
367,
284,
315,
1425,
8,
277,
14,
1725,
1685,
14,
835,
5109,
17554,
1675,
291,
14,
1205,
275,
283,
1721,
8786,
26,
450,
83,
7,
450,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
27501,
1675,
291,
14,
1205,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
17554,
1675,
1834,
8117,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
27501,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
1675,
1834,
6888,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
1213,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
1675,
1834,
5831,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
1802,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
1675,
1834,
9440,
275,
291,
14,
1725,
1685,
14,
1725,
1296,
59,
73,
1055,
2969,
14,
2143,
360,
6610,
13,
24,
1673,
4247,
358,
11556,
327,
1900,
4601,
21941,
3762,
1059,
1675,
1947,
1296,
275,
788,
6808,
83,
4507,
450,
1947,
14,
1913,
342,
367,
1947,
315,
1834,
9440,
14,
1294,
29972,
1675,
3762,
1558,
275,
283,
1987,
904,
8,
1450,
1296,
9,
11556,
367,
519,
315,
1425,
8,
277,
14,
7154,
304,
2628,
862,
26,
4906,
289,
8442,
82,
3244,
14,
5064,
8,
1501,
29,
1569,
8117,
12,
2538,
29,
1569,
6888,
12,
1369,
29,
1569,
5831,
12,
3762,
29,
2969,
1558,
9,
4906,
2059,
2628,
871,
2186,
26,
4906,
340,
519,
508,
291,
14,
7154,
446,
413,
26,
8282,
291,
14,
1205,
275,
283,
4276,
7,
8282,
291,
14,
1205,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
8282,
291,
14,
4456,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
8282,
372,
11556,
291,
14,
5734,
847,
6696,
7801,
1675,
291,
14,
5734,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
13594,
291,
14,
1205,
275,
283,
10759,
7,
1039,
291,
14,
1099,
275,
715,
1039,
291,
14,
1205,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
1039,
291,
14,
4456,
11274,
14,
8159,
8,
277,
14,
2359,
2028,
9,
8740,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
4tikhonov/eurogis
|
maps/bin/get_regions.py
|
4
|
1346
|
#!/usr/bin/python
import urllib2
import simplejson
import json
import sys
from shapely.geometry import shape, Polygon, MultiPolygon
#from shapely.geometry.multipolygon import shape
# Example of polygon
co1 = {"type": "Polygon", "coordinates": [
[(-102.05, 41.0),
(-102.05, 37.0),
(-109.05, 37.0),
(-109.05, 41.0)]]}
year = None
code = None
if sys.argv[1]:
code = sys.argv[1]
if len(sys.argv) > 2:
year = sys.argv[2]
try:
code
except NameError:
code = 10426
try:
year
except NameError:
year = str(1812)
amscode= str(code)
jsondataurl = "http://node-128.dev.socialhistoryservices.org/api/maps?year=" + year + "&format=geojson"
req = urllib2.Request(jsondataurl)
opener = urllib2.build_opener()
f = opener.open(req)
datapolygons = simplejson.load(f)
def coordinates(polygons, amscode):
for key in polygons:
if key == 'features':
data = polygons[key]
for key in data:
response = json.dumps(key)
dict = json.loads(response)
for key in dict:
#print key['properties']
if key == 'properties':
maincode = str(dict[key]['amsterdamcode'])
if maincode == amscode:
co = dict['geometry']
return co
geometry = coordinates(datapolygons, amscode)
#geometry = co1
size = shape(geometry).area / 27878400
print size;
print shape(geometry).type;
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
646,
4011,
18,
199,
646,
13804,
199,
646,
2022,
199,
646,
984,
199,
504,
2215,
590,
14,
7660,
492,
2215,
12,
17560,
12,
6879,
12367,
199,
3,
504,
2215,
590,
14,
7660,
14,
8016,
393,
6585,
492,
2215,
199,
199,
3,
5679,
402,
17248,
199,
331,
17,
275,
2420,
466,
582,
298,
12367,
401,
298,
12924,
582,
359,
272,
359,
2801,
7759,
14,
1717,
12,
13385,
14,
16,
395,
1362,
5868,
7759,
14,
1717,
12,
6877,
14,
16,
395,
1362,
5868,
6996,
14,
1717,
12,
6877,
14,
16,
395,
1362,
5868,
6996,
14,
1717,
12,
13385,
14,
16,
1874,
9420,
199,
199,
3403,
275,
488,
199,
600,
275,
488,
199,
692,
984,
14,
3020,
59,
17,
2189,
272,
1233,
275,
984,
14,
3020,
59,
17,
61,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
499,
26,
272,
5361,
275,
984,
14,
3020,
59,
18,
61,
199,
199,
893,
26,
1362,
1233,
199,
2590,
12746,
26,
1362,
1233,
275,
21083,
1479,
199,
893,
26,
1362,
5361,
199,
2590,
12746,
26,
1362,
5361,
275,
620,
8,
1085,
713,
9,
199,
199,
19470,
600,
29,
620,
8,
600,
9,
199,
1001,
576,
633,
275,
298,
1014,
921,
932,
13,
3933,
14,
2374,
14,
13574,
5570,
5950,
14,
1308,
15,
1246,
15,
8919,
31,
3403,
628,
435,
5361,
435,
11746,
908,
29,
27043,
2,
199,
199,
2103,
275,
4011,
18,
14,
2017,
8,
1001,
576,
633,
9,
199,
11637,
275,
4011,
18,
14,
1506,
63,
11637,
342,
199,
70,
275,
16088,
14,
1490,
8,
2103,
9,
199,
576,
2515,
18067,
275,
13804,
14,
912,
8,
70,
9,
199,
199,
318,
8983,
8,
2515,
18067,
12,
282,
706,
600,
304,
272,
367,
790,
315,
30658,
26,
267,
340,
790,
508,
283,
3179,
356,
6722,
666,
275,
30658,
59,
498,
61,
6722,
367,
790,
315,
666,
26,
507,
198,
1310,
275,
2022,
14,
4180,
8,
498,
9,
507,
198,
807,
275,
2022,
14,
3640,
8,
1310,
9,
507,
198,
509,
790,
315,
1211,
26,
15075,
327,
1361,
790,
459,
3282,
418,
15075,
340,
790,
508,
283,
3282,
356,
686,
198,
973,
600,
275,
620,
8,
807,
59,
498,
2733,
455,
11652,
68,
455,
600,
1105,
686,
198,
692,
2446,
600,
508,
282,
706,
600,
26,
686,
3777,
512,
275,
1211,
459,
7660,
418,
272,
372,
512,
9948,
199,
7660,
275,
8983,
8,
576,
2515,
18067,
12,
282,
706,
600,
9,
199,
3,
7660,
275,
512,
17,
199,
890,
275,
2215,
8,
7660,
680,
6789,
1182,
8087,
1555,
1349,
383,
199,
1361,
1568,
27,
199,
1361,
2215,
8,
7660,
680,
466,
27,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
646,
4011,
18,
199,
646,
13804,
199,
646,
2022,
199,
646,
984,
199,
504,
2215,
590,
14,
7660,
492,
2215,
12,
17560,
12,
6879,
12367,
199,
3,
504,
2215,
590,
14,
7660,
14,
8016,
393,
6585,
492,
2215,
199,
199,
3,
5679,
402,
17248,
199,
331,
17,
275,
2420,
466,
582,
298,
12367,
401,
298,
12924,
582,
359,
272,
359,
2801,
7759,
14,
1717,
12,
13385,
14,
16,
395,
1362,
5868,
7759,
14,
1717,
12,
6877,
14,
16,
395,
1362,
5868,
6996,
14,
1717,
12,
6877,
14,
16,
395,
1362,
5868,
6996,
14,
1717,
12,
13385,
14,
16,
1874,
9420,
199,
199,
3403,
275,
488,
199,
600,
275,
488,
199,
692,
984,
14,
3020,
59,
17,
2189,
272,
1233,
275,
984,
14,
3020,
59,
17,
61,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
499,
26,
272,
5361,
275,
984,
14,
3020,
59,
18,
61,
199,
199,
893,
26,
1362,
1233,
199,
2590,
12746,
26,
1362,
1233,
275,
21083,
1479,
199,
893,
26,
1362,
5361,
199,
2590,
12746,
26,
1362,
5361,
275,
620,
8,
1085,
713,
9,
199,
199,
19470,
600,
29,
620,
8,
600,
9,
199,
1001,
576,
633,
275,
298,
1014,
921,
932,
13,
3933,
14,
2374,
14,
13574,
5570,
5950,
14,
1308,
15,
1246,
15,
8919,
31,
3403,
628,
435,
5361,
435,
11746,
908,
29,
27043,
2,
199,
199,
2103,
275,
4011,
18,
14,
2017,
8,
1001,
576,
633,
9,
199,
11637,
275,
4011,
18,
14,
1506,
63,
11637,
342,
199,
70,
275,
16088,
14,
1490,
8,
2103,
9,
199,
576,
2515,
18067,
275,
13804,
14,
912,
8,
70,
9,
199,
199,
318,
8983,
8,
2515,
18067,
12,
282,
706,
600,
304,
272,
367,
790,
315,
30658,
26,
267,
340,
790,
508,
283,
3179,
356,
6722,
666,
275,
30658,
59,
498,
61,
6722,
367,
790,
315,
666,
26,
507,
198,
1310,
275,
2022,
14,
4180,
8,
498,
9,
507,
198,
807,
275,
2022,
14,
3640,
8,
1310,
9,
507,
198,
509,
790,
315,
1211,
26,
15075,
327,
1361,
790,
459,
3282,
418,
15075,
340,
790,
508,
283,
3282,
356,
686,
198,
973,
600,
275,
620,
8,
807,
59,
498,
2733,
455,
11652,
68,
455,
600,
1105,
686,
198,
692,
2446,
600,
508,
282,
706,
600,
26,
686,
3777,
512,
275,
1211,
459,
7660,
418,
272,
372,
512,
9948,
199,
7660,
275,
8983,
8,
576,
2515,
18067,
12,
282,
706,
600,
9,
199,
3,
7660,
275,
512,
17,
199,
890,
275,
2215,
8,
7660,
680,
6789,
1182,
8087,
1555,
1349,
383,
199,
1361,
1568,
27,
199,
1361,
2215,
8,
7660,
680,
466,
27,
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,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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
] |
emmericp/dpdk
|
app/test/autotest_runner.py
|
1
|
14419
|
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# The main logic behind running autotests in parallel
from __future__ import print_function
import StringIO
import csv
from multiprocessing import Pool, Queue
import pexpect
import re
import subprocess
import sys
import time
import glob
import os
# wait for prompt
def wait_prompt(child):
try:
child.sendline()
result = child.expect(["RTE>>", pexpect.TIMEOUT, pexpect.EOF],
timeout=120)
except:
return False
if result == 0:
return True
else:
return False
# get all valid NUMA nodes
def get_numa_nodes():
return [
int(
re.match(r"node(\d+)", os.path.basename(node))
.group(1)
)
for node in glob.glob("/sys/devices/system/node/node*")
]
# find first (or any, really) CPU on a particular node, will be used to spread
# processes around NUMA nodes to avoid exhausting memory on particular node
def first_cpu_on_node(node_nr):
cpu_path = glob.glob("/sys/devices/system/node/node%d/cpu*" % node_nr)[0]
cpu_name = os.path.basename(cpu_path)
m = re.match(r"cpu(\d+)", cpu_name)
return int(m.group(1))
pool_child = None # per-process child
# we initialize each worker with a queue because we need per-pool unique
# command-line arguments, but we cannot do different arguments in an initializer
# because the API doesn't allow per-worker initializer arguments. so, instead,
# we will initialize with a shared queue, and dequeue command-line arguments
# from this queue
def pool_init(queue, result_queue):
global pool_child
cmdline, prefix = queue.get()
start_time = time.time()
name = ("Start %s" % prefix) if prefix != "" else "Start"
# use default prefix if no prefix was specified
prefix_cmdline = "--file-prefix=%s" % prefix if prefix != "" else ""
# append prefix to cmdline
cmdline = "%s %s" % (cmdline, prefix_cmdline)
# prepare logging of init
startuplog = StringIO.StringIO()
# run test app
try:
print("\n%s %s\n" % ("=" * 20, prefix), file=startuplog)
print("\ncmdline=%s" % cmdline, file=startuplog)
pool_child = pexpect.spawn(cmdline, logfile=startuplog)
# wait for target to boot
if not wait_prompt(pool_child):
pool_child.close()
result = tuple((-1,
"Fail [No prompt]",
name,
time.time() - start_time,
startuplog.getvalue(),
None))
pool_child = None
else:
result = tuple((0,
"Success",
name,
time.time() - start_time,
startuplog.getvalue(),
None))
except:
result = tuple((-1,
"Fail [Can't run]",
name,
time.time() - start_time,
startuplog.getvalue(),
None))
pool_child = None
result_queue.put(result)
# run a test
# each result tuple in results list consists of:
# result value (0 or -1)
# result string
# test name
# total test run time (double)
# raw test log
# test report (if not available, should be None)
#
# this function needs to be outside AutotestRunner class because otherwise Pool
# won't work (or rather it will require quite a bit of effort to make it work).
def run_test(target, test):
global pool_child
if pool_child is None:
return -1, "Fail [No test process]", test["Name"], 0, "", None
# create log buffer for each test
# in multiprocessing environment, the logging would be
# interleaved and will create a mess, hence the buffering
logfile = StringIO.StringIO()
pool_child.logfile = logfile
# make a note when the test started
start_time = time.time()
try:
# print test name to log buffer
print("\n%s %s\n" % ("-" * 20, test["Name"]), file=logfile)
# run test function associated with the test
result = test["Func"](pool_child, test["Command"])
# make a note when the test was finished
end_time = time.time()
log = logfile.getvalue()
# append test data to the result tuple
result += (test["Name"], end_time - start_time, log)
# call report function, if any defined, and supply it with
# target and complete log for test run
if test["Report"]:
report = test["Report"](target, log)
# append report to results tuple
result += (report,)
else:
# report is None
result += (None,)
except:
# make a note when the test crashed
end_time = time.time()
# mark test as failed
result = (-1, "Fail [Crash]", test["Name"],
end_time - start_time, logfile.getvalue(), None)
# return test results
return result
# class representing an instance of autotests run
class AutotestRunner:
cmdline = ""
parallel_test_groups = []
non_parallel_test_groups = []
logfile = None
csvwriter = None
target = ""
start = None
n_tests = 0
fails = 0
log_buffers = []
blacklist = []
whitelist = []
def __init__(self, cmdline, target, blacklist, whitelist, n_processes):
self.cmdline = cmdline
self.target = target
self.blacklist = blacklist
self.whitelist = whitelist
self.skipped = []
self.parallel_tests = []
self.non_parallel_tests = []
self.n_processes = n_processes
self.active_processes = 0
# parse the binary for available test commands
binary = cmdline.split()[0]
stripped = 'not stripped' not in \
subprocess.check_output(['file', binary])
if not stripped:
symbols = subprocess.check_output(['nm', binary]).decode('utf-8')
self.avail_cmds = re.findall('test_register_(\w+)', symbols)
else:
self.avail_cmds = None
# log file filename
logfile = "%s.log" % target
csvfile = "%s.csv" % target
self.logfile = open(logfile, "w")
csvfile = open(csvfile, "w")
self.csvwriter = csv.writer(csvfile)
# prepare results table
self.csvwriter.writerow(["test_name", "test_result", "result_str"])
# set up cmdline string
def __get_cmdline(self, cpu_nr):
cmdline = ("taskset -c %i " % cpu_nr) + self.cmdline
return cmdline
def __process_result(self, result):
# unpack result tuple
test_result, result_str, test_name, \
test_time, log, report = result
# get total run time
cur_time = time.time()
total_time = int(cur_time - self.start)
# print results, test run time and total time since start
result = ("%s:" % test_name).ljust(30)
result += result_str.ljust(29)
result += "[%02dm %02ds]" % (test_time / 60, test_time % 60)
# don't print out total time every line, it's the same anyway
print(result + "[%02dm %02ds]" % (total_time / 60, total_time % 60))
# if test failed and it wasn't a "start" test
if test_result < 0:
self.fails += 1
# collect logs
self.log_buffers.append(log)
# create report if it exists
if report:
try:
f = open("%s_%s_report.rst" %
(self.target, test_name), "w")
except IOError:
print("Report for %s could not be created!" % test_name)
else:
with f:
f.write(report)
# write test result to CSV file
self.csvwriter.writerow([test_name, test_result, result_str])
# this function checks individual test and decides if this test should be in
# the group by comparing it against whitelist/blacklist. it also checks if
# the test is compiled into the binary, and marks it as skipped if necessary
def __filter_test(self, test):
test_cmd = test["Command"]
test_id = test_cmd
# dump tests are specified in full e.g. "Dump_mempool"
if "_autotest" in test_id:
test_id = test_id[:-len("_autotest")]
# filter out blacklisted/whitelisted tests
if self.blacklist and test_id in self.blacklist:
return False
if self.whitelist and test_id not in self.whitelist:
return False
# if test wasn't compiled in, remove it as well
if self.avail_cmds and test_cmd not in self.avail_cmds:
result = 0, "Skipped [Not compiled]", test_id, 0, "", None
self.skipped.append(tuple(result))
return False
return True
def __run_test_group(self, test_group, worker_cmdlines):
group_queue = Queue()
init_result_queue = Queue()
for proc, cmdline in enumerate(worker_cmdlines):
prefix = "test%i" % proc if len(worker_cmdlines) > 1 else ""
group_queue.put(tuple((cmdline, prefix)))
# create a pool of worker threads
# we will initialize child in the initializer, and we don't need to
# close the child because when the pool worker gets destroyed, child
# closes the process
pool = Pool(processes=len(worker_cmdlines),
initializer=pool_init,
initargs=(group_queue, init_result_queue))
results = []
# process all initialization results
for _ in range(len(worker_cmdlines)):
self.__process_result(init_result_queue.get())
# run all tests asynchronously
for test in test_group:
result = pool.apply_async(run_test, (self.target, test))
results.append(result)
# tell the pool to stop all processes once done
pool.close()
# iterate while we have group execution results to get
while len(results) > 0:
# iterate over a copy to be able to safely delete results
# this iterates over a list of group results
for async_result in results[:]:
# if the thread hasn't finished yet, continue
if not async_result.ready():
continue
res = async_result.get()
self.__process_result(res)
# remove result from results list once we're done with it
results.remove(async_result)
# iterate over test groups and run tests associated with them
def run_all_tests(self):
# filter groups
self.parallel_tests = list(
filter(self.__filter_test,
self.parallel_tests)
)
self.non_parallel_tests = list(
filter(self.__filter_test,
self.non_parallel_tests)
)
parallel_cmdlines = []
# FreeBSD doesn't have NUMA support
numa_nodes = get_numa_nodes()
if len(numa_nodes) > 0:
for proc in range(self.n_processes):
# spread cpu affinity between NUMA nodes to have less chance of
# running out of memory while running multiple test apps in
# parallel. to do that, alternate between NUMA nodes in a round
# robin fashion, and pick an arbitrary CPU from that node to
# taskset our execution to
numa_node = numa_nodes[self.active_processes % len(numa_nodes)]
cpu_nr = first_cpu_on_node(numa_node)
parallel_cmdlines += [self.__get_cmdline(cpu_nr)]
# increase number of active processes so that the next cmdline
# gets a different NUMA node
self.active_processes += 1
else:
parallel_cmdlines = [self.cmdline] * self.n_processes
print("Running tests with %d workers" % self.n_processes)
# create table header
print("")
print("Test name".ljust(30) + "Test result".ljust(29) +
"Test".center(9) + "Total".center(9))
print("=" * 80)
if len(self.skipped):
print("Skipped autotests:")
# print out any skipped tests
for result in self.skipped:
# unpack result tuple
test_result, result_str, test_name, _, _, _ = result
self.csvwriter.writerow([test_name, test_result, result_str])
t = ("%s:" % test_name).ljust(30)
t += result_str.ljust(29)
t += "[00m 00s]"
print(t)
# make a note of tests start time
self.start = time.time()
# whatever happens, try to save as much logs as possible
try:
if len(self.parallel_tests) > 0:
print("Parallel autotests:")
self.__run_test_group(self.parallel_tests, parallel_cmdlines)
if len(self.non_parallel_tests) > 0:
print("Non-parallel autotests:")
self.__run_test_group(self.non_parallel_tests, [self.cmdline])
# get total run time
cur_time = time.time()
total_time = int(cur_time - self.start)
# print out summary
print("=" * 80)
print("Total run time: %02dm %02ds" % (total_time / 60,
total_time % 60))
if self.fails != 0:
print("Number of failed tests: %s" % str(self.fails))
# write summary to logfile
self.logfile.write("Summary\n")
self.logfile.write("Target: ".ljust(15) + "%s\n" % self.target)
self.logfile.write("Tests: ".ljust(15) + "%i\n" % self.n_tests)
self.logfile.write("Failed tests: ".ljust(
15) + "%i\n" % self.fails)
except:
print("Exception occurred")
print(sys.exc_info())
self.fails = 1
# drop logs from all executions to a logfile
for buf in self.log_buffers:
self.logfile.write(buf.replace("\r", ""))
return self.fails
|
gpl-2.0
|
[
3,
6988,
19596,
13,
3761,
13,
7544,
26,
6289,
13,
19,
13,
16009,
199,
3,
1898,
8,
67,
9,
7129,
13,
7280,
20619,
11098,
199,
199,
3,
710,
2446,
9661,
22172,
3879,
2599,
2219,
315,
9861,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
5228,
199,
646,
7392,
199,
504,
12866,
492,
15553,
12,
10703,
199,
646,
28855,
199,
646,
295,
199,
646,
3873,
199,
646,
984,
199,
646,
900,
199,
646,
5739,
199,
646,
747,
199,
199,
3,
3618,
367,
8457,
199,
318,
3618,
63,
7650,
8,
1739,
304,
272,
862,
26,
267,
1982,
14,
29857,
342,
267,
754,
275,
1982,
14,
4921,
5234,
50,
3727,
1140,
401,
28855,
14,
8899,
12,
28855,
14,
13178,
467,
2892,
2653,
29,
6708,
9,
272,
871,
26,
267,
372,
756,
272,
340,
754,
508,
378,
26,
267,
372,
715,
272,
587,
26,
267,
372,
756,
421,
199,
3,
664,
1006,
1686,
653,
53,
2054,
3380,
199,
318,
664,
63,
19498,
63,
2415,
837,
272,
372,
359,
267,
1109,
8,
288,
295,
14,
1431,
8,
82,
2,
932,
2961,
68,
11,
4186,
747,
14,
515,
14,
4846,
8,
932,
430,
288,
1275,
923,
8,
17,
9,
267,
776,
267,
367,
1031,
315,
5739,
14,
6463,
4769,
1274,
15,
6410,
15,
2253,
15,
932,
15,
932,
10,
531,
272,
1622,
421,
199,
3,
2342,
1642,
334,
269,
1263,
12,
7710,
9,
11952,
641,
282,
6770,
1031,
12,
911,
506,
1202,
370,
308,
8984,
199,
3,
10358,
6818,
653,
53,
2054,
3380,
370,
5126,
21354,
833,
316,
4402,
641,
6770,
1031,
199,
318,
1642,
63,
3541,
63,
265,
63,
932,
8,
932,
63,
7865,
304,
272,
5033,
63,
515,
275,
5739,
14,
6463,
4769,
1274,
15,
6410,
15,
2253,
15,
932,
15,
932,
5,
68,
15,
3541,
12469,
450,
1031,
63,
7865,
2788,
16,
61,
272,
5033,
63,
354,
275,
747,
14,
515,
14,
4846,
8,
3541,
63,
515,
9,
272,
333,
275,
295,
14,
1431,
8,
82,
2,
3541,
2961,
68,
11,
4186,
5033,
63,
354,
9,
272,
372,
1109,
8,
77,
14,
923,
8,
17,
430,
421,
199,
2293,
63,
1739,
275,
488,
221,
327,
1126,
13,
1412,
1982,
421,
199,
3,
781,
8265,
1924,
7239,
543,
282,
4126,
2952,
781,
1929,
1126,
13,
2293,
3747,
199,
3,
1414,
13,
604,
2368,
12,
1325,
781,
3913,
886,
3365,
2368,
315,
376,
11130,
199,
3,
2952,
314,
3261,
3181,
1133,
2040,
1126,
13,
6599,
11130,
2368,
14,
880,
12,
3140,
12,
199,
3,
781,
911,
8265,
543,
282,
5709,
4126,
12,
436,
23523,
1414,
13,
604,
2368,
199,
3,
687,
642,
4126,
199,
318,
4203,
63,
826,
8,
1825,
12,
754,
63,
1825,
304,
272,
2288,
4203,
63,
1739,
339,
21206,
12,
2403,
275,
4126,
14,
362,
342,
272,
1343,
63,
521,
275,
900,
14,
521,
342,
272,
536,
275,
1689,
3162,
450,
83,
2,
450,
2403,
9,
340,
2403,
1137,
3087,
587,
298,
3162,
2,
339,
327,
675,
849,
2403,
340,
949,
2403,
1990,
2013,
272,
2403,
63,
15612,
275,
4320,
493,
13,
1861,
2458,
83,
2,
450,
2403,
340,
2403,
1137,
3087,
587,
3087,
339,
327,
5666,
2403,
370,
21206,
272,
21206,
275,
2071,
83,
450,
83,
2,
450,
334,
15612,
12,
2403,
63,
15612,
9,
339,
327,
9275,
2050,
402,
4205,
272,
14210,
793,
275,
5228,
14,
6424,
342,
339,
327,
1255,
511,
1145,
272,
862,
26,
398,
870,
4582,
78,
5,
83,
450,
83,
60,
78,
2,
450,
1689,
628,
627,
3388,
12,
2403,
395,
570,
29,
16480,
793,
9,
267,
870,
4582,
78,
15612,
2458,
83,
2,
450,
21206,
12,
570,
29,
16480,
793,
9,
398,
4203,
63,
1739,
275,
28855,
14,
10212,
8,
15612,
12,
17251,
29,
16480,
793,
9,
398,
327,
3618,
367,
1347,
370,
8498,
267,
340,
440,
3618,
63,
7650,
8,
2293,
63,
1739,
304,
288,
4203,
63,
1739,
14,
1600,
342,
953,
754,
275,
2008,
18138,
17,
12,
1169,
298,
4874,
359,
1944,
8457,
11472,
1169,
536,
12,
1169,
900,
14,
521,
342,
446,
1343,
63,
521,
12,
1169,
14210,
793,
14,
7150,
1062,
1169,
488,
430,
288,
4203,
63,
1739,
275,
488,
267,
587,
26,
288,
754,
275,
2008,
1332,
16,
12,
1169,
298,
8300,
401,
1169,
536,
12,
1169,
900,
14,
521,
342,
446,
1343,
63,
521,
12,
1169,
14210,
793,
14,
7150,
1062,
1169,
488,
430,
272,
871,
26,
267,
754,
275,
2008,
18138,
17,
12,
717,
298,
4874,
359,
6049,
1133,
1255,
11472,
717,
536,
12,
717,
900,
14,
521,
342,
446,
1343,
63,
521,
12,
717,
14210,
793,
14,
7150,
1062,
717,
488,
430,
267,
4203,
63,
1739,
275,
488,
339,
754,
63,
1825,
14,
524,
8,
1099,
9,
421,
199,
3,
1255,
282,
511,
199,
3,
1924,
754,
2008,
315,
2058,
769,
18581,
402,
26,
199,
3,
257,
754,
574,
334,
16,
503,
446,
17,
9,
199,
3,
257,
754,
1059,
199,
3,
257,
511,
536,
199,
3,
257,
3141,
511,
1255,
900,
334,
3157,
9,
199,
3,
257,
3066,
511,
943,
199,
3,
257,
511,
3622,
334,
692,
440,
2808,
12,
1077,
506,
488,
9,
199,
3,
199,
3,
642,
805,
4839,
370,
506,
9682,
9195,
396,
7446,
1021,
2952,
4257,
15553,
199,
3,
7859,
1133,
1736,
334,
269,
7830,
652,
911,
4409,
18794,
282,
4546,
402,
28058,
370,
1852,
652,
1736,
680,
199,
318,
1255,
63,
396,
8,
1375,
12,
511,
304,
272,
2288,
4203,
63,
1739,
339,
340,
4203,
63,
1739,
365,
488,
26,
267,
372,
446,
17,
12,
298,
4874,
359,
1944,
511,
2112,
11472,
511,
905,
985,
2255,
378,
12,
4873,
488,
339,
327,
1218,
943,
3335,
367,
1924,
511,
272,
327,
315,
12866,
3734,
12,
314,
2050,
3955,
506,
272,
327,
1640,
274,
4292,
436,
911,
1218,
282,
15634,
12,
19407,
314,
21033,
272,
17251,
275,
5228,
14,
6424,
342,
272,
4203,
63,
1739,
14,
12804,
275,
17251,
339,
327,
1852,
282,
5317,
1380,
314,
511,
8239,
272,
1343,
63,
521,
275,
900,
14,
521,
342,
339,
862,
26,
267,
327,
870,
511,
536,
370,
943,
3335,
267,
870,
4582,
78,
5,
83,
450,
83,
60,
78,
2,
450,
19372,
2,
627,
3388,
12,
511,
905,
985,
10252,
570,
29,
12804,
9
] |
[
6988,
19596,
13,
3761,
13,
7544,
26,
6289,
13,
19,
13,
16009,
199,
3,
1898,
8,
67,
9,
7129,
13,
7280,
20619,
11098,
199,
199,
3,
710,
2446,
9661,
22172,
3879,
2599,
2219,
315,
9861,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
646,
5228,
199,
646,
7392,
199,
504,
12866,
492,
15553,
12,
10703,
199,
646,
28855,
199,
646,
295,
199,
646,
3873,
199,
646,
984,
199,
646,
900,
199,
646,
5739,
199,
646,
747,
199,
199,
3,
3618,
367,
8457,
199,
318,
3618,
63,
7650,
8,
1739,
304,
272,
862,
26,
267,
1982,
14,
29857,
342,
267,
754,
275,
1982,
14,
4921,
5234,
50,
3727,
1140,
401,
28855,
14,
8899,
12,
28855,
14,
13178,
467,
2892,
2653,
29,
6708,
9,
272,
871,
26,
267,
372,
756,
272,
340,
754,
508,
378,
26,
267,
372,
715,
272,
587,
26,
267,
372,
756,
421,
199,
3,
664,
1006,
1686,
653,
53,
2054,
3380,
199,
318,
664,
63,
19498,
63,
2415,
837,
272,
372,
359,
267,
1109,
8,
288,
295,
14,
1431,
8,
82,
2,
932,
2961,
68,
11,
4186,
747,
14,
515,
14,
4846,
8,
932,
430,
288,
1275,
923,
8,
17,
9,
267,
776,
267,
367,
1031,
315,
5739,
14,
6463,
4769,
1274,
15,
6410,
15,
2253,
15,
932,
15,
932,
10,
531,
272,
1622,
421,
199,
3,
2342,
1642,
334,
269,
1263,
12,
7710,
9,
11952,
641,
282,
6770,
1031,
12,
911,
506,
1202,
370,
308,
8984,
199,
3,
10358,
6818,
653,
53,
2054,
3380,
370,
5126,
21354,
833,
316,
4402,
641,
6770,
1031,
199,
318,
1642,
63,
3541,
63,
265,
63,
932,
8,
932,
63,
7865,
304,
272,
5033,
63,
515,
275,
5739,
14,
6463,
4769,
1274,
15,
6410,
15,
2253,
15,
932,
15,
932,
5,
68,
15,
3541,
12469,
450,
1031,
63,
7865,
2788,
16,
61,
272,
5033,
63,
354,
275,
747,
14,
515,
14,
4846,
8,
3541,
63,
515,
9,
272,
333,
275,
295,
14,
1431,
8,
82,
2,
3541,
2961,
68,
11,
4186,
5033,
63,
354,
9,
272,
372,
1109,
8,
77,
14,
923,
8,
17,
430,
421,
199,
2293,
63,
1739,
275,
488,
221,
327,
1126,
13,
1412,
1982,
421,
199,
3,
781,
8265,
1924,
7239,
543,
282,
4126,
2952,
781,
1929,
1126,
13,
2293,
3747,
199,
3,
1414,
13,
604,
2368,
12,
1325,
781,
3913,
886,
3365,
2368,
315,
376,
11130,
199,
3,
2952,
314,
3261,
3181,
1133,
2040,
1126,
13,
6599,
11130,
2368,
14,
880,
12,
3140,
12,
199,
3,
781,
911,
8265,
543,
282,
5709,
4126,
12,
436,
23523,
1414,
13,
604,
2368,
199,
3,
687,
642,
4126,
199,
318,
4203,
63,
826,
8,
1825,
12,
754,
63,
1825,
304,
272,
2288,
4203,
63,
1739,
339,
21206,
12,
2403,
275,
4126,
14,
362,
342,
272,
1343,
63,
521,
275,
900,
14,
521,
342,
272,
536,
275,
1689,
3162,
450,
83,
2,
450,
2403,
9,
340,
2403,
1137,
3087,
587,
298,
3162,
2,
339,
327,
675,
849,
2403,
340,
949,
2403,
1990,
2013,
272,
2403,
63,
15612,
275,
4320,
493,
13,
1861,
2458,
83,
2,
450,
2403,
340,
2403,
1137,
3087,
587,
3087,
339,
327,
5666,
2403,
370,
21206,
272,
21206,
275,
2071,
83,
450,
83,
2,
450,
334,
15612,
12,
2403,
63,
15612,
9,
339,
327,
9275,
2050,
402,
4205,
272,
14210,
793,
275,
5228,
14,
6424,
342,
339,
327,
1255,
511,
1145,
272,
862,
26,
398,
870,
4582,
78,
5,
83,
450,
83,
60,
78,
2,
450,
1689,
628,
627,
3388,
12,
2403,
395,
570,
29,
16480,
793,
9,
267,
870,
4582,
78,
15612,
2458,
83,
2,
450,
21206,
12,
570,
29,
16480,
793,
9,
398,
4203,
63,
1739,
275,
28855,
14,
10212,
8,
15612,
12,
17251,
29,
16480,
793,
9,
398,
327,
3618,
367,
1347,
370,
8498,
267,
340,
440,
3618,
63,
7650,
8,
2293,
63,
1739,
304,
288,
4203,
63,
1739,
14,
1600,
342,
953,
754,
275,
2008,
18138,
17,
12,
1169,
298,
4874,
359,
1944,
8457,
11472,
1169,
536,
12,
1169,
900,
14,
521,
342,
446,
1343,
63,
521,
12,
1169,
14210,
793,
14,
7150,
1062,
1169,
488,
430,
288,
4203,
63,
1739,
275,
488,
267,
587,
26,
288,
754,
275,
2008,
1332,
16,
12,
1169,
298,
8300,
401,
1169,
536,
12,
1169,
900,
14,
521,
342,
446,
1343,
63,
521,
12,
1169,
14210,
793,
14,
7150,
1062,
1169,
488,
430,
272,
871,
26,
267,
754,
275,
2008,
18138,
17,
12,
717,
298,
4874,
359,
6049,
1133,
1255,
11472,
717,
536,
12,
717,
900,
14,
521,
342,
446,
1343,
63,
521,
12,
717,
14210,
793,
14,
7150,
1062,
717,
488,
430,
267,
4203,
63,
1739,
275,
488,
339,
754,
63,
1825,
14,
524,
8,
1099,
9,
421,
199,
3,
1255,
282,
511,
199,
3,
1924,
754,
2008,
315,
2058,
769,
18581,
402,
26,
199,
3,
257,
754,
574,
334,
16,
503,
446,
17,
9,
199,
3,
257,
754,
1059,
199,
3,
257,
511,
536,
199,
3,
257,
3141,
511,
1255,
900,
334,
3157,
9,
199,
3,
257,
3066,
511,
943,
199,
3,
257,
511,
3622,
334,
692,
440,
2808,
12,
1077,
506,
488,
9,
199,
3,
199,
3,
642,
805,
4839,
370,
506,
9682,
9195,
396,
7446,
1021,
2952,
4257,
15553,
199,
3,
7859,
1133,
1736,
334,
269,
7830,
652,
911,
4409,
18794,
282,
4546,
402,
28058,
370,
1852,
652,
1736,
680,
199,
318,
1255,
63,
396,
8,
1375,
12,
511,
304,
272,
2288,
4203,
63,
1739,
339,
340,
4203,
63,
1739,
365,
488,
26,
267,
372,
446,
17,
12,
298,
4874,
359,
1944,
511,
2112,
11472,
511,
905,
985,
2255,
378,
12,
4873,
488,
339,
327,
1218,
943,
3335,
367,
1924,
511,
272,
327,
315,
12866,
3734,
12,
314,
2050,
3955,
506,
272,
327,
1640,
274,
4292,
436,
911,
1218,
282,
15634,
12,
19407,
314,
21033,
272,
17251,
275,
5228,
14,
6424,
342,
272,
4203,
63,
1739,
14,
12804,
275,
17251,
339,
327,
1852,
282,
5317,
1380,
314,
511,
8239,
272,
1343,
63,
521,
275,
900,
14,
521,
342,
339,
862,
26,
267,
327,
870,
511,
536,
370,
943,
3335,
267,
870,
4582,
78,
5,
83,
450,
83,
60,
78,
2,
450,
19372,
2,
627,
3388,
12,
511,
905,
985,
10252,
570,
29,
12804,
9,
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,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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
] |
kenju254/yowsup
|
yowsup/layers/protocol_groups/protocolentities/iq_groups_participants_remove.py
|
61
|
1128
|
from yowsup.structs import ProtocolEntity, ProtocolTreeNode
from .iq_groups_participants import ParticipantsGroupsIqProtocolEntity
class RemoveParticipantsIqProtocolEntity(ParticipantsGroupsIqProtocolEntity):
'''
<iq type="set" id="{{id}}" xmlns="w:g2", to="{{group_jid}}">
<remove>
<participant jid="{{jid}}"></participant>
<participant jid="{{jid}}"></participant>
</remove>
</iq>
'''
def __init__(self, group_jid, participantList, _id = None):
super(RemoveParticipantsIqProtocolEntity, self).__init__(group_jid, participantList, "remove", _id = _id)
@staticmethod
def fromProtocolTreeNode(node):
entity = super(RemoveParticipantsIqProtocolEntity, RemoveParticipantsIqProtocolEntity).fromProtocolTreeNode(node)
entity.__class__ = RemoveParticipantsIqProtocolEntity
participantList = []
for participantNode in node.getChild("remove").getAllChildren():
participantList.append(participantNode["jid"])
entity.setProps(node.getAttributeValue("to"), participantList)
return entity
|
gpl-3.0
|
[
504,
612,
583,
1961,
14,
23253,
492,
11557,
7302,
12,
11557,
26749,
199,
504,
1275,
9962,
63,
2634,
63,
31790,
492,
2235,
20989,
10177,
29961,
3658,
7302,
199,
199,
533,
5852,
1262,
20989,
29961,
3658,
7302,
8,
1262,
20989,
10177,
29961,
3658,
7302,
304,
272,
1449,
272,
665,
9962,
730,
628,
409,
2,
1305,
628,
3638,
344,
30618,
9604,
628,
87,
26,
71,
18,
401,
370,
628,
3638,
923,
63,
14203,
4863,
1743,
267,
665,
2168,
30,
288,
665,
29253,
21752,
628,
3638,
14203,
4863,
10070,
29253,
30,
288,
665,
29253,
21752,
628,
3638,
14203,
4863,
10070,
29253,
30,
267,
3068,
2168,
30,
272,
3068,
9962,
30,
272,
1449,
2286,
347,
636,
826,
721,
277,
12,
1572,
63,
14203,
12,
623,
16448,
1296,
12,
485,
344,
275,
488,
304,
267,
1613,
8,
5587,
1262,
20989,
29961,
3658,
7302,
12,
291,
2843,
826,
721,
923,
63,
14203,
12,
623,
16448,
1296,
12,
298,
2168,
401,
485,
344,
275,
485,
344,
9,
5493,
768,
4639,
272,
347,
687,
3658,
26749,
8,
932,
304,
267,
4642,
275,
1613,
8,
5587,
1262,
20989,
29961,
3658,
7302,
12,
5852,
1262,
20989,
29961,
3658,
7302,
680,
504,
3658,
26749,
8,
932,
9,
267,
4642,
855,
533,
363,
275,
5852,
1262,
20989,
29961,
3658,
7302,
267,
623,
16448,
1296,
275,
942,
267,
367,
623,
16448,
1716,
315,
1031,
14,
26023,
480,
2168,
3471,
31359,
7139,
837,
288,
623,
16448,
1296,
14,
740,
8,
29253,
1716,
905,
14203,
3135,
267,
4642,
14,
409,
24188,
8,
932,
14,
362,
4016,
480,
475,
1288,
623,
16448,
1296,
9,
267,
372,
4642,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
612,
583,
1961,
14,
23253,
492,
11557,
7302,
12,
11557,
26749,
199,
504,
1275,
9962,
63,
2634,
63,
31790,
492,
2235,
20989,
10177,
29961,
3658,
7302,
199,
199,
533,
5852,
1262,
20989,
29961,
3658,
7302,
8,
1262,
20989,
10177,
29961,
3658,
7302,
304,
272,
1449,
272,
665,
9962,
730,
628,
409,
2,
1305,
628,
3638,
344,
30618,
9604,
628,
87,
26,
71,
18,
401,
370,
628,
3638,
923,
63,
14203,
4863,
1743,
267,
665,
2168,
30,
288,
665,
29253,
21752,
628,
3638,
14203,
4863,
10070,
29253,
30,
288,
665,
29253,
21752,
628,
3638,
14203,
4863,
10070,
29253,
30,
267,
3068,
2168,
30,
272,
3068,
9962,
30,
272,
1449,
2286,
347,
636,
826,
721,
277,
12,
1572,
63,
14203,
12,
623,
16448,
1296,
12,
485,
344,
275,
488,
304,
267,
1613,
8,
5587,
1262,
20989,
29961,
3658,
7302,
12,
291,
2843,
826,
721,
923,
63,
14203,
12,
623,
16448,
1296,
12,
298,
2168,
401,
485,
344,
275,
485,
344,
9,
5493,
768,
4639,
272,
347,
687,
3658,
26749,
8,
932,
304,
267,
4642,
275,
1613,
8,
5587,
1262,
20989,
29961,
3658,
7302,
12,
5852,
1262,
20989,
29961,
3658,
7302,
680,
504,
3658,
26749,
8,
932,
9,
267,
4642,
855,
533,
363,
275,
5852,
1262,
20989,
29961,
3658,
7302,
267,
623,
16448,
1296,
275,
942,
267,
367,
623,
16448,
1716,
315,
1031,
14,
26023,
480,
2168,
3471,
31359,
7139,
837,
288,
623,
16448,
1296,
14,
740,
8,
29253,
1716,
905,
14203,
3135,
267,
4642,
14,
409,
24188,
8,
932,
14,
362,
4016,
480,
475,
1288,
623,
16448,
1296,
9,
267,
372,
4642,
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,
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,
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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
] |
Hybrid-Rom/external_skia
|
tools/gen_bench_expectations_from_codereview.py
|
67
|
5806
|
#!/usr/bin/python
# Copyright (c) 2014 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.
"""Generate new bench expectations from results of trybots on a code review."""
import collections
import compare_codereview
import os
import re
import shutil
import subprocess
import sys
BENCH_DATA_URL = 'gs://chromium-skia-gm/perfdata/%s/%s/*'
CHECKOUT_PATH = os.path.realpath(os.path.join(
os.path.dirname(os.path.abspath(__file__)), os.pardir))
TMP_BENCH_DATA_DIR = os.path.join(CHECKOUT_PATH, '.bench_data')
TryBuild = collections.namedtuple(
'TryBuild', ['builder_name', 'build_number', 'is_finished'])
def find_all_builds(codereview_url):
"""Finds and returns information about trybot runs for a code review.
Args:
codereview_url: URL of the codereview in question.
Returns:
List of NamedTuples: (builder_name, build_number, is_finished)
"""
results = compare_codereview.CodeReviewHTMLParser().parse(codereview_url)
try_builds = []
for builder, data in results.iteritems():
if builder.startswith('Perf'):
build_num = data.url.split('/')[-1] if data.url else None
is_finished = (data.status not in ('pending', 'try-pending') and
build_num is not None)
try_builds.append(TryBuild(builder_name=builder,
build_number=build_num,
is_finished=is_finished))
return try_builds
def _all_trybots_finished(try_builds):
"""Return True iff all of the given try jobs have finished.
Args:
try_builds: list of TryBuild instances.
Returns:
True if all of the given try jobs have finished, otherwise False.
"""
for try_build in try_builds:
if not try_build.is_finished:
return False
return True
def all_trybots_finished(codereview_url):
"""Return True iff all of the try jobs on the given codereview have finished.
Args:
codereview_url: string; URL of the codereview.
Returns:
True if all of the try jobs have finished, otherwise False.
"""
return _all_trybots_finished(find_all_builds(codereview_url))
def get_bench_data(builder, build_num, dest_dir):
"""Download the bench data for the given builder at the given build_num.
Args:
builder: string; name of the builder.
build_num: string; build number.
dest_dir: string; destination directory for the bench data.
"""
url = BENCH_DATA_URL % (builder, build_num)
subprocess.check_call(['gsutil', 'cp', '-R', url, dest_dir],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
def find_revision_from_downloaded_data(dest_dir):
"""Finds the revision at which the downloaded data was generated.
Args:
dest_dir: string; directory holding the downloaded data.
Returns:
The revision (git commit hash) at which the downloaded data was
generated, or None if no revision can be found.
"""
for data_file in os.listdir(dest_dir):
match = re.match('bench_(?P<revision>[0-9a-fA-F]{2,40})_data.*', data_file)
if match:
return match.group('revision')
return None
class TrybotNotFinishedError(Exception):
pass
def gen_bench_expectations_from_codereview(codereview_url,
error_on_unfinished=True):
"""Generate bench expectations from a code review.
Scans the given code review for Perf trybot runs. Downloads the results of
finished trybots and uses them to generate new expectations for their
waterfall counterparts.
Args:
url: string; URL of the code review.
error_on_unfinished: bool; throw an error if any trybot has not finished.
"""
try_builds = find_all_builds(codereview_url)
# Verify that all trybots have finished running.
if error_on_unfinished and not _all_trybots_finished(try_builds):
raise TrybotNotFinishedError('Not all trybots have finished.')
failed_data_pull = []
failed_gen_expectations = []
if os.path.isdir(TMP_BENCH_DATA_DIR):
shutil.rmtree(TMP_BENCH_DATA_DIR)
for try_build in try_builds:
try_builder = try_build.builder_name
builder = try_builder.replace('-Trybot', '')
# Download the data.
dest_dir = os.path.join(TMP_BENCH_DATA_DIR, builder)
os.makedirs(dest_dir)
try:
get_bench_data(try_builder, try_build.build_number, dest_dir)
except subprocess.CalledProcessError:
failed_data_pull.append(try_builder)
continue
# Find the revision at which the data was generated.
revision = find_revision_from_downloaded_data(dest_dir)
if not revision:
# If we can't find a revision, then something is wrong with the data we
# downloaded. Skip this builder.
failed_data_pull.append(try_builder)
continue
# Generate new expectations.
output_file = os.path.join(CHECKOUT_PATH, 'expectations', 'bench',
'bench_expectations_%s.txt' % builder)
try:
subprocess.check_call(['python',
os.path.join(CHECKOUT_PATH, 'bench',
'gen_bench_expectations.py'),
'-b', builder, '-o', output_file,
'-d', dest_dir, '-r', revision])
except subprocess.CalledProcessError:
failed_gen_expectations.append(builder)
failure = ''
if failed_data_pull:
failure += 'Failed to load data for: %s\n\n' % ','.join(failed_data_pull)
if failed_gen_expectations:
failure += 'Failed to generate expectations for: %s\n\n' % ','.join(
failed_gen_expectations)
if failure:
raise Exception(failure)
if __name__ == '__main__':
gen_bench_expectations_from_codereview(sys.argv[1])
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
1898,
334,
67,
9,
6927,
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,
421,
199,
624,
6864,
892,
26456,
21851,
687,
2058,
402,
862,
28143,
641,
282,
1233,
11248,
1041,
421,
199,
646,
5055,
199,
646,
6540,
63,
600,
8578,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
3873,
199,
646,
984,
421,
199,
34,
742,
1244,
63,
3998,
63,
2632,
275,
283,
458,
921,
13211,
13,
1339,
4674,
13,
13844,
15,
9452,
576,
3149,
83,
3149,
83,
6331,
7,
199,
8936,
1877,
63,
3243,
275,
747,
14,
515,
14,
11091,
8,
736,
14,
515,
14,
904,
8,
272,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
22159,
747,
14,
21386,
430,
199,
17983,
63,
34,
742,
1244,
63,
3998,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
8936,
1877,
63,
3243,
12,
1987,
16571,
63,
576,
358,
421,
199,
12357,
3425,
275,
5055,
14,
18921,
8,
272,
283,
12357,
3425,
297,
788,
5649,
63,
354,
297,
283,
1506,
63,
1955,
297,
283,
374,
63,
8669,
1105,
421,
199,
318,
2342,
63,
452,
63,
10838,
8,
600,
8578,
63,
633,
304,
523,
408,
30344,
436,
2529,
2556,
3595,
862,
3018,
7858,
367,
282,
1233,
11248,
14,
819,
3033,
26,
272,
1233,
8578,
63,
633,
26,
2851,
402,
314,
1233,
8578,
315,
7894,
14,
819,
1803,
26,
489,
3820,
402,
16198,
7075,
83,
26,
334,
5649,
63,
354,
12,
1900,
63,
1955,
12,
365,
63,
8669,
9,
523,
408,
523,
2058,
275,
6540,
63,
600,
8578,
14,
3034,
21000,
27375,
1252,
1122,
8,
600,
8578,
63,
633,
9,
523,
862,
63,
10838,
275,
942,
523,
367,
6545,
12,
666,
315,
2058,
14,
4611,
837,
272,
340,
6545,
14,
2460,
360,
12387,
735,
489,
1900,
63,
1507,
275,
666,
14,
633,
14,
1294,
25804,
17,
61,
340,
666,
14,
633,
587,
488,
489,
365,
63,
8669,
275,
334,
576,
14,
1205,
440,
315,
661,
6455,
297,
283,
893,
13,
6455,
358,
436,
2151,
1900,
63,
1507,
365,
440,
488,
9,
489,
862,
63,
10838,
14,
740,
8,
12357,
3425,
8,
5649,
63,
354,
29,
5649,
12,
639,
1900,
63,
1955,
29,
1506,
63,
1507,
12,
639,
365,
63,
8669,
29,
374,
63,
8669,
430,
523,
372,
862,
63,
10838,
421,
199,
318,
485,
452,
63,
893,
28143,
63,
8669,
8,
893,
63,
10838,
304,
523,
408,
1767,
715,
17963,
1006,
402,
314,
1627,
862,
9643,
1172,
9158,
14,
819,
3033,
26,
489,
862,
63,
10838,
26,
769,
402,
7649,
3425,
4454,
14,
819,
1803,
26,
489,
715,
340,
1006,
402,
314,
1627,
862,
9643,
1172,
9158,
12,
4257,
756,
14,
523,
408,
523,
367,
862,
63,
1506,
315,
862,
63,
10838,
26,
272,
340,
440,
862,
63,
1506,
14,
374,
63,
8669,
26,
489,
372,
756,
523,
372,
715,
421,
199,
318,
1006,
63,
893,
28143,
63,
8669,
8,
600,
8578,
63,
633,
304,
523,
408,
1767,
715,
17963,
1006,
402,
314,
862,
9643,
641,
314,
1627,
1233,
8578,
1172,
9158,
14,
819,
3033,
26,
489,
1233,
8578,
63,
633,
26,
1059,
27,
2851,
402,
314,
1233,
8578,
14,
819,
1803,
26,
489,
715,
340,
1006,
402,
314,
862,
9643,
1172,
9158,
12,
4257,
756,
14,
523,
408,
523,
372,
485,
452,
63,
893,
28143,
63,
8669,
8,
1623,
63,
452,
63,
10838,
8,
600,
8578,
63,
633,
430,
421,
199,
318,
664,
63,
16571,
63,
576,
8,
5649,
12,
1900,
63,
1507,
12,
2053,
63,
694,
304,
523,
408,
11950,
314,
26456,
666,
367,
314,
1627,
6545,
737,
314,
1627,
1900,
63,
1507,
14,
819,
3033,
26,
489,
6545,
26,
1059,
27,
536,
402,
314,
6545,
14,
489,
1900,
63,
1507,
26,
1059,
27,
1900,
1329,
14,
489,
2053,
63,
694,
26,
1059,
27,
5724,
2082,
367,
314,
26456,
666,
14,
523,
408,
523,
1166,
275,
699,
742,
1244,
63,
3998,
63,
2632,
450,
334,
5649,
12,
1900,
63,
1507,
9,
523,
3873,
14,
1074,
63,
1250,
2941,
458,
1974,
297,
283,
1850,
297,
2475,
50,
297,
1166,
12,
2053,
63,
694,
467,
586,
3839,
29,
5781,
14,
6089,
12,
586,
4635,
29,
5781,
14,
6089,
9,
421,
199,
318,
2342,
63,
5792,
63,
504,
63,
19385,
63,
576,
8,
2614,
63,
694,
304,
523,
408,
30344,
314,
6974,
737,
1314,
314,
13557,
666,
1990,
4046,
14,
819,
3033,
26,
489,
2053,
63,
694,
26,
1059,
27,
2082,
17573,
314,
13557,
666,
14,
819,
1803,
26,
489,
710,
6974,
334,
3187,
5532,
2631,
9,
737,
1314,
314,
13557,
666,
1990,
489,
4046,
12,
503,
488,
340,
949,
6974,
883,
506,
1911,
14,
523,
408,
523,
367,
666,
63,
493,
315,
747,
14,
7374,
8,
2614,
63,
694,
304,
272,
1336,
275,
295,
14,
1431,
360,
16571,
63,
2229,
48,
28,
5792,
9514,
16,
13,
25,
65,
13,
13753,
13,
38,
8194,
18,
12,
2167,
1552,
63,
576,
16110,
666,
63,
493,
9,
272,
340,
1336,
26,
489,
372,
1336,
14,
923,
360,
5792,
358,
523,
372,
488,
421,
199,
533,
7649,
3018,
1763,
13430,
547,
8,
1726,
304,
523,
986,
421,
199,
318,
3805,
63,
16571,
63,
15752,
63,
504,
63,
600,
8578,
8,
600,
8578,
63,
633,
12,
5644,
1125,
63,
265,
63,
324,
8669,
29,
549,
304,
523,
408,
6864,
26456,
21851,
687,
282,
1233,
11248,
14,
819,
13916,
796,
314,
1627,
1233,
11248,
367,
31778,
862,
3018,
7858,
14,
13392,
3640,
314,
2058,
402,
523,
9158,
862,
28143,
436,
4440,
3062,
370,
3550,
892,
21851,
367,
3932,
523,
336,
323,
3941,
452,
7055,
4181,
14,
819,
3033,
26,
489,
1166,
26,
1059,
27,
2851,
402,
314,
1233,
11248,
14,
489,
1125,
63,
265,
63,
324,
8669,
26,
2155,
27,
7978,
376,
1125,
340,
1263,
862,
3018,
965,
440,
9158,
14,
523,
408,
523,
862,
63,
10838,
275,
2342,
63,
452,
63,
10838,
8,
600,
8578,
63,
633,
9,
819,
327,
7635,
626,
1006,
862,
28143,
1172,
9158,
3879,
14,
523,
340,
1125,
63,
265,
63,
324,
8669,
436
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
1898,
334,
67,
9,
6927,
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,
421,
199,
624,
6864,
892,
26456,
21851,
687,
2058,
402,
862,
28143,
641,
282,
1233,
11248,
1041,
421,
199,
646,
5055,
199,
646,
6540,
63,
600,
8578,
199,
646,
747,
199,
646,
295,
199,
646,
5145,
199,
646,
3873,
199,
646,
984,
421,
199,
34,
742,
1244,
63,
3998,
63,
2632,
275,
283,
458,
921,
13211,
13,
1339,
4674,
13,
13844,
15,
9452,
576,
3149,
83,
3149,
83,
6331,
7,
199,
8936,
1877,
63,
3243,
275,
747,
14,
515,
14,
11091,
8,
736,
14,
515,
14,
904,
8,
272,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
4832,
3460,
493,
22159,
747,
14,
21386,
430,
199,
17983,
63,
34,
742,
1244,
63,
3998,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
8936,
1877,
63,
3243,
12,
1987,
16571,
63,
576,
358,
421,
199,
12357,
3425,
275,
5055,
14,
18921,
8,
272,
283,
12357,
3425,
297,
788,
5649,
63,
354,
297,
283,
1506,
63,
1955,
297,
283,
374,
63,
8669,
1105,
421,
199,
318,
2342,
63,
452,
63,
10838,
8,
600,
8578,
63,
633,
304,
523,
408,
30344,
436,
2529,
2556,
3595,
862,
3018,
7858,
367,
282,
1233,
11248,
14,
819,
3033,
26,
272,
1233,
8578,
63,
633,
26,
2851,
402,
314,
1233,
8578,
315,
7894,
14,
819,
1803,
26,
489,
3820,
402,
16198,
7075,
83,
26,
334,
5649,
63,
354,
12,
1900,
63,
1955,
12,
365,
63,
8669,
9,
523,
408,
523,
2058,
275,
6540,
63,
600,
8578,
14,
3034,
21000,
27375,
1252,
1122,
8,
600,
8578,
63,
633,
9,
523,
862,
63,
10838,
275,
942,
523,
367,
6545,
12,
666,
315,
2058,
14,
4611,
837,
272,
340,
6545,
14,
2460,
360,
12387,
735,
489,
1900,
63,
1507,
275,
666,
14,
633,
14,
1294,
25804,
17,
61,
340,
666,
14,
633,
587,
488,
489,
365,
63,
8669,
275,
334,
576,
14,
1205,
440,
315,
661,
6455,
297,
283,
893,
13,
6455,
358,
436,
2151,
1900,
63,
1507,
365,
440,
488,
9,
489,
862,
63,
10838,
14,
740,
8,
12357,
3425,
8,
5649,
63,
354,
29,
5649,
12,
639,
1900,
63,
1955,
29,
1506,
63,
1507,
12,
639,
365,
63,
8669,
29,
374,
63,
8669,
430,
523,
372,
862,
63,
10838,
421,
199,
318,
485,
452,
63,
893,
28143,
63,
8669,
8,
893,
63,
10838,
304,
523,
408,
1767,
715,
17963,
1006,
402,
314,
1627,
862,
9643,
1172,
9158,
14,
819,
3033,
26,
489,
862,
63,
10838,
26,
769,
402,
7649,
3425,
4454,
14,
819,
1803,
26,
489,
715,
340,
1006,
402,
314,
1627,
862,
9643,
1172,
9158,
12,
4257,
756,
14,
523,
408,
523,
367,
862,
63,
1506,
315,
862,
63,
10838,
26,
272,
340,
440,
862,
63,
1506,
14,
374,
63,
8669,
26,
489,
372,
756,
523,
372,
715,
421,
199,
318,
1006,
63,
893,
28143,
63,
8669,
8,
600,
8578,
63,
633,
304,
523,
408,
1767,
715,
17963,
1006,
402,
314,
862,
9643,
641,
314,
1627,
1233,
8578,
1172,
9158,
14,
819,
3033,
26,
489,
1233,
8578,
63,
633,
26,
1059,
27,
2851,
402,
314,
1233,
8578,
14,
819,
1803,
26,
489,
715,
340,
1006,
402,
314,
862,
9643,
1172,
9158,
12,
4257,
756,
14,
523,
408,
523,
372,
485,
452,
63,
893,
28143,
63,
8669,
8,
1623,
63,
452,
63,
10838,
8,
600,
8578,
63,
633,
430,
421,
199,
318,
664,
63,
16571,
63,
576,
8,
5649,
12,
1900,
63,
1507,
12,
2053,
63,
694,
304,
523,
408,
11950,
314,
26456,
666,
367,
314,
1627,
6545,
737,
314,
1627,
1900,
63,
1507,
14,
819,
3033,
26,
489,
6545,
26,
1059,
27,
536,
402,
314,
6545,
14,
489,
1900,
63,
1507,
26,
1059,
27,
1900,
1329,
14,
489,
2053,
63,
694,
26,
1059,
27,
5724,
2082,
367,
314,
26456,
666,
14,
523,
408,
523,
1166,
275,
699,
742,
1244,
63,
3998,
63,
2632,
450,
334,
5649,
12,
1900,
63,
1507,
9,
523,
3873,
14,
1074,
63,
1250,
2941,
458,
1974,
297,
283,
1850,
297,
2475,
50,
297,
1166,
12,
2053,
63,
694,
467,
586,
3839,
29,
5781,
14,
6089,
12,
586,
4635,
29,
5781,
14,
6089,
9,
421,
199,
318,
2342,
63,
5792,
63,
504,
63,
19385,
63,
576,
8,
2614,
63,
694,
304,
523,
408,
30344,
314,
6974,
737,
1314,
314,
13557,
666,
1990,
4046,
14,
819,
3033,
26,
489,
2053,
63,
694,
26,
1059,
27,
2082,
17573,
314,
13557,
666,
14,
819,
1803,
26,
489,
710,
6974,
334,
3187,
5532,
2631,
9,
737,
1314,
314,
13557,
666,
1990,
489,
4046,
12,
503,
488,
340,
949,
6974,
883,
506,
1911,
14,
523,
408,
523,
367,
666,
63,
493,
315,
747,
14,
7374,
8,
2614,
63,
694,
304,
272,
1336,
275,
295,
14,
1431,
360,
16571,
63,
2229,
48,
28,
5792,
9514,
16,
13,
25,
65,
13,
13753,
13,
38,
8194,
18,
12,
2167,
1552,
63,
576,
16110,
666,
63,
493,
9,
272,
340,
1336,
26,
489,
372,
1336,
14,
923,
360,
5792,
358,
523,
372,
488,
421,
199,
533,
7649,
3018,
1763,
13430,
547,
8,
1726,
304,
523,
986,
421,
199,
318,
3805,
63,
16571,
63,
15752,
63,
504,
63,
600,
8578,
8,
600,
8578,
63,
633,
12,
5644,
1125,
63,
265,
63,
324,
8669,
29,
549,
304,
523,
408,
6864,
26456,
21851,
687,
282,
1233,
11248,
14,
819,
13916,
796,
314,
1627,
1233,
11248,
367,
31778,
862,
3018,
7858,
14,
13392,
3640,
314,
2058,
402,
523,
9158,
862,
28143,
436,
4440,
3062,
370,
3550,
892,
21851,
367,
3932,
523,
336,
323,
3941,
452,
7055,
4181,
14,
819,
3033,
26,
489,
1166,
26,
1059,
27,
2851,
402,
314,
1233,
11248,
14,
489,
1125,
63,
265,
63,
324,
8669,
26,
2155,
27,
7978,
376,
1125,
340,
1263,
862,
3018,
965,
440,
9158,
14,
523,
408,
523,
862,
63,
10838,
275,
2342,
63,
452,
63,
10838,
8,
600,
8578,
63,
633,
9,
819,
327,
7635,
626,
1006,
862,
28143,
1172,
9158,
3879,
14,
523,
340,
1125,
63,
265,
63,
324,
8669,
436,
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,
1
] |
akashsinghal/Speech-Memorization-App
|
speech/Swift/Speech-gRPC-Streaming/env/lib/python3.6/site-packages/pip/_vendor/requests/packages/chardet/euckrprober.py
|
2931
|
1675
|
######################## 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"
|
apache-2.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,
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,
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,
421,
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,
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,
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,
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,
421,
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,
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,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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
] |
adblockplus/gyp
|
test/mac/gyptest-strip-default.py
|
232
|
2448
|
#!/usr/bin/env python
# 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.
"""
Verifies that the default STRIP_STYLEs match between different generators.
"""
import TestGyp
import re
import subprocess
import sys
import time
if sys.platform == 'darwin':
test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
CHDIR='strip'
test.run_gyp('test-defaults.gyp', chdir=CHDIR)
test.build('test-defaults.gyp', test.ALL, chdir=CHDIR)
# Lightweight check if stripping was done.
def OutPath(s):
return test.built_file_path(s, chdir=CHDIR)
def CheckNsyms(p, o_expected):
proc = subprocess.Popen(['nm', '-aU', p], stdout=subprocess.PIPE)
o = proc.communicate()[0]
# Filter out mysterious "00 0000 OPT radr://5614542" symbol which
# is apparently only printed on the bots (older toolchain?).
# Yes, "radr", not "rdar".
o = ''.join(filter(lambda s: 'radr://5614542' not in s, o.splitlines(True)))
o = o.replace('A', 'T')
o = re.sub(r'^[a-fA-F0-9]+', 'XXXXXXXX', o, flags=re.MULTILINE)
assert not proc.returncode
if o != o_expected:
print 'Stripping: Expected symbols """\n%s""", got """\n%s"""' % (
o_expected, o)
test.fail_test()
CheckNsyms(OutPath('libsingle_dylib.dylib'),
"""\
XXXXXXXX S _ci
XXXXXXXX S _i
XXXXXXXX T _the_function
XXXXXXXX t _the_hidden_function
XXXXXXXX T _the_used_function
XXXXXXXX T _the_visible_function
""")
CheckNsyms(OutPath('single_so.so'),
"""\
XXXXXXXX S _ci
XXXXXXXX S _i
XXXXXXXX T _the_function
XXXXXXXX t _the_hidden_function
XXXXXXXX T _the_used_function
XXXXXXXX T _the_visible_function
""")
CheckNsyms(OutPath('single_exe'),
"""\
XXXXXXXX T __mh_execute_header
""")
CheckNsyms(test.built_file_path(
'bundle_dylib.framework/Versions/A/bundle_dylib', chdir=CHDIR),
"""\
XXXXXXXX S _ci
XXXXXXXX S _i
XXXXXXXX T _the_function
XXXXXXXX t _the_hidden_function
XXXXXXXX T _the_used_function
XXXXXXXX T _the_visible_function
""")
CheckNsyms(test.built_file_path(
'bundle_so.bundle/Contents/MacOS/bundle_so', chdir=CHDIR),
"""\
XXXXXXXX S _ci
XXXXXXXX S _i
XXXXXXXX T _the_function
XXXXXXXX T _the_used_function
XXXXXXXX T _the_visible_function
""")
CheckNsyms(test.built_file_path(
'bundle_exe.app/Contents/MacOS/bundle_exe', chdir=CHDIR),
"""\
XXXXXXXX T __mh_execute_header
""")
test.pass_test()
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
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,
624,
199,
21168,
626,
314,
849,
7553,
1772,
63,
18466,
83,
1336,
3382,
3365,
16952,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
646,
295,
199,
646,
3873,
199,
646,
984,
199,
646,
900,
199,
199,
692,
984,
14,
3246,
508,
283,
13245,
356,
523,
511,
275,
25688,
14,
774,
13899,
8,
6321,
2968,
8675,
297,
283,
1875,
297,
283,
8701,
1105,
819,
6624,
3022,
534,
1913,
7,
523,
511,
14,
1065,
63,
6179,
360,
396,
13,
4322,
14,
6179,
297,
13097,
29,
30285,
9,
819,
511,
14,
1506,
360,
396,
13,
4322,
14,
6179,
297,
511,
14,
1761,
12,
13097,
29,
30285,
9,
819,
327,
29684,
3463,
1104,
340,
4024,
3637,
1990,
4224,
14,
523,
347,
6219,
2042,
8,
83,
304,
272,
372,
511,
14,
11730,
63,
493,
63,
515,
8,
83,
12,
13097,
29,
30285,
9,
819,
347,
2670,
46,
13807,
8,
80,
12,
312,
63,
2062,
304,
272,
6499,
275,
3873,
14,
7942,
2941,
10756,
297,
2475,
65,
53,
297,
299,
467,
3839,
29,
5781,
14,
6089,
9,
272,
312,
275,
6499,
14,
10664,
3430,
16,
61,
339,
327,
9388,
734,
333,
588,
6236,
1785,
298,
383,
378,
1493,
257,
11662,
660,
5012,
921,
1367,
1079,
19861,
2,
5272,
1314,
272,
327,
365,
27241,
590,
1454,
12487,
641,
314,
31726,
334,
2149,
22689,
31,
680,
272,
327,
29715,
12,
298,
345,
5012,
401,
440,
298,
82,
4460,
1674,
272,
312,
275,
6522,
904,
8,
1541,
8,
2734,
308,
26,
283,
345,
5012,
921,
1367,
1079,
19861,
7,
440,
315,
308,
12,
312,
14,
7644,
8,
549,
1724,
339,
312,
275,
312,
14,
1814,
360,
33,
297,
283,
52,
358,
272,
312,
275,
295,
14,
954,
8,
82,
23811,
65,
13,
13753,
13,
38,
16,
13,
25,
11529,
283,
13312,
297,
312,
12,
3285,
29,
264,
14,
16661,
9,
272,
702,
440,
6499,
14,
9913,
272,
340,
312,
1137,
312,
63,
2062,
26,
489,
870,
283,
24125,
3637,
26,
13796,
6698,
9638,
78,
5,
83,
7208,
4788,
9638,
78,
5,
83,
624,
7,
450,
334,
881,
312,
63,
2062,
12,
312,
9,
489,
511,
14,
1633,
63,
396,
342,
819,
2670,
46,
13807,
8,
2204,
2042,
360,
773,
4780,
63,
22305,
14,
22305,
659,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
307,
485,
1589,
63,
5642,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
2204,
2042,
360,
4780,
63,
1152,
14,
1152,
659,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
307,
485,
1589,
63,
5642,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
2204,
2042,
360,
4780,
63,
5803,
659,
199,
19659,
199,
13312,
377,
636,
17077,
63,
2526,
63,
1291,
199,
6141,
819,
2670,
46,
13807,
8,
396,
14,
11730,
63,
493,
63,
515,
8,
489,
283,
6469,
63,
22305,
14,
4857,
15,
21167,
15,
33,
15,
6469,
63,
22305,
297,
13097,
29,
30285,
395,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
307,
485,
1589,
63,
5642,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
396,
14,
11730,
63,
493,
63,
515,
8,
489,
283,
6469,
63,
1152,
14,
6469,
15,
11383,
15,
3399,
3100,
15,
6469,
63,
1152,
297,
13097,
29,
30285,
395,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
396,
14,
11730,
63,
493,
63,
515,
8,
489,
283,
6469,
63,
5803,
14,
571,
15,
11383,
15,
3399,
3100,
15,
6469,
63,
5803,
297,
13097,
29,
30285,
395,
199,
19659,
199,
13312,
377,
636,
17077,
63,
2526,
63,
1291,
199,
6141,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
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,
624,
199,
21168,
626,
314,
849,
7553,
1772,
63,
18466,
83,
1336,
3382,
3365,
16952,
14,
199,
624,
199,
199,
646,
25688,
199,
199,
646,
295,
199,
646,
3873,
199,
646,
984,
199,
646,
900,
199,
199,
692,
984,
14,
3246,
508,
283,
13245,
356,
523,
511,
275,
25688,
14,
774,
13899,
8,
6321,
2968,
8675,
297,
283,
1875,
297,
283,
8701,
1105,
819,
6624,
3022,
534,
1913,
7,
523,
511,
14,
1065,
63,
6179,
360,
396,
13,
4322,
14,
6179,
297,
13097,
29,
30285,
9,
819,
511,
14,
1506,
360,
396,
13,
4322,
14,
6179,
297,
511,
14,
1761,
12,
13097,
29,
30285,
9,
819,
327,
29684,
3463,
1104,
340,
4024,
3637,
1990,
4224,
14,
523,
347,
6219,
2042,
8,
83,
304,
272,
372,
511,
14,
11730,
63,
493,
63,
515,
8,
83,
12,
13097,
29,
30285,
9,
819,
347,
2670,
46,
13807,
8,
80,
12,
312,
63,
2062,
304,
272,
6499,
275,
3873,
14,
7942,
2941,
10756,
297,
2475,
65,
53,
297,
299,
467,
3839,
29,
5781,
14,
6089,
9,
272,
312,
275,
6499,
14,
10664,
3430,
16,
61,
339,
327,
9388,
734,
333,
588,
6236,
1785,
298,
383,
378,
1493,
257,
11662,
660,
5012,
921,
1367,
1079,
19861,
2,
5272,
1314,
272,
327,
365,
27241,
590,
1454,
12487,
641,
314,
31726,
334,
2149,
22689,
31,
680,
272,
327,
29715,
12,
298,
345,
5012,
401,
440,
298,
82,
4460,
1674,
272,
312,
275,
6522,
904,
8,
1541,
8,
2734,
308,
26,
283,
345,
5012,
921,
1367,
1079,
19861,
7,
440,
315,
308,
12,
312,
14,
7644,
8,
549,
1724,
339,
312,
275,
312,
14,
1814,
360,
33,
297,
283,
52,
358,
272,
312,
275,
295,
14,
954,
8,
82,
23811,
65,
13,
13753,
13,
38,
16,
13,
25,
11529,
283,
13312,
297,
312,
12,
3285,
29,
264,
14,
16661,
9,
272,
702,
440,
6499,
14,
9913,
272,
340,
312,
1137,
312,
63,
2062,
26,
489,
870,
283,
24125,
3637,
26,
13796,
6698,
9638,
78,
5,
83,
7208,
4788,
9638,
78,
5,
83,
624,
7,
450,
334,
881,
312,
63,
2062,
12,
312,
9,
489,
511,
14,
1633,
63,
396,
342,
819,
2670,
46,
13807,
8,
2204,
2042,
360,
773,
4780,
63,
22305,
14,
22305,
659,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
307,
485,
1589,
63,
5642,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
2204,
2042,
360,
4780,
63,
1152,
14,
1152,
659,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
307,
485,
1589,
63,
5642,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
2204,
2042,
360,
4780,
63,
5803,
659,
199,
19659,
199,
13312,
377,
636,
17077,
63,
2526,
63,
1291,
199,
6141,
819,
2670,
46,
13807,
8,
396,
14,
11730,
63,
493,
63,
515,
8,
489,
283,
6469,
63,
22305,
14,
4857,
15,
21167,
15,
33,
15,
6469,
63,
22305,
297,
13097,
29,
30285,
395,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
307,
485,
1589,
63,
5642,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
396,
14,
11730,
63,
493,
63,
515,
8,
489,
283,
6469,
63,
1152,
14,
6469,
15,
11383,
15,
3399,
3100,
15,
6469,
63,
1152,
297,
13097,
29,
30285,
395,
199,
19659,
199,
13312,
428,
485,
559,
199,
13312,
428,
485,
73,
199,
13312,
377,
485,
1589,
63,
1593,
199,
13312,
377,
485,
1589,
63,
2972,
63,
1593,
199,
13312,
377,
485,
1589,
63,
6604,
63,
1593,
199,
6141,
523,
2670,
46,
13807,
8,
396,
14,
11730,
63,
493,
63,
515,
8,
489,
283,
6469,
63,
5803,
14,
571,
15,
11383,
15,
3399,
3100,
15,
6469,
63,
5803,
297,
13097,
29,
30285,
395,
199,
19659,
199,
13312,
377,
636,
17077,
63,
2526,
63,
1291,
199,
6141,
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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
0,
0,
0,
0,
0,
0,
0,
0
] |
corruptnova/namebench
|
nb_third_party/dns/rdtypes/IN/A.py
|
248
|
2055
|
# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
# provided that the above copyright notice and this permission notice
# appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import dns.exception
import dns.ipv4
import dns.rdata
import dns.tokenizer
class A(dns.rdata.Rdata):
"""A record.
@ivar address: an IPv4 address
@type address: string (in the standard "dotted quad" format)"""
__slots__ = ['address']
def __init__(self, rdclass, rdtype, address):
super(A, self).__init__(rdclass, rdtype)
# check that it's OK
junk = dns.ipv4.inet_aton(address)
self.address = address
def to_text(self, origin=None, relativize=True, **kw):
return self.address
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
address = tok.get_identifier()
tok.get_eol()
return cls(rdclass, rdtype, address)
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
file.write(dns.ipv4.inet_aton(self.address))
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
address = dns.ipv4.inet_ntoa(wire[current : current + rdlen])
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
def _cmp(self, other):
sa = dns.ipv4.inet_aton(self.address)
oa = dns.ipv4.inet_aton(other.address)
return cmp(sa, oa)
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
13004,
13,
9488,
12,
8937,
12,
7129,
653,
676,
262,
453,
12,
3277,
14,
199,
3,
199,
3,
8779,
370,
675,
12,
1331,
12,
2811,
12,
436,
11207,
642,
2032,
436,
2399,
199,
3,
3794,
367,
1263,
12016,
543,
503,
1928,
14751,
365,
11882,
10009,
12,
199,
3,
2741,
626,
314,
3432,
4248,
4245,
436,
642,
4983,
4245,
199,
3,
7468,
315,
1006,
6866,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
2,
2401,
4825,
4896,
2639,
8990,
51,
11727,
2990,
199,
3,
1663,
14142,
7816,
2296,
5749,
4141,
6931,
11727,
5292,
2990,
1634,
199,
3,
3169,
2401,
3092,
14,
1621,
4825,
6461,
7000,
4825,
4896,
2639,
6262,
7024,
2381,
199,
3,
1821,
8820,
12,
8703,
12,
9168,
12,
1549,
9110,
6736,
1549,
1821,
6736,
199,
3,
28752,
4118,
27362,
20668,
1206,
4442,
9102,
1634,
4815,
12,
7126,
1549,
9206,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
9254,
1549,
5010,
7056,
25657,
9612,
12,
7043,
5738,
199,
3,
1634,
1549,
1621,
11287,
1663,
2334,
4815,
1549,
13873,
30340,
1634,
5749,
4141,
14,
199,
199,
646,
6715,
14,
1971,
199,
646,
6715,
14,
4774,
20,
199,
646,
6715,
14,
23203,
199,
646,
6715,
14,
13771,
199,
199,
533,
437,
8,
5797,
14,
23203,
14,
50,
576,
304,
272,
408,
33,
2777,
14,
339,
768,
7725,
2287,
26,
376,
6509,
20,
2287,
272,
768,
466,
2287,
26,
1059,
334,
262,
314,
4465,
298,
19404,
16744,
2,
1475,
9471,
339,
636,
7257,
363,
275,
788,
1562,
418,
339,
347,
636,
826,
721,
277,
12,
29320,
12,
22764,
12,
2287,
304,
267,
1613,
8,
33,
12,
291,
2843,
826,
721,
30186,
12,
22764,
9,
267,
327,
1104,
626,
652,
1159,
9949,
267,
24605,
275,
6715,
14,
4774,
20,
14,
10811,
63,
25685,
8,
1562,
9,
267,
291,
14,
1562,
275,
2287,
339,
347,
370,
63,
505,
8,
277,
12,
6330,
29,
403,
12,
13773,
29282,
29,
549,
12,
1011,
829,
304,
267,
372,
291,
14,
1562,
339,
347,
687,
63,
505,
8,
1886,
12,
29320,
12,
22764,
12,
8431,
12,
6330,
275,
488,
12,
13773,
29282,
275,
715,
304,
267,
2287,
275,
8431,
14,
362,
63,
5364,
342,
267,
8431,
14,
362,
63,
20470,
342,
267,
372,
843,
8,
30186,
12,
22764,
12,
2287,
9,
339,
687,
63,
505,
275,
18990,
8,
504,
63,
505,
9,
339,
347,
370,
63,
11239,
8,
277,
12,
570,
12,
11029,
275,
488,
12,
6330,
275,
488,
304,
267,
570,
14,
952,
8,
5797,
14,
4774,
20,
14,
10811,
63,
25685,
8,
277,
14,
1562,
430,
339,
347,
687,
63,
11239,
8,
1886,
12,
29320,
12,
22764,
12,
11799,
12,
1453,
12,
11517,
552,
12,
6330,
275,
488,
304,
267,
2287,
275,
6715,
14,
4774,
20,
14,
10811,
63,
343,
20047,
8,
11239,
59,
1818,
520,
1453,
435,
11517,
552,
566,
267,
372,
843,
8,
30186,
12,
22764,
12,
2287,
9,
339,
687,
63,
11239,
275,
18990,
8,
504,
63,
11239,
9,
339,
347,
485,
5730,
8,
277,
12,
1163,
304,
267,
2937,
275,
6715,
14,
4774,
20,
14,
10811,
63,
25685,
8,
277,
14,
1562,
9,
267,
312,
65,
275,
6715,
14,
4774,
20,
14,
10811,
63,
25685,
8,
1848,
14,
1562,
9,
267,
372,
10467,
8,
2231,
12,
312,
65,
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
] |
[
1898,
334,
35,
9,
13004,
13,
9488,
12,
8937,
12,
7129,
653,
676,
262,
453,
12,
3277,
14,
199,
3,
199,
3,
8779,
370,
675,
12,
1331,
12,
2811,
12,
436,
11207,
642,
2032,
436,
2399,
199,
3,
3794,
367,
1263,
12016,
543,
503,
1928,
14751,
365,
11882,
10009,
12,
199,
3,
2741,
626,
314,
3432,
4248,
4245,
436,
642,
4983,
4245,
199,
3,
7468,
315,
1006,
6866,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
2,
2401,
4825,
4896,
2639,
8990,
51,
11727,
2990,
199,
3,
1663,
14142,
7816,
2296,
5749,
4141,
6931,
11727,
5292,
2990,
1634,
199,
3,
3169,
2401,
3092,
14,
1621,
4825,
6461,
7000,
4825,
4896,
2639,
6262,
7024,
2381,
199,
3,
1821,
8820,
12,
8703,
12,
9168,
12,
1549,
9110,
6736,
1549,
1821,
6736,
199,
3,
28752,
4118,
27362,
20668,
1206,
4442,
9102,
1634,
4815,
12,
7126,
1549,
9206,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
9254,
1549,
5010,
7056,
25657,
9612,
12,
7043,
5738,
199,
3,
1634,
1549,
1621,
11287,
1663,
2334,
4815,
1549,
13873,
30340,
1634,
5749,
4141,
14,
199,
199,
646,
6715,
14,
1971,
199,
646,
6715,
14,
4774,
20,
199,
646,
6715,
14,
23203,
199,
646,
6715,
14,
13771,
199,
199,
533,
437,
8,
5797,
14,
23203,
14,
50,
576,
304,
272,
408,
33,
2777,
14,
339,
768,
7725,
2287,
26,
376,
6509,
20,
2287,
272,
768,
466,
2287,
26,
1059,
334,
262,
314,
4465,
298,
19404,
16744,
2,
1475,
9471,
339,
636,
7257,
363,
275,
788,
1562,
418,
339,
347,
636,
826,
721,
277,
12,
29320,
12,
22764,
12,
2287,
304,
267,
1613,
8,
33,
12,
291,
2843,
826,
721,
30186,
12,
22764,
9,
267,
327,
1104,
626,
652,
1159,
9949,
267,
24605,
275,
6715,
14,
4774,
20,
14,
10811,
63,
25685,
8,
1562,
9,
267,
291,
14,
1562,
275,
2287,
339,
347,
370,
63,
505,
8,
277,
12,
6330,
29,
403,
12,
13773,
29282,
29,
549,
12,
1011,
829,
304,
267,
372,
291,
14,
1562,
339,
347,
687,
63,
505,
8,
1886,
12,
29320,
12,
22764,
12,
8431,
12,
6330,
275,
488,
12,
13773,
29282,
275,
715,
304,
267,
2287,
275,
8431,
14,
362,
63,
5364,
342,
267,
8431,
14,
362,
63,
20470,
342,
267,
372,
843,
8,
30186,
12,
22764,
12,
2287,
9,
339,
687,
63,
505,
275,
18990,
8,
504,
63,
505,
9,
339,
347,
370,
63,
11239,
8,
277,
12,
570,
12,
11029,
275,
488,
12,
6330,
275,
488,
304,
267,
570,
14,
952,
8,
5797,
14,
4774,
20,
14,
10811,
63,
25685,
8,
277,
14,
1562,
430,
339,
347,
687,
63,
11239,
8,
1886,
12,
29320,
12,
22764,
12,
11799,
12,
1453,
12,
11517,
552,
12,
6330,
275,
488,
304,
267,
2287,
275,
6715,
14,
4774,
20,
14,
10811,
63,
343,
20047,
8,
11239,
59,
1818,
520,
1453,
435,
11517,
552,
566,
267,
372,
843,
8,
30186,
12,
22764,
12,
2287,
9,
339,
687,
63,
11239,
275,
18990,
8,
504,
63,
11239,
9,
339,
347,
485,
5730,
8,
277,
12,
1163,
304,
267,
2937,
275,
6715,
14,
4774,
20,
14,
10811,
63,
25685,
8,
277,
14,
1562,
9,
267,
312,
65,
275,
6715,
14,
4774,
20,
14,
10811,
63,
25685,
8,
1848,
14,
1562,
9,
267,
372,
10467,
8,
2231,
12,
312,
65,
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,
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,
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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
] |
ioannistsanaktsidis/invenio
|
modules/websubmit/lib/functions/DEMOVID_Validation.py
|
28
|
4492
|
## This file is part of Invenio.
## Copyright (C) 2011 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.
"""WebSubmit function - Video processing.
"""
from invenio.bibencode_utils import probe
from invenio.websubmit_config import InvenioWebSubmitFunctionStop
import os
__revision__ = "$Id$"
def DEMOVID_Validation(parameters, curdir, form, user_info=None):
"""
"""
messages = []
malformed = False
file_storing_path = os.path.join(curdir, "files", str(user_info['uid']), "NewFile", 'filepath')
file_storing_name = os.path.join(curdir, "files", str(user_info['uid']), "NewFile", 'filename')
file_storing_aspect = os.path.join(curdir, "DEMOVID_ASPECT")
file_storing_title = os.path.join(curdir, "DEMOVID_TITLE")
file_storing_description = os.path.join(curdir, "DEMOVID_DESCR")
file_storing_author = os.path.join(curdir, "DEMOVID_AU")
file_storing_year = os.path.join(curdir, "DEMOVID_YEAR")
## Validate the uploaded video
try:
fp = open(file_storing_path)
fullpath = fp.read()
fp.close()
fp = open(file_storing_name)
filename = fp.read()
fp.close()
if not probe(fullpath) or os.path.splitext(filename)[1] in ['jpg', 'jpeg', 'gif', 'tiff', 'bmp', 'png', 'tga']:
malformed = True
messages.append("The uploaded file is not a supported video format.")
except:
malformed = True
messages.append("Please upload a video.")
## Validate the title
try:
fp = open(file_storing_title)
title = fp.read()
fp.close()
if len(title) < 2 or len(title) > 50:
malformed = True
messages.append("The title is too short, please enter at least 2 characters.")
except:
malformed = True
messages.append("Please enter a title.")
## Validate the description
try:
fp = open(file_storing_description)
description = fp.read()
fp.close()
if len(description) < 10:
malformed = True
messages.append("The description must be at least 10 characters long.")
except:
malformed = True
messages.append("Please enter a description.")
## Validate author
try:
fp = open(file_storing_author)
author = fp.read()
fp.close()
except:
malformed = True
messages.append("Please enter at least one author.")
## Validate year
try:
fp = open(file_storing_year)
year = fp.read()
fp.close()
except:
malformed = True
messages.append("Please enter a year.")
try:
if int(year) < 1000 or int(year) > 9999:
malformed = True
messages.append("Please enter a valid year. It must consist of 4 digits.")
except:
malformed = True
messages.append("Please enter a valid year. It must consist of 4 digits.")
## Validate the aspect ratio
try:
fp = open(file_storing_aspect)
aspect = fp.read()
fp.close()
try:
aspectx, aspecty = aspect.split(':')
aspectx = int(aspectx)
aspecty = int(aspecty)
except:
malformed = True
messages.append("Aspect ratio was not provided as 'Number:Number' format")
except:
malformed = True
messages.append("Please enter an aspect ratio.")
if malformed:
raise InvenioWebSubmitFunctionStop("""
<SCRIPT>
document.forms[0].action="/submit";
document.forms[0].curpage.value = 1;
document.forms[0].step.value = 0;
user_must_confirm_before_leaving_page = false;
alert('%s');
document.forms[0].submit();
</SCRIPT>""" % "\\n".join(messages)
)
else:
return
|
gpl-2.0
|
[
309,
961,
570,
365,
1777,
402,
12235,
14,
199,
309,
1898,
334,
35,
9,
7760,
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,
5926,
17187,
805,
446,
15709,
6661,
14,
199,
199,
624,
199,
199,
504,
13640,
14,
8804,
2143,
63,
1208,
492,
22362,
199,
504,
13640,
14,
2520,
7275,
63,
888,
492,
12235,
5926,
17187,
3481,
6293,
199,
646,
747,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
318,
3265,
2679,
5437,
63,
13816,
8,
3214,
12,
1094,
694,
12,
1824,
12,
922,
63,
815,
29,
403,
304,
272,
408,
272,
408,
272,
3788,
275,
942,
272,
24159,
275,
756,
339,
570,
63,
270,
6854,
63,
515,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1725,
401,
620,
8,
751,
63,
815,
459,
1535,
3815,
298,
4665,
1173,
401,
283,
7218,
358,
272,
570,
63,
270,
6854,
63,
354,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1725,
401,
620,
8,
751,
63,
815,
459,
1535,
3815,
298,
4665,
1173,
401,
283,
1501,
358,
272,
570,
63,
270,
6854,
63,
18658,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
1179,
11401,
531,
272,
570,
63,
270,
6854,
63,
1213,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
19091,
531,
272,
570,
63,
270,
6854,
63,
1802,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
4448,
2944,
531,
272,
570,
63,
270,
6854,
63,
2502,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
9331,
531,
272,
570,
63,
270,
6854,
63,
3403,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
19216,
531,
339,
925,
12134,
314,
14238,
3991,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
515,
9,
267,
26404,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
354,
9,
267,
1788,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
340,
440,
22362,
8,
17943,
9,
503,
747,
14,
515,
14,
7973,
8,
1501,
2788,
17,
61,
315,
788,
8476,
297,
283,
14230,
297,
283,
14513,
297,
283,
29119,
297,
283,
22308,
297,
283,
4524,
297,
283,
84,
5294,
2565,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
1918,
14238,
570,
365,
440,
282,
3748,
3991,
1475,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
5802,
282,
3991,
2685,
339,
925,
12134,
314,
2538,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
1213,
9,
267,
2538,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
340,
822,
8,
1213,
9,
665,
499,
503,
822,
8,
1213,
9,
690,
5238,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
1918,
2538,
365,
4634,
3974,
12,
8749,
9509,
737,
5210,
499,
4110,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
2538,
2685,
2378,
925,
12134,
314,
1369,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
1802,
9,
267,
1369,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
340,
822,
8,
1802,
9,
665,
1616,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
1918,
1369,
1471,
506,
737,
5210,
1616,
4110,
1846,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
1369,
2685,
339,
925,
12134,
4132,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
2502,
9,
267,
4132,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
737,
5210,
1373,
4132,
2685,
339,
925,
12134,
5361,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
3403,
9,
267,
5361,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
5361,
2685,
272,
862,
26,
267,
340,
1109,
8,
3403,
9,
665,
5198,
503,
1109,
8,
3403,
9,
690,
221,
5008,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
8254,
9509,
282,
1686,
5361,
14,
2779,
1471,
17568,
402,
841,
7576,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
1686,
5361,
14,
2779,
1471,
17568,
402,
841,
7576,
2685,
339,
925,
12134,
314,
17435,
10463,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
18658,
9,
267,
17435,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
862,
26,
288,
17435,
88,
12,
17435,
89,
275,
17435,
14,
1294,
11633,
288,
17435,
88,
275,
1109,
8,
18658,
88,
9,
288,
17435,
89,
275,
1109,
8,
18658,
89,
9,
267,
871,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
2822,
1764,
10463,
1990,
440,
2741,
465,
283,
3259,
26,
3259,
7,
1475,
531,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
376,
17435,
10463,
2685,
339,
340,
24159,
26
] |
[
961,
570,
365,
1777,
402,
12235,
14,
199,
309,
1898,
334,
35,
9,
7760,
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,
5926,
17187,
805,
446,
15709,
6661,
14,
199,
199,
624,
199,
199,
504,
13640,
14,
8804,
2143,
63,
1208,
492,
22362,
199,
504,
13640,
14,
2520,
7275,
63,
888,
492,
12235,
5926,
17187,
3481,
6293,
199,
646,
747,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
318,
3265,
2679,
5437,
63,
13816,
8,
3214,
12,
1094,
694,
12,
1824,
12,
922,
63,
815,
29,
403,
304,
272,
408,
272,
408,
272,
3788,
275,
942,
272,
24159,
275,
756,
339,
570,
63,
270,
6854,
63,
515,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1725,
401,
620,
8,
751,
63,
815,
459,
1535,
3815,
298,
4665,
1173,
401,
283,
7218,
358,
272,
570,
63,
270,
6854,
63,
354,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1725,
401,
620,
8,
751,
63,
815,
459,
1535,
3815,
298,
4665,
1173,
401,
283,
1501,
358,
272,
570,
63,
270,
6854,
63,
18658,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
1179,
11401,
531,
272,
570,
63,
270,
6854,
63,
1213,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
19091,
531,
272,
570,
63,
270,
6854,
63,
1802,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
4448,
2944,
531,
272,
570,
63,
270,
6854,
63,
2502,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
9331,
531,
272,
570,
63,
270,
6854,
63,
3403,
275,
747,
14,
515,
14,
904,
8,
15594,
12,
298,
1093,
2679,
5437,
63,
19216,
531,
339,
925,
12134,
314,
14238,
3991,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
515,
9,
267,
26404,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
354,
9,
267,
1788,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
340,
440,
22362,
8,
17943,
9,
503,
747,
14,
515,
14,
7973,
8,
1501,
2788,
17,
61,
315,
788,
8476,
297,
283,
14230,
297,
283,
14513,
297,
283,
29119,
297,
283,
22308,
297,
283,
4524,
297,
283,
84,
5294,
2565,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
1918,
14238,
570,
365,
440,
282,
3748,
3991,
1475,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
5802,
282,
3991,
2685,
339,
925,
12134,
314,
2538,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
1213,
9,
267,
2538,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
340,
822,
8,
1213,
9,
665,
499,
503,
822,
8,
1213,
9,
690,
5238,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
1918,
2538,
365,
4634,
3974,
12,
8749,
9509,
737,
5210,
499,
4110,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
2538,
2685,
2378,
925,
12134,
314,
1369,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
1802,
9,
267,
1369,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
340,
822,
8,
1802,
9,
665,
1616,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
1918,
1369,
1471,
506,
737,
5210,
1616,
4110,
1846,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
1369,
2685,
339,
925,
12134,
4132,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
2502,
9,
267,
4132,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
737,
5210,
1373,
4132,
2685,
339,
925,
12134,
5361,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
3403,
9,
267,
5361,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
5361,
2685,
272,
862,
26,
267,
340,
1109,
8,
3403,
9,
665,
5198,
503,
1109,
8,
3403,
9,
690,
221,
5008,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
8254,
9509,
282,
1686,
5361,
14,
2779,
1471,
17568,
402,
841,
7576,
2685,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
282,
1686,
5361,
14,
2779,
1471,
17568,
402,
841,
7576,
2685,
339,
925,
12134,
314,
17435,
10463,
272,
862,
26,
267,
4090,
275,
1551,
8,
493,
63,
270,
6854,
63,
18658,
9,
267,
17435,
275,
4090,
14,
739,
342,
267,
4090,
14,
1600,
342,
267,
862,
26,
288,
17435,
88,
12,
17435,
89,
275,
17435,
14,
1294,
11633,
288,
17435,
88,
275,
1109,
8,
18658,
88,
9,
288,
17435,
89,
275,
1109,
8,
18658,
89,
9,
267,
871,
26,
288,
24159,
275,
715,
288,
3788,
14,
740,
480,
2822,
1764,
10463,
1990,
440,
2741,
465,
283,
3259,
26,
3259,
7,
1475,
531,
272,
871,
26,
267,
24159,
275,
715,
267,
3788,
14,
740,
480,
8254,
9509,
376,
17435,
10463,
2685,
339,
340,
24159,
26,
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
] |
piensa/geonode
|
geonode/groups/translation.py
|
18
|
1291
|
# -*- coding: utf-8 -*-
#########################################################################
#
# Copyright (C) 2016 OSGeo
#
# 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 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 General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
from modeltranslation.translator import translator, TranslationOptions
from geonode.groups.models import GroupCategory, GroupProfile
class GroupCategoryTranslationOptions(TranslationOptions):
fields = ('name',)
class GroupProfileTranslationOptions(TranslationOptions):
fields = ('title', 'description',)
translator.register(GroupCategory, GroupCategoryTranslationOptions)
translator.register(GroupProfile, GroupProfileTranslationOptions)
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3949,
3,
199,
3,
199,
3,
1898,
334,
35,
9,
7800,
4403,
10748,
199,
3,
199,
3,
961,
2240,
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,
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,
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,
642,
2240,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3949,
3,
199,
199,
504,
1402,
6893,
14,
29346,
492,
32034,
12,
25224,
4558,
199,
199,
504,
2312,
29118,
14,
2634,
14,
992,
492,
5611,
7841,
12,
5611,
5736,
421,
199,
533,
5611,
7841,
18483,
4558,
8,
18483,
4558,
304,
272,
1504,
275,
661,
354,
9538,
421,
199,
533,
5611,
5736,
18483,
4558,
8,
18483,
4558,
304,
272,
1504,
275,
661,
1213,
297,
283,
1802,
9538,
421,
199,
29346,
14,
2683,
8,
2448,
7841,
12,
5611,
7841,
18483,
4558,
9,
199,
29346,
14,
2683,
8,
2448,
5736,
12,
5611,
5736,
18483,
4558,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3949,
3,
199,
3,
199,
3,
1898,
334,
35,
9,
7800,
4403,
10748,
199,
3,
199,
3,
961,
2240,
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,
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,
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,
642,
2240,
14,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
3,
199,
3949,
3,
199,
199,
504,
1402,
6893,
14,
29346,
492,
32034,
12,
25224,
4558,
199,
199,
504,
2312,
29118,
14,
2634,
14,
992,
492,
5611,
7841,
12,
5611,
5736,
421,
199,
533,
5611,
7841,
18483,
4558,
8,
18483,
4558,
304,
272,
1504,
275,
661,
354,
9538,
421,
199,
533,
5611,
5736,
18483,
4558,
8,
18483,
4558,
304,
272,
1504,
275,
661,
1213,
297,
283,
1802,
9538,
421,
199,
29346,
14,
2683,
8,
2448,
7841,
12,
5611,
7841,
18483,
4558,
9,
199,
29346,
14,
2683,
8,
2448,
5736,
12,
5611,
5736,
18483,
4558,
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,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
edxnercel/edx-platform
|
.pycharm_helpers/pydev/pydev_ipython/inputhook.py
|
52
|
18411
|
# coding: utf-8
"""
Inputhook management for GUI event loop integration.
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import sys
import select
#-----------------------------------------------------------------------------
# Constants
#-----------------------------------------------------------------------------
# Constants for identifying the GUI toolkits.
GUI_WX = 'wx'
GUI_QT = 'qt'
GUI_QT4 = 'qt4'
GUI_GTK = 'gtk'
GUI_TK = 'tk'
GUI_OSX = 'osx'
GUI_GLUT = 'glut'
GUI_PYGLET = 'pyglet'
GUI_GTK3 = 'gtk3'
GUI_NONE = 'none' # i.e. disable
#-----------------------------------------------------------------------------
# Utilities
#-----------------------------------------------------------------------------
def ignore_CTRL_C():
"""Ignore CTRL+C (not implemented)."""
pass
def allow_CTRL_C():
"""Take CTRL+C into account (not implemented)."""
pass
#-----------------------------------------------------------------------------
# Main InputHookManager class
#-----------------------------------------------------------------------------
class InputHookManager(object):
"""Manage PyOS_InputHook for different GUI toolkits.
This class installs various hooks under ``PyOSInputHook`` to handle
GUI event loop integration.
"""
def __init__(self):
self._return_control_callback = None
self._apps = {}
self._reset()
self.pyplot_imported = False
def _reset(self):
self._callback_pyfunctype = None
self._callback = None
self._current_gui = None
def set_return_control_callback(self, return_control_callback):
self._return_control_callback = return_control_callback
def get_return_control_callback(self):
return self._return_control_callback
def return_control(self):
return self._return_control_callback()
def get_inputhook(self):
return self._callback
def set_inputhook(self, callback):
"""Set inputhook to callback."""
# We don't (in the context of PyDev console) actually set PyOS_InputHook, but rather
# while waiting for input on xmlrpc we run this code
self._callback = callback
def clear_inputhook(self, app=None):
"""Clear input hook.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ``enable_*`` methods. But
the actual value of the parameter is ignored. This uniform interface
makes it easier to have user-level entry points in the main IPython
app like :meth:`enable_gui`."""
self._reset()
def clear_app_refs(self, gui=None):
"""Clear IPython's internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a
reference to the app. This is needed because in some cases bad things
can happen if a user doesn't hold a reference themselves. This
method is provided to clear the references we are holding.
Parameters
----------
gui : None or str
If None, clear all app references. If ('wx', 'qt4') clear
the app for that toolkit. References are not held for gtk or tk
as those toolkits don't have the notion of an app.
"""
if gui is None:
self._apps = {}
elif gui in self._apps:
del self._apps[gui]
def enable_wx(self, app=None):
"""Enable event loop integration with wxPython.
Parameters
----------
app : WX Application, optional.
Running application to use. If not given, we probe WX for an
existing application object, and create a new one if none is found.
Notes
-----
This methods sets the ``PyOS_InputHook`` for wxPython, which allows
the wxPython to integrate with terminal based applications like
IPython.
If ``app`` is not given we probe for an existing one, and return it if
found. If no existing app is found, we create an :class:`wx.App` as
follows::
import wx
app = wx.App(redirect=False, clearSigInt=False)
"""
import wx
from distutils.version import LooseVersion as V
wx_version = V(wx.__version__).version
if wx_version < [2, 8]:
raise ValueError("requires wxPython >= 2.8, but you have %s" % wx.__version__)
from pydev_ipython.inputhookwx import inputhook_wx
self.set_inputhook(inputhook_wx)
self._current_gui = GUI_WX
if app is None:
app = wx.GetApp()
if app is None:
app = wx.App(redirect=False, clearSigInt=False)
app._in_event_loop = True
self._apps[GUI_WX] = app
return app
def disable_wx(self):
"""Disable event loop integration with wxPython.
This merely sets PyOS_InputHook to NULL.
"""
if GUI_WX in self._apps:
self._apps[GUI_WX]._in_event_loop = False
self.clear_inputhook()
def enable_qt4(self, app=None):
"""Enable event loop integration with PyQt4.
Parameters
----------
app : Qt Application, optional.
Running application to use. If not given, we probe Qt for an
existing application object, and create a new one if none is found.
Notes
-----
This methods sets the PyOS_InputHook for PyQt4, which allows
the PyQt4 to integrate with terminal based applications like
IPython.
If ``app`` is not given we probe for an existing one, and return it if
found. If no existing app is found, we create an :class:`QApplication`
as follows::
from PyQt4 import QtCore
app = QtGui.QApplication(sys.argv)
"""
from pydev_ipython.inputhookqt4 import create_inputhook_qt4
app, inputhook_qt4 = create_inputhook_qt4(self, app)
self.set_inputhook(inputhook_qt4)
self._current_gui = GUI_QT4
app._in_event_loop = True
self._apps[GUI_QT4] = app
return app
def disable_qt4(self):
"""Disable event loop integration with PyQt4.
This merely sets PyOS_InputHook to NULL.
"""
if GUI_QT4 in self._apps:
self._apps[GUI_QT4]._in_event_loop = False
self.clear_inputhook()
def enable_gtk(self, app=None):
"""Enable event loop integration with PyGTK.
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
This methods sets the PyOS_InputHook for PyGTK, which allows
the PyGTK to integrate with terminal based applications like
IPython.
"""
from pydev_ipython.inputhookgtk import create_inputhook_gtk
self.set_inputhook(create_inputhook_gtk(self._stdin_file))
self._current_gui = GUI_GTK
def disable_gtk(self):
"""Disable event loop integration with PyGTK.
This merely sets PyOS_InputHook to NULL.
"""
self.clear_inputhook()
def enable_tk(self, app=None):
"""Enable event loop integration with Tk.
Parameters
----------
app : toplevel :class:`Tkinter.Tk` widget, optional.
Running toplevel widget to use. If not given, we probe Tk for an
existing one, and create a new one if none is found.
Notes
-----
If you have already created a :class:`Tkinter.Tk` object, the only
thing done by this method is to register with the
:class:`InputHookManager`, since creating that object automatically
sets ``PyOS_InputHook``.
"""
self._current_gui = GUI_TK
if app is None:
try:
import Tkinter as _TK
except:
# Python 3
import tkinter as _TK
app = _TK.Tk()
app.withdraw()
self._apps[GUI_TK] = app
from pydev_ipython.inputhooktk import create_inputhook_tk
self.set_inputhook(create_inputhook_tk(app))
return app
def disable_tk(self):
"""Disable event loop integration with Tkinter.
This merely sets PyOS_InputHook to NULL.
"""
self.clear_inputhook()
def enable_glut(self, app=None):
""" Enable event loop integration with GLUT.
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
This methods sets the PyOS_InputHook for GLUT, which allows the GLUT to
integrate with terminal based applications like IPython. Due to GLUT
limitations, it is currently not possible to start the event loop
without first creating a window. You should thus not create another
window but use instead the created one. See 'gui-glut.py' in the
docs/examples/lib directory.
The default screen mode is set to:
glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
"""
import OpenGL.GLUT as glut
from pydev_ipython.inputhookglut import glut_display_mode, \
glut_close, glut_display, \
glut_idle, inputhook_glut
if GUI_GLUT not in self._apps:
glut.glutInit(sys.argv)
glut.glutInitDisplayMode(glut_display_mode)
# This is specific to freeglut
if bool(glut.glutSetOption):
glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE,
glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
glut.glutCreateWindow(sys.argv[0])
glut.glutReshapeWindow(1, 1)
glut.glutHideWindow()
glut.glutWMCloseFunc(glut_close)
glut.glutDisplayFunc(glut_display)
glut.glutIdleFunc(glut_idle)
else:
glut.glutWMCloseFunc(glut_close)
glut.glutDisplayFunc(glut_display)
glut.glutIdleFunc(glut_idle)
self.set_inputhook(inputhook_glut)
self._current_gui = GUI_GLUT
self._apps[GUI_GLUT] = True
def disable_glut(self):
"""Disable event loop integration with glut.
This sets PyOS_InputHook to NULL and set the display function to a
dummy one and set the timer to a dummy timer that will be triggered
very far in the future.
"""
import OpenGL.GLUT as glut
from glut_support import glutMainLoopEvent # @UnresolvedImport
glut.glutHideWindow() # This is an event to be processed below
glutMainLoopEvent()
self.clear_inputhook()
def enable_pyglet(self, app=None):
"""Enable event loop integration with pyglet.
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
This methods sets the ``PyOS_InputHook`` for pyglet, which allows
pyglet to integrate with terminal based applications like
IPython.
"""
from pydev_ipython.inputhookpyglet import inputhook_pyglet
self.set_inputhook(inputhook_pyglet)
self._current_gui = GUI_PYGLET
return app
def disable_pyglet(self):
"""Disable event loop integration with pyglet.
This merely sets PyOS_InputHook to NULL.
"""
self.clear_inputhook()
def enable_gtk3(self, app=None):
"""Enable event loop integration with Gtk3 (gir bindings).
Parameters
----------
app : ignored
Ignored, it's only a placeholder to keep the call signature of all
gui activation methods consistent, which simplifies the logic of
supporting magics.
Notes
-----
This methods sets the PyOS_InputHook for Gtk3, which allows
the Gtk3 to integrate with terminal based applications like
IPython.
"""
from pydev_ipython.inputhookgtk3 import create_inputhook_gtk3
self.set_inputhook(create_inputhook_gtk3(self._stdin_file))
self._current_gui = GUI_GTK
def disable_gtk3(self):
"""Disable event loop integration with PyGTK.
This merely sets PyOS_InputHook to NULL.
"""
self.clear_inputhook()
def enable_mac(self, app=None):
""" Enable event loop integration with MacOSX.
We call function pyplot.pause, which updates and displays active
figure during pause. It's not MacOSX-specific, but it enables to
avoid inputhooks in native MacOSX backend.
Also we shouldn't import pyplot, until user does it. Cause it's
possible to choose backend before importing pyplot for the first
time only.
"""
def inputhook_mac(app=None):
if self.pyplot_imported:
pyplot = sys.modules['matplotlib.pyplot']
try:
pyplot.pause(0.01)
except:
pass
else:
if 'matplotlib.pyplot' in sys.modules:
self.pyplot_imported = True
self.set_inputhook(inputhook_mac)
self._current_gui = GUI_OSX
def disable_mac(self):
self.clear_inputhook()
def current_gui(self):
"""Return a string indicating the currently active GUI or None."""
return self._current_gui
inputhook_manager = InputHookManager()
enable_wx = inputhook_manager.enable_wx
disable_wx = inputhook_manager.disable_wx
enable_qt4 = inputhook_manager.enable_qt4
disable_qt4 = inputhook_manager.disable_qt4
enable_gtk = inputhook_manager.enable_gtk
disable_gtk = inputhook_manager.disable_gtk
enable_tk = inputhook_manager.enable_tk
disable_tk = inputhook_manager.disable_tk
enable_glut = inputhook_manager.enable_glut
disable_glut = inputhook_manager.disable_glut
enable_pyglet = inputhook_manager.enable_pyglet
disable_pyglet = inputhook_manager.disable_pyglet
enable_gtk3 = inputhook_manager.enable_gtk3
disable_gtk3 = inputhook_manager.disable_gtk3
enable_mac = inputhook_manager.enable_mac
disable_mac = inputhook_manager.disable_mac
clear_inputhook = inputhook_manager.clear_inputhook
set_inputhook = inputhook_manager.set_inputhook
current_gui = inputhook_manager.current_gui
clear_app_refs = inputhook_manager.clear_app_refs
# We maintain this as stdin_ready so that the individual inputhooks
# can diverge as little as possible from their IPython sources
stdin_ready = inputhook_manager.return_control
set_return_control_callback = inputhook_manager.set_return_control_callback
get_return_control_callback = inputhook_manager.get_return_control_callback
get_inputhook = inputhook_manager.get_inputhook
# Convenience function to switch amongst them
def enable_gui(gui=None, app=None):
"""Switch amongst GUI input hooks by name.
This is just a utility wrapper around the methods of the InputHookManager
object.
Parameters
----------
gui : optional, string or None
If None (or 'none'), clears input hook, otherwise it must be one
of the recognized GUI names (see ``GUI_*`` constants in module).
app : optional, existing application object.
For toolkits that have the concept of a global app, you can supply an
existing one. If not given, the toolkit will be probed for one, and if
none is found, a new one will be created. Note that GTK does not have
this concept, and passing an app if ``gui=="GTK"`` will raise an error.
Returns
-------
The output of the underlying gui switch routine, typically the actual
PyOS_InputHook wrapper object or the GUI toolkit app created, if there was
one.
"""
if get_return_control_callback() is None:
raise ValueError("A return_control_callback must be supplied as a reference before a gui can be enabled")
guis = {GUI_NONE: clear_inputhook,
GUI_OSX: enable_mac,
GUI_TK: enable_tk,
GUI_GTK: enable_gtk,
GUI_WX: enable_wx,
GUI_QT: enable_qt4, # qt3 not supported
GUI_QT4: enable_qt4,
GUI_GLUT: enable_glut,
GUI_PYGLET: enable_pyglet,
GUI_GTK3: enable_gtk3,
}
try:
gui_hook = guis[gui]
except KeyError:
if gui is None or gui == '':
gui_hook = clear_inputhook
else:
e = "Invalid GUI request %r, valid ones are:%s" % (gui, guis.keys())
raise ValueError(e)
return gui_hook(app)
__all__ = [
"GUI_WX",
"GUI_QT",
"GUI_QT4",
"GUI_GTK",
"GUI_TK",
"GUI_OSX",
"GUI_GLUT",
"GUI_PYGLET",
"GUI_GTK3",
"GUI_NONE",
"ignore_CTRL_C",
"allow_CTRL_C",
"InputHookManager",
"inputhook_manager",
"enable_wx",
"disable_wx",
"enable_qt4",
"disable_qt4",
"enable_gtk",
"disable_gtk",
"enable_tk",
"disable_tk",
"enable_glut",
"disable_glut",
"enable_pyglet",
"disable_pyglet",
"enable_gtk3",
"disable_gtk3",
"enable_mac",
"disable_mac",
"clear_inputhook",
"set_inputhook",
"current_gui",
"clear_app_refs",
"stdin_ready",
"set_return_control_callback",
"get_return_control_callback",
"get_inputhook",
"enable_gui"]
|
agpl-3.0
|
[
3,
2803,
26,
2774,
13,
24,
199,
624,
199,
607,
80,
762,
6992,
10041,
367,
17160,
1566,
4438,
13150,
14,
199,
624,
199,
199,
18045,
199,
3,
221,
1898,
334,
35,
9,
9079,
13,
8128,
221,
710,
16243,
15290,
11682,
199,
3,
199,
3,
221,
17484,
1334,
314,
2895,
402,
314,
6289,
844,
14,
221,
710,
2615,
4190,
365,
315,
199,
3,
221,
314,
570,
9685,
12,
1854,
465,
1777,
402,
642,
2032,
14,
199,
18045,
199,
199,
18045,
199,
3,
24339,
199,
18045,
199,
199,
646,
984,
199,
646,
3504,
199,
199,
18045,
199,
3,
22296,
199,
18045,
199,
199,
3,
22296,
367,
21119,
314,
17160,
4744,
75,
1405,
14,
199,
14438,
63,
16783,
275,
283,
6323,
7,
199,
14438,
63,
19229,
275,
283,
8440,
7,
199,
14438,
63,
19229,
20,
275,
283,
8440,
20,
7,
199,
14438,
63,
8391,
43,
275,
283,
12275,
7,
199,
14438,
63,
15263,
275,
283,
2663,
7,
199,
14438,
63,
25160,
275,
283,
28197,
7,
199,
14438,
63,
2226,
934,
275,
283,
3528,
337,
7,
199,
14438,
63,
4521,
2226,
775,
275,
283,
647,
18678,
7,
199,
14438,
63,
8391,
43,
19,
275,
283,
12275,
19,
7,
199,
14438,
63,
9185,
275,
283,
3592,
7,
221,
327,
284,
14,
69,
14,
3507,
199,
199,
18045,
199,
3,
738,
17933,
199,
18045,
199,
199,
318,
3686,
63,
22584,
63,
35,
837,
272,
408,
9495,
445,
1766,
44,
11,
35,
334,
1397,
6366,
10477,
272,
986,
199,
199,
318,
2040,
63,
22584,
63,
35,
837,
272,
408,
27200,
445,
1766,
44,
11,
35,
1901,
2933,
334,
1397,
6366,
10477,
272,
986,
199,
199,
18045,
199,
3,
11298,
6924,
8481,
2988,
1021,
199,
18045,
421,
199,
533,
6924,
8481,
2988,
8,
785,
304,
272,
408,
20588,
1611,
3100,
63,
3205,
8481,
367,
3365,
17160,
4744,
75,
1405,
14,
339,
961,
1021,
25801,
7750,
12604,
1334,
1124,
2713,
3100,
3205,
8481,
1040,
370,
2429,
272,
17160,
1566,
4438,
13150,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
1107,
63,
2785,
63,
3058,
275,
488,
267,
291,
423,
5181,
275,
1052,
267,
291,
423,
3958,
342,
267,
291,
14,
13563,
63,
17932,
275,
756,
339,
347,
485,
3958,
8,
277,
304,
267,
291,
423,
3058,
63,
647,
7036,
3667,
275,
488,
267,
291,
423,
3058,
275,
488,
267,
291,
423,
1818,
63,
5885,
275,
488,
339,
347,
663,
63,
1107,
63,
2785,
63,
3058,
8,
277,
12,
372,
63,
2785,
63,
3058,
304,
267,
291,
423,
1107,
63,
2785,
63,
3058,
275,
372,
63,
2785,
63,
3058,
339,
347,
664,
63,
1107,
63,
2785,
63,
3058,
8,
277,
304,
267,
372,
291,
423,
1107,
63,
2785,
63,
3058,
339,
347,
372,
63,
2785,
8,
277,
304,
267,
372,
291,
423,
1107,
63,
2785,
63,
3058,
342,
339,
347,
664,
63,
11416,
762,
6992,
8,
277,
304,
267,
372,
291,
423,
3058,
339,
347,
663,
63,
11416,
762,
6992,
8,
277,
12,
3233,
304,
267,
408,
1084,
10702,
762,
6992,
370,
3233,
1041,
267,
327,
2136,
2793,
1133,
334,
262,
314,
1067,
402,
1611,
12680,
8559,
9,
5965,
663,
1611,
3100,
63,
3205,
8481,
12,
1325,
7830,
267,
327,
1830,
10923,
367,
1324,
641,
15432,
781,
1255,
642,
1233,
267,
291,
423,
3058,
275,
3233,
339,
347,
5436,
63,
11416,
762,
6992,
8,
277,
12,
1145,
29,
403,
304,
267,
408,
9721,
1324,
5759,
14,
398,
3897,
267,
4143,
267,
1145,
520,
2716,
12,
5525,
881,
961,
2725,
365,
4370,
1454,
880,
626,
5436,
63,
11416,
762,
6992,
342,
883,
506,
881,
2797,
543,
282,
8545,
3217,
465,
1006,
314,
1124,
4296,
15192,
1040,
3102,
14,
221,
11017,
881,
314,
3503,
574,
402,
314,
2725,
365,
5525,
14,
221,
961,
14818,
3217,
881,
7704,
652,
14905,
370,
1172,
922,
13,
1896,
2397,
4501,
315,
314,
2446,
16243,
881,
1145,
2839,
520,
5247,
1705,
4296,
63,
5885,
17105,
267,
291,
423,
3958,
342,
339,
347,
5436,
63,
571,
63,
7655,
8,
277,
12,
11621,
29,
403,
304,
267,
408,
9721,
16243,
1159,
5007,
3659,
370,
376,
4223,
1256,
14,
398,
3979,
5907,
781,
1218,
376,
1145,
367,
282,
922,
641,
19227,
20,
503,
4818,
12,
781,
10266,
282,
267,
3659,
370,
314,
1145,
14,
221,
961,
365,
4346,
2952,
315,
2005,
5560,
4875,
7645,
267,
883,
5992,
340,
282,
922,
3181,
1133,
10266,
282,
3659,
17279,
14,
221,
961,
267,
1083,
365,
2741,
370,
5436,
314,
6941,
781,
787,
17573,
14,
398,
3897,
267,
4143,
267,
11621,
520,
488,
503,
620,
288,
982,
488,
12,
5436,
1006,
1145,
6941,
14,
221,
982,
661,
6323,
297,
283,
8440,
20,
358,
5436,
288,
314,
1145,
367,
626,
4744,
6065,
14,
221,
14504,
787,
440,
23608,
367,
8116,
503,
10157,
288,
465,
5204,
4744,
75,
1405,
2793,
1133,
1172,
314,
949,
296,
402,
376,
1145,
14,
267,
408,
267,
340,
11621,
365,
488,
26,
288,
291,
423,
5181,
275,
1052,
267,
916,
11621,
315,
291,
423,
5181,
26,
288,
2150,
291,
423,
5181,
59,
5885,
61,
339,
347,
4756,
63,
6323,
8,
277,
12,
1145,
29,
403,
304,
267,
408,
6476,
1566,
4438,
13150,
543,
4818,
4718,
14,
398,
3897,
267,
4143,
267,
1145,
520,
644,
56,
13515,
12,
2716,
14,
288,
26848,
4223,
370,
675,
14,
221,
982,
440,
1627,
12,
781,
22362,
644,
56,
367,
376,
288,
3411,
4223,
909,
12,
436,
1218,
282,
892,
1373,
340,
7179,
365,
1911,
14,
398,
8144,
267,
9063,
267,
961,
3102,
5951,
314,
1124,
2713,
3100,
63,
3205,
8481,
1040,
367,
4818,
4718,
12,
1314,
6127,
267,
314,
4818,
4718,
370,
21494,
543,
11167,
4079,
13103,
2839,
267,
16243,
14,
398,
982,
1124,
571,
1040,
365,
440,
1627,
781,
22362,
367,
376,
3411,
1373,
12,
436,
372,
652,
340,
267,
1911,
14,
221,
982,
949,
3411,
1145,
365,
1911,
12,
781,
1218,
376,
520,
533,
1705,
6323,
14,
2640,
64,
465,
267,
11924,
447,
953,
492,
4818,
288,
1145,
275,
4818,
14,
2640,
8,
4876,
29,
797,
12,
5436,
11575,
3241,
29,
797,
9,
267,
408,
267,
492,
4818,
267,
687,
7065,
14,
1023,
492,
18462,
465,
812,
267,
4818,
63,
1023,
275,
812,
8,
6323,
855,
1023,
28634,
1023,
398,
340,
4818
] |
[
2803,
26,
2774,
13,
24,
199,
624,
199,
607,
80,
762,
6992,
10041,
367,
17160,
1566,
4438,
13150,
14,
199,
624,
199,
199,
18045,
199,
3,
221,
1898,
334,
35,
9,
9079,
13,
8128,
221,
710,
16243,
15290,
11682,
199,
3,
199,
3,
221,
17484,
1334,
314,
2895,
402,
314,
6289,
844,
14,
221,
710,
2615,
4190,
365,
315,
199,
3,
221,
314,
570,
9685,
12,
1854,
465,
1777,
402,
642,
2032,
14,
199,
18045,
199,
199,
18045,
199,
3,
24339,
199,
18045,
199,
199,
646,
984,
199,
646,
3504,
199,
199,
18045,
199,
3,
22296,
199,
18045,
199,
199,
3,
22296,
367,
21119,
314,
17160,
4744,
75,
1405,
14,
199,
14438,
63,
16783,
275,
283,
6323,
7,
199,
14438,
63,
19229,
275,
283,
8440,
7,
199,
14438,
63,
19229,
20,
275,
283,
8440,
20,
7,
199,
14438,
63,
8391,
43,
275,
283,
12275,
7,
199,
14438,
63,
15263,
275,
283,
2663,
7,
199,
14438,
63,
25160,
275,
283,
28197,
7,
199,
14438,
63,
2226,
934,
275,
283,
3528,
337,
7,
199,
14438,
63,
4521,
2226,
775,
275,
283,
647,
18678,
7,
199,
14438,
63,
8391,
43,
19,
275,
283,
12275,
19,
7,
199,
14438,
63,
9185,
275,
283,
3592,
7,
221,
327,
284,
14,
69,
14,
3507,
199,
199,
18045,
199,
3,
738,
17933,
199,
18045,
199,
199,
318,
3686,
63,
22584,
63,
35,
837,
272,
408,
9495,
445,
1766,
44,
11,
35,
334,
1397,
6366,
10477,
272,
986,
199,
199,
318,
2040,
63,
22584,
63,
35,
837,
272,
408,
27200,
445,
1766,
44,
11,
35,
1901,
2933,
334,
1397,
6366,
10477,
272,
986,
199,
199,
18045,
199,
3,
11298,
6924,
8481,
2988,
1021,
199,
18045,
421,
199,
533,
6924,
8481,
2988,
8,
785,
304,
272,
408,
20588,
1611,
3100,
63,
3205,
8481,
367,
3365,
17160,
4744,
75,
1405,
14,
339,
961,
1021,
25801,
7750,
12604,
1334,
1124,
2713,
3100,
3205,
8481,
1040,
370,
2429,
272,
17160,
1566,
4438,
13150,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
1107,
63,
2785,
63,
3058,
275,
488,
267,
291,
423,
5181,
275,
1052,
267,
291,
423,
3958,
342,
267,
291,
14,
13563,
63,
17932,
275,
756,
339,
347,
485,
3958,
8,
277,
304,
267,
291,
423,
3058,
63,
647,
7036,
3667,
275,
488,
267,
291,
423,
3058,
275,
488,
267,
291,
423,
1818,
63,
5885,
275,
488,
339,
347,
663,
63,
1107,
63,
2785,
63,
3058,
8,
277,
12,
372,
63,
2785,
63,
3058,
304,
267,
291,
423,
1107,
63,
2785,
63,
3058,
275,
372,
63,
2785,
63,
3058,
339,
347,
664,
63,
1107,
63,
2785,
63,
3058,
8,
277,
304,
267,
372,
291,
423,
1107,
63,
2785,
63,
3058,
339,
347,
372,
63,
2785,
8,
277,
304,
267,
372,
291,
423,
1107,
63,
2785,
63,
3058,
342,
339,
347,
664,
63,
11416,
762,
6992,
8,
277,
304,
267,
372,
291,
423,
3058,
339,
347,
663,
63,
11416,
762,
6992,
8,
277,
12,
3233,
304,
267,
408,
1084,
10702,
762,
6992,
370,
3233,
1041,
267,
327,
2136,
2793,
1133,
334,
262,
314,
1067,
402,
1611,
12680,
8559,
9,
5965,
663,
1611,
3100,
63,
3205,
8481,
12,
1325,
7830,
267,
327,
1830,
10923,
367,
1324,
641,
15432,
781,
1255,
642,
1233,
267,
291,
423,
3058,
275,
3233,
339,
347,
5436,
63,
11416,
762,
6992,
8,
277,
12,
1145,
29,
403,
304,
267,
408,
9721,
1324,
5759,
14,
398,
3897,
267,
4143,
267,
1145,
520,
2716,
12,
5525,
881,
961,
2725,
365,
4370,
1454,
880,
626,
5436,
63,
11416,
762,
6992,
342,
883,
506,
881,
2797,
543,
282,
8545,
3217,
465,
1006,
314,
1124,
4296,
15192,
1040,
3102,
14,
221,
11017,
881,
314,
3503,
574,
402,
314,
2725,
365,
5525,
14,
221,
961,
14818,
3217,
881,
7704,
652,
14905,
370,
1172,
922,
13,
1896,
2397,
4501,
315,
314,
2446,
16243,
881,
1145,
2839,
520,
5247,
1705,
4296,
63,
5885,
17105,
267,
291,
423,
3958,
342,
339,
347,
5436,
63,
571,
63,
7655,
8,
277,
12,
11621,
29,
403,
304,
267,
408,
9721,
16243,
1159,
5007,
3659,
370,
376,
4223,
1256,
14,
398,
3979,
5907,
781,
1218,
376,
1145,
367,
282,
922,
641,
19227,
20,
503,
4818,
12,
781,
10266,
282,
267,
3659,
370,
314,
1145,
14,
221,
961,
365,
4346,
2952,
315,
2005,
5560,
4875,
7645,
267,
883,
5992,
340,
282,
922,
3181,
1133,
10266,
282,
3659,
17279,
14,
221,
961,
267,
1083,
365,
2741,
370,
5436,
314,
6941,
781,
787,
17573,
14,
398,
3897,
267,
4143,
267,
11621,
520,
488,
503,
620,
288,
982,
488,
12,
5436,
1006,
1145,
6941,
14,
221,
982,
661,
6323,
297,
283,
8440,
20,
358,
5436,
288,
314,
1145,
367,
626,
4744,
6065,
14,
221,
14504,
787,
440,
23608,
367,
8116,
503,
10157,
288,
465,
5204,
4744,
75,
1405,
2793,
1133,
1172,
314,
949,
296,
402,
376,
1145,
14,
267,
408,
267,
340,
11621,
365,
488,
26,
288,
291,
423,
5181,
275,
1052,
267,
916,
11621,
315,
291,
423,
5181,
26,
288,
2150,
291,
423,
5181,
59,
5885,
61,
339,
347,
4756,
63,
6323,
8,
277,
12,
1145,
29,
403,
304,
267,
408,
6476,
1566,
4438,
13150,
543,
4818,
4718,
14,
398,
3897,
267,
4143,
267,
1145,
520,
644,
56,
13515,
12,
2716,
14,
288,
26848,
4223,
370,
675,
14,
221,
982,
440,
1627,
12,
781,
22362,
644,
56,
367,
376,
288,
3411,
4223,
909,
12,
436,
1218,
282,
892,
1373,
340,
7179,
365,
1911,
14,
398,
8144,
267,
9063,
267,
961,
3102,
5951,
314,
1124,
2713,
3100,
63,
3205,
8481,
1040,
367,
4818,
4718,
12,
1314,
6127,
267,
314,
4818,
4718,
370,
21494,
543,
11167,
4079,
13103,
2839,
267,
16243,
14,
398,
982,
1124,
571,
1040,
365,
440,
1627,
781,
22362,
367,
376,
3411,
1373,
12,
436,
372,
652,
340,
267,
1911,
14,
221,
982,
949,
3411,
1145,
365,
1911,
12,
781,
1218,
376,
520,
533,
1705,
6323,
14,
2640,
64,
465,
267,
11924,
447,
953,
492,
4818,
288,
1145,
275,
4818,
14,
2640,
8,
4876,
29,
797,
12,
5436,
11575,
3241,
29,
797,
9,
267,
408,
267,
492,
4818,
267,
687,
7065,
14,
1023,
492,
18462,
465,
812,
267,
4818,
63,
1023,
275,
812,
8,
6323,
855,
1023,
28634,
1023,
398,
340,
4818,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
__license__ = 'Public Domain'
import codecs
import io
import os
import random
import sys
from .options import (
parseOpts,
)
from .compat import (
compat_expanduser,
compat_getpass,
compat_print,
compat_shlex_split,
workaround_optparse_bug9161,
)
from .utils import (
DateRange,
decodeOption,
DEFAULT_OUTTMPL,
DownloadError,
match_filter_func,
MaxDownloadsReached,
preferredencoding,
read_batch_urls,
SameFileError,
setproctitle,
std_headers,
write_string,
)
from .update import update_self
from .downloader import (
FileDownloader,
)
from .extractor import gen_extractors, list_extractors
from .YoutubeDL import YoutubeDL
def _real_main(argv=None):
# Compatibility fixes for Windows
if sys.platform == 'win32':
# https://github.com/rg3/youtube-dl/issues/820
codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None)
workaround_optparse_bug9161()
setproctitle('youtube-dl')
parser, opts, args = parseOpts(argv)
# Set user agent
if opts.user_agent is not None:
std_headers['User-Agent'] = opts.user_agent
# Set referer
if opts.referer is not None:
std_headers['Referer'] = opts.referer
# Custom HTTP headers
if opts.headers is not None:
for h in opts.headers:
if h.find(':', 1) < 0:
parser.error('wrong header formatting, it should be key:value, not "%s"' % h)
key, value = h.split(':', 2)
if opts.verbose:
write_string('[debug] Adding header from command line option %s:%s\n' % (key, value))
std_headers[key] = value
# Dump user agent
if opts.dump_user_agent:
compat_print(std_headers['User-Agent'])
sys.exit(0)
# Batch file verification
batch_urls = []
if opts.batchfile is not None:
try:
if opts.batchfile == '-':
batchfd = sys.stdin
else:
batchfd = io.open(opts.batchfile, 'r', encoding='utf-8', errors='ignore')
batch_urls = read_batch_urls(batchfd)
if opts.verbose:
write_string('[debug] Batch file urls: ' + repr(batch_urls) + '\n')
except IOError:
sys.exit('ERROR: batch file could not be read')
all_urls = batch_urls + args
all_urls = [url.strip() for url in all_urls]
_enc = preferredencoding()
all_urls = [url.decode(_enc, 'ignore') if isinstance(url, bytes) else url for url in all_urls]
if opts.list_extractors:
for ie in list_extractors(opts.age_limit):
compat_print(ie.IE_NAME + (' (CURRENTLY BROKEN)' if not ie._WORKING else ''))
matchedUrls = [url for url in all_urls if ie.suitable(url)]
for mu in matchedUrls:
compat_print(' ' + mu)
sys.exit(0)
if opts.list_extractor_descriptions:
for ie in list_extractors(opts.age_limit):
if not ie._WORKING:
continue
desc = getattr(ie, 'IE_DESC', ie.IE_NAME)
if desc is False:
continue
if hasattr(ie, 'SEARCH_KEY'):
_SEARCHES = ('cute kittens', 'slithering pythons', 'falling cat', 'angry poodle', 'purple fish', 'running tortoise', 'sleeping bunny', 'burping cow')
_COUNTS = ('', '5', '10', 'all')
desc += ' (Example: "%s%s:%s" )' % (ie.SEARCH_KEY, random.choice(_COUNTS), random.choice(_SEARCHES))
compat_print(desc)
sys.exit(0)
# Conflicting, missing and erroneous options
if opts.usenetrc and (opts.username is not None or opts.password is not None):
parser.error('using .netrc conflicts with giving username/password')
if opts.password is not None and opts.username is None:
parser.error('account username missing\n')
if opts.outtmpl is not None and (opts.usetitle or opts.autonumber or opts.useid):
parser.error('using output template conflicts with using title, video ID or auto number')
if opts.usetitle and opts.useid:
parser.error('using title conflicts with using video ID')
if opts.username is not None and opts.password is None:
opts.password = compat_getpass('Type account password and press [Return]: ')
if opts.ratelimit is not None:
numeric_limit = FileDownloader.parse_bytes(opts.ratelimit)
if numeric_limit is None:
parser.error('invalid rate limit specified')
opts.ratelimit = numeric_limit
if opts.min_filesize is not None:
numeric_limit = FileDownloader.parse_bytes(opts.min_filesize)
if numeric_limit is None:
parser.error('invalid min_filesize specified')
opts.min_filesize = numeric_limit
if opts.max_filesize is not None:
numeric_limit = FileDownloader.parse_bytes(opts.max_filesize)
if numeric_limit is None:
parser.error('invalid max_filesize specified')
opts.max_filesize = numeric_limit
if opts.retries is not None:
if opts.retries in ('inf', 'infinite'):
opts_retries = float('inf')
else:
try:
opts_retries = int(opts.retries)
except (TypeError, ValueError):
parser.error('invalid retry count specified')
if opts.buffersize is not None:
numeric_buffersize = FileDownloader.parse_bytes(opts.buffersize)
if numeric_buffersize is None:
parser.error('invalid buffer size specified')
opts.buffersize = numeric_buffersize
if opts.playliststart <= 0:
raise ValueError('Playlist start must be positive')
if opts.playlistend not in (-1, None) and opts.playlistend < opts.playliststart:
raise ValueError('Playlist end must be greater than playlist start')
if opts.extractaudio:
if opts.audioformat not in ['best', 'aac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav']:
parser.error('invalid audio format specified')
if opts.audioquality:
opts.audioquality = opts.audioquality.strip('k').strip('K')
if not opts.audioquality.isdigit():
parser.error('invalid audio quality specified')
if opts.recodevideo is not None:
if opts.recodevideo not in ['mp4', 'flv', 'webm', 'ogg', 'mkv', 'avi']:
parser.error('invalid video recode format specified')
if opts.convertsubtitles is not None:
if opts.convertsubtitles not in ['srt', 'vtt', 'ass']:
parser.error('invalid subtitle format specified')
if opts.date is not None:
date = DateRange.day(opts.date)
else:
date = DateRange(opts.dateafter, opts.datebefore)
# Do not download videos when there are audio-only formats
if opts.extractaudio and not opts.keepvideo and opts.format is None:
opts.format = 'bestaudio/best'
# --all-sub automatically sets --write-sub if --write-auto-sub is not given
# this was the old behaviour if only --all-sub was given.
if opts.allsubtitles and not opts.writeautomaticsub:
opts.writesubtitles = True
outtmpl = ((opts.outtmpl is not None and opts.outtmpl) or
(opts.format == '-1' and opts.usetitle and '%(title)s-%(id)s-%(format)s.%(ext)s') or
(opts.format == '-1' and '%(id)s-%(format)s.%(ext)s') or
(opts.usetitle and opts.autonumber and '%(autonumber)s-%(title)s-%(id)s.%(ext)s') or
(opts.usetitle and '%(title)s-%(id)s.%(ext)s') or
(opts.useid and '%(id)s.%(ext)s') or
(opts.autonumber and '%(autonumber)s-%(id)s.%(ext)s') or
DEFAULT_OUTTMPL)
if not os.path.splitext(outtmpl)[1] and opts.extractaudio:
parser.error('Cannot download a video and extract audio into the same'
' file! Use "{0}.%(ext)s" instead of "{0}" as the output'
' template'.format(outtmpl))
any_getting = opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat or opts.getduration or opts.dumpjson or opts.dump_single_json
any_printing = opts.print_json
download_archive_fn = compat_expanduser(opts.download_archive) if opts.download_archive is not None else opts.download_archive
# PostProcessors
postprocessors = []
# Add the metadata pp first, the other pps will copy it
if opts.metafromtitle:
postprocessors.append({
'key': 'MetadataFromTitle',
'titleformat': opts.metafromtitle
})
if opts.addmetadata:
postprocessors.append({'key': 'FFmpegMetadata'})
if opts.extractaudio:
postprocessors.append({
'key': 'FFmpegExtractAudio',
'preferredcodec': opts.audioformat,
'preferredquality': opts.audioquality,
'nopostoverwrites': opts.nopostoverwrites,
})
if opts.recodevideo:
postprocessors.append({
'key': 'FFmpegVideoConvertor',
'preferedformat': opts.recodevideo,
})
if opts.convertsubtitles:
postprocessors.append({
'key': 'FFmpegSubtitlesConvertor',
'format': opts.convertsubtitles,
})
if opts.embedsubtitles:
postprocessors.append({
'key': 'FFmpegEmbedSubtitle',
})
if opts.xattrs:
postprocessors.append({'key': 'XAttrMetadata'})
if opts.embedthumbnail:
already_have_thumbnail = opts.writethumbnail or opts.write_all_thumbnails
postprocessors.append({
'key': 'EmbedThumbnail',
'already_have_thumbnail': already_have_thumbnail
})
if not already_have_thumbnail:
opts.writethumbnail = True
# Please keep ExecAfterDownload towards the bottom as it allows the user to modify the final file in any way.
# So if the user is able to remove the file before your postprocessor runs it might cause a few problems.
if opts.exec_cmd:
postprocessors.append({
'key': 'ExecAfterDownload',
'exec_cmd': opts.exec_cmd,
})
if opts.xattr_set_filesize:
try:
import xattr
xattr # Confuse flake8
except ImportError:
parser.error('setting filesize xattr requested but python-xattr is not available')
external_downloader_args = None
if opts.external_downloader_args:
external_downloader_args = compat_shlex_split(opts.external_downloader_args)
postprocessor_args = None
if opts.postprocessor_args:
postprocessor_args = compat_shlex_split(opts.postprocessor_args)
match_filter = (
None if opts.match_filter is None
else match_filter_func(opts.match_filter))
ydl_opts = {
'usenetrc': opts.usenetrc,
'username': opts.username,
'password': opts.password,
'twofactor': opts.twofactor,
'videopassword': opts.videopassword,
'quiet': (opts.quiet or any_getting or any_printing),
'no_warnings': opts.no_warnings,
'forceurl': opts.geturl,
'forcetitle': opts.gettitle,
'forceid': opts.getid,
'forcethumbnail': opts.getthumbnail,
'forcedescription': opts.getdescription,
'forceduration': opts.getduration,
'forcefilename': opts.getfilename,
'forceformat': opts.getformat,
'forcejson': opts.dumpjson or opts.print_json,
'dump_single_json': opts.dump_single_json,
'simulate': opts.simulate or any_getting,
'skip_download': opts.skip_download,
'format': opts.format,
'listformats': opts.listformats,
'outtmpl': outtmpl,
'autonumber_size': opts.autonumber_size,
'restrictfilenames': opts.restrictfilenames,
'ignoreerrors': opts.ignoreerrors,
'force_generic_extractor': opts.force_generic_extractor,
'ratelimit': opts.ratelimit,
'nooverwrites': opts.nooverwrites,
'retries': opts_retries,
'buffersize': opts.buffersize,
'noresizebuffer': opts.noresizebuffer,
'continuedl': opts.continue_dl,
'noprogress': opts.noprogress,
'progress_with_newline': opts.progress_with_newline,
'playliststart': opts.playliststart,
'playlistend': opts.playlistend,
'playlistreverse': opts.playlist_reverse,
'noplaylist': opts.noplaylist,
'logtostderr': opts.outtmpl == '-',
'consoletitle': opts.consoletitle,
'nopart': opts.nopart,
'updatetime': opts.updatetime,
'writedescription': opts.writedescription,
'writeannotations': opts.writeannotations,
'writeinfojson': opts.writeinfojson,
'writethumbnail': opts.writethumbnail,
'write_all_thumbnails': opts.write_all_thumbnails,
'writesubtitles': opts.writesubtitles,
'writeautomaticsub': opts.writeautomaticsub,
'allsubtitles': opts.allsubtitles,
'listsubtitles': opts.listsubtitles,
'subtitlesformat': opts.subtitlesformat,
'subtitleslangs': opts.subtitleslangs,
'matchtitle': decodeOption(opts.matchtitle),
'rejecttitle': decodeOption(opts.rejecttitle),
'max_downloads': opts.max_downloads,
'prefer_free_formats': opts.prefer_free_formats,
'verbose': opts.verbose,
'dump_intermediate_pages': opts.dump_intermediate_pages,
'write_pages': opts.write_pages,
'test': opts.test,
'keepvideo': opts.keepvideo,
'min_filesize': opts.min_filesize,
'max_filesize': opts.max_filesize,
'min_views': opts.min_views,
'max_views': opts.max_views,
'daterange': date,
'cachedir': opts.cachedir,
'youtube_print_sig_code': opts.youtube_print_sig_code,
'age_limit': opts.age_limit,
'download_archive': download_archive_fn,
'cookiefile': opts.cookiefile,
'nocheckcertificate': opts.no_check_certificate,
'prefer_insecure': opts.prefer_insecure,
'proxy': opts.proxy,
'socket_timeout': opts.socket_timeout,
'bidi_workaround': opts.bidi_workaround,
'debug_printtraffic': opts.debug_printtraffic,
'prefer_ffmpeg': opts.prefer_ffmpeg,
'include_ads': opts.include_ads,
'default_search': opts.default_search,
'youtube_include_dash_manifest': opts.youtube_include_dash_manifest,
'encoding': opts.encoding,
'extract_flat': opts.extract_flat,
'merge_output_format': opts.merge_output_format,
'postprocessors': postprocessors,
'fixup': opts.fixup,
'source_address': opts.source_address,
'call_home': opts.call_home,
'sleep_interval': opts.sleep_interval,
'external_downloader': opts.external_downloader,
'list_thumbnails': opts.list_thumbnails,
'playlist_items': opts.playlist_items,
'xattr_set_filesize': opts.xattr_set_filesize,
'match_filter': match_filter,
'no_color': opts.no_color,
'ffmpeg_location': opts.ffmpeg_location,
'hls_prefer_native': opts.hls_prefer_native,
'external_downloader_args': external_downloader_args,
'postprocessor_args': postprocessor_args,
'cn_verification_proxy': opts.cn_verification_proxy,
}
with YoutubeDL(ydl_opts) as ydl:
# Update version
if opts.update_self:
update_self(ydl.to_screen, opts.verbose)
# Remove cache dir
if opts.rm_cachedir:
ydl.cache.remove()
# Maybe do nothing
if (len(all_urls) < 1) and (opts.load_info_filename is None):
if opts.update_self or opts.rm_cachedir:
sys.exit()
ydl.warn_if_short_id(sys.argv[1:] if argv is None else argv)
parser.error(
'You must provide at least one URL.\n'
'Type youtube-dl --help to see a list of all options.')
try:
if opts.load_info_filename is not None:
retcode = ydl.download_with_info_file(opts.load_info_filename)
else:
retcode = ydl.download(all_urls)
except MaxDownloadsReached:
ydl.to_screen('--max-download limit reached, aborting.')
retcode = 101
sys.exit(retcode)
def main(argv=None):
try:
_real_main(argv)
except DownloadError:
sys.exit(1)
except SameFileError:
sys.exit('ERROR: fixed output name but more than one file to download')
except KeyboardInterrupt:
sys.exit('\nERROR: Interrupted by user')
__all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors']
|
unlicense
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
363,
1682,
363,
275,
283,
9885,
14061,
7,
199,
199,
646,
6010,
199,
646,
5890,
199,
646,
747,
199,
646,
2196,
199,
646,
984,
421,
199,
504,
1275,
1419,
492,
334,
272,
2198,
24429,
12,
199,
9,
199,
504,
1275,
5819,
492,
334,
272,
8434,
63,
12131,
12,
272,
8434,
63,
27481,
12,
272,
8434,
63,
1361,
12,
272,
8434,
63,
32507,
63,
1294,
12,
272,
18092,
63,
2992,
1122,
63,
1266,
25,
12285,
12,
199,
9,
199,
504,
1275,
1208,
492,
334,
272,
6148,
4709,
12,
272,
4849,
2602,
12,
272,
6186,
63,
1877,
23719,
12,
272,
17955,
547,
12,
272,
1336,
63,
1541,
63,
1532,
12,
272,
8228,
3514,
3640,
497,
4583,
12,
272,
16602,
264,
848,
1523,
12,
272,
1586,
63,
2912,
63,
3603,
12,
272,
14766,
25212,
12,
272,
663,
4687,
1213,
12,
272,
2418,
63,
2139,
12,
272,
2218,
63,
875,
12,
199,
9,
199,
504,
1275,
873,
492,
1678,
63,
277,
199,
504,
1275,
22846,
492,
334,
272,
3814,
3514,
3422,
12,
199,
9,
199,
504,
1275,
22677,
492,
3805,
63,
2911,
13451,
12,
769,
63,
2911,
13451,
199,
504,
1275,
57,
7715,
8045,
492,
1488,
7715,
8045,
421,
199,
318,
485,
3093,
63,
973,
8,
3020,
29,
403,
304,
272,
327,
3599,
5880,
25079,
367,
5417,
272,
340,
984,
14,
3246,
508,
283,
2676,
708,
356,
267,
327,
4178,
921,
5031,
14,
957,
15,
12430,
19,
15,
9788,
13,
5030,
15,
10115,
15,
24,
1165,
267,
6010,
14,
2683,
8,
2734,
536,
26,
6010,
14,
3892,
360,
1624,
13,
24,
358,
340,
536,
508,
283,
1850,
2182,
4587,
7,
587,
488,
9,
339,
18092,
63,
2992,
1122,
63,
1266,
25,
12285,
342,
339,
663,
4687,
1213,
360,
9788,
13,
5030,
358,
339,
1798,
12,
3999,
12,
1249,
275,
2198,
24429,
8,
3020,
9,
339,
327,
2494,
922,
6631,
272,
340,
3999,
14,
751,
63,
4054,
365,
440,
488,
26,
267,
2418,
63,
2139,
459,
1899,
13,
7788,
418,
275,
3999,
14,
751,
63,
4054,
339,
327,
2494,
25104,
272,
340,
3999,
14,
20996,
365,
440,
488,
26,
267,
2418,
63,
2139,
459,
28900,
418,
275,
3999,
14,
20996,
339,
327,
8388,
3101,
2323,
272,
340,
3999,
14,
2139,
365,
440,
488,
26,
267,
367,
394,
315,
3999,
14,
2139,
26,
288,
340,
394,
14,
1623,
16451,
413,
9,
665,
378,
26,
355,
1798,
14,
705,
360,
10603,
1406,
10803,
12,
652,
1077,
506,
790,
26,
585,
12,
440,
2071,
83,
4507,
450,
394,
9,
288,
790,
12,
574,
275,
394,
14,
1294,
16451,
499,
9,
288,
340,
3999,
14,
3832,
26,
355,
2218,
63,
875,
11894,
1757,
61,
12934,
1406,
687,
1414,
1004,
945,
450,
83,
2689,
83,
60,
78,
7,
450,
334,
498,
12,
574,
430,
288,
2418,
63,
2139,
59,
498,
61,
275,
574,
339,
327,
19460,
922,
6631,
272,
340,
3999,
14,
2724,
63,
751,
63,
4054,
26,
267,
8434,
63,
1361,
8,
1516,
63,
2139,
459,
1899,
13,
7788,
1105,
267,
984,
14,
2224,
8,
16,
9,
339,
327,
17206,
570,
14786,
272,
3522,
63,
3603,
275,
942,
272,
340,
3999,
14,
2912,
493,
365,
440,
488,
26,
267,
862,
26,
288,
340,
3999,
14,
2912,
493,
508,
20905,
355,
3522,
2592,
275,
984,
14,
6626,
288,
587,
26,
355,
3522,
2592,
275,
5890,
14,
1490,
8,
3291,
14,
2912,
493,
12,
283,
82,
297,
2644,
534,
1624,
13,
24,
297,
2552,
534,
4247,
358,
288,
3522,
63,
3603,
275,
1586,
63,
2912,
63,
3603,
8,
2912,
2592,
9,
288,
340,
3999,
14,
3832,
26,
355,
2218,
63,
875,
11894,
1757,
61,
17206,
570,
8187,
26,
283,
435,
4700,
8,
2912,
63,
3603,
9,
435,
1557,
78,
358,
267,
871,
5925,
26,
288,
984,
14,
2224,
360,
3170,
26,
3522,
570,
4293,
440,
506,
1586,
358,
272,
1006,
63,
3603,
275,
3522,
63,
3603,
435,
1249,
272,
1006,
63,
3603,
275,
359,
633,
14,
1913,
342,
367,
1166,
315,
1006,
63,
3603,
61,
272,
485,
10945,
275,
16602,
264,
848,
1523,
342,
272,
1006,
63,
3603,
275,
359,
633,
14,
2708,
1547,
10945,
12,
283,
4247,
358,
340,
1228,
8,
633,
12,
2783,
9,
587,
1166,
367,
1166,
315,
1006,
63,
3603,
61,
339,
340,
3999,
14,
513,
63,
2911,
13451,
26,
267,
367,
13446,
315,
769,
63,
2911,
13451,
8,
3291,
14,
474,
63,
3097,
304,
288,
8434,
63,
1361,
8,
1873,
14,
4332,
63,
2339,
435,
661,
334,
14211,
6084,
699,
1092,
6945,
3171,
340,
440,
13446,
423,
8406,
1206,
587,
12381,
288,
7838,
21867,
478,
275,
359,
633,
367,
1166,
315,
1006,
63,
3603,
340,
13446,
14,
83,
10020,
8,
633,
1874,
288,
367,
8504,
315,
7838,
21867,
478,
26,
355,
8434,
63,
1361,
360,
221,
283,
435,
8504,
9,
267,
984,
14,
2224,
8,
16,
9,
272,
340,
3999,
14,
513,
63,
22677,
63,
21713,
26,
267,
367,
13446,
315,
769,
63,
2911,
13451,
8,
3291,
14,
474,
63,
3097,
304,
288,
340,
440,
13446,
423,
8406,
1206,
26,
355,
1980,
288,
4328,
275,
2519,
8,
1873,
12,
283,
4332,
63,
15119,
297,
13446,
14,
4332,
63,
2339,
9,
288,
340,
4328,
365,
756,
26,
355,
1980,
288,
340,
2688,
8,
1873,
12,
283,
15962,
63,
3078,
735,
355,
485,
15962,
654,
275,
661,
67,
938,
1022,
390,
32461,
297,
283,
23766,
728,
316,
2366,
83,
297,
283,
70,
26039,
6230,
297,
283,
621,
651,
1115,
364,
274,
297,
283,
6653,
11045,
289,
2453,
297,
283,
5720,
307,
361,
79,
572,
297,
283,
4532,
316,
330,
324,
9745,
297,
283,
30735,
4073,
512,
87,
358,
355,
485,
8760,
51,
275,
13134,
283,
21,
297,
283,
709,
297,
283,
452,
358,
355,
4328,
847,
283,
334,
9846,
26,
2071,
83,
5,
83,
2689,
83,
2,
776,
7,
450,
334,
1873,
14,
15962,
63,
3078,
12,
2196,
14,
5095,
1547,
8760,
51,
395,
2196,
14,
5095,
1547,
15962,
654,
430,
288,
8434,
63,
1361,
8,
3257,
9,
267,
984,
14,
2224,
8,
16,
9,
339,
327,
32539,
6960,
316,
12,
4124,
436,
2329
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
363,
1682,
363,
275,
283,
9885,
14061,
7,
199,
199,
646,
6010,
199,
646,
5890,
199,
646,
747,
199,
646,
2196,
199,
646,
984,
421,
199,
504,
1275,
1419,
492,
334,
272,
2198,
24429,
12,
199,
9,
199,
504,
1275,
5819,
492,
334,
272,
8434,
63,
12131,
12,
272,
8434,
63,
27481,
12,
272,
8434,
63,
1361,
12,
272,
8434,
63,
32507,
63,
1294,
12,
272,
18092,
63,
2992,
1122,
63,
1266,
25,
12285,
12,
199,
9,
199,
504,
1275,
1208,
492,
334,
272,
6148,
4709,
12,
272,
4849,
2602,
12,
272,
6186,
63,
1877,
23719,
12,
272,
17955,
547,
12,
272,
1336,
63,
1541,
63,
1532,
12,
272,
8228,
3514,
3640,
497,
4583,
12,
272,
16602,
264,
848,
1523,
12,
272,
1586,
63,
2912,
63,
3603,
12,
272,
14766,
25212,
12,
272,
663,
4687,
1213,
12,
272,
2418,
63,
2139,
12,
272,
2218,
63,
875,
12,
199,
9,
199,
504,
1275,
873,
492,
1678,
63,
277,
199,
504,
1275,
22846,
492,
334,
272,
3814,
3514,
3422,
12,
199,
9,
199,
504,
1275,
22677,
492,
3805,
63,
2911,
13451,
12,
769,
63,
2911,
13451,
199,
504,
1275,
57,
7715,
8045,
492,
1488,
7715,
8045,
421,
199,
318,
485,
3093,
63,
973,
8,
3020,
29,
403,
304,
272,
327,
3599,
5880,
25079,
367,
5417,
272,
340,
984,
14,
3246,
508,
283,
2676,
708,
356,
267,
327,
4178,
921,
5031,
14,
957,
15,
12430,
19,
15,
9788,
13,
5030,
15,
10115,
15,
24,
1165,
267,
6010,
14,
2683,
8,
2734,
536,
26,
6010,
14,
3892,
360,
1624,
13,
24,
358,
340,
536,
508,
283,
1850,
2182,
4587,
7,
587,
488,
9,
339,
18092,
63,
2992,
1122,
63,
1266,
25,
12285,
342,
339,
663,
4687,
1213,
360,
9788,
13,
5030,
358,
339,
1798,
12,
3999,
12,
1249,
275,
2198,
24429,
8,
3020,
9,
339,
327,
2494,
922,
6631,
272,
340,
3999,
14,
751,
63,
4054,
365,
440,
488,
26,
267,
2418,
63,
2139,
459,
1899,
13,
7788,
418,
275,
3999,
14,
751,
63,
4054,
339,
327,
2494,
25104,
272,
340,
3999,
14,
20996,
365,
440,
488,
26,
267,
2418,
63,
2139,
459,
28900,
418,
275,
3999,
14,
20996,
339,
327,
8388,
3101,
2323,
272,
340,
3999,
14,
2139,
365,
440,
488,
26,
267,
367,
394,
315,
3999,
14,
2139,
26,
288,
340,
394,
14,
1623,
16451,
413,
9,
665,
378,
26,
355,
1798,
14,
705,
360,
10603,
1406,
10803,
12,
652,
1077,
506,
790,
26,
585,
12,
440,
2071,
83,
4507,
450,
394,
9,
288,
790,
12,
574,
275,
394,
14,
1294,
16451,
499,
9,
288,
340,
3999,
14,
3832,
26,
355,
2218,
63,
875,
11894,
1757,
61,
12934,
1406,
687,
1414,
1004,
945,
450,
83,
2689,
83,
60,
78,
7,
450,
334,
498,
12,
574,
430,
288,
2418,
63,
2139,
59,
498,
61,
275,
574,
339,
327,
19460,
922,
6631,
272,
340,
3999,
14,
2724,
63,
751,
63,
4054,
26,
267,
8434,
63,
1361,
8,
1516,
63,
2139,
459,
1899,
13,
7788,
1105,
267,
984,
14,
2224,
8,
16,
9,
339,
327,
17206,
570,
14786,
272,
3522,
63,
3603,
275,
942,
272,
340,
3999,
14,
2912,
493,
365,
440,
488,
26,
267,
862,
26,
288,
340,
3999,
14,
2912,
493,
508,
20905,
355,
3522,
2592,
275,
984,
14,
6626,
288,
587,
26,
355,
3522,
2592,
275,
5890,
14,
1490,
8,
3291,
14,
2912,
493,
12,
283,
82,
297,
2644,
534,
1624,
13,
24,
297,
2552,
534,
4247,
358,
288,
3522,
63,
3603,
275,
1586,
63,
2912,
63,
3603,
8,
2912,
2592,
9,
288,
340,
3999,
14,
3832,
26,
355,
2218,
63,
875,
11894,
1757,
61,
17206,
570,
8187,
26,
283,
435,
4700,
8,
2912,
63,
3603,
9,
435,
1557,
78,
358,
267,
871,
5925,
26,
288,
984,
14,
2224,
360,
3170,
26,
3522,
570,
4293,
440,
506,
1586,
358,
272,
1006,
63,
3603,
275,
3522,
63,
3603,
435,
1249,
272,
1006,
63,
3603,
275,
359,
633,
14,
1913,
342,
367,
1166,
315,
1006,
63,
3603,
61,
272,
485,
10945,
275,
16602,
264,
848,
1523,
342,
272,
1006,
63,
3603,
275,
359,
633,
14,
2708,
1547,
10945,
12,
283,
4247,
358,
340,
1228,
8,
633,
12,
2783,
9,
587,
1166,
367,
1166,
315,
1006,
63,
3603,
61,
339,
340,
3999,
14,
513,
63,
2911,
13451,
26,
267,
367,
13446,
315,
769,
63,
2911,
13451,
8,
3291,
14,
474,
63,
3097,
304,
288,
8434,
63,
1361,
8,
1873,
14,
4332,
63,
2339,
435,
661,
334,
14211,
6084,
699,
1092,
6945,
3171,
340,
440,
13446,
423,
8406,
1206,
587,
12381,
288,
7838,
21867,
478,
275,
359,
633,
367,
1166,
315,
1006,
63,
3603,
340,
13446,
14,
83,
10020,
8,
633,
1874,
288,
367,
8504,
315,
7838,
21867,
478,
26,
355,
8434,
63,
1361,
360,
221,
283,
435,
8504,
9,
267,
984,
14,
2224,
8,
16,
9,
272,
340,
3999,
14,
513,
63,
22677,
63,
21713,
26,
267,
367,
13446,
315,
769,
63,
2911,
13451,
8,
3291,
14,
474,
63,
3097,
304,
288,
340,
440,
13446,
423,
8406,
1206,
26,
355,
1980,
288,
4328,
275,
2519,
8,
1873,
12,
283,
4332,
63,
15119,
297,
13446,
14,
4332,
63,
2339,
9,
288,
340,
4328,
365,
756,
26,
355,
1980,
288,
340,
2688,
8,
1873,
12,
283,
15962,
63,
3078,
735,
355,
485,
15962,
654,
275,
661,
67,
938,
1022,
390,
32461,
297,
283,
23766,
728,
316,
2366,
83,
297,
283,
70,
26039,
6230,
297,
283,
621,
651,
1115,
364,
274,
297,
283,
6653,
11045,
289,
2453,
297,
283,
5720,
307,
361,
79,
572,
297,
283,
4532,
316,
330,
324,
9745,
297,
283,
30735,
4073,
512,
87,
358,
355,
485,
8760,
51,
275,
13134,
283,
21,
297,
283,
709,
297,
283,
452,
358,
355,
4328,
847,
283,
334,
9846,
26,
2071,
83,
5,
83,
2689,
83,
2,
776,
7,
450,
334,
1873,
14,
15962,
63,
3078,
12,
2196,
14,
5095,
1547,
8760,
51,
395,
2196,
14,
5095,
1547,
15962,
654,
430,
288,
8434,
63,
1361,
8,
3257,
9,
267,
984,
14,
2224,
8,
16,
9,
339,
327,
32539,
6960,
316,
12,
4124,
436,
2329,
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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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,
1,
1,
1
] |
AlanZatarain/cortex-vfx
|
test/IECore/TypeIdTest.py
|
12
|
2531
|
##########################################################################
#
# Copyright (c) 2008, Image Engine Design 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 Image Engine Design nor the names of any
# other contributors to this software 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.
#
##########################################################################
import unittest
import IECore
class TypeIdTest( unittest.TestCase ) :
def testNoDuplicates( self ) :
#boost.python.enum doesn't allow us to ensure that no duplicate values are in it. Here we do a simple verification to ensure
#that the value of each attribute IECore.TypeId.XXXXX is present in the "values" array. If it's not, the likely cause
#is a duplicate.
ids = {}
num = 0
for i in dir( IECore.TypeId ) :
v = getattr( IECore.TypeId, i )
if type( v ) is IECore.TypeId :
if v in ids :
raise RuntimeError ("TypeId for %s is a duplicate of %s" % ( i, ids[v] ) )
ids[v] = i
num = num + 1
self.assertEqual( num, len( IECore.TypeId.values ) )
if __name__ == "__main__":
unittest.main()
|
bsd-3-clause
|
[
26863,
199,
3,
199,
3,
221,
1898,
334,
67,
9,
9079,
12,
6047,
12580,
29410,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
221,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
221,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
221,
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,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
755,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
258,
627,
11443,
314,
536,
402,
6047,
12580,
29410,
6590,
314,
1561,
402,
1263,
199,
3,
755,
1163,
8417,
370,
642,
2032,
1443,
506,
1202,
370,
10692,
503,
199,
3,
755,
10016,
7585,
7131,
687,
642,
2032,
1928,
2488,
6791,
199,
3,
755,
5313,
4983,
14,
199,
3,
199,
3,
221,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
199,
3,
221,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
221,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
199,
3,
221,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
199,
3,
221,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
199,
3,
221,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
221,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
199,
3,
221,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
199,
3,
221,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
199,
3,
221,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
199,
3,
221,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
26863,
199,
199,
646,
2882,
199,
646,
14707,
199,
199,
533,
2434,
1304,
774,
8,
2882,
14,
1746,
776,
520,
421,
198,
318,
511,
1944,
36,
10771,
8,
291,
776,
520,
2742,
198,
3,
15589,
14,
1548,
14,
4869,
3181,
1133,
2040,
2739,
370,
4868,
626,
949,
9250,
1338,
787,
315,
652,
14,
11842,
781,
886,
282,
3486,
14786,
370,
4868,
507,
198,
3,
9099,
314,
574,
402,
1924,
2225,
14707,
14,
2568,
14,
6873,
56,
365,
3451,
315,
314,
298,
1459,
2,
1625,
14,
982,
652,
1159,
440,
12,
314,
12060,
7675,
507,
198,
3,
374,
282,
9250,
14,
2742,
198,
1580,
275,
1052,
2742,
198,
1507,
275,
378,
507,
198,
509,
284,
315,
2935,
8,
14707,
14,
2568,
776,
520,
6319,
198,
86,
275,
2519,
8,
14707,
14,
2568,
12,
284,
776,
686,
198,
692,
730,
8,
373,
776,
365,
14707,
14,
2568,
520,
1871,
1585,
198,
692,
373,
315,
2762,
520,
28558,
198,
3730,
6064,
1689,
2568,
367,
450,
83,
365,
282,
9250,
402,
450,
83,
2,
450,
334,
284,
12,
2762,
59,
86,
61,
776,
776,
16737,
198,
1580,
59,
86,
61,
275,
284,
16737,
198,
1507,
275,
1967,
435,
413,
2742,
198,
277,
14,
629,
8,
1967,
12,
822,
8,
14707,
14,
2568,
14,
1459,
776,
776,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
267,
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
] |
[
199,
3,
199,
3,
221,
1898,
334,
67,
9,
9079,
12,
6047,
12580,
29410,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
221,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
221,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
221,
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,
4248,
199,
3,
755,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
755,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
258,
627,
11443,
314,
536,
402,
6047,
12580,
29410,
6590,
314,
1561,
402,
1263,
199,
3,
755,
1163,
8417,
370,
642,
2032,
1443,
506,
1202,
370,
10692,
503,
199,
3,
755,
10016,
7585,
7131,
687,
642,
2032,
1928,
2488,
6791,
199,
3,
755,
5313,
4983,
14,
199,
3,
199,
3,
221,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
199,
3,
221,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
221,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
199,
3,
221,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
11489,
1549,
199,
3,
221,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
8820,
12,
199,
3,
221,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
5471,
2296,
12,
199,
3,
221,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
7126,
12,
1549,
199,
3,
221,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
199,
3,
221,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
334,
6446,
199,
3,
221,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
199,
3,
221,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
26863,
199,
199,
646,
2882,
199,
646,
14707,
199,
199,
533,
2434,
1304,
774,
8,
2882,
14,
1746,
776,
520,
421,
198,
318,
511,
1944,
36,
10771,
8,
291,
776,
520,
2742,
198,
3,
15589,
14,
1548,
14,
4869,
3181,
1133,
2040,
2739,
370,
4868,
626,
949,
9250,
1338,
787,
315,
652,
14,
11842,
781,
886,
282,
3486,
14786,
370,
4868,
507,
198,
3,
9099,
314,
574,
402,
1924,
2225,
14707,
14,
2568,
14,
6873,
56,
365,
3451,
315,
314,
298,
1459,
2,
1625,
14,
982,
652,
1159,
440,
12,
314,
12060,
7675,
507,
198,
3,
374,
282,
9250,
14,
2742,
198,
1580,
275,
1052,
2742,
198,
1507,
275,
378,
507,
198,
509,
284,
315,
2935,
8,
14707,
14,
2568,
776,
520,
6319,
198,
86,
275,
2519,
8,
14707,
14,
2568,
12,
284,
776,
686,
198,
692,
730,
8,
373,
776,
365,
14707,
14,
2568,
520,
1871,
1585,
198,
692,
373,
315,
2762,
520,
28558,
198,
3730,
6064,
1689,
2568,
367,
450,
83,
365,
282,
9250,
402,
450,
83,
2,
450,
334,
284,
12,
2762,
59,
86,
61,
776,
776,
16737,
198,
1580,
59,
86,
61,
275,
284,
16737,
198,
1507,
275,
1967,
435,
413,
2742,
198,
277,
14,
629,
8,
1967,
12,
822,
8,
14707,
14,
2568,
14,
1459,
776,
776,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
267,
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,
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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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
] |
benoitsteiner/tensorflow-xsmm
|
tensorflow/python/saved_model/utils_test.py
|
62
|
5133
|
# Copyright 2015 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.
# ==============================================================================
"""Tests for SavedModel utils."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.core.framework import types_pb2
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import sparse_tensor
from tensorflow.python.ops import array_ops
from tensorflow.python.platform import test
from tensorflow.python.saved_model import utils
class UtilsTest(test.TestCase):
def testBuildTensorInfoDense(self):
x = array_ops.placeholder(dtypes.float32, 1, name="x")
x_tensor_info = utils.build_tensor_info(x)
self.assertEqual("x:0", x_tensor_info.name)
self.assertEqual(types_pb2.DT_FLOAT, x_tensor_info.dtype)
self.assertEqual(1, len(x_tensor_info.tensor_shape.dim))
self.assertEqual(1, x_tensor_info.tensor_shape.dim[0].size)
def testBuildTensorInfoSparse(self):
x = array_ops.sparse_placeholder(dtypes.float32, [42, 69], name="x")
x_tensor_info = utils.build_tensor_info(x)
self.assertEqual(x.values.name,
x_tensor_info.coo_sparse.values_tensor_name)
self.assertEqual(x.indices.name,
x_tensor_info.coo_sparse.indices_tensor_name)
self.assertEqual(x.dense_shape.name,
x_tensor_info.coo_sparse.dense_shape_tensor_name)
self.assertEqual(types_pb2.DT_FLOAT, x_tensor_info.dtype)
self.assertEqual(2, len(x_tensor_info.tensor_shape.dim))
self.assertEqual(42, x_tensor_info.tensor_shape.dim[0].size)
self.assertEqual(69, x_tensor_info.tensor_shape.dim[1].size)
def testGetTensorFromInfoDense(self):
expected = array_ops.placeholder(dtypes.float32, 1, name="x")
tensor_info = utils.build_tensor_info(expected)
actual = utils.get_tensor_from_tensor_info(tensor_info)
self.assertIsInstance(actual, ops.Tensor)
self.assertEqual(expected.name, actual.name)
def testGetTensorFromInfoSparse(self):
expected = array_ops.sparse_placeholder(dtypes.float32, name="x")
tensor_info = utils.build_tensor_info(expected)
actual = utils.get_tensor_from_tensor_info(tensor_info)
self.assertIsInstance(actual, sparse_tensor.SparseTensor)
self.assertEqual(expected.values.name, actual.values.name)
self.assertEqual(expected.indices.name, actual.indices.name)
self.assertEqual(expected.dense_shape.name, actual.dense_shape.name)
def testGetTensorFromInfoInOtherGraph(self):
with ops.Graph().as_default() as expected_graph:
expected = array_ops.placeholder(dtypes.float32, 1, name="right")
tensor_info = utils.build_tensor_info(expected)
with ops.Graph().as_default(): # Some other graph.
array_ops.placeholder(dtypes.float32, 1, name="other")
actual = utils.get_tensor_from_tensor_info(tensor_info,
graph=expected_graph)
self.assertIsInstance(actual, ops.Tensor)
self.assertIs(actual.graph, expected_graph)
self.assertEqual(expected.name, actual.name)
def testGetTensorFromInfoInScope(self):
# Build a TensorInfo with name "bar/x:0".
with ops.Graph().as_default():
with ops.name_scope("bar"):
unscoped = array_ops.placeholder(dtypes.float32, 1, name="x")
tensor_info = utils.build_tensor_info(unscoped)
self.assertEqual("bar/x:0", tensor_info.name)
# Build a graph with node "foo/bar/x:0", akin to importing into scope foo.
with ops.Graph().as_default():
with ops.name_scope("foo"):
with ops.name_scope("bar"):
expected = array_ops.placeholder(dtypes.float32, 1, name="x")
self.assertEqual("foo/bar/x:0", expected.name)
# Test that tensor is found by prepending the import scope.
actual = utils.get_tensor_from_tensor_info(tensor_info,
import_scope="foo")
self.assertEqual(expected.name, actual.name)
def testGetTensorFromInfoRaisesErrors(self):
expected = array_ops.placeholder(dtypes.float32, 1, name="x")
tensor_info = utils.build_tensor_info(expected)
tensor_info.name = "blah:0" # Nonexistant name.
with self.assertRaises(KeyError):
utils.get_tensor_from_tensor_info(tensor_info)
tensor_info.ClearField("name") # Malformed (missing encoding).
with self.assertRaises(ValueError):
utils.get_tensor_from_tensor_info(tensor_info)
if __name__ == "__main__":
test.main()
|
apache-2.0
|
[
3,
1898,
6900,
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,
2925,
367,
29026,
1685,
3778,
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,
1018,
14,
4857,
492,
2943,
63,
3317,
18,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
4857,
492,
5178,
63,
3128,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
199,
504,
3228,
14,
1548,
14,
8420,
63,
1238,
492,
3778,
421,
199,
533,
17397,
774,
8,
396,
14,
1746,
304,
819,
347,
511,
3425,
3861,
2354,
15327,
8,
277,
304,
272,
671,
275,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
88,
531,
272,
671,
63,
3128,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
88,
9,
272,
291,
14,
629,
480,
88,
26,
16,
401,
671,
63,
3128,
63,
815,
14,
354,
9,
272,
291,
14,
629,
8,
1313,
63,
3317,
18,
14,
7438,
63,
11783,
12,
671,
63,
3128,
63,
815,
14,
2271,
9,
272,
291,
14,
629,
8,
17,
12,
822,
8,
88,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
430,
272,
291,
14,
629,
8,
17,
12,
671,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
59,
16,
1055,
890,
9,
819,
347,
511,
3425,
3861,
2354,
8629,
8,
277,
304,
272,
671,
275,
1625,
63,
1483,
14,
4421,
63,
6199,
8,
5717,
14,
1609,
708,
12,
359,
2260,
12,
14610,
467,
536,
628,
88,
531,
272,
671,
63,
3128,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
88,
9,
272,
291,
14,
629,
8,
88,
14,
1459,
14,
354,
12,
2151,
671,
63,
3128,
63,
815,
14,
22684,
63,
4421,
14,
1459,
63,
3128,
63,
354,
9,
272,
291,
14,
629,
8,
88,
14,
4108,
14,
354,
12,
2151,
671,
63,
3128,
63,
815,
14,
22684,
63,
4421,
14,
4108,
63,
3128,
63,
354,
9,
272,
291,
14,
629,
8,
88,
14,
7253,
63,
1392,
14,
354,
12,
2151,
671,
63,
3128,
63,
815,
14,
22684,
63,
4421,
14,
7253,
63,
1392,
63,
3128,
63,
354,
9,
272,
291,
14,
629,
8,
1313,
63,
3317,
18,
14,
7438,
63,
11783,
12,
671,
63,
3128,
63,
815,
14,
2271,
9,
272,
291,
14,
629,
8,
18,
12,
822,
8,
88,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
430,
272,
291,
14,
629,
8,
2260,
12,
671,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
59,
16,
1055,
890,
9,
272,
291,
14,
629,
8,
1876,
12,
671,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
59,
17,
1055,
890,
9,
819,
347,
19970,
3861,
2532,
2354,
15327,
8,
277,
304,
272,
1420,
275,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
88,
531,
272,
2345,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
2062,
9,
272,
3503,
275,
3778,
14,
362,
63,
3128,
63,
504,
63,
3128,
63,
815,
8,
3128,
63,
815,
9,
272,
291,
14,
6926,
8,
6514,
12,
4156,
14,
3861,
9,
272,
291,
14,
629,
8,
2062,
14,
354,
12,
3503,
14,
354,
9,
819,
347,
19970,
3861,
2532,
2354,
8629,
8,
277,
304,
272,
1420,
275,
1625,
63,
1483,
14,
4421,
63,
6199,
8,
5717,
14,
1609,
708,
12,
536,
628,
88,
531,
272,
2345,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
2062,
9,
272,
3503,
275,
3778,
14,
362,
63,
3128,
63,
504,
63,
3128,
63,
815,
8,
3128,
63,
815,
9,
272,
291,
14,
6926,
8,
6514,
12,
5178,
63,
3128,
14,
12079,
9,
272,
291,
14,
629,
8,
2062,
14,
1459,
14,
354,
12,
3503,
14,
1459,
14,
354,
9,
272,
291,
14,
629,
8,
2062,
14,
4108,
14,
354,
12,
3503,
14,
4108,
14,
354,
9,
272,
291,
14,
629,
8,
2062,
14,
7253,
63,
1392,
14,
354,
12,
3503,
14,
7253,
63,
1392,
14,
354,
9,
819,
347,
19970,
3861,
2532,
2354,
607,
8632,
4578,
8,
277,
304,
272,
543,
4156,
14,
4578,
1252,
305,
63,
885,
342,
465,
1420,
63,
2180,
26,
489,
1420,
275,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
1019,
531,
489,
2345,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
2062,
9,
272,
543,
4156,
14,
4578,
1252,
305,
63,
885,
837,
221,
327,
6601,
1163,
3343,
14,
489,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
1848,
531,
272,
3503,
275,
3778,
14,
362,
63,
3128,
63,
504,
63,
3128,
63,
815,
8,
3128,
63,
815,
12,
6901,
3343,
29,
2062,
63,
2180,
9,
272,
291,
14,
6926,
8,
6514,
12,
4156,
14,
3861,
9,
272,
291,
14,
3436,
8,
6514,
14,
2180,
12,
1420,
63,
2180,
9,
272,
291,
14,
629,
8,
2062,
14,
354,
12,
3503,
14,
354,
9,
819,
347,
19970,
3861,
2532,
2354,
31469,
8,
277,
304,
272,
327,
6516,
282,
5878,
2354,
543,
536,
298,
1700,
15,
88,
26,
16
] |
[
1898,
6900,
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,
2925,
367,
29026,
1685,
3778,
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,
1018,
14,
4857,
492,
2943,
63,
3317,
18,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
4857,
492,
5178,
63,
3128,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
199,
504,
3228,
14,
1548,
14,
8420,
63,
1238,
492,
3778,
421,
199,
533,
17397,
774,
8,
396,
14,
1746,
304,
819,
347,
511,
3425,
3861,
2354,
15327,
8,
277,
304,
272,
671,
275,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
88,
531,
272,
671,
63,
3128,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
88,
9,
272,
291,
14,
629,
480,
88,
26,
16,
401,
671,
63,
3128,
63,
815,
14,
354,
9,
272,
291,
14,
629,
8,
1313,
63,
3317,
18,
14,
7438,
63,
11783,
12,
671,
63,
3128,
63,
815,
14,
2271,
9,
272,
291,
14,
629,
8,
17,
12,
822,
8,
88,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
430,
272,
291,
14,
629,
8,
17,
12,
671,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
59,
16,
1055,
890,
9,
819,
347,
511,
3425,
3861,
2354,
8629,
8,
277,
304,
272,
671,
275,
1625,
63,
1483,
14,
4421,
63,
6199,
8,
5717,
14,
1609,
708,
12,
359,
2260,
12,
14610,
467,
536,
628,
88,
531,
272,
671,
63,
3128,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
88,
9,
272,
291,
14,
629,
8,
88,
14,
1459,
14,
354,
12,
2151,
671,
63,
3128,
63,
815,
14,
22684,
63,
4421,
14,
1459,
63,
3128,
63,
354,
9,
272,
291,
14,
629,
8,
88,
14,
4108,
14,
354,
12,
2151,
671,
63,
3128,
63,
815,
14,
22684,
63,
4421,
14,
4108,
63,
3128,
63,
354,
9,
272,
291,
14,
629,
8,
88,
14,
7253,
63,
1392,
14,
354,
12,
2151,
671,
63,
3128,
63,
815,
14,
22684,
63,
4421,
14,
7253,
63,
1392,
63,
3128,
63,
354,
9,
272,
291,
14,
629,
8,
1313,
63,
3317,
18,
14,
7438,
63,
11783,
12,
671,
63,
3128,
63,
815,
14,
2271,
9,
272,
291,
14,
629,
8,
18,
12,
822,
8,
88,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
430,
272,
291,
14,
629,
8,
2260,
12,
671,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
59,
16,
1055,
890,
9,
272,
291,
14,
629,
8,
1876,
12,
671,
63,
3128,
63,
815,
14,
3128,
63,
1392,
14,
3572,
59,
17,
1055,
890,
9,
819,
347,
19970,
3861,
2532,
2354,
15327,
8,
277,
304,
272,
1420,
275,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
88,
531,
272,
2345,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
2062,
9,
272,
3503,
275,
3778,
14,
362,
63,
3128,
63,
504,
63,
3128,
63,
815,
8,
3128,
63,
815,
9,
272,
291,
14,
6926,
8,
6514,
12,
4156,
14,
3861,
9,
272,
291,
14,
629,
8,
2062,
14,
354,
12,
3503,
14,
354,
9,
819,
347,
19970,
3861,
2532,
2354,
8629,
8,
277,
304,
272,
1420,
275,
1625,
63,
1483,
14,
4421,
63,
6199,
8,
5717,
14,
1609,
708,
12,
536,
628,
88,
531,
272,
2345,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
2062,
9,
272,
3503,
275,
3778,
14,
362,
63,
3128,
63,
504,
63,
3128,
63,
815,
8,
3128,
63,
815,
9,
272,
291,
14,
6926,
8,
6514,
12,
5178,
63,
3128,
14,
12079,
9,
272,
291,
14,
629,
8,
2062,
14,
1459,
14,
354,
12,
3503,
14,
1459,
14,
354,
9,
272,
291,
14,
629,
8,
2062,
14,
4108,
14,
354,
12,
3503,
14,
4108,
14,
354,
9,
272,
291,
14,
629,
8,
2062,
14,
7253,
63,
1392,
14,
354,
12,
3503,
14,
7253,
63,
1392,
14,
354,
9,
819,
347,
19970,
3861,
2532,
2354,
607,
8632,
4578,
8,
277,
304,
272,
543,
4156,
14,
4578,
1252,
305,
63,
885,
342,
465,
1420,
63,
2180,
26,
489,
1420,
275,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
1019,
531,
489,
2345,
63,
815,
275,
3778,
14,
1506,
63,
3128,
63,
815,
8,
2062,
9,
272,
543,
4156,
14,
4578,
1252,
305,
63,
885,
837,
221,
327,
6601,
1163,
3343,
14,
489,
1625,
63,
1483,
14,
6199,
8,
5717,
14,
1609,
708,
12,
413,
12,
536,
628,
1848,
531,
272,
3503,
275,
3778,
14,
362,
63,
3128,
63,
504,
63,
3128,
63,
815,
8,
3128,
63,
815,
12,
6901,
3343,
29,
2062,
63,
2180,
9,
272,
291,
14,
6926,
8,
6514,
12,
4156,
14,
3861,
9,
272,
291,
14,
3436,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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
] |
geerlingguy/ansible-modules-extras
|
cloud/amazon/dynamodb_table.py
|
35
|
8108
|
#!/usr/bin/python
# 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: dynamodb_table
short_description: Create, update or delete AWS Dynamo DB tables.
description:
- Create or delete AWS Dynamo DB tables.
- Can update the provisioned throughput on existing tables.
- Returns the status of the specified table.
version_added: "2.0"
author: Alan Loi (@loia)
version_added: "2.0"
requirements:
- "boto >= 2.13.2"
options:
state:
description:
- Create or delete the table
required: false
choices: ['present', 'absent']
default: 'present'
name:
description:
- Name of the table.
required: true
hash_key_name:
description:
- Name of the hash key.
- Required when C(state=present).
required: false
default: null
hash_key_type:
description:
- Type of the hash key.
required: false
choices: ['STRING', 'NUMBER', 'BINARY']
default: 'STRING'
range_key_name:
description:
- Name of the range key.
required: false
default: null
range_key_type:
description:
- Type of the range key.
required: false
choices: ['STRING', 'NUMBER', 'BINARY']
default: 'STRING'
read_capacity:
description:
- Read throughput capacity (units) to provision.
required: false
default: 1
write_capacity:
description:
- Write throughput capacity (units) to provision.
required: false
default: 1
region:
description:
- The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used.
required: false
aliases: ['aws_region', 'ec2_region']
extends_documentation_fragment: aws
"""
EXAMPLES = '''
# Create dynamo table with hash and range primary key
- dynamodb_table:
name: my-table
region: us-east-1
hash_key_name: id
hash_key_type: STRING
range_key_name: create_time
range_key_type: NUMBER
read_capacity: 2
write_capacity: 2
# Update capacity on existing dynamo table
- dynamodb_table:
name: my-table
region: us-east-1
read_capacity: 10
write_capacity: 10
# Delete dynamo table
- dynamodb_table:
name: my-table
region: us-east-1
state: absent
'''
RETURN = '''
table_status:
description: The current status of the table.
returned: success
type: string
sample: ACTIVE
'''
try:
import boto
import boto.dynamodb2
from boto.dynamodb2.table import Table
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.types import STRING, NUMBER, BINARY
from boto.exception import BotoServerError, NoAuthHandlerFound, JSONResponseError
HAS_BOTO = True
except ImportError:
HAS_BOTO = False
DYNAMO_TYPE_MAP = {
'STRING': STRING,
'NUMBER': NUMBER,
'BINARY': BINARY
}
def create_or_update_dynamo_table(connection, module):
table_name = module.params.get('name')
hash_key_name = module.params.get('hash_key_name')
hash_key_type = module.params.get('hash_key_type')
range_key_name = module.params.get('range_key_name')
range_key_type = module.params.get('range_key_type')
read_capacity = module.params.get('read_capacity')
write_capacity = module.params.get('write_capacity')
schema = [
HashKey(hash_key_name, DYNAMO_TYPE_MAP.get(hash_key_type)),
RangeKey(range_key_name, DYNAMO_TYPE_MAP.get(range_key_type))
]
throughput = {
'read': read_capacity,
'write': write_capacity
}
result = dict(
region=module.params.get('region'),
table_name=table_name,
hash_key_name=hash_key_name,
hash_key_type=hash_key_type,
range_key_name=range_key_name,
range_key_type=range_key_type,
read_capacity=read_capacity,
write_capacity=write_capacity,
)
try:
table = Table(table_name, connection=connection)
if dynamo_table_exists(table):
result['changed'] = update_dynamo_table(table, throughput=throughput, check_mode=module.check_mode)
else:
if not module.check_mode:
Table.create(table_name, connection=connection, schema=schema, throughput=throughput)
result['changed'] = True
if not module.check_mode:
result['table_status'] = table.describe()['Table']['TableStatus']
except BotoServerError:
result['msg'] = 'Failed to create/update dynamo table due to error: ' + traceback.format_exc()
module.fail_json(**result)
else:
module.exit_json(**result)
def delete_dynamo_table(connection, module):
table_name = module.params.get('name')
result = dict(
region=module.params.get('region'),
table_name=table_name,
)
try:
table = Table(table_name, connection=connection)
if dynamo_table_exists(table):
if not module.check_mode:
table.delete()
result['changed'] = True
else:
result['changed'] = False
except BotoServerError:
result['msg'] = 'Failed to delete dynamo table due to error: ' + traceback.format_exc()
module.fail_json(**result)
else:
module.exit_json(**result)
def dynamo_table_exists(table):
try:
table.describe()
return True
except JSONResponseError, e:
if e.message and e.message.startswith('Requested resource not found'):
return False
else:
raise e
def update_dynamo_table(table, throughput=None, check_mode=False):
table.describe() # populate table details
if has_throughput_changed(table, throughput):
if not check_mode:
return table.update(throughput=throughput)
else:
return True
return False
def has_throughput_changed(table, new_throughput):
if not new_throughput:
return False
return new_throughput['read'] != table.throughput['read'] or \
new_throughput['write'] != table.throughput['write']
def main():
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
state=dict(default='present', choices=['present', 'absent']),
name=dict(required=True, type='str'),
hash_key_name=dict(required=True, type='str'),
hash_key_type=dict(default='STRING', type='str', choices=['STRING', 'NUMBER', 'BINARY']),
range_key_name=dict(type='str'),
range_key_type=dict(default='STRING', type='str', choices=['STRING', 'NUMBER', 'BINARY']),
read_capacity=dict(default=1, type='int'),
write_capacity=dict(default=1, type='int'),
))
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True)
if not HAS_BOTO:
module.fail_json(msg='boto required for this module')
region, ec2_url, aws_connect_params = get_aws_connection_info(module)
if not region:
module.fail_json(msg='region must be specified')
try:
connection = connect_to_aws(boto.dynamodb2, region, **aws_connect_params)
except (NoAuthHandlerFound, StandardError), e:
module.fail_json(msg=str(e))
state = module.params.get('state')
if state == 'present':
create_or_update_dynamo_table(connection, module)
elif state == 'absent':
delete_dynamo_table(connection, module)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
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,
8948,
275,
408,
199,
2595,
199,
578,
26,
31388,
13152,
63,
1224,
199,
3612,
63,
1802,
26,
2790,
12,
1678,
503,
3145,
10168,
577,
26284,
6249,
6716,
14,
199,
1802,
26,
523,
446,
2790,
503,
3145,
10168,
577,
26284,
6249,
6716,
14,
523,
446,
6855,
1678,
314,
1727,
12308,
4012,
524,
641,
3411,
6716,
14,
523,
446,
1803,
314,
2004,
402,
314,
2013,
1817,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
2502,
26,
437,
1502,
3835,
73,
8593,
320,
4674,
9,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
7538,
26,
523,
446,
298,
10914,
2356,
499,
14,
969,
14,
18,
2,
199,
1419,
26,
523,
1174,
26,
272,
1369,
26,
489,
446,
2790,
503,
3145,
314,
1817,
272,
1415,
26,
3055,
272,
3415,
26,
788,
1881,
297,
283,
5575,
418,
272,
849,
26,
283,
1881,
7,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
1817,
14,
272,
1415,
26,
2549,
523,
2631,
63,
498,
63,
354,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
2631,
790,
14,
489,
446,
11105,
1380,
445,
8,
929,
29,
1881,
680,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
2631,
63,
498,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
314,
2631,
790,
14,
272,
1415,
26,
3055,
272,
3415,
26,
788,
5353,
297,
283,
9190,
297,
283,
13246,
418,
272,
849,
26,
283,
5353,
7,
523,
1425,
63,
498,
63,
354,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
1425,
790,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1425,
63,
498,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
314,
1425,
790,
14,
272,
1415,
26,
3055,
272,
3415,
26,
788,
5353,
297,
283,
9190,
297,
283,
13246,
418,
272,
849,
26,
283,
5353,
7,
523,
1586,
63,
10457,
26,
272,
1369,
26,
489,
446,
5574,
4012,
524,
14893,
334,
5260,
9,
370,
15408,
14,
272,
1415,
26,
3055,
272,
849,
26,
413,
523,
2218,
63,
10457,
26,
272,
1369,
26,
489,
446,
6990,
4012,
524,
14893,
334,
5260,
9,
370,
15408,
14,
272,
1415,
26,
3055,
272,
849,
26,
413,
523,
4897,
26,
272,
1369,
26,
489,
446,
710,
10168,
4897,
370,
675,
14,
982,
440,
2013,
2066,
314,
574,
402,
314,
15352,
18,
63,
23030,
3734,
1750,
12,
340,
1263,
12,
365,
1202,
14,
272,
1415,
26,
3055,
272,
5481,
26,
788,
7231,
63,
4551,
297,
283,
825,
18,
63,
4551,
418,
199,
199,
11036,
63,
9970,
63,
7677,
26,
11488,
199,
624,
199,
199,
8918,
275,
1449,
199,
3,
2790,
366,
26284,
1817,
543,
2631,
436,
1425,
5062,
790,
199,
13,
31388,
13152,
63,
1224,
26,
272,
536,
26,
3002,
13,
1224,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
2631,
63,
498,
63,
354,
26,
1305,
272,
2631,
63,
498,
63,
466,
26,
18661,
272,
1425,
63,
498,
63,
354,
26,
1218,
63,
521,
272,
1425,
63,
498,
63,
466,
26,
18122,
272,
1586,
63,
10457,
26,
499,
272,
2218,
63,
10457,
26,
499,
199,
199,
3,
6162,
14893,
641,
3411,
366,
26284,
1817,
199,
13,
31388,
13152,
63,
1224,
26,
272,
536,
26,
3002,
13,
1224,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
1586,
63,
10457,
26,
1616,
272,
2218,
63,
10457,
26,
1616,
199,
199,
3,
8496,
366,
26284,
1817,
199,
13,
31388,
13152,
63,
1224,
26,
272,
536,
26,
3002,
13,
1224,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
1174,
26,
9552,
199,
2344,
199,
199,
9677,
275,
1449,
199,
1224,
63,
1205,
26,
272,
1369,
26,
710,
1453,
2004,
402,
314,
1817,
14,
272,
2138,
26,
3182,
272,
730,
26,
1059,
272,
2690,
26,
26577,
199,
2344,
199,
199,
893,
26,
272,
492,
6055,
272,
492,
6055,
14,
30001,
18,
272,
687,
6055,
14,
30001,
18,
14,
1224,
492,
6957,
272,
687,
6055,
14,
30001,
18,
14,
955,
492,
16101,
1197,
12,
13114,
1197,
272,
687,
6055,
14,
30001,
18,
14,
1313,
492,
18661,
12,
18122,
12,
32698,
272,
687,
6055,
14,
1971,
492,
24411,
17692,
12,
3091,
21547,
3601,
12,
4840,
19712,
272,
7509,
63,
21373,
275,
715,
199,
199,
2590,
3545,
26,
272,
7509,
63,
21373,
275,
756,
421,
199,
11446,
7335,
47,
63,
2711,
63,
5443,
275,
469,
272,
283,
5353,
356,
18661,
12,
272,
283,
9190,
356,
18122,
12,
272,
283,
13246,
356,
32698,
199,
93,
421,
199,
318,
1218,
63,
269,
63,
873,
63,
20353,
79,
63,
1224,
8,
2105,
12,
859,
304,
272,
1817,
63,
354,
275,
859,
14,
1162,
14,
362,
360,
354,
358,
272,
2631,
63,
498,
63,
354,
275,
859,
14,
1162,
14,
362,
360,
2227,
63,
498,
63,
354,
358,
272,
2631,
63,
498,
63,
466,
275,
859,
14,
1162,
14,
362,
360,
2227,
63,
498,
63,
466,
358,
272,
1425,
63,
498,
63,
354,
275,
859,
14,
1162,
14,
362,
360,
1842,
63,
498,
63,
354,
358,
272,
1425,
63,
498,
63,
466,
275,
859,
14,
1162,
14,
362,
360,
1842,
63,
498,
63,
466,
358,
272,
1586,
63,
10457,
275,
859,
14,
1162,
14,
362,
360,
739,
63,
10457,
358,
272,
2218,
63,
10457,
275,
859
] |
[
2647,
15,
1393,
15,
1548,
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,
8948,
275,
408,
199,
2595,
199,
578,
26,
31388,
13152,
63,
1224,
199,
3612,
63,
1802,
26,
2790,
12,
1678,
503,
3145,
10168,
577,
26284,
6249,
6716,
14,
199,
1802,
26,
523,
446,
2790,
503,
3145,
10168,
577,
26284,
6249,
6716,
14,
523,
446,
6855,
1678,
314,
1727,
12308,
4012,
524,
641,
3411,
6716,
14,
523,
446,
1803,
314,
2004,
402,
314,
2013,
1817,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
2502,
26,
437,
1502,
3835,
73,
8593,
320,
4674,
9,
199,
1023,
63,
3270,
26,
298,
18,
14,
16,
2,
199,
7538,
26,
523,
446,
298,
10914,
2356,
499,
14,
969,
14,
18,
2,
199,
1419,
26,
523,
1174,
26,
272,
1369,
26,
489,
446,
2790,
503,
3145,
314,
1817,
272,
1415,
26,
3055,
272,
3415,
26,
788,
1881,
297,
283,
5575,
418,
272,
849,
26,
283,
1881,
7,
523,
536,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
1817,
14,
272,
1415,
26,
2549,
523,
2631,
63,
498,
63,
354,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
2631,
790,
14,
489,
446,
11105,
1380,
445,
8,
929,
29,
1881,
680,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
2631,
63,
498,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
314,
2631,
790,
14,
272,
1415,
26,
3055,
272,
3415,
26,
788,
5353,
297,
283,
9190,
297,
283,
13246,
418,
272,
849,
26,
283,
5353,
7,
523,
1425,
63,
498,
63,
354,
26,
272,
1369,
26,
489,
446,
2812,
402,
314,
1425,
790,
14,
272,
1415,
26,
3055,
272,
849,
26,
2973,
523,
1425,
63,
498,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
314,
1425,
790,
14,
272,
1415,
26,
3055,
272,
3415,
26,
788,
5353,
297,
283,
9190,
297,
283,
13246,
418,
272,
849,
26,
283,
5353,
7,
523,
1586,
63,
10457,
26,
272,
1369,
26,
489,
446,
5574,
4012,
524,
14893,
334,
5260,
9,
370,
15408,
14,
272,
1415,
26,
3055,
272,
849,
26,
413,
523,
2218,
63,
10457,
26,
272,
1369,
26,
489,
446,
6990,
4012,
524,
14893,
334,
5260,
9,
370,
15408,
14,
272,
1415,
26,
3055,
272,
849,
26,
413,
523,
4897,
26,
272,
1369,
26,
489,
446,
710,
10168,
4897,
370,
675,
14,
982,
440,
2013,
2066,
314,
574,
402,
314,
15352,
18,
63,
23030,
3734,
1750,
12,
340,
1263,
12,
365,
1202,
14,
272,
1415,
26,
3055,
272,
5481,
26,
788,
7231,
63,
4551,
297,
283,
825,
18,
63,
4551,
418,
199,
199,
11036,
63,
9970,
63,
7677,
26,
11488,
199,
624,
199,
199,
8918,
275,
1449,
199,
3,
2790,
366,
26284,
1817,
543,
2631,
436,
1425,
5062,
790,
199,
13,
31388,
13152,
63,
1224,
26,
272,
536,
26,
3002,
13,
1224,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
2631,
63,
498,
63,
354,
26,
1305,
272,
2631,
63,
498,
63,
466,
26,
18661,
272,
1425,
63,
498,
63,
354,
26,
1218,
63,
521,
272,
1425,
63,
498,
63,
466,
26,
18122,
272,
1586,
63,
10457,
26,
499,
272,
2218,
63,
10457,
26,
499,
199,
199,
3,
6162,
14893,
641,
3411,
366,
26284,
1817,
199,
13,
31388,
13152,
63,
1224,
26,
272,
536,
26,
3002,
13,
1224,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
1586,
63,
10457,
26,
1616,
272,
2218,
63,
10457,
26,
1616,
199,
199,
3,
8496,
366,
26284,
1817,
199,
13,
31388,
13152,
63,
1224,
26,
272,
536,
26,
3002,
13,
1224,
272,
4897,
26,
2739,
13,
14346,
13,
17,
272,
1174,
26,
9552,
199,
2344,
199,
199,
9677,
275,
1449,
199,
1224,
63,
1205,
26,
272,
1369,
26,
710,
1453,
2004,
402,
314,
1817,
14,
272,
2138,
26,
3182,
272,
730,
26,
1059,
272,
2690,
26,
26577,
199,
2344,
199,
199,
893,
26,
272,
492,
6055,
272,
492,
6055,
14,
30001,
18,
272,
687,
6055,
14,
30001,
18,
14,
1224,
492,
6957,
272,
687,
6055,
14,
30001,
18,
14,
955,
492,
16101,
1197,
12,
13114,
1197,
272,
687,
6055,
14,
30001,
18,
14,
1313,
492,
18661,
12,
18122,
12,
32698,
272,
687,
6055,
14,
1971,
492,
24411,
17692,
12,
3091,
21547,
3601,
12,
4840,
19712,
272,
7509,
63,
21373,
275,
715,
199,
199,
2590,
3545,
26,
272,
7509,
63,
21373,
275,
756,
421,
199,
11446,
7335,
47,
63,
2711,
63,
5443,
275,
469,
272,
283,
5353,
356,
18661,
12,
272,
283,
9190,
356,
18122,
12,
272,
283,
13246,
356,
32698,
199,
93,
421,
199,
318,
1218,
63,
269,
63,
873,
63,
20353,
79,
63,
1224,
8,
2105,
12,
859,
304,
272,
1817,
63,
354,
275,
859,
14,
1162,
14,
362,
360,
354,
358,
272,
2631,
63,
498,
63,
354,
275,
859,
14,
1162,
14,
362,
360,
2227,
63,
498,
63,
354,
358,
272,
2631,
63,
498,
63,
466,
275,
859,
14,
1162,
14,
362,
360,
2227,
63,
498,
63,
466,
358,
272,
1425,
63,
498,
63,
354,
275,
859,
14,
1162,
14,
362,
360,
1842,
63,
498,
63,
354,
358,
272,
1425,
63,
498,
63,
466,
275,
859,
14,
1162,
14,
362,
360,
1842,
63,
498,
63,
466,
358,
272,
1586,
63,
10457,
275,
859,
14,
1162,
14,
362,
360,
739,
63,
10457,
358,
272,
2218,
63,
10457,
275,
859,
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,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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
] |
unkyulee/elastic-cms
|
src/web/modules/post/services/config.py
|
1
|
2826
|
import web.util.tools as tools
import os
from web import app
import lib.es as es
def get(p):
# get host and index from the global config
h = tools.get_conf(p['host'], p['navigation']['id'], 'host', 'http://localhost:9200')
n = tools.get_conf(p['host'], p['navigation']['id'], 'index', '')
return {
'name': get_conf(h, n, 'name', ''),
'description': get_conf(h, n, 'description', ''),
'host': h,
'index': n,
'upload_dir':
get_conf(h, n, 'upload_dir',
os.path.join( app.config.get('BASE_DIR'), 'uploads' )
),
'allowed_exts': get_conf(h, n, 'allowed_exts',''),
'page_size': get_conf(h, n, 'page_size', '10'),
'query': get_conf(h, n, 'query', '*'),
'sort_field': get_conf(h, n, 'sort_field', '_score'),
'sort_dir': get_conf(h, n, 'sort_dir', 'desc'),
'top': get_conf(h, n, 'top', ''),
'footer': get_conf(h, n, 'footer', ''),
'side': get_conf(h, n, 'side', ''),
'content_header': get_conf(h, n, 'content_header', ''),
'content_footer': get_conf(h, n, 'content_footer', ''),
'intro': get_conf(h, n, 'intro', ''),
'search_query': get_conf(h, n, 'search_query', ''),
'search_item_template': get_conf(h, n, 'search_item_template', ''),
'keep_history': get_conf(h, n, 'keep_history', 'Yes'),
}
def set(p):
# get host, index
host = p['c']['host']
if not host:
host = tools.get('host')
index = p['c']['index']
if not index:
index = tools.get('index')
# get host and index from the global config
tools.set_conf(p['host'], p['navigation']['id'], 'host', host)
tools.set_conf(p['host'], p['navigation']['id'], 'index', index)
# set local config
if p['c']['index']: # save local config only when index is already created
set_conf(host, index, 'name', tools.get('name'))
set_conf(host, index, 'description', tools.get('description'))
set_conf(host, index, 'upload_dir', tools.get('upload_dir'))
set_conf(host, index, 'allowed_exts', tools.get('allowed_exts'))
set_conf(host, index, 'page_size', tools.get('page_size'))
set_conf(host, index, 'query', tools.get('query'))
set_conf(host, index, 'sort_field', tools.get('sort_field'))
set_conf(host, index, 'sort_dir', tools.get('sort_dir'))
set_conf(host, index, 'keep_history', tools.get('keep_history'))
def get_conf(host, index, name, default):
ret = es.get(host, index, "config", name)
return ret.get('value') if ret and ret.get('value') else default
def set_conf(host, index, name, value):
config = {
'name': name,
'value': value
}
es.update(host, index, "config", name, config)
es.flush(host, index)
|
mit
|
[
646,
3330,
14,
1974,
14,
2537,
465,
7249,
199,
646,
747,
199,
504,
3330,
492,
1145,
199,
646,
1973,
14,
397,
465,
9455,
199,
199,
318,
664,
8,
80,
304,
272,
327,
664,
1591,
436,
1478,
687,
314,
2288,
1101,
272,
394,
275,
7249,
14,
362,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1102,
297,
283,
1014,
921,
5967,
26,
25,
1840,
358,
272,
302,
275,
7249,
14,
362,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1080,
297,
4074,
339,
372,
469,
267,
283,
354,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
354,
297,
9929,
267,
283,
1802,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1802,
297,
9929,
267,
283,
1102,
356,
394,
12,
267,
283,
1080,
356,
302,
12,
267,
283,
5064,
63,
694,
356,
288,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
5064,
63,
694,
297,
355,
747,
14,
515,
14,
904,
8,
1145,
14,
888,
14,
362,
360,
5825,
63,
3022,
659,
283,
21725,
7,
776,
288,
2318,
267,
283,
6541,
63,
25752,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
6541,
63,
25752,
25936,
267,
283,
1606,
63,
890,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1606,
63,
890,
297,
283,
709,
659,
267,
283,
1131,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1131,
297,
6438,
659,
267,
283,
3191,
63,
698,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
3191,
63,
698,
297,
2513,
3397,
659,
267,
283,
3191,
63,
694,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
3191,
63,
694,
297,
283,
3257,
659,
267,
283,
2119,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
2119,
297,
9929,
267,
283,
12781,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
12781,
297,
9929,
267,
283,
2441,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
2441,
297,
9929,
267,
283,
1317,
63,
1291,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1317,
63,
1291,
297,
9929,
267,
283,
1317,
63,
12781,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1317,
63,
12781,
297,
9929,
267,
283,
18206,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
18206,
297,
9929,
267,
283,
1733,
63,
1131,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1733,
63,
1131,
297,
9929,
267,
283,
1733,
63,
1053,
63,
1160,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1733,
63,
1053,
63,
1160,
297,
9929,
267,
283,
3250,
63,
5570,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
3250,
63,
5570,
297,
283,
12555,
659,
272,
789,
199,
199,
318,
663,
8,
80,
304,
272,
327,
664,
1591,
12,
1478,
272,
1591,
275,
299,
459,
67,
2545,
1102,
418,
272,
340,
440,
1591,
26,
267,
1591,
275,
7249,
14,
362,
360,
1102,
358,
339,
1478,
275,
299,
459,
67,
2545,
1080,
418,
272,
340,
440,
1478,
26,
267,
1478,
275,
7249,
14,
362,
360,
1080,
358,
339,
327,
664,
1591,
436,
1478,
687,
314,
2288,
1101,
272,
7249,
14,
409,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1102,
297,
1591,
9,
272,
7249,
14,
409,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1080,
297,
1478,
9,
339,
327,
663,
2257,
1101,
272,
340,
299,
459,
67,
2545,
1080,
2565,
327,
3354,
2257,
1101,
1454,
1380,
1478,
365,
2575,
2737,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
354,
297,
7249,
14,
362,
360,
354,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
1802,
297,
7249,
14,
362,
360,
1802,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
5064,
63,
694,
297,
7249,
14,
362,
360,
5064,
63,
694,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
6541,
63,
25752,
297,
7249,
14,
362,
360,
6541,
63,
25752,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
1606,
63,
890,
297,
7249,
14,
362,
360,
1606,
63,
890,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
1131,
297,
7249,
14,
362,
360,
1131,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
3191,
63,
698,
297,
7249,
14,
362,
360,
3191,
63,
698,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
3191,
63,
694,
297,
7249,
14,
362,
360,
3191,
63,
694,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
3250,
63,
5570,
297,
7249,
14,
362,
360,
3250,
63,
5570,
1333,
421,
199,
318,
664,
63,
2190,
8,
1102,
12,
1478,
12,
536,
12,
849,
304,
272,
2203,
275,
9455,
14,
362,
8,
1102,
12,
1478,
12,
298,
888,
401,
536,
9,
272,
372,
2203,
14,
362,
360,
585,
358,
340,
2203,
436,
2203,
14,
362,
360,
585,
358,
587,
849,
421,
199,
318,
663,
63,
2190,
8,
1102,
12,
1478,
12,
536,
12,
574,
304,
272,
1101,
275,
469,
267,
283,
354,
356,
536,
12,
267,
283,
585,
356,
574,
272,
789,
272,
9455,
14,
873,
8,
1102,
12,
1478,
12,
298,
888,
401,
536,
12,
1101,
9,
272,
9455,
14,
4939,
8,
1102,
12,
1478,
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
] |
[
3330,
14,
1974,
14,
2537,
465,
7249,
199,
646,
747,
199,
504,
3330,
492,
1145,
199,
646,
1973,
14,
397,
465,
9455,
199,
199,
318,
664,
8,
80,
304,
272,
327,
664,
1591,
436,
1478,
687,
314,
2288,
1101,
272,
394,
275,
7249,
14,
362,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1102,
297,
283,
1014,
921,
5967,
26,
25,
1840,
358,
272,
302,
275,
7249,
14,
362,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1080,
297,
4074,
339,
372,
469,
267,
283,
354,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
354,
297,
9929,
267,
283,
1802,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1802,
297,
9929,
267,
283,
1102,
356,
394,
12,
267,
283,
1080,
356,
302,
12,
267,
283,
5064,
63,
694,
356,
288,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
5064,
63,
694,
297,
355,
747,
14,
515,
14,
904,
8,
1145,
14,
888,
14,
362,
360,
5825,
63,
3022,
659,
283,
21725,
7,
776,
288,
2318,
267,
283,
6541,
63,
25752,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
6541,
63,
25752,
25936,
267,
283,
1606,
63,
890,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1606,
63,
890,
297,
283,
709,
659,
267,
283,
1131,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1131,
297,
6438,
659,
267,
283,
3191,
63,
698,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
3191,
63,
698,
297,
2513,
3397,
659,
267,
283,
3191,
63,
694,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
3191,
63,
694,
297,
283,
3257,
659,
267,
283,
2119,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
2119,
297,
9929,
267,
283,
12781,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
12781,
297,
9929,
267,
283,
2441,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
2441,
297,
9929,
267,
283,
1317,
63,
1291,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1317,
63,
1291,
297,
9929,
267,
283,
1317,
63,
12781,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1317,
63,
12781,
297,
9929,
267,
283,
18206,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
18206,
297,
9929,
267,
283,
1733,
63,
1131,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1733,
63,
1131,
297,
9929,
267,
283,
1733,
63,
1053,
63,
1160,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
1733,
63,
1053,
63,
1160,
297,
9929,
267,
283,
3250,
63,
5570,
356,
664,
63,
2190,
8,
72,
12,
302,
12,
283,
3250,
63,
5570,
297,
283,
12555,
659,
272,
789,
199,
199,
318,
663,
8,
80,
304,
272,
327,
664,
1591,
12,
1478,
272,
1591,
275,
299,
459,
67,
2545,
1102,
418,
272,
340,
440,
1591,
26,
267,
1591,
275,
7249,
14,
362,
360,
1102,
358,
339,
1478,
275,
299,
459,
67,
2545,
1080,
418,
272,
340,
440,
1478,
26,
267,
1478,
275,
7249,
14,
362,
360,
1080,
358,
339,
327,
664,
1591,
436,
1478,
687,
314,
2288,
1101,
272,
7249,
14,
409,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1102,
297,
1591,
9,
272,
7249,
14,
409,
63,
2190,
8,
80,
459,
1102,
995,
299,
459,
24148,
2545,
344,
995,
283,
1080,
297,
1478,
9,
339,
327,
663,
2257,
1101,
272,
340,
299,
459,
67,
2545,
1080,
2565,
327,
3354,
2257,
1101,
1454,
1380,
1478,
365,
2575,
2737,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
354,
297,
7249,
14,
362,
360,
354,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
1802,
297,
7249,
14,
362,
360,
1802,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
5064,
63,
694,
297,
7249,
14,
362,
360,
5064,
63,
694,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
6541,
63,
25752,
297,
7249,
14,
362,
360,
6541,
63,
25752,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
1606,
63,
890,
297,
7249,
14,
362,
360,
1606,
63,
890,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
1131,
297,
7249,
14,
362,
360,
1131,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
3191,
63,
698,
297,
7249,
14,
362,
360,
3191,
63,
698,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
3191,
63,
694,
297,
7249,
14,
362,
360,
3191,
63,
694,
1333,
267,
663,
63,
2190,
8,
1102,
12,
1478,
12,
283,
3250,
63,
5570,
297,
7249,
14,
362,
360,
3250,
63,
5570,
1333,
421,
199,
318,
664,
63,
2190,
8,
1102,
12,
1478,
12,
536,
12,
849,
304,
272,
2203,
275,
9455,
14,
362,
8,
1102,
12,
1478,
12,
298,
888,
401,
536,
9,
272,
372,
2203,
14,
362,
360,
585,
358,
340,
2203,
436,
2203,
14,
362,
360,
585,
358,
587,
849,
421,
199,
318,
663,
63,
2190,
8,
1102,
12,
1478,
12,
536,
12,
574,
304,
272,
1101,
275,
469,
267,
283,
354,
356,
536,
12,
267,
283,
585,
356,
574,
272,
789,
272,
9455,
14,
873,
8,
1102,
12,
1478,
12,
298,
888,
401,
536,
12,
1101,
9,
272,
9455,
14,
4939,
8,
1102,
12,
1478,
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,
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,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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
GutenkunstLab/SloppyCell
|
test/test_FixedPoints.py
|
1
|
3610
|
import unittest
import scipy
from SloppyCell.ReactionNetworks import *
lorenz = Network('lorenz')
lorenz.add_compartment('basic')
lorenz.add_species('x', 'basic', 0.5)
lorenz.add_species('y', 'basic', 0.5)
lorenz.add_species('z', 'basic', 0.5)
lorenz.add_parameter('sigma', 1.0)
lorenz.add_parameter('r', 2.0)
lorenz.add_parameter('b', 2.0)
lorenz.add_rate_rule('x', 'sigma*(y-x)')
lorenz.add_rate_rule('y', 'r*x - y - x*z')
lorenz.add_rate_rule('z', 'x*y - b*z')
class test_fixedpoints(unittest.TestCase):
def test_basic(self):
""" Test basic fixed-point finding """
net = lorenz.copy('test')
fp = Dynamics.dyn_var_fixed_point(net, dv0=[1,1,1], with_logs=False)
# This should find the fixed-point [sqrt(2), sqrt(2), 1]
self.assertAlmostEqual(fp[0], scipy.sqrt(2), 6, 'Failed on basic 1,0.')
self.assertAlmostEqual(fp[1], scipy.sqrt(2), 6, 'Failed on basic 1,1.')
self.assertAlmostEqual(fp[2], 1, 6, 'Failed on basic 1,2.')
fp = Dynamics.dyn_var_fixed_point(net, dv0=[-0.1,-0.1,-0.1],
with_logs=False)
# This should find the fixed-point [0, 0, 0]
self.assertAlmostEqual(fp[0], 0, 6, 'Failed on basic 2,0.')
self.assertAlmostEqual(fp[1], 0, 6, 'Failed on basic 2,1.')
self.assertAlmostEqual(fp[2], 0, 6, 'Failed on basic 2,2.')
def test_withlogs(self):
""" Test fixed-point finding with logs """
net = lorenz.copy('test')
fp = Dynamics.dyn_var_fixed_point(net, dv0=[1,1,1], with_logs=True)
# This should find the fixed-point [sqrt(2), sqrt(2), 1]
self.assertAlmostEqual(fp[0], scipy.sqrt(2), 6, 'Failed on logs 1,0.')
self.assertAlmostEqual(fp[1], scipy.sqrt(2), 6, 'Failed on logs 1,1.')
self.assertAlmostEqual(fp[2], 1, 6, 'Failed on logs 1,2.')
fp = Dynamics.dyn_var_fixed_point(net, dv0=[0.1,0.1,0.1],
with_logs=True)
# This should find the fixed-point [0, 0, 0]
self.assertAlmostEqual(fp[0], 0, 6, 'Failed on logs 2,0.')
self.assertAlmostEqual(fp[1], 0, 6, 'Failed on logs 2,1.')
self.assertAlmostEqual(fp[2], 0, 6, 'Failed on logs 2,2.')
def test_stability(self):
net = lorenz.copy('test')
# The sqrt(b*(r-1)), sqrt(b*(r-1)), r-1 fixed point is stable for r < rH
# Strogatz, Nonlinear Dynamics and Chaos (p. 316)
fp, stable = Dynamics.dyn_var_fixed_point(net, dv0=[1,1,1],
stability=True)
self.assertEqual(stable, -1, 'Failed to classify stable fixed point')
# (0,0,0) is a saddle here
fp, stable = Dynamics.dyn_var_fixed_point(net, dv0=[0.01,0.01,0.01],
stability=True)
self.assertEqual(stable, 0, 'Failed to classify saddle')
# (0,0,0) is a stable node here
net.set_var_ic('r', 0.5)
fp, stable = Dynamics.dyn_var_fixed_point(net, dv0=[0.1,0.1,0.1],
stability=True)
self.assertEqual(stable, -1, 'Failed to classify stable fixed point')
# Now make the far fixed point a saddle...
net.set_var_ic('sigma', 6.0)
net.set_var_ic('r', 25)
fp, stable = Dynamics.dyn_var_fixed_point(net, dv0=[10,10,10],
stability=True)
self.assertEqual(stable, 0, 'Failed to classify saddle')
suite = unittest.makeSuite(test_fixedpoints)
if __name__ == '__main__':
unittest.main()
|
bsd-3-clause
|
[
646,
2882,
199,
199,
646,
7026,
199,
199,
504,
428,
18630,
647,
8108,
14,
6512,
30551,
492,
627,
199,
199,
320,
828,
90,
275,
7220,
360,
320,
828,
90,
358,
199,
320,
828,
90,
14,
525,
63,
863,
580,
434,
360,
4316,
358,
199,
320,
828,
90,
14,
525,
63,
17168,
360,
88,
297,
283,
4316,
297,
378,
14,
21,
9,
199,
320,
828,
90,
14,
525,
63,
17168,
360,
89,
297,
283,
4316,
297,
378,
14,
21,
9,
199,
320,
828,
90,
14,
525,
63,
17168,
360,
90,
297,
283,
4316,
297,
378,
14,
21,
9,
199,
320,
828,
90,
14,
525,
63,
5329,
360,
9412,
297,
413,
14,
16,
9,
199,
320,
828,
90,
14,
525,
63,
5329,
360,
82,
297,
499,
14,
16,
9,
199,
320,
828,
90,
14,
525,
63,
5329,
360,
66,
297,
499,
14,
16,
9,
199,
320,
828,
90,
14,
525,
63,
1866,
63,
2200,
360,
88,
297,
283,
9412,
5830,
89,
13,
88,
5942,
199,
320,
828,
90,
14,
525,
63,
1866,
63,
2200,
360,
89,
297,
283,
82,
10,
88,
446,
612,
446,
671,
10,
90,
358,
199,
320,
828,
90,
14,
525,
63,
1866,
63,
2200,
360,
90,
297,
283,
88,
10,
89,
446,
330,
10,
90,
358,
199,
199,
533,
511,
63,
5964,
3438,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4316,
8,
277,
304,
267,
408,
1379,
5678,
6317,
13,
1403,
17196,
408,
267,
1851,
275,
560,
828,
90,
14,
1574,
360,
396,
358,
267,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
17,
12,
17,
12,
17,
467,
543,
63,
7270,
29,
797,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
5079,
8,
18,
395,
7452,
8,
18,
395,
413,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
5678,
413,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
5678,
413,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
413,
12,
1227,
12,
283,
4276,
641,
5678,
413,
12,
18,
2659,
398,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
13,
16,
14,
17,
3057,
16,
14,
17,
3057,
16,
14,
17,
467,
221,
5101,
543,
63,
7270,
29,
797,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
16,
12,
378,
12,
378,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
378,
12,
1227,
12,
283,
4276,
641,
5678,
499,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
378,
12,
1227,
12,
283,
4276,
641,
5678,
499,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
378,
12,
1227,
12,
283,
4276,
641,
5678,
499,
12,
18,
2659,
339,
347,
511,
63,
1045,
7270,
8,
277,
304,
267,
408,
1379,
6317,
13,
1403,
17196,
543,
9610,
408,
267,
1851,
275,
560,
828,
90,
14,
1574,
360,
396,
358,
267,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
17,
12,
17,
12,
17,
467,
543,
63,
7270,
29,
549,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
5079,
8,
18,
395,
7452,
8,
18,
395,
413,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
9610,
413,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
9610,
413,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
413,
12,
1227,
12,
283,
4276,
641,
9610,
413,
12,
18,
2659,
398,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
16,
14,
17,
12,
16,
14,
17,
12,
16,
14,
17,
467,
221,
5101,
543,
63,
7270,
29,
549,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
16,
12,
378,
12,
378,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
378,
12,
1227,
12,
283,
4276,
641,
9610,
499,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
378,
12,
1227,
12,
283,
4276,
641,
9610,
499,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
378,
12,
1227,
12,
283,
4276,
641,
9610,
499,
12,
18,
2659,
339,
347,
511,
63,
270,
3616,
8,
277,
304,
267,
1851,
275,
560,
828,
90,
14,
1574,
360,
396,
358,
267,
327,
710,
7452,
8,
66,
5830,
82,
13,
17,
1826,
7452,
8,
66,
5830,
82,
13,
17,
1826,
519,
13,
17,
6317,
2376,
365,
17830,
367,
519,
665,
519,
40,
267,
327,
221,
428,
1374,
71,
10214,
12,
10172,
6676,
577,
4019,
2932,
436,
445,
2411,
736,
334,
80,
14,
650,
975,
9,
267,
4090,
12,
17830,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
17,
12,
17,
12,
17,
467,
221,
8179,
410,
3616,
29,
549,
9,
267,
291,
14,
629,
8,
11989,
12,
446,
17,
12,
283,
4276,
370,
28837,
17830,
6317,
2376,
358,
398,
327,
334,
16,
12,
16,
12,
16,
9,
365,
282,
308,
20101,
2348,
267,
4090,
12,
17830,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
16,
14,
614,
12,
16,
14,
614,
12,
16,
14,
614,
467,
221,
8179,
410,
3616,
29,
549,
9,
267,
291,
14,
629,
8,
11989,
12,
378,
12,
283,
4276,
370,
28837,
308,
20101,
358,
398,
327,
334,
16,
12,
16,
12,
16,
9,
365,
282,
17830,
1031,
2348,
267,
1851,
14,
409,
63,
1391,
63,
530,
360,
82,
297,
378,
14,
21,
9,
267,
4090,
12,
17830,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
16,
14,
17,
12,
16,
14,
17,
12,
16,
14,
17,
467
] |
[
2882,
199,
199,
646,
7026,
199,
199,
504,
428,
18630,
647,
8108,
14,
6512,
30551,
492,
627,
199,
199,
320,
828,
90,
275,
7220,
360,
320,
828,
90,
358,
199,
320,
828,
90,
14,
525,
63,
863,
580,
434,
360,
4316,
358,
199,
320,
828,
90,
14,
525,
63,
17168,
360,
88,
297,
283,
4316,
297,
378,
14,
21,
9,
199,
320,
828,
90,
14,
525,
63,
17168,
360,
89,
297,
283,
4316,
297,
378,
14,
21,
9,
199,
320,
828,
90,
14,
525,
63,
17168,
360,
90,
297,
283,
4316,
297,
378,
14,
21,
9,
199,
320,
828,
90,
14,
525,
63,
5329,
360,
9412,
297,
413,
14,
16,
9,
199,
320,
828,
90,
14,
525,
63,
5329,
360,
82,
297,
499,
14,
16,
9,
199,
320,
828,
90,
14,
525,
63,
5329,
360,
66,
297,
499,
14,
16,
9,
199,
320,
828,
90,
14,
525,
63,
1866,
63,
2200,
360,
88,
297,
283,
9412,
5830,
89,
13,
88,
5942,
199,
320,
828,
90,
14,
525,
63,
1866,
63,
2200,
360,
89,
297,
283,
82,
10,
88,
446,
612,
446,
671,
10,
90,
358,
199,
320,
828,
90,
14,
525,
63,
1866,
63,
2200,
360,
90,
297,
283,
88,
10,
89,
446,
330,
10,
90,
358,
199,
199,
533,
511,
63,
5964,
3438,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4316,
8,
277,
304,
267,
408,
1379,
5678,
6317,
13,
1403,
17196,
408,
267,
1851,
275,
560,
828,
90,
14,
1574,
360,
396,
358,
267,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
17,
12,
17,
12,
17,
467,
543,
63,
7270,
29,
797,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
5079,
8,
18,
395,
7452,
8,
18,
395,
413,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
5678,
413,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
5678,
413,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
413,
12,
1227,
12,
283,
4276,
641,
5678,
413,
12,
18,
2659,
398,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
13,
16,
14,
17,
3057,
16,
14,
17,
3057,
16,
14,
17,
467,
221,
5101,
543,
63,
7270,
29,
797,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
16,
12,
378,
12,
378,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
378,
12,
1227,
12,
283,
4276,
641,
5678,
499,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
378,
12,
1227,
12,
283,
4276,
641,
5678,
499,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
378,
12,
1227,
12,
283,
4276,
641,
5678,
499,
12,
18,
2659,
339,
347,
511,
63,
1045,
7270,
8,
277,
304,
267,
408,
1379,
6317,
13,
1403,
17196,
543,
9610,
408,
267,
1851,
275,
560,
828,
90,
14,
1574,
360,
396,
358,
267,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
17,
12,
17,
12,
17,
467,
543,
63,
7270,
29,
549,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
5079,
8,
18,
395,
7452,
8,
18,
395,
413,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
9610,
413,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
7026,
14,
5079,
8,
18,
395,
1227,
12,
283,
4276,
641,
9610,
413,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
413,
12,
1227,
12,
283,
4276,
641,
9610,
413,
12,
18,
2659,
398,
4090,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
16,
14,
17,
12,
16,
14,
17,
12,
16,
14,
17,
467,
221,
5101,
543,
63,
7270,
29,
549,
9,
267,
327,
961,
1077,
2342,
314,
6317,
13,
1403,
359,
16,
12,
378,
12,
378,
61,
267,
291,
14,
7904,
8,
3997,
59,
16,
467,
378,
12,
1227,
12,
283,
4276,
641,
9610,
499,
12,
16,
2659,
267,
291,
14,
7904,
8,
3997,
59,
17,
467,
378,
12,
1227,
12,
283,
4276,
641,
9610,
499,
12,
17,
2659,
267,
291,
14,
7904,
8,
3997,
59,
18,
467,
378,
12,
1227,
12,
283,
4276,
641,
9610,
499,
12,
18,
2659,
339,
347,
511,
63,
270,
3616,
8,
277,
304,
267,
1851,
275,
560,
828,
90,
14,
1574,
360,
396,
358,
267,
327,
710,
7452,
8,
66,
5830,
82,
13,
17,
1826,
7452,
8,
66,
5830,
82,
13,
17,
1826,
519,
13,
17,
6317,
2376,
365,
17830,
367,
519,
665,
519,
40,
267,
327,
221,
428,
1374,
71,
10214,
12,
10172,
6676,
577,
4019,
2932,
436,
445,
2411,
736,
334,
80,
14,
650,
975,
9,
267,
4090,
12,
17830,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
17,
12,
17,
12,
17,
467,
221,
8179,
410,
3616,
29,
549,
9,
267,
291,
14,
629,
8,
11989,
12,
446,
17,
12,
283,
4276,
370,
28837,
17830,
6317,
2376,
358,
398,
327,
334,
16,
12,
16,
12,
16,
9,
365,
282,
308,
20101,
2348,
267,
4090,
12,
17830,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
16,
14,
614,
12,
16,
14,
614,
12,
16,
14,
614,
467,
221,
8179,
410,
3616,
29,
549,
9,
267,
291,
14,
629,
8,
11989,
12,
378,
12,
283,
4276,
370,
28837,
308,
20101,
358,
398,
327,
334,
16,
12,
16,
12,
16,
9,
365,
282,
17830,
1031,
2348,
267,
1851,
14,
409,
63,
1391,
63,
530,
360,
82,
297,
378,
14,
21,
9,
267,
4090,
12,
17830,
275,
577,
4019,
2932,
14,
17883,
63,
1391,
63,
5964,
63,
1403,
8,
846,
12,
26869,
16,
1524,
16,
14,
17,
12,
16,
14,
17,
12,
16,
14,
17,
467,
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,
1
] |
bitemyapp/Suns
|
src/pika/exceptions.py
|
6
|
4260
|
"""Pika specific exceptions"""
class AMQPError(Exception):
def __repr__(self):
return 'An unspecified AMQP error has occurred'
class AMQPConnectionError(AMQPError):
def __repr__(self):
if len(self.args) == 1:
if (self.args[0] == 1):
return ('No connection could be opened after 1 '
'connection attempt')
else:
return ('No connection could be opened after %s '
'connection attempts' %
self.args[0])
elif len(self.args) == 2:
return '%s: %s' % (self.args[0], self.args[1])
class IncompatibleProtocolError(AMQPConnectionError):
def __repr__(self):
return 'The protocol returned by the server is not supported'
class AuthenticationError(AMQPConnectionError):
def __repr__(self):
return ('Server and client could not negotiate use of the %s '
'authentication mechanism' % self.args[0])
class ProbableAuthenticationError(AMQPConnectionError):
def __repr__(self):
return ('Client was disconnected at a connection stage indicating a '
'probable authentication error')
class ProbableAccessDeniedError(AMQPConnectionError):
def __repr__(self):
return ('Client was disconnected at a connection stage indicating a '
'probable denial of access to the specified virtual host')
class NoFreeChannels(AMQPConnectionError):
def __repr__(self):
return 'The connection has run out of free channels'
class ConnectionClosed(AMQPConnectionError):
def __repr__(self):
return 'The AMQP connection was closed (%s) %s' % (self.args[0],
self.args[1])
class AMQPChannelError(AMQPError):
def __repr__(self):
return 'An unspecified AMQP channel error has occurred'
class ChannelClosed(AMQPChannelError):
def __repr__(self):
return 'The channel was remotely closed (%s) %s' % (self.args[0],
self.args[1])
class DuplicateConsumerTag(AMQPChannelError):
def __repr__(self):
return ('The consumer tag specified already exists for this '
'channel: %s' % self.args[0])
class ConsumerCancelled(AMQPChannelError):
def __repr__(self):
return 'Server cancelled consumer (%s): %s' % (self.args[0].reply_code,
self.args[0].reply_text)
class InvalidChannelNumber(AMQPError):
def __repr__(self):
return 'An invalid channel number has been specified: %s' % self.args[0]
class ProtocolSyntaxError(AMQPError):
def __repr__(self):
return 'An unspecified protocol syntax error occurred'
class UnexpectedFrameError(ProtocolSyntaxError):
def __repr__(self):
return 'Received a frame out of sequence: %r' % self.args[0]
class ProtocolVersionMismatch(ProtocolSyntaxError):
def __repr__(self):
return 'Protocol versions did not match: %r vs %r' % (self.args[0],
self.args[1])
class BodyTooLongError(ProtocolSyntaxError):
def __repr__(self):
return ('Received too many bytes for a message delivery: '
'Received %i, expected %i' % (self.args[0], self.args[1]))
class InvalidFrameError(ProtocolSyntaxError):
def __repr__(self):
return 'Invalid frame received: %r' % self.args[0]
class InvalidFieldTypeException(ProtocolSyntaxError):
def __repr__(self):
return 'Unsupported field kind %s' % self.args[0]
class UnspportedAMQPFieldException(ProtocolSyntaxError):
def __repr__(self):
return 'Unsupported field kind %s' % type(self.args[1])
class MethodNotImplemented(AMQPError):
pass
class ChannelError(Exception):
def __repr__(self):
return 'An unspecified error occurred with the Channel'
class InvalidMinimumFrameSize(ProtocolSyntaxError):
def __repr__(self):
return 'AMQP Minimum Frame Size is 4096 Bytes'
class InvalidMaximumFrameSize(ProtocolSyntaxError):
def __repr__(self):
return 'AMQP Maximum Frame Size is 131072 Bytes'
|
bsd-3-clause
|
[
624,
48,
26966,
2488,
4967,
624,
421,
199,
533,
437,
14449,
48,
547,
8,
1726,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
437,
14449,
48,
1125,
965,
8920,
7,
421,
199,
533,
437,
14449,
48,
20349,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
340,
822,
8,
277,
14,
589,
9,
508,
413,
26,
288,
340,
334,
277,
14,
589,
59,
16,
61,
508,
413,
304,
355,
372,
661,
1944,
1950,
4293,
506,
12123,
2410,
413,
283,
717,
283,
2105,
7427,
358,
288,
587,
26,
355,
372,
661,
1944,
1950,
4293,
506,
12123,
2410,
450,
83,
283,
717,
283,
2105,
12454,
7,
450,
717,
291,
14,
589,
59,
16,
566,
267,
916,
822,
8,
277,
14,
589,
9,
508,
499,
26,
288,
372,
1543,
83,
26,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
467,
291,
14,
589,
59,
17,
566,
421,
199,
533,
1010,
6490,
3658,
547,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
4113,
2138,
701,
314,
1654,
365,
440,
3748,
7,
421,
199,
533,
15995,
547,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
3120,
436,
1890,
4293,
440,
29184,
323,
675,
402,
314,
450,
83,
283,
355,
283,
11725,
14729,
7,
450,
291,
14,
589,
59,
16,
566,
421,
199,
533,
22770,
461,
27942,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
3041,
1990,
25602,
737,
282,
1950,
9546,
9297,
282,
283,
355,
283,
6101,
461,
6299,
1125,
358,
421,
199,
533,
22770,
461,
3946,
15729,
547,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
3041,
1990,
25602,
737,
282,
1950,
9546,
9297,
282,
283,
355,
283,
6101,
461,
5376,
2380,
402,
2879,
370,
314,
2013,
5791,
1591,
358,
421,
199,
533,
3091,
10146,
27138,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
1950,
965,
1255,
734,
402,
2867,
9245,
7,
421,
199,
533,
8113,
15190,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
437,
14449,
48,
1950,
1990,
6876,
4366,
83,
9,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
467,
15491,
291,
14,
589,
59,
17,
566,
421,
199,
533,
437,
14449,
48,
5358,
547,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
437,
14449,
48,
3623,
1125,
965,
8920,
7,
421,
199,
533,
17270,
15190,
8,
1156,
31208,
5358,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
3623,
1990,
3982,
590,
6876,
4366,
83,
9,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
467,
14663,
291,
14,
589,
59,
17,
566,
421,
199,
533,
23942,
18186,
1931,
8,
1156,
31208,
5358,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
1918,
9790,
1947,
2013,
2575,
3495,
367,
642,
283,
355,
283,
2775,
26,
450,
83,
7,
450,
291,
14,
589,
59,
16,
566,
421,
199,
533,
1448,
5391,
22127,
8,
1156,
31208,
5358,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3120,
20115,
9790,
4366,
83,
304,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
1055,
8102,
63,
600,
12,
10940,
291,
14,
589,
59,
16,
1055,
8102,
63,
505,
9,
421,
199,
533,
6378,
5358,
3259,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
3866,
3623,
1329,
965,
2757,
2013,
26,
450,
83,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
11557,
9294,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
4113,
6302,
1125,
8920,
7,
421,
199,
533,
25345,
3160,
547,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
9392,
282,
2787,
734,
402,
3414,
26,
450,
82,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
11557,
3353,
23055,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3658,
5459,
8103,
440,
1336,
26,
450,
82,
8118,
450,
82,
7,
450,
334,
277,
14,
589,
59,
16,
467,
16854,
291,
14,
589,
59,
17,
566,
421,
199,
533,
29665,
13749,
9551,
547,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
9392,
4634,
5002,
2783,
367,
282,
1245,
18719,
26,
283,
355,
283,
9392,
450,
73,
12,
1420,
450,
73,
7,
450,
334,
277,
14,
589,
59,
16,
467,
291,
14,
589,
59,
17,
2459,
421,
199,
533,
6378,
3160,
547,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3364,
2787,
3086,
26,
450,
82,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
6378,
792,
804,
1726,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
12647,
901,
4928,
450,
83,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
15254,
802,
1376,
1156,
31208,
792,
1726,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
12647,
901,
4928,
450,
83,
7,
450,
730,
8,
277,
14,
589,
59,
17,
566,
421,
199,
533,
9075,
14278,
8,
1156,
31208,
547,
304,
272,
986,
421,
199,
533,
17270,
547,
8,
1726,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
1125,
8920,
543,
314,
17270,
7,
421,
199,
533,
6378,
12092,
3160,
2320,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1156,
31208,
22466,
11726,
14579,
365,
17125,
9879,
7,
421,
199,
533,
6378,
10915,
3160,
2320,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1156,
31208,
14212,
11726,
14579,
365,
4944,
709,
2819,
9879,
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
] |
[
48,
26966,
2488,
4967,
624,
421,
199,
533,
437,
14449,
48,
547,
8,
1726,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
437,
14449,
48,
1125,
965,
8920,
7,
421,
199,
533,
437,
14449,
48,
20349,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
340,
822,
8,
277,
14,
589,
9,
508,
413,
26,
288,
340,
334,
277,
14,
589,
59,
16,
61,
508,
413,
304,
355,
372,
661,
1944,
1950,
4293,
506,
12123,
2410,
413,
283,
717,
283,
2105,
7427,
358,
288,
587,
26,
355,
372,
661,
1944,
1950,
4293,
506,
12123,
2410,
450,
83,
283,
717,
283,
2105,
12454,
7,
450,
717,
291,
14,
589,
59,
16,
566,
267,
916,
822,
8,
277,
14,
589,
9,
508,
499,
26,
288,
372,
1543,
83,
26,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
467,
291,
14,
589,
59,
17,
566,
421,
199,
533,
1010,
6490,
3658,
547,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
4113,
2138,
701,
314,
1654,
365,
440,
3748,
7,
421,
199,
533,
15995,
547,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
3120,
436,
1890,
4293,
440,
29184,
323,
675,
402,
314,
450,
83,
283,
355,
283,
11725,
14729,
7,
450,
291,
14,
589,
59,
16,
566,
421,
199,
533,
22770,
461,
27942,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
3041,
1990,
25602,
737,
282,
1950,
9546,
9297,
282,
283,
355,
283,
6101,
461,
6299,
1125,
358,
421,
199,
533,
22770,
461,
3946,
15729,
547,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
3041,
1990,
25602,
737,
282,
1950,
9546,
9297,
282,
283,
355,
283,
6101,
461,
5376,
2380,
402,
2879,
370,
314,
2013,
5791,
1591,
358,
421,
199,
533,
3091,
10146,
27138,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
1950,
965,
1255,
734,
402,
2867,
9245,
7,
421,
199,
533,
8113,
15190,
8,
1156,
31208,
20349,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
437,
14449,
48,
1950,
1990,
6876,
4366,
83,
9,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
467,
15491,
291,
14,
589,
59,
17,
566,
421,
199,
533,
437,
14449,
48,
5358,
547,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
437,
14449,
48,
3623,
1125,
965,
8920,
7,
421,
199,
533,
17270,
15190,
8,
1156,
31208,
5358,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1918,
3623,
1990,
3982,
590,
6876,
4366,
83,
9,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
467,
14663,
291,
14,
589,
59,
17,
566,
421,
199,
533,
23942,
18186,
1931,
8,
1156,
31208,
5358,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
1918,
9790,
1947,
2013,
2575,
3495,
367,
642,
283,
355,
283,
2775,
26,
450,
83,
7,
450,
291,
14,
589,
59,
16,
566,
421,
199,
533,
1448,
5391,
22127,
8,
1156,
31208,
5358,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3120,
20115,
9790,
4366,
83,
304,
450,
83,
7,
450,
334,
277,
14,
589,
59,
16,
1055,
8102,
63,
600,
12,
10940,
291,
14,
589,
59,
16,
1055,
8102,
63,
505,
9,
421,
199,
533,
6378,
5358,
3259,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
3866,
3623,
1329,
965,
2757,
2013,
26,
450,
83,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
11557,
9294,
8,
1156,
31208,
547,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
4113,
6302,
1125,
8920,
7,
421,
199,
533,
25345,
3160,
547,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
9392,
282,
2787,
734,
402,
3414,
26,
450,
82,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
11557,
3353,
23055,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3658,
5459,
8103,
440,
1336,
26,
450,
82,
8118,
450,
82,
7,
450,
334,
277,
14,
589,
59,
16,
467,
16854,
291,
14,
589,
59,
17,
566,
421,
199,
533,
29665,
13749,
9551,
547,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
661,
9392,
4634,
5002,
2783,
367,
282,
1245,
18719,
26,
283,
355,
283,
9392,
450,
73,
12,
1420,
450,
73,
7,
450,
334,
277,
14,
589,
59,
16,
467,
291,
14,
589,
59,
17,
2459,
421,
199,
533,
6378,
3160,
547,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
3364,
2787,
3086,
26,
450,
82,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
6378,
792,
804,
1726,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
12647,
901,
4928,
450,
83,
7,
450,
291,
14,
589,
59,
16,
61,
421,
199,
533,
15254,
802,
1376,
1156,
31208,
792,
1726,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
12647,
901,
4928,
450,
83,
7,
450,
730,
8,
277,
14,
589,
59,
17,
566,
421,
199,
533,
9075,
14278,
8,
1156,
31208,
547,
304,
272,
986,
421,
199,
533,
17270,
547,
8,
1726,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
2493,
21994,
1125,
8920,
543,
314,
17270,
7,
421,
199,
533,
6378,
12092,
3160,
2320,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1156,
31208,
22466,
11726,
14579,
365,
17125,
9879,
7,
421,
199,
533,
6378,
10915,
3160,
2320,
8,
3658,
9294,
304,
272,
347,
636,
2722,
721,
277,
304,
267,
372,
283,
1156,
31208,
14212,
11726,
14579,
365,
4944,
709,
2819,
9879,
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,
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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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
diagramsoftware/odoo
|
addons/sale/res_partner.py
|
236
|
1722
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 fields,osv
class res_partner(osv.osv):
_inherit = 'res.partner'
def _sale_order_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict(map(lambda x: (x,0), ids))
# The current user may not have access rights for sale orders
try:
for partner in self.browse(cr, uid, ids, context):
res[partner.id] = len(partner.sale_order_ids) + len(partner.mapped('child_ids.sale_order_ids'))
except:
pass
return res
_columns = {
'sale_order_count': fields.function(_sale_order_count, string='# of Sales Order', type='integer'),
'sale_order_ids': fields.one2many('sale.order','partner_id','Sales Order')
}
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
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,
1504,
12,
4795,
199,
199,
533,
522,
63,
3899,
8,
4795,
14,
4795,
304,
272,
485,
6486,
275,
283,
470,
14,
3899,
7,
339,
347,
485,
8515,
63,
1648,
63,
835,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1211,
8,
1130,
8,
2734,
671,
26,
334,
88,
12,
16,
395,
2762,
430,
267,
327,
710,
1453,
922,
1443,
440,
1172,
2879,
4481,
367,
13590,
15460,
267,
862,
26,
288,
367,
5854,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
304,
355,
522,
59,
3899,
14,
344,
61,
275,
822,
8,
3899,
14,
8515,
63,
1648,
63,
1580,
9,
435,
822,
8,
3899,
14,
11663,
360,
1739,
63,
1580,
14,
8515,
63,
1648,
63,
1580,
1333,
267,
871,
26,
288,
986,
267,
372,
522,
339,
485,
3406,
275,
469,
267,
283,
8515,
63,
1648,
63,
835,
356,
1504,
14,
1593,
1547,
8515,
63,
1648,
63,
835,
12,
1059,
26431,
402,
428,
7098,
9240,
297,
730,
534,
4115,
659,
267,
283,
8515,
63,
1648,
63,
1580,
356,
1504,
14,
368,
18,
3479,
360,
8515,
14,
1648,
1673,
3899,
63,
344,
1673,
18220,
9240,
358,
272,
789,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
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,
1504,
12,
4795,
199,
199,
533,
522,
63,
3899,
8,
4795,
14,
4795,
304,
272,
485,
6486,
275,
283,
470,
14,
3899,
7,
339,
347,
485,
8515,
63,
1648,
63,
835,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
901,
63,
354,
12,
1680,
12,
1067,
29,
403,
304,
267,
522,
275,
1211,
8,
1130,
8,
2734,
671,
26,
334,
88,
12,
16,
395,
2762,
430,
267,
327,
710,
1453,
922,
1443,
440,
1172,
2879,
4481,
367,
13590,
15460,
267,
862,
26,
288,
367,
5854,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
304,
355,
522,
59,
3899,
14,
344,
61,
275,
822,
8,
3899,
14,
8515,
63,
1648,
63,
1580,
9,
435,
822,
8,
3899,
14,
11663,
360,
1739,
63,
1580,
14,
8515,
63,
1648,
63,
1580,
1333,
267,
871,
26,
288,
986,
267,
372,
522,
339,
485,
3406,
275,
469,
267,
283,
8515,
63,
1648,
63,
835,
356,
1504,
14,
1593,
1547,
8515,
63,
1648,
63,
835,
12,
1059,
26431,
402,
428,
7098,
9240,
297,
730,
534,
4115,
659,
267,
283,
8515,
63,
1648,
63,
1580,
356,
1504,
14,
368,
18,
3479,
360,
8515,
14,
1648,
1673,
3899,
63,
344,
1673,
18220,
9240,
358,
272,
789,
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,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
sijis/err
|
tests/backend_tests/text_test.py
|
3
|
1047
|
import sys
from tempfile import mkdtemp
import pytest
import logging
import os
from errbot.backends.text import TextBackend
from errbot.bootstrap import bot_config_defaults
@pytest.fixture
def text_backend():
tempdir = mkdtemp()
# reset the config every time
sys.modules.pop('errbot.config-template', None)
__import__('errbot.config-template')
config = sys.modules['errbot.config-template']
bot_config_defaults(config)
config.BOT_DATA_DIR = tempdir
config.BOT_LOG_FILE = os.path.join(tempdir, 'log.txt')
config.BOT_EXTRA_PLUGIN_DIR = []
config.BOT_LOG_LEVEL = logging.DEBUG
config.BOT_PREFIX = '!'
config.BOT_IDENTITY['username'] = '@testme'
config.BOT_ADMINS = ['@test_admin']
return TextBackend(config)
def test_change_presence(text_backend, caplog):
with caplog.at_level(logging.DEBUG):
text_backend.change_presence('online', "I'm online")
assert len(caplog.messages) == 1
a_message = caplog.messages[0]
assert a_message.startswith('*** Changed presence')
|
gpl-3.0
|
[
646,
984,
199,
504,
5549,
492,
31781,
199,
199,
646,
4613,
199,
646,
2050,
199,
646,
747,
199,
199,
504,
2329,
3018,
14,
7765,
14,
505,
492,
4516,
8447,
199,
504,
2329,
3018,
14,
11146,
492,
5888,
63,
888,
63,
4322,
421,
199,
32,
4462,
14,
5997,
199,
318,
1318,
63,
4620,
837,
272,
21628,
275,
31781,
342,
339,
327,
5305,
314,
1101,
4036,
900,
272,
984,
14,
3112,
14,
1935,
360,
1508,
3018,
14,
888,
13,
1160,
297,
488,
9,
272,
636,
646,
19734,
1508,
3018,
14,
888,
13,
1160,
358,
272,
1101,
275,
984,
14,
3112,
459,
1508,
3018,
14,
888,
13,
1160,
418,
272,
5888,
63,
888,
63,
4322,
8,
888,
9,
272,
1101,
14,
11372,
63,
3998,
63,
3022,
275,
21628,
272,
1101,
14,
11372,
63,
4947,
63,
3817,
275,
747,
14,
515,
14,
904,
8,
11567,
12,
283,
793,
14,
2424,
358,
272,
1101,
14,
11372,
63,
18555,
63,
19108,
63,
3022,
275,
942,
272,
1101,
14,
11372,
63,
4947,
63,
11817,
275,
2050,
14,
5287,
272,
1101,
14,
11372,
63,
6351,
275,
29376,
272,
1101,
14,
11372,
63,
7466,
1922,
459,
2473,
418,
275,
10267,
396,
278,
7,
272,
1101,
14,
11372,
63,
14288,
51,
275,
788,
32,
396,
63,
2113,
418,
339,
372,
4516,
8447,
8,
888,
9,
421,
199,
318,
511,
63,
1461,
63,
21566,
8,
505,
63,
4620,
12,
32297,
304,
272,
543,
32297,
14,
292,
63,
1896,
8,
4806,
14,
5287,
304,
267,
1318,
63,
4620,
14,
1461,
63,
21566,
360,
15178,
297,
298,
41,
6704,
18470,
531,
272,
702,
822,
8,
2874,
793,
14,
3431,
9,
508,
413,
272,
282,
63,
1188,
275,
32297,
14,
3431,
59,
16,
61,
272,
702,
282,
63,
1188,
14,
2460,
360,
9153,
25649,
20024,
358,
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
] |
[
984,
199,
504,
5549,
492,
31781,
199,
199,
646,
4613,
199,
646,
2050,
199,
646,
747,
199,
199,
504,
2329,
3018,
14,
7765,
14,
505,
492,
4516,
8447,
199,
504,
2329,
3018,
14,
11146,
492,
5888,
63,
888,
63,
4322,
421,
199,
32,
4462,
14,
5997,
199,
318,
1318,
63,
4620,
837,
272,
21628,
275,
31781,
342,
339,
327,
5305,
314,
1101,
4036,
900,
272,
984,
14,
3112,
14,
1935,
360,
1508,
3018,
14,
888,
13,
1160,
297,
488,
9,
272,
636,
646,
19734,
1508,
3018,
14,
888,
13,
1160,
358,
272,
1101,
275,
984,
14,
3112,
459,
1508,
3018,
14,
888,
13,
1160,
418,
272,
5888,
63,
888,
63,
4322,
8,
888,
9,
272,
1101,
14,
11372,
63,
3998,
63,
3022,
275,
21628,
272,
1101,
14,
11372,
63,
4947,
63,
3817,
275,
747,
14,
515,
14,
904,
8,
11567,
12,
283,
793,
14,
2424,
358,
272,
1101,
14,
11372,
63,
18555,
63,
19108,
63,
3022,
275,
942,
272,
1101,
14,
11372,
63,
4947,
63,
11817,
275,
2050,
14,
5287,
272,
1101,
14,
11372,
63,
6351,
275,
29376,
272,
1101,
14,
11372,
63,
7466,
1922,
459,
2473,
418,
275,
10267,
396,
278,
7,
272,
1101,
14,
11372,
63,
14288,
51,
275,
788,
32,
396,
63,
2113,
418,
339,
372,
4516,
8447,
8,
888,
9,
421,
199,
318,
511,
63,
1461,
63,
21566,
8,
505,
63,
4620,
12,
32297,
304,
272,
543,
32297,
14,
292,
63,
1896,
8,
4806,
14,
5287,
304,
267,
1318,
63,
4620,
14,
1461,
63,
21566,
360,
15178,
297,
298,
41,
6704,
18470,
531,
272,
702,
822,
8,
2874,
793,
14,
3431,
9,
508,
413,
272,
282,
63,
1188,
275,
32297,
14,
3431,
59,
16,
61,
272,
702,
282,
63,
1188,
14,
2460,
360,
9153,
25649,
20024,
358,
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,
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,
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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
] |
lijoantony/django-oscar
|
src/oscar/apps/dashboard/catalogue/tables.py
|
27
|
2631
|
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
from django_tables2 import Column, LinkColumn, TemplateColumn, A
from oscar.core.loading import get_class, get_model
DashboardTable = get_class('dashboard.tables', 'DashboardTable')
Product = get_model('catalogue', 'Product')
Category = get_model('catalogue', 'Category')
class ProductTable(DashboardTable):
title = TemplateColumn(
verbose_name=_('Title'),
template_name='dashboard/catalogue/product_row_title.html',
order_by='title', accessor=A('title'))
image = TemplateColumn(
verbose_name=_('Image'),
template_name='dashboard/catalogue/product_row_image.html',
orderable=False)
product_class = Column(
verbose_name=_('Product type'),
accessor=A('product_class'),
order_by='product_class__name')
variants = TemplateColumn(
verbose_name=_("Variants"),
template_name='dashboard/catalogue/product_row_variants.html',
orderable=False
)
stock_records = TemplateColumn(
verbose_name=_('Stock records'),
template_name='dashboard/catalogue/product_row_stockrecords.html',
orderable=False)
actions = TemplateColumn(
verbose_name=_('Actions'),
template_name='dashboard/catalogue/product_row_actions.html',
orderable=False)
icon = "sitemap"
class Meta(DashboardTable.Meta):
model = Product
fields = ('upc', 'date_updated')
sequence = ('title', 'upc', 'image', 'product_class', 'variants',
'stock_records', '...', 'date_updated', 'actions')
order_by = '-date_updated'
class CategoryTable(DashboardTable):
name = LinkColumn('dashboard:catalogue-category-update', args=[A('pk')])
description = TemplateColumn(
template_code='{{ record.description|default:""|striptags'
'|cut:" "|truncatewords:6 }}')
# mark_safe is needed because of
# https://github.com/bradleyayers/django-tables2/issues/187
num_children = LinkColumn(
'dashboard:catalogue-category-detail-list', args=[A('pk')],
verbose_name=mark_safe(_('Number of child categories')),
accessor='get_num_children',
orderable=False)
actions = TemplateColumn(
template_name='dashboard/catalogue/category_row_actions.html',
orderable=False)
icon = "sitemap"
caption = ungettext_lazy("%s Category", "%s Categories")
class Meta(DashboardTable.Meta):
model = Category
fields = ('name', 'description')
|
bsd-3-clause
|
[
504,
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
5501,
26843,
63,
6395,
199,
199,
504,
1639,
63,
5987,
18,
492,
4996,
12,
10967,
4547,
12,
5458,
4547,
12,
437,
199,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
533,
12,
664,
63,
1238,
199,
199,
30122,
3186,
275,
664,
63,
533,
360,
9743,
14,
5987,
297,
283,
30122,
3186,
358,
199,
5884,
275,
664,
63,
1238,
360,
22330,
297,
283,
5884,
358,
199,
7841,
275,
664,
63,
1238,
360,
22330,
297,
283,
7841,
358,
421,
199,
533,
12705,
3186,
8,
30122,
3186,
304,
272,
2538,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
6888,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
1213,
14,
1360,
297,
267,
1865,
63,
991,
534,
1213,
297,
19474,
29,
33,
360,
1213,
1333,
272,
1834,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
3491,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
1569,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
272,
3336,
63,
533,
275,
4996,
8,
267,
3376,
63,
354,
12397,
5884,
730,
659,
267,
19474,
29,
33,
360,
2558,
63,
533,
659,
267,
1865,
63,
991,
534,
2558,
63,
533,
363,
354,
358,
272,
21169,
275,
5458,
4547,
8,
267,
3376,
63,
354,
9384,
9958,
2285,
1288,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
15680,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
272,
776,
272,
10952,
63,
6502,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
17103,
5767,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
6088,
6502,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
272,
5445,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
9303,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
3723,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
339,
7016,
275,
298,
17205,
2,
339,
1021,
6288,
8,
30122,
3186,
14,
3396,
304,
267,
1402,
275,
12705,
267,
1504,
275,
661,
384,
67,
297,
283,
602,
63,
5334,
358,
267,
3414,
275,
661,
1213,
297,
283,
384,
67,
297,
283,
1569,
297,
283,
2558,
63,
533,
297,
283,
15680,
297,
490,
283,
6088,
63,
6502,
297,
283,
20833,
283,
602,
63,
5334,
297,
283,
3723,
358,
267,
1865,
63,
991,
275,
2475,
602,
63,
5334,
7,
421,
199,
533,
13573,
3186,
8,
30122,
3186,
304,
272,
536,
275,
10967,
4547,
360,
9743,
26,
22330,
13,
3710,
13,
873,
297,
1249,
1524,
33,
360,
2051,
2023,
272,
1369,
275,
5458,
4547,
8,
267,
1978,
63,
600,
534,
3638,
2777,
14,
1802,
92,
885,
26,
341,
92,
1913,
2969,
7,
1993,
11280,
5919,
5424,
6,
10758,
9426,
92,
12517,
3148,
26,
22,
28404,
272,
327,
2216,
63,
3489,
365,
4346,
2952,
402,
272,
327,
4178,
921,
5031,
14,
957,
15,
7828,
3011,
89,
1187,
1192,
15,
1176,
13,
5987,
18,
15,
10115,
15,
11775,
272,
1967,
63,
3223,
275,
10967,
4547,
8,
267,
283,
9743,
26,
22330,
13,
3710,
13,
5506,
13,
513,
297,
1249,
1524,
33,
360,
2051,
2665,
267,
3376,
63,
354,
29,
1657,
63,
3489,
6723,
3259,
402,
1982,
9695,
3855,
267,
19474,
534,
362,
63,
1507,
63,
3223,
297,
267,
503,
271,
6842,
29,
797,
9,
272,
5445,
275,
5458,
4547,
8,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
3710,
63,
1143,
63,
3723,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
339,
7016,
275,
298,
17205,
2,
272,
19038,
275,
26843,
63,
6395,
3647,
83,
13573,
401,
2071,
83,
23995,
6112,
531,
339,
1021,
6288,
8,
30122,
3186,
14,
3396,
304,
267,
1402,
275,
13573,
267,
1504,
275,
661,
354,
297,
283,
1802,
358,
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
] |
[
1639,
14,
1208,
14,
28389,
492,
2216,
63,
3489,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
5501,
26843,
63,
6395,
199,
199,
504,
1639,
63,
5987,
18,
492,
4996,
12,
10967,
4547,
12,
5458,
4547,
12,
437,
199,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
533,
12,
664,
63,
1238,
199,
199,
30122,
3186,
275,
664,
63,
533,
360,
9743,
14,
5987,
297,
283,
30122,
3186,
358,
199,
5884,
275,
664,
63,
1238,
360,
22330,
297,
283,
5884,
358,
199,
7841,
275,
664,
63,
1238,
360,
22330,
297,
283,
7841,
358,
421,
199,
533,
12705,
3186,
8,
30122,
3186,
304,
272,
2538,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
6888,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
1213,
14,
1360,
297,
267,
1865,
63,
991,
534,
1213,
297,
19474,
29,
33,
360,
1213,
1333,
272,
1834,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
3491,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
1569,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
272,
3336,
63,
533,
275,
4996,
8,
267,
3376,
63,
354,
12397,
5884,
730,
659,
267,
19474,
29,
33,
360,
2558,
63,
533,
659,
267,
1865,
63,
991,
534,
2558,
63,
533,
363,
354,
358,
272,
21169,
275,
5458,
4547,
8,
267,
3376,
63,
354,
9384,
9958,
2285,
1288,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
15680,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
272,
776,
272,
10952,
63,
6502,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
17103,
5767,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
6088,
6502,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
272,
5445,
275,
5458,
4547,
8,
267,
3376,
63,
354,
12397,
9303,
659,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
2558,
63,
1143,
63,
3723,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
339,
7016,
275,
298,
17205,
2,
339,
1021,
6288,
8,
30122,
3186,
14,
3396,
304,
267,
1402,
275,
12705,
267,
1504,
275,
661,
384,
67,
297,
283,
602,
63,
5334,
358,
267,
3414,
275,
661,
1213,
297,
283,
384,
67,
297,
283,
1569,
297,
283,
2558,
63,
533,
297,
283,
15680,
297,
490,
283,
6088,
63,
6502,
297,
283,
20833,
283,
602,
63,
5334,
297,
283,
3723,
358,
267,
1865,
63,
991,
275,
2475,
602,
63,
5334,
7,
421,
199,
533,
13573,
3186,
8,
30122,
3186,
304,
272,
536,
275,
10967,
4547,
360,
9743,
26,
22330,
13,
3710,
13,
873,
297,
1249,
1524,
33,
360,
2051,
2023,
272,
1369,
275,
5458,
4547,
8,
267,
1978,
63,
600,
534,
3638,
2777,
14,
1802,
92,
885,
26,
341,
92,
1913,
2969,
7,
1993,
11280,
5919,
5424,
6,
10758,
9426,
92,
12517,
3148,
26,
22,
28404,
272,
327,
2216,
63,
3489,
365,
4346,
2952,
402,
272,
327,
4178,
921,
5031,
14,
957,
15,
7828,
3011,
89,
1187,
1192,
15,
1176,
13,
5987,
18,
15,
10115,
15,
11775,
272,
1967,
63,
3223,
275,
10967,
4547,
8,
267,
283,
9743,
26,
22330,
13,
3710,
13,
5506,
13,
513,
297,
1249,
1524,
33,
360,
2051,
2665,
267,
3376,
63,
354,
29,
1657,
63,
3489,
6723,
3259,
402,
1982,
9695,
3855,
267,
19474,
534,
362,
63,
1507,
63,
3223,
297,
267,
503,
271,
6842,
29,
797,
9,
272,
5445,
275,
5458,
4547,
8,
267,
1978,
63,
354,
534,
9743,
15,
22330,
15,
3710,
63,
1143,
63,
3723,
14,
1360,
297,
267,
503,
271,
6842,
29,
797,
9,
339,
7016,
275,
298,
17205,
2,
272,
19038,
275,
26843,
63,
6395,
3647,
83,
13573,
401,
2071,
83,
23995,
6112,
531,
339,
1021,
6288,
8,
30122,
3186,
14,
3396,
304,
267,
1402,
275,
13573,
267,
1504,
275,
661,
354,
297,
283,
1802,
358,
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,
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
] |
Meriipu/quodlibet
|
tests/plugin/test_console.py
|
4
|
1050
|
# Copyright 2017 Christoph Reiter
#
# 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.
from gi.repository import Gtk
from quodlibet.formats import AudioFile
from quodlibet.util.songwrapper import SongWrapper
from tests.plugin import PluginTestCase
AUDIO_FILE = SongWrapper(AudioFile({'~filename': "/tmp/foobar"}))
class TConsole(PluginTestCase):
def setUp(self):
self.mod = self.modules["Python Console Sidebar"]
def tearDown(self):
del self.mod
def test_sidebar_plugin(self):
plugin = self.mod.PyConsoleSidebar()
plugin.enabled()
self.failUnless(isinstance(plugin.create_sidebar(), Gtk.Widget), True)
plugin.plugin_on_songs_selected([AUDIO_FILE])
self.failUnlessEqual(plugin.console.namespace.get('songs'),
[AUDIO_FILE])
plugin.disabled()
|
gpl-2.0
|
[
3,
1898,
9708,
2799,
322,
2379,
72,
799,
1661,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
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,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
504,
18895,
14,
8421,
492,
11424,
199,
199,
504,
2173,
364,
773,
386,
14,
6321,
492,
30885,
1173,
199,
504,
2173,
364,
773,
386,
14,
1974,
14,
19351,
5029,
492,
29405,
4590,
199,
504,
2295,
14,
2718,
492,
11349,
1746,
199,
199,
27743,
63,
3817,
275,
29405,
4590,
8,
15484,
1173,
3252,
94,
1501,
356,
3286,
2791,
15,
9664,
3570,
430,
421,
199,
533,
377,
9270,
8,
5061,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1494,
275,
291,
14,
3112,
905,
4718,
19809,
428,
2655,
1700,
937,
339,
347,
6766,
8,
277,
304,
267,
2150,
291,
14,
1494,
339,
347,
511,
63,
27372,
63,
2718,
8,
277,
304,
267,
3589,
275,
291,
14,
1494,
14,
2713,
9270,
15414,
1700,
342,
267,
3589,
14,
3827,
342,
267,
291,
14,
7589,
8,
6074,
8,
2718,
14,
981,
63,
27372,
1062,
11424,
14,
3339,
395,
715,
9,
267,
3589,
14,
2718,
63,
265,
63,
834,
458,
63,
5511,
779,
27743,
63,
3817,
566,
267,
291,
14,
14247,
8,
2718,
14,
6614,
14,
3251,
14,
362,
360,
834,
458,
659,
2490,
359,
27743,
63,
3817,
566,
267,
3589,
14,
7011,
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,
32768,
32768,
32768,
32768,
32768,
32768,
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,
9708,
2799,
322,
2379,
72,
799,
1661,
199,
3,
199,
3,
961,
2240,
365,
2867,
2032,
27,
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,
27,
1902,
1015,
499,
402,
314,
844,
12,
503,
199,
3,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
199,
504,
18895,
14,
8421,
492,
11424,
199,
199,
504,
2173,
364,
773,
386,
14,
6321,
492,
30885,
1173,
199,
504,
2173,
364,
773,
386,
14,
1974,
14,
19351,
5029,
492,
29405,
4590,
199,
504,
2295,
14,
2718,
492,
11349,
1746,
199,
199,
27743,
63,
3817,
275,
29405,
4590,
8,
15484,
1173,
3252,
94,
1501,
356,
3286,
2791,
15,
9664,
3570,
430,
421,
199,
533,
377,
9270,
8,
5061,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1494,
275,
291,
14,
3112,
905,
4718,
19809,
428,
2655,
1700,
937,
339,
347,
6766,
8,
277,
304,
267,
2150,
291,
14,
1494,
339,
347,
511,
63,
27372,
63,
2718,
8,
277,
304,
267,
3589,
275,
291,
14,
1494,
14,
2713,
9270,
15414,
1700,
342,
267,
3589,
14,
3827,
342,
267,
291,
14,
7589,
8,
6074,
8,
2718,
14,
981,
63,
27372,
1062,
11424,
14,
3339,
395,
715,
9,
267,
3589,
14,
2718,
63,
265,
63,
834,
458,
63,
5511,
779,
27743,
63,
3817,
566,
267,
291,
14,
14247,
8,
2718,
14,
6614,
14,
3251,
14,
362,
360,
834,
458,
659,
2490,
359,
27743,
63,
3817,
566,
267,
3589,
14,
7011,
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,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
CloudBotIRC/CloudBotLegacy
|
plugins/brainfuck.py
|
6
|
2477
|
"""brainfuck interpreter adapted from (public domain) code at
http://brainfuck.sourceforge.net/brain.py"""
import re
import random
from util import hook
BUFFER_SIZE = 5000
MAX_STEPS = 1000000
@hook.command('brainfuck')
@hook.command
def bf(inp):
"""bf <prog> -- Executes <prog> as Brainfuck code."""
program = re.sub('[^][<>+-.,]', '', inp)
# create a dict of brackets pairs, for speed later on
brackets = {}
open_brackets = []
for pos in range(len(program)):
if program[pos] == '[':
open_brackets.append(pos)
elif program[pos] == ']':
if len(open_brackets) > 0:
brackets[pos] = open_brackets[-1]
brackets[open_brackets[-1]] = pos
open_brackets.pop()
else:
return 'unbalanced brackets'
if len(open_brackets) != 0:
return 'unbalanced brackets'
# now we can start interpreting
ip = 0 # instruction pointer
mp = 0 # memory pointer
steps = 0
memory = [0] * BUFFER_SIZE # initial memory area
rightmost = 0
output = "" # we'll save the output here
# the main program loop:
while ip < len(program):
c = program[ip]
if c == '+':
memory[mp] += 1 % 256
elif c == '-':
memory[mp] -= 1 % 256
elif c == '>':
mp += 1
if mp > rightmost:
rightmost = mp
if mp >= len(memory):
# no restriction on memory growth!
memory.extend([0] * BUFFER_SIZE)
elif c == '<':
mp -= 1 % len(memory)
elif c == '.':
output += chr(memory[mp])
if len(output) > 500:
break
elif c == ',':
memory[mp] = random.randint(1, 255)
elif c == '[':
if memory[mp] == 0:
ip = brackets[ip]
elif c == ']':
if memory[mp] != 0:
ip = brackets[ip]
ip += 1
steps += 1
if steps > MAX_STEPS:
if output == '':
output = '(no output)'
output += '[exceeded {} iterations]'.format(MAX_STEPS)
break
stripped_output = re.sub(r'[\x00-\x1F]', '', output)
if stripped_output == '':
if output != '':
return 'no printable output'
return 'no output'
return stripped_output[:430].decode('utf8', 'ignore')
|
gpl-3.0
|
[
624,
7828,
4904,
10112,
12693,
26266,
687,
334,
3455,
2881,
9,
1233,
737,
199,
1014,
921,
7828,
4904,
10112,
14,
22943,
14,
846,
15,
22246,
14,
647,
624,
199,
199,
646,
295,
199,
646,
2196,
199,
199,
504,
4884,
492,
5759,
421,
199,
10960,
63,
4305,
275,
22369,
199,
4283,
63,
840,
25711,
275,
19492,
421,
199,
32,
3664,
14,
1531,
360,
7828,
4904,
10112,
358,
199,
32,
3664,
14,
1531,
199,
318,
18839,
8,
11416,
304,
272,
408,
4361,
665,
6595,
30,
1553,
9434,
3862,
665,
6595,
30,
465,
32377,
4904,
10112,
1233,
1041,
339,
2240,
275,
295,
14,
954,
360,
4735,
1527,
16137,
16341,
2020,
4300,
3260,
10702,
9,
339,
327,
1218,
282,
1211,
402,
21873,
6342,
12,
367,
8112,
2945,
641,
272,
21873,
275,
1052,
272,
1551,
63,
14594,
83,
275,
942,
272,
367,
2086,
315,
1425,
8,
552,
8,
6815,
2298,
267,
340,
2240,
59,
1712,
61,
508,
6730,
356,
288,
1551,
63,
14594,
83,
14,
740,
8,
1712,
9,
267,
916,
2240,
59,
1712,
61,
508,
24710,
356,
288,
340,
822,
8,
1490,
63,
14594,
83,
9,
690,
378,
26,
355,
21873,
59,
1712,
61,
275,
1551,
63,
14594,
83,
1988,
17,
61,
355,
21873,
59,
1490,
63,
14594,
83,
1988,
17,
2677,
275,
2086,
355,
1551,
63,
14594,
83,
14,
1935,
342,
288,
587,
26,
355,
372,
283,
324,
18923,
21873,
7,
272,
340,
822,
8,
1490,
63,
14594,
83,
9,
1137,
378,
26,
267,
372,
283,
324,
18923,
21873,
7,
339,
327,
3063,
781,
883,
1343,
6421,
1337,
272,
3384,
275,
378,
263,
327,
16329,
7849,
272,
6118,
275,
378,
263,
327,
4402,
7849,
272,
7124,
275,
378,
272,
4402,
275,
359,
16,
61,
627,
699,
8158,
540,
63,
4305,
221,
327,
2536,
4402,
9150,
272,
2451,
2786,
275,
378,
272,
1072,
275,
3087,
257,
327,
781,
7171,
3354,
314,
1072,
2348,
339,
327,
314,
2446,
2240,
4438,
26,
272,
1830,
3384,
665,
822,
8,
6815,
304,
267,
286,
275,
2240,
59,
711,
61,
267,
340,
286,
508,
6681,
356,
288,
4402,
59,
311,
61,
847,
413,
450,
7633,
267,
916,
286,
508,
20905,
288,
4402,
59,
311,
61,
4862,
413,
450,
7633,
267,
916,
286,
508,
12696,
356,
288,
6118,
847,
413,
288,
340,
6118,
690,
2451,
2786,
26,
355,
2451,
2786,
275,
6118,
355,
340,
6118,
2356,
822,
8,
4844,
304,
490,
327,
949,
10588,
641,
4402,
20772,
273,
1,
490,
4402,
14,
2880,
779,
16,
61,
627,
699,
8158,
540,
63,
4305,
9,
267,
916,
286,
508,
2650,
356,
288,
6118,
4862,
413,
450,
822,
8,
4844,
9,
267,
916,
286,
508,
26351,
288,
1072,
847,
8678,
8,
4844,
59,
311,
566,
288,
340,
822,
8,
1199,
9,
690,
6891,
26,
355,
2059,
267,
916,
286,
508,
1656,
356,
288,
4402,
59,
311,
61,
275,
2196,
14,
8393,
8,
17,
12,
5450,
9,
267,
916,
286,
508,
6730,
356,
288,
340,
4402,
59,
311,
61,
508,
378,
26,
355,
3384,
275,
21873,
59,
711,
61,
267,
916,
286,
508,
24710,
356,
288,
340,
4402,
59,
311,
61,
1137,
378,
26,
355,
3384,
275,
21873,
59,
711,
61,
398,
3384,
847,
413,
267,
7124,
847,
413,
267,
340,
7124,
690,
9141,
63,
840,
25711,
26,
288,
340,
1072,
508,
8061,
355,
1072,
275,
8189,
889,
1072,
3171,
288,
1072,
847,
6730,
476,
19750,
1052,
10615,
61,
1370,
908,
8,
4283,
63,
840,
25711,
9,
288,
2059,
339,
14489,
63,
1199,
275,
295,
14,
954,
8,
82,
22123,
88,
383,
2696,
88,
17,
38,
4300,
3260,
1072,
9,
339,
340,
14489,
63,
1199,
508,
8061,
267,
340,
1072,
1137,
8061,
288,
372,
283,
889,
21834,
1072,
7,
267,
372,
283,
889,
1072,
7,
339,
372,
14489,
63,
1199,
1491,
25473,
1055,
2708,
360,
1624,
24,
297,
283,
4247,
358,
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
] |
[
7828,
4904,
10112,
12693,
26266,
687,
334,
3455,
2881,
9,
1233,
737,
199,
1014,
921,
7828,
4904,
10112,
14,
22943,
14,
846,
15,
22246,
14,
647,
624,
199,
199,
646,
295,
199,
646,
2196,
199,
199,
504,
4884,
492,
5759,
421,
199,
10960,
63,
4305,
275,
22369,
199,
4283,
63,
840,
25711,
275,
19492,
421,
199,
32,
3664,
14,
1531,
360,
7828,
4904,
10112,
358,
199,
32,
3664,
14,
1531,
199,
318,
18839,
8,
11416,
304,
272,
408,
4361,
665,
6595,
30,
1553,
9434,
3862,
665,
6595,
30,
465,
32377,
4904,
10112,
1233,
1041,
339,
2240,
275,
295,
14,
954,
360,
4735,
1527,
16137,
16341,
2020,
4300,
3260,
10702,
9,
339,
327,
1218,
282,
1211,
402,
21873,
6342,
12,
367,
8112,
2945,
641,
272,
21873,
275,
1052,
272,
1551,
63,
14594,
83,
275,
942,
272,
367,
2086,
315,
1425,
8,
552,
8,
6815,
2298,
267,
340,
2240,
59,
1712,
61,
508,
6730,
356,
288,
1551,
63,
14594,
83,
14,
740,
8,
1712,
9,
267,
916,
2240,
59,
1712,
61,
508,
24710,
356,
288,
340,
822,
8,
1490,
63,
14594,
83,
9,
690,
378,
26,
355,
21873,
59,
1712,
61,
275,
1551,
63,
14594,
83,
1988,
17,
61,
355,
21873,
59,
1490,
63,
14594,
83,
1988,
17,
2677,
275,
2086,
355,
1551,
63,
14594,
83,
14,
1935,
342,
288,
587,
26,
355,
372,
283,
324,
18923,
21873,
7,
272,
340,
822,
8,
1490,
63,
14594,
83,
9,
1137,
378,
26,
267,
372,
283,
324,
18923,
21873,
7,
339,
327,
3063,
781,
883,
1343,
6421,
1337,
272,
3384,
275,
378,
263,
327,
16329,
7849,
272,
6118,
275,
378,
263,
327,
4402,
7849,
272,
7124,
275,
378,
272,
4402,
275,
359,
16,
61,
627,
699,
8158,
540,
63,
4305,
221,
327,
2536,
4402,
9150,
272,
2451,
2786,
275,
378,
272,
1072,
275,
3087,
257,
327,
781,
7171,
3354,
314,
1072,
2348,
339,
327,
314,
2446,
2240,
4438,
26,
272,
1830,
3384,
665,
822,
8,
6815,
304,
267,
286,
275,
2240,
59,
711,
61,
267,
340,
286,
508,
6681,
356,
288,
4402,
59,
311,
61,
847,
413,
450,
7633,
267,
916,
286,
508,
20905,
288,
4402,
59,
311,
61,
4862,
413,
450,
7633,
267,
916,
286,
508,
12696,
356,
288,
6118,
847,
413,
288,
340,
6118,
690,
2451,
2786,
26,
355,
2451,
2786,
275,
6118,
355,
340,
6118,
2356,
822,
8,
4844,
304,
490,
327,
949,
10588,
641,
4402,
20772,
273,
1,
490,
4402,
14,
2880,
779,
16,
61,
627,
699,
8158,
540,
63,
4305,
9,
267,
916,
286,
508,
2650,
356,
288,
6118,
4862,
413,
450,
822,
8,
4844,
9,
267,
916,
286,
508,
26351,
288,
1072,
847,
8678,
8,
4844,
59,
311,
566,
288,
340,
822,
8,
1199,
9,
690,
6891,
26,
355,
2059,
267,
916,
286,
508,
1656,
356,
288,
4402,
59,
311,
61,
275,
2196,
14,
8393,
8,
17,
12,
5450,
9,
267,
916,
286,
508,
6730,
356,
288,
340,
4402,
59,
311,
61,
508,
378,
26,
355,
3384,
275,
21873,
59,
711,
61,
267,
916,
286,
508,
24710,
356,
288,
340,
4402,
59,
311,
61,
1137,
378,
26,
355,
3384,
275,
21873,
59,
711,
61,
398,
3384,
847,
413,
267,
7124,
847,
413,
267,
340,
7124,
690,
9141,
63,
840,
25711,
26,
288,
340,
1072,
508,
8061,
355,
1072,
275,
8189,
889,
1072,
3171,
288,
1072,
847,
6730,
476,
19750,
1052,
10615,
61,
1370,
908,
8,
4283,
63,
840,
25711,
9,
288,
2059,
339,
14489,
63,
1199,
275,
295,
14,
954,
8,
82,
22123,
88,
383,
2696,
88,
17,
38,
4300,
3260,
1072,
9,
339,
340,
14489,
63,
1199,
508,
8061,
267,
340,
1072,
1137,
8061,
288,
372,
283,
889,
21834,
1072,
7,
267,
372,
283,
889,
1072,
7,
339,
372,
14489,
63,
1199,
1491,
25473,
1055,
2708,
360,
1624,
24,
297,
283,
4247,
358,
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,
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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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
] |
tcarmelveilleux/IcarusAltimeter
|
Analysis/altitude_analysis.py
|
1
|
1202
|
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 14 19:34:31 2015
@author: Tennessee
"""
import numpy as np
import matplotlib.pyplot as plt
def altitude(atm_hpa, sea_level_hpa):
return 44330 * (1.0 - np.power(atm_hpa / sea_level_hpa, 0.1903))
def plot_alt():
default_msl = 101300.0
pressure = np.linspace(97772.58 / 100.0, 79495.0 / 100.0, 2000)
alt_nominal = altitude(pressure, default_msl) - altitude(97772.58 / 100.0, default_msl)
alt_too_high = altitude(pressure, default_msl + (1000 / 100.0)) - altitude(97772.58 / 100.0, default_msl + (1000 / 100.0))
alt_too_low = altitude(pressure, default_msl - (1000 / 100.0)) - altitude(97772.58 / 100.0, default_msl - (1000 / 100.0))
f1 = plt.figure()
ax = f1.gca()
ax.plot(pressure, alt_nominal, "b-", label="nom")
ax.plot(pressure, alt_too_high, "r-", label="high")
ax.plot(pressure, alt_too_low, "g-", label="low")
ax.legend()
f1.show()
f2 = plt.figure()
ax = f2.gca()
ax.plot(pressure, alt_too_high - alt_nominal, "r-", label="high")
ax.plot(pressure, alt_too_low - alt_nominal, "g-", label="low")
ax.legend()
f2.show()
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
199,
10502,
641,
377,
310,
1603,
348,
4329,
5851,
26,
1082,
26,
2192,
6900,
199,
199,
32,
2502,
26,
377,
287,
17775,
3239,
199,
624,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
318,
29534,
8,
292,
77,
63,
72,
387,
12,
29894,
63,
1896,
63,
72,
387,
304,
272,
372,
10868,
14137,
627,
334,
17,
14,
16,
446,
980,
14,
5652,
8,
292,
77,
63,
72,
387,
1182,
29894,
63,
1896,
63,
72,
387,
12,
378,
14,
1167,
1644,
430,
1362,
199,
318,
5137,
63,
4478,
837,
272,
849,
63,
706,
76,
275,
14313,
5863,
14,
16,
2286,
25471,
275,
980,
14,
11649,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
13734,
20384,
14,
16,
1182,
2948,
14,
16,
12,
12293,
9,
272,
8791,
63,
15998,
1582,
275,
29534,
8,
21999,
12,
849,
63,
706,
76,
9,
446,
29534,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
849,
63,
706,
76,
9,
272,
8791,
63,
7354,
63,
6260,
275,
29534,
8,
21999,
12,
849,
63,
706,
76,
435,
334,
5279,
1182,
2948,
14,
16,
430,
446,
29534,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
849,
63,
706,
76,
435,
334,
5279,
1182,
2948,
14,
16,
430,
272,
8791,
63,
7354,
63,
674,
275,
29534,
8,
21999,
12,
849,
63,
706,
76,
446,
334,
5279,
1182,
2948,
14,
16,
430,
446,
29534,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
849,
63,
706,
76,
446,
334,
5279,
1182,
2948,
14,
16,
430,
2286,
289,
17,
275,
4488,
14,
8941,
342,
272,
2185,
275,
289,
17,
14,
71,
696,
342,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
15998,
1582,
12,
298,
66,
13,
401,
1768,
628,
15998,
531,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
6260,
12,
298,
82,
13,
401,
1768,
628,
6260,
531,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
674,
12,
298,
71,
13,
401,
1768,
628,
674,
531,
2286,
2185,
14,
10231,
342,
2286,
289,
17,
14,
2384,
342,
2286,
289,
18,
275,
4488,
14,
8941,
342,
272,
2185,
275,
289,
18,
14,
71,
696,
342,
339,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
6260,
446,
8791,
63,
15998,
1582,
12,
298,
82,
13,
401,
1768,
628,
6260,
531,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
674,
446,
8791,
63,
15998,
1582,
12,
298,
71,
13,
401,
1768,
628,
674,
531,
2286,
2185,
14,
10231,
342,
2286,
289,
18,
14,
2384,
342,
26339,
16872,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
199,
10502,
641,
377,
310,
1603,
348,
4329,
5851,
26,
1082,
26,
2192,
6900,
199,
199,
32,
2502,
26,
377,
287,
17775,
3239,
199,
624,
199,
199,
646,
2680,
465,
980,
199,
646,
8027,
14,
13563,
465,
4488,
199,
199,
318,
29534,
8,
292,
77,
63,
72,
387,
12,
29894,
63,
1896,
63,
72,
387,
304,
272,
372,
10868,
14137,
627,
334,
17,
14,
16,
446,
980,
14,
5652,
8,
292,
77,
63,
72,
387,
1182,
29894,
63,
1896,
63,
72,
387,
12,
378,
14,
1167,
1644,
430,
1362,
199,
318,
5137,
63,
4478,
837,
272,
849,
63,
706,
76,
275,
14313,
5863,
14,
16,
2286,
25471,
275,
980,
14,
11649,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
13734,
20384,
14,
16,
1182,
2948,
14,
16,
12,
12293,
9,
272,
8791,
63,
15998,
1582,
275,
29534,
8,
21999,
12,
849,
63,
706,
76,
9,
446,
29534,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
849,
63,
706,
76,
9,
272,
8791,
63,
7354,
63,
6260,
275,
29534,
8,
21999,
12,
849,
63,
706,
76,
435,
334,
5279,
1182,
2948,
14,
16,
430,
446,
29534,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
849,
63,
706,
76,
435,
334,
5279,
1182,
2948,
14,
16,
430,
272,
8791,
63,
7354,
63,
674,
275,
29534,
8,
21999,
12,
849,
63,
706,
76,
446,
334,
5279,
1182,
2948,
14,
16,
430,
446,
29534,
8,
30605,
2819,
14,
2010,
1182,
2948,
14,
16,
12,
849,
63,
706,
76,
446,
334,
5279,
1182,
2948,
14,
16,
430,
2286,
289,
17,
275,
4488,
14,
8941,
342,
272,
2185,
275,
289,
17,
14,
71,
696,
342,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
15998,
1582,
12,
298,
66,
13,
401,
1768,
628,
15998,
531,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
6260,
12,
298,
82,
13,
401,
1768,
628,
6260,
531,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
674,
12,
298,
71,
13,
401,
1768,
628,
674,
531,
2286,
2185,
14,
10231,
342,
2286,
289,
17,
14,
2384,
342,
2286,
289,
18,
275,
4488,
14,
8941,
342,
272,
2185,
275,
289,
18,
14,
71,
696,
342,
339,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
6260,
446,
8791,
63,
15998,
1582,
12,
298,
82,
13,
401,
1768,
628,
6260,
531,
272,
2185,
14,
2798,
8,
21999,
12,
8791,
63,
7354,
63,
674,
446,
8791,
63,
15998,
1582,
12,
298,
71,
13,
401,
1768,
628,
674,
531,
2286,
2185,
14,
10231,
342,
2286,
289,
18,
14,
2384,
342,
26339,
16872,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
endlessm/chromium-browser
|
third_party/catapult/third_party/typ/typ/tests/stats_test.py
|
84
|
2292
|
# Copyright 2014 Dirk Pranke. 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.
import unittest
from typ.stats import Stats
class TestStats(unittest.TestCase):
def test_basic(self):
s = Stats('foo', lambda: 0, 32)
self.assertEqual(s.format(), 'foo')
def test_edges(self):
s = Stats('[%s/%f/%t/%r/%p]', lambda: 0, 32)
self.assertEqual(s.format(), '[0/0/0/0/-]')
s.started = 3
s.total = 5
s.finished = 1
self.assertEqual(s.format(), '[3/1/5/2/ 60.0]')
s.started = 5
s.finished = 5
self.assertEqual(s.format(), '[5/5/5/0/100.0]')
def test_elapsed_time(self):
times = [0.0, 0.4]
s = Stats('[%e]', lambda: times.pop(0), 32)
self.assertEqual(s.format(), '[0.400]')
s = Stats('[%e]', lambda: 0, 32)
self.assertEqual(s.format(), '[0.000]')
def test_current_rate(self):
times = [0.0, 0.1, 0.2]
s = Stats('[%c]', lambda: times.pop(0), 1)
self.assertEquals(s.format(), '[-]')
s.add_time()
s.add_time()
self.assertEquals(s.format(), '[ 10.0]')
def test_overall_rate(self):
times = [0, 0, 5]
s = Stats('[%o]', lambda: times.pop(0), 32)
self.assertEqual(s.format(), '[-]')
s.started = 3
s.finished = 1
s.total = 5
self.assertEqual(s.format(), '[ 0.2]')
def test_escaped_percent(self):
s = Stats('%%', lambda: 0, 32)
self.assertEqual(s.format(), '%')
def test_unrecognized_escape(self):
s = Stats('%x', lambda: 0, 32)
self.assertEqual(s.format(), '%x')
def test_remaining(self):
s = Stats('%u', lambda: 0, 32)
s.total = 2
self.assertEqual(s.format(), '2')
|
bsd-3-clause
|
[
3,
1898,
6927,
25866,
75,
510,
1312,
415,
14,
2900,
4481,
4644,
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,
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,
199,
646,
2882,
199,
199,
504,
6211,
14,
3200,
492,
29062,
421,
199,
533,
1379,
8257,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4316,
8,
277,
304,
267,
308,
275,
29062,
360,
1421,
297,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
283,
1421,
358,
339,
347,
511,
63,
6929,
8,
277,
304,
267,
308,
275,
29062,
360,
9722,
83,
3149,
70,
3149,
84,
3149,
82,
3149,
80,
4300,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
16,
15,
16,
15,
16,
15,
16,
22551,
10374,
267,
308,
14,
8924,
275,
650,
267,
308,
14,
2923,
275,
959,
267,
308,
14,
8669,
275,
413,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
19,
15,
17,
15,
21,
15,
18,
15,
5212,
14,
16,
10374,
398,
308,
14,
8924,
275,
959,
267,
308,
14,
8669,
275,
959,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
21,
15,
21,
15,
21,
15,
16,
15,
1960,
14,
16,
10374,
339,
347,
511,
63,
16691,
63,
521,
8,
277,
304,
267,
5431,
275,
359,
16,
14,
16,
12,
378,
14,
20,
61,
267,
308,
275,
29062,
360,
9722,
69,
4300,
2400,
26,
5431,
14,
1935,
8,
16,
395,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
16,
14,
5303,
10374,
398,
308,
275,
29062,
360,
9722,
69,
4300,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
16,
14,
1493,
10374,
339,
347,
511,
63,
1818,
63,
1866,
8,
277,
304,
267,
5431,
275,
359,
16,
14,
16,
12,
378,
14,
17,
12,
378,
14,
18,
61,
267,
308,
275,
29062,
360,
9722,
67,
4300,
2400,
26,
5431,
14,
1935,
8,
16,
395,
413,
9,
267,
291,
14,
2947,
8,
83,
14,
908,
1062,
283,
1988,
10374,
267,
308,
14,
525,
63,
521,
342,
267,
308,
14,
525,
63,
521,
342,
267,
291,
14,
2947,
8,
83,
14,
908,
1062,
6730,
1616,
14,
16,
10374,
339,
347,
511,
63,
1883,
452,
63,
1866,
8,
277,
304,
267,
5431,
275,
359,
16,
12,
378,
12,
959,
61,
267,
308,
275,
29062,
360,
9722,
79,
4300,
2400,
26,
5431,
14,
1935,
8,
16,
395,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
283,
1988,
10374,
267,
308,
14,
8924,
275,
650,
267,
308,
14,
8669,
275,
413,
267,
308,
14,
2923,
275,
959,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
221,
378,
14,
18,
10374,
339,
347,
511,
63,
13572,
63,
7045,
8,
277,
304,
267,
308,
275,
29062,
3508,
28575,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
1543,
358,
339,
347,
511,
63,
324,
13221,
63,
3765,
8,
277,
304,
267,
308,
275,
29062,
3508,
88,
297,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
1543,
88,
358,
339,
347,
511,
63,
11266,
8,
277,
304,
267,
308,
275,
29062,
3508,
85,
297,
2400,
26,
378,
12,
4337,
9,
267,
308,
14,
2923,
275,
499,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
283,
18,
358,
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
] |
[
1898,
6927,
25866,
75,
510,
1312,
415,
14,
2900,
4481,
4644,
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,
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,
199,
646,
2882,
199,
199,
504,
6211,
14,
3200,
492,
29062,
421,
199,
533,
1379,
8257,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4316,
8,
277,
304,
267,
308,
275,
29062,
360,
1421,
297,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
283,
1421,
358,
339,
347,
511,
63,
6929,
8,
277,
304,
267,
308,
275,
29062,
360,
9722,
83,
3149,
70,
3149,
84,
3149,
82,
3149,
80,
4300,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
16,
15,
16,
15,
16,
15,
16,
22551,
10374,
267,
308,
14,
8924,
275,
650,
267,
308,
14,
2923,
275,
959,
267,
308,
14,
8669,
275,
413,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
19,
15,
17,
15,
21,
15,
18,
15,
5212,
14,
16,
10374,
398,
308,
14,
8924,
275,
959,
267,
308,
14,
8669,
275,
959,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
21,
15,
21,
15,
21,
15,
16,
15,
1960,
14,
16,
10374,
339,
347,
511,
63,
16691,
63,
521,
8,
277,
304,
267,
5431,
275,
359,
16,
14,
16,
12,
378,
14,
20,
61,
267,
308,
275,
29062,
360,
9722,
69,
4300,
2400,
26,
5431,
14,
1935,
8,
16,
395,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
16,
14,
5303,
10374,
398,
308,
275,
29062,
360,
9722,
69,
4300,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
16,
14,
1493,
10374,
339,
347,
511,
63,
1818,
63,
1866,
8,
277,
304,
267,
5431,
275,
359,
16,
14,
16,
12,
378,
14,
17,
12,
378,
14,
18,
61,
267,
308,
275,
29062,
360,
9722,
67,
4300,
2400,
26,
5431,
14,
1935,
8,
16,
395,
413,
9,
267,
291,
14,
2947,
8,
83,
14,
908,
1062,
283,
1988,
10374,
267,
308,
14,
525,
63,
521,
342,
267,
308,
14,
525,
63,
521,
342,
267,
291,
14,
2947,
8,
83,
14,
908,
1062,
6730,
1616,
14,
16,
10374,
339,
347,
511,
63,
1883,
452,
63,
1866,
8,
277,
304,
267,
5431,
275,
359,
16,
12,
378,
12,
959,
61,
267,
308,
275,
29062,
360,
9722,
79,
4300,
2400,
26,
5431,
14,
1935,
8,
16,
395,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
283,
1988,
10374,
267,
308,
14,
8924,
275,
650,
267,
308,
14,
8669,
275,
413,
267,
308,
14,
2923,
275,
959,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
6730,
221,
378,
14,
18,
10374,
339,
347,
511,
63,
13572,
63,
7045,
8,
277,
304,
267,
308,
275,
29062,
3508,
28575,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
1543,
358,
339,
347,
511,
63,
324,
13221,
63,
3765,
8,
277,
304,
267,
308,
275,
29062,
3508,
88,
297,
2400,
26,
378,
12,
4337,
9,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
1543,
88,
358,
339,
347,
511,
63,
11266,
8,
277,
304,
267,
308,
275,
29062,
3508,
85,
297,
2400,
26,
378,
12,
4337,
9,
267,
308,
14,
2923,
275,
499,
267,
291,
14,
629,
8,
83,
14,
908,
1062,
283,
18,
358,
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,
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
] |
clef/python-social-auth
|
social/tests/backends/test_azuread.py
|
58
|
3180
|
"""
Copyright (c) 2015 Microsoft Open Technologies, Inc.
All rights reserved.
MIT License
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 json
from social.tests.backends.oauth import OAuth2Test
class AzureADOAuth2Test(OAuth2Test):
backend_path = 'social.backends.azuread.AzureADOAuth2'
user_data_url = 'https://graph.windows.net/me'
expected_username = 'foobar'
access_token_body = json.dumps({
'access_token': 'foobar',
'token_type': 'bearer',
'id_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL'
'3N0cy53aW5kb3dzLm5ldC83Mjc0MDZhYy03MDY4LTQ4ZmEtOTJiOS1jMmQ'
'2NzIxMWJjNTAvIiwiaWF0IjpudWxsLCJleHAiOm51bGwsImF1ZCI6IjAyO'
'WNjMDEwLWJiNzQtNGQyYi1hMDQwLWY5Y2VkM2ZkMmM3NiIsInN1YiI6In'
'FVOHhrczltSHFuVjZRMzR6aDdTQVpvY2loOUV6cnJJOW1wVlhPSWJWQTg'
'iLCJ2ZXIiOiIxLjAiLCJ0aWQiOiI3Mjc0MDZhYy03MDY4LTQ4ZmEtOTJi'
'OS1jMmQ2NzIxMWJjNTAiLCJvaWQiOiI3ZjhlMTk2OS04YjgxLTQzOGMtO'
'GQ0ZS1hZDZmNTYyYjI4YmIiLCJ1cG4iOiJmb29iYXJAdGVzdC5vbm1pY3'
'Jvc29mdC5jb20iLCJnaXZlbl9uYW1lIjoiZm9vIiwiZmFtaWx5X25hbWU'
'iOiJiYXIiLCJuYW1lIjoiZm9vIGJhciIsInVuaXF1ZV9uYW1lIjoiZm9v'
'YmFyQHRlc3Qub25taWNyb3NvZnQuY29tIiwicHdkX2V4cCI6IjQ3MzMwO'
'TY4IiwicHdkX3VybCI6Imh0dHBzOi8vcG9ydGFsLm1pY3Jvc29mdG9ubG'
'luZS5jb20vQ2hhbmdlUGFzc3dvcmQuYXNweCJ9.3V50dHXTZOHj9UWtkn'
'2g7BjX5JxNe8skYlK4PdhiLz4',
'expires_in': 3600,
'expires_on': 1423650396,
'not_before': 1423646496
})
refresh_token_body = json.dumps({
'access_token': 'foobar-new-token',
'token_type': 'bearer',
'expires_in': 3600,
'refresh_token': 'foobar-new-refresh-token',
'scope': 'identity'
})
def test_login(self):
self.do_login()
def test_partial_pipeline(self):
self.do_partial_pipeline()
def test_refresh_token(self):
user, social = self.do_refresh_token()
self.assertEqual(social.extra_data['access_token'], 'foobar-new-token')
|
bsd-3-clause
|
[
624,
199,
7384,
334,
67,
9,
6900,
15332,
3232,
19215,
12,
3277,
14,
199,
199,
2422,
4481,
4644,
14,
199,
199,
13965,
844,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
1006,
199,
16847,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
26734,
14,
199,
624,
199,
199,
646,
2022,
199,
199,
504,
20295,
14,
2219,
14,
7765,
14,
6126,
492,
11715,
18,
774,
421,
199,
533,
15474,
1554,
12906,
18,
774,
8,
12906,
18,
774,
304,
272,
4865,
63,
515,
275,
283,
13574,
14,
7765,
14,
9078,
350,
14,
22386,
1554,
12906,
18,
7,
272,
922,
63,
576,
63,
633,
275,
283,
2859,
921,
2180,
14,
8258,
14,
846,
15,
278,
7,
272,
1420,
63,
2473,
275,
283,
9664,
7,
272,
2879,
63,
1418,
63,
2030,
275,
2022,
14,
4180,
2561,
267,
283,
2732,
63,
1418,
356,
283,
9664,
297,
267,
283,
1418,
63,
466,
356,
283,
1235,
21462,
297,
267,
283,
344,
63,
1418,
356,
283,
14655,
42,
16,
69,
56,
28960,
47,
73,
25575,
54,
17,
19910,
7027,
42,
16168,
39,
559,
47,
73,
32126,
53,
90,
41,
17,
20959,
42,
25,
14,
14655,
42,
2352,
19,
14738,
47,
73,
42,
364,
14784,
13683,
90,
8822,
44,
7,
490,
283,
19,
46,
16,
1480,
2481,
19098,
21,
7862,
19,
17019,
23041,
21,
1447,
35,
2658,
20958,
67,
16,
5127,
12674,
30694,
1644,
5127,
57,
20,
17090,
49,
20,
26467,
37,
84,
1387,
16911,
3100,
17,
74,
28171,
49,
7,
490,
283,
18,
23406,
41,
88,
32726,
42,
74,
46,
6166,
86,
31105,
87,
4674,
29046,
16,
41,
11538,
1181,
55,
7977,
7027,
42,
274,
6294,
73,
29197,
2869,
66,
39,
3569,
16221,
38,
17,
58,
3553,
22,
41,
74,
33,
89,
47,
7,
490,
283,
3705,
74,
45,
1093,
87,
20145,
16911,
23406,
4238,
12259,
49,
89,
21001,
17,
72,
5127,
49,
87,
20145,
57,
21,
57,
18,
54,
75,
45,
18,
58,
75,
28171,
45,
19,
20959,
1831,
607,
46,
17,
21001,
41,
22,
607,
7,
490,
283,
38,
10662,
23626,
1195,
90,
4116,
3234,
19590,
54,
74,
58,
11026,
90,
50,
22,
65,
36,
19772,
25527,
1381,
57,
18,
320,
47,
15110,
22,
6413,
42,
15465,
55,
17,
87,
54,
25514,
5067,
55,
42,
55,
19229,
71,
7,
490,
283,
73,
7027,
42,
18,
15473,
31105,
47,
73,
41,
88,
15573,
28960,
7027,
42,
16,
19098,
19910,
47,
73,
41,
19,
20958,
67,
16,
5127,
12674,
30694,
1644,
5127,
57,
20,
17090,
49,
20,
26467,
37,
84,
1387,
16911,
7,
490,
283,
3100,
17,
74,
28171,
49,
18,
23406,
41,
88,
32726,
42,
74,
46,
6166,
73,
7027,
42,
3042,
55,
19910,
47,
73,
41,
19,
58,
74,
15544,
5747,
75,
18,
3100,
966,
57,
74,
20777,
17090,
49,
90,
14008,
45,
84,
47,
7,
490,
283,
39,
49,
16,
26697,
17,
72,
58,
36,
26467,
46,
2099,
89,
57,
74,
41,
20,
57,
77,
31105,
7027,
42,
17,
67,
39,
20,
73,
47,
73,
42,
887,
1398,
73,
16936,
42,
2767,
14876,
23670,
35,
21,
86,
12648,
17,
80,
57,
19,
7,
490,
283,
42,
6737,
1398,
1064,
35,
21,
26257,
1165,
73,
7027,
42,
3540,
56,
58,
18842,
25,
85,
20207,
17,
76,
41,
743,
73,
26467,
25,
86,
31105,
14249,
26467,
38,
502,
55,
88,
21,
56,
821,
16168,
55,
53,
7,
490,
283,
73,
47,
73,
16911,
16936,
31105,
7027,
24783,
20207,
17,
76,
41,
743,
73,
26467,
25,
86,
1277,
42,
72,
559,
1831,
607,
54,
1458,
25145,
17,
58,
54,
25,
85,
20207,
17,
76,
41,
743,
73,
26467,
25,
86,
7,
490,
283,
57,
77,
30559,
49,
14784,
10181,
19,
49,
456,
821,
502,
3705,
28564,
19,
46,
86,
26713,
2371,
57,
1398,
84,
31105,
87,
530,
40,
6341,
56,
18,
54,
20,
67,
3553,
22,
41,
74,
49,
19,
23332,
45,
87,
47,
7,
490,
283,
2099,
20,
31105,
87,
530,
40,
6341,
56,
19,
54,
28564,
3553,
22,
16221,
72,
16,
68,
25262,
90,
47,
73,
24,
6737,
39,
25,
24503,
17395,
83,
23041,
17,
80,
57,
19,
42,
6737,
1398,
1064,
39,
25,
456,
39,
7,
490,
283,
10836,
26697,
21,
26257,
1165,
86,
49,
18,
12156,
66,
1064,
76,
10134,
38,
26698,
19,
8398,
4400,
2371,
16936,
46,
1129,
35,
42,
25,
14,
19,
54,
1400,
68,
40,
56,
14226,
30454,
74,
25,
53,
55,
2663,
78,
7,
490,
283,
18,
71,
23,
34,
74,
56,
21,
21968,
4698,
24,
1339,
57,
76,
43,
20,
48,
68,
5812,
44,
90,
20,
297,
267,
283,
12342,
63,
262,
356,
15751,
12,
267,
283,
12342,
63,
265,
356,
31308,
1344,
1400,
13443,
12,
267,
283,
1397,
63,
5182,
356,
4329,
1789,
21336,
2534,
272,
3828,
272,
9236,
63,
1418,
63,
2030,
275,
2022,
14,
4180,
2561,
267,
283,
2732,
63,
1418,
356,
283,
9664,
13,
1222,
13,
1418,
297,
267,
283,
1418,
63,
466,
356,
283,
1235,
21462,
297,
267,
283,
12342,
63,
262,
356,
15751,
12,
267,
283,
6635,
63,
1418,
356,
283,
9664
] |
[
199,
7384,
334,
67,
9,
6900,
15332,
3232,
19215,
12,
3277,
14,
199,
199,
2422,
4481,
4644,
14,
199,
199,
13965,
844,
199,
199,
7980,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
1618,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
262,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
475,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
16847,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
70,
13399,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
199,
1918,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
1006,
199,
16847,
503,
13393,
12468,
402,
314,
2290,
14,
199,
199,
18061,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
8947,
5177,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
38,
3061,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
5580,
4149,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
2673,
2477,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
1877,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
26734,
14,
199,
624,
199,
199,
646,
2022,
199,
199,
504,
20295,
14,
2219,
14,
7765,
14,
6126,
492,
11715,
18,
774,
421,
199,
533,
15474,
1554,
12906,
18,
774,
8,
12906,
18,
774,
304,
272,
4865,
63,
515,
275,
283,
13574,
14,
7765,
14,
9078,
350,
14,
22386,
1554,
12906,
18,
7,
272,
922,
63,
576,
63,
633,
275,
283,
2859,
921,
2180,
14,
8258,
14,
846,
15,
278,
7,
272,
1420,
63,
2473,
275,
283,
9664,
7,
272,
2879,
63,
1418,
63,
2030,
275,
2022,
14,
4180,
2561,
267,
283,
2732,
63,
1418,
356,
283,
9664,
297,
267,
283,
1418,
63,
466,
356,
283,
1235,
21462,
297,
267,
283,
344,
63,
1418,
356,
283,
14655,
42,
16,
69,
56,
28960,
47,
73,
25575,
54,
17,
19910,
7027,
42,
16168,
39,
559,
47,
73,
32126,
53,
90,
41,
17,
20959,
42,
25,
14,
14655,
42,
2352,
19,
14738,
47,
73,
42,
364,
14784,
13683,
90,
8822,
44,
7,
490,
283,
19,
46,
16,
1480,
2481,
19098,
21,
7862,
19,
17019,
23041,
21,
1447,
35,
2658,
20958,
67,
16,
5127,
12674,
30694,
1644,
5127,
57,
20,
17090,
49,
20,
26467,
37,
84,
1387,
16911,
3100,
17,
74,
28171,
49,
7,
490,
283,
18,
23406,
41,
88,
32726,
42,
74,
46,
6166,
86,
31105,
87,
4674,
29046,
16,
41,
11538,
1181,
55,
7977,
7027,
42,
274,
6294,
73,
29197,
2869,
66,
39,
3569,
16221,
38,
17,
58,
3553,
22,
41,
74,
33,
89,
47,
7,
490,
283,
3705,
74,
45,
1093,
87,
20145,
16911,
23406,
4238,
12259,
49,
89,
21001,
17,
72,
5127,
49,
87,
20145,
57,
21,
57,
18,
54,
75,
45,
18,
58,
75,
28171,
45,
19,
20959,
1831,
607,
46,
17,
21001,
41,
22,
607,
7,
490,
283,
38,
10662,
23626,
1195,
90,
4116,
3234,
19590,
54,
74,
58,
11026,
90,
50,
22,
65,
36,
19772,
25527,
1381,
57,
18,
320,
47,
15110,
22,
6413,
42,
15465,
55,
17,
87,
54,
25514,
5067,
55,
42,
55,
19229,
71,
7,
490,
283,
73,
7027,
42,
18,
15473,
31105,
47,
73,
41,
88,
15573,
28960,
7027,
42,
16,
19098,
19910,
47,
73,
41,
19,
20958,
67,
16,
5127,
12674,
30694,
1644,
5127,
57,
20,
17090,
49,
20,
26467,
37,
84,
1387,
16911,
7,
490,
283,
3100,
17,
74,
28171,
49,
18,
23406,
41,
88,
32726,
42,
74,
46,
6166,
73,
7027,
42,
3042,
55,
19910,
47,
73,
41,
19,
58,
74,
15544,
5747,
75,
18,
3100,
966,
57,
74,
20777,
17090,
49,
90,
14008,
45,
84,
47,
7,
490,
283,
39,
49,
16,
26697,
17,
72,
58,
36,
26467,
46,
2099,
89,
57,
74,
41,
20,
57,
77,
31105,
7027,
42,
17,
67,
39,
20,
73,
47,
73,
42,
887,
1398,
73,
16936,
42,
2767,
14876,
23670,
35,
21,
86,
12648,
17,
80,
57,
19,
7,
490,
283,
42,
6737,
1398,
1064,
35,
21,
26257,
1165,
73,
7027,
42,
3540,
56,
58,
18842,
25,
85,
20207,
17,
76,
41,
743,
73,
26467,
25,
86,
31105,
14249,
26467,
38,
502,
55,
88,
21,
56,
821,
16168,
55,
53,
7,
490,
283,
73,
47,
73,
16911,
16936,
31105,
7027,
24783,
20207,
17,
76,
41,
743,
73,
26467,
25,
86,
1277,
42,
72,
559,
1831,
607,
54,
1458,
25145,
17,
58,
54,
25,
85,
20207,
17,
76,
41,
743,
73,
26467,
25,
86,
7,
490,
283,
57,
77,
30559,
49,
14784,
10181,
19,
49,
456,
821,
502,
3705,
28564,
19,
46,
86,
26713,
2371,
57,
1398,
84,
31105,
87,
530,
40,
6341,
56,
18,
54,
20,
67,
3553,
22,
41,
74,
49,
19,
23332,
45,
87,
47,
7,
490,
283,
2099,
20,
31105,
87,
530,
40,
6341,
56,
19,
54,
28564,
3553,
22,
16221,
72,
16,
68,
25262,
90,
47,
73,
24,
6737,
39,
25,
24503,
17395,
83,
23041,
17,
80,
57,
19,
42,
6737,
1398,
1064,
39,
25,
456,
39,
7,
490,
283,
10836,
26697,
21,
26257,
1165,
86,
49,
18,
12156,
66,
1064,
76,
10134,
38,
26698,
19,
8398,
4400,
2371,
16936,
46,
1129,
35,
42,
25,
14,
19,
54,
1400,
68,
40,
56,
14226,
30454,
74,
25,
53,
55,
2663,
78,
7,
490,
283,
18,
71,
23,
34,
74,
56,
21,
21968,
4698,
24,
1339,
57,
76,
43,
20,
48,
68,
5812,
44,
90,
20,
297,
267,
283,
12342,
63,
262,
356,
15751,
12,
267,
283,
12342,
63,
265,
356,
31308,
1344,
1400,
13443,
12,
267,
283,
1397,
63,
5182,
356,
4329,
1789,
21336,
2534,
272,
3828,
272,
9236,
63,
1418,
63,
2030,
275,
2022,
14,
4180,
2561,
267,
283,
2732,
63,
1418,
356,
283,
9664,
13,
1222,
13,
1418,
297,
267,
283,
1418,
63,
466,
356,
283,
1235,
21462,
297,
267,
283,
12342,
63,
262,
356,
15751,
12,
267,
283,
6635,
63,
1418,
356,
283,
9664,
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
] |
SmartPeople/zulip
|
zerver/webhooks/zapier/view.py
|
14
|
1068
|
from __future__ import absolute_import
from django.utils.translation import ugettext as _
from typing import Any, Callable, Dict
from django.http import HttpRequest, HttpResponse
from zerver.lib.actions import check_send_message
from zerver.lib.response import json_success, json_error
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile, Client
@api_key_only_webhook_view('Zapier')
@has_request_variables
def api_zapier_webhook(request, user_profile, client,
payload=REQ(argument_type='body'),
stream=REQ(default='zapier')):
# type: (HttpRequest, UserProfile, Client, Dict[str, Any], str) -> HttpResponse
subject = payload.get('subject')
content = payload.get('content')
if subject is None:
return json_error(_("Subject can't be empty"))
if content is None:
return json_error(_("Content can't be empty"))
check_send_message(user_profile, client, "stream", [stream], subject, content)
return json_success()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
14090,
492,
6184,
12,
16975,
12,
7448,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
199,
504,
19959,
14,
773,
14,
3723,
492,
1104,
63,
2254,
63,
1188,
199,
504,
19959,
14,
773,
14,
1310,
492,
2022,
63,
3742,
12,
2022,
63,
705,
199,
504,
19959,
14,
11547,
492,
5363,
49,
12,
965,
63,
1069,
63,
3669,
12,
2986,
63,
498,
63,
2118,
63,
22944,
63,
1345,
199,
504,
19959,
14,
992,
492,
19037,
12,
6810,
421,
199,
32,
1246,
63,
498,
63,
2118,
63,
22944,
63,
1345,
360,
58,
1246,
281,
358,
199,
32,
1989,
63,
1069,
63,
3669,
199,
318,
2986,
63,
21059,
281,
63,
22944,
8,
1069,
12,
922,
63,
2913,
12,
1890,
12,
2432,
4886,
29,
14583,
8,
2094,
63,
466,
534,
2030,
659,
2432,
2547,
29,
14583,
8,
885,
534,
21059,
281,
8109,
272,
327,
730,
26,
334,
10441,
12,
19037,
12,
6810,
12,
7448,
59,
495,
12,
6184,
467,
620,
9,
1035,
6183,
272,
5420,
275,
4886,
14,
362,
360,
5875,
358,
272,
1564,
275,
4886,
14,
362,
360,
1317,
358,
272,
340,
5420,
365,
488,
26,
267,
372,
2022,
63,
705,
6115,
13528,
883,
1133,
506,
2701,
2237,
272,
340,
1564,
365,
488,
26,
267,
372,
2022,
63,
705,
6115,
2714,
883,
1133,
506,
2701,
2237,
272,
1104,
63,
2254,
63,
1188,
8,
751,
63,
2913,
12,
1890,
12,
298,
1745,
401,
359,
1745,
467,
5420,
12,
1564,
9,
272,
372,
2022,
63,
3742,
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,
32768,
32768,
32768,
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,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
14090,
492,
6184,
12,
16975,
12,
7448,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
199,
504,
19959,
14,
773,
14,
3723,
492,
1104,
63,
2254,
63,
1188,
199,
504,
19959,
14,
773,
14,
1310,
492,
2022,
63,
3742,
12,
2022,
63,
705,
199,
504,
19959,
14,
11547,
492,
5363,
49,
12,
965,
63,
1069,
63,
3669,
12,
2986,
63,
498,
63,
2118,
63,
22944,
63,
1345,
199,
504,
19959,
14,
992,
492,
19037,
12,
6810,
421,
199,
32,
1246,
63,
498,
63,
2118,
63,
22944,
63,
1345,
360,
58,
1246,
281,
358,
199,
32,
1989,
63,
1069,
63,
3669,
199,
318,
2986,
63,
21059,
281,
63,
22944,
8,
1069,
12,
922,
63,
2913,
12,
1890,
12,
2432,
4886,
29,
14583,
8,
2094,
63,
466,
534,
2030,
659,
2432,
2547,
29,
14583,
8,
885,
534,
21059,
281,
8109,
272,
327,
730,
26,
334,
10441,
12,
19037,
12,
6810,
12,
7448,
59,
495,
12,
6184,
467,
620,
9,
1035,
6183,
272,
5420,
275,
4886,
14,
362,
360,
5875,
358,
272,
1564,
275,
4886,
14,
362,
360,
1317,
358,
272,
340,
5420,
365,
488,
26,
267,
372,
2022,
63,
705,
6115,
13528,
883,
1133,
506,
2701,
2237,
272,
340,
1564,
365,
488,
26,
267,
372,
2022,
63,
705,
6115,
2714,
883,
1133,
506,
2701,
2237,
272,
1104,
63,
2254,
63,
1188,
8,
751,
63,
2913,
12,
1890,
12,
298,
1745,
401,
359,
1745,
467,
5420,
12,
1564,
9,
272,
372,
2022,
63,
3742,
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,
32768,
32768,
32768,
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,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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
] |
tokenly/counterparty-lib
|
counterpartylib/test/conftest.py
|
2
|
5555
|
#! /usr/bin/python3
"""
Test suite configuration
"""
import os
import sys
current_dir = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
base_dir = os.path.normpath(os.path.join(current_dir, '../../'))
sys.path.insert(0, base_dir)
import json, binascii, apsw
from datetime import datetime
import pytest, util_test
from fixtures.vectors import UNITTEST_VECTOR
from fixtures.params import DEFAULT_PARAMS
from fixtures.scenarios import INTEGRATION_SCENARIOS
from counterpartylib.lib import config, util, backend, transaction
import bitcoin as bitcoinlib
import bitcoin.rpc as bitcoinlib_rpc
def pytest_collection_modifyitems(session, config, items):
"""Run contracts_test.py last."""
items[:] = list(reversed(items))
def pytest_generate_tests(metafunc):
"""Generate all py.test cases. Checks for different types of tests and creates proper context."""
if metafunc.function.__name__ == 'test_vector':
args = util_test.vector_to_args(UNITTEST_VECTOR, pytest.config.option.function)
metafunc.parametrize('tx_name, method, inputs, outputs, error, records', args)
elif metafunc.function.__name__ == 'test_scenario':
args = []
for scenario_name in INTEGRATION_SCENARIOS:
if pytest.config.option.scenario == [] or scenario_name in pytest.config.option.scenario:
args.append((scenario_name, INTEGRATION_SCENARIOS[scenario_name][1], INTEGRATION_SCENARIOS[scenario_name][0]))
metafunc.parametrize('scenario_name, base_scenario_name, transactions', args)
elif metafunc.function.__name__ == 'test_book':
if pytest.config.option.skiptestbook == 'all':
args = []
elif pytest.config.option.skiptestbook == 'testnet':
args = [False]
elif pytest.config.option.skiptestbook == 'mainnet':
args = [True]
else:
args = [True, False]
metafunc.parametrize('testnet', args)
def pytest_addoption(parser):
"""Add useful test suite argument options."""
parser.addoption("--function", action="append", default=[], help="list of functions to test")
parser.addoption("--scenario", action="append", default=[], help="list of scenarios to test")
parser.addoption("--gentxhex", action='store_true', default=False, help="generate and print unsigned hex for *.compose() tests")
parser.addoption("--savescenarios", action='store_true', default=False, help="generate sql dump and log in .new files")
parser.addoption("--skiptestbook", default='no', help="skip test book(s) (use with one of the following values: `all`, `testnet` or `mainnet`)")
@pytest.fixture(scope="module")
def rawtransactions_db(request):
"""Return a database object."""
db = apsw.Connection(util_test.CURR_DIR + '/fixtures/rawtransactions.db')
if (request.module.__name__ == 'integration_test'):
util_test.initialise_rawtransactions_db(db)
return db
@pytest.fixture(autouse=True)
def init_mock_functions(monkeypatch, rawtransactions_db):
"""Test suit mock functions.
Mock functions override default behaviour to allow test suit to work - for instance, date_passed is overwritten
so that every date will pass. Those are available to every test function in this suite."""
util_test.rawtransactions_db = rawtransactions_db
def get_unspent_txouts(address, unconfirmed=False, multisig_inputs=False):
with open(util_test.CURR_DIR + '/fixtures/unspent_outputs.json', 'r') as listunspent_test_file:
wallet_unspent = json.load(listunspent_test_file)
unspent_txouts = [output for output in wallet_unspent if output['address'] == address]
return unspent_txouts
def isodt(epoch_time):
return datetime.utcfromtimestamp(epoch_time).isoformat()
def curr_time():
return 0
def date_passed(date):
return False
def init_api_access_log():
pass
def pubkeyhash_to_pubkey(address, provided_pubkeys=None):
return DEFAULT_PARAMS['pubkey'][address]
def multisig_pubkeyhashes_to_pubkeys(address, provided_pubkeys=None):
# TODO: Should be updated?!
array = address.split('_')
signatures_required = int(array[0])
pubkeyhashes = array[1:-1]
pubkeys = [DEFAULT_PARAMS['pubkey'][pubkeyhash] for pubkeyhash in pubkeyhashes]
address = '_'.join([str(signatures_required)] + sorted(pubkeys) + [str(len(pubkeys))])
return address
def get_cached_raw_transaction(tx_hash, verbose=False):
return util_test.getrawtransaction(rawtransactions_db, bitcoinlib.core.lx(tx_hash))
util.CURRENT_BLOCK_INDEX = DEFAULT_PARAMS['default_block'] - 1
monkeypatch.setattr('counterpartylib.lib.backend.get_unspent_txouts', get_unspent_txouts)
monkeypatch.setattr('counterpartylib.lib.log.isodt', isodt)
monkeypatch.setattr('counterpartylib.lib.log.curr_time', curr_time)
monkeypatch.setattr('counterpartylib.lib.util.date_passed', date_passed)
monkeypatch.setattr('counterpartylib.lib.api.init_api_access_log', init_api_access_log)
if hasattr(config, 'PREFIX'):
monkeypatch.setattr('counterpartylib.lib.config.PREFIX', b'TESTXXXX')
monkeypatch.setattr('counterpartylib.lib.backend.getrawtransaction', get_cached_raw_transaction)
monkeypatch.setattr('counterpartylib.lib.backend.pubkeyhash_to_pubkey', pubkeyhash_to_pubkey)
monkeypatch.setattr('counterpartylib.lib.backend.multisig_pubkeyhashes_to_pubkeys', multisig_pubkeyhashes_to_pubkeys)
|
mit
|
[
3168,
1182,
2647,
15,
1393,
15,
1548,
19,
199,
199,
624,
199,
774,
5241,
2897,
199,
624,
199,
199,
646,
747,
199,
646,
984,
199,
199,
1818,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
8,
736,
14,
515,
14,
904,
8,
736,
14,
9458,
1062,
747,
14,
515,
14,
12131,
3460,
493,
363,
7845,
199,
1095,
63,
694,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
1818,
63,
694,
12,
283,
9707,
1333,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
1300,
63,
694,
9,
199,
199,
646,
2022,
12,
14755,
12,
282,
1190,
87,
199,
504,
2197,
492,
2197,
199,
199,
646,
4613,
12,
4884,
63,
396,
199,
199,
504,
15188,
14,
12280,
492,
25836,
2864,
63,
2524,
1028,
726,
199,
504,
15188,
14,
1162,
492,
6186,
63,
17978,
199,
504,
15188,
14,
32225,
492,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
199,
199,
504,
7055,
7522,
773,
14,
773,
492,
1101,
12,
4884,
12,
4865,
12,
6008,
199,
199,
646,
27214,
465,
27214,
773,
199,
646,
27214,
14,
4354,
465,
27214,
773,
63,
4354,
199,
199,
318,
4613,
63,
3627,
63,
8951,
1744,
8,
1730,
12,
1101,
12,
2974,
304,
272,
408,
2540,
18782,
3021,
63,
396,
14,
647,
2061,
1041,
272,
2974,
5873,
275,
769,
8,
13501,
8,
1744,
430,
199,
199,
318,
4613,
63,
4208,
63,
2219,
8,
2024,
1532,
304,
272,
408,
6864,
1006,
1134,
14,
396,
5560,
14,
13813,
367,
3365,
2943,
402,
2295,
436,
8491,
5576,
1067,
1041,
272,
340,
3404,
1532,
14,
1593,
855,
354,
363,
508,
283,
396,
63,
4106,
356,
267,
1249,
275,
4884,
63,
396,
14,
4106,
63,
475,
63,
589,
8,
15505,
2864,
63,
2524,
1028,
726,
12,
4613,
14,
888,
14,
1422,
14,
1593,
9,
267,
3404,
1532,
14,
10396,
360,
2347,
63,
354,
12,
1083,
12,
4153,
12,
4704,
12,
1125,
12,
5767,
297,
1249,
9,
272,
916,
3404,
1532,
14,
1593,
855,
354,
363,
508,
283,
396,
63,
13444,
356,
267,
1249,
275,
942,
267,
367,
15728,
63,
354,
315,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
26,
288,
340,
4613,
14,
888,
14,
1422,
14,
13444,
508,
942,
503,
15728,
63,
354,
315,
4613,
14,
888,
14,
1422,
14,
13444,
26,
355,
1249,
14,
740,
1332,
13444,
63,
354,
12,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
59,
13444,
63,
354,
1527,
17,
467,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
59,
13444,
63,
354,
1527,
16,
2459,
267,
3404,
1532,
14,
10396,
360,
13444,
63,
354,
12,
1300,
63,
13444,
63,
354,
12,
15809,
297,
1249,
9,
272,
916,
3404,
1532,
14,
1593,
855,
354,
363,
508,
283,
396,
63,
2706,
356,
267,
340,
4613,
14,
888,
14,
1422,
14,
2759,
396,
2706,
508,
283,
452,
356,
288,
1249,
275,
942,
267,
916,
4613,
14,
888,
14,
1422,
14,
2759,
396,
2706,
508,
283,
396,
846,
356,
288,
1249,
275,
359,
797,
61,
267,
916,
4613,
14,
888,
14,
1422,
14,
2759,
396,
2706,
508,
283,
973,
846,
356,
288,
1249,
275,
359,
549,
61,
267,
587,
26,
288,
1249,
275,
359,
549,
12,
756,
61,
267,
3404,
1532,
14,
10396,
360,
396,
846,
297,
1249,
9,
199,
199,
318,
4613,
63,
525,
1422,
8,
2087,
304,
272,
408,
1123,
2997,
511,
5241,
1423,
1511,
1041,
272,
1798,
14,
525,
1422,
6739,
1593,
401,
1595,
628,
740,
401,
849,
6034,
1720,
628,
513,
402,
3423,
370,
511,
531,
272,
1798,
14,
525,
1422,
6739,
13444,
401,
1595,
628,
740,
401,
849,
6034,
1720,
628,
513,
402,
28444,
370,
511,
531,
272,
1798,
14,
525,
1422,
6739,
12069,
88,
4097,
401,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1720,
628,
4208,
436,
870,
7381,
6318,
367,
23588,
12607,
342,
2295,
531,
272,
1798,
14,
525,
1422,
6739,
83,
7047,
2497,
17832,
401,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1720,
628,
4208,
3875,
5461,
436,
943,
315,
1275,
1222,
1584,
531,
272,
1798,
14,
525,
1422,
6739,
2759,
396,
2706,
401,
849,
534,
889,
297,
1720,
628,
2759,
511,
6719,
8,
83,
9,
334,
1180,
543,
1373,
402,
314,
2569,
1338,
26,
658,
452,
3559,
658,
396,
846,
64,
503,
658,
973,
846,
64,
6320,
199,
199,
32,
4462,
14,
5997,
8,
2645,
628,
578,
531,
199,
318,
3066,
13754,
63,
697,
8,
1069,
304,
272,
408,
1767,
282,
3050,
909,
1041,
272,
1592,
275,
282,
1190,
87,
14,
3225,
8,
1974,
63,
396,
14,
7013,
50,
63,
3022,
435,
1994,
8769,
15,
1773,
13754,
14,
697,
358,
272,
340,
334,
1069,
14,
578,
855,
354,
363,
508,
283,
15092,
63,
396,
735,
267,
4884,
63,
396,
14,
2747,
572,
63,
1773,
13754,
63,
697,
8,
697,
9,
272,
372,
1592,
199,
199,
32,
4462,
14,
5997,
8,
6898,
7130,
29,
549,
9,
199,
318,
4205,
63,
1805,
63,
5777,
8,
20372,
2068,
12,
3066,
13754,
63,
697,
304,
272,
408,
774,
308,
4993,
1683,
3423,
14,
339,
4420,
3423,
4278,
849,
13942,
370,
2040,
511,
308,
4993,
370,
1736,
446,
367,
1256,
12,
1434,
63,
12070,
365,
20200,
5591,
880,
626,
4036,
1434,
911,
986,
14,
18049,
261,
787,
2808,
370,
4036,
511,
805,
315,
642,
5241,
1041,
339,
4884,
63,
396,
14,
1773,
13754,
63,
697,
275,
3066,
13754,
63,
697,
339,
347,
664,
63,
324,
19435,
63,
2347,
16816,
8,
1562,
12,
625,
16391,
29,
797,
12,
3510,
4093,
63,
3711,
29,
797,
304,
267,
543,
1551,
8,
1974,
63,
396,
14,
7013,
50,
63,
3022,
435,
1994,
8769,
15,
324,
19435,
63,
4467,
14,
1001,
297,
283,
82,
358,
465,
769,
324,
19435,
63,
396,
63,
493,
26,
288,
20534,
63,
324,
19435,
275,
2022,
14,
912,
8,
513,
324,
19435,
63,
396,
63,
493,
9,
288,
625,
19435,
63,
2347,
16816,
275,
359,
1199,
367,
1072,
315,
20534,
63,
324,
19435,
340,
1072,
459,
1562,
418,
508,
2287,
61,
288,
372,
625,
19435,
63,
2347,
16816,
339,
347,
365,
364,
84,
8,
7367,
63,
521,
304,
267,
372,
2197,
14,
5834,
18531,
8,
7367,
63,
521,
680,
17070,
342,
339
] |
[
1182,
2647,
15,
1393,
15,
1548,
19,
199,
199,
624,
199,
774,
5241,
2897,
199,
624,
199,
199,
646,
747,
199,
646,
984,
199,
199,
1818,
63,
694,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
8,
736,
14,
515,
14,
904,
8,
736,
14,
9458,
1062,
747,
14,
515,
14,
12131,
3460,
493,
363,
7845,
199,
1095,
63,
694,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
1818,
63,
694,
12,
283,
9707,
1333,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
1300,
63,
694,
9,
199,
199,
646,
2022,
12,
14755,
12,
282,
1190,
87,
199,
504,
2197,
492,
2197,
199,
199,
646,
4613,
12,
4884,
63,
396,
199,
199,
504,
15188,
14,
12280,
492,
25836,
2864,
63,
2524,
1028,
726,
199,
504,
15188,
14,
1162,
492,
6186,
63,
17978,
199,
504,
15188,
14,
32225,
492,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
199,
199,
504,
7055,
7522,
773,
14,
773,
492,
1101,
12,
4884,
12,
4865,
12,
6008,
199,
199,
646,
27214,
465,
27214,
773,
199,
646,
27214,
14,
4354,
465,
27214,
773,
63,
4354,
199,
199,
318,
4613,
63,
3627,
63,
8951,
1744,
8,
1730,
12,
1101,
12,
2974,
304,
272,
408,
2540,
18782,
3021,
63,
396,
14,
647,
2061,
1041,
272,
2974,
5873,
275,
769,
8,
13501,
8,
1744,
430,
199,
199,
318,
4613,
63,
4208,
63,
2219,
8,
2024,
1532,
304,
272,
408,
6864,
1006,
1134,
14,
396,
5560,
14,
13813,
367,
3365,
2943,
402,
2295,
436,
8491,
5576,
1067,
1041,
272,
340,
3404,
1532,
14,
1593,
855,
354,
363,
508,
283,
396,
63,
4106,
356,
267,
1249,
275,
4884,
63,
396,
14,
4106,
63,
475,
63,
589,
8,
15505,
2864,
63,
2524,
1028,
726,
12,
4613,
14,
888,
14,
1422,
14,
1593,
9,
267,
3404,
1532,
14,
10396,
360,
2347,
63,
354,
12,
1083,
12,
4153,
12,
4704,
12,
1125,
12,
5767,
297,
1249,
9,
272,
916,
3404,
1532,
14,
1593,
855,
354,
363,
508,
283,
396,
63,
13444,
356,
267,
1249,
275,
942,
267,
367,
15728,
63,
354,
315,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
26,
288,
340,
4613,
14,
888,
14,
1422,
14,
13444,
508,
942,
503,
15728,
63,
354,
315,
4613,
14,
888,
14,
1422,
14,
13444,
26,
355,
1249,
14,
740,
1332,
13444,
63,
354,
12,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
59,
13444,
63,
354,
1527,
17,
467,
14985,
3975,
2594,
63,
5153,
742,
689,
13532,
59,
13444,
63,
354,
1527,
16,
2459,
267,
3404,
1532,
14,
10396,
360,
13444,
63,
354,
12,
1300,
63,
13444,
63,
354,
12,
15809,
297,
1249,
9,
272,
916,
3404,
1532,
14,
1593,
855,
354,
363,
508,
283,
396,
63,
2706,
356,
267,
340,
4613,
14,
888,
14,
1422,
14,
2759,
396,
2706,
508,
283,
452,
356,
288,
1249,
275,
942,
267,
916,
4613,
14,
888,
14,
1422,
14,
2759,
396,
2706,
508,
283,
396,
846,
356,
288,
1249,
275,
359,
797,
61,
267,
916,
4613,
14,
888,
14,
1422,
14,
2759,
396,
2706,
508,
283,
973,
846,
356,
288,
1249,
275,
359,
549,
61,
267,
587,
26,
288,
1249,
275,
359,
549,
12,
756,
61,
267,
3404,
1532,
14,
10396,
360,
396,
846,
297,
1249,
9,
199,
199,
318,
4613,
63,
525,
1422,
8,
2087,
304,
272,
408,
1123,
2997,
511,
5241,
1423,
1511,
1041,
272,
1798,
14,
525,
1422,
6739,
1593,
401,
1595,
628,
740,
401,
849,
6034,
1720,
628,
513,
402,
3423,
370,
511,
531,
272,
1798,
14,
525,
1422,
6739,
13444,
401,
1595,
628,
740,
401,
849,
6034,
1720,
628,
513,
402,
28444,
370,
511,
531,
272,
1798,
14,
525,
1422,
6739,
12069,
88,
4097,
401,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1720,
628,
4208,
436,
870,
7381,
6318,
367,
23588,
12607,
342,
2295,
531,
272,
1798,
14,
525,
1422,
6739,
83,
7047,
2497,
17832,
401,
1595,
534,
1617,
63,
2052,
297,
849,
29,
797,
12,
1720,
628,
4208,
3875,
5461,
436,
943,
315,
1275,
1222,
1584,
531,
272,
1798,
14,
525,
1422,
6739,
2759,
396,
2706,
401,
849,
534,
889,
297,
1720,
628,
2759,
511,
6719,
8,
83,
9,
334,
1180,
543,
1373,
402,
314,
2569,
1338,
26,
658,
452,
3559,
658,
396,
846,
64,
503,
658,
973,
846,
64,
6320,
199,
199,
32,
4462,
14,
5997,
8,
2645,
628,
578,
531,
199,
318,
3066,
13754,
63,
697,
8,
1069,
304,
272,
408,
1767,
282,
3050,
909,
1041,
272,
1592,
275,
282,
1190,
87,
14,
3225,
8,
1974,
63,
396,
14,
7013,
50,
63,
3022,
435,
1994,
8769,
15,
1773,
13754,
14,
697,
358,
272,
340,
334,
1069,
14,
578,
855,
354,
363,
508,
283,
15092,
63,
396,
735,
267,
4884,
63,
396,
14,
2747,
572,
63,
1773,
13754,
63,
697,
8,
697,
9,
272,
372,
1592,
199,
199,
32,
4462,
14,
5997,
8,
6898,
7130,
29,
549,
9,
199,
318,
4205,
63,
1805,
63,
5777,
8,
20372,
2068,
12,
3066,
13754,
63,
697,
304,
272,
408,
774,
308,
4993,
1683,
3423,
14,
339,
4420,
3423,
4278,
849,
13942,
370,
2040,
511,
308,
4993,
370,
1736,
446,
367,
1256,
12,
1434,
63,
12070,
365,
20200,
5591,
880,
626,
4036,
1434,
911,
986,
14,
18049,
261,
787,
2808,
370,
4036,
511,
805,
315,
642,
5241,
1041,
339,
4884,
63,
396,
14,
1773,
13754,
63,
697,
275,
3066,
13754,
63,
697,
339,
347,
664,
63,
324,
19435,
63,
2347,
16816,
8,
1562,
12,
625,
16391,
29,
797,
12,
3510,
4093,
63,
3711,
29,
797,
304,
267,
543,
1551,
8,
1974,
63,
396,
14,
7013,
50,
63,
3022,
435,
1994,
8769,
15,
324,
19435,
63,
4467,
14,
1001,
297,
283,
82,
358,
465,
769,
324,
19435,
63,
396,
63,
493,
26,
288,
20534,
63,
324,
19435,
275,
2022,
14,
912,
8,
513,
324,
19435,
63,
396,
63,
493,
9,
288,
625,
19435,
63,
2347,
16816,
275,
359,
1199,
367,
1072,
315,
20534,
63,
324,
19435,
340,
1072,
459,
1562,
418,
508,
2287,
61,
288,
372,
625,
19435,
63,
2347,
16816,
339,
347,
365,
364,
84,
8,
7367,
63,
521,
304,
267,
372,
2197,
14,
5834,
18531,
8,
7367,
63,
521,
680,
17070,
342,
339,
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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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
] |
aESeguridad/GERE
|
venv/lib/python2.7/site-packages/flask_weasyprint/__init__.py
|
1
|
7726
|
# coding: utf8
"""
flask_weasyprint
~~~~~~~~~~~~~~~~
Flask-WeasyPrint: Make PDF in your Flask app with WeasyPrint.
:copyright: (c) 2012 by Simon Sapin.
:license: BSD, see LICENSE for more details.
"""
import weasyprint
from flask import request, current_app
from werkzeug.test import Client, ClientRedirectError
from werkzeug.wrappers import Response
try:
import urlparse
except ImportError: # Python 3
from urllib import parse as urlparse
try:
unicode
except NameError: # Python 3
unicode = str
VERSION = '0.5'
__all__ = ['VERSION', 'make_flask_url_dispatcher', 'make_url_fetcher',
'HTML', 'CSS', 'render_pdf']
DEFAULT_PORTS = frozenset([('http', 80), ('https', 443)])
def make_flask_url_dispatcher():
"""Return an URL dispatcher based on the current :ref:`request context
<flask:request-context>`.
You generally don’t need to call this directly.
The context is used when the dispatcher is first created but not
afterwards. It is not required after this function has returned.
Dispatch to the context’s app URLs below the context’s root URL.
If the app has a ``SERVER_NAME`` :ref:`config <flask:config>`, also
accept URLs that have that domain name or a subdomain thereof.
"""
def parse_netloc(netloc):
"""Return (hostname, port)."""
parsed = urlparse.urlsplit('http://' + netloc)
return parsed.hostname, parsed.port
app = current_app._get_current_object()
root_path = request.script_root
server_name = app.config.get('SERVER_NAME')
if server_name:
hostname, port = parse_netloc(server_name)
def accept(url):
"""Accept any URL scheme; also accept subdomains."""
return url.hostname is not None and (
url.hostname == hostname or
url.hostname.endswith('.' + hostname))
else:
scheme = request.scheme
hostname, port = parse_netloc(request.host)
if (scheme, port) in DEFAULT_PORTS:
port = None
def accept(url):
"""Do not accept subdomains."""
return (url.scheme, url.hostname) == (scheme, hostname)
def dispatch(url_string):
if isinstance(url_string, bytes):
url_string = url_string.decode('utf8')
url = urlparse.urlsplit(url_string)
url_port = url.port
if (url.scheme, url_port) in DEFAULT_PORTS:
url_port = None
if accept(url) and url_port == port and url.path.startswith(root_path):
netloc = url.netloc
if url.port and not url_port:
netloc = netloc.rsplit(':', 1)[0] # remove default port
base_url = '%s://%s%s' % (url.scheme, netloc, root_path)
path = url.path[len(root_path):]
if url.query:
path += '?' + url.query
# Ignore url.fragment
return app, base_url, path
return dispatch
def make_url_fetcher(dispatcher=None,
next_fetcher=weasyprint.default_url_fetcher):
"""Return an function suitable as a ``url_fetcher`` in WeasyPrint.
You generally don’t need to call this directly.
If ``dispatcher`` is not provided, :func:`make_flask_url_dispatcher`
is called to get one. This requires a request context.
Otherwise, it must be a callable that take an URL and return either
``None`` or a ``(wsgi_callable, base_url, path)`` tuple. For None
``next_fetcher`` is used. (By default, fetch normally over the network.)
For a tuple the request is made at the WSGI level.
``wsgi_callable`` must be a Flask application or another WSGI callable.
``base_url`` is the root URL for the application while ``path``
is the path within the application.
Typically ``base_url + path`` is equal or equivalent to the passed URL.
"""
if dispatcher is None:
dispatcher = make_flask_url_dispatcher()
def flask_url_fetcher(url):
redirect_chain = set()
while 1:
result = dispatcher(url)
if result is None:
return next_fetcher(url)
app, base_url, path = result
client = Client(app, response_wrapper=Response)
if isinstance(path, unicode):
# TODO: double-check this. Apparently Werzeug %-unquotes bytes
# but not Unicode URLs. (IRI vs. URI or something.)
path = path.encode('utf8')
response = client.get(path, base_url=base_url)
if response.status_code == 200:
return dict(
string=response.data,
mime_type=response.mimetype,
encoding=response.charset,
redirected_url=url)
# The test client can follow redirects, but do it ourselves
# to get access to the redirected URL.
elif response.status_code in (301, 302, 303, 305, 307):
redirect_chain.add(url)
url = response.location
if url in redirect_chain:
raise ClientRedirectError('loop detected')
else:
raise ValueError('Flask-WeasyPrint got HTTP status %s for %s%s'
% (response.status, base_url, path))
return flask_url_fetcher
def _wrapper(class_, *args, **kwargs):
if args:
guess = args[0]
args = args[1:]
else:
guess = kwargs.pop('guess', None)
if guess is not None and not hasattr(guess, 'read'):
# Assume a (possibly relative) URL
guess = urlparse.urljoin(request.url, guess)
if 'string' in kwargs and 'base_url' not in kwargs:
# Strings do not have an "intrinsic" base URL, use the request context.
kwargs['base_url'] = request.url
kwargs['url_fetcher'] = make_url_fetcher()
return class_(guess, *args, **kwargs)
def HTML(*args, **kwargs):
"""Like `weasyprint.HTML()
<http://weasyprint.org/using/#the-weasyprint-html-class>`_ but:
* :func:`make_url_fetcher` is used to create an ``url_fetcher``
* If ``guess`` is not a file object, it is an URL relative to the current
request context.
This means that you can just pass a result from :func:`flask.url_for`.
* If ``string`` is passed, ``base_url`` defaults to the current
request’s URL.
This requires a Flask request context.
"""
return _wrapper(weasyprint.HTML, *args, **kwargs)
def CSS(*args, **kwargs):
return _wrapper(weasyprint.CSS, *args, **kwargs)
CSS.__doc__ = HTML.__doc__.replace('HTML', 'CSS').replace('html', 'css')
def render_pdf(html, stylesheets=None, download_filename=None):
"""Render a PDF to a response with the correct ``Content-Type`` header.
:param html:
Either a :class:`weasyprint.HTML` object or an URL to be passed
to :func:`flask_weasyprint.HTML`. The latter case requires
a request context.
:param stylesheets:
A list of user stylesheets, passed to
:meth:`~weasyprint.HTML.write_pdf`
:param download_filename:
If provided, the ``Content-Disposition`` header is set so that most
web browser will show the "Save as…" dialog with the value as the
default filename.
:returns: a :class:`flask.Response` object.
"""
if not hasattr(html, 'write_pdf'):
html = HTML(html)
pdf = html.write_pdf(stylesheets=stylesheets)
response = current_app.response_class(pdf, mimetype='application/pdf')
if download_filename:
response.headers.add('Content-Disposition', 'attachment',
filename=download_filename)
return response
|
gpl-3.0
|
[
3,
2803,
26,
2774,
24,
199,
624,
272,
7209,
63,
1129,
5660,
1361,
272,
18294,
339,
16704,
13,
6004,
5660,
5375,
26,
4155,
15537,
315,
2195,
16704,
1145,
543,
2136,
5660,
5375,
14,
339,
520,
7307,
26,
334,
67,
9,
6029,
701,
10751,
265,
428,
439,
262,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
199,
624,
199,
199,
646,
781,
5660,
1361,
199,
504,
7209,
492,
1056,
12,
1453,
63,
571,
199,
504,
10380,
14,
396,
492,
6810,
12,
6810,
7071,
547,
199,
504,
10380,
14,
21148,
492,
7232,
199,
199,
893,
26,
272,
492,
7097,
199,
2590,
3545,
26,
221,
327,
2018,
650,
272,
687,
4011,
492,
2198,
465,
7097,
199,
199,
893,
26,
272,
2649,
199,
2590,
12746,
26,
221,
327,
2018,
650,
272,
2649,
275,
620,
421,
199,
4612,
275,
283,
16,
14,
21,
7,
199,
363,
452,
363,
275,
788,
4612,
297,
283,
1875,
63,
15720,
63,
633,
63,
14913,
297,
283,
1875,
63,
633,
63,
26983,
297,
1779,
283,
4943,
297,
283,
14391,
297,
283,
3352,
63,
5607,
418,
421,
199,
3472,
63,
3657,
51,
275,
9522,
8318,
1014,
297,
5939,
395,
661,
2859,
297,
23865,
3948,
421,
199,
318,
1852,
63,
15720,
63,
633,
63,
14913,
837,
272,
408,
1767,
376,
2851,
17475,
4079,
641,
314,
1453,
520,
1121,
1705,
1069,
1067,
272,
665,
15720,
26,
1069,
13,
1100,
14943,
339,
2047,
16711,
2793,
21045,
84,
1929,
370,
1240,
642,
5370,
14,
339,
710,
1067,
365,
1202,
1380,
314,
17475,
365,
1642,
2737,
1325,
440,
272,
26982,
14,
2779,
365,
440,
1415,
2410,
642,
805,
965,
2138,
14,
339,
28626,
370,
314,
1067,
21045,
83,
1145,
10867,
5084,
314,
1067,
21045,
83,
1738,
2851,
14,
272,
982,
314,
1145,
965,
282,
1124,
6613,
63,
2339,
1040,
520,
1121,
1705,
888,
665,
15720,
26,
888,
30,
3559,
2597,
272,
4729,
10867,
626,
1172,
626,
2881,
536,
503,
282,
23301,
2337,
1618,
14,
339,
408,
272,
347,
2198,
63,
12652,
8,
12652,
304,
267,
408,
1767,
334,
4269,
12,
1844,
10477,
267,
4565,
275,
7097,
14,
29491,
360,
1014,
22399,
435,
10154,
9,
267,
372,
4565,
14,
4269,
12,
4565,
14,
719,
339,
1145,
275,
1453,
63,
571,
423,
362,
63,
1818,
63,
785,
342,
272,
1738,
63,
515,
275,
1056,
14,
1579,
63,
1231,
339,
1654,
63,
354,
275,
1145,
14,
888,
14,
362,
360,
6613,
63,
2339,
358,
272,
340,
1654,
63,
354,
26,
267,
6246,
12,
1844,
275,
2198,
63,
12652,
8,
1000,
63,
354,
9,
398,
347,
4729,
8,
633,
304,
288,
408,
8422,
1263,
2851,
5687,
27,
2597,
4729,
1007,
9756,
1041,
288,
372,
1166,
14,
4269,
365,
440,
488,
436,
334,
355,
1166,
14,
4269,
508,
6246,
503,
355,
1166,
14,
4269,
14,
4130,
360,
3530,
435,
6246,
430,
272,
587,
26,
267,
5687,
275,
1056,
14,
5512,
267,
6246,
12,
1844,
275,
2198,
63,
12652,
8,
1069,
14,
1102,
9,
267,
340,
334,
5512,
12,
1844,
9,
315,
6186,
63,
3657,
51,
26,
288,
1844,
275,
488,
398,
347,
4729,
8,
633,
304,
288,
408,
2585,
440,
4729,
1007,
9756,
1041,
288,
372,
334,
633,
14,
5512,
12,
1166,
14,
4269,
9,
508,
334,
5512,
12,
6246,
9,
339,
347,
7634,
8,
633,
63,
875,
304,
267,
340,
1228,
8,
633,
63,
875,
12,
2783,
304,
288,
1166,
63,
875,
275,
1166,
63,
875,
14,
2708,
360,
1624,
24,
358,
267,
1166,
275,
7097,
14,
29491,
8,
633,
63,
875,
9,
267,
1166,
63,
719,
275,
1166,
14,
719,
267,
340,
334,
633,
14,
5512,
12,
1166,
63,
719,
9,
315,
6186,
63,
3657,
51,
26,
288,
1166,
63,
719,
275,
488,
267,
340,
4729,
8,
633,
9,
436,
1166,
63,
719,
508,
1844,
436,
1166,
14,
515,
14,
2460,
8,
1231,
63,
515,
304,
288,
10154,
275,
1166,
14,
12652,
288,
340,
1166,
14,
719,
436,
440,
1166,
63,
719,
26,
355,
10154,
275,
10154,
14,
13490,
16451,
413,
2788,
16,
61,
221,
327,
2813,
849,
1844,
288,
1300,
63,
633,
275,
1543,
83,
13827,
83,
5,
83,
7,
450,
334,
633,
14,
5512,
12,
10154,
12,
1738,
63,
515,
9,
288,
931,
275,
1166,
14,
515,
59,
552,
8,
1231,
63,
515,
15405,
288,
340,
1166,
14,
1131,
26,
355,
931,
847,
15539,
435,
1166,
14,
1131,
288,
327,
14092,
1166,
14,
7677,
288,
372,
1145,
12,
1300,
63,
633,
12,
931,
339,
372,
7634,
421,
199,
318,
1852,
63,
633,
63,
26983,
8,
14913,
29,
403,
12,
2151,
2163,
63,
26983,
29,
1129,
5660,
1361,
14,
885,
63,
633,
63,
26983,
304,
272,
408,
1767,
376,
805,
11233,
465,
282,
1124,
633,
63,
26983,
1040,
315,
2136,
5660,
5375,
14,
272,
2047,
16711,
2793,
21045,
84,
1929,
370,
1240,
642,
5370,
14,
339,
982,
1124,
14913,
1040,
365,
440,
221,
2741,
12,
520,
1532,
1705,
1875,
63,
15720,
63,
633,
63,
14913,
64,
272,
365,
2797,
370,
664,
1373,
14,
961,
5074,
282,
1056,
1067,
14,
339,
6630,
12,
652,
1471,
506,
282,
4550,
626,
5452,
376,
2851,
436,
372,
1902,
272,
1124,
403,
1040,
503,
282,
15475,
6508,
63,
8296,
12,
1300,
63,
633,
12,
931,
9719,
2008,
14,
2104,
488,
272,
1124,
2184,
63,
26983,
1040,
365,
1202,
14,
334,
2175,
849,
12,
5267,
12252,
1806,
314,
2784,
4959,
272,
2104,
282,
2008,
314,
1056,
365,
6326,
737,
314,
9279,
2166,
14,
272,
1124,
6508,
63,
8296,
1040,
1471,
506,
282,
16704,
4223,
503,
4573,
9279,
4550,
14,
272,
1124,
1095,
63,
633,
1040,
365,
314,
1738,
2851,
367,
314,
4223,
1830,
1124,
515,
1040,
272,
365,
314,
931,
4453,
314,
4223,
14,
272,
26914,
1124,
1095,
63,
633,
435,
931,
1040,
365,
4472,
503,
7353,
370,
314,
3032,
2851,
14,
339,
408,
272,
340,
17475,
365,
488,
26,
267,
17475,
275,
1852,
63,
15720,
63,
633,
63,
14913,
342,
339,
347,
7209,
63,
633,
63,
26983,
8,
633,
304,
267,
4660,
63,
4429,
275,
663,
342,
267,
1830,
413,
26,
288,
754,
275,
17475,
8,
633,
9,
288,
340,
754,
365,
488,
26,
355,
372,
2163,
63,
26983,
8,
633,
9,
288,
1145,
12,
1300,
63,
633,
12,
931,
275
] |
[
2803,
26,
2774,
24,
199,
624,
272,
7209,
63,
1129,
5660,
1361,
272,
18294,
339,
16704,
13,
6004,
5660,
5375,
26,
4155,
15537,
315,
2195,
16704,
1145,
543,
2136,
5660,
5375,
14,
339,
520,
7307,
26,
334,
67,
9,
6029,
701,
10751,
265,
428,
439,
262,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
199,
624,
199,
199,
646,
781,
5660,
1361,
199,
504,
7209,
492,
1056,
12,
1453,
63,
571,
199,
504,
10380,
14,
396,
492,
6810,
12,
6810,
7071,
547,
199,
504,
10380,
14,
21148,
492,
7232,
199,
199,
893,
26,
272,
492,
7097,
199,
2590,
3545,
26,
221,
327,
2018,
650,
272,
687,
4011,
492,
2198,
465,
7097,
199,
199,
893,
26,
272,
2649,
199,
2590,
12746,
26,
221,
327,
2018,
650,
272,
2649,
275,
620,
421,
199,
4612,
275,
283,
16,
14,
21,
7,
199,
363,
452,
363,
275,
788,
4612,
297,
283,
1875,
63,
15720,
63,
633,
63,
14913,
297,
283,
1875,
63,
633,
63,
26983,
297,
1779,
283,
4943,
297,
283,
14391,
297,
283,
3352,
63,
5607,
418,
421,
199,
3472,
63,
3657,
51,
275,
9522,
8318,
1014,
297,
5939,
395,
661,
2859,
297,
23865,
3948,
421,
199,
318,
1852,
63,
15720,
63,
633,
63,
14913,
837,
272,
408,
1767,
376,
2851,
17475,
4079,
641,
314,
1453,
520,
1121,
1705,
1069,
1067,
272,
665,
15720,
26,
1069,
13,
1100,
14943,
339,
2047,
16711,
2793,
21045,
84,
1929,
370,
1240,
642,
5370,
14,
339,
710,
1067,
365,
1202,
1380,
314,
17475,
365,
1642,
2737,
1325,
440,
272,
26982,
14,
2779,
365,
440,
1415,
2410,
642,
805,
965,
2138,
14,
339,
28626,
370,
314,
1067,
21045,
83,
1145,
10867,
5084,
314,
1067,
21045,
83,
1738,
2851,
14,
272,
982,
314,
1145,
965,
282,
1124,
6613,
63,
2339,
1040,
520,
1121,
1705,
888,
665,
15720,
26,
888,
30,
3559,
2597,
272,
4729,
10867,
626,
1172,
626,
2881,
536,
503,
282,
23301,
2337,
1618,
14,
339,
408,
272,
347,
2198,
63,
12652,
8,
12652,
304,
267,
408,
1767,
334,
4269,
12,
1844,
10477,
267,
4565,
275,
7097,
14,
29491,
360,
1014,
22399,
435,
10154,
9,
267,
372,
4565,
14,
4269,
12,
4565,
14,
719,
339,
1145,
275,
1453,
63,
571,
423,
362,
63,
1818,
63,
785,
342,
272,
1738,
63,
515,
275,
1056,
14,
1579,
63,
1231,
339,
1654,
63,
354,
275,
1145,
14,
888,
14,
362,
360,
6613,
63,
2339,
358,
272,
340,
1654,
63,
354,
26,
267,
6246,
12,
1844,
275,
2198,
63,
12652,
8,
1000,
63,
354,
9,
398,
347,
4729,
8,
633,
304,
288,
408,
8422,
1263,
2851,
5687,
27,
2597,
4729,
1007,
9756,
1041,
288,
372,
1166,
14,
4269,
365,
440,
488,
436,
334,
355,
1166,
14,
4269,
508,
6246,
503,
355,
1166,
14,
4269,
14,
4130,
360,
3530,
435,
6246,
430,
272,
587,
26,
267,
5687,
275,
1056,
14,
5512,
267,
6246,
12,
1844,
275,
2198,
63,
12652,
8,
1069,
14,
1102,
9,
267,
340,
334,
5512,
12,
1844,
9,
315,
6186,
63,
3657,
51,
26,
288,
1844,
275,
488,
398,
347,
4729,
8,
633,
304,
288,
408,
2585,
440,
4729,
1007,
9756,
1041,
288,
372,
334,
633,
14,
5512,
12,
1166,
14,
4269,
9,
508,
334,
5512,
12,
6246,
9,
339,
347,
7634,
8,
633,
63,
875,
304,
267,
340,
1228,
8,
633,
63,
875,
12,
2783,
304,
288,
1166,
63,
875,
275,
1166,
63,
875,
14,
2708,
360,
1624,
24,
358,
267,
1166,
275,
7097,
14,
29491,
8,
633,
63,
875,
9,
267,
1166,
63,
719,
275,
1166,
14,
719,
267,
340,
334,
633,
14,
5512,
12,
1166,
63,
719,
9,
315,
6186,
63,
3657,
51,
26,
288,
1166,
63,
719,
275,
488,
267,
340,
4729,
8,
633,
9,
436,
1166,
63,
719,
508,
1844,
436,
1166,
14,
515,
14,
2460,
8,
1231,
63,
515,
304,
288,
10154,
275,
1166,
14,
12652,
288,
340,
1166,
14,
719,
436,
440,
1166,
63,
719,
26,
355,
10154,
275,
10154,
14,
13490,
16451,
413,
2788,
16,
61,
221,
327,
2813,
849,
1844,
288,
1300,
63,
633,
275,
1543,
83,
13827,
83,
5,
83,
7,
450,
334,
633,
14,
5512,
12,
10154,
12,
1738,
63,
515,
9,
288,
931,
275,
1166,
14,
515,
59,
552,
8,
1231,
63,
515,
15405,
288,
340,
1166,
14,
1131,
26,
355,
931,
847,
15539,
435,
1166,
14,
1131,
288,
327,
14092,
1166,
14,
7677,
288,
372,
1145,
12,
1300,
63,
633,
12,
931,
339,
372,
7634,
421,
199,
318,
1852,
63,
633,
63,
26983,
8,
14913,
29,
403,
12,
2151,
2163,
63,
26983,
29,
1129,
5660,
1361,
14,
885,
63,
633,
63,
26983,
304,
272,
408,
1767,
376,
805,
11233,
465,
282,
1124,
633,
63,
26983,
1040,
315,
2136,
5660,
5375,
14,
272,
2047,
16711,
2793,
21045,
84,
1929,
370,
1240,
642,
5370,
14,
339,
982,
1124,
14913,
1040,
365,
440,
221,
2741,
12,
520,
1532,
1705,
1875,
63,
15720,
63,
633,
63,
14913,
64,
272,
365,
2797,
370,
664,
1373,
14,
961,
5074,
282,
1056,
1067,
14,
339,
6630,
12,
652,
1471,
506,
282,
4550,
626,
5452,
376,
2851,
436,
372,
1902,
272,
1124,
403,
1040,
503,
282,
15475,
6508,
63,
8296,
12,
1300,
63,
633,
12,
931,
9719,
2008,
14,
2104,
488,
272,
1124,
2184,
63,
26983,
1040,
365,
1202,
14,
334,
2175,
849,
12,
5267,
12252,
1806,
314,
2784,
4959,
272,
2104,
282,
2008,
314,
1056,
365,
6326,
737,
314,
9279,
2166,
14,
272,
1124,
6508,
63,
8296,
1040,
1471,
506,
282,
16704,
4223,
503,
4573,
9279,
4550,
14,
272,
1124,
1095,
63,
633,
1040,
365,
314,
1738,
2851,
367,
314,
4223,
1830,
1124,
515,
1040,
272,
365,
314,
931,
4453,
314,
4223,
14,
272,
26914,
1124,
1095,
63,
633,
435,
931,
1040,
365,
4472,
503,
7353,
370,
314,
3032,
2851,
14,
339,
408,
272,
340,
17475,
365,
488,
26,
267,
17475,
275,
1852,
63,
15720,
63,
633,
63,
14913,
342,
339,
347,
7209,
63,
633,
63,
26983,
8,
633,
304,
267,
4660,
63,
4429,
275,
663,
342,
267,
1830,
413,
26,
288,
754,
275,
17475,
8,
633,
9,
288,
340,
754,
365,
488,
26,
355,
372,
2163,
63,
26983,
8,
633,
9,
288,
1145,
12,
1300,
63,
633,
12,
931,
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,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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
] |
pombredanne/numba
|
numba/cuda/tests/cudapy/test_gufunc.py
|
2
|
10779
|
from __future__ import print_function, absolute_import
from numba import void, float32, float64
import numpy as np
import numpy.core.umath_tests as ut
from numba import guvectorize
from numba import cuda
from timeit import default_timer as time
from numba import unittest_support as unittest
from numba.cuda.testing import skip_on_cudasim
non_stream_speedups = []
stream_speedups = []
@skip_on_cudasim('ufunc API unsupported in the simulator')
class TestCUDAGufunc(unittest.TestCase):
def test_gufunc_small(self):
@guvectorize([void(float32[:, :], float32[:, :], float32[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
gufunc.max_blocksize = 512
matrix_ct = 2
A = np.arange(matrix_ct * 2 * 4, dtype=np.float32).reshape(matrix_ct, 2,
4)
B = np.arange(matrix_ct * 4 * 5, dtype=np.float32).reshape(matrix_ct, 4,
5)
ts = time()
C = gufunc(A, B)
tcuda = time() - ts
ts = time()
Gold = ut.matrix_multiply(A, B)
tcpu = time() - ts
non_stream_speedups.append(tcpu / tcuda)
print(C, Gold)
self.assertTrue(np.allclose(C, Gold))
def test_gufunc_auto_transfer(self):
@guvectorize([void(float32[:, :], float32[:, :], float32[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
gufunc.max_blocksize = 512
matrix_ct = 2
A = np.arange(matrix_ct * 2 * 4, dtype=np.float32).reshape(matrix_ct, 2,
4)
B = np.arange(matrix_ct * 4 * 5, dtype=np.float32).reshape(matrix_ct, 4,
5)
dB = cuda.to_device(B)
ts = time()
C = gufunc(A, dB).copy_to_host()
tcuda = time() - ts
ts = time()
Gold = ut.matrix_multiply(A, B)
tcpu = time() - ts
non_stream_speedups.append(tcpu / tcuda)
print(C, Gold)
self.assertTrue(np.allclose(C, Gold))
def test_gufunc(self):
@guvectorize([void(float32[:, :], float32[:, :], float32[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
gufunc.max_blocksize = 512
matrix_ct = 1001 # an odd number to test thread/block division in CUDA
A = np.arange(matrix_ct * 2 * 4, dtype=np.float32).reshape(matrix_ct, 2,
4)
B = np.arange(matrix_ct * 4 * 5, dtype=np.float32).reshape(matrix_ct, 4,
5)
ts = time()
C = gufunc(A, B)
tcuda = time() - ts
ts = time()
Gold = ut.matrix_multiply(A, B)
tcpu = time() - ts
non_stream_speedups.append(tcpu / tcuda)
self.assertTrue(np.allclose(C, Gold))
def test_gufunc_hidim(self):
@guvectorize([void(float32[:, :], float32[:, :], float32[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
gufunc.max_blocksize = 512
matrix_ct = 100 # an odd number to test thread/block division in CUDA
A = np.arange(matrix_ct * 2 * 4, dtype=np.float32).reshape(4, 25, 2, 4)
B = np.arange(matrix_ct * 4 * 5, dtype=np.float32).reshape(4, 25, 4, 5)
ts = time()
C = gufunc(A, B)
tcuda = time() - ts
ts = time()
Gold = ut.matrix_multiply(A, B)
tcpu = time() - ts
non_stream_speedups.append(tcpu / tcuda)
self.assertTrue(np.allclose(C, Gold))
def test_gufunc_new_axis(self):
@guvectorize([void(float64[:, :], float64[:, :], float64[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
X = np.random.randn(10, 3, 3)
Y = np.random.randn(3, 3)
gold = ut.matrix_multiply(X, Y)
res1 = gufunc(X, Y)
np.testing.assert_allclose(gold, res1)
res2 = gufunc(X, np.tile(Y, (10, 1, 1)))
np.testing.assert_allclose(gold, res2)
def test_gufunc_adjust_blocksize(self):
@guvectorize([void(float32[:, :], float32[:, :], float32[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
gufunc.max_blocksize = 512
matrix_ct = 1001 # an odd number to test thread/block division in CUDA
A = np.arange(matrix_ct * 2 * 4, dtype=np.float32).reshape(matrix_ct, 2,
4)
B = np.arange(matrix_ct * 4 * 5, dtype=np.float32).reshape(matrix_ct, 4,
5)
gufunc.max_blocksize = 32
C = gufunc(A, B)
Gold = ut.matrix_multiply(A, B)
self.assertTrue(np.allclose(C, Gold))
def test_gufunc_stream(self):
@guvectorize([void(float32[:, :], float32[:, :], float32[:, :])],
'(m,n),(n,p)->(m,p)',
target='cuda')
def matmulcore(A, B, C):
m, n = A.shape
n, p = B.shape
for i in range(m):
for j in range(p):
C[i, j] = 0
for k in range(n):
C[i, j] += A[i, k] * B[k, j]
gufunc = matmulcore
gufunc.max_blocksize = 512
#cuda.driver.flush_pending_free()
matrix_ct = 1001 # an odd number to test thread/block division in CUDA
A = np.arange(matrix_ct * 2 * 4, dtype=np.float32).reshape(matrix_ct, 2,
4)
B = np.arange(matrix_ct * 4 * 5, dtype=np.float32).reshape(matrix_ct, 4,
5)
ts = time()
stream = cuda.stream()
dA = cuda.to_device(A, stream)
dB = cuda.to_device(B, stream)
dC = cuda.device_array(shape=(1001, 2, 5), dtype=A.dtype, stream=stream)
dC = gufunc(dA, dB, out=dC, stream=stream)
C = dC.copy_to_host(stream=stream)
stream.synchronize()
tcuda = time() - ts
ts = time()
Gold = ut.matrix_multiply(A, B)
tcpu = time() - ts
stream_speedups.append(tcpu / tcuda)
self.assertTrue(np.allclose(C, Gold))
def test_copy(self):
@guvectorize([void(float32[:], float32[:])],
'(x)->(x)',
target='cuda')
def copy(A, B):
for i in range(B.size):
B[i] = A[i]
A = np.arange(10, dtype=np.float32) + 1
B = np.zeros_like(A)
copy(A, out=B)
self.assertTrue(np.allclose(A, B))
def test_copy_odd(self):
@guvectorize([void(float32[:], float32[:])],
'(x)->(x)',
target='cuda')
def copy(A, B):
for i in range(B.size):
B[i] = A[i]
A = np.arange(11, dtype=np.float32) + 1
B = np.zeros_like(A)
copy(A, out=B)
self.assertTrue(np.allclose(A, B))
def test_copy2d(self):
@guvectorize([void(float32[:, :], float32[:, :])],
'(x, y)->(x, y)',
target='cuda')
def copy2d(A, B):
for x in range(B.shape[0]):
for y in range(B.shape[1]):
B[x, y] = A[x, y]
A = np.arange(30, dtype=np.float32).reshape(5, 6) + 1
B = np.zeros_like(A)
copy2d(A, out=B)
self.assertTrue(np.allclose(A, B))
def test_nopython_flag(self):
def foo(A, B):
pass
# nopython = True is fine
guvectorize([void(float32[:], float32[:])], '(x)->(x)', target='cuda',
nopython=True)(foo)
# nopython = False is bad
with self.assertRaises(TypeError) as raises:
guvectorize([void(float32[:], float32[:])], '(x)->(x)',
target='cuda', nopython=False)(foo)
self.assertEqual("nopython flag must be True", str(raises.exception))
def test_invalid_flags(self):
# Check invalid flags
def foo(A, B):
pass
with self.assertRaises(TypeError) as raises:
guvectorize([void(float32[:], float32[:])], '(x)->(x)',
target='cuda', what1=True, ever2=False)(foo)
head = "The following target options are not supported:"
msg = str(raises.exception)
self.assertEqual(msg[:len(head)], head)
items = msg[len(head):].strip().split(',')
items = [i.strip("'\" ") for i in items]
self.assertEqual(set(['what1', 'ever2']), set(items))
if __name__ == '__main__':
unittest.main()
|
bsd-2-clause
|
[
504,
636,
2443,
363,
492,
870,
63,
1593,
12,
3679,
63,
646,
199,
504,
1967,
2470,
492,
2309,
12,
2069,
708,
12,
2069,
772,
199,
646,
2680,
465,
980,
199,
646,
2680,
14,
1018,
14,
24502,
63,
2219,
465,
11430,
199,
504,
1967,
2470,
492,
8129,
4106,
794,
199,
504,
1967,
2470,
492,
23123,
199,
504,
900,
390,
492,
849,
63,
7414,
465,
900,
199,
504,
1967,
2470,
492,
2882,
63,
4058,
465,
2882,
199,
504,
1967,
2470,
14,
16309,
14,
4776,
492,
3372,
63,
265,
63,
67,
1181,
305,
1017,
421,
199,
2865,
63,
1745,
63,
7625,
15203,
275,
942,
199,
1745,
63,
7625,
15203,
275,
942,
421,
199,
32,
2759,
63,
265,
63,
67,
1181,
305,
1017,
360,
18810,
3261,
16313,
315,
314,
15797,
358,
199,
533,
1379,
30925,
1254,
18810,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
71,
18810,
63,
7241,
8,
277,
304,
398,
768,
6051,
4106,
794,
779,
1647,
8,
1609,
708,
3981,
26450,
2069,
708,
3981,
26450,
2069,
708,
3981,
520,
27520,
2151,
8189,
77,
12,
78,
11865,
78,
12,
80,
20844,
8,
77,
12,
80,
3196,
2151,
1347,
534,
16309,
358,
267,
347,
2530,
3703,
1018,
8,
33,
12,
699,
12,
445,
304,
288,
333,
12,
302,
275,
437,
14,
1392,
288,
302,
12,
299,
275,
699,
14,
1392,
288,
367,
284,
315,
1425,
8,
77,
304,
355,
367,
1335,
315,
1425,
8,
80,
304,
490,
445,
59,
73,
12,
1335,
61,
275,
378,
490,
367,
1022,
315,
1425,
8,
78,
304,
717,
445,
59,
73,
12,
1335,
61,
847,
437,
59,
73,
12,
1022,
61,
627,
699,
59,
75,
12,
1335,
61,
7318,
486,
18810,
275,
2530,
3703,
1018,
267,
486,
18810,
14,
988,
63,
25959,
275,
10574,
398,
3634,
63,
319,
275,
499,
267,
437,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
499,
627,
841,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
499,
12,
28095,
841,
9,
267,
699,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
841,
627,
959,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
841,
12,
28095,
959,
9,
398,
6714,
275,
900,
342,
267,
445,
275,
486,
18810,
8,
33,
12,
699,
9,
267,
14415,
6727,
275,
900,
342,
446,
6714,
398,
6714,
275,
900,
342,
267,
598,
1753,
275,
11430,
14,
3642,
63,
13710,
8,
33,
12,
699,
9,
267,
307,
3541,
275,
900,
342,
446,
6714,
398,
2222,
63,
1745,
63,
7625,
15203,
14,
740,
8,
84,
3541,
1182,
14415,
6727,
9,
398,
870,
8,
35,
12,
598,
1753,
9,
398,
291,
14,
1815,
8,
1590,
14,
7520,
8,
35,
12,
598,
1753,
430,
339,
347,
511,
63,
71,
18810,
63,
2495,
63,
9609,
8,
277,
304,
398,
768,
6051,
4106,
794,
779,
1647,
8,
1609,
708,
3981,
26450,
2069,
708,
3981,
26450,
2069,
708,
3981,
520,
27520,
2151,
8189,
77,
12,
78,
11865,
78,
12,
80,
20844,
8,
77,
12,
80,
3196,
2151,
1347,
534,
16309,
358,
267,
347,
2530,
3703,
1018,
8,
33,
12,
699,
12,
445,
304,
288,
333,
12,
302,
275,
437,
14,
1392,
288,
302,
12,
299,
275,
699,
14,
1392,
288,
367,
284,
315,
1425,
8,
77,
304,
355,
367,
1335,
315,
1425,
8,
80,
304,
490,
445,
59,
73,
12,
1335,
61,
275,
378,
490,
367,
1022,
315,
1425,
8,
78,
304,
717,
445,
59,
73,
12,
1335,
61,
847,
437,
59,
73,
12,
1022,
61,
627,
699,
59,
75,
12,
1335,
61,
398,
486,
18810,
275,
2530,
3703,
1018,
267,
486,
18810,
14,
988,
63,
25959,
275,
10574,
398,
3634,
63,
319,
275,
499,
267,
437,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
499,
627,
841,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
499,
12,
28095,
841,
9,
267,
699,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
841,
627,
959,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
841,
12,
28095,
959,
9,
398,
366,
34,
275,
23123,
14,
475,
63,
1782,
8,
34,
9,
398,
6714,
275,
900,
342,
267,
445,
275,
486,
18810,
8,
33,
12,
366,
34,
680,
1574,
63,
475,
63,
1102,
342,
267,
14415,
6727,
275,
900,
342,
446,
6714,
398,
6714,
275,
900,
342,
267,
598,
1753,
275,
11430,
14,
3642,
63,
13710,
8,
33,
12,
699,
9,
267,
307,
3541,
275,
900,
342,
446,
6714,
398,
2222,
63,
1745,
63,
7625,
15203,
14,
740,
8,
84,
3541,
1182,
14415,
6727,
9,
398,
870,
8,
35,
12,
598,
1753,
9,
398,
291,
14,
1815,
8,
1590,
14,
7520,
8,
35,
12,
598,
1753,
430,
339,
347,
511,
63,
71,
18810,
8,
277,
304,
398,
768,
6051,
4106,
794,
779,
1647,
8,
1609,
708,
3981,
26450,
2069,
708,
3981,
26450,
2069,
708,
3981,
520,
27520,
2151,
8189,
77,
12,
78,
11865,
78,
12,
80,
20844,
8,
77,
12,
80,
3196,
2151,
1347,
534,
16309,
358,
267,
347,
2530,
3703,
1018,
8,
33,
12,
699,
12,
445,
304,
288,
333,
12,
302,
275,
437,
14,
1392,
288,
302,
12,
299,
275,
699,
14,
1392,
288,
367,
284,
315,
1425,
8,
77,
304,
355,
367,
1335,
315,
1425,
8,
80,
304,
490,
445,
59,
73,
12,
1335,
61,
275,
378,
490,
367,
1022,
315,
1425,
8,
78,
304,
717,
445,
59,
73,
12,
1335,
61,
847,
437,
59,
73,
12,
1022,
61,
627,
699,
59,
75,
12,
1335,
61,
398,
486,
18810,
275,
2530,
3703,
1018,
267,
486,
18810,
14,
988,
63,
25959,
275,
10574,
398,
3634,
63,
319,
275,
2948,
17,
327,
376,
16699,
1329,
370,
511,
2462,
15,
1457,
4629,
315,
445,
3383,
33,
267,
437,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
499,
627,
841,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
499,
12,
28095,
841,
9,
267,
699,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
841,
627,
959,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
841,
12,
28095,
959,
9,
398,
6714,
275,
900,
342,
267,
445,
275,
486,
18810
] |
[
636,
2443,
363,
492,
870,
63,
1593,
12,
3679,
63,
646,
199,
504,
1967,
2470,
492,
2309,
12,
2069,
708,
12,
2069,
772,
199,
646,
2680,
465,
980,
199,
646,
2680,
14,
1018,
14,
24502,
63,
2219,
465,
11430,
199,
504,
1967,
2470,
492,
8129,
4106,
794,
199,
504,
1967,
2470,
492,
23123,
199,
504,
900,
390,
492,
849,
63,
7414,
465,
900,
199,
504,
1967,
2470,
492,
2882,
63,
4058,
465,
2882,
199,
504,
1967,
2470,
14,
16309,
14,
4776,
492,
3372,
63,
265,
63,
67,
1181,
305,
1017,
421,
199,
2865,
63,
1745,
63,
7625,
15203,
275,
942,
199,
1745,
63,
7625,
15203,
275,
942,
421,
199,
32,
2759,
63,
265,
63,
67,
1181,
305,
1017,
360,
18810,
3261,
16313,
315,
314,
15797,
358,
199,
533,
1379,
30925,
1254,
18810,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
71,
18810,
63,
7241,
8,
277,
304,
398,
768,
6051,
4106,
794,
779,
1647,
8,
1609,
708,
3981,
26450,
2069,
708,
3981,
26450,
2069,
708,
3981,
520,
27520,
2151,
8189,
77,
12,
78,
11865,
78,
12,
80,
20844,
8,
77,
12,
80,
3196,
2151,
1347,
534,
16309,
358,
267,
347,
2530,
3703,
1018,
8,
33,
12,
699,
12,
445,
304,
288,
333,
12,
302,
275,
437,
14,
1392,
288,
302,
12,
299,
275,
699,
14,
1392,
288,
367,
284,
315,
1425,
8,
77,
304,
355,
367,
1335,
315,
1425,
8,
80,
304,
490,
445,
59,
73,
12,
1335,
61,
275,
378,
490,
367,
1022,
315,
1425,
8,
78,
304,
717,
445,
59,
73,
12,
1335,
61,
847,
437,
59,
73,
12,
1022,
61,
627,
699,
59,
75,
12,
1335,
61,
7318,
486,
18810,
275,
2530,
3703,
1018,
267,
486,
18810,
14,
988,
63,
25959,
275,
10574,
398,
3634,
63,
319,
275,
499,
267,
437,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
499,
627,
841,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
499,
12,
28095,
841,
9,
267,
699,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
841,
627,
959,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
841,
12,
28095,
959,
9,
398,
6714,
275,
900,
342,
267,
445,
275,
486,
18810,
8,
33,
12,
699,
9,
267,
14415,
6727,
275,
900,
342,
446,
6714,
398,
6714,
275,
900,
342,
267,
598,
1753,
275,
11430,
14,
3642,
63,
13710,
8,
33,
12,
699,
9,
267,
307,
3541,
275,
900,
342,
446,
6714,
398,
2222,
63,
1745,
63,
7625,
15203,
14,
740,
8,
84,
3541,
1182,
14415,
6727,
9,
398,
870,
8,
35,
12,
598,
1753,
9,
398,
291,
14,
1815,
8,
1590,
14,
7520,
8,
35,
12,
598,
1753,
430,
339,
347,
511,
63,
71,
18810,
63,
2495,
63,
9609,
8,
277,
304,
398,
768,
6051,
4106,
794,
779,
1647,
8,
1609,
708,
3981,
26450,
2069,
708,
3981,
26450,
2069,
708,
3981,
520,
27520,
2151,
8189,
77,
12,
78,
11865,
78,
12,
80,
20844,
8,
77,
12,
80,
3196,
2151,
1347,
534,
16309,
358,
267,
347,
2530,
3703,
1018,
8,
33,
12,
699,
12,
445,
304,
288,
333,
12,
302,
275,
437,
14,
1392,
288,
302,
12,
299,
275,
699,
14,
1392,
288,
367,
284,
315,
1425,
8,
77,
304,
355,
367,
1335,
315,
1425,
8,
80,
304,
490,
445,
59,
73,
12,
1335,
61,
275,
378,
490,
367,
1022,
315,
1425,
8,
78,
304,
717,
445,
59,
73,
12,
1335,
61,
847,
437,
59,
73,
12,
1022,
61,
627,
699,
59,
75,
12,
1335,
61,
398,
486,
18810,
275,
2530,
3703,
1018,
267,
486,
18810,
14,
988,
63,
25959,
275,
10574,
398,
3634,
63,
319,
275,
499,
267,
437,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
499,
627,
841,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
499,
12,
28095,
841,
9,
267,
699,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
841,
627,
959,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
841,
12,
28095,
959,
9,
398,
366,
34,
275,
23123,
14,
475,
63,
1782,
8,
34,
9,
398,
6714,
275,
900,
342,
267,
445,
275,
486,
18810,
8,
33,
12,
366,
34,
680,
1574,
63,
475,
63,
1102,
342,
267,
14415,
6727,
275,
900,
342,
446,
6714,
398,
6714,
275,
900,
342,
267,
598,
1753,
275,
11430,
14,
3642,
63,
13710,
8,
33,
12,
699,
9,
267,
307,
3541,
275,
900,
342,
446,
6714,
398,
2222,
63,
1745,
63,
7625,
15203,
14,
740,
8,
84,
3541,
1182,
14415,
6727,
9,
398,
870,
8,
35,
12,
598,
1753,
9,
398,
291,
14,
1815,
8,
1590,
14,
7520,
8,
35,
12,
598,
1753,
430,
339,
347,
511,
63,
71,
18810,
8,
277,
304,
398,
768,
6051,
4106,
794,
779,
1647,
8,
1609,
708,
3981,
26450,
2069,
708,
3981,
26450,
2069,
708,
3981,
520,
27520,
2151,
8189,
77,
12,
78,
11865,
78,
12,
80,
20844,
8,
77,
12,
80,
3196,
2151,
1347,
534,
16309,
358,
267,
347,
2530,
3703,
1018,
8,
33,
12,
699,
12,
445,
304,
288,
333,
12,
302,
275,
437,
14,
1392,
288,
302,
12,
299,
275,
699,
14,
1392,
288,
367,
284,
315,
1425,
8,
77,
304,
355,
367,
1335,
315,
1425,
8,
80,
304,
490,
445,
59,
73,
12,
1335,
61,
275,
378,
490,
367,
1022,
315,
1425,
8,
78,
304,
717,
445,
59,
73,
12,
1335,
61,
847,
437,
59,
73,
12,
1022,
61,
627,
699,
59,
75,
12,
1335,
61,
398,
486,
18810,
275,
2530,
3703,
1018,
267,
486,
18810,
14,
988,
63,
25959,
275,
10574,
398,
3634,
63,
319,
275,
2948,
17,
327,
376,
16699,
1329,
370,
511,
2462,
15,
1457,
4629,
315,
445,
3383,
33,
267,
437,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
499,
627,
841,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
499,
12,
28095,
841,
9,
267,
699,
275,
980,
14,
5605,
8,
3642,
63,
319,
627,
841,
627,
959,
12,
2152,
29,
1590,
14,
1609,
708,
680,
5217,
8,
3642,
63,
319,
12,
841,
12,
28095,
959,
9,
398,
6714,
275,
900,
342,
267,
445,
275,
486,
18810,
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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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
Samuel789/MediPi
|
MedManagementWeb/env/lib/python3.5/site-packages/django/contrib/gis/gdal/datasource.py
|
46
|
4682
|
"""
DataSource is a wrapper for the OGR Data Source object, which provides
an interface for reading vector geometry data from many different file
formats (including ESRI shapefiles).
When instantiating a DataSource object, use the filename of a
GDAL-supported data source. For example, a SHP file or a
TIGER/Line file from the government.
The ds_driver keyword is used internally when a ctypes pointer
is passed in directly.
Example:
ds = DataSource('/home/foo/bar.shp')
for layer in ds:
for feature in layer:
# Getting the geometry for the feature.
g = feature.geom
# Getting the 'description' field for the feature.
desc = feature['description']
# We can also increment through all of the fields
# attached to this feature.
for field in feature:
# Get the name of the field (e.g. 'description')
nm = field.name
# Get the type (integer) of the field, e.g. 0 => OFTInteger
t = field.type
# Returns the value the field; OFTIntegers return ints,
# OFTReal returns floats, all else returns string.
val = field.value
"""
from ctypes import byref
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.error import GDALException, OGRIndexError
from django.contrib.gis.gdal.layer import Layer
from django.contrib.gis.gdal.prototypes import ds as capi
from django.utils import six
from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr__api_8h.html
#
# The OGR_DS_* routines are relevant here.
class DataSource(GDALBase):
"Wraps an OGR Data Source object."
destructor = capi.destroy_ds
def __init__(self, ds_input, ds_driver=False, write=False, encoding='utf-8'):
# The write flag.
if write:
self._write = 1
else:
self._write = 0
# See also http://trac.osgeo.org/gdal/wiki/rfc23_ogr_unicode
self.encoding = encoding
Driver.ensure_registered()
if isinstance(ds_input, six.string_types):
# The data source driver is a void pointer.
ds_driver = Driver.ptr_type()
try:
# OGROpen will auto-detect the data source type.
ds = capi.open_ds(force_bytes(ds_input), self._write, byref(ds_driver))
except GDALException:
# Making the error message more clear rather than something
# like "Invalid pointer returned from OGROpen".
raise GDALException('Could not open the datasource at "%s"' % ds_input)
elif isinstance(ds_input, self.ptr_type) and isinstance(ds_driver, Driver.ptr_type):
ds = ds_input
else:
raise GDALException('Invalid data source input type: %s' % type(ds_input))
if ds:
self.ptr = ds
self.driver = Driver(ds_driver)
else:
# Raise an exception if the returned pointer is NULL
raise GDALException('Invalid data source file "%s"' % ds_input)
def __iter__(self):
"Allows for iteration over the layers in a data source."
for i in range(self.layer_count):
yield self[i]
def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
if isinstance(index, six.string_types):
layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
if not layer:
raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
elif isinstance(index, int):
if index < 0 or index >= self.layer_count:
raise OGRIndexError('index out of range')
layer = capi.get_layer(self._ptr, index)
else:
raise TypeError('Invalid index type: %s' % type(index))
return Layer(layer, self)
def __len__(self):
"Returns the number of layers within the data source."
return self.layer_count
def __str__(self):
"Returns OGR GetName and Driver for the Data Source."
return '%s (%s)' % (self.name, str(self.driver))
@property
def layer_count(self):
"Returns the number of layers in the data source."
return capi.get_layer_count(self._ptr)
@property
def name(self):
"Returns the name of the data source."
name = capi.get_ds_name(self._ptr)
return force_text(name, self.encoding, strings_only=True)
|
apache-2.0
|
[
624,
199,
24300,
365,
282,
4975,
367,
314,
10904,
3918,
5800,
909,
12,
1314,
6571,
199,
376,
3217,
367,
7664,
5477,
3400,
666,
687,
5002,
3365,
570,
199,
6752,
334,
15768,
10427,
6129,
2215,
1725,
680,
421,
3979,
9034,
1958,
282,
24300,
909,
12,
675,
314,
1788,
402,
282,
199,
15801,
13,
4946,
666,
1350,
14,
221,
2104,
2893,
12,
282,
4410,
48,
570,
503,
282,
199,
377,
1277,
540,
15,
3049,
570,
687,
314,
3681,
25490,
14,
421,
710,
6364,
63,
3090,
4252,
365,
1202,
14448,
1380,
282,
5577,
7849,
199,
365,
3032,
315,
5370,
14,
421,
5679,
26,
523,
6364,
275,
24300,
2336,
4219,
15,
1421,
15,
1700,
14,
17299,
358,
523,
367,
4045,
315,
6364,
26,
489,
367,
3878,
315,
4045,
26,
881,
327,
20703,
314,
3400,
367,
314,
3878,
14,
881,
486,
275,
3878,
14,
6481,
8592,
327,
20703,
314,
283,
1802,
7,
901,
367,
314,
3878,
14,
881,
4328,
275,
3878,
459,
1802,
418,
8592,
327,
2136,
883,
2597,
11609,
4012,
1006,
402,
314,
1504,
881,
327,
221,
10102,
370,
642,
3878,
14,
881,
367,
901,
315,
3878,
26,
1598,
327,
2372,
314,
536,
402,
314,
901,
334,
69,
14,
71,
14,
283,
1802,
358,
1598,
16751,
275,
901,
14,
354,
25841,
327,
2372,
314,
730,
334,
4115,
9,
402,
314,
901,
12,
325,
14,
71,
14,
378,
9265,
20025,
2674,
1598,
307,
275,
901,
14,
466,
25841,
327,
1803,
314,
574,
314,
901,
27,
20025,
2674,
83,
372,
14526,
12,
1598,
327,
221,
20025,
10099,
2529,
15657,
12,
1006,
587,
2529,
1059,
14,
1598,
1139,
275,
901,
14,
585,
199,
624,
199,
504,
5577,
492,
15968,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
3090,
492,
19447,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
15801,
1726,
12,
10904,
12129,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1897,
492,
11915,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
6364,
465,
13648,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
421,
199,
3,
2104,
1655,
2556,
12,
1937,
314,
10904,
445,
3261,
1350,
1233,
26,
199,
3,
221,
1455,
921,
1544,
14,
11600,
14,
1308,
15,
14945,
363,
1246,
63,
24,
72,
14,
1360,
199,
3,
199,
3,
710,
10904,
63,
3177,
15192,
14975,
787,
12082,
2348,
14,
199,
533,
24300,
8,
17835,
1563,
304,
272,
298,
55,
8146,
376,
10904,
3918,
5800,
909,
2122,
272,
32133,
275,
13648,
14,
7237,
63,
795,
339,
347,
636,
826,
721,
277,
12,
6364,
63,
1210,
12,
6364,
63,
3090,
29,
797,
12,
2218,
29,
797,
12,
2644,
534,
1624,
13,
24,
735,
267,
327,
710,
2218,
3305,
14,
267,
340,
2218,
26,
288,
291,
423,
952,
275,
413,
267,
587,
26,
288,
291,
423,
952,
275,
378,
267,
327,
1666,
2597,
1455,
921,
23047,
14,
736,
6721,
14,
1308,
15,
11600,
15,
6797,
15,
8973,
1789,
63,
14945,
63,
2975,
267,
291,
14,
2991,
275,
2644,
398,
19447,
14,
7505,
63,
11616,
342,
398,
340,
1228,
8,
795,
63,
1210,
12,
3816,
14,
875,
63,
1313,
304,
288,
327,
710,
666,
1350,
5253,
365,
282,
2309,
7849,
14,
288,
6364,
63,
3090,
275,
19447,
14,
4695,
63,
466,
342,
288,
862,
26,
355,
327,
19746,
1092,
897,
911,
2599,
13,
13552,
314,
666,
1350,
730,
14,
355,
6364,
275,
13648,
14,
1490,
63,
795,
8,
3990,
63,
2394,
8,
795,
63,
1210,
395,
291,
423,
952,
12,
15968,
8,
795,
63,
3090,
430,
288,
871,
15801,
1726,
26,
355,
327,
32269,
314,
1125,
1245,
1655,
5436,
7830,
2419,
6020,
355,
327,
2839,
298,
3364,
7849,
2138,
687,
19746,
1092,
897,
1674,
355,
746,
15801,
1726,
360,
6531,
440,
1551,
314,
29289,
737,
2071,
83,
4507,
450,
6364,
63,
1210,
9,
267,
916,
1228,
8,
795,
63,
1210,
12,
291,
14,
4695,
63,
466,
9,
436,
1228,
8,
795,
63,
3090,
12,
19447,
14,
4695,
63,
466,
304,
288,
6364,
275,
6364,
63,
1210,
267,
587,
26,
288,
746,
15801,
1726,
360,
3364,
666,
1350,
1324,
730,
26,
450,
83,
7,
450,
730,
8,
795,
63,
1210,
430,
398,
340,
6364,
26,
288,
291,
14,
4695,
275,
6364,
288,
291,
14,
3090,
275,
19447,
8,
795,
63,
3090,
9,
267,
587,
26,
288,
327,
14771,
376,
1919,
340,
314,
2138,
7849,
365,
5962,
288,
746,
15801,
1726,
360,
3364,
666,
1350,
570,
2071,
83,
4507,
450,
6364,
63,
1210,
9,
339,
347,
636,
1661,
721,
277,
304,
267,
298,
19780,
367,
8494,
1806,
314,
9393,
315,
282,
666,
1350,
2122,
267,
367,
284,
315,
1425,
8,
277,
14,
1897,
63,
835,
304,
288,
1995,
291,
59,
73,
61,
339,
347,
636,
6095,
721,
277,
12,
1478,
304,
267,
298,
19780,
675,
402,
314,
1478,
942,
4182,
370,
664,
282,
4045,
737,
314,
1478,
2122,
267,
340,
1228,
8,
1080,
12,
3816,
14,
875,
63,
1313,
304,
288,
4045,
275,
13648,
14,
362,
63,
1897,
63,
991,
63,
354,
8,
277,
14,
4695,
12,
3542,
63,
2394,
8,
1080,
430,
288,
340,
440,
4045,
26,
355,
746,
10904,
12129,
360,
3197,
10904,
11915,
536,
1627,
26,
2071,
83,
4507,
450,
1478,
9,
267,
916,
1228,
8,
1080,
12,
1109,
304,
288,
340,
1478,
665,
378,
503,
1478,
2356,
291,
14,
1897,
63,
835,
26,
355,
746,
10904,
12129,
360,
1080,
734,
402,
1425,
358,
288,
4045,
275,
13648,
14,
362,
63,
1897,
8,
277,
423,
4695,
12,
1478,
9,
267,
587,
26,
288,
746,
3146,
360,
3364,
1478,
730,
26,
450,
83,
7,
450,
730,
8,
1080,
430,
267,
372,
11915,
8,
1897,
12,
291,
9,
339,
347,
636,
552,
721,
277,
304,
267,
298,
3407,
314,
1329,
402,
9393,
4453,
314,
666,
1350,
2122,
267,
372,
291,
14,
1897,
63,
835,
339,
347,
636,
495,
721,
277,
304,
267,
298,
3407,
10904,
2372,
985,
436,
19447,
367,
314,
3918,
5800,
2122,
267,
372,
1543,
83,
4366,
83,
3171
] |
[
199,
24300,
365,
282,
4975,
367,
314,
10904,
3918,
5800,
909,
12,
1314,
6571,
199,
376,
3217,
367,
7664,
5477,
3400,
666,
687,
5002,
3365,
570,
199,
6752,
334,
15768,
10427,
6129,
2215,
1725,
680,
421,
3979,
9034,
1958,
282,
24300,
909,
12,
675,
314,
1788,
402,
282,
199,
15801,
13,
4946,
666,
1350,
14,
221,
2104,
2893,
12,
282,
4410,
48,
570,
503,
282,
199,
377,
1277,
540,
15,
3049,
570,
687,
314,
3681,
25490,
14,
421,
710,
6364,
63,
3090,
4252,
365,
1202,
14448,
1380,
282,
5577,
7849,
199,
365,
3032,
315,
5370,
14,
421,
5679,
26,
523,
6364,
275,
24300,
2336,
4219,
15,
1421,
15,
1700,
14,
17299,
358,
523,
367,
4045,
315,
6364,
26,
489,
367,
3878,
315,
4045,
26,
881,
327,
20703,
314,
3400,
367,
314,
3878,
14,
881,
486,
275,
3878,
14,
6481,
8592,
327,
20703,
314,
283,
1802,
7,
901,
367,
314,
3878,
14,
881,
4328,
275,
3878,
459,
1802,
418,
8592,
327,
2136,
883,
2597,
11609,
4012,
1006,
402,
314,
1504,
881,
327,
221,
10102,
370,
642,
3878,
14,
881,
367,
901,
315,
3878,
26,
1598,
327,
2372,
314,
536,
402,
314,
901,
334,
69,
14,
71,
14,
283,
1802,
358,
1598,
16751,
275,
901,
14,
354,
25841,
327,
2372,
314,
730,
334,
4115,
9,
402,
314,
901,
12,
325,
14,
71,
14,
378,
9265,
20025,
2674,
1598,
307,
275,
901,
14,
466,
25841,
327,
1803,
314,
574,
314,
901,
27,
20025,
2674,
83,
372,
14526,
12,
1598,
327,
221,
20025,
10099,
2529,
15657,
12,
1006,
587,
2529,
1059,
14,
1598,
1139,
275,
901,
14,
585,
199,
624,
199,
504,
5577,
492,
15968,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
3090,
492,
19447,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
15801,
1726,
12,
10904,
12129,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1897,
492,
11915,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
6364,
465,
13648,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
12,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
421,
199,
3,
2104,
1655,
2556,
12,
1937,
314,
10904,
445,
3261,
1350,
1233,
26,
199,
3,
221,
1455,
921,
1544,
14,
11600,
14,
1308,
15,
14945,
363,
1246,
63,
24,
72,
14,
1360,
199,
3,
199,
3,
710,
10904,
63,
3177,
15192,
14975,
787,
12082,
2348,
14,
199,
533,
24300,
8,
17835,
1563,
304,
272,
298,
55,
8146,
376,
10904,
3918,
5800,
909,
2122,
272,
32133,
275,
13648,
14,
7237,
63,
795,
339,
347,
636,
826,
721,
277,
12,
6364,
63,
1210,
12,
6364,
63,
3090,
29,
797,
12,
2218,
29,
797,
12,
2644,
534,
1624,
13,
24,
735,
267,
327,
710,
2218,
3305,
14,
267,
340,
2218,
26,
288,
291,
423,
952,
275,
413,
267,
587,
26,
288,
291,
423,
952,
275,
378,
267,
327,
1666,
2597,
1455,
921,
23047,
14,
736,
6721,
14,
1308,
15,
11600,
15,
6797,
15,
8973,
1789,
63,
14945,
63,
2975,
267,
291,
14,
2991,
275,
2644,
398,
19447,
14,
7505,
63,
11616,
342,
398,
340,
1228,
8,
795,
63,
1210,
12,
3816,
14,
875,
63,
1313,
304,
288,
327,
710,
666,
1350,
5253,
365,
282,
2309,
7849,
14,
288,
6364,
63,
3090,
275,
19447,
14,
4695,
63,
466,
342,
288,
862,
26,
355,
327,
19746,
1092,
897,
911,
2599,
13,
13552,
314,
666,
1350,
730,
14,
355,
6364,
275,
13648,
14,
1490,
63,
795,
8,
3990,
63,
2394,
8,
795,
63,
1210,
395,
291,
423,
952,
12,
15968,
8,
795,
63,
3090,
430,
288,
871,
15801,
1726,
26,
355,
327,
32269,
314,
1125,
1245,
1655,
5436,
7830,
2419,
6020,
355,
327,
2839,
298,
3364,
7849,
2138,
687,
19746,
1092,
897,
1674,
355,
746,
15801,
1726,
360,
6531,
440,
1551,
314,
29289,
737,
2071,
83,
4507,
450,
6364,
63,
1210,
9,
267,
916,
1228,
8,
795,
63,
1210,
12,
291,
14,
4695,
63,
466,
9,
436,
1228,
8,
795,
63,
3090,
12,
19447,
14,
4695,
63,
466,
304,
288,
6364,
275,
6364,
63,
1210,
267,
587,
26,
288,
746,
15801,
1726,
360,
3364,
666,
1350,
1324,
730,
26,
450,
83,
7,
450,
730,
8,
795,
63,
1210,
430,
398,
340,
6364,
26,
288,
291,
14,
4695,
275,
6364,
288,
291,
14,
3090,
275,
19447,
8,
795,
63,
3090,
9,
267,
587,
26,
288,
327,
14771,
376,
1919,
340,
314,
2138,
7849,
365,
5962,
288,
746,
15801,
1726,
360,
3364,
666,
1350,
570,
2071,
83,
4507,
450,
6364,
63,
1210,
9,
339,
347,
636,
1661,
721,
277,
304,
267,
298,
19780,
367,
8494,
1806,
314,
9393,
315,
282,
666,
1350,
2122,
267,
367,
284,
315,
1425,
8,
277,
14,
1897,
63,
835,
304,
288,
1995,
291,
59,
73,
61,
339,
347,
636,
6095,
721,
277,
12,
1478,
304,
267,
298,
19780,
675,
402,
314,
1478,
942,
4182,
370,
664,
282,
4045,
737,
314,
1478,
2122,
267,
340,
1228,
8,
1080,
12,
3816,
14,
875,
63,
1313,
304,
288,
4045,
275,
13648,
14,
362,
63,
1897,
63,
991,
63,
354,
8,
277,
14,
4695,
12,
3542,
63,
2394,
8,
1080,
430,
288,
340,
440,
4045,
26,
355,
746,
10904,
12129,
360,
3197,
10904,
11915,
536,
1627,
26,
2071,
83,
4507,
450,
1478,
9,
267,
916,
1228,
8,
1080,
12,
1109,
304,
288,
340,
1478,
665,
378,
503,
1478,
2356,
291,
14,
1897,
63,
835,
26,
355,
746,
10904,
12129,
360,
1080,
734,
402,
1425,
358,
288,
4045,
275,
13648,
14,
362,
63,
1897,
8,
277,
423,
4695,
12,
1478,
9,
267,
587,
26,
288,
746,
3146,
360,
3364,
1478,
730,
26,
450,
83,
7,
450,
730,
8,
1080,
430,
267,
372,
11915,
8,
1897,
12,
291,
9,
339,
347,
636,
552,
721,
277,
304,
267,
298,
3407,
314,
1329,
402,
9393,
4453,
314,
666,
1350,
2122,
267,
372,
291,
14,
1897,
63,
835,
339,
347,
636,
495,
721,
277,
304,
267,
298,
3407,
10904,
2372,
985,
436,
19447,
367,
314,
3918,
5800,
2122,
267,
372,
1543,
83,
4366,
83,
3171,
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,
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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
] |
jannishuebl/electron
|
script/bump-version.py
|
135
|
3506
|
#!/usr/bin/env python
import os
import re
import sys
from lib.util import execute, get_atom_shell_version, parse_version, scoped_cwd
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main():
if len(sys.argv) != 2 or sys.argv[1] == '-h':
print 'Usage: bump-version.py [<version> | major | minor | patch]'
return 1
option = sys.argv[1]
increments = ['major', 'minor', 'patch', 'build']
if option in increments:
version = get_atom_shell_version()
versions = parse_version(version.split('-')[0])
versions = increase_version(versions, increments.index(option))
else:
versions = parse_version(option)
version = '.'.join(versions[:3])
with scoped_cwd(SOURCE_ROOT):
update_atom_gyp(version)
update_win_rc(version, versions)
update_version_h(versions)
update_info_plist(version)
tag_version(version)
def increase_version(versions, index):
for i in range(index + 1, 4):
versions[i] = '0'
versions[index] = str(int(versions[index]) + 1)
return versions
def update_atom_gyp(version):
pattern = re.compile(" *'version%' *: *'[0-9.]+'")
with open('atom.gyp', 'r') as f:
lines = f.readlines()
for i in range(0, len(lines)):
if pattern.match(lines[i]):
lines[i] = " 'version%': '{0}',\n".format(version)
with open('atom.gyp', 'w') as f:
f.write(''.join(lines))
return
def update_win_rc(version, versions):
pattern_fv = re.compile(' FILEVERSION [0-9,]+')
pattern_pv = re.compile(' PRODUCTVERSION [0-9,]+')
pattern_fvs = re.compile(' *VALUE "FileVersion", "[0-9.]+"')
pattern_pvs = re.compile(' *VALUE "ProductVersion", "[0-9.]+"')
win_rc = os.path.join('atom', 'browser', 'resources', 'win', 'atom.rc')
with open(win_rc, 'r') as f:
lines = f.readlines()
versions = [str(v) for v in versions]
for i in range(0, len(lines)):
line = lines[i]
if pattern_fv.match(line):
lines[i] = ' FILEVERSION {0}\r\n'.format(','.join(versions))
elif pattern_pv.match(line):
lines[i] = ' PRODUCTVERSION {0}\r\n'.format(','.join(versions))
elif pattern_fvs.match(line):
lines[i] = ' VALUE "FileVersion", "{0}"\r\n'.format(version)
elif pattern_pvs.match(line):
lines[i] = ' VALUE "ProductVersion", "{0}"\r\n'.format(version)
with open(win_rc, 'w') as f:
f.write(''.join(lines))
def update_version_h(versions):
version_h = os.path.join('atom', 'common', 'atom_version.h')
with open(version_h, 'r') as f:
lines = f.readlines()
for i in range(0, len(lines)):
line = lines[i]
if 'ATOM_MAJOR_VERSION' in line:
lines[i] = '#define ATOM_MAJOR_VERSION {0}\n'.format(versions[0])
lines[i + 1] = '#define ATOM_MINOR_VERSION {0}\n'.format(versions[1])
lines[i + 2] = '#define ATOM_PATCH_VERSION {0}\n'.format(versions[2])
with open(version_h, 'w') as f:
f.write(''.join(lines))
return
def update_info_plist(version):
info_plist = os.path.join('atom', 'browser', 'resources', 'mac', 'Info.plist')
with open(info_plist, 'r') as f:
lines = f.readlines()
for i in range(0, len(lines)):
line = lines[i]
if 'CFBundleVersion' in line:
lines[i + 1] = ' <string>{0}</string>\n'.format(version)
with open(info_plist, 'w') as f:
f.write(''.join(lines))
return
def tag_version(version):
execute(['git', 'commit', '-a', '-m', 'Bump v{0}'.format(version)])
if __name__ == '__main__':
sys.exit(main())
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
199,
504,
1973,
14,
1974,
492,
5341,
12,
664,
63,
4188,
63,
5641,
63,
1023,
12,
2198,
63,
1023,
12,
27582,
63,
6525,
421,
199,
10187,
63,
5441,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
29658,
421,
199,
318,
2446,
837,
523,
340,
822,
8,
1274,
14,
3020,
9,
1137,
499,
503,
984,
14,
3020,
59,
17,
61,
508,
2475,
72,
356,
272,
870,
283,
7692,
26,
28108,
13,
1023,
14,
647,
24936,
1023,
30,
1204,
12160,
1204,
12612,
1204,
3371,
6616,
272,
372,
413,
819,
945,
275,
984,
14,
3020,
59,
17,
61,
523,
10035,
1470,
275,
788,
8452,
297,
283,
11067,
297,
283,
2068,
297,
283,
1506,
418,
523,
340,
945,
315,
10035,
1470,
26,
272,
1015,
275,
664,
63,
4188,
63,
5641,
63,
1023,
342,
272,
5459,
275,
2198,
63,
1023,
8,
1023,
14,
1294,
3654,
5832,
16,
566,
272,
5459,
275,
19781,
63,
1023,
8,
6234,
12,
10035,
1470,
14,
1080,
8,
1422,
430,
523,
587,
26,
272,
5459,
275,
2198,
63,
1023,
8,
1422,
9,
819,
1015,
275,
15671,
904,
8,
6234,
1491,
19,
566,
819,
543,
27582,
63,
6525,
8,
10187,
63,
5441,
304,
272,
1678,
63,
4188,
63,
6179,
8,
1023,
9,
272,
1678,
63,
2676,
63,
1195,
8,
1023,
12,
5459,
9,
272,
1678,
63,
1023,
63,
72,
8,
6234,
9,
272,
1678,
63,
815,
63,
10265,
8,
1023,
9,
272,
1947,
63,
1023,
8,
1023,
9,
421,
199,
318,
19781,
63,
1023,
8,
6234,
12,
1478,
304,
523,
367,
284,
315,
1425,
8,
1080,
435,
413,
12,
841,
304,
272,
5459,
59,
73,
61,
275,
283,
16,
7,
523,
5459,
59,
1080,
61,
275,
620,
8,
442,
8,
6234,
59,
1080,
566,
435,
413,
9,
523,
372,
5459,
421,
199,
318,
1678,
63,
4188,
63,
6179,
8,
1023,
304,
523,
3851,
275,
295,
14,
2014,
480,
627,
7,
1023,
5,
7,
627,
26,
627,
3894,
16,
13,
25,
32455,
9859,
523,
543,
1551,
360,
4188,
14,
6179,
297,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14,
9684,
342,
819,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
1278,
2298,
272,
340,
3851,
14,
1431,
8,
1278,
59,
73,
4682,
489,
2385,
59,
73,
61,
275,
298,
259,
283,
1023,
5,
356,
5041,
16,
7293,
60,
78,
1674,
908,
8,
1023,
9,
489,
543,
1551,
360,
4188,
14,
6179,
297,
283,
87,
358,
465,
289,
26,
267,
289,
14,
952,
17840,
904,
8,
1278,
430,
489,
372,
421,
199,
318,
1678,
63,
2676,
63,
1195,
8,
1023,
12,
5459,
304,
523,
3851,
63,
13692,
275,
295,
14,
2014,
360,
13024,
4612,
359,
16,
13,
25,
12,
2807,
358,
523,
3851,
63,
1381,
275,
295,
14,
2014,
360,
3611,
13461,
4612,
359,
16,
13,
25,
12,
2807,
358,
523,
3851,
63,
70,
3122,
275,
295,
14,
2014,
360,
627,
7041,
298,
1173,
3353,
401,
7369,
16,
13,
25,
32455,
9008,
523,
3851,
63,
1381,
83,
275,
295,
14,
2014,
360,
627,
7041,
298,
5884,
3353,
401,
7369,
16,
13,
25,
32455,
9008,
819,
4747,
63,
1195,
275,
747,
14,
515,
14,
904,
360,
4188,
297,
283,
5750,
297,
283,
4435,
297,
283,
2676,
297,
283,
4188,
14,
1195,
358,
523,
543,
1551,
8,
2676,
63,
1195,
12,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14,
9684,
342,
819,
5459,
275,
359,
495,
8,
86,
9,
367,
373,
315,
5459,
61,
523,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
1278,
2298,
272,
1004,
275,
2385,
59,
73,
61,
272,
340,
3851,
63,
13692,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
13024,
4612,
469,
16,
4988,
82,
60,
78,
1370,
908,
5102,
1370,
904,
8,
6234,
430,
272,
916,
3851,
63,
1381,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
3611,
13461,
4612,
469,
16,
4988,
82,
60,
78,
1370,
908,
5102,
1370,
904,
8,
6234,
430,
272,
916,
3851,
63,
70,
3122,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
3322,
21170,
298,
1173,
3353,
401,
5310,
16,
93,
3212,
82,
60,
78,
1370,
908,
8,
1023,
9,
272,
916,
3851,
63,
1381,
83,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
3322,
21170,
298,
5884,
3353,
401,
5310,
16,
93,
3212,
82,
60,
78,
1370,
908,
8,
1023,
9,
819,
543,
1551,
8,
2676,
63,
1195,
12,
283,
87,
358,
465,
289,
26,
272,
289,
14,
952,
17840,
904,
8,
1278,
430,
421,
199,
318,
1678,
63,
1023,
63,
72,
8,
6234,
304,
523,
1015,
63,
72,
275,
747,
14,
515,
14,
904,
360,
4188,
297,
283,
2330,
297,
283,
4188,
63,
1023,
14,
72,
358,
523,
543,
1551,
8,
1023,
63,
72,
12,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14,
9684,
342,
819,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
1278,
2298,
272,
1004,
275,
2385,
59,
73,
61,
272,
340,
283,
22479,
63,
29241,
63,
4612,
7,
315,
1004,
26,
489,
2385,
59,
73,
61,
275,
3943,
4640,
437,
19731,
63,
29241,
63,
4612,
469,
16,
4988,
78,
1370,
908,
8,
6234,
59,
16,
566,
489,
2385,
59,
73,
435,
413,
61,
275,
3943,
4640,
437,
19731,
63,
4896,
726,
63,
4612,
469,
16,
4988,
78,
1370,
908,
8,
6234,
59,
17,
566,
489,
2385,
59,
73,
435,
499,
61,
275,
3943,
4640,
437,
19731,
63,
17073,
63,
4612,
469,
16,
4988,
78,
1370,
908,
8,
6234,
59,
18,
566,
2541,
543,
1551,
8,
1023,
63,
72,
12,
283,
87,
358,
465,
289,
26,
267,
289,
14,
952,
17840,
904,
8,
1278,
430,
489,
372,
421,
199,
318,
1678,
63,
815,
63,
10265,
8,
1023,
304,
523,
2256,
63,
10265,
275,
747,
14,
515,
14,
904,
360,
4188,
297,
283,
5750,
297,
283,
4435,
297,
283,
3088,
297,
283,
2354,
14,
10265,
358,
523,
543,
1551,
8,
815,
63,
10265,
12,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
747,
199,
646,
295,
199,
646,
984,
199,
199,
504,
1973,
14,
1974,
492,
5341,
12,
664,
63,
4188,
63,
5641,
63,
1023,
12,
2198,
63,
1023,
12,
27582,
63,
6525,
421,
199,
10187,
63,
5441,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
3475,
3460,
493,
29658,
421,
199,
318,
2446,
837,
523,
340,
822,
8,
1274,
14,
3020,
9,
1137,
499,
503,
984,
14,
3020,
59,
17,
61,
508,
2475,
72,
356,
272,
870,
283,
7692,
26,
28108,
13,
1023,
14,
647,
24936,
1023,
30,
1204,
12160,
1204,
12612,
1204,
3371,
6616,
272,
372,
413,
819,
945,
275,
984,
14,
3020,
59,
17,
61,
523,
10035,
1470,
275,
788,
8452,
297,
283,
11067,
297,
283,
2068,
297,
283,
1506,
418,
523,
340,
945,
315,
10035,
1470,
26,
272,
1015,
275,
664,
63,
4188,
63,
5641,
63,
1023,
342,
272,
5459,
275,
2198,
63,
1023,
8,
1023,
14,
1294,
3654,
5832,
16,
566,
272,
5459,
275,
19781,
63,
1023,
8,
6234,
12,
10035,
1470,
14,
1080,
8,
1422,
430,
523,
587,
26,
272,
5459,
275,
2198,
63,
1023,
8,
1422,
9,
819,
1015,
275,
15671,
904,
8,
6234,
1491,
19,
566,
819,
543,
27582,
63,
6525,
8,
10187,
63,
5441,
304,
272,
1678,
63,
4188,
63,
6179,
8,
1023,
9,
272,
1678,
63,
2676,
63,
1195,
8,
1023,
12,
5459,
9,
272,
1678,
63,
1023,
63,
72,
8,
6234,
9,
272,
1678,
63,
815,
63,
10265,
8,
1023,
9,
272,
1947,
63,
1023,
8,
1023,
9,
421,
199,
318,
19781,
63,
1023,
8,
6234,
12,
1478,
304,
523,
367,
284,
315,
1425,
8,
1080,
435,
413,
12,
841,
304,
272,
5459,
59,
73,
61,
275,
283,
16,
7,
523,
5459,
59,
1080,
61,
275,
620,
8,
442,
8,
6234,
59,
1080,
566,
435,
413,
9,
523,
372,
5459,
421,
199,
318,
1678,
63,
4188,
63,
6179,
8,
1023,
304,
523,
3851,
275,
295,
14,
2014,
480,
627,
7,
1023,
5,
7,
627,
26,
627,
3894,
16,
13,
25,
32455,
9859,
523,
543,
1551,
360,
4188,
14,
6179,
297,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14,
9684,
342,
819,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
1278,
2298,
272,
340,
3851,
14,
1431,
8,
1278,
59,
73,
4682,
489,
2385,
59,
73,
61,
275,
298,
259,
283,
1023,
5,
356,
5041,
16,
7293,
60,
78,
1674,
908,
8,
1023,
9,
489,
543,
1551,
360,
4188,
14,
6179,
297,
283,
87,
358,
465,
289,
26,
267,
289,
14,
952,
17840,
904,
8,
1278,
430,
489,
372,
421,
199,
318,
1678,
63,
2676,
63,
1195,
8,
1023,
12,
5459,
304,
523,
3851,
63,
13692,
275,
295,
14,
2014,
360,
13024,
4612,
359,
16,
13,
25,
12,
2807,
358,
523,
3851,
63,
1381,
275,
295,
14,
2014,
360,
3611,
13461,
4612,
359,
16,
13,
25,
12,
2807,
358,
523,
3851,
63,
70,
3122,
275,
295,
14,
2014,
360,
627,
7041,
298,
1173,
3353,
401,
7369,
16,
13,
25,
32455,
9008,
523,
3851,
63,
1381,
83,
275,
295,
14,
2014,
360,
627,
7041,
298,
5884,
3353,
401,
7369,
16,
13,
25,
32455,
9008,
819,
4747,
63,
1195,
275,
747,
14,
515,
14,
904,
360,
4188,
297,
283,
5750,
297,
283,
4435,
297,
283,
2676,
297,
283,
4188,
14,
1195,
358,
523,
543,
1551,
8,
2676,
63,
1195,
12,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14,
9684,
342,
819,
5459,
275,
359,
495,
8,
86,
9,
367,
373,
315,
5459,
61,
523,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
1278,
2298,
272,
1004,
275,
2385,
59,
73,
61,
272,
340,
3851,
63,
13692,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
13024,
4612,
469,
16,
4988,
82,
60,
78,
1370,
908,
5102,
1370,
904,
8,
6234,
430,
272,
916,
3851,
63,
1381,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
3611,
13461,
4612,
469,
16,
4988,
82,
60,
78,
1370,
908,
5102,
1370,
904,
8,
6234,
430,
272,
916,
3851,
63,
70,
3122,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
3322,
21170,
298,
1173,
3353,
401,
5310,
16,
93,
3212,
82,
60,
78,
1370,
908,
8,
1023,
9,
272,
916,
3851,
63,
1381,
83,
14,
1431,
8,
604,
304,
489,
2385,
59,
73,
61,
275,
283,
3322,
21170,
298,
5884,
3353,
401,
5310,
16,
93,
3212,
82,
60,
78,
1370,
908,
8,
1023,
9,
819,
543,
1551,
8,
2676,
63,
1195,
12,
283,
87,
358,
465,
289,
26,
272,
289,
14,
952,
17840,
904,
8,
1278,
430,
421,
199,
318,
1678,
63,
1023,
63,
72,
8,
6234,
304,
523,
1015,
63,
72,
275,
747,
14,
515,
14,
904,
360,
4188,
297,
283,
2330,
297,
283,
4188,
63,
1023,
14,
72,
358,
523,
543,
1551,
8,
1023,
63,
72,
12,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
14,
9684,
342,
819,
367,
284,
315,
1425,
8,
16,
12,
822,
8,
1278,
2298,
272,
1004,
275,
2385,
59,
73,
61,
272,
340,
283,
22479,
63,
29241,
63,
4612,
7,
315,
1004,
26,
489,
2385,
59,
73,
61,
275,
3943,
4640,
437,
19731,
63,
29241,
63,
4612,
469,
16,
4988,
78,
1370,
908,
8,
6234,
59,
16,
566,
489,
2385,
59,
73,
435,
413,
61,
275,
3943,
4640,
437,
19731,
63,
4896,
726,
63,
4612,
469,
16,
4988,
78,
1370,
908,
8,
6234,
59,
17,
566,
489,
2385,
59,
73,
435,
499,
61,
275,
3943,
4640,
437,
19731,
63,
17073,
63,
4612,
469,
16,
4988,
78,
1370,
908,
8,
6234,
59,
18,
566,
2541,
543,
1551,
8,
1023,
63,
72,
12,
283,
87,
358,
465,
289,
26,
267,
289,
14,
952,
17840,
904,
8,
1278,
430,
489,
372,
421,
199,
318,
1678,
63,
815,
63,
10265,
8,
1023,
304,
523,
2256,
63,
10265,
275,
747,
14,
515,
14,
904,
360,
4188,
297,
283,
5750,
297,
283,
4435,
297,
283,
3088,
297,
283,
2354,
14,
10265,
358,
523,
543,
1551,
8,
815,
63,
10265,
12,
283,
82,
358,
465,
289,
26,
272,
2385,
275,
289,
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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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,
1
] |
olivierayache/xuggle-xuggler
|
captive/libx264/csrc/tools/digress/cli.py
|
145
|
4413
|
"""
Digress's CLI interface.
"""
import inspect
import sys
from optparse import OptionParser
import textwrap
from types import MethodType
from digress import __version__ as version
def dispatchable(func):
"""
Mark a method as dispatchable.
"""
func.digress_dispatchable = True
return func
class Dispatcher(object):
"""
Dispatcher for CLI commands.
"""
def __init__(self, fixture):
self.fixture = fixture
fixture.dispatcher = self
def _monkey_print_help(self, optparse, *args, **kwargs):
# monkey patches OptionParser._print_help
OptionParser.print_help(optparse, *args, **kwargs)
print >>sys.stderr, "\nAvailable commands:"
maxlen = max([ len(command_name) for command_name in self.commands ])
descwidth = 80 - maxlen - 4
for command_name, command_meth in self.commands.iteritems():
print >>sys.stderr, " %s %s\n" % (
command_name.ljust(maxlen + 1),
("\n" + (maxlen + 4) * " ").join(
textwrap.wrap(" ".join(filter(
None,
command_meth.__doc__.strip().replace("\n", " ").split(" ")
)),
descwidth
)
)
)
def _enable_flush(self):
self.fixture.flush_before = True
def _populate_parser(self):
self.commands = self._get_commands()
self.optparse = OptionParser(
usage = "usage: %prog [options] command [args]",
description = "Digress CLI frontend for %s." % self.fixture.__class__.__name__,
version = "Digress %s" % version
)
self.optparse.print_help = MethodType(self._monkey_print_help, self.optparse, OptionParser)
self.optparse.add_option(
"-f",
"--flush",
action="callback",
callback=lambda option, opt, value, parser: self._enable_flush(),
help="flush existing data for a revision before testing"
)
self.optparse.add_option(
"-c",
"--cases",
metavar="FOO,BAR",
action="callback",
dest="cases",
type=str,
callback=lambda option, opt, value, parser: self._select_cases(*value.split(",")),
help="test cases to run, run with command list to see full list"
)
def _select_cases(self, *cases):
self.fixture.cases = filter(lambda case: case.__name__ in cases, self.fixture.cases)
def _get_commands(self):
commands = {}
for name, member in inspect.getmembers(self.fixture):
if hasattr(member, "digress_dispatchable"):
commands[name] = member
return commands
def _run_command(self, name, *args):
if name not in self.commands:
print >>sys.stderr, "error: %s is not a valid command\n" % name
self.optparse.print_help()
return
command = self.commands[name]
argspec = inspect.getargspec(command)
max_arg_len = len(argspec.args) - 1
min_arg_len = max_arg_len - ((argspec.defaults is not None) and len(argspec.defaults) or 0)
if len(args) < min_arg_len:
print >>sys.stderr, "error: %s takes at least %d arguments\n" % (
name,
min_arg_len
)
print >>sys.stderr, "%s\n" % command.__doc__
self.optparse.print_help()
return
if len(args) > max_arg_len:
print >>sys.stderr, "error: %s takes at most %d arguments\n" % (
name,
max_arg_len
)
print >>sys.stderr, "%s\n" % command.__doc__
self.optparse.print_help()
return
command(*args)
def pre_dispatch(self):
pass
def dispatch(self):
self._populate_parser()
self.optparse.parse_args()
self.pre_dispatch()
args = self.optparse.parse_args()[1] # arguments may require reparsing after pre_dispatch; see test_x264.py
if len(args) == 0:
print >>sys.stderr, "error: no comamnd specified\n"
self.optparse.print_help()
return
command = args[0]
addenda = args[1:]
self._run_command(command, *addenda)
|
lgpl-3.0
|
[
624,
199,
17107,
753,
1159,
14214,
3217,
14,
199,
624,
199,
199,
646,
6485,
199,
646,
984,
199,
504,
8691,
492,
13491,
199,
199,
646,
13390,
199,
199,
504,
2943,
492,
9075,
804,
199,
199,
504,
487,
3313,
492,
636,
1023,
363,
465,
1015,
199,
199,
318,
7634,
461,
8,
1532,
304,
272,
408,
272,
7173,
282,
1083,
465,
7634,
461,
14,
272,
408,
272,
2562,
14,
328,
3313,
63,
6052,
461,
275,
715,
272,
372,
2562,
199,
199,
533,
5289,
11238,
8,
785,
304,
272,
408,
272,
5289,
11238,
367,
14214,
3718,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
10949,
304,
267,
291,
14,
5997,
275,
10949,
267,
10949,
14,
14913,
275,
291,
339,
347,
485,
20372,
63,
1361,
63,
3437,
8,
277,
12,
8691,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
14198,
12385,
13491,
423,
1361,
63,
3437,
267,
13491,
14,
1361,
63,
3437,
8,
2992,
1122,
12,
627,
589,
12,
1011,
958,
9,
398,
870,
4331,
1274,
14,
3083,
12,
1867,
78,
11464,
3718,
5424,
398,
21037,
275,
1390,
779,
822,
8,
1531,
63,
354,
9,
367,
1414,
63,
354,
315,
291,
14,
4405,
4794,
398,
4328,
2063,
275,
5939,
446,
21037,
446,
841,
398,
367,
1414,
63,
354,
12,
1414,
63,
5247,
315,
291,
14,
4405,
14,
4611,
837,
288,
870,
4331,
1274,
14,
3083,
12,
298,
221,
450,
83,
450,
83,
60,
78,
2,
450,
334,
355,
1414,
63,
354,
14,
19996,
8,
29078,
435,
413,
395,
355,
25381,
78,
2,
435,
334,
29078,
435,
841,
9,
627,
298,
298,
680,
904,
8,
490,
13390,
14,
3823,
480,
3680,
904,
8,
1541,
8,
1169,
488,
12,
1169,
1414,
63,
5247,
855,
1301,
4343,
1913,
1252,
1814,
4582,
78,
401,
298,
298,
680,
1294,
480,
6099,
717,
22583,
717,
4328,
2063,
490,
776,
355,
776,
288,
776,
339,
347,
485,
4296,
63,
4939,
8,
277,
304,
267,
291,
14,
5997,
14,
4939,
63,
5182,
275,
715,
339,
347,
485,
13817,
63,
2087,
8,
277,
304,
267,
291,
14,
4405,
275,
291,
423,
362,
63,
4405,
342,
398,
291,
14,
2992,
1122,
275,
13491,
8,
288,
4503,
275,
298,
3807,
26,
450,
6595,
359,
1419,
61,
1414,
359,
589,
11472,
288,
1369,
275,
298,
17107,
753,
14214,
22523,
367,
450,
83,
2122,
450,
291,
14,
5997,
855,
533,
4914,
354,
3108,
288,
1015,
275,
298,
17107,
753,
450,
83,
2,
450,
1015,
267,
776,
398,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
275,
9075,
804,
8,
277,
423,
20372,
63,
1361,
63,
3437,
12,
291,
14,
2992,
1122,
12,
13491,
9,
398,
291,
14,
2992,
1122,
14,
525,
63,
1422,
8,
288,
3905,
70,
401,
288,
4320,
4939,
401,
288,
1595,
628,
3058,
401,
288,
3233,
29,
2734,
945,
12,
2450,
12,
574,
12,
1798,
26,
291,
423,
4296,
63,
4939,
1062,
288,
1720,
628,
4939,
3411,
666,
367,
282,
6974,
2544,
5343,
2,
267,
776,
398,
291,
14,
2992,
1122,
14,
525,
63,
1422,
8,
288,
3905,
67,
401,
288,
4320,
9403,
401,
288,
8214,
628,
13046,
12,
13895,
401,
288,
1595,
628,
3058,
401,
288,
2053,
628,
9403,
401,
288,
730,
29,
495,
12,
288,
3233,
29,
2734,
945,
12,
2450,
12,
574,
12,
1798,
26,
291,
423,
2416,
63,
9403,
2031,
585,
14,
1294,
11854,
8150,
288,
1720,
628,
396,
5560,
370,
1255,
12,
1255,
543,
1414,
769,
370,
1937,
2615,
769,
2,
267,
776,
339,
347,
485,
2416,
63,
9403,
8,
277,
12,
627,
9403,
304,
267,
291,
14,
5997,
14,
9403,
275,
2457,
8,
2734,
1930,
26,
1930,
855,
354,
363,
315,
5560,
12,
291,
14,
5997,
14,
9403,
9,
339,
347,
485,
362,
63,
4405,
8,
277,
304,
267,
3718,
275,
1052,
398,
367,
536,
12,
3653,
315,
6485,
14,
28719,
8,
277,
14,
5997,
304,
288,
340,
2688,
8,
1114,
12,
298,
328,
3313,
63,
6052,
461,
2349,
355,
3718,
59,
354,
61,
275,
3653,
398,
372,
3718,
339,
347,
485,
1065,
63,
1531,
8,
277,
12,
536,
12,
627,
589,
304,
267,
340,
536,
440,
315,
291,
14,
4405,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
450,
83,
365,
440,
282,
1686,
1414,
60,
78,
2,
450,
536,
288,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
342,
288,
372,
398,
1414,
275,
291,
14,
4405,
59,
354,
61,
398,
26632,
275,
6485,
14,
29836,
8,
1531,
9,
398,
1390,
63,
1273,
63,
552,
275,
822,
8,
15644,
14,
589,
9,
446,
413,
267,
1748,
63,
1273,
63,
552,
275,
1390,
63,
1273,
63,
552,
446,
3666,
15644,
14,
4322,
365,
440,
488,
9,
436,
822,
8,
15644,
14,
4322,
9,
503,
378,
9,
398,
340,
822,
8,
589,
9,
665,
1748,
63,
1273,
63,
552,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
450,
83,
6181,
737,
5210,
450,
68,
2368,
60,
78,
2,
450,
334,
355,
536,
12,
355,
1748,
63,
1273,
63,
552,
288,
776,
288,
870,
4331,
1274,
14,
3083,
12,
2071,
83,
60,
78,
2,
450,
1414,
855,
1301,
363,
288,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
342,
288,
372,
398,
340,
822,
8,
589,
9,
690,
1390,
63,
1273,
63,
552,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
450,
83,
6181,
737,
4750,
450,
68,
2368,
60,
78,
2,
450,
334,
355,
536,
12,
355,
1390,
63,
1273,
63,
552,
288,
776,
288,
870,
4331,
1274,
14,
3083,
12,
2071,
83,
60,
78,
2,
450,
1414,
855,
1301,
363,
288,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
342,
288,
372,
398,
1414,
2031,
589,
9,
339,
347,
876,
63,
6052,
8,
277,
304,
267,
986,
339,
347,
7634,
8,
277,
304,
267,
291,
423,
13817,
63,
2087,
342,
398,
291,
14,
2992,
1122,
14,
1122,
63,
589,
342,
267,
291,
14,
657,
63,
6052,
342,
267,
1249,
275,
291,
14,
2992,
1122,
14,
1122,
63,
589,
3430,
17,
61,
327,
2368,
1443,
4409,
295,
11059,
2410,
876,
63,
6052,
27,
1937,
511,
63,
88,
9408,
14,
647,
398,
340,
822,
8,
589,
9,
508,
378,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
949
] |
[
199,
17107,
753,
1159,
14214,
3217,
14,
199,
624,
199,
199,
646,
6485,
199,
646,
984,
199,
504,
8691,
492,
13491,
199,
199,
646,
13390,
199,
199,
504,
2943,
492,
9075,
804,
199,
199,
504,
487,
3313,
492,
636,
1023,
363,
465,
1015,
199,
199,
318,
7634,
461,
8,
1532,
304,
272,
408,
272,
7173,
282,
1083,
465,
7634,
461,
14,
272,
408,
272,
2562,
14,
328,
3313,
63,
6052,
461,
275,
715,
272,
372,
2562,
199,
199,
533,
5289,
11238,
8,
785,
304,
272,
408,
272,
5289,
11238,
367,
14214,
3718,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
10949,
304,
267,
291,
14,
5997,
275,
10949,
267,
10949,
14,
14913,
275,
291,
339,
347,
485,
20372,
63,
1361,
63,
3437,
8,
277,
12,
8691,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
14198,
12385,
13491,
423,
1361,
63,
3437,
267,
13491,
14,
1361,
63,
3437,
8,
2992,
1122,
12,
627,
589,
12,
1011,
958,
9,
398,
870,
4331,
1274,
14,
3083,
12,
1867,
78,
11464,
3718,
5424,
398,
21037,
275,
1390,
779,
822,
8,
1531,
63,
354,
9,
367,
1414,
63,
354,
315,
291,
14,
4405,
4794,
398,
4328,
2063,
275,
5939,
446,
21037,
446,
841,
398,
367,
1414,
63,
354,
12,
1414,
63,
5247,
315,
291,
14,
4405,
14,
4611,
837,
288,
870,
4331,
1274,
14,
3083,
12,
298,
221,
450,
83,
450,
83,
60,
78,
2,
450,
334,
355,
1414,
63,
354,
14,
19996,
8,
29078,
435,
413,
395,
355,
25381,
78,
2,
435,
334,
29078,
435,
841,
9,
627,
298,
298,
680,
904,
8,
490,
13390,
14,
3823,
480,
3680,
904,
8,
1541,
8,
1169,
488,
12,
1169,
1414,
63,
5247,
855,
1301,
4343,
1913,
1252,
1814,
4582,
78,
401,
298,
298,
680,
1294,
480,
6099,
717,
22583,
717,
4328,
2063,
490,
776,
355,
776,
288,
776,
339,
347,
485,
4296,
63,
4939,
8,
277,
304,
267,
291,
14,
5997,
14,
4939,
63,
5182,
275,
715,
339,
347,
485,
13817,
63,
2087,
8,
277,
304,
267,
291,
14,
4405,
275,
291,
423,
362,
63,
4405,
342,
398,
291,
14,
2992,
1122,
275,
13491,
8,
288,
4503,
275,
298,
3807,
26,
450,
6595,
359,
1419,
61,
1414,
359,
589,
11472,
288,
1369,
275,
298,
17107,
753,
14214,
22523,
367,
450,
83,
2122,
450,
291,
14,
5997,
855,
533,
4914,
354,
3108,
288,
1015,
275,
298,
17107,
753,
450,
83,
2,
450,
1015,
267,
776,
398,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
275,
9075,
804,
8,
277,
423,
20372,
63,
1361,
63,
3437,
12,
291,
14,
2992,
1122,
12,
13491,
9,
398,
291,
14,
2992,
1122,
14,
525,
63,
1422,
8,
288,
3905,
70,
401,
288,
4320,
4939,
401,
288,
1595,
628,
3058,
401,
288,
3233,
29,
2734,
945,
12,
2450,
12,
574,
12,
1798,
26,
291,
423,
4296,
63,
4939,
1062,
288,
1720,
628,
4939,
3411,
666,
367,
282,
6974,
2544,
5343,
2,
267,
776,
398,
291,
14,
2992,
1122,
14,
525,
63,
1422,
8,
288,
3905,
67,
401,
288,
4320,
9403,
401,
288,
8214,
628,
13046,
12,
13895,
401,
288,
1595,
628,
3058,
401,
288,
2053,
628,
9403,
401,
288,
730,
29,
495,
12,
288,
3233,
29,
2734,
945,
12,
2450,
12,
574,
12,
1798,
26,
291,
423,
2416,
63,
9403,
2031,
585,
14,
1294,
11854,
8150,
288,
1720,
628,
396,
5560,
370,
1255,
12,
1255,
543,
1414,
769,
370,
1937,
2615,
769,
2,
267,
776,
339,
347,
485,
2416,
63,
9403,
8,
277,
12,
627,
9403,
304,
267,
291,
14,
5997,
14,
9403,
275,
2457,
8,
2734,
1930,
26,
1930,
855,
354,
363,
315,
5560,
12,
291,
14,
5997,
14,
9403,
9,
339,
347,
485,
362,
63,
4405,
8,
277,
304,
267,
3718,
275,
1052,
398,
367,
536,
12,
3653,
315,
6485,
14,
28719,
8,
277,
14,
5997,
304,
288,
340,
2688,
8,
1114,
12,
298,
328,
3313,
63,
6052,
461,
2349,
355,
3718,
59,
354,
61,
275,
3653,
398,
372,
3718,
339,
347,
485,
1065,
63,
1531,
8,
277,
12,
536,
12,
627,
589,
304,
267,
340,
536,
440,
315,
291,
14,
4405,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
450,
83,
365,
440,
282,
1686,
1414,
60,
78,
2,
450,
536,
288,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
342,
288,
372,
398,
1414,
275,
291,
14,
4405,
59,
354,
61,
398,
26632,
275,
6485,
14,
29836,
8,
1531,
9,
398,
1390,
63,
1273,
63,
552,
275,
822,
8,
15644,
14,
589,
9,
446,
413,
267,
1748,
63,
1273,
63,
552,
275,
1390,
63,
1273,
63,
552,
446,
3666,
15644,
14,
4322,
365,
440,
488,
9,
436,
822,
8,
15644,
14,
4322,
9,
503,
378,
9,
398,
340,
822,
8,
589,
9,
665,
1748,
63,
1273,
63,
552,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
450,
83,
6181,
737,
5210,
450,
68,
2368,
60,
78,
2,
450,
334,
355,
536,
12,
355,
1748,
63,
1273,
63,
552,
288,
776,
288,
870,
4331,
1274,
14,
3083,
12,
2071,
83,
60,
78,
2,
450,
1414,
855,
1301,
363,
288,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
342,
288,
372,
398,
340,
822,
8,
589,
9,
690,
1390,
63,
1273,
63,
552,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
450,
83,
6181,
737,
4750,
450,
68,
2368,
60,
78,
2,
450,
334,
355,
536,
12,
355,
1390,
63,
1273,
63,
552,
288,
776,
288,
870,
4331,
1274,
14,
3083,
12,
2071,
83,
60,
78,
2,
450,
1414,
855,
1301,
363,
288,
291,
14,
2992,
1122,
14,
1361,
63,
3437,
342,
288,
372,
398,
1414,
2031,
589,
9,
339,
347,
876,
63,
6052,
8,
277,
304,
267,
986,
339,
347,
7634,
8,
277,
304,
267,
291,
423,
13817,
63,
2087,
342,
398,
291,
14,
2992,
1122,
14,
1122,
63,
589,
342,
267,
291,
14,
657,
63,
6052,
342,
267,
1249,
275,
291,
14,
2992,
1122,
14,
1122,
63,
589,
3430,
17,
61,
327,
2368,
1443,
4409,
295,
11059,
2410,
876,
63,
6052,
27,
1937,
511,
63,
88,
9408,
14,
647,
398,
340,
822,
8,
589,
9,
508,
378,
26,
288,
870,
4331,
1274,
14,
3083,
12,
298,
705,
26,
949,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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texture.py
|
40
|
1597
|
'''
Repeat Texture on Resize
========================
This examples repeats the letter 'K' (mtexture1.png) 64 times in a window.
You should see 8 rows and 8 columns of white K letters, along a label
showing the current size. As you resize the window, it stays an 8x8.
This example includes a label with a colored background.
Note the image mtexture1.png is a white 'K' on a transparent background, which
makes it hard to see.
'''
from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.properties import ObjectProperty, ListProperty
from kivy.lang import Builder
kv = '''
<LabelOnBackground>:
canvas.before:
Color:
rgb: self.background
Rectangle:
pos: self.pos
size: self.size
FloatLayout:
canvas.before:
Color:
rgb: 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
texture: app.texture
LabelOnBackground:
text: '{} (try to resize the window)'.format(root.size)
color: (0.4, 1, 1, 1)
background: (.3, .3, .3)
pos_hint: {'center_x': .5, 'center_y': .5 }
size_hint: None, None
height: 30
width: 250
'''
class LabelOnBackground(Label):
background = ListProperty((0.2, 0.2, 0.2))
class RepeatTexture(App):
texture = ObjectProperty()
def build(self):
self.texture = Image(source='mtexture1.png').texture
self.texture.wrap = 'repeat'
self.texture.uvsize = (8, 8)
return Builder.load_string(kv)
RepeatTexture().run()
|
mit
|
[
2344,
199,
27600,
4516,
608,
641,
799,
890,
199,
1280,
763,
199,
199,
2765,
7251,
28908,
314,
8082,
283,
43,
7,
334,
77,
12611,
17,
14,
4524,
9,
5049,
5431,
315,
282,
4353,
14,
199,
5556,
1077,
1937,
1695,
4730,
436,
1695,
4362,
402,
10424,
1804,
14435,
12,
3180,
282,
1768,
199,
2384,
316,
314,
1453,
1568,
14,
3709,
1265,
15210,
314,
4353,
12,
652,
2612,
588,
376,
1695,
88,
24,
14,
199,
2765,
2893,
6952,
282,
1768,
543,
282,
32076,
8020,
14,
199,
199,
7443,
314,
1834,
333,
12611,
17,
14,
4524,
365,
282,
10424,
283,
43,
7,
641,
282,
17265,
8020,
12,
1314,
199,
391,
9246,
652,
7508,
370,
1937,
14,
199,
2344,
199,
199,
504,
17227,
14,
571,
492,
4693,
199,
504,
17227,
14,
24263,
14,
1569,
492,
6047,
199,
504,
17227,
14,
24263,
14,
1302,
492,
10354,
199,
504,
17227,
14,
3282,
492,
6935,
3697,
12,
3820,
3697,
199,
504,
17227,
14,
4159,
492,
19286,
199,
199,
11475,
275,
1449,
199,
28,
4314,
3314,
14148,
20020,
272,
10218,
14,
5182,
26,
267,
11581,
26,
288,
15180,
26,
291,
14,
7451,
267,
21536,
4593,
26,
288,
2086,
26,
291,
14,
1712,
288,
1568,
26,
291,
14,
890,
199,
199,
5136,
4798,
26,
272,
10218,
14,
5182,
26,
267,
11581,
26,
288,
15180,
26,
413,
12,
413,
12,
413,
267,
21536,
4593,
26,
288,
2086,
26,
291,
14,
1712,
288,
1568,
26,
291,
14,
890,
288,
14855,
26,
1145,
14,
12611,
339,
10354,
3314,
14148,
26,
267,
1318,
26,
9005,
334,
893,
370,
15210,
314,
4353,
9,
1370,
908,
8,
1231,
14,
890,
9,
267,
3164,
26,
334,
16,
14,
20,
12,
413,
12,
413,
12,
413,
9,
267,
8020,
26,
17048,
19,
12,
1275,
19,
12,
1275,
19,
9,
267,
2086,
63,
6479,
26,
791,
4218,
63,
88,
356,
1275,
21,
12,
283,
4218,
63,
89,
356,
1275,
21,
789,
267,
1568,
63,
6479,
26,
488,
12,
488,
267,
4569,
26,
4233,
267,
3462,
26,
16074,
199,
199,
2344,
421,
199,
533,
10354,
3314,
14148,
8,
4314,
304,
272,
8020,
275,
3820,
3697,
1332,
16,
14,
18,
12,
378,
14,
18,
12,
378,
14,
18,
430,
421,
199,
533,
21973,
292,
17165,
8,
2640,
304,
339,
14855,
275,
6935,
3697,
342,
339,
347,
1900,
8,
277,
304,
267,
291,
14,
12611,
275,
6047,
8,
1365,
534,
77,
12611,
17,
14,
4524,
1959,
12611,
267,
291,
14,
12611,
14,
3823,
275,
283,
8755,
7,
267,
291,
14,
12611,
14,
9154,
890,
275,
334,
24,
12,
1695,
9,
267,
372,
19286,
14,
912,
63,
875,
8,
11475,
9,
199,
199,
27600,
17165,
1252,
1065,
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
] |
[
199,
27600,
4516,
608,
641,
799,
890,
199,
1280,
763,
199,
199,
2765,
7251,
28908,
314,
8082,
283,
43,
7,
334,
77,
12611,
17,
14,
4524,
9,
5049,
5431,
315,
282,
4353,
14,
199,
5556,
1077,
1937,
1695,
4730,
436,
1695,
4362,
402,
10424,
1804,
14435,
12,
3180,
282,
1768,
199,
2384,
316,
314,
1453,
1568,
14,
3709,
1265,
15210,
314,
4353,
12,
652,
2612,
588,
376,
1695,
88,
24,
14,
199,
2765,
2893,
6952,
282,
1768,
543,
282,
32076,
8020,
14,
199,
199,
7443,
314,
1834,
333,
12611,
17,
14,
4524,
365,
282,
10424,
283,
43,
7,
641,
282,
17265,
8020,
12,
1314,
199,
391,
9246,
652,
7508,
370,
1937,
14,
199,
2344,
199,
199,
504,
17227,
14,
571,
492,
4693,
199,
504,
17227,
14,
24263,
14,
1569,
492,
6047,
199,
504,
17227,
14,
24263,
14,
1302,
492,
10354,
199,
504,
17227,
14,
3282,
492,
6935,
3697,
12,
3820,
3697,
199,
504,
17227,
14,
4159,
492,
19286,
199,
199,
11475,
275,
1449,
199,
28,
4314,
3314,
14148,
20020,
272,
10218,
14,
5182,
26,
267,
11581,
26,
288,
15180,
26,
291,
14,
7451,
267,
21536,
4593,
26,
288,
2086,
26,
291,
14,
1712,
288,
1568,
26,
291,
14,
890,
199,
199,
5136,
4798,
26,
272,
10218,
14,
5182,
26,
267,
11581,
26,
288,
15180,
26,
413,
12,
413,
12,
413,
267,
21536,
4593,
26,
288,
2086,
26,
291,
14,
1712,
288,
1568,
26,
291,
14,
890,
288,
14855,
26,
1145,
14,
12611,
339,
10354,
3314,
14148,
26,
267,
1318,
26,
9005,
334,
893,
370,
15210,
314,
4353,
9,
1370,
908,
8,
1231,
14,
890,
9,
267,
3164,
26,
334,
16,
14,
20,
12,
413,
12,
413,
12,
413,
9,
267,
8020,
26,
17048,
19,
12,
1275,
19,
12,
1275,
19,
9,
267,
2086,
63,
6479,
26,
791,
4218,
63,
88,
356,
1275,
21,
12,
283,
4218,
63,
89,
356,
1275,
21,
789,
267,
1568,
63,
6479,
26,
488,
12,
488,
267,
4569,
26,
4233,
267,
3462,
26,
16074,
199,
199,
2344,
421,
199,
533,
10354,
3314,
14148,
8,
4314,
304,
272,
8020,
275,
3820,
3697,
1332,
16,
14,
18,
12,
378,
14,
18,
12,
378,
14,
18,
430,
421,
199,
533,
21973,
292,
17165,
8,
2640,
304,
339,
14855,
275,
6935,
3697,
342,
339,
347,
1900,
8,
277,
304,
267,
291,
14,
12611,
275,
6047,
8,
1365,
534,
77,
12611,
17,
14,
4524,
1959,
12611,
267,
291,
14,
12611,
14,
3823,
275,
283,
8755,
7,
267,
291,
14,
12611,
14,
9154,
890,
275,
334,
24,
12,
1695,
9,
267,
372,
19286,
14,
912,
63,
875,
8,
11475,
9,
199,
199,
27600,
17165,
1252,
1065,
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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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
] |
marty331/jakesclock
|
flask/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/pyodbc.py
|
59
|
2665
|
# mysql/pyodbc.py
# Copyright (C) 2005-2015 the SQLAlchemy 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
"""
.. dialect:: mysql+pyodbc
:name: PyODBC
:dbapi: pyodbc
:connectstring: mysql+pyodbc://<username>:<password>@<dsnname>
:url: http://pypi.python.org/pypi/pyodbc/
.. note:: The PyODBC for MySQL dialect is not well supported, and
is subject to unresolved character encoding issues
which exist within the current ODBC drivers available.
(see http://code.google.com/p/pyodbc/issues/detail?id=25).
Other dialects for MySQL are recommended.
"""
from .base import MySQLDialect, MySQLExecutionContext
from ...connectors.pyodbc import PyODBCConnector
from ... import util
import re
class MySQLExecutionContext_pyodbc(MySQLExecutionContext):
def get_lastrowid(self):
cursor = self.create_cursor()
cursor.execute("SELECT LAST_INSERT_ID()")
lastrowid = cursor.fetchone()[0]
cursor.close()
return lastrowid
class MySQLDialect_pyodbc(PyODBCConnector, MySQLDialect):
supports_unicode_statements = False
execution_ctx_cls = MySQLExecutionContext_pyodbc
pyodbc_driver_name = "MySQL"
def __init__(self, **kw):
# deal with http://code.google.com/p/pyodbc/issues/detail?id=25
kw.setdefault('convert_unicode', True)
super(MySQLDialect_pyodbc, self).__init__(**kw)
def _detect_charset(self, connection):
"""Sniff out the character set in use for connection results."""
# Prefer 'character_set_results' for the current connection over the
# value in the driver. SET NAMES or individual variable SETs will
# change the charset without updating the driver's view of the world.
#
# If it's decided that issuing that sort of SQL leaves you SOL, then
# this can prefer the driver value.
rs = connection.execute("SHOW VARIABLES LIKE 'character_set%%'")
opts = dict([(row[0], row[1]) for row in self._compat_fetchall(rs)])
for key in ('character_set_connection', 'character_set'):
if opts.get(key, None):
return opts[key]
util.warn("Could not detect the connection character set. "
"Assuming latin1.")
return 'latin1'
def _extract_error_code(self, exception):
m = re.compile(r"\((\d+)\)").search(str(exception.args))
c = m.group(1)
if c:
return int(c)
else:
return None
dialect = MySQLDialect_pyodbc
|
gpl-2.0
|
[
3,
12896,
15,
647,
19887,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
7806,
314,
14303,
11462,
436,
8417,
199,
3,
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,
421,
199,
703,
10982,
447,
12896,
11,
647,
19887,
272,
520,
354,
26,
1611,
47,
23317,
272,
520,
22103,
26,
1134,
19887,
272,
520,
2242,
875,
26,
12896,
11,
647,
19887,
921,
28,
2473,
30,
16875,
2060,
30,
32,
28,
32510,
354,
30,
272,
520,
633,
26,
1455,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
15,
647,
19887,
15,
339,
2508,
5317,
447,
710,
1611,
47,
23317,
367,
11200,
10982,
365,
440,
5521,
3748,
12,
436,
2126,
365,
5420,
370,
625,
13697,
4528,
2644,
10876,
2126,
1314,
2187,
4453,
314,
1453,
593,
23317,
19016,
2808,
14,
2126,
334,
3239,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
647,
19887,
15,
10115,
15,
5506,
31,
344,
29,
821,
680,
2126,
5439,
10982,
83,
367,
11200,
787,
14318,
14,
199,
199,
624,
199,
199,
504,
1275,
1095,
492,
11200,
22080,
12,
4932,
18445,
906,
9542,
2206,
2998,
199,
504,
2263,
2242,
1384,
14,
647,
19887,
492,
1611,
47,
23317,
20476,
199,
504,
2263,
492,
4884,
199,
646,
295,
421,
199,
533,
4932,
18445,
906,
9542,
2206,
2998,
63,
647,
19887,
8,
5713,
18445,
906,
9542,
2206,
2998,
304,
339,
347,
664,
63,
2019,
29450,
8,
277,
304,
267,
3920,
275,
291,
14,
981,
63,
3937,
342,
267,
3920,
14,
2526,
480,
4859,
491,
11307,
63,
10258,
63,
998,
16060,
267,
2061,
29450,
275,
3920,
14,
11591,
3430,
16,
61,
267,
3920,
14,
1600,
342,
267,
372,
2061,
29450,
421,
199,
533,
11200,
22080,
63,
647,
19887,
8,
2713,
47,
23317,
20476,
12,
11200,
22080,
304,
272,
5171,
63,
2975,
63,
15384,
275,
756,
272,
6451,
63,
3799,
63,
1886,
275,
4932,
18445,
906,
9542,
2206,
2998,
63,
647,
19887,
339,
1134,
19887,
63,
3090,
63,
354,
275,
298,
20784,
2,
339,
347,
636,
826,
721,
277,
12,
1011,
829,
304,
267,
327,
7962,
543,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
647,
19887,
15,
10115,
15,
5506,
31,
344,
29,
821,
267,
4775,
14,
5486,
360,
3916,
63,
2975,
297,
715,
9,
267,
1613,
8,
20784,
22080,
63,
647,
19887,
12,
291,
2843,
826,
14155,
829,
9,
339,
347,
485,
13552,
63,
6043,
8,
277,
12,
1950,
304,
267,
408,
51,
8445,
556,
734,
314,
4528,
663,
315,
675,
367,
1950,
2058,
1041,
398,
327,
510,
21928,
283,
10856,
63,
409,
63,
2604,
7,
367,
314,
1453,
1950,
1806,
314,
267,
327,
574,
315,
314,
5253,
14,
221,
11543,
26149,
654,
503,
8212,
1750,
11543,
83,
911,
267,
327,
1570,
314,
5960,
1928,
12928,
314,
5253,
1159,
2455,
402,
314,
6701,
14,
267,
327,
267,
327,
982,
652,
1159,
12985,
770,
626,
365,
9648,
316,
626,
4069,
402,
5385,
16733,
1265,
17524,
12,
2066,
267,
327,
642,
883,
16602,
314,
5253,
574,
14,
267,
10717,
275,
1950,
14,
2526,
480,
19085,
30098,
17041,
29369,
283,
10856,
63,
409,
8530,
9859,
267,
3999,
275,
1211,
7694,
1143,
59,
16,
467,
1962,
59,
17,
566,
367,
1962,
315,
291,
423,
5819,
63,
10174,
8,
2393,
3948,
267,
367,
790,
315,
661,
10856,
63,
409,
63,
2105,
297,
283,
10856,
63,
409,
735,
288,
340,
3999,
14,
362,
8,
498,
12,
488,
304,
355,
372,
3999,
59,
498,
61,
398,
4884,
14,
4050,
480,
6531,
440,
9696,
314,
1950,
4528,
663,
14,
221,
298,
2116,
298,
9824,
12848,
16899,
17,
2685,
267,
372,
283,
10378,
17,
7,
339,
347,
485,
5005,
63,
705,
63,
600,
8,
277,
12,
1919,
304,
267,
333,
275,
295,
14,
2014,
8,
82,
3212,
1332,
60,
68,
13439,
9,
3471,
1733,
8,
495,
8,
1971,
14,
589,
430,
267,
286,
275,
333,
14,
923,
8,
17,
9,
267,
340,
286,
26,
288,
372,
1109,
8,
67,
9,
267,
587,
26,
288,
372,
488,
199,
199,
11072,
275,
11200,
22080,
63,
647,
19887,
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
] |
[
12896,
15,
647,
19887,
14,
647,
199,
3,
1898,
334,
35,
9,
11811,
13,
7806,
314,
14303,
11462,
436,
8417,
199,
3,
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,
421,
199,
703,
10982,
447,
12896,
11,
647,
19887,
272,
520,
354,
26,
1611,
47,
23317,
272,
520,
22103,
26,
1134,
19887,
272,
520,
2242,
875,
26,
12896,
11,
647,
19887,
921,
28,
2473,
30,
16875,
2060,
30,
32,
28,
32510,
354,
30,
272,
520,
633,
26,
1455,
921,
17343,
14,
1548,
14,
1308,
15,
17343,
15,
647,
19887,
15,
339,
2508,
5317,
447,
710,
1611,
47,
23317,
367,
11200,
10982,
365,
440,
5521,
3748,
12,
436,
2126,
365,
5420,
370,
625,
13697,
4528,
2644,
10876,
2126,
1314,
2187,
4453,
314,
1453,
593,
23317,
19016,
2808,
14,
2126,
334,
3239,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
647,
19887,
15,
10115,
15,
5506,
31,
344,
29,
821,
680,
2126,
5439,
10982,
83,
367,
11200,
787,
14318,
14,
199,
199,
624,
199,
199,
504,
1275,
1095,
492,
11200,
22080,
12,
4932,
18445,
906,
9542,
2206,
2998,
199,
504,
2263,
2242,
1384,
14,
647,
19887,
492,
1611,
47,
23317,
20476,
199,
504,
2263,
492,
4884,
199,
646,
295,
421,
199,
533,
4932,
18445,
906,
9542,
2206,
2998,
63,
647,
19887,
8,
5713,
18445,
906,
9542,
2206,
2998,
304,
339,
347,
664,
63,
2019,
29450,
8,
277,
304,
267,
3920,
275,
291,
14,
981,
63,
3937,
342,
267,
3920,
14,
2526,
480,
4859,
491,
11307,
63,
10258,
63,
998,
16060,
267,
2061,
29450,
275,
3920,
14,
11591,
3430,
16,
61,
267,
3920,
14,
1600,
342,
267,
372,
2061,
29450,
421,
199,
533,
11200,
22080,
63,
647,
19887,
8,
2713,
47,
23317,
20476,
12,
11200,
22080,
304,
272,
5171,
63,
2975,
63,
15384,
275,
756,
272,
6451,
63,
3799,
63,
1886,
275,
4932,
18445,
906,
9542,
2206,
2998,
63,
647,
19887,
339,
1134,
19887,
63,
3090,
63,
354,
275,
298,
20784,
2,
339,
347,
636,
826,
721,
277,
12,
1011,
829,
304,
267,
327,
7962,
543,
1455,
921,
600,
14,
3098,
14,
957,
15,
80,
15,
647,
19887,
15,
10115,
15,
5506,
31,
344,
29,
821,
267,
4775,
14,
5486,
360,
3916,
63,
2975,
297,
715,
9,
267,
1613,
8,
20784,
22080,
63,
647,
19887,
12,
291,
2843,
826,
14155,
829,
9,
339,
347,
485,
13552,
63,
6043,
8,
277,
12,
1950,
304,
267,
408,
51,
8445,
556,
734,
314,
4528,
663,
315,
675,
367,
1950,
2058,
1041,
398,
327,
510,
21928,
283,
10856,
63,
409,
63,
2604,
7,
367,
314,
1453,
1950,
1806,
314,
267,
327,
574,
315,
314,
5253,
14,
221,
11543,
26149,
654,
503,
8212,
1750,
11543,
83,
911,
267,
327,
1570,
314,
5960,
1928,
12928,
314,
5253,
1159,
2455,
402,
314,
6701,
14,
267,
327,
267,
327,
982,
652,
1159,
12985,
770,
626,
365,
9648,
316,
626,
4069,
402,
5385,
16733,
1265,
17524,
12,
2066,
267,
327,
642,
883,
16602,
314,
5253,
574,
14,
267,
10717,
275,
1950,
14,
2526,
480,
19085,
30098,
17041,
29369,
283,
10856,
63,
409,
8530,
9859,
267,
3999,
275,
1211,
7694,
1143,
59,
16,
467,
1962,
59,
17,
566,
367,
1962,
315,
291,
423,
5819,
63,
10174,
8,
2393,
3948,
267,
367,
790,
315,
661,
10856,
63,
409,
63,
2105,
297,
283,
10856,
63,
409,
735,
288,
340,
3999,
14,
362,
8,
498,
12,
488,
304,
355,
372,
3999,
59,
498,
61,
398,
4884,
14,
4050,
480,
6531,
440,
9696,
314,
1950,
4528,
663,
14,
221,
298,
2116,
298,
9824,
12848,
16899,
17,
2685,
267,
372,
283,
10378,
17,
7,
339,
347,
485,
5005,
63,
705,
63,
600,
8,
277,
12,
1919,
304,
267,
333,
275,
295,
14,
2014,
8,
82,
3212,
1332,
60,
68,
13439,
9,
3471,
1733,
8,
495,
8,
1971,
14,
589,
430,
267,
286,
275,
333,
14,
923,
8,
17,
9,
267,
340,
286,
26,
288,
372,
1109,
8,
67,
9,
267,
587,
26,
288,
372,
488,
199,
199,
11072,
275,
11200,
22080,
63,
647,
19887,
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,
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,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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
] |
awifi-dev/android_kernel_lge_awifi
|
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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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
] |
ThomasHabets/python-pyhsm
|
examples/yhsm-monitor-exit.py
|
1
|
1480
|
#!/usr/bin/env python
#
# Copyright (c) 2011, Yubico AB
# All rights reserved.
#
# Utility to send a MONITOR_EXIT command to a YubiHSM.
#
# MONITOR_EXIT only works if the YubiHSM is in debug mode. It would
# be a security problem to allow remote reconfiguration of a production
# YubiHSM.
#
# If your YubiHSM is not in debug mode, enter configuration mode by
# pressing the small button while inserting the YubiHSM in the USB port.
#
import sys
sys.path.append('Lib');
import pyhsm
device = "/dev/ttyACM0"
# simplified arguments parsing
d_argv = dict.fromkeys(sys.argv)
debug = d_argv.has_key('-v')
raw = d_argv.has_key('-v')
if d_argv.has_key('-h'):
sys.stderr.write("Syntax: %s [-v] [-R]\n" % (sys.argv[0]))
sys.stderr.write("\nOptions :\n")
sys.stderr.write(" -v verbose\n")
sys.stderr.write(" -R raw MONITOR_EXIT command\n")
sys.exit(0)
res = 0
try:
s = pyhsm.base.YHSM(device=device, debug = debug)
if raw:
# No initialization
s.write('\x7f\xef\xbe\xad\xba\x10\x41\x52\x45')
else:
print "Version: %s" % s.info()
s.monitor_exit()
print "Exited monitor-mode (maybe)"
if raw:
print "s.stick == %s" % s.stick
print "s.stick.ser == %s" % s.stick.ser
for _ in xrange(3):
s.stick.ser.write("\n")
line = s.stick.ser.readline()
print "%s" % (line)
except pyhsm.exception.YHSM_Error, e:
print "ERROR: %s" % e
res = 1
sys.exit(res)
|
bsd-2-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
7760,
12,
1488,
456,
12802,
14840,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
20511,
370,
3222,
282,
603,
615,
649,
726,
63,
17219,
1414,
370,
282,
1488,
456,
73,
40,
4029,
14,
199,
3,
199,
3,
603,
615,
649,
726,
63,
17219,
1454,
5419,
340,
314,
1488,
456,
73,
40,
4029,
365,
315,
3105,
818,
14,
2779,
3955,
199,
3,
506,
282,
6391,
5160,
370,
2040,
3982,
295,
4758,
402,
282,
9920,
199,
3,
1488,
456,
73,
40,
4029,
14,
199,
3,
199,
3,
982,
2195,
1488,
456,
73,
40,
4029,
365,
440,
315,
3105,
818,
12,
9509,
2897,
818,
701,
199,
3,
15105,
316,
314,
7425,
5528,
1830,
28498,
314,
1488,
456,
73,
40,
4029,
315,
314,
28655,
1844,
14,
199,
3,
199,
199,
646,
984,
199,
1274,
14,
515,
14,
740,
360,
4728,
11339,
199,
646,
1134,
72,
3300,
199,
199,
1782,
275,
3286,
2374,
15,
4707,
1348,
45,
16,
2,
199,
199,
3,
26867,
2368,
6057,
199,
68,
63,
3020,
275,
1211,
14,
19164,
8,
1274,
14,
3020,
9,
199,
1757,
275,
366,
63,
3020,
14,
1989,
63,
498,
3654,
86,
358,
199,
1773,
275,
366,
63,
3020,
14,
1989,
63,
498,
3654,
86,
358,
199,
199,
692,
366,
63,
3020,
14,
1989,
63,
498,
3654,
72,
735,
272,
984,
14,
3083,
14,
952,
480,
16626,
26,
450,
83,
5243,
86,
61,
5243,
50,
7272,
78,
2,
450,
334,
1274,
14,
3020,
59,
16,
2459,
272,
984,
14,
3083,
14,
952,
4582,
78,
4558,
520,
60,
78,
531,
272,
984,
14,
3083,
14,
952,
480,
221,
446,
86,
221,
3376,
60,
78,
531,
272,
984,
14,
3083,
14,
952,
480,
221,
446,
50,
221,
3066,
603,
615,
649,
726,
63,
17219,
1414,
60,
78,
531,
272,
984,
14,
2224,
8,
16,
9,
199,
199,
470,
275,
378,
199,
893,
26,
272,
308,
275,
1134,
72,
3300,
14,
1095,
14,
57,
40,
4029,
8,
1782,
29,
1782,
12,
3105,
275,
3105,
9,
339,
340,
3066,
26,
267,
327,
3091,
11097,
267,
308,
14,
952,
2258,
88,
23,
70,
60,
9532,
60,
9957,
60,
10135,
60,
10539,
60,
88,
709,
60,
88,
2953,
60,
88,
2528,
60,
88,
2322,
358,
272,
587,
26,
267,
870,
298,
3353,
26,
450,
83,
2,
450,
308,
14,
815,
342,
267,
308,
14,
7157,
63,
2224,
342,
339,
870,
298,
920,
5703,
8372,
13,
632,
334,
11853,
2924,
339,
340,
3066,
26,
267,
870,
298,
83,
14,
18043,
508,
450,
83,
2,
450,
308,
14,
18043,
267,
870,
298,
83,
14,
18043,
14,
332,
508,
450,
83,
2,
450,
308,
14,
18043,
14,
332,
398,
367,
485,
315,
4945,
8,
19,
304,
288,
308,
14,
18043,
14,
332,
14,
952,
4582,
78,
531,
288,
1004,
275,
308,
14,
18043,
14,
332,
14,
6407,
342,
288,
870,
2071,
83,
2,
450,
334,
604,
9,
199,
2590,
1134,
72,
3300,
14,
1971,
14,
57,
40,
4029,
63,
547,
12,
325,
26,
272,
870,
298,
3170,
26,
450,
83,
2,
450,
325,
272,
522,
275,
413,
199,
199,
1274,
14,
2224,
8,
470,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
7760,
12,
1488,
456,
12802,
14840,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
20511,
370,
3222,
282,
603,
615,
649,
726,
63,
17219,
1414,
370,
282,
1488,
456,
73,
40,
4029,
14,
199,
3,
199,
3,
603,
615,
649,
726,
63,
17219,
1454,
5419,
340,
314,
1488,
456,
73,
40,
4029,
365,
315,
3105,
818,
14,
2779,
3955,
199,
3,
506,
282,
6391,
5160,
370,
2040,
3982,
295,
4758,
402,
282,
9920,
199,
3,
1488,
456,
73,
40,
4029,
14,
199,
3,
199,
3,
982,
2195,
1488,
456,
73,
40,
4029,
365,
440,
315,
3105,
818,
12,
9509,
2897,
818,
701,
199,
3,
15105,
316,
314,
7425,
5528,
1830,
28498,
314,
1488,
456,
73,
40,
4029,
315,
314,
28655,
1844,
14,
199,
3,
199,
199,
646,
984,
199,
1274,
14,
515,
14,
740,
360,
4728,
11339,
199,
646,
1134,
72,
3300,
199,
199,
1782,
275,
3286,
2374,
15,
4707,
1348,
45,
16,
2,
199,
199,
3,
26867,
2368,
6057,
199,
68,
63,
3020,
275,
1211,
14,
19164,
8,
1274,
14,
3020,
9,
199,
1757,
275,
366,
63,
3020,
14,
1989,
63,
498,
3654,
86,
358,
199,
1773,
275,
366,
63,
3020,
14,
1989,
63,
498,
3654,
86,
358,
199,
199,
692,
366,
63,
3020,
14,
1989,
63,
498,
3654,
72,
735,
272,
984,
14,
3083,
14,
952,
480,
16626,
26,
450,
83,
5243,
86,
61,
5243,
50,
7272,
78,
2,
450,
334,
1274,
14,
3020,
59,
16,
2459,
272,
984,
14,
3083,
14,
952,
4582,
78,
4558,
520,
60,
78,
531,
272,
984,
14,
3083,
14,
952,
480,
221,
446,
86,
221,
3376,
60,
78,
531,
272,
984,
14,
3083,
14,
952,
480,
221,
446,
50,
221,
3066,
603,
615,
649,
726,
63,
17219,
1414,
60,
78,
531,
272,
984,
14,
2224,
8,
16,
9,
199,
199,
470,
275,
378,
199,
893,
26,
272,
308,
275,
1134,
72,
3300,
14,
1095,
14,
57,
40,
4029,
8,
1782,
29,
1782,
12,
3105,
275,
3105,
9,
339,
340,
3066,
26,
267,
327,
3091,
11097,
267,
308,
14,
952,
2258,
88,
23,
70,
60,
9532,
60,
9957,
60,
10135,
60,
10539,
60,
88,
709,
60,
88,
2953,
60,
88,
2528,
60,
88,
2322,
358,
272,
587,
26,
267,
870,
298,
3353,
26,
450,
83,
2,
450,
308,
14,
815,
342,
267,
308,
14,
7157,
63,
2224,
342,
339,
870,
298,
920,
5703,
8372,
13,
632,
334,
11853,
2924,
339,
340,
3066,
26,
267,
870,
298,
83,
14,
18043,
508,
450,
83,
2,
450,
308,
14,
18043,
267,
870,
298,
83,
14,
18043,
14,
332,
508,
450,
83,
2,
450,
308,
14,
18043,
14,
332,
398,
367,
485,
315,
4945,
8,
19,
304,
288,
308,
14,
18043,
14,
332,
14,
952,
4582,
78,
531,
288,
1004,
275,
308,
14,
18043,
14,
332,
14,
6407,
342,
288,
870,
2071,
83,
2,
450,
334,
604,
9,
199,
2590,
1134,
72,
3300,
14,
1971,
14,
57,
40,
4029,
63,
547,
12,
325,
26,
272,
870,
298,
3170,
26,
450,
83,
2,
450,
325,
272,
522,
275,
413,
199,
199,
1274,
14,
2224,
8,
470,
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,
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,
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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
] |
o3project/ryu-oe
|
ryu/controller/event.py
|
43
|
1110
|
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
#
# 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.
class EventBase(object):
# Nothing yet
pass
class EventRequestBase(EventBase):
def __init__(self):
super(EventRequestBase, self).__init__()
self.dst = None # app.name of provide the event.
self.src = None
self.sync = False
self.reply_q = None
class EventReplyBase(EventBase):
def __init__(self, dst):
super(EventReplyBase, self).__init__()
self.dst = dst
|
apache-2.0
|
[
3,
1898,
334,
35,
9,
7760,
653,
711,
678,
23884,
2180,
436,
23884,
9339,
11098,
14,
199,
3,
1898,
334,
35,
9,
7760,
6596,
1151,
85,
1488,
14541,
72,
419,
665,
11552,
391,
72,
419,
737,
1139,
7226,
512,
28921,
30,
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,
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,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
533,
6763,
1563,
8,
785,
304,
272,
327,
20550,
5966,
272,
986,
421,
199,
533,
6763,
2017,
1563,
8,
2390,
1563,
304,
272,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
2390,
2017,
1563,
12,
291,
2843,
826,
4533,
267,
291,
14,
5119,
275,
488,
221,
327,
1145,
14,
354,
402,
5647,
314,
1566,
14,
267,
291,
14,
2164,
275,
488,
267,
291,
14,
5186,
275,
756,
267,
291,
14,
8102,
63,
81,
275,
488,
421,
199,
533,
6763,
14166,
1563,
8,
2390,
1563,
304,
272,
347,
636,
826,
721,
277,
12,
5042,
304,
267,
1613,
8,
2390,
14166,
1563,
12,
291,
2843,
826,
4533,
267,
291,
14,
5119,
275,
5042,
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
] |
[
1898,
334,
35,
9,
7760,
653,
711,
678,
23884,
2180,
436,
23884,
9339,
11098,
14,
199,
3,
1898,
334,
35,
9,
7760,
6596,
1151,
85,
1488,
14541,
72,
419,
665,
11552,
391,
72,
419,
737,
1139,
7226,
512,
28921,
30,
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,
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,
199,
3,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
421,
199,
533,
6763,
1563,
8,
785,
304,
272,
327,
20550,
5966,
272,
986,
421,
199,
533,
6763,
2017,
1563,
8,
2390,
1563,
304,
272,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
2390,
2017,
1563,
12,
291,
2843,
826,
4533,
267,
291,
14,
5119,
275,
488,
221,
327,
1145,
14,
354,
402,
5647,
314,
1566,
14,
267,
291,
14,
2164,
275,
488,
267,
291,
14,
5186,
275,
756,
267,
291,
14,
8102,
63,
81,
275,
488,
421,
199,
533,
6763,
14166,
1563,
8,
2390,
1563,
304,
272,
347,
636,
826,
721,
277,
12,
5042,
304,
267,
1613,
8,
2390,
14166,
1563,
12,
291,
2843,
826,
4533,
267,
291,
14,
5119,
275,
5042,
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,
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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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
] |
omor1/linux-430
|
scripts/gdb/linux/modules.py
|
774
|
2718
|
#
# gdb helper commands and functions for Linux kernel debugging
#
# module tools
#
# Copyright (c) Siemens AG, 2013
#
# Authors:
# Jan Kiszka <jan.kiszka@siemens.com>
#
# This work is licensed under the terms of the GNU GPL version 2.
#
import gdb
from linux import cpus, utils
module_type = utils.CachedType("struct module")
def module_list():
global module_type
module_ptr_type = module_type.get_type().pointer()
modules = gdb.parse_and_eval("modules")
entry = modules['next']
end_of_list = modules.address
while entry != end_of_list:
yield utils.container_of(entry, module_ptr_type, "list")
entry = entry['next']
def find_module_by_name(name):
for module in module_list():
if module['name'].string() == name:
return module
return None
class LxModule(gdb.Function):
"""Find module by name and return the module variable.
$lx_module("MODULE"): Given the name MODULE, iterate over all loaded modules
of the target and return that module variable which MODULE matches."""
def __init__(self):
super(LxModule, self).__init__("lx_module")
def invoke(self, mod_name):
mod_name = mod_name.string()
module = find_module_by_name(mod_name)
if module:
return module.dereference()
else:
raise gdb.GdbError("Unable to find MODULE " + mod_name)
LxModule()
class LxLsmod(gdb.Command):
"""List currently loaded modules."""
_module_use_type = utils.CachedType("struct module_use")
def __init__(self):
super(LxLsmod, self).__init__("lx-lsmod", gdb.COMMAND_DATA)
def invoke(self, arg, from_tty):
gdb.write(
"Address{0} Module Size Used by\n".format(
" " if utils.get_long_type().sizeof == 8 else ""))
for module in module_list():
gdb.write("{address} {name:<19} {size:>8} {ref}".format(
address=str(module['module_core']).split()[0],
name=module['name'].string(),
size=str(module['core_size']),
ref=str(module['refcnt']['counter'])))
source_list = module['source_list']
t = self._module_use_type.get_type().pointer()
entry = source_list['next']
first = True
while entry != source_list.address:
use = utils.container_of(entry, t, "source_list")
gdb.write("{separator}{name}".format(
separator=" " if first else ",",
name=use['source']['name'].string()))
first = False
entry = entry['next']
gdb.write("\n")
LxLsmod()
|
gpl-2.0
|
[
3,
199,
3,
12124,
5922,
3718,
436,
3423,
367,
10130,
5114,
10201,
199,
3,
199,
3,
221,
859,
7249,
199,
3,
199,
3,
1898,
334,
67,
9,
428,
1873,
278,
561,
26787,
12,
6171,
199,
3,
199,
3,
6642,
26,
199,
3,
221,
17474,
1804,
374,
90,
7351,
665,
24418,
14,
75,
374,
90,
7351,
32,
23994,
278,
561,
14,
957,
30,
199,
3,
199,
3,
961,
1736,
365,
18233,
1334,
314,
2895,
402,
314,
1664,
14629,
1015,
499,
14,
199,
3,
199,
199,
646,
12124,
199,
199,
504,
18369,
492,
24174,
12,
3778,
421,
199,
578,
63,
466,
275,
3778,
14,
16138,
804,
480,
1820,
859,
531,
421,
199,
318,
859,
63,
513,
837,
272,
2288,
859,
63,
466,
272,
859,
63,
4695,
63,
466,
275,
859,
63,
466,
14,
362,
63,
466,
1252,
3929,
342,
272,
4621,
275,
12124,
14,
1122,
63,
460,
63,
2579,
480,
3112,
531,
272,
2397,
275,
4621,
459,
2184,
418,
272,
1284,
63,
1618,
63,
513,
275,
4621,
14,
1562,
339,
1830,
2397,
1137,
1284,
63,
1618,
63,
513,
26,
267,
1995,
3778,
14,
3600,
63,
1618,
8,
2373,
12,
859,
63,
4695,
63,
466,
12,
298,
513,
531,
267,
2397,
275,
2397,
459,
2184,
418,
421,
199,
318,
2342,
63,
578,
63,
991,
63,
354,
8,
354,
304,
272,
367,
859,
315,
859,
63,
513,
837,
267,
340,
859,
459,
354,
2278,
875,
342,
508,
536,
26,
288,
372,
859,
272,
372,
488,
421,
199,
533,
491,
88,
2377,
8,
17119,
14,
3481,
304,
272,
408,
6591,
859,
701,
536,
436,
372,
314,
859,
1750,
14,
199,
199,
4,
23605,
63,
578,
480,
10001,
2349,
9138,
314,
536,
30223,
12,
13974,
1806,
1006,
6511,
4621,
199,
1618,
314,
1347,
436,
372,
626,
859,
1750,
1314,
30223,
4450,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
44,
88,
2377,
12,
291,
2843,
826,
29093,
23605,
63,
578,
531,
339,
347,
12677,
8,
277,
12,
3413,
63,
354,
304,
267,
3413,
63,
354,
275,
3413,
63,
354,
14,
875,
342,
267,
859,
275,
2342,
63,
578,
63,
991,
63,
354,
8,
1494,
63,
354,
9,
267,
340,
859,
26,
288,
372,
859,
14,
27915,
342,
267,
587,
26,
288,
746,
12124,
14,
39,
697,
547,
480,
6005,
370,
2342,
30223,
298,
435,
3413,
63,
354,
9,
421,
199,
44,
88,
2377,
342,
421,
199,
533,
491,
88,
44,
83,
1494,
8,
17119,
14,
3110,
304,
272,
408,
1296,
5544,
6511,
4621,
1041,
339,
485,
578,
63,
1180,
63,
466,
275,
3778,
14,
16138,
804,
480,
1820,
859,
63,
1180,
531,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
44,
88,
44,
83,
1494,
12,
291,
2843,
826,
29093,
23605,
13,
478,
1494,
401,
12124,
14,
10761,
63,
3998,
9,
339,
347,
12677,
8,
277,
12,
1680,
12,
687,
63,
4707,
304,
267,
12124,
14,
952,
8,
288,
298,
1476,
91,
16,
93,
259,
5673,
8295,
14579,
221,
8051,
701,
60,
78,
1674,
908,
8,
355,
298,
263,
298,
340,
3778,
14,
362,
63,
2809,
63,
466,
1252,
12590,
508,
1695,
587,
25491,
398,
367,
859,
315,
859,
63,
513,
837,
288,
12124,
14,
952,
13076,
1562,
93,
469,
354,
16875,
1167,
93,
469,
890,
26,
30,
24,
93,
221,
469,
1121,
5469,
908,
8,
355,
2287,
29,
495,
8,
578,
459,
578,
63,
1018,
13227,
1294,
3430,
16,
467,
355,
536,
29,
578,
459,
354,
2278,
875,
1062,
355,
1568,
29,
495,
8,
578,
459,
1018,
63,
890,
3815,
355,
2984,
29,
495,
8,
578,
459,
1121,
6507,
2545,
5337,
26991,
953,
1350,
63,
513,
275,
859,
459,
1365,
63,
513,
418,
288,
307,
275,
291,
423,
578,
63,
1180,
63,
466,
14,
362,
63,
466,
1252,
3929,
342,
288,
2397,
275,
1350,
63,
513,
459,
2184,
418,
288,
1642,
275,
715,
288,
1830,
2397,
1137,
1350,
63,
513,
14,
1562,
26,
355,
675,
275,
3778,
14,
3600,
63,
1618,
8,
2373,
12,
307,
12,
298,
1365,
63,
513,
531,
355,
12124,
14,
952,
13076,
9896,
8847,
354,
5469,
908,
8,
490,
9432,
628,
298,
340,
1642,
587,
3872,
401,
490,
536,
29,
1180,
459,
1365,
2545,
354,
2278,
875,
4059,
355,
1642,
275,
756,
355,
2397,
275,
2397,
459,
2184,
418,
288,
12124,
14,
952,
4582,
78,
531,
421,
199,
44,
88,
44,
83,
1494,
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
] |
[
199,
3,
12124,
5922,
3718,
436,
3423,
367,
10130,
5114,
10201,
199,
3,
199,
3,
221,
859,
7249,
199,
3,
199,
3,
1898,
334,
67,
9,
428,
1873,
278,
561,
26787,
12,
6171,
199,
3,
199,
3,
6642,
26,
199,
3,
221,
17474,
1804,
374,
90,
7351,
665,
24418,
14,
75,
374,
90,
7351,
32,
23994,
278,
561,
14,
957,
30,
199,
3,
199,
3,
961,
1736,
365,
18233,
1334,
314,
2895,
402,
314,
1664,
14629,
1015,
499,
14,
199,
3,
199,
199,
646,
12124,
199,
199,
504,
18369,
492,
24174,
12,
3778,
421,
199,
578,
63,
466,
275,
3778,
14,
16138,
804,
480,
1820,
859,
531,
421,
199,
318,
859,
63,
513,
837,
272,
2288,
859,
63,
466,
272,
859,
63,
4695,
63,
466,
275,
859,
63,
466,
14,
362,
63,
466,
1252,
3929,
342,
272,
4621,
275,
12124,
14,
1122,
63,
460,
63,
2579,
480,
3112,
531,
272,
2397,
275,
4621,
459,
2184,
418,
272,
1284,
63,
1618,
63,
513,
275,
4621,
14,
1562,
339,
1830,
2397,
1137,
1284,
63,
1618,
63,
513,
26,
267,
1995,
3778,
14,
3600,
63,
1618,
8,
2373,
12,
859,
63,
4695,
63,
466,
12,
298,
513,
531,
267,
2397,
275,
2397,
459,
2184,
418,
421,
199,
318,
2342,
63,
578,
63,
991,
63,
354,
8,
354,
304,
272,
367,
859,
315,
859,
63,
513,
837,
267,
340,
859,
459,
354,
2278,
875,
342,
508,
536,
26,
288,
372,
859,
272,
372,
488,
421,
199,
533,
491,
88,
2377,
8,
17119,
14,
3481,
304,
272,
408,
6591,
859,
701,
536,
436,
372,
314,
859,
1750,
14,
199,
199,
4,
23605,
63,
578,
480,
10001,
2349,
9138,
314,
536,
30223,
12,
13974,
1806,
1006,
6511,
4621,
199,
1618,
314,
1347,
436,
372,
626,
859,
1750,
1314,
30223,
4450,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
44,
88,
2377,
12,
291,
2843,
826,
29093,
23605,
63,
578,
531,
339,
347,
12677,
8,
277,
12,
3413,
63,
354,
304,
267,
3413,
63,
354,
275,
3413,
63,
354,
14,
875,
342,
267,
859,
275,
2342,
63,
578,
63,
991,
63,
354,
8,
1494,
63,
354,
9,
267,
340,
859,
26,
288,
372,
859,
14,
27915,
342,
267,
587,
26,
288,
746,
12124,
14,
39,
697,
547,
480,
6005,
370,
2342,
30223,
298,
435,
3413,
63,
354,
9,
421,
199,
44,
88,
2377,
342,
421,
199,
533,
491,
88,
44,
83,
1494,
8,
17119,
14,
3110,
304,
272,
408,
1296,
5544,
6511,
4621,
1041,
339,
485,
578,
63,
1180,
63,
466,
275,
3778,
14,
16138,
804,
480,
1820,
859,
63,
1180,
531,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
8,
44,
88,
44,
83,
1494,
12,
291,
2843,
826,
29093,
23605,
13,
478,
1494,
401,
12124,
14,
10761,
63,
3998,
9,
339,
347,
12677,
8,
277,
12,
1680,
12,
687,
63,
4707,
304,
267,
12124,
14,
952,
8,
288,
298,
1476,
91,
16,
93,
259,
5673,
8295,
14579,
221,
8051,
701,
60,
78,
1674,
908,
8,
355,
298,
263,
298,
340,
3778,
14,
362,
63,
2809,
63,
466,
1252,
12590,
508,
1695,
587,
25491,
398,
367,
859,
315,
859,
63,
513,
837,
288,
12124,
14,
952,
13076,
1562,
93,
469,
354,
16875,
1167,
93,
469,
890,
26,
30,
24,
93,
221,
469,
1121,
5469,
908,
8,
355,
2287,
29,
495,
8,
578,
459,
578,
63,
1018,
13227,
1294,
3430,
16,
467,
355,
536,
29,
578,
459,
354,
2278,
875,
1062,
355,
1568,
29,
495,
8,
578,
459,
1018,
63,
890,
3815,
355,
2984,
29,
495,
8,
578,
459,
1121,
6507,
2545,
5337,
26991,
953,
1350,
63,
513,
275,
859,
459,
1365,
63,
513,
418,
288,
307,
275,
291,
423,
578,
63,
1180,
63,
466,
14,
362,
63,
466,
1252,
3929,
342,
288,
2397,
275,
1350,
63,
513,
459,
2184,
418,
288,
1642,
275,
715,
288,
1830,
2397,
1137,
1350,
63,
513,
14,
1562,
26,
355,
675,
275,
3778,
14,
3600,
63,
1618,
8,
2373,
12,
307,
12,
298,
1365,
63,
513,
531,
355,
12124,
14,
952,
13076,
9896,
8847,
354,
5469,
908,
8,
490,
9432,
628,
298,
340,
1642,
587,
3872,
401,
490,
536,
29,
1180,
459,
1365,
2545,
354,
2278,
875,
4059,
355,
1642,
275,
756,
355,
2397,
275,
2397,
459,
2184,
418,
288,
12124,
14,
952,
4582,
78,
531,
421,
199,
44,
88,
44,
83,
1494,
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,
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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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
] |
darvin/qtdjango
|
src/qtdjango/settings.py
|
1
|
5503
|
# -*- coding: utf-8 -*-
from qtdjango.helpers import test_connection
__author__ = 'darvin'
from qtdjango.connection import *
__author__ = 'darvin'
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class BooleanEdit(QCheckBox):
def text(self):
return QVariant(self.checkState()).toString()
def setText(self, text):
self.setChecked(QVariant(text).toBool())
class SettingsDialog(QDialog):
widgets_table = [
# (name, caption, widget object, default value),
("address", u"Адрес сервера", QLineEdit, "http://127.0.0.1:8000"),
("api_path", u"Путь к api сервера", QLineEdit, "/api/"),
("server_package", u"Название пакета сервера", QLineEdit, "none"),
("login", u"Ваш логин", QLineEdit, ""),
("password", u"Ваш пароль", QLineEdit, ""),
("open_links_in_external_browser", \
u"Открывать ссылки из окна информации во внешнем браузере", BooleanEdit, True),
]
def __init__(self, parent=None, error_message=None, models_manager=None):
super(SettingsDialog, self).__init__(parent)
self.setWindowTitle(u"Настройки")
self.setModal(True)
self.formlayout = QFormLayout()
self.models_manager = models_manager
self.settings = QSettings()
self.message_widget = QLabel()
self.__widgets = []
for name, caption, widget_class, default in self.widgets_table:
self.__widgets.append((name, caption, widget_class(), default))
for name, caption, widget, default in self.__widgets:
self.formlayout.addRow(caption, widget)
widget.setText(self.settings.value(name, default).toString())
self.formlayout.addRow(self.message_widget)
if error_message is not None:
self.message(**error_message)
buttonBox = QDialogButtonBox(QDialogButtonBox.Save\
| QDialogButtonBox.Cancel |QDialogButtonBox.RestoreDefaults)
testButton = QPushButton(u"Тестировать соединение")
buttonBox.addButton(testButton, QDialogButtonBox.ActionRole)
testButton.clicked.connect(self.test)
buttonBox.accepted.connect(self.accept)
buttonBox.rejected.connect(self.reject)
buttonBox.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore)
self.formlayout.addRow(buttonBox)
self.setLayout(self.formlayout)
def accept(self):
if self.test():
for name, caption, widget, default in self.__widgets:
self.settings.setValue(name, widget.text())
self.models_manager.set_connection_params(\
self.get_value("address"), \
self.get_value("api_path"), \
self.get_value("login"),\
self.get_value("password"))
QDialog.accept(self)
def restore(self):
for name, caption, widget, default in self.__widgets:
widget.setText(default)
def message(self, text, error=False, works=False, fields=[]):
self.message_widget.setText(text)
if error:
color = "red"
elif works:
color = "green"
else:
color = "black"
css = "QLabel { color : %s; }" % color
self.message_widget.setStyleSheet(css)
for name, caption, widget, default in self.__widgets:
self.formlayout.labelForField(widget).setStyleSheet("")
if name in fields:
self.formlayout.labelForField(widget).setStyleSheet(css)
def get_value(self, name):
return unicode(self.settings.value(name).toString())
def test(self):
s = {}
for name, caption, widget, default in self.__widgets:
s[name] = unicode(widget.text())
try:
remote_version = test_connection(s["address"],s["api_path"],s["login"],s["password"])
import qtdjango
if qtdjango.__version__==remote_version:
self.message(text=u"Удаленный сервер настроен правильно!", works=True)
return True
elif remote_version is not None:
self.message(u"Версия системы на удаленном сервере отличается от\
версии системы на клиенте")
return True
except SocketError:
self.message(text=u"Ошибка при подключении к удаленному серверу", error=True, fields=\
("address",))
except ServerNotFoundError:
self.message(text=u"Удаленный сервер недоступен", error=True, fields=\
("address",))
except NotQtDjangoResponceError:
self.message(text=u"Не правильно настроен путь на удаленном сервере или \
удаленный сервер не является сервером системы", error=True, fields=\
("address","api_path"))
except AuthError:
self.message(text=u"Неверное имя пользователя или пароль", error=True, fields=\
("login","password"))
return False
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
19227,
1176,
14,
7546,
492,
511,
63,
2105,
199,
199,
363,
2502,
363,
275,
283,
4460,
11908,
7,
421,
199,
504,
19227,
1176,
14,
2105,
492,
627,
199,
199,
363,
2502,
363,
275,
283,
4460,
11908,
7,
421,
199,
504,
14084,
20,
14,
10901,
492,
627,
199,
504,
14084,
20,
14,
10604,
492,
627,
421,
199,
533,
9411,
4685,
8,
49,
20530,
304,
272,
347,
1318,
8,
277,
304,
267,
372,
27875,
8,
277,
14,
1074,
2223,
8801,
16695,
342,
272,
347,
663,
1872,
8,
277,
12,
1318,
304,
267,
291,
14,
26657,
8,
49,
12935,
8,
505,
680,
475,
10349,
1012,
421,
199,
533,
13303,
5619,
8,
30983,
304,
2378,
11114,
63,
1224,
275,
359,
199,
3,
3322,
334,
354,
12,
19038,
12,
3938,
909,
12,
849,
574,
395,
288,
1689,
1562,
401,
399,
2,
141,
239,
20497,
7753,
6286,
8474,
24071,
21273,
19630,
21273,
5657,
401,
1413,
21708,
12,
298,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
1288,
288,
1689,
1246,
63,
515,
401,
399,
2,
141,
254,
12195,
7413,
16961,
31999,
2986,
24071,
21273,
19630,
21273,
5657,
401,
1413,
21708,
12,
3286,
1246,
15,
1288,
288,
1689,
1000,
63,
2491,
401,
399,
2,
141,
252,
13111,
116,
19630,
21674,
6500,
6286,
19820,
5657,
11487,
30160,
5657,
24071,
21273,
19630,
21273,
5657,
401,
1413,
21708,
12,
298,
3592,
1288,
288,
1689,
2886,
401,
399,
2,
141,
241,
5657,
27202,
7038,
120,
8381,
112,
27859,
401,
1413,
21708,
12,
16241,
288,
1689,
2060,
401,
399,
2,
141,
241,
5657,
27202,
19820,
27559,
26927,
16961,
401,
1413,
21708,
12,
16241,
288,
1689,
1490,
63,
4614,
63,
262,
63,
5159,
63,
5750,
401,
971,
1467,
399,
2,
141,
253,
7413,
11487,
7753,
17445,
19630,
24219,
16961,
24071,
8474,
17445,
10356,
11487,
6500,
221,
16863,
116,
221,
8381,
119,
7592,
5657,
221,
27859,
31815,
26438,
23000,
5657,
25827,
6500,
6500,
22213,
5806,
22213,
7592,
6286,
27202,
7592,
15578,
121,
7038,
110,
7753,
5657,
12195,
31027,
21273,
6286,
401,
9411,
4685,
12,
715,
395,
398,
1622,
272,
347,
636,
826,
721,
277,
12,
1676,
29,
403,
12,
1125,
63,
1188,
29,
403,
12,
1709,
63,
2609,
29,
403,
304,
267,
1613,
8,
5268,
5619,
12,
291,
2843,
826,
721,
1708,
9,
267,
291,
14,
30601,
8,
85,
2,
141,
252,
5657,
18261,
7753,
8381,
118,
11487,
6500,
531,
267,
291,
14,
409,
23689,
8,
549,
9,
267,
291,
14,
964,
4209,
275,
1413,
2821,
4798,
342,
267,
291,
14,
992,
63,
2609,
275,
1709,
63,
2609,
267,
291,
14,
1751,
275,
1413,
5268,
342,
267,
291,
14,
1188,
63,
3440,
275,
1413,
4314,
342,
267,
291,
855,
8583,
275,
942,
267,
367,
536,
12,
19038,
12,
3938,
63,
533,
12,
849,
315,
291,
14,
8583,
63,
1224,
26,
288,
291,
855,
8583,
14,
740,
1332,
354,
12,
19038,
12,
3938,
63,
533,
1062,
849,
430,
398,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
288,
291,
14,
964,
4209,
14,
525,
5810,
8,
13410,
12,
3938,
9,
288,
3938,
14,
8341,
8,
277,
14,
1751,
14,
585,
8,
354,
12,
849,
680,
16695,
1012,
398,
291,
14,
964,
4209,
14,
525,
5810,
8,
277,
14,
1188,
63,
3440,
9,
398,
340,
1125,
63,
1188,
365,
440,
488,
26,
288,
291,
14,
1188,
3682,
705,
63,
1188,
9,
398,
5528,
3532,
275,
1413,
5619,
4259,
3532,
8,
30983,
4259,
3532,
14,
8229,
60,
288,
1204,
1413,
5619,
4259,
3532,
14,
9083,
1204,
30983,
4259,
3532,
14,
21012,
16986,
9,
398,
511,
4259,
275,
1413,
20083,
8,
85,
2,
141,
96,
6286,
18261,
6500,
7753,
21267,
24219,
16961,
24071,
5806,
15578,
113,
27859,
18624,
6500,
6286,
531,
267,
5528,
3532,
14,
525,
4259,
8,
396,
4259,
12,
1413,
5619,
4259,
3532,
14,
3310,
7422,
9,
267,
511,
4259,
14,
11276,
14,
2242,
8,
277,
14,
396,
9,
267,
5528,
3532,
14,
16121,
14,
2242,
8,
277,
14,
5694,
9,
267,
5528,
3532,
14,
24054,
14,
2242,
8,
277,
14,
16857,
9,
267,
5528,
3532,
14,
3887,
8,
30983,
4259,
3532,
14,
21012,
16986,
680,
11276,
14,
2242,
8,
277,
14,
8011,
9,
267,
291,
14,
964,
4209,
14,
525,
5810,
8,
3887,
3532,
9,
267,
291,
14,
409,
4798,
8,
277,
14,
964,
4209,
9,
339,
347,
4729,
8,
277,
304,
267,
340,
291,
14,
396,
837,
288,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
355,
291,
14,
1751,
14,
14733,
8,
354,
12,
3938,
14,
505,
1012,
953,
291,
14,
992,
63,
2609,
14,
409,
63,
2105,
63,
1162,
2961,
490,
291,
14,
362,
63,
585,
480,
1562,
1288,
971,
490,
291,
14,
362,
63,
585,
480,
1246,
63,
515,
1288,
971,
490,
291,
14,
362,
63,
585,
480,
2886,
1288,
60,
490,
291,
14,
362,
63,
585,
480,
2060,
2237,
288,
1413,
5619,
14,
5694,
8,
277,
9,
16478,
347,
9066,
8,
277,
304,
267,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
288,
3938,
14,
8341,
8,
885,
9,
339,
347,
1245,
8,
277,
12,
1318,
12,
1125,
29,
797,
12,
5419,
29,
797,
12,
1504,
17894,
267,
291,
14,
1188,
63,
3440,
14,
8341,
8,
505,
9,
267,
340,
1125,
26,
288,
3164,
275,
298,
581,
2,
267,
916,
5419,
26,
288,
3164,
275,
298,
7731,
2,
267,
587,
26,
288,
3164,
275,
298,
8399,
2,
398,
11431,
275,
298,
19890,
469,
3164,
520,
450,
83,
27,
789,
2,
450,
3164,
267,
291,
14,
1188,
63,
3440,
14,
31091,
16715,
8,
3919,
9,
267,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
288,
291,
14,
964,
4209,
14,
1302,
1858,
792,
8,
3440,
680,
31091,
16715,
10804,
288,
340,
536,
315,
1504,
26,
355,
291,
14,
964,
4209,
14,
1302,
1858,
792,
8,
3440,
680,
31091,
16715,
8,
3919,
9,
339,
347,
664,
63,
585,
8,
277,
12,
536,
304,
267,
372,
2649,
8,
277,
14,
1751,
14,
585,
8,
354,
680,
16695,
1012,
339,
347,
511,
8,
277,
304,
267,
308,
275,
1052,
267,
367,
536,
12,
19038,
12
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
19227,
1176,
14,
7546,
492,
511,
63,
2105,
199,
199,
363,
2502,
363,
275,
283,
4460,
11908,
7,
421,
199,
504,
19227,
1176,
14,
2105,
492,
627,
199,
199,
363,
2502,
363,
275,
283,
4460,
11908,
7,
421,
199,
504,
14084,
20,
14,
10901,
492,
627,
199,
504,
14084,
20,
14,
10604,
492,
627,
421,
199,
533,
9411,
4685,
8,
49,
20530,
304,
272,
347,
1318,
8,
277,
304,
267,
372,
27875,
8,
277,
14,
1074,
2223,
8801,
16695,
342,
272,
347,
663,
1872,
8,
277,
12,
1318,
304,
267,
291,
14,
26657,
8,
49,
12935,
8,
505,
680,
475,
10349,
1012,
421,
199,
533,
13303,
5619,
8,
30983,
304,
2378,
11114,
63,
1224,
275,
359,
199,
3,
3322,
334,
354,
12,
19038,
12,
3938,
909,
12,
849,
574,
395,
288,
1689,
1562,
401,
399,
2,
141,
239,
20497,
7753,
6286,
8474,
24071,
21273,
19630,
21273,
5657,
401,
1413,
21708,
12,
298,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
15214,
1288,
288,
1689,
1246,
63,
515,
401,
399,
2,
141,
254,
12195,
7413,
16961,
31999,
2986,
24071,
21273,
19630,
21273,
5657,
401,
1413,
21708,
12,
3286,
1246,
15,
1288,
288,
1689,
1000,
63,
2491,
401,
399,
2,
141,
252,
13111,
116,
19630,
21674,
6500,
6286,
19820,
5657,
11487,
30160,
5657,
24071,
21273,
19630,
21273,
5657,
401,
1413,
21708,
12,
298,
3592,
1288,
288,
1689,
2886,
401,
399,
2,
141,
241,
5657,
27202,
7038,
120,
8381,
112,
27859,
401,
1413,
21708,
12,
16241,
288,
1689,
2060,
401,
399,
2,
141,
241,
5657,
27202,
19820,
27559,
26927,
16961,
401,
1413,
21708,
12,
16241,
288,
1689,
1490,
63,
4614,
63,
262,
63,
5159,
63,
5750,
401,
971,
1467,
399,
2,
141,
253,
7413,
11487,
7753,
17445,
19630,
24219,
16961,
24071,
8474,
17445,
10356,
11487,
6500,
221,
16863,
116,
221,
8381,
119,
7592,
5657,
221,
27859,
31815,
26438,
23000,
5657,
25827,
6500,
6500,
22213,
5806,
22213,
7592,
6286,
27202,
7592,
15578,
121,
7038,
110,
7753,
5657,
12195,
31027,
21273,
6286,
401,
9411,
4685,
12,
715,
395,
398,
1622,
272,
347,
636,
826,
721,
277,
12,
1676,
29,
403,
12,
1125,
63,
1188,
29,
403,
12,
1709,
63,
2609,
29,
403,
304,
267,
1613,
8,
5268,
5619,
12,
291,
2843,
826,
721,
1708,
9,
267,
291,
14,
30601,
8,
85,
2,
141,
252,
5657,
18261,
7753,
8381,
118,
11487,
6500,
531,
267,
291,
14,
409,
23689,
8,
549,
9,
267,
291,
14,
964,
4209,
275,
1413,
2821,
4798,
342,
267,
291,
14,
992,
63,
2609,
275,
1709,
63,
2609,
267,
291,
14,
1751,
275,
1413,
5268,
342,
267,
291,
14,
1188,
63,
3440,
275,
1413,
4314,
342,
267,
291,
855,
8583,
275,
942,
267,
367,
536,
12,
19038,
12,
3938,
63,
533,
12,
849,
315,
291,
14,
8583,
63,
1224,
26,
288,
291,
855,
8583,
14,
740,
1332,
354,
12,
19038,
12,
3938,
63,
533,
1062,
849,
430,
398,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
288,
291,
14,
964,
4209,
14,
525,
5810,
8,
13410,
12,
3938,
9,
288,
3938,
14,
8341,
8,
277,
14,
1751,
14,
585,
8,
354,
12,
849,
680,
16695,
1012,
398,
291,
14,
964,
4209,
14,
525,
5810,
8,
277,
14,
1188,
63,
3440,
9,
398,
340,
1125,
63,
1188,
365,
440,
488,
26,
288,
291,
14,
1188,
3682,
705,
63,
1188,
9,
398,
5528,
3532,
275,
1413,
5619,
4259,
3532,
8,
30983,
4259,
3532,
14,
8229,
60,
288,
1204,
1413,
5619,
4259,
3532,
14,
9083,
1204,
30983,
4259,
3532,
14,
21012,
16986,
9,
398,
511,
4259,
275,
1413,
20083,
8,
85,
2,
141,
96,
6286,
18261,
6500,
7753,
21267,
24219,
16961,
24071,
5806,
15578,
113,
27859,
18624,
6500,
6286,
531,
267,
5528,
3532,
14,
525,
4259,
8,
396,
4259,
12,
1413,
5619,
4259,
3532,
14,
3310,
7422,
9,
267,
511,
4259,
14,
11276,
14,
2242,
8,
277,
14,
396,
9,
267,
5528,
3532,
14,
16121,
14,
2242,
8,
277,
14,
5694,
9,
267,
5528,
3532,
14,
24054,
14,
2242,
8,
277,
14,
16857,
9,
267,
5528,
3532,
14,
3887,
8,
30983,
4259,
3532,
14,
21012,
16986,
680,
11276,
14,
2242,
8,
277,
14,
8011,
9,
267,
291,
14,
964,
4209,
14,
525,
5810,
8,
3887,
3532,
9,
267,
291,
14,
409,
4798,
8,
277,
14,
964,
4209,
9,
339,
347,
4729,
8,
277,
304,
267,
340,
291,
14,
396,
837,
288,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
355,
291,
14,
1751,
14,
14733,
8,
354,
12,
3938,
14,
505,
1012,
953,
291,
14,
992,
63,
2609,
14,
409,
63,
2105,
63,
1162,
2961,
490,
291,
14,
362,
63,
585,
480,
1562,
1288,
971,
490,
291,
14,
362,
63,
585,
480,
1246,
63,
515,
1288,
971,
490,
291,
14,
362,
63,
585,
480,
2886,
1288,
60,
490,
291,
14,
362,
63,
585,
480,
2060,
2237,
288,
1413,
5619,
14,
5694,
8,
277,
9,
16478,
347,
9066,
8,
277,
304,
267,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
288,
3938,
14,
8341,
8,
885,
9,
339,
347,
1245,
8,
277,
12,
1318,
12,
1125,
29,
797,
12,
5419,
29,
797,
12,
1504,
17894,
267,
291,
14,
1188,
63,
3440,
14,
8341,
8,
505,
9,
267,
340,
1125,
26,
288,
3164,
275,
298,
581,
2,
267,
916,
5419,
26,
288,
3164,
275,
298,
7731,
2,
267,
587,
26,
288,
3164,
275,
298,
8399,
2,
398,
11431,
275,
298,
19890,
469,
3164,
520,
450,
83,
27,
789,
2,
450,
3164,
267,
291,
14,
1188,
63,
3440,
14,
31091,
16715,
8,
3919,
9,
267,
367,
536,
12,
19038,
12,
3938,
12,
849,
315,
291,
855,
8583,
26,
288,
291,
14,
964,
4209,
14,
1302,
1858,
792,
8,
3440,
680,
31091,
16715,
10804,
288,
340,
536,
315,
1504,
26,
355,
291,
14,
964,
4209,
14,
1302,
1858,
792,
8,
3440,
680,
31091,
16715,
8,
3919,
9,
339,
347,
664,
63,
585,
8,
277,
12,
536,
304,
267,
372,
2649,
8,
277,
14,
1751,
14,
585,
8,
354,
680,
16695,
1012,
339,
347,
511,
8,
277,
304,
267,
308,
275,
1052,
267,
367,
536,
12,
19038,
12,
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
] |
person142/scipy
|
scipy/interpolate/tests/test_gil.py
|
9
|
1882
|
import itertools
import threading
import time
import numpy as np
from numpy.testing import assert_equal
import pytest
import scipy.interpolate
class TestGIL(object):
"""Check if the GIL is properly released by scipy.interpolate functions."""
def setup_method(self):
self.messages = []
def log(self, message):
self.messages.append(message)
def make_worker_thread(self, target, args):
log = self.log
class WorkerThread(threading.Thread):
def run(self):
log('interpolation started')
target(*args)
log('interpolation complete')
return WorkerThread()
@pytest.mark.slow
@pytest.mark.xfail(reason='race conditions, may depend on system load')
def test_rectbivariatespline(self):
def generate_params(n_points):
x = y = np.linspace(0, 1000, n_points)
x_grid, y_grid = np.meshgrid(x, y)
z = x_grid * y_grid
return x, y, z
def calibrate_delay(requested_time):
for n_points in itertools.count(5000, 1000):
args = generate_params(n_points)
time_started = time.time()
interpolate(*args)
if time.time() - time_started > requested_time:
return args
def interpolate(x, y, z):
scipy.interpolate.RectBivariateSpline(x, y, z)
args = calibrate_delay(requested_time=3)
worker_thread = self.make_worker_thread(interpolate, args)
worker_thread.start()
for i in range(3):
time.sleep(0.5)
self.log('working')
worker_thread.join()
assert_equal(self.messages, [
'interpolation started',
'working',
'working',
'working',
'interpolation complete',
])
|
bsd-3-clause
|
[
646,
7975,
199,
646,
5796,
199,
646,
900,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
702,
63,
1452,
199,
646,
4613,
199,
646,
7026,
14,
21294,
421,
199,
533,
1379,
39,
1193,
8,
785,
304,
272,
408,
1799,
340,
314,
598,
1193,
365,
7684,
14286,
701,
7026,
14,
21294,
3423,
1041,
339,
347,
3272,
63,
765,
8,
277,
304,
267,
291,
14,
3431,
275,
942,
339,
347,
943,
8,
277,
12,
1245,
304,
267,
291,
14,
3431,
14,
740,
8,
1188,
9,
339,
347,
1852,
63,
6599,
63,
2671,
8,
277,
12,
1347,
12,
1249,
304,
267,
943,
275,
291,
14,
793,
398,
1021,
23886,
4436,
8,
12562,
14,
4436,
304,
288,
347,
1255,
8,
277,
304,
355,
943,
360,
21080,
8239,
358,
355,
1347,
2031,
589,
9,
355,
943,
360,
21080,
4890,
358,
398,
372,
23886,
4436,
342,
339,
768,
4462,
14,
1657,
14,
14362,
272,
768,
4462,
14,
1657,
14,
22557,
8,
5764,
534,
5986,
3704,
12,
1443,
11687,
641,
2656,
2248,
358,
272,
347,
511,
63,
1201,
66,
23225,
27066,
8,
277,
304,
267,
347,
3550,
63,
1162,
8,
78,
63,
3438,
304,
288,
671,
275,
612,
275,
980,
14,
11649,
8,
16,
12,
5198,
12,
302,
63,
3438,
9,
288,
671,
63,
3825,
12,
612,
63,
3825,
275,
980,
14,
6480,
3825,
8,
88,
12,
612,
9,
288,
1315,
275,
671,
63,
3825,
627,
612,
63,
3825,
288,
372,
671,
12,
612,
12,
1315,
398,
347,
12855,
1866,
63,
5814,
8,
11151,
63,
521,
304,
288,
367,
302,
63,
3438,
315,
7975,
14,
835,
8,
13128,
12,
5198,
304,
355,
1249,
275,
3550,
63,
1162,
8,
78,
63,
3438,
9,
355,
900,
63,
8924,
275,
900,
14,
521,
342,
355,
28884,
2031,
589,
9,
355,
340,
900,
14,
521,
342,
446,
900,
63,
8924,
690,
5839,
63,
521,
26,
490,
372,
1249,
398,
347,
28884,
8,
88,
12,
612,
12,
1315,
304,
288,
7026,
14,
21294,
14,
8252,
34,
23225,
27558,
8,
88,
12,
612,
12,
1315,
9,
398,
1249,
275,
12855,
1866,
63,
5814,
8,
11151,
63,
521,
29,
19,
9,
267,
7239,
63,
2671,
275,
291,
14,
1875,
63,
6599,
63,
2671,
8,
21294,
12,
1249,
9,
267,
7239,
63,
2671,
14,
928,
342,
267,
367,
284,
315,
1425,
8,
19,
304,
288,
900,
14,
4532,
8,
16,
14,
21,
9,
288,
291,
14,
793,
360,
9818,
358,
267,
7239,
63,
2671,
14,
904,
342,
267,
702,
63,
1452,
8,
277,
14,
3431,
12,
359,
288,
283,
21080,
8239,
297,
288,
283,
9818,
297,
288,
283,
9818,
297,
288,
283,
9818,
297,
288,
283,
21080,
4890,
297,
267,
4794,
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
] |
[
7975,
199,
646,
5796,
199,
646,
900,
199,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
4776,
492,
702,
63,
1452,
199,
646,
4613,
199,
646,
7026,
14,
21294,
421,
199,
533,
1379,
39,
1193,
8,
785,
304,
272,
408,
1799,
340,
314,
598,
1193,
365,
7684,
14286,
701,
7026,
14,
21294,
3423,
1041,
339,
347,
3272,
63,
765,
8,
277,
304,
267,
291,
14,
3431,
275,
942,
339,
347,
943,
8,
277,
12,
1245,
304,
267,
291,
14,
3431,
14,
740,
8,
1188,
9,
339,
347,
1852,
63,
6599,
63,
2671,
8,
277,
12,
1347,
12,
1249,
304,
267,
943,
275,
291,
14,
793,
398,
1021,
23886,
4436,
8,
12562,
14,
4436,
304,
288,
347,
1255,
8,
277,
304,
355,
943,
360,
21080,
8239,
358,
355,
1347,
2031,
589,
9,
355,
943,
360,
21080,
4890,
358,
398,
372,
23886,
4436,
342,
339,
768,
4462,
14,
1657,
14,
14362,
272,
768,
4462,
14,
1657,
14,
22557,
8,
5764,
534,
5986,
3704,
12,
1443,
11687,
641,
2656,
2248,
358,
272,
347,
511,
63,
1201,
66,
23225,
27066,
8,
277,
304,
267,
347,
3550,
63,
1162,
8,
78,
63,
3438,
304,
288,
671,
275,
612,
275,
980,
14,
11649,
8,
16,
12,
5198,
12,
302,
63,
3438,
9,
288,
671,
63,
3825,
12,
612,
63,
3825,
275,
980,
14,
6480,
3825,
8,
88,
12,
612,
9,
288,
1315,
275,
671,
63,
3825,
627,
612,
63,
3825,
288,
372,
671,
12,
612,
12,
1315,
398,
347,
12855,
1866,
63,
5814,
8,
11151,
63,
521,
304,
288,
367,
302,
63,
3438,
315,
7975,
14,
835,
8,
13128,
12,
5198,
304,
355,
1249,
275,
3550,
63,
1162,
8,
78,
63,
3438,
9,
355,
900,
63,
8924,
275,
900,
14,
521,
342,
355,
28884,
2031,
589,
9,
355,
340,
900,
14,
521,
342,
446,
900,
63,
8924,
690,
5839,
63,
521,
26,
490,
372,
1249,
398,
347,
28884,
8,
88,
12,
612,
12,
1315,
304,
288,
7026,
14,
21294,
14,
8252,
34,
23225,
27558,
8,
88,
12,
612,
12,
1315,
9,
398,
1249,
275,
12855,
1866,
63,
5814,
8,
11151,
63,
521,
29,
19,
9,
267,
7239,
63,
2671,
275,
291,
14,
1875,
63,
6599,
63,
2671,
8,
21294,
12,
1249,
9,
267,
7239,
63,
2671,
14,
928,
342,
267,
367,
284,
315,
1425,
8,
19,
304,
288,
900,
14,
4532,
8,
16,
14,
21,
9,
288,
291,
14,
793,
360,
9818,
358,
267,
7239,
63,
2671,
14,
904,
342,
267,
702,
63,
1452,
8,
277,
14,
3431,
12,
359,
288,
283,
21080,
8239,
297,
288,
283,
9818,
297,
288,
283,
9818,
297,
288,
283,
9818,
297,
288,
283,
21080,
4890,
297,
267,
4794,
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,
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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module does some pretty
ugly stuff with the Python traceback system in order to achieve tracebacks
with correct line numbers, locals and contents.
:copyright: (c) 2010 by the Jinja Team.
:license: BSD, see LICENSE for more details.
"""
import sys
import traceback
from types import TracebackType
from jinja2.utils import missing, internal_code
from jinja2.exceptions import TemplateSyntaxError
from jinja2._compat import iteritems, reraise, code_type
# on pypy we can take advantage of transparent proxies
try:
from __pypy__ import tproxy
except ImportError:
tproxy = None
# how does the raise helper look like?
try:
exec("raise TypeError, 'foo'")
except SyntaxError:
raise_helper = 'raise __jinja_exception__[1]'
except TypeError:
raise_helper = 'raise __jinja_exception__[0], __jinja_exception__[1]'
class TracebackFrameProxy(object):
"""Proxies a traceback frame."""
def __init__(self, tb):
self.tb = tb
self._tb_next = None
@property
def tb_next(self):
return self._tb_next
def set_next(self, next):
if tb_set_next is not None:
try:
tb_set_next(self.tb, next and next.tb or None)
except Exception:
# this function can fail due to all the hackery it does
# on various python implementations. We just catch errors
# down and ignore them if necessary.
pass
self._tb_next = next
@property
def is_jinja_frame(self):
return '__jinja_template__' in self.tb.tb_frame.f_globals
def __getattr__(self, name):
return getattr(self.tb, name)
def make_frame_proxy(frame):
proxy = TracebackFrameProxy(frame)
if tproxy is None:
return proxy
def operation_handler(operation, *args, **kwargs):
if operation in ('__getattribute__', '__getattr__'):
return getattr(proxy, args[0])
elif operation == '__setattr__':
proxy.__setattr__(*args, **kwargs)
else:
return getattr(proxy, operation)(*args, **kwargs)
return tproxy(TracebackType, operation_handler)
class ProcessedTraceback(object):
"""Holds a Jinja preprocessed traceback for printing or reraising."""
def __init__(self, exc_type, exc_value, frames):
assert frames, 'no frames for this traceback?'
self.exc_type = exc_type
self.exc_value = exc_value
self.frames = frames
# newly concatenate the frames (which are proxies)
prev_tb = None
for tb in self.frames:
if prev_tb is not None:
prev_tb.set_next(tb)
prev_tb = tb
prev_tb.set_next(None)
def render_as_text(self, limit=None):
"""Return a string with the traceback."""
lines = traceback.format_exception(self.exc_type, self.exc_value,
self.frames[0], limit=limit)
return ''.join(lines).rstrip()
def render_as_html(self, full=False):
"""Return a unicode string with the traceback as rendered HTML."""
from jinja2.debugrenderer import render_traceback
return u'%s\n\n<!--\n%s\n-->' % (
render_traceback(self, full=full),
self.render_as_text().decode('utf-8', 'replace')
)
@property
def is_template_syntax_error(self):
"""`True` if this is a template syntax error."""
return isinstance(self.exc_value, TemplateSyntaxError)
@property
def exc_info(self):
"""Exception info tuple with a proxy around the frame objects."""
return self.exc_type, self.exc_value, self.frames[0]
@property
def standard_exc_info(self):
"""Standard python exc_info for re-raising"""
tb = self.frames[0]
# the frame will be an actual traceback (or transparent proxy) if
# we are on pypy or a python implementation with support for tproxy
if type(tb) is not TracebackType:
tb = tb.tb
return self.exc_type, self.exc_value, tb
def make_traceback(exc_info, source_hint=None):
"""Creates a processed traceback object from the exc_info."""
exc_type, exc_value, tb = exc_info
if isinstance(exc_value, TemplateSyntaxError):
exc_info = translate_syntax_error(exc_value, source_hint)
initial_skip = 0
else:
initial_skip = 1
return translate_exception(exc_info, initial_skip)
def translate_syntax_error(error, source=None):
"""Rewrites a syntax error to please traceback systems."""
error.source = source
error.translated = True
exc_info = (error.__class__, error, None)
filename = error.filename
if filename is None:
filename = '<unknown>'
return fake_exc_info(exc_info, filename, error.lineno)
def translate_exception(exc_info, initial_skip=0):
"""If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames.
"""
tb = exc_info[2]
frames = []
# skip some internal frames if wanted
for x in range(initial_skip):
if tb is not None:
tb = tb.tb_next
initial_tb = tb
while tb is not None:
# skip frames decorated with @internalcode. These are internal
# calls we can't avoid and that are useless in template debugging
# output.
if tb.tb_frame.f_code in internal_code:
tb = tb.tb_next
continue
# save a reference to the next frame if we override the current
# one with a faked one.
next = tb.tb_next
# fake template exceptions
template = tb.tb_frame.f_globals.get('__jinja_template__')
if template is not None:
lineno = template.get_corresponding_lineno(tb.tb_lineno)
tb = fake_exc_info(exc_info[:2] + (tb,), template.filename,
lineno)[2]
frames.append(make_frame_proxy(tb))
tb = next
# if we don't have any exceptions in the frames left, we have to
# reraise it unchanged.
# XXX: can we backup here? when could this happen?
if not frames:
reraise(exc_info[0], exc_info[1], exc_info[2])
return ProcessedTraceback(exc_info[0], exc_info[1], frames)
def fake_exc_info(exc_info, filename, lineno):
"""Helper for `translate_exception`."""
exc_type, exc_value, tb = exc_info
# figure the real context out
if tb is not None:
real_locals = tb.tb_frame.f_locals.copy()
ctx = real_locals.get('context')
if ctx:
locals = ctx.get_all()
else:
locals = {}
for name, value in iteritems(real_locals):
if name.startswith('l_') and value is not missing:
locals[name[2:]] = value
# if there is a local called __jinja_exception__, we get
# rid of it to not break the debug functionality.
locals.pop('__jinja_exception__', None)
else:
locals = {}
# assamble fake globals we need
globals = {
'__name__': filename,
'__file__': filename,
'__jinja_exception__': exc_info[:2],
# we don't want to keep the reference to the template around
# to not cause circular dependencies, but we mark it as Jinja
# frame for the ProcessedTraceback
'__jinja_template__': None
}
# and fake the exception
code = compile('\n' * (lineno - 1) + raise_helper, filename, 'exec')
# if it's possible, change the name of the code. This won't work
# on some python environments such as google appengine
try:
if tb is None:
location = 'template'
else:
function = tb.tb_frame.f_code.co_name
if function == 'root':
location = 'top-level template code'
elif function.startswith('block_'):
location = 'block "%s"' % function[6:]
else:
location = 'template'
code = code_type(0, code.co_nlocals, code.co_stacksize,
code.co_flags, code.co_code, code.co_consts,
code.co_names, code.co_varnames, filename,
location, code.co_firstlineno,
code.co_lnotab, (), ())
except:
pass
# execute the code and catch the new traceback
try:
exec(code, globals, locals)
except:
exc_info = sys.exc_info()
new_tb = exc_info[2].tb_next
# return without this frame
return exc_info[:2] + (new_tb,)
def _init_ugly_crap():
"""This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object. Do not attempt to use this on non cpython
interpreters
"""
import ctypes
from types import TracebackType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
# regular python
class _PyObject(ctypes.Structure):
pass
_PyObject._fields_ = [
('ob_refcnt', _Py_ssize_t),
('ob_type', ctypes.POINTER(_PyObject))
]
# python with trace
if hasattr(sys, 'getobjects'):
class _PyObject(ctypes.Structure):
pass
_PyObject._fields_ = [
('_ob_next', ctypes.POINTER(_PyObject)),
('_ob_prev', ctypes.POINTER(_PyObject)),
('ob_refcnt', _Py_ssize_t),
('ob_type', ctypes.POINTER(_PyObject))
]
class _Traceback(_PyObject):
pass
_Traceback._fields_ = [
('tb_next', ctypes.POINTER(_Traceback)),
('tb_frame', ctypes.POINTER(_PyObject)),
('tb_lasti', ctypes.c_int),
('tb_lineno', ctypes.c_int)
]
def tb_set_next(tb, next):
"""Set the tb_next attribute of a traceback object."""
if not (isinstance(tb, TracebackType) and
(next is None or isinstance(next, TracebackType))):
raise TypeError('tb_set_next arguments must be traceback objects')
obj = _Traceback.from_address(id(tb))
if tb.tb_next is not None:
old = _Traceback.from_address(id(tb.tb_next))
old.ob_refcnt -= 1
if next is None:
obj.tb_next = ctypes.POINTER(_Traceback)()
else:
next = _Traceback.from_address(id(next))
next.ob_refcnt += 1
obj.tb_next = ctypes.pointer(next)
return tb_set_next
# try to get a tb_set_next implementation if we don't have transparent
# proxies.
tb_set_next = None
if tproxy is None:
try:
tb_set_next = _init_ugly_crap()
except:
pass
del _init_ugly_crap
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
1757,
272,
32202,
339,
24664,
314,
3105,
3217,
367,
17300,
14,
221,
961,
859,
1630,
2005,
7268,
272,
23761,
8292,
543,
314,
2018,
5190,
2656,
315,
1865,
370,
32194,
5190,
83,
272,
543,
3211,
1004,
5579,
12,
9480,
436,
4072,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
984,
199,
646,
5190,
199,
504,
2943,
492,
15273,
804,
199,
504,
10321,
18,
14,
1208,
492,
4124,
12,
5007,
63,
600,
199,
504,
10321,
18,
14,
3924,
492,
17762,
199,
504,
10321,
18,
423,
5819,
492,
10849,
12,
24139,
12,
1233,
63,
466,
199,
199,
3,
641,
1134,
647,
781,
883,
5452,
30268,
402,
17265,
14942,
199,
893,
26,
272,
687,
636,
20233,
363,
492,
307,
3280,
199,
2590,
3545,
26,
272,
307,
3280,
275,
488,
421,
199,
3,
4212,
1630,
314,
746,
5922,
3648,
2839,
31,
199,
893,
26,
272,
2146,
480,
3730,
3146,
12,
283,
1421,
9859,
199,
2590,
12053,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
17,
6616,
199,
2590,
3146,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
16,
467,
636,
12264,
63,
1971,
12298,
17,
6616,
421,
199,
533,
15273,
3160,
4936,
8,
785,
304,
272,
408,
26689,
1500,
282,
5190,
2787,
1041,
339,
347,
636,
826,
721,
277,
12,
7070,
304,
267,
291,
14,
5842,
275,
7070,
267,
291,
423,
5842,
63,
2184,
275,
488,
339,
768,
1829,
272,
347,
7070,
63,
2184,
8,
277,
304,
267,
372,
291,
423,
5842,
63,
2184,
339,
347,
663,
63,
2184,
8,
277,
12,
2163,
304,
267,
340,
7070,
63,
409,
63,
2184,
365,
440,
488,
26,
288,
862,
26,
355,
7070,
63,
409,
63,
2184,
8,
277,
14,
5842,
12,
2163,
436,
2163,
14,
5842,
503,
488,
9,
288,
871,
2186,
26,
355,
327,
642,
805,
883,
2449,
7037,
370,
1006,
314,
11176,
994,
652,
1630,
355,
327,
641,
7750,
2366,
12591,
14,
221,
2136,
2951,
8579,
2552,
355,
327,
3224,
436,
3686,
3062,
340,
5784,
14,
355,
986,
267,
291,
423,
5842,
63,
2184,
275,
2163,
339,
768,
1829,
272,
347,
365,
63,
12264,
63,
1943,
8,
277,
304,
267,
372,
2560,
12264,
63,
1160,
12217,
315,
291,
14,
5842,
14,
5842,
63,
1943,
14,
70,
63,
8473,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
14,
5842,
12,
536,
9,
421,
199,
318,
1852,
63,
1943,
63,
3280,
8,
1943,
304,
272,
4566,
275,
15273,
3160,
4936,
8,
1943,
9,
272,
340,
307,
3280,
365,
488,
26,
267,
372,
4566,
272,
347,
3439,
63,
2232,
8,
5735,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
3439,
315,
25038,
18480,
7500,
2560,
5675,
12168,
288,
372,
2519,
8,
3280,
12,
1249,
59,
16,
566,
267,
916,
3439,
508,
2560,
10202,
3706,
288,
4566,
855,
10202,
9308,
589,
12,
1011,
958,
9,
267,
587,
26,
288,
372,
2519,
8,
3280,
12,
3439,
25967,
589,
12,
1011,
958,
9,
272,
372,
307,
3280,
8,
15905,
804,
12,
3439,
63,
2232,
9,
421,
199,
533,
2165,
4234,
15905,
8,
785,
304,
272,
408,
40,
8250,
282,
17300,
876,
7292,
5190,
367,
16116,
503,
295,
345,
11136,
1041,
339,
347,
636,
826,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
11223,
304,
267,
702,
11223,
12,
283,
889,
11223,
367,
642,
5190,
14069,
267,
291,
14,
2804,
63,
466,
275,
3178,
63,
466,
267,
291,
14,
2804,
63,
585,
275,
3178,
63,
585,
267,
291,
14,
8444,
275,
11223,
398,
327,
13903,
24788,
314,
11223,
334,
6777,
787,
14942,
9,
267,
5071,
63,
5842,
275,
488,
267,
367,
7070,
315,
291,
14,
8444,
26,
288,
340,
5071,
63,
5842,
365,
440,
488,
26,
355,
5071,
63,
5842,
14,
409,
63,
2184,
8,
5842,
9,
288,
5071,
63,
5842,
275,
7070,
267,
5071,
63,
5842,
14,
409,
63,
2184,
8,
403,
9,
339,
347,
3795,
63,
305,
63,
505,
8,
277,
12,
2304,
29,
403,
304,
267,
408,
1767,
282,
1059,
543,
314,
5190,
1041,
267,
2385,
275,
5190,
14,
908,
63,
1971,
8,
277,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
5644,
291,
14,
8444,
59,
16,
467,
2304,
29,
3097,
9,
267,
372,
6522,
904,
8,
1278,
680,
6735,
342,
339,
347,
3795,
63,
305,
63,
1360,
8,
277,
12,
2615,
29,
797,
304,
267,
408,
1767,
282,
2649,
1059,
543,
314,
5190,
465,
8018,
4163,
1041,
267,
687,
10321,
18,
14,
1757,
12471,
492,
3795,
63,
6894,
267,
372,
399,
5956,
83,
60,
78,
60,
78,
25273,
60,
78,
5,
83,
60,
78,
306,
3524,
450,
334,
288,
3795,
63,
6894,
8,
277,
12,
2615,
29,
2861,
395,
288,
291,
14,
3352,
63,
305,
63,
505,
1252,
2708,
360,
1624,
13,
24,
297,
283,
1814,
358,
267,
776,
339,
768,
1829,
272,
347,
365,
63,
1160,
63,
7093,
63,
705,
8,
277,
304,
267,
408,
64,
549,
64,
340,
642,
365,
282,
1978,
6302,
1125,
1041,
267,
372,
1228,
8,
277,
14,
2804,
63,
585,
12,
17762,
9,
339,
768,
1829,
272,
347,
3178,
63,
815,
8,
277,
304,
267,
408,
1726,
2256,
2008,
543,
282,
4566,
6818,
314,
2787,
2251,
1041,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
291,
14,
8444,
59,
16,
61,
339,
768,
1829,
272,
347,
4465,
63,
2804,
63,
815,
8,
277,
304,
267,
408,
9232,
2366,
3178,
63,
815,
367,
295,
13,
345,
11136,
624,
267,
7070,
275,
291,
14,
8444,
59,
16,
61,
267,
327,
314,
2787,
911,
506,
376,
3503,
5190,
334,
269,
17265,
4566,
9,
340,
267,
327,
781,
787,
641,
1134,
647,
503,
282,
2366,
4514,
543,
2291,
367,
307,
3280,
267,
340,
730,
8,
5842,
9,
365,
440,
15273,
804,
26,
288,
7070,
275,
7070,
14,
5842,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
7070,
421,
199,
318,
1852,
63,
6894,
8,
2804,
63,
815,
12
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
10321,
18,
14,
1757,
272,
32202,
339,
24664,
314,
3105,
3217,
367,
17300,
14,
221,
961,
859,
1630,
2005,
7268,
272,
23761,
8292,
543,
314,
2018,
5190,
2656,
315,
1865,
370,
32194,
5190,
83,
272,
543,
3211,
1004,
5579,
12,
9480,
436,
4072,
14,
339,
520,
7307,
26,
334,
67,
9,
7129,
701,
314,
17300,
11682,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
646,
984,
199,
646,
5190,
199,
504,
2943,
492,
15273,
804,
199,
504,
10321,
18,
14,
1208,
492,
4124,
12,
5007,
63,
600,
199,
504,
10321,
18,
14,
3924,
492,
17762,
199,
504,
10321,
18,
423,
5819,
492,
10849,
12,
24139,
12,
1233,
63,
466,
199,
199,
3,
641,
1134,
647,
781,
883,
5452,
30268,
402,
17265,
14942,
199,
893,
26,
272,
687,
636,
20233,
363,
492,
307,
3280,
199,
2590,
3545,
26,
272,
307,
3280,
275,
488,
421,
199,
3,
4212,
1630,
314,
746,
5922,
3648,
2839,
31,
199,
893,
26,
272,
2146,
480,
3730,
3146,
12,
283,
1421,
9859,
199,
2590,
12053,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
17,
6616,
199,
2590,
3146,
26,
272,
746,
63,
3676,
275,
283,
3730,
636,
12264,
63,
1971,
12298,
16,
467,
636,
12264,
63,
1971,
12298,
17,
6616,
421,
199,
533,
15273,
3160,
4936,
8,
785,
304,
272,
408,
26689,
1500,
282,
5190,
2787,
1041,
339,
347,
636,
826,
721,
277,
12,
7070,
304,
267,
291,
14,
5842,
275,
7070,
267,
291,
423,
5842,
63,
2184,
275,
488,
339,
768,
1829,
272,
347,
7070,
63,
2184,
8,
277,
304,
267,
372,
291,
423,
5842,
63,
2184,
339,
347,
663,
63,
2184,
8,
277,
12,
2163,
304,
267,
340,
7070,
63,
409,
63,
2184,
365,
440,
488,
26,
288,
862,
26,
355,
7070,
63,
409,
63,
2184,
8,
277,
14,
5842,
12,
2163,
436,
2163,
14,
5842,
503,
488,
9,
288,
871,
2186,
26,
355,
327,
642,
805,
883,
2449,
7037,
370,
1006,
314,
11176,
994,
652,
1630,
355,
327,
641,
7750,
2366,
12591,
14,
221,
2136,
2951,
8579,
2552,
355,
327,
3224,
436,
3686,
3062,
340,
5784,
14,
355,
986,
267,
291,
423,
5842,
63,
2184,
275,
2163,
339,
768,
1829,
272,
347,
365,
63,
12264,
63,
1943,
8,
277,
304,
267,
372,
2560,
12264,
63,
1160,
12217,
315,
291,
14,
5842,
14,
5842,
63,
1943,
14,
70,
63,
8473,
339,
347,
636,
5675,
721,
277,
12,
536,
304,
267,
372,
2519,
8,
277,
14,
5842,
12,
536,
9,
421,
199,
318,
1852,
63,
1943,
63,
3280,
8,
1943,
304,
272,
4566,
275,
15273,
3160,
4936,
8,
1943,
9,
272,
340,
307,
3280,
365,
488,
26,
267,
372,
4566,
272,
347,
3439,
63,
2232,
8,
5735,
12,
627,
589,
12,
1011,
958,
304,
267,
340,
3439,
315,
25038,
18480,
7500,
2560,
5675,
12168,
288,
372,
2519,
8,
3280,
12,
1249,
59,
16,
566,
267,
916,
3439,
508,
2560,
10202,
3706,
288,
4566,
855,
10202,
9308,
589,
12,
1011,
958,
9,
267,
587,
26,
288,
372,
2519,
8,
3280,
12,
3439,
25967,
589,
12,
1011,
958,
9,
272,
372,
307,
3280,
8,
15905,
804,
12,
3439,
63,
2232,
9,
421,
199,
533,
2165,
4234,
15905,
8,
785,
304,
272,
408,
40,
8250,
282,
17300,
876,
7292,
5190,
367,
16116,
503,
295,
345,
11136,
1041,
339,
347,
636,
826,
721,
277,
12,
3178,
63,
466,
12,
3178,
63,
585,
12,
11223,
304,
267,
702,
11223,
12,
283,
889,
11223,
367,
642,
5190,
14069,
267,
291,
14,
2804,
63,
466,
275,
3178,
63,
466,
267,
291,
14,
2804,
63,
585,
275,
3178,
63,
585,
267,
291,
14,
8444,
275,
11223,
398,
327,
13903,
24788,
314,
11223,
334,
6777,
787,
14942,
9,
267,
5071,
63,
5842,
275,
488,
267,
367,
7070,
315,
291,
14,
8444,
26,
288,
340,
5071,
63,
5842,
365,
440,
488,
26,
355,
5071,
63,
5842,
14,
409,
63,
2184,
8,
5842,
9,
288,
5071,
63,
5842,
275,
7070,
267,
5071,
63,
5842,
14,
409,
63,
2184,
8,
403,
9,
339,
347,
3795,
63,
305,
63,
505,
8,
277,
12,
2304,
29,
403,
304,
267,
408,
1767,
282,
1059,
543,
314,
5190,
1041,
267,
2385,
275,
5190,
14,
908,
63,
1971,
8,
277,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
5644,
291,
14,
8444,
59,
16,
467,
2304,
29,
3097,
9,
267,
372,
6522,
904,
8,
1278,
680,
6735,
342,
339,
347,
3795,
63,
305,
63,
1360,
8,
277,
12,
2615,
29,
797,
304,
267,
408,
1767,
282,
2649,
1059,
543,
314,
5190,
465,
8018,
4163,
1041,
267,
687,
10321,
18,
14,
1757,
12471,
492,
3795,
63,
6894,
267,
372,
399,
5956,
83,
60,
78,
60,
78,
25273,
60,
78,
5,
83,
60,
78,
306,
3524,
450,
334,
288,
3795,
63,
6894,
8,
277,
12,
2615,
29,
2861,
395,
288,
291,
14,
3352,
63,
305,
63,
505,
1252,
2708,
360,
1624,
13,
24,
297,
283,
1814,
358,
267,
776,
339,
768,
1829,
272,
347,
365,
63,
1160,
63,
7093,
63,
705,
8,
277,
304,
267,
408,
64,
549,
64,
340,
642,
365,
282,
1978,
6302,
1125,
1041,
267,
372,
1228,
8,
277,
14,
2804,
63,
585,
12,
17762,
9,
339,
768,
1829,
272,
347,
3178,
63,
815,
8,
277,
304,
267,
408,
1726,
2256,
2008,
543,
282,
4566,
6818,
314,
2787,
2251,
1041,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
291,
14,
8444,
59,
16,
61,
339,
768,
1829,
272,
347,
4465,
63,
2804,
63,
815,
8,
277,
304,
267,
408,
9232,
2366,
3178,
63,
815,
367,
295,
13,
345,
11136,
624,
267,
7070,
275,
291,
14,
8444,
59,
16,
61,
267,
327,
314,
2787,
911,
506,
376,
3503,
5190,
334,
269,
17265,
4566,
9,
340,
267,
327,
781,
787,
641,
1134,
647,
503,
282,
2366,
4514,
543,
2291,
367,
307,
3280,
267,
340,
730,
8,
5842,
9,
365,
440,
15273,
804,
26,
288,
7070,
275,
7070,
14,
5842,
267,
372,
291,
14,
2804,
63,
466,
12,
291,
14,
2804,
63,
585,
12,
7070,
421,
199,
318,
1852,
63,
6894,
8,
2804,
63,
815,
12,
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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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
] |
kiyoto/statsmodels
|
statsmodels/api.py
|
2
|
1484
|
from . import iolib
from . import datasets
from . import tools
from .tools.tools import add_constant, categorical
from . import regression
from .regression.linear_model import OLS, GLS, WLS, GLSAR
from .regression.quantile_regression import QuantReg
from .regression.mixed_linear_model import MixedLM
from .genmod import api as genmod
from .genmod.api import GLM, GEE, OrdinalGEE, NominalGEE, families, cov_struct
from . import robust
from .robust.robust_linear_model import RLM
from .discrete.discrete_model import (Poisson, Logit, Probit,
MNLogit, NegativeBinomial)
from .tsa import api as tsa
from .duration.hazard_regression import PHReg
from .nonparametric import api as nonparametric
from . import distributions
from .__init__ import test
from . import version
from .info import __doc__
from .graphics.gofplots import qqplot, qqplot_2samples, qqline, ProbPlot
from .graphics import api as graphics
from .stats import api as stats
from .emplike import api as emplike
from .duration import api as duration
from .formula import api as formula
from .iolib.smpickle import load_pickle as load
from .tools.pca import PCA
from .tools.print_version import show_versions
from .tools.web import webdoc
import os
chmpath = os.path.join(os.path.dirname(__file__), 'statsmodelsdoc.chm')
if os.path.exists(chmpath):
def open_help(chmpath=chmpath):
from subprocess import Popen
p = Popen(chmpath, shell=True)
del os
del chmpath
|
bsd-3-clause
|
[
504,
1275,
492,
5890,
773,
199,
504,
1275,
492,
13148,
199,
504,
1275,
492,
7249,
199,
504,
1275,
2537,
14,
2537,
492,
1050,
63,
4083,
12,
22138,
199,
504,
1275,
492,
10864,
199,
504,
1275,
12513,
14,
6676,
63,
1238,
492,
593,
5296,
12,
3563,
51,
12,
644,
5296,
12,
3563,
51,
689,
199,
504,
1275,
12513,
14,
29249,
63,
12513,
492,
5843,
867,
2872,
199,
504,
1275,
12513,
14,
10455,
63,
6676,
63,
1238,
492,
21203,
25526,
199,
504,
1275,
2268,
1494,
492,
2986,
465,
3805,
1494,
199,
504,
1275,
2268,
1494,
14,
1246,
492,
3563,
45,
12,
598,
8699,
12,
4236,
68,
1582,
4962,
37,
12,
653,
676,
1582,
4962,
37,
12,
21450,
20111,
12,
13786,
63,
1820,
199,
504,
1275,
492,
23399,
199,
504,
1275,
293,
15549,
14,
293,
15549,
63,
6676,
63,
1238,
492,
820,
25526,
199,
504,
1275,
23591,
14,
23591,
63,
1238,
492,
334,
1575,
18571,
12,
5297,
390,
12,
2165,
2075,
12,
4228,
603,
46,
2445,
390,
12,
32548,
13394,
6471,
9,
199,
504,
1275,
1086,
65,
492,
2986,
465,
307,
2231,
199,
504,
1275,
5553,
14,
22133,
1005,
63,
12513,
492,
510,
40,
2872,
199,
504,
1275,
2865,
9727,
67,
492,
2986,
465,
2222,
9727,
67,
199,
504,
1275,
492,
10208,
199,
504,
221,
855,
826,
363,
492,
511,
199,
504,
1275,
492,
1015,
199,
504,
1275,
815,
492,
636,
1301,
363,
199,
504,
1275,
15707,
14,
71,
1618,
13701,
492,
1894,
81,
2798,
12,
1894,
81,
2798,
63,
18,
3356,
12,
1894,
81,
604,
12,
22770,
10711,
199,
504,
1275,
15707,
492,
2986,
465,
24348,
199,
504,
1275,
3200,
492,
2986,
465,
5020,
199,
504,
1275,
2109,
2930,
492,
2986,
465,
9052,
2930,
199,
504,
1275,
5553,
492,
2986,
465,
7373,
199,
199,
504,
1275,
16798,
492,
2986,
465,
15723,
199,
199,
504,
1275,
2308,
773,
14,
83,
311,
2000,
274,
492,
2248,
63,
8092,
465,
2248,
199,
199,
504,
1275,
2537,
14,
19247,
492,
25266,
199,
504,
1275,
2537,
14,
1361,
63,
1023,
492,
2498,
63,
6234,
199,
504,
1275,
2537,
14,
2520,
492,
3330,
1301,
199,
199,
646,
747,
199,
199,
335,
8075,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
3200,
992,
1301,
14,
335,
77,
358,
199,
692,
747,
14,
515,
14,
2444,
8,
335,
8075,
304,
272,
347,
1551,
63,
3437,
8,
335,
8075,
29,
335,
8075,
304,
267,
687,
3873,
492,
13995,
398,
299,
275,
13995,
8,
335,
8075,
12,
5218,
29,
549,
9,
199,
199,
2264,
747,
199,
2264,
682,
8075,
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
] |
[
1275,
492,
5890,
773,
199,
504,
1275,
492,
13148,
199,
504,
1275,
492,
7249,
199,
504,
1275,
2537,
14,
2537,
492,
1050,
63,
4083,
12,
22138,
199,
504,
1275,
492,
10864,
199,
504,
1275,
12513,
14,
6676,
63,
1238,
492,
593,
5296,
12,
3563,
51,
12,
644,
5296,
12,
3563,
51,
689,
199,
504,
1275,
12513,
14,
29249,
63,
12513,
492,
5843,
867,
2872,
199,
504,
1275,
12513,
14,
10455,
63,
6676,
63,
1238,
492,
21203,
25526,
199,
504,
1275,
2268,
1494,
492,
2986,
465,
3805,
1494,
199,
504,
1275,
2268,
1494,
14,
1246,
492,
3563,
45,
12,
598,
8699,
12,
4236,
68,
1582,
4962,
37,
12,
653,
676,
1582,
4962,
37,
12,
21450,
20111,
12,
13786,
63,
1820,
199,
504,
1275,
492,
23399,
199,
504,
1275,
293,
15549,
14,
293,
15549,
63,
6676,
63,
1238,
492,
820,
25526,
199,
504,
1275,
23591,
14,
23591,
63,
1238,
492,
334,
1575,
18571,
12,
5297,
390,
12,
2165,
2075,
12,
4228,
603,
46,
2445,
390,
12,
32548,
13394,
6471,
9,
199,
504,
1275,
1086,
65,
492,
2986,
465,
307,
2231,
199,
504,
1275,
5553,
14,
22133,
1005,
63,
12513,
492,
510,
40,
2872,
199,
504,
1275,
2865,
9727,
67,
492,
2986,
465,
2222,
9727,
67,
199,
504,
1275,
492,
10208,
199,
504,
221,
855,
826,
363,
492,
511,
199,
504,
1275,
492,
1015,
199,
504,
1275,
815,
492,
636,
1301,
363,
199,
504,
1275,
15707,
14,
71,
1618,
13701,
492,
1894,
81,
2798,
12,
1894,
81,
2798,
63,
18,
3356,
12,
1894,
81,
604,
12,
22770,
10711,
199,
504,
1275,
15707,
492,
2986,
465,
24348,
199,
504,
1275,
3200,
492,
2986,
465,
5020,
199,
504,
1275,
2109,
2930,
492,
2986,
465,
9052,
2930,
199,
504,
1275,
5553,
492,
2986,
465,
7373,
199,
199,
504,
1275,
16798,
492,
2986,
465,
15723,
199,
199,
504,
1275,
2308,
773,
14,
83,
311,
2000,
274,
492,
2248,
63,
8092,
465,
2248,
199,
199,
504,
1275,
2537,
14,
19247,
492,
25266,
199,
504,
1275,
2537,
14,
1361,
63,
1023,
492,
2498,
63,
6234,
199,
504,
1275,
2537,
14,
2520,
492,
3330,
1301,
199,
199,
646,
747,
199,
199,
335,
8075,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
3200,
992,
1301,
14,
335,
77,
358,
199,
692,
747,
14,
515,
14,
2444,
8,
335,
8075,
304,
272,
347,
1551,
63,
3437,
8,
335,
8075,
29,
335,
8075,
304,
267,
687,
3873,
492,
13995,
398,
299,
275,
13995,
8,
335,
8075,
12,
5218,
29,
549,
9,
199,
199,
2264,
747,
199,
2264,
682,
8075,
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,
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,
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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
] |
rodriguezdevera/sakai
|
reference/library/src/webapp/editor/FCKeditor/editor/filemanager/connectors/py/fckconnector.py
|
131
|
2686
|
#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2010 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http://www.gnu.org/licenses/gpl.html
- GNU Lesser General Public License Version 2.1 or later (the "LGPL")
http://www.gnu.org/licenses/lgpl.html
- Mozilla Public License Version 1.1 or later (the "MPL")
http://www.mozilla.org/MPL/MPL-1.1.html
== END LICENSE ==
Base Connector for Python (CGI and WSGI).
See config.py for configuration settings
"""
import cgi, os
from fckutil import *
from fckcommands import * # default command's implementation
from fckoutput import * # base http, xml and html output mixins
import config as Config
class FCKeditorConnectorBase( object ):
"The base connector class. Subclass it to extend functionality (see Zope example)"
def __init__(self, environ=None):
"Constructor: Here you should parse request fields, initialize variables, etc."
self.request = FCKeditorRequest(environ) # Parse request
self.headers = [] # Clean Headers
if environ:
self.environ = environ
else:
self.environ = os.environ
# local functions
def setHeader(self, key, value):
self.headers.append ((key, value))
return
class FCKeditorRequest(object):
"A wrapper around the request object"
def __init__(self, environ):
if environ: # WSGI
self.request = cgi.FieldStorage(fp=environ['wsgi.input'],
environ=environ,
keep_blank_values=1)
self.environ = environ
else: # plain old cgi
self.environ = os.environ
self.request = cgi.FieldStorage()
if 'REQUEST_METHOD' in self.environ and 'QUERY_STRING' in self.environ:
if self.environ['REQUEST_METHOD'].upper()=='POST':
# we are in a POST, but GET query_string exists
# cgi parses by default POST data, so parse GET QUERY_STRING too
self.get_request = cgi.FieldStorage(fp=None,
environ={
'REQUEST_METHOD':'GET',
'QUERY_STRING':self.environ['QUERY_STRING'],
},
)
else:
self.get_request={}
def has_key(self, key):
return self.request.has_key(key) or self.get_request.has_key(key)
def get(self, key, default=None):
if key in self.request.keys():
field = self.request[key]
elif key in self.get_request.keys():
field = self.get_request[key]
else:
return default
if hasattr(field,"filename") and field.filename: #file upload, do not convert return value
return field
else:
return field.value
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
2999,
199,
624,
202,
199,
4161,
1136,
27050,
446,
710,
1318,
8823,
367,
22026,
446,
1455,
921,
1544,
14,
70,
346,
7515,
14,
846,
202,
199,
7384,
334,
35,
9,
13004,
13,
6542,
481,
264,
9910,
331,
8256,
271,
20936,
1804,
78,
12198,
287,
2999,
199,
389,
16427,
5113,
508,
2999,
199,
31661,
1334,
314,
2895,
402,
1263,
402,
314,
2569,
12378,
737,
2195,
202,
199,
5095,
26,
2999,
199,
13,
1664,
1696,
1684,
844,
3394,
499,
503,
2945,
334,
1589,
298,
12006,
531,
202,
199,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
14,
1360,
2999,
199,
13,
1664,
6401,
1696,
1684,
844,
3394,
499,
14,
17,
503,
2945,
334,
1589,
298,
44,
12006,
531,
202,
199,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
9783,
1168,
14,
1360,
2999,
199,
13,
17728,
1684,
844,
3394,
413,
14,
17,
503,
2945,
334,
1589,
298,
3950,
531,
202,
199,
1014,
921,
1544,
14,
12102,
14,
1308,
15,
3950,
15,
3950,
13,
17,
14,
17,
14,
1360,
2999,
199,
389,
7729,
5113,
508,
2999,
199,
1563,
13482,
2406,
367,
2018,
334,
21337,
436,
9279,
680,
2999,
199,
9295,
1101,
14,
647,
367,
2897,
2202,
2999,
199,
624,
202,
199,
646,
16004,
12,
747,
2999,
199,
504,
289,
346,
1974,
492,
627,
202,
199,
504,
289,
346,
4405,
492,
627,
221,
198,
3,
849,
1414,
1159,
4514,
202,
199,
504,
289,
346,
1199,
492,
627,
221,
198,
3,
1300,
1455,
12,
2748,
436,
3517,
1072,
13667,
3617,
202,
199,
646,
1101,
465,
4094,
2999,
199,
533,
20934,
1136,
27050,
20476,
1563,
8,
909,
3461,
1223,
198,
2,
1918,
1300,
13252,
1021,
14,
30184,
652,
370,
12247,
9330,
334,
3239,
3107,
13458,
2893,
2924,
10060,
198,
318,
636,
826,
721,
277,
12,
6160,
29,
403,
304,
4122,
198,
2,
11447,
26,
11842,
1265,
1077,
2198,
1056,
1504,
12,
8265,
2860,
12,
5423,
2122,
4122,
198,
277,
14,
1069,
275,
20934,
1136,
27050,
2017,
8,
2314,
9,
327,
6077,
1056,
4122,
198,
277,
14,
2139,
275,
942,
27997,
198,
3,
12762,
21391,
4122,
198,
692,
6160,
26,
7903,
198,
277,
14,
2314,
275,
6160,
4122,
198,
2836,
26,
7903,
198,
277,
14,
2314,
275,
747,
14,
2314,
10060,
198,
3,
2257,
3423,
10060,
198,
318,
663,
2567,
8,
277,
12,
790,
12,
574,
304,
4122,
198,
277,
14,
2139,
14,
740,
3666,
498,
12,
574,
430,
4122,
198,
1107,
2999,
199,
533,
20934,
1136,
27050,
2017,
8,
785,
304,
1223,
198,
2,
33,
4975,
6818,
314,
1056,
909,
2,
1223,
198,
318,
636,
826,
721,
277,
12,
6160,
304,
4122,
198,
692,
6160,
26,
327,
9279,
7903,
198,
277,
14,
1069,
275,
16004,
14,
792,
6408,
8,
3997,
29,
2314,
459,
6508,
14,
1210,
995,
28578,
198,
2314,
29,
2314,
12,
28578,
198,
3250,
63,
2500,
63,
1459,
29,
17,
9,
7903,
198,
277,
14,
2314,
275,
6160,
4122,
198,
2836,
26,
327,
8971,
2269,
16004,
7903,
198,
277,
14,
2314,
275,
747,
14,
2314,
7903,
198,
277,
14,
1069,
275,
16004,
14,
792,
6408,
342,
4122,
198,
692,
283,
6780,
63,
9977,
7,
315,
291,
14,
2314,
436,
283,
11938,
63,
5353,
7,
315,
291,
14,
2314,
26,
7903,
198,
692,
291,
14,
2314,
459,
6780,
63,
9977,
2278,
4142,
342,
6803,
4030,
356,
13610,
198,
3,
781,
787,
315,
282,
8761,
12,
1325,
9576,
1827,
63,
875,
3495,
13610,
198,
3,
16004,
19953,
701,
849,
8761,
666,
12,
880,
2198,
9576,
7813,
9418,
63,
5353,
4634,
13610,
198,
277,
14,
362,
63,
1069,
275,
16004,
14,
792,
6408,
8,
3997,
29,
403,
12,
28578,
198,
2314,
3126,
28578,
198,
7,
6780,
63,
9977,
5242,
2970,
297,
28578,
198,
7,
11938,
63,
5353,
356,
277,
14,
2314,
459,
11938,
63,
5353,
995,
28578,
198,
1386,
28578,
198,
9,
4122,
198,
2836,
26,
7903,
198,
277,
14,
362,
63,
1069,
7622,
10060,
198,
318,
965,
63,
498,
8,
277,
12,
790,
304,
4122,
198,
1107,
291,
14,
1069,
14,
1989,
63,
498,
8,
498,
9,
503,
291,
14,
362,
63,
1069,
14,
1989,
63,
498,
8,
498,
9,
10060,
198,
318,
664,
8,
277,
12,
790,
12,
849,
29,
403,
304,
4122,
198,
692,
790,
315,
291,
14,
1069,
14,
1612,
837,
7903,
198,
698,
275,
291,
14,
1069,
59,
498,
61,
4122,
198,
4164,
790,
315,
291,
14,
362,
63,
1069,
14,
1612,
837,
7903,
198,
698,
275,
291,
14,
362,
63,
1069,
59,
498,
61,
4122,
198,
2836,
26,
7903,
198,
1107,
849,
4122,
198,
692,
2688,
8,
698,
4589,
1501,
531,
436,
901,
14,
1501,
26,
327,
493,
5802,
12,
886,
440,
3957,
372,
574,
7903,
198,
1107,
901,
4122,
198,
2836,
26,
7903,
198,
1107,
901,
14,
585,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
2999,
199,
624,
202,
199,
4161,
1136,
27050,
446,
710,
1318,
8823,
367,
22026,
446,
1455,
921,
1544,
14,
70,
346,
7515,
14,
846,
202,
199,
7384,
334,
35,
9,
13004,
13,
6542,
481,
264,
9910,
331,
8256,
271,
20936,
1804,
78,
12198,
287,
2999,
199,
389,
16427,
5113,
508,
2999,
199,
31661,
1334,
314,
2895,
402,
1263,
402,
314,
2569,
12378,
737,
2195,
202,
199,
5095,
26,
2999,
199,
13,
1664,
1696,
1684,
844,
3394,
499,
503,
2945,
334,
1589,
298,
12006,
531,
202,
199,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
14,
1360,
2999,
199,
13,
1664,
6401,
1696,
1684,
844,
3394,
499,
14,
17,
503,
2945,
334,
1589,
298,
44,
12006,
531,
202,
199,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
9783,
1168,
14,
1360,
2999,
199,
13,
17728,
1684,
844,
3394,
413,
14,
17,
503,
2945,
334,
1589,
298,
3950,
531,
202,
199,
1014,
921,
1544,
14,
12102,
14,
1308,
15,
3950,
15,
3950,
13,
17,
14,
17,
14,
1360,
2999,
199,
389,
7729,
5113,
508,
2999,
199,
1563,
13482,
2406,
367,
2018,
334,
21337,
436,
9279,
680,
2999,
199,
9295,
1101,
14,
647,
367,
2897,
2202,
2999,
199,
624,
202,
199,
646,
16004,
12,
747,
2999,
199,
504,
289,
346,
1974,
492,
627,
202,
199,
504,
289,
346,
4405,
492,
627,
221,
198,
3,
849,
1414,
1159,
4514,
202,
199,
504,
289,
346,
1199,
492,
627,
221,
198,
3,
1300,
1455,
12,
2748,
436,
3517,
1072,
13667,
3617,
202,
199,
646,
1101,
465,
4094,
2999,
199,
533,
20934,
1136,
27050,
20476,
1563,
8,
909,
3461,
1223,
198,
2,
1918,
1300,
13252,
1021,
14,
30184,
652,
370,
12247,
9330,
334,
3239,
3107,
13458,
2893,
2924,
10060,
198,
318,
636,
826,
721,
277,
12,
6160,
29,
403,
304,
4122,
198,
2,
11447,
26,
11842,
1265,
1077,
2198,
1056,
1504,
12,
8265,
2860,
12,
5423,
2122,
4122,
198,
277,
14,
1069,
275,
20934,
1136,
27050,
2017,
8,
2314,
9,
327,
6077,
1056,
4122,
198,
277,
14,
2139,
275,
942,
27997,
198,
3,
12762,
21391,
4122,
198,
692,
6160,
26,
7903,
198,
277,
14,
2314,
275,
6160,
4122,
198,
2836,
26,
7903,
198,
277,
14,
2314,
275,
747,
14,
2314,
10060,
198,
3,
2257,
3423,
10060,
198,
318,
663,
2567,
8,
277,
12,
790,
12,
574,
304,
4122,
198,
277,
14,
2139,
14,
740,
3666,
498,
12,
574,
430,
4122,
198,
1107,
2999,
199,
533,
20934,
1136,
27050,
2017,
8,
785,
304,
1223,
198,
2,
33,
4975,
6818,
314,
1056,
909,
2,
1223,
198,
318,
636,
826,
721,
277,
12,
6160,
304,
4122,
198,
692,
6160,
26,
327,
9279,
7903,
198,
277,
14,
1069,
275,
16004,
14,
792,
6408,
8,
3997,
29,
2314,
459,
6508,
14,
1210,
995,
28578,
198,
2314,
29,
2314,
12,
28578,
198,
3250,
63,
2500,
63,
1459,
29,
17,
9,
7903,
198,
277,
14,
2314,
275,
6160,
4122,
198,
2836,
26,
327,
8971,
2269,
16004,
7903,
198,
277,
14,
2314,
275,
747,
14,
2314,
7903,
198,
277,
14,
1069,
275,
16004,
14,
792,
6408,
342,
4122,
198,
692,
283,
6780,
63,
9977,
7,
315,
291,
14,
2314,
436,
283,
11938,
63,
5353,
7,
315,
291,
14,
2314,
26,
7903,
198,
692,
291,
14,
2314,
459,
6780,
63,
9977,
2278,
4142,
342,
6803,
4030,
356,
13610,
198,
3,
781,
787,
315,
282,
8761,
12,
1325,
9576,
1827,
63,
875,
3495,
13610,
198,
3,
16004,
19953,
701,
849,
8761,
666,
12,
880,
2198,
9576,
7813,
9418,
63,
5353,
4634,
13610,
198,
277,
14,
362,
63,
1069,
275,
16004,
14,
792,
6408,
8,
3997,
29,
403,
12,
28578,
198,
2314,
3126,
28578,
198,
7,
6780,
63,
9977,
5242,
2970,
297,
28578,
198,
7,
11938,
63,
5353,
356,
277,
14,
2314,
459,
11938,
63,
5353,
995,
28578,
198,
1386,
28578,
198,
9,
4122,
198,
2836,
26,
7903,
198,
277,
14,
362,
63,
1069,
7622,
10060,
198,
318,
965,
63,
498,
8,
277,
12,
790,
304,
4122,
198,
1107,
291,
14,
1069,
14,
1989,
63,
498,
8,
498,
9,
503,
291,
14,
362,
63,
1069,
14,
1989,
63,
498,
8,
498,
9,
10060,
198,
318,
664,
8,
277,
12,
790,
12,
849,
29,
403,
304,
4122,
198,
692,
790,
315,
291,
14,
1069,
14,
1612,
837,
7903,
198,
698,
275,
291,
14,
1069,
59,
498,
61,
4122,
198,
4164,
790,
315,
291,
14,
362,
63,
1069,
14,
1612,
837,
7903,
198,
698,
275,
291,
14,
362,
63,
1069,
59,
498,
61,
4122,
198,
2836,
26,
7903,
198,
1107,
849,
4122,
198,
692,
2688,
8,
698,
4589,
1501,
531,
436,
901,
14,
1501,
26,
327,
493,
5802,
12,
886,
440,
3957,
372,
574,
7903,
198,
1107,
901,
4122,
198,
2836,
26,
7903,
198,
1107,
901,
14,
585,
1223,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
bonitadecker77/python-for-android
|
python-modules/twisted/twisted/trial/test/test_output.py
|
61
|
5167
|
# Copyright (c) 2008 Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Tests for the output generated by trial.
"""
import os, StringIO
from twisted.scripts import trial
from twisted.trial import runner
from twisted.trial.test import packages
def runTrial(*args):
from twisted.trial import reporter
config = trial.Options()
config.parseOptions(args)
output = StringIO.StringIO()
myRunner = runner.TrialRunner(
reporter.VerboseTextReporter,
stream=output,
workingDirectory=config['temp-directory'])
suite = trial._getSuite(config)
result = myRunner.run(suite)
return output.getvalue()
class TestImportErrors(packages.SysPathManglingTest):
"""Actually run trial as if on the command line and check that the output
is what we expect.
"""
debug = False
parent = "_testImportErrors"
def runTrial(self, *args):
return runTrial('--temp-directory', self.mktemp(), *args)
def _print(self, stuff):
print stuff
return stuff
def failUnlessIn(self, container, containee, *args, **kwargs):
# redefined to be useful in callbacks
super(TestImportErrors, self).failUnlessIn(
containee, container, *args, **kwargs)
return container
def failIfIn(self, container, containee, *args, **kwargs):
# redefined to be useful in callbacks
super(TestImportErrors, self).failIfIn(
containee, container, *args, **kwargs)
return container
def test_trialRun(self):
self.runTrial()
def test_nonexistentModule(self):
d = self.runTrial('twisted.doesntexist')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, 'twisted.doesntexist')
return d
def test_nonexistentPackage(self):
d = self.runTrial('doesntexist')
self.failUnlessIn(d, 'doesntexist')
self.failUnlessIn(d, 'ModuleNotFound')
self.failUnlessIn(d, '[ERROR]')
return d
def test_nonexistentPackageWithModule(self):
d = self.runTrial('doesntexist.barney')
self.failUnlessIn(d, 'doesntexist.barney')
self.failUnlessIn(d, 'ObjectNotFound')
self.failUnlessIn(d, '[ERROR]')
return d
def test_badpackage(self):
d = self.runTrial('badpackage')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, 'badpackage')
self.failIfIn(d, 'IOError')
return d
def test_moduleInBadpackage(self):
d = self.runTrial('badpackage.test_module')
self.failUnlessIn(d, "[ERROR]")
self.failUnlessIn(d, "badpackage.test_module")
self.failIfIn(d, 'IOError')
return d
def test_badmodule(self):
d = self.runTrial('package.test_bad_module')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, 'package.test_bad_module')
self.failIfIn(d, 'IOError')
self.failIfIn(d, '<module ')
return d
def test_badimport(self):
d = self.runTrial('package.test_import_module')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, 'package.test_import_module')
self.failIfIn(d, 'IOError')
self.failIfIn(d, '<module ')
return d
def test_recurseImport(self):
d = self.runTrial('package')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, 'test_bad_module')
self.failUnlessIn(d, 'test_import_module')
self.failIfIn(d, '<module ')
self.failIfIn(d, 'IOError')
return d
def test_recurseImportErrors(self):
d = self.runTrial('package2')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, 'package2')
self.failUnlessIn(d, 'test_module')
self.failUnlessIn(d, "No module named frotz")
self.failIfIn(d, '<module ')
self.failIfIn(d, 'IOError')
return d
def test_nonRecurseImportErrors(self):
d = self.runTrial('-N', 'package2')
self.failUnlessIn(d, '[ERROR]')
self.failUnlessIn(d, "No module named frotz")
self.failIfIn(d, '<module ')
return d
def test_regularRun(self):
d = self.runTrial('package.test_module')
self.failIfIn(d, '[ERROR]')
self.failIfIn(d, 'IOError')
self.failUnlessIn(d, 'OK')
self.failUnlessIn(d, 'PASSED (successes=1)')
return d
def test_filename(self):
self.mangleSysPath(self.oldPath)
d = self.runTrial(
os.path.join(self.parent, 'package', 'test_module.py'))
self.failIfIn(d, '[ERROR]')
self.failIfIn(d, 'IOError')
self.failUnlessIn(d, 'OK')
self.failUnlessIn(d, 'PASSED (successes=1)')
return d
def test_dosFile(self):
## XXX -- not really an output test, more of a script test
self.mangleSysPath(self.oldPath)
d = self.runTrial(
os.path.join(self.parent,
'package', 'test_dos_module.py'))
self.failIfIn(d, '[ERROR]')
self.failIfIn(d, 'IOError')
self.failUnlessIn(d, 'OK')
self.failUnlessIn(d, 'PASSED (successes=1)')
return d
|
apache-2.0
|
[
3,
1898,
334,
67,
9,
9079,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
199,
199,
624,
199,
2925,
367,
314,
1072,
4046,
701,
16324,
14,
199,
624,
199,
199,
646,
747,
12,
5228,
199,
199,
504,
7390,
14,
6429,
492,
16324,
199,
504,
7390,
14,
14443,
492,
7876,
199,
504,
7390,
14,
14443,
14,
396,
492,
6117,
421,
199,
318,
1255,
52,
1383,
2031,
589,
304,
272,
687,
7390,
14,
14443,
492,
17663,
272,
1101,
275,
16324,
14,
4558,
342,
272,
1101,
14,
1122,
4558,
8,
589,
9,
272,
1072,
275,
5228,
14,
6424,
342,
272,
3002,
7446,
275,
7876,
14,
52,
1383,
7446,
8,
267,
17663,
14,
21879,
1872,
15891,
12,
267,
2547,
29,
1199,
12,
267,
6449,
6231,
29,
888,
459,
808,
13,
3619,
1105,
272,
5241,
275,
16324,
423,
362,
6207,
8,
888,
9,
272,
754,
275,
3002,
7446,
14,
1065,
8,
5768,
9,
272,
372,
1072,
14,
7150,
342,
421,
199,
533,
1379,
6295,
9298,
8,
5154,
14,
11319,
2042,
45,
26896,
774,
304,
272,
408,
19348,
3163,
1255,
16324,
465,
340,
641,
314,
1414,
1004,
436,
1104,
626,
314,
1072,
272,
365,
4052,
781,
4282,
14,
272,
408,
339,
3105,
275,
756,
272,
1676,
275,
2668,
396,
6295,
9298,
2,
272,
347,
1255,
52,
1383,
8,
277,
12,
627,
589,
304,
267,
372,
1255,
52,
1383,
4517,
808,
13,
3619,
297,
291,
14,
22136,
1062,
627,
589,
9,
339,
347,
485,
1361,
8,
277,
12,
8292,
304,
267,
870,
8292,
267,
372,
8292,
339,
347,
2449,
5524,
607,
8,
277,
12,
3970,
12,
1395,
1024,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
295,
4037,
370,
506,
2997,
315,
13484,
267,
1613,
8,
774,
6295,
9298,
12,
291,
680,
7589,
607,
8,
288,
1395,
1024,
12,
3970,
12,
627,
589,
12,
1011,
958,
9,
267,
372,
3970,
339,
347,
2449,
3917,
607,
8,
277,
12,
3970,
12,
1395,
1024,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
295,
4037,
370,
506,
2997,
315,
13484,
267,
1613,
8,
774,
6295,
9298,
12,
291,
680,
19670,
607,
8,
288,
1395,
1024,
12,
3970,
12,
627,
589,
12,
1011,
958,
9,
267,
372,
3970,
339,
347,
511,
63,
14443,
2540,
8,
277,
304,
267,
291,
14,
1065,
52,
1383,
342,
339,
347,
511,
63,
21573,
2377,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
12145,
14,
30977,
3858,
631,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
12145,
14,
30977,
3858,
631,
358,
267,
372,
366,
339,
347,
511,
63,
21573,
8599,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
30977,
3858,
631,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
30977,
3858,
631,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2377,
4667,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
372,
366,
339,
347,
511,
63,
21573,
8599,
3007,
2377,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
30977,
3858,
631,
14,
1700,
23263,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
30977,
3858,
631,
14,
1700,
23263,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
1692,
4667,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
372,
366,
339,
347,
511,
63,
4087,
2491,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
4087,
2491,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
4087,
2491,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
372,
366,
339,
347,
511,
63,
578,
607,
5725,
2491,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
4087,
2491,
14,
396,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
7369,
3170,
12523,
267,
291,
14,
7589,
607,
8,
68,
12,
298,
4087,
2491,
14,
396,
63,
578,
531,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
372,
366,
339,
347,
511,
63,
4087,
578,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
14,
396,
63,
4087,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2491,
14,
396,
63,
4087,
63,
578,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
372,
366,
339,
347,
511,
63,
2470,
328,
412,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
14,
396,
63,
646,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2491,
14,
396,
63,
646,
63,
578,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
372,
366,
339,
347,
511,
63,
25786,
6295,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
396,
63,
4087,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
396,
63,
646,
63,
578,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
372,
366,
339,
347,
511,
63,
25786,
6295,
9298,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
18,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2491,
18,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
396,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
298,
1944,
859,
4310,
26226,
3903,
531,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
291,
14,
19670,
607,
8,
68,
12
] |
[
1898,
334,
67,
9,
9079,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
199,
199,
624,
199,
2925,
367,
314,
1072,
4046,
701,
16324,
14,
199,
624,
199,
199,
646,
747,
12,
5228,
199,
199,
504,
7390,
14,
6429,
492,
16324,
199,
504,
7390,
14,
14443,
492,
7876,
199,
504,
7390,
14,
14443,
14,
396,
492,
6117,
421,
199,
318,
1255,
52,
1383,
2031,
589,
304,
272,
687,
7390,
14,
14443,
492,
17663,
272,
1101,
275,
16324,
14,
4558,
342,
272,
1101,
14,
1122,
4558,
8,
589,
9,
272,
1072,
275,
5228,
14,
6424,
342,
272,
3002,
7446,
275,
7876,
14,
52,
1383,
7446,
8,
267,
17663,
14,
21879,
1872,
15891,
12,
267,
2547,
29,
1199,
12,
267,
6449,
6231,
29,
888,
459,
808,
13,
3619,
1105,
272,
5241,
275,
16324,
423,
362,
6207,
8,
888,
9,
272,
754,
275,
3002,
7446,
14,
1065,
8,
5768,
9,
272,
372,
1072,
14,
7150,
342,
421,
199,
533,
1379,
6295,
9298,
8,
5154,
14,
11319,
2042,
45,
26896,
774,
304,
272,
408,
19348,
3163,
1255,
16324,
465,
340,
641,
314,
1414,
1004,
436,
1104,
626,
314,
1072,
272,
365,
4052,
781,
4282,
14,
272,
408,
339,
3105,
275,
756,
272,
1676,
275,
2668,
396,
6295,
9298,
2,
272,
347,
1255,
52,
1383,
8,
277,
12,
627,
589,
304,
267,
372,
1255,
52,
1383,
4517,
808,
13,
3619,
297,
291,
14,
22136,
1062,
627,
589,
9,
339,
347,
485,
1361,
8,
277,
12,
8292,
304,
267,
870,
8292,
267,
372,
8292,
339,
347,
2449,
5524,
607,
8,
277,
12,
3970,
12,
1395,
1024,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
295,
4037,
370,
506,
2997,
315,
13484,
267,
1613,
8,
774,
6295,
9298,
12,
291,
680,
7589,
607,
8,
288,
1395,
1024,
12,
3970,
12,
627,
589,
12,
1011,
958,
9,
267,
372,
3970,
339,
347,
2449,
3917,
607,
8,
277,
12,
3970,
12,
1395,
1024,
12,
627,
589,
12,
1011,
958,
304,
267,
327,
295,
4037,
370,
506,
2997,
315,
13484,
267,
1613,
8,
774,
6295,
9298,
12,
291,
680,
19670,
607,
8,
288,
1395,
1024,
12,
3970,
12,
627,
589,
12,
1011,
958,
9,
267,
372,
3970,
339,
347,
511,
63,
14443,
2540,
8,
277,
304,
267,
291,
14,
1065,
52,
1383,
342,
339,
347,
511,
63,
21573,
2377,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
12145,
14,
30977,
3858,
631,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
12145,
14,
30977,
3858,
631,
358,
267,
372,
366,
339,
347,
511,
63,
21573,
8599,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
30977,
3858,
631,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
30977,
3858,
631,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2377,
4667,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
372,
366,
339,
347,
511,
63,
21573,
8599,
3007,
2377,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
30977,
3858,
631,
14,
1700,
23263,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
30977,
3858,
631,
14,
1700,
23263,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
1692,
4667,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
372,
366,
339,
347,
511,
63,
4087,
2491,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
4087,
2491,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
4087,
2491,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
372,
366,
339,
347,
511,
63,
578,
607,
5725,
2491,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
4087,
2491,
14,
396,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
7369,
3170,
12523,
267,
291,
14,
7589,
607,
8,
68,
12,
298,
4087,
2491,
14,
396,
63,
578,
531,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
372,
366,
339,
347,
511,
63,
4087,
578,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
14,
396,
63,
4087,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2491,
14,
396,
63,
4087,
63,
578,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
372,
366,
339,
347,
511,
63,
2470,
328,
412,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
14,
396,
63,
646,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2491,
14,
396,
63,
646,
63,
578,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
372,
366,
339,
347,
511,
63,
25786,
6295,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
396,
63,
4087,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
396,
63,
646,
63,
578,
358,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
291,
14,
19670,
607,
8,
68,
12,
283,
13760,
358,
267,
372,
366,
339,
347,
511,
63,
25786,
6295,
9298,
8,
277,
304,
267,
366,
275,
291,
14,
1065,
52,
1383,
360,
2491,
18,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
6730,
3170,
10374,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
2491,
18,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
283,
396,
63,
578,
358,
267,
291,
14,
7589,
607,
8,
68,
12,
298,
1944,
859,
4310,
26226,
3903,
531,
267,
291,
14,
19670,
607,
8,
68,
12,
2650,
578,
5320,
267,
291,
14,
19670,
607,
8,
68,
12,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
barbarahui/nuxeo-calisphere
|
s3stash/nxstash_mediajson.py
|
1
|
4444
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import os
from s3stash.nxstashref import NuxeoStashRef
from deepharvest.deepharvest_nuxeo import DeepHarvestNuxeo
from deepharvest.mediajson import MediaJson
from dplaingestion.mappers.ucldc_nuxeo_mapper import UCLDCNuxeoMapper
import json
import s3stash.s3tools
FILENAME_FORMAT = "{}-media.json"
class NuxeoStashMediaJson(NuxeoStashRef):
''' create and stash media.json file for a nuxeo object '''
def __init__(self,
path,
bucket,
region,
pynuxrc='~/.pynuxrc',
replace=True,
**kwargs):
super(NuxeoStashMediaJson, self).__init__(path, bucket, region,
pynuxrc, replace, **kwargs)
self.dh = DeepHarvestNuxeo(
self.path, self.bucket, pynuxrc=self.pynuxrc)
self.mj = MediaJson()
self.filename = FILENAME_FORMAT.format(self.uid)
self.filepath = os.path.join(self.tmp_dir, self.filename)
self._update_report('filename', self.filename)
self._update_report('filepath', self.filepath)
def nxstashref(self):
return self.nxstash_mediajson()
def nxstash_mediajson(self):
''' create media.json file for object and stash on s3 '''
self._update_report('stashed', False)
# extract and transform metadata for parent obj and any components
parent_md = self._get_parent_metadata(self.metadata)
component_md = [
self._get_component_metadata(c)
for c in self.dh.fetch_components(self.metadata)
]
# create media.json file
media_json = self.mj.create_media_json(parent_md, component_md)
self._write_file(media_json, self.filepath)
# stash media.json file on s3
stashed, s3_report = s3stash.s3tools.s3stash(
self.filepath, self.bucket, self.filename, self.region,
'application/json', self.replace)
self._update_report('s3_stash', s3_report)
self._update_report('stashed', stashed)
self._remove_tmp()
return self.report
def _get_parent_metadata(self, obj):
''' assemble top-level (parent) object metadata '''
metadata = {}
metadata['label'] = obj['title']
# only provide id, href, format if Nuxeo Document has file attached
full_metadata = self.nx.get_metadata(uid=obj['uid'])
if self.dh.has_file(full_metadata):
metadata['id'] = obj['uid']
metadata['href'] = self.dh.get_object_download_url(full_metadata)
metadata['format'] = self.dh.get_calisphere_object_type(obj[
'type'])
if metadata['format'] == 'video':
metadata['dimensions'] = self.dh.get_video_dimensions(
full_metadata)
return metadata
def _get_component_metadata(self, obj):
''' assemble component object metadata '''
metadata = {}
full_metadata = self.nx.get_metadata(uid=obj['uid'])
metadata['label'] = obj['title']
metadata['id'] = obj['uid']
metadata['href'] = self.dh.get_object_download_url(full_metadata)
# extract additional ucldc metadata from 'properties' element
ucldc_md = self._get_ucldc_schema_properties(full_metadata)
for key, value in ucldc_md.iteritems():
metadata[key] = value
# map 'type'
metadata['format'] = self.dh.get_calisphere_object_type(obj['type'])
return metadata
def _get_ucldc_schema_properties(self, metadata):
''' get additional metadata as mapped by harvester '''
properties = {}
mapper = UCLDCNuxeoMapper(metadata)
mapper.map_original_record()
mapper.map_source_resource()
properties = mapper.mapped_data['sourceResource']
properties.update(mapper.mapped_data['originalRecord'])
return properties
def _write_file(self, content_dict, filepath):
""" convert dict to json and write to file """
content_json = json.dumps(
content_dict, indent=4, separators=(',', ': '), sort_keys=False)
with open(filepath, 'wb') as f:
f.write(content_json)
f.flush()
def main(argv=None):
pass
if __name__ == "__main__":
sys.exit(main())
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
984,
199,
646,
747,
199,
504,
308,
19,
27145,
14,
7343,
27145,
1121,
492,
653,
85,
1845,
79,
933,
1119,
2891,
199,
504,
27646,
838,
285,
13981,
14,
11192,
838,
285,
13981,
63,
4850,
1845,
79,
492,
577,
7840,
18248,
13981,
21988,
1845,
79,
199,
504,
27646,
838,
285,
13981,
14,
4603,
1001,
492,
12300,
9653,
199,
504,
366,
6104,
3199,
1636,
14,
24469,
14,
85,
429,
3833,
63,
4850,
1845,
79,
63,
7153,
492,
738,
1981,
5196,
21988,
1845,
79,
11880,
199,
646,
2022,
199,
646,
308,
19,
27145,
14,
83,
19,
2537,
199,
199,
15440,
63,
4807,
275,
11491,
13,
4603,
14,
1001,
2,
421,
199,
533,
653,
85,
1845,
79,
933,
1119,
11398,
9653,
8,
21988,
1845,
79,
933,
1119,
2891,
304,
272,
1449,
1218,
436,
410,
1119,
5898,
14,
1001,
570,
367,
282,
15699,
1845,
79,
909,
1449,
339,
347,
636,
826,
721,
277,
12,
326,
931,
12,
326,
5315,
12,
326,
4897,
12,
326,
1134,
78,
2521,
1195,
534,
94,
8083,
647,
78,
2521,
1195,
297,
326,
3350,
29,
549,
12,
326,
1011,
958,
304,
267,
1613,
8,
21988,
1845,
79,
933,
1119,
11398,
9653,
12,
291,
2843,
826,
721,
515,
12,
5315,
12,
4897,
12,
8179,
1134,
78,
2521,
1195,
12,
3350,
12,
1011,
958,
9,
398,
291,
14,
7821,
275,
577,
7840,
18248,
13981,
21988,
1845,
79,
8,
288,
291,
14,
515,
12,
291,
14,
4623,
12,
1134,
78,
2521,
1195,
29,
277,
14,
647,
78,
2521,
1195,
9,
267,
291,
14,
77,
74,
275,
12300,
9653,
342,
398,
291,
14,
1501,
275,
16444,
11536,
63,
4807,
14,
908,
8,
277,
14,
1535,
9,
267,
291,
14,
7218,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2791,
63,
694,
12,
291,
14,
1501,
9,
267,
291,
423,
873,
63,
3070,
360,
1501,
297,
291,
14,
1501,
9,
267,
291,
423,
873,
63,
3070,
360,
7218,
297,
291,
14,
7218,
9,
339,
347,
8484,
27145,
1121,
8,
277,
304,
267,
372,
291,
14,
7343,
27145,
63,
4603,
1001,
342,
339,
347,
8484,
27145,
63,
4603,
1001,
8,
277,
304,
267,
1449,
1218,
5898,
14,
1001,
570,
367,
909,
436,
410,
1119,
641,
308,
19,
1449,
267,
291,
423,
873,
63,
3070,
360,
270,
21189,
297,
756,
9,
398,
327,
5536,
436,
5793,
3341,
367,
1676,
1559,
436,
1263,
7323,
267,
1676,
63,
1064,
275,
291,
423,
362,
63,
1708,
63,
2343,
8,
277,
14,
2343,
9,
267,
3931,
63,
1064,
275,
359,
288,
291,
423,
362,
63,
3173,
63,
2343,
8,
67,
9,
288,
367,
286,
315,
291,
14,
7821,
14,
3535,
63,
4608,
8,
277,
14,
2343,
9,
267,
1622,
398,
327,
1218,
5898,
14,
1001,
570,
267,
5898,
63,
1001,
275,
291,
14,
77,
74,
14,
981,
63,
4603,
63,
1001,
8,
1708,
63,
1064,
12,
3931,
63,
1064,
9,
267,
291,
423,
952,
63,
493,
8,
4603,
63,
1001,
12,
291,
14,
7218,
9,
398,
327,
410,
1119,
5898,
14,
1001,
570,
641,
308,
19,
267,
410,
21189,
12,
308,
19,
63,
3070,
275,
308,
19,
27145,
14,
83,
19,
2537,
14,
83,
19,
27145,
8,
288,
291,
14,
7218,
12,
291,
14,
4623,
12,
291,
14,
1501,
12,
291,
14,
4551,
12,
288,
283,
3578,
15,
1001,
297,
291,
14,
1814,
9,
267,
291,
423,
873,
63,
3070,
360,
83,
19,
63,
27145,
297,
308,
19,
63,
3070,
9,
267,
291,
423,
873,
63,
3070,
360,
270,
21189,
297,
410,
21189,
9,
398,
291,
423,
2168,
63,
2791,
342,
398,
372,
291,
14,
3070,
339,
347,
485,
362,
63,
1708,
63,
2343,
8,
277,
12,
1559,
304,
267,
1449,
22931,
2746,
13,
1896,
334,
1708,
9,
909,
3341,
1449,
267,
3341,
275,
1052,
267,
3341,
459,
1302,
418,
275,
1559,
459,
1213,
418,
398,
327,
1454,
5647,
1305,
12,
4369,
12,
1475,
340,
653,
85,
1845,
79,
7543,
965,
570,
10102,
267,
2615,
63,
2343,
275,
291,
14,
7343,
14,
362,
63,
2343,
8,
1535,
29,
1113,
459,
1535,
1105,
398,
340,
291,
14,
7821,
14,
1989,
63,
493,
8,
2861,
63,
2343,
304,
288,
3341,
459,
344,
418,
275,
1559,
459,
1535,
418,
288,
3341,
459,
6399,
418,
275,
291,
14,
7821,
14,
362,
63,
785,
63,
4249,
63,
633,
8,
2861,
63,
2343,
9,
288,
3341,
459,
908,
418,
275,
291,
14,
7821,
14,
362,
63,
915,
27474,
1681,
63,
785,
63,
466,
8,
1113,
59,
355,
283,
466,
1105,
288,
340,
3341,
459,
908,
418,
508,
283,
3722,
356,
355,
3341,
459,
13320,
418,
275,
291,
14,
7821,
14,
362,
63,
3722,
63,
13320,
8,
490,
2615,
63,
2343,
9,
398,
372,
3341,
339,
347,
485,
362,
63,
3173,
63,
2343,
8,
277,
12,
1559,
304,
267,
1449,
22931,
3931,
909,
3341,
1449,
267,
3341,
275,
1052,
267,
2615,
63,
2343,
275,
291,
14,
7343,
14,
362,
63,
2343,
8,
1535,
29,
1113,
459,
1535,
1105,
267,
3341,
459,
1302,
418,
275,
1559,
459,
1213,
418,
267,
3341,
459,
344,
418,
275,
1559,
459,
1535,
418,
267,
3341,
459,
6399,
418,
275,
291,
14,
7821,
14,
362,
63,
785,
63,
4249,
63,
633,
8,
2861,
63,
2343,
9,
398,
327,
5536,
4722,
221,
399,
429,
3833,
3341,
687,
283,
3282,
7,
1819,
267,
399,
429,
3833,
63,
1064,
275,
291,
423,
362,
63,
85,
429,
3833,
63,
3629,
63,
3282,
8,
2861,
63,
2343,
9,
398,
367,
790,
12,
574,
315,
399,
429,
3833,
63,
1064,
14,
4611,
837,
288,
3341,
59,
498,
61,
275,
574,
398,
327,
2341,
283,
466,
7,
267,
3341,
459,
908,
418,
275,
291,
14,
7821,
14,
362,
63,
915,
27474,
1681,
63,
785,
63,
466,
8,
1113,
459,
466,
1105,
398,
372,
3341,
339,
347,
485,
362,
63,
85,
429,
3833,
63,
3629,
63,
3282,
8,
277,
12,
3341,
304,
267,
1449,
664,
4722,
3341,
465,
9994,
701,
12159,
26691,
1449,
267,
4382,
275,
1052,
398,
7796,
275,
738,
1981,
5196,
21988,
1845,
79,
11880,
8,
2343,
9,
267,
7796,
14,
1130,
63,
5043,
63,
3059
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
984,
199,
646,
747,
199,
504,
308,
19,
27145,
14,
7343,
27145,
1121,
492,
653,
85,
1845,
79,
933,
1119,
2891,
199,
504,
27646,
838,
285,
13981,
14,
11192,
838,
285,
13981,
63,
4850,
1845,
79,
492,
577,
7840,
18248,
13981,
21988,
1845,
79,
199,
504,
27646,
838,
285,
13981,
14,
4603,
1001,
492,
12300,
9653,
199,
504,
366,
6104,
3199,
1636,
14,
24469,
14,
85,
429,
3833,
63,
4850,
1845,
79,
63,
7153,
492,
738,
1981,
5196,
21988,
1845,
79,
11880,
199,
646,
2022,
199,
646,
308,
19,
27145,
14,
83,
19,
2537,
199,
199,
15440,
63,
4807,
275,
11491,
13,
4603,
14,
1001,
2,
421,
199,
533,
653,
85,
1845,
79,
933,
1119,
11398,
9653,
8,
21988,
1845,
79,
933,
1119,
2891,
304,
272,
1449,
1218,
436,
410,
1119,
5898,
14,
1001,
570,
367,
282,
15699,
1845,
79,
909,
1449,
339,
347,
636,
826,
721,
277,
12,
326,
931,
12,
326,
5315,
12,
326,
4897,
12,
326,
1134,
78,
2521,
1195,
534,
94,
8083,
647,
78,
2521,
1195,
297,
326,
3350,
29,
549,
12,
326,
1011,
958,
304,
267,
1613,
8,
21988,
1845,
79,
933,
1119,
11398,
9653,
12,
291,
2843,
826,
721,
515,
12,
5315,
12,
4897,
12,
8179,
1134,
78,
2521,
1195,
12,
3350,
12,
1011,
958,
9,
398,
291,
14,
7821,
275,
577,
7840,
18248,
13981,
21988,
1845,
79,
8,
288,
291,
14,
515,
12,
291,
14,
4623,
12,
1134,
78,
2521,
1195,
29,
277,
14,
647,
78,
2521,
1195,
9,
267,
291,
14,
77,
74,
275,
12300,
9653,
342,
398,
291,
14,
1501,
275,
16444,
11536,
63,
4807,
14,
908,
8,
277,
14,
1535,
9,
267,
291,
14,
7218,
275,
747,
14,
515,
14,
904,
8,
277,
14,
2791,
63,
694,
12,
291,
14,
1501,
9,
267,
291,
423,
873,
63,
3070,
360,
1501,
297,
291,
14,
1501,
9,
267,
291,
423,
873,
63,
3070,
360,
7218,
297,
291,
14,
7218,
9,
339,
347,
8484,
27145,
1121,
8,
277,
304,
267,
372,
291,
14,
7343,
27145,
63,
4603,
1001,
342,
339,
347,
8484,
27145,
63,
4603,
1001,
8,
277,
304,
267,
1449,
1218,
5898,
14,
1001,
570,
367,
909,
436,
410,
1119,
641,
308,
19,
1449,
267,
291,
423,
873,
63,
3070,
360,
270,
21189,
297,
756,
9,
398,
327,
5536,
436,
5793,
3341,
367,
1676,
1559,
436,
1263,
7323,
267,
1676,
63,
1064,
275,
291,
423,
362,
63,
1708,
63,
2343,
8,
277,
14,
2343,
9,
267,
3931,
63,
1064,
275,
359,
288,
291,
423,
362,
63,
3173,
63,
2343,
8,
67,
9,
288,
367,
286,
315,
291,
14,
7821,
14,
3535,
63,
4608,
8,
277,
14,
2343,
9,
267,
1622,
398,
327,
1218,
5898,
14,
1001,
570,
267,
5898,
63,
1001,
275,
291,
14,
77,
74,
14,
981,
63,
4603,
63,
1001,
8,
1708,
63,
1064,
12,
3931,
63,
1064,
9,
267,
291,
423,
952,
63,
493,
8,
4603,
63,
1001,
12,
291,
14,
7218,
9,
398,
327,
410,
1119,
5898,
14,
1001,
570,
641,
308,
19,
267,
410,
21189,
12,
308,
19,
63,
3070,
275,
308,
19,
27145,
14,
83,
19,
2537,
14,
83,
19,
27145,
8,
288,
291,
14,
7218,
12,
291,
14,
4623,
12,
291,
14,
1501,
12,
291,
14,
4551,
12,
288,
283,
3578,
15,
1001,
297,
291,
14,
1814,
9,
267,
291,
423,
873,
63,
3070,
360,
83,
19,
63,
27145,
297,
308,
19,
63,
3070,
9,
267,
291,
423,
873,
63,
3070,
360,
270,
21189,
297,
410,
21189,
9,
398,
291,
423,
2168,
63,
2791,
342,
398,
372,
291,
14,
3070,
339,
347,
485,
362,
63,
1708,
63,
2343,
8,
277,
12,
1559,
304,
267,
1449,
22931,
2746,
13,
1896,
334,
1708,
9,
909,
3341,
1449,
267,
3341,
275,
1052,
267,
3341,
459,
1302,
418,
275,
1559,
459,
1213,
418,
398,
327,
1454,
5647,
1305,
12,
4369,
12,
1475,
340,
653,
85,
1845,
79,
7543,
965,
570,
10102,
267,
2615,
63,
2343,
275,
291,
14,
7343,
14,
362,
63,
2343,
8,
1535,
29,
1113,
459,
1535,
1105,
398,
340,
291,
14,
7821,
14,
1989,
63,
493,
8,
2861,
63,
2343,
304,
288,
3341,
459,
344,
418,
275,
1559,
459,
1535,
418,
288,
3341,
459,
6399,
418,
275,
291,
14,
7821,
14,
362,
63,
785,
63,
4249,
63,
633,
8,
2861,
63,
2343,
9,
288,
3341,
459,
908,
418,
275,
291,
14,
7821,
14,
362,
63,
915,
27474,
1681,
63,
785,
63,
466,
8,
1113,
59,
355,
283,
466,
1105,
288,
340,
3341,
459,
908,
418,
508,
283,
3722,
356,
355,
3341,
459,
13320,
418,
275,
291,
14,
7821,
14,
362,
63,
3722,
63,
13320,
8,
490,
2615,
63,
2343,
9,
398,
372,
3341,
339,
347,
485,
362,
63,
3173,
63,
2343,
8,
277,
12,
1559,
304,
267,
1449,
22931,
3931,
909,
3341,
1449,
267,
3341,
275,
1052,
267,
2615,
63,
2343,
275,
291,
14,
7343,
14,
362,
63,
2343,
8,
1535,
29,
1113,
459,
1535,
1105,
267,
3341,
459,
1302,
418,
275,
1559,
459,
1213,
418,
267,
3341,
459,
344,
418,
275,
1559,
459,
1535,
418,
267,
3341,
459,
6399,
418,
275,
291,
14,
7821,
14,
362,
63,
785,
63,
4249,
63,
633,
8,
2861,
63,
2343,
9,
398,
327,
5536,
4722,
221,
399,
429,
3833,
3341,
687,
283,
3282,
7,
1819,
267,
399,
429,
3833,
63,
1064,
275,
291,
423,
362,
63,
85,
429,
3833,
63,
3629,
63,
3282,
8,
2861,
63,
2343,
9,
398,
367,
790,
12,
574,
315,
399,
429,
3833,
63,
1064,
14,
4611,
837,
288,
3341,
59,
498,
61,
275,
574,
398,
327,
2341,
283,
466,
7,
267,
3341,
459,
908,
418,
275,
291,
14,
7821,
14,
362,
63,
915,
27474,
1681,
63,
785,
63,
466,
8,
1113,
459,
466,
1105,
398,
372,
3341,
339,
347,
485,
362,
63,
85,
429,
3833,
63,
3629,
63,
3282,
8,
277,
12,
3341,
304,
267,
1449,
664,
4722,
3341,
465,
9994,
701,
12159,
26691,
1449,
267,
4382,
275,
1052,
398,
7796,
275,
738,
1981,
5196,
21988,
1845,
79,
11880,
8,
2343,
9,
267,
7796,
14,
1130,
63,
5043,
63,
3059,
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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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
] |
jhseu/tensorflow
|
tensorflow/python/keras/callbacks_v1.py
|
9
|
19005
|
# Copyright 2015 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.
# ==============================================================================
# pylint: disable=g-import-not-at-top
"""Callbacks: utilities called at certain points during model training.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import numpy as np
from tensorflow.python.eager import context
from tensorflow.python.eager import profiler
from tensorflow.python.framework import dtypes
from tensorflow.python.keras import backend as K
from tensorflow.python.keras import callbacks
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import state_ops
from tensorflow.python.ops import summary_ops_v2
from tensorflow.python.ops import variables
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.summary import summary as tf_summary
from tensorflow.python.training import saver
from tensorflow.python.util.tf_export import keras_export
@keras_export(v1=['keras.callbacks.TensorBoard'])
class TensorBoard(callbacks.Callback):
# pylint: disable=line-too-long
"""Enable visualizations for TensorBoard.
TensorBoard is a visualization tool provided with TensorFlow.
This callback logs events for TensorBoard, including:
* Metrics summary plots
* Training graph visualization
* Activation histograms
* Sampled profiling
If you have installed TensorFlow with pip, you should be able
to launch TensorBoard from the command line:
```sh
tensorboard --logdir=path_to_your_logs
```
You can find more information about TensorBoard
[here](https://www.tensorflow.org/get_started/summaries_and_tensorboard).
Arguments:
log_dir: the path of the directory where to save the log files to be
parsed by TensorBoard.
histogram_freq: frequency (in epochs) at which to compute activation and
weight histograms for the layers of the model. If set to 0, histograms
won't be computed. Validation data (or split) must be specified for
histogram visualizations.
write_graph: whether to visualize the graph in TensorBoard. The log file
can become quite large when write_graph is set to True.
write_grads: whether to visualize gradient histograms in TensorBoard.
`histogram_freq` must be greater than 0.
batch_size: size of batch of inputs to feed to the network for histograms
computation.
write_images: whether to write model weights to visualize as image in
TensorBoard.
embeddings_freq: frequency (in epochs) at which selected embedding layers
will be saved. If set to 0, embeddings won't be computed. Data to be
visualized in TensorBoard's Embedding tab must be passed as
`embeddings_data`.
embeddings_layer_names: a list of names of layers to keep eye on. If None
or empty list all the embedding layer will be watched.
embeddings_metadata: a dictionary which maps layer name to a file name in
which metadata for this embedding layer is saved. See the
[details](https://www.tensorflow.org/how_tos/embedding_viz/#metadata_optional)
about metadata files format. In case if the same metadata file is
used for all embedding layers, string can be passed.
embeddings_data: data to be embedded at layers specified in
`embeddings_layer_names`. Numpy array (if the model has a single input)
or list of Numpy arrays (if the model has multiple inputs). Learn [more
about
embeddings](https://www.tensorflow.org/programmers_guide/embedding)
update_freq: `'batch'` or `'epoch'` or integer. When using `'batch'`,
writes the losses and metrics to TensorBoard after each batch. The same
applies for `'epoch'`. If using an integer, let's say `1000`, the
callback will write the metrics and losses to TensorBoard every 1000
samples. Note that writing too frequently to TensorBoard can slow down
your training.
profile_batch: Profile the batch to sample compute characteristics. By
default, it will profile the second batch. Set profile_batch=0 to
disable profiling.
Raises:
ValueError: If histogram_freq is set and no validation data is provided.
@compatibility(eager)
Using the `TensorBoard` callback will work when eager execution is enabled,
with the restriction that outputting histogram summaries of weights and
gradients is not supported. Consequently, `histogram_freq` will be ignored.
@end_compatibility
"""
# pylint: enable=line-too-long
def __init__(self,
log_dir='./logs',
histogram_freq=0,
batch_size=32,
write_graph=True,
write_grads=False,
write_images=False,
embeddings_freq=0,
embeddings_layer_names=None,
embeddings_metadata=None,
embeddings_data=None,
update_freq='epoch',
profile_batch=2):
super(TensorBoard, self).__init__()
self.log_dir = log_dir
self.histogram_freq = histogram_freq
if self.histogram_freq and context.executing_eagerly():
logging.warning(
UserWarning('Weight and gradient histograms not supported for eager'
'execution, setting `histogram_freq` to `0`.'))
self.histogram_freq = 0
self.merged = None
self.write_graph = write_graph
self.write_grads = write_grads
self.write_images = write_images
self.batch_size = batch_size
self._current_batch = 0
self._total_batches_seen = 0
self._total_val_batches_seen = 0
self.embeddings_freq = embeddings_freq
self.embeddings_layer_names = embeddings_layer_names
self.embeddings_metadata = embeddings_metadata
self.embeddings_data = embeddings_data
if update_freq == 'batch':
self.update_freq = 1
else:
self.update_freq = update_freq
self._samples_seen = 0
self._samples_seen_at_last_write = 0
# TODO(fishx): Add a link to the full profiler tutorial.
self._profile_batch = profile_batch
# One profiler session is running if it is True.
self._is_profiling = False
# TensorBoard should only write summaries on the chief when in a
# Multi-Worker setting.
self._chief_worker_only = True
def _init_writer(self, model):
"""Sets file writer."""
if context.executing_eagerly():
self.writer = summary_ops_v2.create_file_writer(self.log_dir)
if not model.run_eagerly and self.write_graph:
with self.writer.as_default():
summary_ops_v2.graph(K.get_graph(), step=0)
elif self.write_graph:
self.writer = tf_summary.FileWriter(self.log_dir, K.get_graph())
else:
self.writer = tf_summary.FileWriter(self.log_dir)
def _make_histogram_ops(self, model):
"""Defines histogram ops when histogram_freq > 0."""
# only make histogram summary op if it hasn't already been made
if self.histogram_freq and self.merged is None:
for layer in self.model.layers:
for weight in layer.weights:
mapped_weight_name = weight.name.replace(':', '_')
tf_summary.histogram(mapped_weight_name, weight)
if self.write_images:
w_img = array_ops.squeeze(weight)
shape = K.int_shape(w_img)
if len(shape) == 2: # dense layer kernel case
if shape[0] > shape[1]:
w_img = array_ops.transpose(w_img)
shape = K.int_shape(w_img)
w_img = array_ops.reshape(w_img, [1, shape[0], shape[1], 1])
elif len(shape) == 3: # convnet case
if K.image_data_format() == 'channels_last':
# switch to channels_first to display
# every kernel as a separate image
w_img = array_ops.transpose(w_img, perm=[2, 0, 1])
shape = K.int_shape(w_img)
w_img = array_ops.reshape(w_img,
[shape[0], shape[1], shape[2], 1])
elif len(shape) == 1: # bias case
w_img = array_ops.reshape(w_img, [1, shape[0], 1, 1])
else:
# not possible to handle 3D convnets etc.
continue
shape = K.int_shape(w_img)
assert len(shape) == 4 and shape[-1] in [1, 3, 4]
tf_summary.image(mapped_weight_name, w_img)
if self.write_grads:
for weight in layer.trainable_weights:
mapped_weight_name = weight.name.replace(':', '_')
grads = model.optimizer.get_gradients(model.total_loss, weight)
def is_indexed_slices(grad):
return type(grad).__name__ == 'IndexedSlices'
grads = [
grad.values if is_indexed_slices(grad) else grad
for grad in grads
]
tf_summary.histogram('{}_grad'.format(mapped_weight_name), grads)
if hasattr(layer, 'output'):
if isinstance(layer.output, list):
for i, output in enumerate(layer.output):
tf_summary.histogram('{}_out_{}'.format(layer.name, i), output)
else:
tf_summary.histogram('{}_out'.format(layer.name), layer.output)
def set_model(self, model):
"""Sets Keras model and creates summary ops."""
self.model = model
self._init_writer(model)
# histogram summaries only enabled in graph mode
if not context.executing_eagerly():
self._make_histogram_ops(model)
self.merged = tf_summary.merge_all()
# If both embedding_freq and embeddings_data are available, we will
# visualize embeddings.
if self.embeddings_freq and self.embeddings_data is not None:
# Avoid circular dependency.
from tensorflow.python.keras.engine import training_utils # pylint: disable=g-import-not-at-top
self.embeddings_data = training_utils.standardize_input_data(
self.embeddings_data, model.input_names)
# If embedding_layer_names are not provided, get all of the embedding
# layers from the model.
embeddings_layer_names = self.embeddings_layer_names
if not embeddings_layer_names:
embeddings_layer_names = [
layer.name
for layer in self.model.layers
if type(layer).__name__ == 'Embedding'
]
self.assign_embeddings = []
embeddings_vars = {}
self.batch_id = batch_id = array_ops.placeholder(dtypes.int32)
self.step = step = array_ops.placeholder(dtypes.int32)
for layer in self.model.layers:
if layer.name in embeddings_layer_names:
embedding_input = self.model.get_layer(layer.name).output
embedding_size = np.prod(embedding_input.shape[1:])
embedding_input = array_ops.reshape(embedding_input,
(step, int(embedding_size)))
shape = (self.embeddings_data[0].shape[0], int(embedding_size))
embedding = variables.Variable(
array_ops.zeros(shape), name=layer.name + '_embedding')
embeddings_vars[layer.name] = embedding
batch = state_ops.assign(embedding[batch_id:batch_id + step],
embedding_input)
self.assign_embeddings.append(batch)
self.saver = saver.Saver(list(embeddings_vars.values()))
# Create embeddings_metadata dictionary
if isinstance(self.embeddings_metadata, str):
embeddings_metadata = {
layer_name: self.embeddings_metadata
for layer_name in embeddings_vars.keys()
}
else:
# If embedding_metadata is already a dictionary
embeddings_metadata = self.embeddings_metadata
try:
from tensorboard.plugins import projector
except ImportError:
raise ImportError('Failed to import TensorBoard. Please make sure that '
'TensorBoard integration is complete."')
# TODO(psv): Add integration tests to test embedding visualization
# with TensorBoard callback. We are unable to write a unit test for this
# because TensorBoard dependency assumes TensorFlow package is installed.
config = projector.ProjectorConfig()
for layer_name, tensor in embeddings_vars.items():
embedding = config.embeddings.add()
embedding.tensor_name = tensor.name
if (embeddings_metadata is not None and
layer_name in embeddings_metadata):
embedding.metadata_path = embeddings_metadata[layer_name]
projector.visualize_embeddings(self.writer, config)
def _fetch_callback(self, summary):
self.writer.add_summary(summary, self._total_val_batches_seen)
self._total_val_batches_seen += 1
def _write_custom_summaries(self, step, logs=None):
"""Writes metrics out as custom scalar summaries.
Arguments:
step: the global step to use for TensorBoard.
logs: dict. Keys are scalar summary names, values are
NumPy scalars.
"""
logs = logs or {}
if context.executing_eagerly():
# use v2 summary ops
with self.writer.as_default(), summary_ops_v2.always_record_summaries():
for name, value in logs.items():
if isinstance(value, np.ndarray):
value = value.item()
summary_ops_v2.scalar(name, value, step=step)
else:
# use FileWriter from v1 summary
for name, value in logs.items():
if isinstance(value, np.ndarray):
value = value.item()
summary = tf_summary.Summary()
summary_value = summary.value.add()
summary_value.simple_value = value
summary_value.tag = name
self.writer.add_summary(summary, step)
self.writer.flush()
def on_batch_end(self, batch, logs=None):
"""Writes scalar summaries for metrics on every training batch.
Performs profiling if current batch is in profiler_batches.
"""
# Don't output batch_size and batch number as TensorBoard summaries
logs = logs or {}
self._samples_seen += logs.get('size', 1)
samples_seen_since = self._samples_seen - self._samples_seen_at_last_write
if self.update_freq != 'epoch' and samples_seen_since >= self.update_freq:
batch_logs = {('batch_' + k): v
for k, v in logs.items()
if k not in ['batch', 'size', 'num_steps']}
self._write_custom_summaries(self._total_batches_seen, batch_logs)
self._samples_seen_at_last_write = self._samples_seen
self._total_batches_seen += 1
if self._is_profiling:
profiler.save(self.log_dir, profiler.stop())
self._is_profiling = False
elif (not self._is_profiling and
self._total_batches_seen == self._profile_batch - 1):
profiler.start()
self._is_profiling = True
def on_train_begin(self, logs=None):
if self._profile_batch == 1:
profiler.start()
self._is_profiling = True
def on_epoch_begin(self, epoch, logs=None):
"""Add histogram op to Model eval_function callbacks, reset batch count."""
# check if histogram summary should be run for this epoch
if self.histogram_freq and epoch % self.histogram_freq == 0:
self._epoch = epoch
# pylint: disable=protected-access
# add the histogram summary op if it should run this epoch
self.model._make_test_function()
if self.merged not in self.model.test_function.fetches:
self.model.test_function.fetches.append(self.merged)
self.model.test_function.fetch_callbacks[
self.merged] = self._fetch_callback
# pylint: enable=protected-access
def on_epoch_end(self, epoch, logs=None):
"""Checks if summary ops should run next epoch, logs scalar summaries."""
# don't output batch_size and
# batch number as TensorBoard summaries
logs = {('epoch_' + k): v
for k, v in logs.items()
if k not in ['batch', 'size', 'num_steps']}
if self.update_freq == 'epoch':
step = epoch
else:
step = self._samples_seen
self._write_custom_summaries(step, logs)
# pop the histogram summary op after each epoch
if self.histogram_freq:
# pylint: disable=protected-access
if self.merged in self.model.test_function.fetches:
self.model.test_function.fetches.remove(self.merged)
if self.merged in self.model.test_function.fetch_callbacks:
self.model.test_function.fetch_callbacks.pop(self.merged)
# pylint: enable=protected-access
if self.embeddings_data is None and self.embeddings_freq:
raise ValueError('To visualize embeddings, embeddings_data must '
'be provided.')
if self.embeddings_freq and self.embeddings_data is not None:
if epoch % self.embeddings_freq == 0:
# We need a second forward-pass here because we're passing
# the `embeddings_data` explicitly. This design allows to pass
# arbitrary data as `embeddings_data` and results from the fact
# that we need to know the size of the `tf.Variable`s which
# hold the embeddings in `set_model`. At this point, however,
# the `validation_data` is not yet set.
embeddings_data = self.embeddings_data
n_samples = embeddings_data[0].shape[0]
i = 0
sess = K.get_session()
while i < n_samples:
step = min(self.batch_size, n_samples - i)
batch = slice(i, i + step)
if isinstance(self.model.input, list):
feed_dict = {
model_input: embeddings_data[idx][batch]
for idx, model_input in enumerate(self.model.input)
}
else:
feed_dict = {self.model.input: embeddings_data[0][batch]}
feed_dict.update({self.batch_id: i, self.step: step})
if not isinstance(K.learning_phase(), int):
feed_dict[K.learning_phase()] = False
sess.run(self.assign_embeddings, feed_dict=feed_dict)
self.saver.save(sess,
os.path.join(self.log_dir, 'keras_embedding.ckpt'),
epoch)
i += self.batch_size
def on_train_end(self, logs=None):
if self._is_profiling:
profiler.save(self.log_dir, profiler.stop())
self._is_profiling = False
self.writer.close()
|
apache-2.0
|
[
3,
1898,
6900,
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,
4287,
26,
3507,
29,
71,
13,
646,
13,
1397,
13,
292,
13,
2119,
199,
624,
17958,
26,
15841,
2797,
737,
9842,
4501,
5309,
1402,
6093,
14,
199,
624,
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,
646,
747,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
10283,
492,
1067,
199,
504,
3228,
14,
1548,
14,
10283,
492,
23173,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
8811,
492,
4865,
465,
1804,
199,
504,
3228,
14,
1548,
14,
8811,
492,
13484,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1174,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6212,
63,
1483,
63,
86,
18,
199,
504,
3228,
14,
1548,
14,
1483,
492,
2860,
199,
504,
3228,
14,
1548,
14,
3246,
492,
2833,
63,
4806,
465,
2050,
199,
504,
3228,
14,
1548,
14,
4705,
492,
6212,
465,
2833,
63,
4705,
199,
504,
3228,
14,
1548,
14,
7588,
492,
17559,
199,
504,
3228,
14,
1548,
14,
1974,
14,
3249,
63,
3790,
492,
11708,
63,
3790,
421,
199,
32,
8811,
63,
3790,
8,
86,
17,
2968,
8811,
14,
11948,
14,
3861,
18995,
1105,
199,
533,
5878,
18995,
8,
11948,
14,
2806,
304,
523,
327,
4287,
26,
3507,
29,
604,
13,
7354,
13,
2809,
523,
408,
6476,
13104,
12270,
367,
5878,
18995,
14,
819,
5878,
18995,
365,
282,
13104,
2072,
4744,
2741,
543,
9134,
14,
819,
961,
3233,
9610,
4474,
367,
5878,
18995,
12,
5893,
26,
523,
627,
10072,
11818,
6212,
19695,
523,
627,
22859,
3343,
13104,
2072,
523,
627,
29441,
394,
22137,
523,
627,
15227,
68,
30238,
819,
982,
1265,
1172,
4903,
9134,
543,
7305,
12,
1265,
1077,
506,
7688,
523,
370,
10623,
5878,
18995,
687,
314,
1414,
1004,
26,
819,
10841,
609,
523,
2345,
3576,
1553,
22222,
29,
515,
63,
475,
63,
12695,
63,
7270,
523,
10841,
819,
2047,
883,
2342,
1655,
2556,
3595,
5878,
18995,
523,
359,
1681,
8738,
2859,
921,
1544,
14,
16008,
14,
1308,
15,
362,
63,
8924,
15,
19883,
63,
460,
63,
3128,
3576,
680,
819,
7628,
26,
489,
943,
63,
694,
26,
314,
931,
402,
314,
2082,
2382,
370,
3354,
314,
943,
1584,
370,
506,
267,
4565,
701,
5878,
18995,
14,
489,
15379,
63,
5646,
26,
9857,
334,
262,
18463,
9,
737,
1314,
370,
4526,
10361,
436,
267,
5401,
394,
22137,
367,
314,
9393,
402,
314,
1402,
14,
982,
663,
370,
378,
12,
394,
22137,
267,
7859,
1133,
506,
9235,
14,
19381,
666,
334,
269,
3715,
9,
1471,
506,
2013,
367,
267,
15379,
13104,
12270,
14,
489,
2218,
63,
2180,
26,
3775,
370,
13104,
794,
314,
3343,
315,
5878,
18995,
14,
710,
943,
570,
267,
883,
8649,
18794,
7031,
1380,
2218,
63,
2180,
365,
663,
370,
715,
14,
489,
2218,
63,
16525,
26,
3775,
370,
13104,
794,
6709,
394,
22137,
315,
5878,
18995,
14,
267,
658,
14805,
63,
5646,
64,
1471,
506,
8932,
2419,
378,
14,
489,
3522,
63,
890,
26,
1568,
402,
3522,
402,
4153,
370,
4733,
370,
314,
2784,
367,
394,
22137,
267,
14009,
14,
489,
2218,
63,
4782,
26,
3775,
370,
2218,
1402,
4931,
370,
13104,
794,
465,
1834,
315,
267,
5878,
18995,
14,
489,
6441,
21270,
63,
5646,
26,
9857,
334,
262,
18463,
9,
737,
1314,
4895,
12452,
9393,
267,
911,
506,
6290,
14,
982,
663,
370,
378,
12,
6441,
21270,
7859,
1133,
506,
9235,
14,
3918,
370,
506,
267,
13104,
1759,
315,
5878,
18995,
1159,
24297,
1098,
5174,
1471,
506,
3032,
465,
267,
658,
32719,
63,
576,
2313,
489,
6441,
21270,
63,
1897,
63,
1247,
26,
282,
769,
402,
1561,
402,
9393,
370,
4215,
25892,
641,
14,
982,
488,
267,
503,
2701,
769,
1006,
314,
12452,
4045,
911,
506,
9626,
379,
14,
489,
6441,
21270,
63,
2343,
26,
282,
2600,
1314,
9033,
4045,
536,
370,
282,
570,
536,
315,
267,
1314,
3341,
367,
642,
12452,
4045,
365,
6290,
14,
1666,
314,
881,
359,
5087,
8738,
2859,
921,
1544,
14,
16008,
14,
1308,
15,
1917,
63,
14543,
15,
14275,
63,
17249,
12645,
2343,
63,
4144,
9,
288,
3595,
3341,
1584,
1475,
14,
1010,
1930,
340,
314,
2011,
3341,
570,
365,
288,
1202,
367,
1006,
12452,
9393,
12,
1059,
883,
506,
3032,
14,
489,
6441,
21270,
63,
576,
26,
666,
370,
506,
12169,
737,
9393,
2013,
315,
267,
658,
32719,
63,
1897,
63,
1247,
2313,
20535,
1625,
334,
692,
314,
1402,
965,
282,
2849,
1324,
9,
267,
503,
769,
402,
20535,
6572,
334,
692,
314,
1402,
965,
3663,
4153,
680,
7005,
1060,
359,
6878,
267,
3595,
288,
6441,
21270,
8738,
2859,
921,
1544,
14,
16008,
14,
1308,
15,
6815,
16465,
63,
17348,
15,
14275,
9,
489,
1678,
63,
5646,
26,
658,
7,
2912,
7,
64,
503,
658,
7,
7367,
7,
64,
503,
3000,
14,
3979,
1808,
658,
7,
2912,
7,
3559,
267,
14511,
314,
21289,
436,
7186,
370,
5878,
18995,
2410,
1924,
3522,
14,
710,
2011,
267,
12966,
367,
658,
7,
7367,
7,
2313,
982,
1808,
376,
3000,
12,
4691,
1159,
14722,
658,
5279,
3559,
314,
267,
3233,
911,
2218,
314,
7186,
436,
21289,
370,
5878,
18995,
4036,
5198,
267,
5845,
14,
3390,
626,
3575,
4634,
28914,
590
] |
[
1898,
6900,
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,
4287,
26,
3507,
29,
71,
13,
646,
13,
1397,
13,
292,
13,
2119,
199,
624,
17958,
26,
15841,
2797,
737,
9842,
4501,
5309,
1402,
6093,
14,
199,
624,
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,
646,
747,
199,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
1548,
14,
10283,
492,
1067,
199,
504,
3228,
14,
1548,
14,
10283,
492,
23173,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
8811,
492,
4865,
465,
1804,
199,
504,
3228,
14,
1548,
14,
8811,
492,
13484,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1174,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6212,
63,
1483,
63,
86,
18,
199,
504,
3228,
14,
1548,
14,
1483,
492,
2860,
199,
504,
3228,
14,
1548,
14,
3246,
492,
2833,
63,
4806,
465,
2050,
199,
504,
3228,
14,
1548,
14,
4705,
492,
6212,
465,
2833,
63,
4705,
199,
504,
3228,
14,
1548,
14,
7588,
492,
17559,
199,
504,
3228,
14,
1548,
14,
1974,
14,
3249,
63,
3790,
492,
11708,
63,
3790,
421,
199,
32,
8811,
63,
3790,
8,
86,
17,
2968,
8811,
14,
11948,
14,
3861,
18995,
1105,
199,
533,
5878,
18995,
8,
11948,
14,
2806,
304,
523,
327,
4287,
26,
3507,
29,
604,
13,
7354,
13,
2809,
523,
408,
6476,
13104,
12270,
367,
5878,
18995,
14,
819,
5878,
18995,
365,
282,
13104,
2072,
4744,
2741,
543,
9134,
14,
819,
961,
3233,
9610,
4474,
367,
5878,
18995,
12,
5893,
26,
523,
627,
10072,
11818,
6212,
19695,
523,
627,
22859,
3343,
13104,
2072,
523,
627,
29441,
394,
22137,
523,
627,
15227,
68,
30238,
819,
982,
1265,
1172,
4903,
9134,
543,
7305,
12,
1265,
1077,
506,
7688,
523,
370,
10623,
5878,
18995,
687,
314,
1414,
1004,
26,
819,
10841,
609,
523,
2345,
3576,
1553,
22222,
29,
515,
63,
475,
63,
12695,
63,
7270,
523,
10841,
819,
2047,
883,
2342,
1655,
2556,
3595,
5878,
18995,
523,
359,
1681,
8738,
2859,
921,
1544,
14,
16008,
14,
1308,
15,
362,
63,
8924,
15,
19883,
63,
460,
63,
3128,
3576,
680,
819,
7628,
26,
489,
943,
63,
694,
26,
314,
931,
402,
314,
2082,
2382,
370,
3354,
314,
943,
1584,
370,
506,
267,
4565,
701,
5878,
18995,
14,
489,
15379,
63,
5646,
26,
9857,
334,
262,
18463,
9,
737,
1314,
370,
4526,
10361,
436,
267,
5401,
394,
22137,
367,
314,
9393,
402,
314,
1402,
14,
982,
663,
370,
378,
12,
394,
22137,
267,
7859,
1133,
506,
9235,
14,
19381,
666,
334,
269,
3715,
9,
1471,
506,
2013,
367,
267,
15379,
13104,
12270,
14,
489,
2218,
63,
2180,
26,
3775,
370,
13104,
794,
314,
3343,
315,
5878,
18995,
14,
710,
943,
570,
267,
883,
8649,
18794,
7031,
1380,
2218,
63,
2180,
365,
663,
370,
715,
14,
489,
2218,
63,
16525,
26,
3775,
370,
13104,
794,
6709,
394,
22137,
315,
5878,
18995,
14,
267,
658,
14805,
63,
5646,
64,
1471,
506,
8932,
2419,
378,
14,
489,
3522,
63,
890,
26,
1568,
402,
3522,
402,
4153,
370,
4733,
370,
314,
2784,
367,
394,
22137,
267,
14009,
14,
489,
2218,
63,
4782,
26,
3775,
370,
2218,
1402,
4931,
370,
13104,
794,
465,
1834,
315,
267,
5878,
18995,
14,
489,
6441,
21270,
63,
5646,
26,
9857,
334,
262,
18463,
9,
737,
1314,
4895,
12452,
9393,
267,
911,
506,
6290,
14,
982,
663,
370,
378,
12,
6441,
21270,
7859,
1133,
506,
9235,
14,
3918,
370,
506,
267,
13104,
1759,
315,
5878,
18995,
1159,
24297,
1098,
5174,
1471,
506,
3032,
465,
267,
658,
32719,
63,
576,
2313,
489,
6441,
21270,
63,
1897,
63,
1247,
26,
282,
769,
402,
1561,
402,
9393,
370,
4215,
25892,
641,
14,
982,
488,
267,
503,
2701,
769,
1006,
314,
12452,
4045,
911,
506,
9626,
379,
14,
489,
6441,
21270,
63,
2343,
26,
282,
2600,
1314,
9033,
4045,
536,
370,
282,
570,
536,
315,
267,
1314,
3341,
367,
642,
12452,
4045,
365,
6290,
14,
1666,
314,
881,
359,
5087,
8738,
2859,
921,
1544,
14,
16008,
14,
1308,
15,
1917,
63,
14543,
15,
14275,
63,
17249,
12645,
2343,
63,
4144,
9,
288,
3595,
3341,
1584,
1475,
14,
1010,
1930,
340,
314,
2011,
3341,
570,
365,
288,
1202,
367,
1006,
12452,
9393,
12,
1059,
883,
506,
3032,
14,
489,
6441,
21270,
63,
576,
26,
666,
370,
506,
12169,
737,
9393,
2013,
315,
267,
658,
32719,
63,
1897,
63,
1247,
2313,
20535,
1625,
334,
692,
314,
1402,
965,
282,
2849,
1324,
9,
267,
503,
769,
402,
20535,
6572,
334,
692,
314,
1402,
965,
3663,
4153,
680,
7005,
1060,
359,
6878,
267,
3595,
288,
6441,
21270,
8738,
2859,
921,
1544,
14,
16008,
14,
1308,
15,
6815,
16465,
63,
17348,
15,
14275,
9,
489,
1678,
63,
5646,
26,
658,
7,
2912,
7,
64,
503,
658,
7,
7367,
7,
64,
503,
3000,
14,
3979,
1808,
658,
7,
2912,
7,
3559,
267,
14511,
314,
21289,
436,
7186,
370,
5878,
18995,
2410,
1924,
3522,
14,
710,
2011,
267,
12966,
367,
658,
7,
7367,
7,
2313,
982,
1808,
376,
3000,
12,
4691,
1159,
14722,
658,
5279,
3559,
314,
267,
3233,
911,
2218,
314,
7186,
436,
21289,
370,
5878,
18995,
4036,
5198,
267,
5845,
14,
3390,
626,
3575,
4634,
28914,
590,
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,
1
] |
huonw/servo
|
tests/wpt/update/updatecommandline.py
|
210
|
1736
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
def create_parser():
from wptrunner import wptcommandline
parser = wptcommandline.create_parser_update()
parser.add_argument("--upstream", dest="upstream", action="store_true", default=None,
help="Push local changes to upstream repository even when not syncing")
parser.add_argument("--no-upstream", dest="upstream", action="store_false", default=None,
help="Dont't push local changes to upstream repository when syncing")
parser.add_argument("--token-file", action="store", type=wptcommandline.abs_path,
help="Path to file containing github token")
parser.add_argument("--token", action="store", help="GitHub token to use")
return parser
def check_args(kwargs):
from wptrunner import wptcommandline
wptcommandline.set_from_config(kwargs)
kwargs["upstream"] = kwargs["upstream"] if kwargs["upstream"] is not None else kwargs["sync"]
if kwargs["upstream"]:
if kwargs["rev"]:
raise ValueError("Setting --rev with --upstream isn't supported")
if kwargs["token"] is None:
if kwargs["token_file"] is None:
raise ValueError("Must supply either a token file or a token")
with open(kwargs["token_file"]) as f:
token = f.read().strip()
kwargs["token"] = token
del kwargs["token_file"]
return kwargs
def parse_args():
parser = create_parser()
kwargs = vars(parser.parse_args())
return check_args(kwargs)
|
mpl-2.0
|
[
3,
961,
5800,
5495,
8204,
365,
5420,
370,
314,
2895,
402,
314,
17728,
1684,
199,
3,
844,
12,
373,
14,
499,
14,
16,
14,
982,
282,
1331,
402,
314,
28481,
1990,
440,
1854,
543,
642,
199,
3,
570,
12,
2047,
883,
3332,
1373,
737,
1455,
921,
12102,
14,
1308,
15,
3950,
15,
18,
14,
16,
8083,
199,
199,
318,
1218,
63,
2087,
837,
272,
687,
336,
4695,
324,
1372,
492,
336,
541,
1531,
604,
339,
1798,
275,
336,
541,
1531,
604,
14,
981,
63,
2087,
63,
873,
342,
272,
1798,
14,
525,
63,
2094,
6739,
20099,
401,
2053,
628,
20099,
401,
1595,
628,
1617,
63,
2052,
401,
849,
29,
403,
12,
717,
1720,
628,
10731,
2257,
4493,
370,
18932,
7611,
2755,
1380,
440,
7604,
316,
531,
272,
1798,
14,
525,
63,
2094,
6739,
889,
13,
20099,
401,
2053,
628,
20099,
401,
1595,
628,
1617,
63,
3910,
401,
849,
29,
403,
12,
717,
1720,
628,
20028,
1133,
6675,
2257,
4493,
370,
18932,
7611,
1380,
7604,
316,
531,
272,
1798,
14,
525,
63,
2094,
6739,
1418,
13,
493,
401,
1595,
628,
1617,
401,
730,
29,
32460,
1531,
604,
14,
2101,
63,
515,
12,
717,
1720,
628,
2042,
370,
570,
3035,
12869,
1526,
531,
272,
1798,
14,
525,
63,
2094,
6739,
1418,
401,
1595,
628,
1617,
401,
1720,
628,
14686,
15338,
1526,
370,
675,
531,
272,
372,
1798,
421,
199,
318,
1104,
63,
589,
8,
958,
304,
272,
687,
336,
4695,
324,
1372,
492,
336,
541,
1531,
604,
339,
336,
541,
1531,
604,
14,
409,
63,
504,
63,
888,
8,
958,
9,
272,
2074,
905,
20099,
937,
275,
2074,
905,
20099,
937,
340,
2074,
905,
20099,
937,
365,
440,
488,
587,
2074,
905,
5186,
937,
339,
340,
2074,
905,
20099,
6229,
267,
340,
2074,
905,
4964,
6229,
288,
746,
1722,
480,
7776,
1553,
4964,
543,
1553,
20099,
5712,
1133,
3748,
531,
267,
340,
2074,
905,
1418,
937,
365,
488,
26,
288,
340,
2074,
905,
1418,
63,
493,
937,
365,
488,
26,
355,
746,
1722,
480,
13757,
17169,
1902,
282,
1526,
570,
503,
282,
1526,
531,
288,
543,
1551,
8,
958,
905,
1418,
63,
493,
3135,
465,
289,
26,
355,
1526,
275,
289,
14,
739,
1252,
1913,
342,
355,
2074,
905,
1418,
937,
275,
1526,
272,
2150,
2074,
905,
1418,
63,
493,
937,
272,
372,
2074,
199,
199,
318,
2198,
63,
589,
837,
272,
1798,
275,
1218,
63,
2087,
342,
272,
2074,
275,
6802,
8,
2087,
14,
1122,
63,
589,
1012,
272,
372,
1104,
63,
589,
8,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
5800,
5495,
8204,
365,
5420,
370,
314,
2895,
402,
314,
17728,
1684,
199,
3,
844,
12,
373,
14,
499,
14,
16,
14,
982,
282,
1331,
402,
314,
28481,
1990,
440,
1854,
543,
642,
199,
3,
570,
12,
2047,
883,
3332,
1373,
737,
1455,
921,
12102,
14,
1308,
15,
3950,
15,
18,
14,
16,
8083,
199,
199,
318,
1218,
63,
2087,
837,
272,
687,
336,
4695,
324,
1372,
492,
336,
541,
1531,
604,
339,
1798,
275,
336,
541,
1531,
604,
14,
981,
63,
2087,
63,
873,
342,
272,
1798,
14,
525,
63,
2094,
6739,
20099,
401,
2053,
628,
20099,
401,
1595,
628,
1617,
63,
2052,
401,
849,
29,
403,
12,
717,
1720,
628,
10731,
2257,
4493,
370,
18932,
7611,
2755,
1380,
440,
7604,
316,
531,
272,
1798,
14,
525,
63,
2094,
6739,
889,
13,
20099,
401,
2053,
628,
20099,
401,
1595,
628,
1617,
63,
3910,
401,
849,
29,
403,
12,
717,
1720,
628,
20028,
1133,
6675,
2257,
4493,
370,
18932,
7611,
1380,
7604,
316,
531,
272,
1798,
14,
525,
63,
2094,
6739,
1418,
13,
493,
401,
1595,
628,
1617,
401,
730,
29,
32460,
1531,
604,
14,
2101,
63,
515,
12,
717,
1720,
628,
2042,
370,
570,
3035,
12869,
1526,
531,
272,
1798,
14,
525,
63,
2094,
6739,
1418,
401,
1595,
628,
1617,
401,
1720,
628,
14686,
15338,
1526,
370,
675,
531,
272,
372,
1798,
421,
199,
318,
1104,
63,
589,
8,
958,
304,
272,
687,
336,
4695,
324,
1372,
492,
336,
541,
1531,
604,
339,
336,
541,
1531,
604,
14,
409,
63,
504,
63,
888,
8,
958,
9,
272,
2074,
905,
20099,
937,
275,
2074,
905,
20099,
937,
340,
2074,
905,
20099,
937,
365,
440,
488,
587,
2074,
905,
5186,
937,
339,
340,
2074,
905,
20099,
6229,
267,
340,
2074,
905,
4964,
6229,
288,
746,
1722,
480,
7776,
1553,
4964,
543,
1553,
20099,
5712,
1133,
3748,
531,
267,
340,
2074,
905,
1418,
937,
365,
488,
26,
288,
340,
2074,
905,
1418,
63,
493,
937,
365,
488,
26,
355,
746,
1722,
480,
13757,
17169,
1902,
282,
1526,
570,
503,
282,
1526,
531,
288,
543,
1551,
8,
958,
905,
1418,
63,
493,
3135,
465,
289,
26,
355,
1526,
275,
289,
14,
739,
1252,
1913,
342,
355,
2074,
905,
1418,
937,
275,
1526,
272,
2150,
2074,
905,
1418,
63,
493,
937,
272,
372,
2074,
199,
199,
318,
2198,
63,
589,
837,
272,
1798,
275,
1218,
63,
2087,
342,
272,
2074,
275,
6802,
8,
2087,
14,
1122,
63,
589,
1012,
272,
372,
1104,
63,
589,
8,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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ific modules import the appropriate
functions from this module themselves.
"""
import os
import stat
__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
'getsize', 'isdir', 'isfile']
# Does a path exist?
# This is false for dangling symbolic links on systems that support them.
def exists(path):
"""Test whether a path exists. Returns False for broken symbolic links"""
try:
os.stat(path)
except os.error:
return False
return True
# This follows symbolic links, so both islink() and isdir() can be true
# for the same path on systems that support symlinks
def isfile(path):
"""Test whether a path is a regular file"""
try:
st = os.stat(path)
except os.error:
return False
return stat.S_ISREG(st.st_mode)
# Is a path a directory?
# This follows symbolic links, so both islink() and isdir()
# can be true for the same path on systems that support symlinks
def isdir(s):
"""Return true if the pathname refers to an existing directory."""
try:
st = os.stat(s)
except os.error:
return False
return stat.S_ISDIR(st.st_mode)
def getsize(filename):
"""Return the size of a file, reported by os.stat()."""
return os.stat(filename).st_size
def getmtime(filename):
"""Return the last modification time of a file, reported by os.stat()."""
return os.stat(filename).st_mtime
def getatime(filename):
"""Return the last access time of a file, reported by os.stat()."""
return os.stat(filename).st_atime
def getctime(filename):
"""Return the metadata change time of a file, reported by os.stat()."""
return os.stat(filename).st_ctime
# Return the longest prefix of all list elements.
def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m: return ''
s1 = min(m)
s2 = max(m)
for i, c in enumerate(s1):
if c != s2[i]:
return s1[:i]
return s1
# Split a path in root and extension.
# The extension is everything starting at the last dot in the last
# pathname component; the root is everything before that.
# It is always true that root + ext == p.
# Generic implementation of splitext, to be parametrized with
# the separators
def _splitext(p, sep, altsep, extsep):
"""Split the extension from a pathname.
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty."""
# NOTE: This code must work for text and bytes strings.
sepIndex = p.rfind(sep)
if altsep:
altsepIndex = p.rfind(altsep)
sepIndex = max(sepIndex, altsepIndex)
dotIndex = p.rfind(extsep)
if dotIndex > sepIndex:
# skip all leading dots
filenameIndex = sepIndex + 1
while filenameIndex < dotIndex:
if p[filenameIndex:filenameIndex+1] != extsep:
return p[:dotIndex], p[dotIndex:]
filenameIndex += 1
return p, p[:0]
|
gpl-3.0
|
[
624,
199,
2042,
5331,
2863,
370,
1655,
2419,
1373,
4403,
199,
2585,
440,
675,
5370,
14,
221,
710,
4403,
2488,
4621,
492,
314,
5827,
199,
5777,
687,
642,
859,
17279,
14,
199,
624,
199,
646,
747,
199,
646,
5672,
199,
199,
363,
452,
363,
275,
788,
2330,
1861,
297,
283,
2444,
297,
283,
362,
27867,
297,
283,
362,
20691,
297,
283,
26628,
297,
1779,
283,
20733,
297,
283,
6027,
297,
283,
6292,
418,
421,
199,
3,
12078,
282,
931,
2187,
31,
199,
3,
961,
365,
3055,
367,
366,
26896,
13673,
6220,
641,
10460,
626,
2291,
3062,
14,
199,
318,
3495,
8,
515,
304,
272,
408,
774,
3775,
282,
931,
3495,
14,
221,
1803,
756,
367,
10529,
13673,
6220,
624,
272,
862,
26,
267,
747,
14,
3736,
8,
515,
9,
272,
871,
747,
14,
705,
26,
267,
372,
756,
272,
372,
715,
421,
199,
3,
961,
11924,
13673,
6220,
12,
880,
3865,
365,
1073,
342,
436,
26004,
342,
883,
506,
2549,
199,
3,
367,
314,
2011,
931,
641,
10460,
626,
2291,
19891,
199,
318,
29214,
8,
515,
304,
272,
408,
774,
3775,
282,
931,
365,
282,
5578,
570,
624,
272,
862,
26,
267,
410,
275,
747,
14,
3736,
8,
515,
9,
272,
871,
747,
14,
705,
26,
267,
372,
756,
272,
372,
5672,
14,
51,
63,
1311,
5616,
8,
270,
14,
270,
63,
632,
9,
421,
199,
3,
6596,
282,
931,
282,
2082,
31,
199,
3,
961,
11924,
13673,
6220,
12,
880,
3865,
365,
1073,
342,
436,
26004,
342,
199,
3,
883,
506,
2549,
367,
314,
2011,
931,
641,
10460,
626,
2291,
19891,
199,
318,
26004,
8,
83,
304,
272,
408,
1767,
2549,
340,
314,
11776,
15724,
370,
376,
3411,
2082,
1041,
272,
862,
26,
267,
410,
275,
747,
14,
3736,
8,
83,
9,
272,
871,
747,
14,
705,
26,
267,
372,
756,
272,
372,
5672,
14,
51,
63,
1311,
3022,
8,
270,
14,
270,
63,
632,
9,
421,
199,
318,
664,
890,
8,
1501,
304,
272,
408,
1767,
314,
1568,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
890,
421,
199,
318,
664,
8180,
8,
1501,
304,
272,
408,
1767,
314,
2061,
7100,
900,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
8180,
421,
199,
318,
664,
27867,
8,
1501,
304,
272,
408,
1767,
314,
2061,
2879,
900,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
27867,
421,
199,
318,
664,
20691,
8,
1501,
304,
272,
408,
1767,
314,
3341,
1570,
900,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
20691,
421,
199,
3,
1432,
314,
21303,
2403,
402,
1006,
769,
4008,
14,
199,
318,
2863,
1861,
8,
77,
304,
272,
298,
13735,
282,
769,
402,
931,
1247,
12,
2529,
314,
21303,
2863,
9186,
3931,
2,
272,
340,
440,
333,
26,
372,
2125,
272,
308,
17,
275,
1748,
8,
77,
9,
272,
308,
18,
275,
1390,
8,
77,
9,
272,
367,
284,
12,
286,
315,
3874,
8,
83,
17,
304,
267,
340,
286,
1137,
308,
18,
59,
73,
2189,
288,
372,
308,
17,
1491,
73,
61,
272,
372,
308,
17,
199,
199,
3,
11740,
282,
931,
315,
1738,
436,
3329,
14,
199,
3,
710,
3329,
365,
8137,
6617,
737,
314,
2061,
6308,
315,
314,
2061,
199,
3,
11776,
3931,
27,
314,
1738,
365,
8137,
2544,
626,
14,
199,
3,
2779,
365,
3544,
2549,
626,
1738,
435,
1599,
508,
299,
14,
199,
199,
3,
8307,
4514,
402,
2249,
7699,
12,
370,
506,
18117,
599,
7068,
543,
199,
3,
314,
17658,
199,
318,
485,
7973,
8,
80,
12,
7375,
12,
8791,
4127,
12,
1599,
4127,
304,
272,
408,
8862,
314,
3329,
687,
282,
11776,
14,
339,
13282,
365,
8137,
687,
314,
2061,
6308,
370,
314,
1284,
12,
17289,
272,
9186,
21185,
14,
221,
1803,
7340,
1231,
12,
1599,
2924,
27,
1599,
1443,
506,
2701,
1041,
272,
327,
6944,
26,
961,
1233,
1471,
1736,
367,
1318,
436,
2783,
3326,
14,
339,
7375,
2681,
275,
299,
14,
14542,
8,
4127,
9,
272,
340,
8791,
4127,
26,
267,
8791,
4127,
2681,
275,
299,
14,
14542,
8,
4478,
4127,
9,
267,
7375,
2681,
275,
1390,
8,
4127,
2681,
12,
8791,
4127,
2681,
9,
339,
6308,
2681,
275,
299,
14,
14542,
8,
832,
4127,
9,
272,
340,
6308,
2681,
690,
7375,
2681,
26,
267,
327,
3372,
1006,
9186,
21185,
267,
1788,
2681,
275,
7375,
2681,
435,
413,
267,
1830,
1788,
2681,
665,
6308,
2681,
26,
288,
340,
299,
59,
1501,
2681,
26,
1501,
2681,
11,
17,
61,
1137,
1599,
4127,
26,
355,
372,
299,
1491,
3287,
2681,
467,
299,
59,
3287,
2681,
2938,
288,
1788,
2681,
847,
413,
339,
372,
299,
12,
299,
1491,
16,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
2042,
5331,
2863,
370,
1655,
2419,
1373,
4403,
199,
2585,
440,
675,
5370,
14,
221,
710,
4403,
2488,
4621,
492,
314,
5827,
199,
5777,
687,
642,
859,
17279,
14,
199,
624,
199,
646,
747,
199,
646,
5672,
199,
199,
363,
452,
363,
275,
788,
2330,
1861,
297,
283,
2444,
297,
283,
362,
27867,
297,
283,
362,
20691,
297,
283,
26628,
297,
1779,
283,
20733,
297,
283,
6027,
297,
283,
6292,
418,
421,
199,
3,
12078,
282,
931,
2187,
31,
199,
3,
961,
365,
3055,
367,
366,
26896,
13673,
6220,
641,
10460,
626,
2291,
3062,
14,
199,
318,
3495,
8,
515,
304,
272,
408,
774,
3775,
282,
931,
3495,
14,
221,
1803,
756,
367,
10529,
13673,
6220,
624,
272,
862,
26,
267,
747,
14,
3736,
8,
515,
9,
272,
871,
747,
14,
705,
26,
267,
372,
756,
272,
372,
715,
421,
199,
3,
961,
11924,
13673,
6220,
12,
880,
3865,
365,
1073,
342,
436,
26004,
342,
883,
506,
2549,
199,
3,
367,
314,
2011,
931,
641,
10460,
626,
2291,
19891,
199,
318,
29214,
8,
515,
304,
272,
408,
774,
3775,
282,
931,
365,
282,
5578,
570,
624,
272,
862,
26,
267,
410,
275,
747,
14,
3736,
8,
515,
9,
272,
871,
747,
14,
705,
26,
267,
372,
756,
272,
372,
5672,
14,
51,
63,
1311,
5616,
8,
270,
14,
270,
63,
632,
9,
421,
199,
3,
6596,
282,
931,
282,
2082,
31,
199,
3,
961,
11924,
13673,
6220,
12,
880,
3865,
365,
1073,
342,
436,
26004,
342,
199,
3,
883,
506,
2549,
367,
314,
2011,
931,
641,
10460,
626,
2291,
19891,
199,
318,
26004,
8,
83,
304,
272,
408,
1767,
2549,
340,
314,
11776,
15724,
370,
376,
3411,
2082,
1041,
272,
862,
26,
267,
410,
275,
747,
14,
3736,
8,
83,
9,
272,
871,
747,
14,
705,
26,
267,
372,
756,
272,
372,
5672,
14,
51,
63,
1311,
3022,
8,
270,
14,
270,
63,
632,
9,
421,
199,
318,
664,
890,
8,
1501,
304,
272,
408,
1767,
314,
1568,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
890,
421,
199,
318,
664,
8180,
8,
1501,
304,
272,
408,
1767,
314,
2061,
7100,
900,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
8180,
421,
199,
318,
664,
27867,
8,
1501,
304,
272,
408,
1767,
314,
2061,
2879,
900,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
27867,
421,
199,
318,
664,
20691,
8,
1501,
304,
272,
408,
1767,
314,
3341,
1570,
900,
402,
282,
570,
12,
14581,
701,
747,
14,
3736,
20693,
272,
372,
747,
14,
3736,
8,
1501,
680,
270,
63,
20691,
421,
199,
3,
1432,
314,
21303,
2403,
402,
1006,
769,
4008,
14,
199,
318,
2863,
1861,
8,
77,
304,
272,
298,
13735,
282,
769,
402,
931,
1247,
12,
2529,
314,
21303,
2863,
9186,
3931,
2,
272,
340,
440,
333,
26,
372,
2125,
272,
308,
17,
275,
1748,
8,
77,
9,
272,
308,
18,
275,
1390,
8,
77,
9,
272,
367,
284,
12,
286,
315,
3874,
8,
83,
17,
304,
267,
340,
286,
1137,
308,
18,
59,
73,
2189,
288,
372,
308,
17,
1491,
73,
61,
272,
372,
308,
17,
199,
199,
3,
11740,
282,
931,
315,
1738,
436,
3329,
14,
199,
3,
710,
3329,
365,
8137,
6617,
737,
314,
2061,
6308,
315,
314,
2061,
199,
3,
11776,
3931,
27,
314,
1738,
365,
8137,
2544,
626,
14,
199,
3,
2779,
365,
3544,
2549,
626,
1738,
435,
1599,
508,
299,
14,
199,
199,
3,
8307,
4514,
402,
2249,
7699,
12,
370,
506,
18117,
599,
7068,
543,
199,
3,
314,
17658,
199,
318,
485,
7973,
8,
80,
12,
7375,
12,
8791,
4127,
12,
1599,
4127,
304,
272,
408,
8862,
314,
3329,
687,
282,
11776,
14,
339,
13282,
365,
8137,
687,
314,
2061,
6308,
370,
314,
1284,
12,
17289,
272,
9186,
21185,
14,
221,
1803,
7340,
1231,
12,
1599,
2924,
27,
1599,
1443,
506,
2701,
1041,
272,
327,
6944,
26,
961,
1233,
1471,
1736,
367,
1318,
436,
2783,
3326,
14,
339,
7375,
2681,
275,
299,
14,
14542,
8,
4127,
9,
272,
340,
8791,
4127,
26,
267,
8791,
4127,
2681,
275,
299,
14,
14542,
8,
4478,
4127,
9,
267,
7375,
2681,
275,
1390,
8,
4127,
2681,
12,
8791,
4127,
2681,
9,
339,
6308,
2681,
275,
299,
14,
14542,
8,
832,
4127,
9,
272,
340,
6308,
2681,
690,
7375,
2681,
26,
267,
327,
3372,
1006,
9186,
21185,
267,
1788,
2681,
275,
7375,
2681,
435,
413,
267,
1830,
1788,
2681,
665,
6308,
2681,
26,
288,
340,
299,
59,
1501,
2681,
26,
1501,
2681,
11,
17,
61,
1137,
1599,
4127,
26,
355,
372,
299,
1491,
3287,
2681,
467,
299,
59,
3287,
2681,
2938,
288,
1788,
2681,
847,
413,
339,
372,
299,
12,
299,
1491,
16,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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
] |
vikitripathi/MB-MessApp-API
|
messApp/env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/exceptions.py
|
330
|
3364
|
# urllib3/exceptions.py
# Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
#
# This module is part of urllib3 and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
## Base Exceptions
class HTTPError(Exception):
"Base exception 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 ConnectionError(HTTPError):
"Raised when a normal connection fails."
pass
class DecodeError(HTTPError):
"Raised when automatic decoding based on Content-Type fails."
pass
## Leaf Exceptions
class MaxRetryError(RequestError):
"Raised when the maximum number of retries is exceeded."
def __init__(self, pool, url, reason=None):
self.reason = reason
message = "Max retries exceeded with url: %s" % url
if reason:
message += " (Caused by %s: %s)" % (type(reason), reason)
else:
message += " (Caused by redirect)"
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 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 LocationParseError(ValueError, HTTPError):
"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
|
apache-2.0
|
[
3,
4011,
19,
15,
3924,
14,
647,
199,
3,
1898,
9079,
13,
6965,
6061,
17885,
31449,
293,
86,
436,
8417,
334,
3239,
6483,
14,
2424,
9,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
4011,
19,
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,
421,
199,
309,
3523,
24873,
199,
199,
533,
15050,
8,
1726,
304,
272,
298,
1563,
1919,
1202,
701,
642,
859,
2122,
272,
986,
421,
199,
533,
15553,
547,
8,
12815,
304,
272,
298,
1563,
1919,
367,
2552,
18104,
4453,
282,
4203,
2122,
272,
347,
636,
826,
721,
277,
12,
4203,
12,
1245,
304,
267,
291,
14,
2293,
275,
4203,
267,
15050,
855,
826,
721,
277,
12,
2071,
83,
26,
450,
83,
2,
450,
334,
2293,
12,
1245,
430,
339,
347,
636,
5270,
721,
277,
304,
267,
327,
2104,
24394,
12901,
14,
267,
372,
291,
855,
533,
3108,
334,
403,
12,
488,
9,
421,
199,
533,
4784,
547,
8,
5453,
547,
304,
272,
298,
1563,
1919,
367,
15553,
9298,
626,
1172,
4568,
10867,
2122,
272,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
304,
267,
291,
14,
633,
275,
1166,
267,
15553,
547,
855,
826,
721,
277,
12,
4203,
12,
1245,
9,
339,
347,
636,
5270,
721,
277,
304,
267,
327,
2104,
24394,
12901,
14,
267,
372,
291,
855,
533,
3108,
334,
403,
12,
291,
14,
633,
12,
488,
9,
421,
199,
533,
7799,
547,
8,
12815,
304,
272,
298,
16894,
1380,
7799,
5897,
6918,
315,
376,
14147,
1950,
2122,
272,
986,
421,
199,
533,
12373,
547,
8,
12815,
304,
272,
298,
16894,
1380,
314,
1950,
370,
282,
4566,
6918,
2122,
272,
986,
421,
199,
533,
25417,
8,
12815,
304,
272,
298,
16894,
1380,
282,
3293,
1950,
6918,
2122,
272,
986,
421,
199,
533,
22462,
547,
8,
12815,
304,
272,
298,
16894,
1380,
4834,
15952,
4079,
641,
6646,
13,
804,
6918,
2122,
272,
986,
421,
199,
309,
27836,
24873,
199,
199,
533,
8228,
12989,
547,
8,
19261,
304,
272,
298,
16894,
1380,
314,
5696,
1329,
402,
10086,
365,
22007,
2122,
339,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
4499,
29,
403,
304,
267,
291,
14,
5764,
275,
4499,
398,
1245,
275,
298,
4261,
10086,
22007,
543,
1166,
26,
450,
83,
2,
450,
1166,
267,
340,
4499,
26,
288,
1245,
847,
298,
334,
3630,
2972,
701,
450,
83,
26,
450,
83,
2924,
450,
334,
466,
8,
5764,
395,
4499,
9,
267,
587,
26,
288,
1245,
847,
298,
334,
3630,
2972,
701,
4660,
2924,
398,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
421,
199,
533,
10891,
6970,
547,
8,
19261,
304,
272,
298,
16894,
1380,
376,
3411,
4203,
7545,
282,
1056,
367,
282,
11608,
1591,
2122,
339,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
10086,
29,
19,
304,
267,
1245,
275,
298,
6948,
379,
370,
1551,
282,
11608,
1591,
543,
1166,
26,
450,
83,
2,
450,
1166,
267,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
267,
291,
14,
10937,
275,
10086,
421,
199,
533,
12878,
2223,
547,
8,
12815,
304,
272,
408,
24997,
1380,
9476,
376,
3866,
1174,
370,
282,
2653,
408,
272,
986,
421,
199,
533,
31886,
8,
12815,
304,
272,
408,
24997,
1380,
282,
2838,
2653,
1125,
11058,
14,
339,
32754,
316,
642,
1125,
911,
8579,
3865,
520,
2804,
1705,
3284,
6372,
9298,
272,
665,
3284,
19382,
8637,
436,
520,
2804,
1705,
8631,
6372,
9298,
665,
8631,
19382,
14943,
272,
408,
272,
986,
421,
199,
533,
5574,
19382,
8,
19382,
12,
4784,
547,
304,
272,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18390,
666,
687,
282,
1654,
2,
272,
986,
421,
199,
3,
961,
2653,
1125,
1630,
440,
1172,
282,
2851,
10102,
436,
4839,
370,
8287,
687,
314,
199,
3,
1300,
15050,
199,
533,
15175,
19382,
8,
19382,
304,
272,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18170,
370,
282,
1654,
2,
272,
986,
421,
199,
533,
9630,
5453,
547,
8,
5453,
547,
304,
272,
298,
16894,
1380,
282,
4203,
7858,
734,
402,
6947,
436,
949,
1655,
787,
4370,
2122,
272,
986,
421,
199,
533,
5980,
939,
5453,
547,
8,
5453,
547,
304,
272,
298,
16894,
1380,
282,
1056,
655,
878,
282,
4203,
2410,
314,
4203,
965,
2757,
6876,
2122,
272,
986,
421,
199,
533,
12625,
9123,
8,
3393,
12,
15050,
304,
272,
298,
16894,
1380,
664,
63,
1102,
503,
8545,
6918,
370,
2198,
314,
2851,
1324,
2122,
339,
347,
636,
826,
721,
277,
12,
2909,
304,
267,
1245,
275,
298,
4276,
370,
2198,
26,
450,
83,
2,
450,
2909,
267,
15050,
855,
826,
721,
277,
12,
1245,
9,
398,
291,
14,
1985,
275,
2909,
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
] |
[
4011,
19,
15,
3924,
14,
647,
199,
3,
1898,
9079,
13,
6965,
6061,
17885,
31449,
293,
86,
436,
8417,
334,
3239,
6483,
14,
2424,
9,
199,
3,
199,
3,
961,
859,
365,
1777,
402,
4011,
19,
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,
421,
199,
309,
3523,
24873,
199,
199,
533,
15050,
8,
1726,
304,
272,
298,
1563,
1919,
1202,
701,
642,
859,
2122,
272,
986,
421,
199,
533,
15553,
547,
8,
12815,
304,
272,
298,
1563,
1919,
367,
2552,
18104,
4453,
282,
4203,
2122,
272,
347,
636,
826,
721,
277,
12,
4203,
12,
1245,
304,
267,
291,
14,
2293,
275,
4203,
267,
15050,
855,
826,
721,
277,
12,
2071,
83,
26,
450,
83,
2,
450,
334,
2293,
12,
1245,
430,
339,
347,
636,
5270,
721,
277,
304,
267,
327,
2104,
24394,
12901,
14,
267,
372,
291,
855,
533,
3108,
334,
403,
12,
488,
9,
421,
199,
533,
4784,
547,
8,
5453,
547,
304,
272,
298,
1563,
1919,
367,
15553,
9298,
626,
1172,
4568,
10867,
2122,
272,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
304,
267,
291,
14,
633,
275,
1166,
267,
15553,
547,
855,
826,
721,
277,
12,
4203,
12,
1245,
9,
339,
347,
636,
5270,
721,
277,
304,
267,
327,
2104,
24394,
12901,
14,
267,
372,
291,
855,
533,
3108,
334,
403,
12,
291,
14,
633,
12,
488,
9,
421,
199,
533,
7799,
547,
8,
12815,
304,
272,
298,
16894,
1380,
7799,
5897,
6918,
315,
376,
14147,
1950,
2122,
272,
986,
421,
199,
533,
12373,
547,
8,
12815,
304,
272,
298,
16894,
1380,
314,
1950,
370,
282,
4566,
6918,
2122,
272,
986,
421,
199,
533,
25417,
8,
12815,
304,
272,
298,
16894,
1380,
282,
3293,
1950,
6918,
2122,
272,
986,
421,
199,
533,
22462,
547,
8,
12815,
304,
272,
298,
16894,
1380,
4834,
15952,
4079,
641,
6646,
13,
804,
6918,
2122,
272,
986,
421,
199,
309,
27836,
24873,
199,
199,
533,
8228,
12989,
547,
8,
19261,
304,
272,
298,
16894,
1380,
314,
5696,
1329,
402,
10086,
365,
22007,
2122,
339,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
4499,
29,
403,
304,
267,
291,
14,
5764,
275,
4499,
398,
1245,
275,
298,
4261,
10086,
22007,
543,
1166,
26,
450,
83,
2,
450,
1166,
267,
340,
4499,
26,
288,
1245,
847,
298,
334,
3630,
2972,
701,
450,
83,
26,
450,
83,
2924,
450,
334,
466,
8,
5764,
395,
4499,
9,
267,
587,
26,
288,
1245,
847,
298,
334,
3630,
2972,
701,
4660,
2924,
398,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
421,
199,
533,
10891,
6970,
547,
8,
19261,
304,
272,
298,
16894,
1380,
376,
3411,
4203,
7545,
282,
1056,
367,
282,
11608,
1591,
2122,
339,
347,
636,
826,
721,
277,
12,
4203,
12,
1166,
12,
10086,
29,
19,
304,
267,
1245,
275,
298,
6948,
379,
370,
1551,
282,
11608,
1591,
543,
1166,
26,
450,
83,
2,
450,
1166,
267,
4784,
547,
855,
826,
721,
277,
12,
4203,
12,
1166,
12,
1245,
9,
267,
291,
14,
10937,
275,
10086,
421,
199,
533,
12878,
2223,
547,
8,
12815,
304,
272,
408,
24997,
1380,
9476,
376,
3866,
1174,
370,
282,
2653,
408,
272,
986,
421,
199,
533,
31886,
8,
12815,
304,
272,
408,
24997,
1380,
282,
2838,
2653,
1125,
11058,
14,
339,
32754,
316,
642,
1125,
911,
8579,
3865,
520,
2804,
1705,
3284,
6372,
9298,
272,
665,
3284,
19382,
8637,
436,
520,
2804,
1705,
8631,
6372,
9298,
665,
8631,
19382,
14943,
272,
408,
272,
986,
421,
199,
533,
5574,
19382,
8,
19382,
12,
4784,
547,
304,
272,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18390,
666,
687,
282,
1654,
2,
272,
986,
421,
199,
3,
961,
2653,
1125,
1630,
440,
1172,
282,
2851,
10102,
436,
4839,
370,
8287,
687,
314,
199,
3,
1300,
15050,
199,
533,
15175,
19382,
8,
19382,
304,
272,
298,
16894,
1380,
282,
2838,
2653,
11058,
1830,
18170,
370,
282,
1654,
2,
272,
986,
421,
199,
533,
9630,
5453,
547,
8,
5453,
547,
304,
272,
298,
16894,
1380,
282,
4203,
7858,
734,
402,
6947,
436,
949,
1655,
787,
4370,
2122,
272,
986,
421,
199,
533,
5980,
939,
5453,
547,
8,
5453,
547,
304,
272,
298,
16894,
1380,
282,
1056,
655,
878,
282,
4203,
2410,
314,
4203,
965,
2757,
6876,
2122,
272,
986,
421,
199,
533,
12625,
9123,
8,
3393,
12,
15050,
304,
272,
298,
16894,
1380,
664,
63,
1102,
503,
8545,
6918,
370,
2198,
314,
2851,
1324,
2122,
339,
347,
636,
826,
721,
277,
12,
2909,
304,
267,
1245,
275,
298,
4276,
370,
2198,
26,
450,
83,
2,
450,
2909,
267,
15050,
855,
826,
721,
277,
12,
1245,
9,
398,
291,
14,
1985,
275,
2909,
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,
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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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
] |
thierry1985/project-1022
|
translate/pddl/pddl_types.py
|
3
|
2620
|
# Renamed from types.py to avoid clash with stdlib module.
# In the future, use explicitly relative imports or absolute
# imports as a better solution.
import conditions
import graph
import itertools
class Type(object):
def __init__(self, name, basetype_name=None):
self.name = name
self.basetype_name = basetype_name
def __str__(self):
return self.name
def __repr__(self):
return "Type(%s, %s)" % (self.name, self.basetype_name)
def set_supertypes(type_list):
typename_to_type = {}
child_types = []
for type in type_list:
type.supertype_names = []
typename_to_type[type.name] = type
if type.basetype_name:
child_types.append((type.name, type.basetype_name))
for (desc_name, anc_name) in graph.transitive_closure(child_types):
typename_to_type[desc_name].supertype_names.append(anc_name)
class TypedObject(object):
def __init__(self, name, type):
self.name = name
if isinstance(type,list):
self.type = tuple(type)
else:
self.type = type
def __hash__(self):
return hash((self.name, self.type))
def __eq__(self, other):
return self.name == other.name and self.type == other.type
def __ne__(self, other):
return not self == other
def __str__(self):
return "%s: %s" % (self.name, self.type)
def uniquify_name(self, type_map, renamings):
if self.name not in type_map:
type_map[self.name] = self.type
return self
for counter in itertools.count(1):
new_name = self.name + str(counter)
if new_name not in type_map:
renamings[self.name] = new_name
type_map[new_name] = self.type
return TypedObject(new_name, self.type)
def to_untyped_strips(self):
return conditions.Atom(self.type, [self.name])
# types is used to add (either ...) statements as supertypes
def parse_typed_list(alist, only_variables=False, constructor=TypedObject, functions=False, types=[]):
result = []
while alist:
try:
separator_position = alist.index("-")
except ValueError:
items = alist
if functions:
type = "number"
else:
type = "object"
alist = []
else:
items = alist[:separator_position]
type = alist[separator_position + 1]
if isinstance(type,list):
assert type[0]=="either"
type = tuple(type)
for subtype in type[1:]:
types.append(Type(subtype,type))
alist = alist[separator_position + 2:]
for item in items:
assert not only_variables or item.startswith("?")
entry = constructor(item, type)
result.append(entry)
return result
|
mit
|
[
3,
22756,
68,
687,
2943,
14,
647,
370,
5126,
30109,
543,
26678,
859,
14,
199,
3,
1010,
314,
6466,
12,
675,
7662,
3847,
8925,
503,
3679,
199,
3,
8925,
465,
282,
8034,
8744,
14,
199,
199,
646,
3704,
199,
199,
646,
3343,
199,
199,
646,
7975,
199,
199,
533,
2434,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
536,
12,
1300,
466,
63,
354,
29,
403,
304,
272,
291,
14,
354,
275,
536,
272,
291,
14,
25882,
63,
354,
275,
1300,
466,
63,
354,
523,
347,
636,
495,
721,
277,
304,
272,
372,
291,
14,
354,
523,
347,
636,
2722,
721,
277,
304,
272,
372,
298,
804,
4042,
83,
12,
450,
83,
2924,
450,
334,
277,
14,
354,
12,
291,
14,
25882,
63,
354,
9,
199,
199,
318,
663,
63,
4792,
1313,
8,
466,
63,
513,
304,
523,
19151,
63,
475,
63,
466,
275,
1052,
523,
1982,
63,
1313,
275,
942,
523,
367,
730,
315,
730,
63,
513,
26,
272,
730,
14,
4792,
466,
63,
1247,
275,
942,
272,
19151,
63,
475,
63,
466,
59,
466,
14,
354,
61,
275,
730,
272,
340,
730,
14,
25882,
63,
354,
26,
489,
1982,
63,
1313,
14,
740,
1332,
466,
14,
354,
12,
730,
14,
25882,
63,
354,
430,
523,
367,
334,
3257,
63,
354,
12,
376,
67,
63,
354,
9,
315,
3343,
14,
3936,
3013,
63,
13008,
8,
1739,
63,
1313,
304,
272,
19151,
63,
475,
63,
466,
59,
3257,
63,
354,
1055,
4792,
466,
63,
1247,
14,
740,
8,
18595,
63,
354,
9,
421,
199,
533,
31906,
1692,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
536,
12,
730,
304,
272,
291,
14,
354,
275,
536,
272,
340,
1228,
8,
466,
12,
513,
304,
267,
291,
14,
466,
275,
2008,
8,
466,
9,
272,
587,
26,
267,
291,
14,
466,
275,
730,
523,
347,
636,
2227,
721,
277,
304,
272,
372,
2631,
1332,
277,
14,
354,
12,
291,
14,
466,
430,
523,
347,
636,
4077,
721,
277,
12,
1163,
304,
272,
372,
291,
14,
354,
508,
1163,
14,
354,
436,
291,
14,
466,
508,
1163,
14,
466,
523,
347,
636,
685,
721,
277,
12,
1163,
304,
272,
372,
440,
291,
508,
1163,
523,
347,
636,
495,
721,
277,
304,
272,
372,
2071,
83,
26,
450,
83,
2,
450,
334,
277,
14,
354,
12,
291,
14,
466,
9,
523,
347,
15439,
392,
2021,
63,
354,
8,
277,
12,
730,
63,
1130,
12,
2903,
455,
780,
304,
272,
340,
291,
14,
354,
440,
315,
730,
63,
1130,
26,
489,
730,
63,
1130,
59,
277,
14,
354,
61,
275,
291,
14,
466,
489,
372,
291,
272,
367,
7055,
315,
7975,
14,
835,
8,
17,
304,
489,
892,
63,
354,
275,
291,
14,
354,
435,
620,
8,
5337,
9,
489,
340,
892,
63,
354,
440,
315,
730,
63,
1130,
26,
267,
2903,
455,
780,
59,
277,
14,
354,
61,
275,
892,
63,
354,
267,
730,
63,
1130,
59,
1222,
63,
354,
61,
275,
291,
14,
466,
267,
372,
31906,
1692,
8,
1222,
63,
354,
12,
291,
14,
466,
9,
523,
347,
370,
63,
324,
22033,
63,
816,
1190,
8,
277,
304,
272,
372,
3704,
14,
12097,
8,
277,
14,
466,
12,
359,
277,
14,
354,
566,
199,
199,
3,
2943,
365,
1202,
370,
1050,
334,
22051,
19172,
9834,
465,
1613,
1313,
199,
318,
2198,
63,
22033,
63,
513,
8,
26279,
12,
1454,
63,
3669,
29,
797,
12,
3787,
29,
22193,
1692,
12,
3423,
29,
797,
12,
2943,
17894,
523,
754,
275,
942,
523,
1830,
741,
631,
26,
272,
862,
26,
489,
9432,
63,
3124,
275,
741,
631,
14,
1080,
6096,
531,
272,
871,
1722,
26,
489,
2974,
275,
741,
631,
489,
340,
3423,
26,
267,
730,
275,
298,
1955,
2,
489,
587,
26,
267,
730,
275,
298,
785,
2,
489,
741,
631,
275,
942,
272,
587,
26,
489,
2974,
275,
741,
631,
1491,
9896,
63,
3124,
61,
489,
730,
275,
741,
631,
59,
9896,
63,
3124,
435,
413,
61,
489,
340,
1228,
8,
466,
12,
513,
304,
267,
702,
730,
59,
16,
61,
11800,
22051,
2,
267,
730,
275,
2008,
8,
466,
9,
267,
367,
15686,
315,
730,
59,
17,
10688,
288,
2943,
14,
740,
8,
804,
8,
10512,
12,
466,
430,
489,
741,
631,
275,
741,
631,
59,
9896,
63,
3124,
435,
499,
2938,
272,
367,
1242,
315,
2974,
26,
489,
702,
440,
1454,
63,
3669,
503,
1242,
14,
2460,
480,
18582,
489,
2397,
275,
3787,
8,
1053,
12,
730,
9,
489,
754,
14,
740,
8,
2373,
9,
523,
372,
754,
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
] |
[
22756,
68,
687,
2943,
14,
647,
370,
5126,
30109,
543,
26678,
859,
14,
199,
3,
1010,
314,
6466,
12,
675,
7662,
3847,
8925,
503,
3679,
199,
3,
8925,
465,
282,
8034,
8744,
14,
199,
199,
646,
3704,
199,
199,
646,
3343,
199,
199,
646,
7975,
199,
199,
533,
2434,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
536,
12,
1300,
466,
63,
354,
29,
403,
304,
272,
291,
14,
354,
275,
536,
272,
291,
14,
25882,
63,
354,
275,
1300,
466,
63,
354,
523,
347,
636,
495,
721,
277,
304,
272,
372,
291,
14,
354,
523,
347,
636,
2722,
721,
277,
304,
272,
372,
298,
804,
4042,
83,
12,
450,
83,
2924,
450,
334,
277,
14,
354,
12,
291,
14,
25882,
63,
354,
9,
199,
199,
318,
663,
63,
4792,
1313,
8,
466,
63,
513,
304,
523,
19151,
63,
475,
63,
466,
275,
1052,
523,
1982,
63,
1313,
275,
942,
523,
367,
730,
315,
730,
63,
513,
26,
272,
730,
14,
4792,
466,
63,
1247,
275,
942,
272,
19151,
63,
475,
63,
466,
59,
466,
14,
354,
61,
275,
730,
272,
340,
730,
14,
25882,
63,
354,
26,
489,
1982,
63,
1313,
14,
740,
1332,
466,
14,
354,
12,
730,
14,
25882,
63,
354,
430,
523,
367,
334,
3257,
63,
354,
12,
376,
67,
63,
354,
9,
315,
3343,
14,
3936,
3013,
63,
13008,
8,
1739,
63,
1313,
304,
272,
19151,
63,
475,
63,
466,
59,
3257,
63,
354,
1055,
4792,
466,
63,
1247,
14,
740,
8,
18595,
63,
354,
9,
421,
199,
533,
31906,
1692,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
536,
12,
730,
304,
272,
291,
14,
354,
275,
536,
272,
340,
1228,
8,
466,
12,
513,
304,
267,
291,
14,
466,
275,
2008,
8,
466,
9,
272,
587,
26,
267,
291,
14,
466,
275,
730,
523,
347,
636,
2227,
721,
277,
304,
272,
372,
2631,
1332,
277,
14,
354,
12,
291,
14,
466,
430,
523,
347,
636,
4077,
721,
277,
12,
1163,
304,
272,
372,
291,
14,
354,
508,
1163,
14,
354,
436,
291,
14,
466,
508,
1163,
14,
466,
523,
347,
636,
685,
721,
277,
12,
1163,
304,
272,
372,
440,
291,
508,
1163,
523,
347,
636,
495,
721,
277,
304,
272,
372,
2071,
83,
26,
450,
83,
2,
450,
334,
277,
14,
354,
12,
291,
14,
466,
9,
523,
347,
15439,
392,
2021,
63,
354,
8,
277,
12,
730,
63,
1130,
12,
2903,
455,
780,
304,
272,
340,
291,
14,
354,
440,
315,
730,
63,
1130,
26,
489,
730,
63,
1130,
59,
277,
14,
354,
61,
275,
291,
14,
466,
489,
372,
291,
272,
367,
7055,
315,
7975,
14,
835,
8,
17,
304,
489,
892,
63,
354,
275,
291,
14,
354,
435,
620,
8,
5337,
9,
489,
340,
892,
63,
354,
440,
315,
730,
63,
1130,
26,
267,
2903,
455,
780,
59,
277,
14,
354,
61,
275,
892,
63,
354,
267,
730,
63,
1130,
59,
1222,
63,
354,
61,
275,
291,
14,
466,
267,
372,
31906,
1692,
8,
1222,
63,
354,
12,
291,
14,
466,
9,
523,
347,
370,
63,
324,
22033,
63,
816,
1190,
8,
277,
304,
272,
372,
3704,
14,
12097,
8,
277,
14,
466,
12,
359,
277,
14,
354,
566,
199,
199,
3,
2943,
365,
1202,
370,
1050,
334,
22051,
19172,
9834,
465,
1613,
1313,
199,
318,
2198,
63,
22033,
63,
513,
8,
26279,
12,
1454,
63,
3669,
29,
797,
12,
3787,
29,
22193,
1692,
12,
3423,
29,
797,
12,
2943,
17894,
523,
754,
275,
942,
523,
1830,
741,
631,
26,
272,
862,
26,
489,
9432,
63,
3124,
275,
741,
631,
14,
1080,
6096,
531,
272,
871,
1722,
26,
489,
2974,
275,
741,
631,
489,
340,
3423,
26,
267,
730,
275,
298,
1955,
2,
489,
587,
26,
267,
730,
275,
298,
785,
2,
489,
741,
631,
275,
942,
272,
587,
26,
489,
2974,
275,
741,
631,
1491,
9896,
63,
3124,
61,
489,
730,
275,
741,
631,
59,
9896,
63,
3124,
435,
413,
61,
489,
340,
1228,
8,
466,
12,
513,
304,
267,
702,
730,
59,
16,
61,
11800,
22051,
2,
267,
730,
275,
2008,
8,
466,
9,
267,
367,
15686,
315,
730,
59,
17,
10688,
288,
2943,
14,
740,
8,
804,
8,
10512,
12,
466,
430,
489,
741,
631,
275,
741,
631,
59,
9896,
63,
3124,
435,
499,
2938,
272,
367,
1242,
315,
2974,
26,
489,
702,
440,
1454,
63,
3669,
503,
1242,
14,
2460,
480,
18582,
489,
2397,
275,
3787,
8,
1053,
12,
730,
9,
489,
754,
14,
740,
8,
2373,
9,
523,
372,
754,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
rd37/horizon
|
openstack_dashboard/dashboards/project/instances/urls.py
|
7
|
1957
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2012 Nebula, Inc.
#
# 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 django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
from openstack_dashboard.dashboards.project.instances import views
INSTANCES = r'^(?P<instance_id>[^/]+)/%s$'
INSTANCES_KEYPAIR = r'^(?P<instance_id>[^/]+)/(?P<keypair_name>[^/]+)/%s$'
VIEW_MOD = 'openstack_dashboard.dashboards.project.instances.views'
urlpatterns = patterns(VIEW_MOD,
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^launch$', views.LaunchInstanceView.as_view(), name='launch'),
url(r'^(?P<instance_id>[^/]+)/$',
views.DetailView.as_view(), name='detail'),
url(INSTANCES % 'update', views.UpdateView.as_view(), name='update'),
url(INSTANCES % 'rebuild', views.RebuildView.as_view(), name='rebuild'),
url(INSTANCES % 'console', 'console', name='console'),
url(INSTANCES % 'vnc', 'vnc', name='vnc'),
url(INSTANCES % 'spice', 'spice', name='spice'),
url(INSTANCES % 'rdp', 'rdp', name='rdp'),
url(INSTANCES % 'resize', views.ResizeView.as_view(), name='resize'),
url(INSTANCES_KEYPAIR % 'decryptpassword',
views.DecryptPasswordView.as_view(), name='decryptpassword'),
)
|
apache-2.0
|
[
3,
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
1898,
6029,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
1898,
6029,
653,
2871,
7586,
12,
3277,
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,
199,
504,
1639,
14,
2190,
14,
3603,
492,
7970,
221,
327,
8151,
199,
504,
1639,
14,
2190,
14,
3603,
492,
1166,
221,
327,
8151,
199,
199,
504,
13869,
63,
9743,
14,
30424,
14,
1715,
14,
5990,
492,
6858,
421,
199,
7834,
879,
16734,
275,
519,
24550,
48,
28,
842,
63,
344,
26906,
2447,
5,
83,
12913,
199,
7834,
879,
16734,
63,
3078,
28263,
275,
519,
24550,
48,
28,
842,
63,
344,
26906,
2447,
2229,
48,
28,
19263,
63,
354,
26906,
2447,
5,
83,
12913,
199,
12058,
63,
8816,
275,
283,
8512,
63,
9743,
14,
30424,
14,
1715,
14,
5990,
14,
4196,
7,
421,
199,
20050,
275,
7970,
8,
12058,
63,
8816,
12,
272,
1166,
8,
82,
4289,
4268,
6858,
14,
2681,
2768,
14,
305,
63,
1345,
1062,
536,
534,
1080,
659,
272,
1166,
8,
82,
4289,
9850,
4268,
6858,
14,
18543,
3244,
2768,
14,
305,
63,
1345,
1062,
536,
534,
9850,
659,
272,
1166,
8,
82,
24550,
48,
28,
842,
63,
344,
26906,
2447,
4268,
267,
6858,
14,
28539,
14,
305,
63,
1345,
1062,
536,
534,
5506,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
873,
297,
6858,
14,
4152,
2768,
14,
305,
63,
1345,
1062,
536,
534,
873,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
19278,
297,
6858,
14,
497,
1506,
2768,
14,
305,
63,
1345,
1062,
536,
534,
19278,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
6614,
297,
283,
6614,
297,
536,
534,
6614,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
24093,
297,
283,
24093,
297,
536,
534,
24093,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
681,
1885,
297,
283,
681,
1885,
297,
536,
534,
681,
1885,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
82,
5780,
297,
283,
82,
5780,
297,
536,
534,
82,
5780,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
8709,
297,
6858,
14,
24559,
2768,
14,
305,
63,
1345,
1062,
536,
534,
8709,
659,
272,
1166,
8,
7834,
879,
16734,
63,
3078,
28263,
450,
283,
15682,
2060,
297,
267,
6858,
14,
8584,
13656,
6139,
2768,
14,
305,
63,
1345,
1062,
536,
534,
15682,
2060,
659,
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
] |
[
6695,
26,
20849,
29,
20,
20105,
29,
20,
25966,
29,
20,
199,
199,
3,
1898,
6029,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
1898,
6029,
653,
2871,
7586,
12,
3277,
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,
199,
504,
1639,
14,
2190,
14,
3603,
492,
7970,
221,
327,
8151,
199,
504,
1639,
14,
2190,
14,
3603,
492,
1166,
221,
327,
8151,
199,
199,
504,
13869,
63,
9743,
14,
30424,
14,
1715,
14,
5990,
492,
6858,
421,
199,
7834,
879,
16734,
275,
519,
24550,
48,
28,
842,
63,
344,
26906,
2447,
5,
83,
12913,
199,
7834,
879,
16734,
63,
3078,
28263,
275,
519,
24550,
48,
28,
842,
63,
344,
26906,
2447,
2229,
48,
28,
19263,
63,
354,
26906,
2447,
5,
83,
12913,
199,
12058,
63,
8816,
275,
283,
8512,
63,
9743,
14,
30424,
14,
1715,
14,
5990,
14,
4196,
7,
421,
199,
20050,
275,
7970,
8,
12058,
63,
8816,
12,
272,
1166,
8,
82,
4289,
4268,
6858,
14,
2681,
2768,
14,
305,
63,
1345,
1062,
536,
534,
1080,
659,
272,
1166,
8,
82,
4289,
9850,
4268,
6858,
14,
18543,
3244,
2768,
14,
305,
63,
1345,
1062,
536,
534,
9850,
659,
272,
1166,
8,
82,
24550,
48,
28,
842,
63,
344,
26906,
2447,
4268,
267,
6858,
14,
28539,
14,
305,
63,
1345,
1062,
536,
534,
5506,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
873,
297,
6858,
14,
4152,
2768,
14,
305,
63,
1345,
1062,
536,
534,
873,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
19278,
297,
6858,
14,
497,
1506,
2768,
14,
305,
63,
1345,
1062,
536,
534,
19278,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
6614,
297,
283,
6614,
297,
536,
534,
6614,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
24093,
297,
283,
24093,
297,
536,
534,
24093,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
681,
1885,
297,
283,
681,
1885,
297,
536,
534,
681,
1885,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
82,
5780,
297,
283,
82,
5780,
297,
536,
534,
82,
5780,
659,
272,
1166,
8,
7834,
879,
16734,
450,
283,
8709,
297,
6858,
14,
24559,
2768,
14,
305,
63,
1345,
1062,
536,
534,
8709,
659,
272,
1166,
8,
7834,
879,
16734,
63,
3078,
28263,
450,
283,
15682,
2060,
297,
267,
6858,
14,
8584,
13656,
6139,
2768,
14,
305,
63,
1345,
1062,
536,
534,
15682,
2060,
659,
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,
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,
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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
] |
isht3/zulip
|
zerver/views/user_settings.py
|
7
|
12505
|
from __future__ import absolute_import
from typing import Optional, Any
from typing import Text
from django.utils.translation import ugettext as _
from django.conf import settings
from django.contrib.auth import authenticate, update_session_auth_hash
from django.http import HttpRequest, HttpResponse
from zerver.decorator import authenticated_json_post_view, has_request_variables, REQ
from zerver.lib.actions import do_change_password, \
do_change_full_name, do_change_enable_desktop_notifications, \
do_change_enter_sends, do_change_enable_sounds, \
do_change_enable_offline_email_notifications, do_change_enable_digest_emails, \
do_change_enable_offline_push_notifications, do_change_enable_online_push_notifications, \
do_change_default_desktop_notifications, do_change_autoscroll_forever, \
do_change_enable_stream_desktop_notifications, do_change_enable_stream_sounds, \
do_regenerate_api_key, do_change_avatar_source, do_change_twenty_four_hour_time, \
do_change_left_side_userlist, do_change_default_language, \
do_change_pm_content_in_desktop_notifications
from zerver.lib.avatar import avatar_url
from zerver.lib.i18n import get_available_language_codes
from zerver.lib.response import json_success, json_error
from zerver.lib.upload import upload_avatar_image
from zerver.lib.validator import check_bool, check_string
from zerver.lib.request import JsonableError
from zerver.models import UserProfile, Realm, name_changes_disabled
@has_request_variables
def json_change_ui_settings(request, user_profile,
autoscroll_forever=REQ(validator=check_bool,
default=None),
default_desktop_notifications=REQ(validator=check_bool,
default=None)):
# type: (HttpRequest, UserProfile, Optional[bool], Optional[bool]) -> HttpResponse
result = {}
if autoscroll_forever is not None and \
user_profile.autoscroll_forever != autoscroll_forever:
do_change_autoscroll_forever(user_profile, autoscroll_forever)
result['autoscroll_forever'] = autoscroll_forever
if default_desktop_notifications is not None and \
user_profile.default_desktop_notifications != default_desktop_notifications:
do_change_default_desktop_notifications(user_profile, default_desktop_notifications)
result['default_desktop_notifications'] = default_desktop_notifications
return json_success(result)
@authenticated_json_post_view
@has_request_variables
def json_change_settings(request, user_profile,
full_name=REQ(default=""),
old_password=REQ(default=""),
new_password=REQ(default=""),
confirm_password=REQ(default="")):
# type: (HttpRequest, UserProfile, Text, Text, Text, Text) -> HttpResponse
if not (full_name or new_password):
return json_error(_("No new data supplied"))
if new_password != "" or confirm_password != "":
if new_password != confirm_password:
return json_error(_("New password must match confirmation password!"))
if not authenticate(username=user_profile.email, password=old_password):
return json_error(_("Wrong password!"))
do_change_password(user_profile, new_password)
# In Django 1.10, password changes invalidates sessions, see
# https://docs.djangoproject.com/en/1.10/topics/auth/default/#session-invalidation-on-password-change
# for details. To avoid this logging the user out of his own
# session (which would provide a confusing UX at best), we
# update the session hash here.
update_session_auth_hash(request, user_profile)
# We also save the session to the DB immediately to mitigate
# race conditions. In theory, there is still a race condition
# and to completely avoid it we will have to use some kind of
# mutex lock in `django.contrib.auth.get_user` where session
# is verified. To make that lock work we will have to control
# the AuthenticationMiddleware which is currently controlled
# by Django,
request.session.save()
result = {}
if user_profile.full_name != full_name and full_name.strip() != "":
if name_changes_disabled(user_profile.realm):
# Failingly silently is fine -- they can't do it through the UI, so
# they'd have to be trying to break the rules.
pass
else:
new_full_name = full_name.strip()
if len(new_full_name) > UserProfile.MAX_NAME_LENGTH:
return json_error(_("Name too long!"))
do_change_full_name(user_profile, new_full_name)
result['full_name'] = new_full_name
return json_success(result)
@has_request_variables
def update_display_settings_backend(request, user_profile,
twenty_four_hour_time=REQ(validator=check_bool, default=None),
default_language=REQ(validator=check_string, default=None),
left_side_userlist=REQ(validator=check_bool, default=None)):
# type: (HttpRequest, UserProfile, Optional[bool], Optional[str], Optional[bool]) -> HttpResponse
if (default_language is not None and
default_language not in get_available_language_codes()):
raise JsonableError(_("Invalid language '%s'" % (default_language,)))
result = {} # type: Dict[str, Any]
if (default_language is not None and
user_profile.default_language != default_language):
do_change_default_language(user_profile, default_language)
result['default_language'] = default_language
elif (twenty_four_hour_time is not None and
user_profile.twenty_four_hour_time != twenty_four_hour_time):
do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time)
result['twenty_four_hour_time'] = twenty_four_hour_time
elif (left_side_userlist is not None and
user_profile.left_side_userlist != left_side_userlist):
do_change_left_side_userlist(user_profile, left_side_userlist)
result['left_side_userlist'] = left_side_userlist
return json_success(result)
@has_request_variables
def json_change_notify_settings(request, user_profile,
enable_stream_desktop_notifications=REQ(validator=check_bool,
default=None),
enable_stream_sounds=REQ(validator=check_bool,
default=None),
enable_desktop_notifications=REQ(validator=check_bool,
default=None),
enable_sounds=REQ(validator=check_bool,
default=None),
enable_offline_email_notifications=REQ(validator=check_bool,
default=None),
enable_offline_push_notifications=REQ(validator=check_bool,
default=None),
enable_online_push_notifications=REQ(validator=check_bool,
default=None),
enable_digest_emails=REQ(validator=check_bool,
default=None),
pm_content_in_desktop_notifications=REQ(validator=check_bool,
default=None)):
# type: (HttpRequest, UserProfile, Optional[bool], Optional[bool], Optional[bool], Optional[bool], Optional[bool], Optional[bool], Optional[bool], Optional[bool], Optional[bool]) -> HttpResponse
result = {}
# Stream notification settings.
if enable_stream_desktop_notifications is not None and \
user_profile.enable_stream_desktop_notifications != enable_stream_desktop_notifications:
do_change_enable_stream_desktop_notifications(
user_profile, enable_stream_desktop_notifications)
result['enable_stream_desktop_notifications'] = enable_stream_desktop_notifications
if enable_stream_sounds is not None and \
user_profile.enable_stream_sounds != enable_stream_sounds:
do_change_enable_stream_sounds(user_profile, enable_stream_sounds)
result['enable_stream_sounds'] = enable_stream_sounds
# PM and @-mention settings.
if enable_desktop_notifications is not None and \
user_profile.enable_desktop_notifications != enable_desktop_notifications:
do_change_enable_desktop_notifications(user_profile, enable_desktop_notifications)
result['enable_desktop_notifications'] = enable_desktop_notifications
if enable_sounds is not None and \
user_profile.enable_sounds != enable_sounds:
do_change_enable_sounds(user_profile, enable_sounds)
result['enable_sounds'] = enable_sounds
if enable_offline_email_notifications is not None and \
user_profile.enable_offline_email_notifications != enable_offline_email_notifications:
do_change_enable_offline_email_notifications(user_profile, enable_offline_email_notifications)
result['enable_offline_email_notifications'] = enable_offline_email_notifications
if enable_offline_push_notifications is not None and \
user_profile.enable_offline_push_notifications != enable_offline_push_notifications:
do_change_enable_offline_push_notifications(user_profile, enable_offline_push_notifications)
result['enable_offline_push_notifications'] = enable_offline_push_notifications
if enable_online_push_notifications is not None and \
user_profile.enable_online_push_notifications != enable_online_push_notifications:
do_change_enable_online_push_notifications(user_profile, enable_online_push_notifications)
result['enable_online_push_notifications'] = enable_online_push_notifications
if enable_digest_emails is not None and \
user_profile.enable_digest_emails != enable_digest_emails:
do_change_enable_digest_emails(user_profile, enable_digest_emails)
result['enable_digest_emails'] = enable_digest_emails
if pm_content_in_desktop_notifications is not None and \
user_profile.pm_content_in_desktop_notifications != pm_content_in_desktop_notifications:
do_change_pm_content_in_desktop_notifications(user_profile, pm_content_in_desktop_notifications)
result['pm_content_in_desktop_notifications'] = pm_content_in_desktop_notifications
return json_success(result)
def set_avatar_backend(request, user_profile):
# type: (HttpRequest, UserProfile) -> HttpResponse
if len(request.FILES) != 1:
return json_error(_("You must upload exactly one avatar."))
user_file = list(request.FILES.values())[0]
upload_avatar_image(user_file, user_profile, user_profile.email)
do_change_avatar_source(user_profile, UserProfile.AVATAR_FROM_USER)
user_avatar_url = avatar_url(user_profile)
json_result = dict(
avatar_url = user_avatar_url
)
return json_success(json_result)
def delete_avatar_backend(request, user_profile):
# type: (HttpRequest, UserProfile) -> HttpResponse
do_change_avatar_source(user_profile, UserProfile.AVATAR_FROM_GRAVATAR)
gravatar_url = avatar_url(user_profile)
json_result = dict(
avatar_url = gravatar_url
)
return json_success(json_result)
@has_request_variables
def regenerate_api_key(request, user_profile):
# type: (HttpRequest, UserProfile) -> HttpResponse
do_regenerate_api_key(user_profile)
json_result = dict(
api_key = user_profile.api_key
)
return json_success(json_result)
@has_request_variables
def change_enter_sends(request, user_profile,
enter_sends=REQ(validator=check_bool)):
# type: (HttpRequest, UserProfile, bool) -> HttpResponse
do_change_enter_sends(user_profile, enter_sends)
return json_success()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
14090,
492,
4879,
12,
6184,
199,
504,
14090,
492,
4516,
199,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
492,
12895,
12,
1678,
63,
1730,
63,
1178,
63,
2227,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
199,
199,
504,
19959,
14,
11547,
492,
15082,
63,
1001,
63,
1932,
63,
1345,
12,
965,
63,
1069,
63,
3669,
12,
5363,
49,
199,
504,
19959,
14,
773,
14,
3723,
492,
886,
63,
1461,
63,
2060,
12,
971,
272,
886,
63,
1461,
63,
2861,
63,
354,
12,
886,
63,
1461,
63,
4296,
63,
14487,
63,
12782,
12,
971,
272,
886,
63,
1461,
63,
4200,
63,
2464,
795,
12,
886,
63,
1461,
63,
4296,
63,
14990,
83,
12,
971,
272,
886,
63,
1461,
63,
4296,
63,
18430,
63,
2123,
63,
12782,
12,
886,
63,
1461,
63,
4296,
63,
5671,
63,
14170,
12,
971,
272,
886,
63,
1461,
63,
4296,
63,
18430,
63,
5335,
63,
12782,
12,
886,
63,
1461,
63,
4296,
63,
15178,
63,
5335,
63,
12782,
12,
971,
272,
886,
63,
1461,
63,
885,
63,
14487,
63,
12782,
12,
886,
63,
1461,
63,
2495,
6755,
63,
21327,
12,
971,
272,
886,
63,
1461,
63,
4296,
63,
1745,
63,
14487,
63,
12782,
12,
886,
63,
1461,
63,
4296,
63,
1745,
63,
14990,
83,
12,
971,
272,
886,
63,
1135,
22978,
63,
1246,
63,
498,
12,
886,
63,
1461,
63,
14584,
63,
1365,
12,
886,
63,
1461,
63,
8122,
287,
369,
63,
13672,
63,
5180,
63,
521,
12,
971,
272,
886,
63,
1461,
63,
3039,
63,
2441,
63,
751,
513,
12,
886,
63,
1461,
63,
885,
63,
3671,
12,
971,
272,
886,
63,
1461,
63,
7073,
63,
1317,
63,
262,
63,
14487,
63,
12782,
199,
504,
19959,
14,
773,
14,
14584,
492,
20913,
63,
633,
199,
504,
19959,
14,
773,
14,
73,
1085,
78,
492,
664,
63,
4561,
63,
3671,
63,
6021,
199,
504,
19959,
14,
773,
14,
1310,
492,
2022,
63,
3742,
12,
2022,
63,
705,
199,
504,
19959,
14,
773,
14,
5064,
492,
5802,
63,
14584,
63,
1569,
199,
504,
19959,
14,
773,
14,
11034,
492,
1104,
63,
2245,
12,
1104,
63,
875,
199,
504,
19959,
14,
773,
14,
1069,
492,
14587,
461,
547,
199,
504,
19959,
14,
992,
492,
19037,
12,
27715,
12,
536,
63,
6627,
63,
7011,
199,
199,
32,
1989,
63,
1069,
63,
3669,
199,
318,
2022,
63,
1461,
63,
1907,
63,
1751,
8,
1069,
12,
922,
63,
2913,
12,
1169,
2599,
6755,
63,
21327,
29,
14583,
8,
11034,
29,
1074,
63,
2245,
12,
8962,
849,
29,
403,
395,
1169,
849,
63,
14487,
63,
12782,
29,
14583,
8,
11034,
29,
1074,
63,
2245,
12,
16854,
849,
29,
403,
2298,
272,
327,
730,
26,
334,
10441,
12,
19037,
12,
4879,
59,
2245,
467,
4879,
59,
2245,
566,
1035,
6183,
339,
754,
275,
1052,
339,
340,
2599,
6755,
63,
21327,
365,
440,
488,
436,
971,
288,
922,
63,
2913,
14,
2495,
6755,
63,
21327,
1137,
2599,
6755,
63,
21327,
26,
267,
886,
63,
1461,
63,
2495,
6755,
63,
21327,
8,
751,
63,
2913,
12,
2599,
6755,
63,
21327,
9,
267,
754,
459,
2495,
6755,
63,
21327,
418,
275,
2599,
6755,
63,
21327,
339,
340,
849,
63,
14487,
63,
12782,
365,
440,
488,
436,
971,
288,
922,
63,
2913,
14,
885,
63,
14487,
63,
12782,
1137,
849,
63,
14487,
63,
12782,
26,
267,
886,
63,
1461,
63,
885,
63,
14487,
63,
12782,
8,
751,
63,
2913,
12,
849,
63,
14487,
63,
12782,
9,
267,
754,
459,
885,
63,
14487,
63,
12782,
418,
275,
849,
63,
14487,
63,
12782,
339,
372,
2022,
63,
3742,
8,
1099,
9,
199,
199,
32,
12177,
63,
1001,
63,
1932,
63,
1345,
199,
32,
1989,
63,
1069,
63,
3669,
199,
318,
2022,
63,
1461,
63,
1751,
8,
1069,
12,
922,
63,
2913,
12,
586,
2615,
63,
354,
29,
14583,
8,
885,
9287,
395,
586,
2269,
63,
2060,
29,
14583,
8,
885,
9287,
395,
586,
892,
63,
2060,
29,
14583,
8,
885,
9287,
395,
586,
12679,
63,
2060,
29,
14583,
8,
885,
9287,
2298,
272,
327,
730,
26,
334,
10441,
12,
19037,
12,
4516,
12,
4516,
12,
4516,
12,
4516,
9,
1035,
6183,
272,
340,
440,
334,
2861,
63,
354,
503,
892,
63,
2060,
304,
267,
372,
2022,
63,
705,
6115,
1944,
892,
666,
6841,
2237,
339,
340,
892,
63,
2060,
1137,
3087,
503,
12679,
63,
2060,
1137,
10812,
267,
340,
892,
63,
2060,
1137,
12679,
63,
2060,
26,
288,
372,
2022,
63,
705,
6115,
4665,
2505,
1471,
1336,
18791,
2505,
1,
2237,
267,
340,
440,
12895,
8,
2473,
29,
751,
63,
2913,
14,
2123,
12,
2505,
29,
1753,
63,
2060,
304,
288,
372,
2022,
63,
705,
6115,
14858,
2505,
1,
2237,
267,
886,
63,
1461,
63,
2060,
8,
751,
63,
2913,
12,
892,
63,
2060,
9,
267,
327,
1010,
5634,
413,
14,
709,
12,
2505,
4493,
3866,
2335,
12184,
12,
1937,
267,
327,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
17,
14,
709,
15,
11299,
15,
1178,
15,
885,
12645,
1730,
13,
3197,
425,
13,
265,
13,
2060,
13,
1461,
267,
327,
367,
2436,
14,
4005,
5126,
642,
2050,
314,
922,
734,
402,
17049,
5705,
267,
327,
2351,
334,
6777,
3955,
5647,
282,
3743,
4941,
738,
56,
737,
5526,
395,
781,
267,
327,
1678,
314,
2351,
2631,
2348,
14,
267,
1678,
63,
1730,
63,
1178,
63,
2227,
8,
1069,
12,
922,
63,
2913,
9,
267,
327,
2136,
2597,
3354,
314,
2351,
370,
314,
6249,
9939,
370,
333,
5277,
3237,
267,
327,
21209,
3704,
14,
1010,
30629,
12,
2337,
365,
5139,
282,
21209,
5558,
267,
327,
436,
370,
14793,
5126,
652,
781,
911,
1172,
370,
675,
2005,
4928,
402,
267,
327,
333,
18173,
4650,
315,
658,
1176,
14,
2828,
14,
1178,
14,
362,
63,
751,
64,
2382,
2351,
267,
327,
365,
16317,
14,
4005,
1852,
626,
4650,
1736,
781,
911,
1172,
370,
3304,
267,
327,
314,
15995,
6608,
1314,
365,
5544,
22284,
267,
327,
701,
5634,
12,
267,
1056,
14,
1730,
14,
2117,
342,
339,
754,
275,
1052,
272,
340,
922,
63,
2913
] |
[
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
14090,
492,
4879,
12,
6184,
199,
504,
14090,
492,
4516,
199,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
465,
485,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
1178,
492,
12895,
12,
1678,
63,
1730,
63,
1178,
63,
2227,
199,
504,
1639,
14,
1014,
492,
20730,
12,
6183,
199,
199,
504,
19959,
14,
11547,
492,
15082,
63,
1001,
63,
1932,
63,
1345,
12,
965,
63,
1069,
63,
3669,
12,
5363,
49,
199,
504,
19959,
14,
773,
14,
3723,
492,
886,
63,
1461,
63,
2060,
12,
971,
272,
886,
63,
1461,
63,
2861,
63,
354,
12,
886,
63,
1461,
63,
4296,
63,
14487,
63,
12782,
12,
971,
272,
886,
63,
1461,
63,
4200,
63,
2464,
795,
12,
886,
63,
1461,
63,
4296,
63,
14990,
83,
12,
971,
272,
886,
63,
1461,
63,
4296,
63,
18430,
63,
2123,
63,
12782,
12,
886,
63,
1461,
63,
4296,
63,
5671,
63,
14170,
12,
971,
272,
886,
63,
1461,
63,
4296,
63,
18430,
63,
5335,
63,
12782,
12,
886,
63,
1461,
63,
4296,
63,
15178,
63,
5335,
63,
12782,
12,
971,
272,
886,
63,
1461,
63,
885,
63,
14487,
63,
12782,
12,
886,
63,
1461,
63,
2495,
6755,
63,
21327,
12,
971,
272,
886,
63,
1461,
63,
4296,
63,
1745,
63,
14487,
63,
12782,
12,
886,
63,
1461,
63,
4296,
63,
1745,
63,
14990,
83,
12,
971,
272,
886,
63,
1135,
22978,
63,
1246,
63,
498,
12,
886,
63,
1461,
63,
14584,
63,
1365,
12,
886,
63,
1461,
63,
8122,
287,
369,
63,
13672,
63,
5180,
63,
521,
12,
971,
272,
886,
63,
1461,
63,
3039,
63,
2441,
63,
751,
513,
12,
886,
63,
1461,
63,
885,
63,
3671,
12,
971,
272,
886,
63,
1461,
63,
7073,
63,
1317,
63,
262,
63,
14487,
63,
12782,
199,
504,
19959,
14,
773,
14,
14584,
492,
20913,
63,
633,
199,
504,
19959,
14,
773,
14,
73,
1085,
78,
492,
664,
63,
4561,
63,
3671,
63,
6021,
199,
504,
19959,
14,
773,
14,
1310,
492,
2022,
63,
3742,
12,
2022,
63,
705,
199,
504,
19959,
14,
773,
14,
5064,
492,
5802,
63,
14584,
63,
1569,
199,
504,
19959,
14,
773,
14,
11034,
492,
1104,
63,
2245,
12,
1104,
63,
875,
199,
504,
19959,
14,
773,
14,
1069,
492,
14587,
461,
547,
199,
504,
19959,
14,
992,
492,
19037,
12,
27715,
12,
536,
63,
6627,
63,
7011,
199,
199,
32,
1989,
63,
1069,
63,
3669,
199,
318,
2022,
63,
1461,
63,
1907,
63,
1751,
8,
1069,
12,
922,
63,
2913,
12,
1169,
2599,
6755,
63,
21327,
29,
14583,
8,
11034,
29,
1074,
63,
2245,
12,
8962,
849,
29,
403,
395,
1169,
849,
63,
14487,
63,
12782,
29,
14583,
8,
11034,
29,
1074,
63,
2245,
12,
16854,
849,
29,
403,
2298,
272,
327,
730,
26,
334,
10441,
12,
19037,
12,
4879,
59,
2245,
467,
4879,
59,
2245,
566,
1035,
6183,
339,
754,
275,
1052,
339,
340,
2599,
6755,
63,
21327,
365,
440,
488,
436,
971,
288,
922,
63,
2913,
14,
2495,
6755,
63,
21327,
1137,
2599,
6755,
63,
21327,
26,
267,
886,
63,
1461,
63,
2495,
6755,
63,
21327,
8,
751,
63,
2913,
12,
2599,
6755,
63,
21327,
9,
267,
754,
459,
2495,
6755,
63,
21327,
418,
275,
2599,
6755,
63,
21327,
339,
340,
849,
63,
14487,
63,
12782,
365,
440,
488,
436,
971,
288,
922,
63,
2913,
14,
885,
63,
14487,
63,
12782,
1137,
849,
63,
14487,
63,
12782,
26,
267,
886,
63,
1461,
63,
885,
63,
14487,
63,
12782,
8,
751,
63,
2913,
12,
849,
63,
14487,
63,
12782,
9,
267,
754,
459,
885,
63,
14487,
63,
12782,
418,
275,
849,
63,
14487,
63,
12782,
339,
372,
2022,
63,
3742,
8,
1099,
9,
199,
199,
32,
12177,
63,
1001,
63,
1932,
63,
1345,
199,
32,
1989,
63,
1069,
63,
3669,
199,
318,
2022,
63,
1461,
63,
1751,
8,
1069,
12,
922,
63,
2913,
12,
586,
2615,
63,
354,
29,
14583,
8,
885,
9287,
395,
586,
2269,
63,
2060,
29,
14583,
8,
885,
9287,
395,
586,
892,
63,
2060,
29,
14583,
8,
885,
9287,
395,
586,
12679,
63,
2060,
29,
14583,
8,
885,
9287,
2298,
272,
327,
730,
26,
334,
10441,
12,
19037,
12,
4516,
12,
4516,
12,
4516,
12,
4516,
9,
1035,
6183,
272,
340,
440,
334,
2861,
63,
354,
503,
892,
63,
2060,
304,
267,
372,
2022,
63,
705,
6115,
1944,
892,
666,
6841,
2237,
339,
340,
892,
63,
2060,
1137,
3087,
503,
12679,
63,
2060,
1137,
10812,
267,
340,
892,
63,
2060,
1137,
12679,
63,
2060,
26,
288,
372,
2022,
63,
705,
6115,
4665,
2505,
1471,
1336,
18791,
2505,
1,
2237,
267,
340,
440,
12895,
8,
2473,
29,
751,
63,
2913,
14,
2123,
12,
2505,
29,
1753,
63,
2060,
304,
288,
372,
2022,
63,
705,
6115,
14858,
2505,
1,
2237,
267,
886,
63,
1461,
63,
2060,
8,
751,
63,
2913,
12,
892,
63,
2060,
9,
267,
327,
1010,
5634,
413,
14,
709,
12,
2505,
4493,
3866,
2335,
12184,
12,
1937,
267,
327,
4178,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
17,
14,
709,
15,
11299,
15,
1178,
15,
885,
12645,
1730,
13,
3197,
425,
13,
265,
13,
2060,
13,
1461,
267,
327,
367,
2436,
14,
4005,
5126,
642,
2050,
314,
922,
734,
402,
17049,
5705,
267,
327,
2351,
334,
6777,
3955,
5647,
282,
3743,
4941,
738,
56,
737,
5526,
395,
781,
267,
327,
1678,
314,
2351,
2631,
2348,
14,
267,
1678,
63,
1730,
63,
1178,
63,
2227,
8,
1069,
12,
922,
63,
2913,
9,
267,
327,
2136,
2597,
3354,
314,
2351,
370,
314,
6249,
9939,
370,
333,
5277,
3237,
267,
327,
21209,
3704,
14,
1010,
30629,
12,
2337,
365,
5139,
282,
21209,
5558,
267,
327,
436,
370,
14793,
5126,
652,
781,
911,
1172,
370,
675,
2005,
4928,
402,
267,
327,
333,
18173,
4650,
315,
658,
1176,
14,
2828,
14,
1178,
14,
362,
63,
751,
64,
2382,
2351,
267,
327,
365,
16317,
14,
4005,
1852,
626,
4650,
1736,
781,
911,
1172,
370,
3304,
267,
327,
314,
15995,
6608,
1314,
365,
5544,
22284,
267,
327,
701,
5634,
12,
267,
1056,
14,
1730,
14,
2117,
342,
339,
754,
275,
1052,
272,
340,
922,
63,
2913,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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
194
|
1290
|
#!/usr/bin/env python
# Copyright 2015 The Kubernetes Authors.
#
# 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.
# Script to print out PR info in release note format.
import json
import sys
import urllib2
PULLQUERY=("https://api.github.com/repos/"
"kubernetes/kubernetes/pulls/{pull}")
LOGIN="login"
TITLE="title"
USER="user"
def print_pulls(pulls):
for pull in pulls:
d = json.loads(urllib2.urlopen(PULLQUERY.format(pull=pull)).read())
print "* {title} #{pull} ({author})".format(
title=d[TITLE], pull=pull, author=d[USER][LOGIN])
if __name__ == "__main__":
if len(sys.argv) < 2:
print ("Usage: {cmd} <pulls>...: Prints out short " +
"markdown description for PRs appropriate for release notes.")
sys.exit(1)
print_pulls(sys.argv[1:])
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
6900,
710,
28723,
6642,
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,
3,
14914,
370,
870,
734,
12218,
2256,
315,
4683,
5317,
1475,
14,
199,
199,
646,
2022,
199,
646,
984,
199,
646,
4011,
18,
199,
199,
48,
3785,
11938,
15387,
2859,
921,
1246,
14,
5031,
14,
957,
15,
11857,
6687,
1779,
298,
17422,
15,
17422,
15,
80,
13072,
5321,
9302,
15412,
199,
17208,
628,
2886,
2,
199,
19091,
628,
1213,
2,
199,
3791,
628,
751,
2,
199,
199,
318,
870,
63,
80,
13072,
8,
80,
13072,
304,
523,
367,
10299,
315,
299,
13072,
26,
272,
366,
275,
2022,
14,
3640,
8,
4078,
18,
14,
10890,
8,
48,
3785,
11938,
14,
908,
8,
9302,
29,
9302,
4992,
739,
1012,
272,
870,
8969,
469,
1213,
93,
327,
91,
9302,
93,
11459,
2502,
25974,
908,
8,
267,
2538,
29,
68,
59,
19091,
467,
10299,
29,
9302,
12,
4132,
29,
68,
59,
3791,
1527,
17208,
566,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
523,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
272,
870,
1689,
7692,
26,
469,
1760,
93,
665,
80,
13072,
30,
1396,
26,
9101,
83,
734,
3974,
298,
435,
1779,
298,
15653,
1369,
367,
12218,
83,
5827,
367,
4683,
12681,
2685,
272,
984,
14,
2224,
8,
17,
9,
523,
870,
63,
80,
13072,
8,
1274,
14,
3020,
59,
17,
5728,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
6900,
710,
28723,
6642,
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,
3,
14914,
370,
870,
734,
12218,
2256,
315,
4683,
5317,
1475,
14,
199,
199,
646,
2022,
199,
646,
984,
199,
646,
4011,
18,
199,
199,
48,
3785,
11938,
15387,
2859,
921,
1246,
14,
5031,
14,
957,
15,
11857,
6687,
1779,
298,
17422,
15,
17422,
15,
80,
13072,
5321,
9302,
15412,
199,
17208,
628,
2886,
2,
199,
19091,
628,
1213,
2,
199,
3791,
628,
751,
2,
199,
199,
318,
870,
63,
80,
13072,
8,
80,
13072,
304,
523,
367,
10299,
315,
299,
13072,
26,
272,
366,
275,
2022,
14,
3640,
8,
4078,
18,
14,
10890,
8,
48,
3785,
11938,
14,
908,
8,
9302,
29,
9302,
4992,
739,
1012,
272,
870,
8969,
469,
1213,
93,
327,
91,
9302,
93,
11459,
2502,
25974,
908,
8,
267,
2538,
29,
68,
59,
19091,
467,
10299,
29,
9302,
12,
4132,
29,
68,
59,
3791,
1527,
17208,
566,
199,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
523,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
272,
870,
1689,
7692,
26,
469,
1760,
93,
665,
80,
13072,
30,
1396,
26,
9101,
83,
734,
3974,
298,
435,
1779,
298,
15653,
1369,
367,
12218,
83,
5827,
367,
4683,
12681,
2685,
272,
984,
14,
2224,
8,
17,
9,
523,
870,
63,
80,
13072,
8,
1274,
14,
3020,
59,
17,
5728,
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,
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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
] |
knehez/edx-platform
|
lms/djangoapps/teams/migrations/0001_initial.py
|
84
|
7593
|
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'CourseTeam'
db.create_table('teams_courseteam', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('team_id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)),
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
('is_active', self.gf('django.db.models.fields.BooleanField')(default=True)),
('course_id', self.gf('xmodule_django.models.CourseKeyField')(max_length=255, db_index=True)),
('topic_id', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=255, blank=True)),
('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
('description', self.gf('django.db.models.fields.CharField')(max_length=300)),
('country', self.gf('django_countries.fields.CountryField')(max_length=2, blank=True)),
('language', self.gf('student.models.LanguageField')(max_length=16, blank=True)),
))
db.send_create_signal('teams', ['CourseTeam'])
# Adding model 'CourseTeamMembership'
db.create_table('teams_courseteammembership', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
('team', self.gf('django.db.models.fields.related.ForeignKey')(related_name='membership', to=orm['teams.CourseTeam'])),
('date_joined', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
))
db.send_create_signal('teams', ['CourseTeamMembership'])
# Adding unique constraint on 'CourseTeamMembership', fields ['user', 'team']
db.create_unique('teams_courseteammembership', ['user_id', 'team_id'])
def backwards(self, orm):
# Removing unique constraint on 'CourseTeamMembership', fields ['user', 'team']
db.delete_unique('teams_courseteammembership', ['user_id', 'team_id'])
# Deleting model 'CourseTeam'
db.delete_table('teams_courseteam')
# Deleting model 'CourseTeamMembership'
db.delete_table('teams_courseteammembership')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'teams.courseteam': {
'Meta': {'object_name': 'CourseTeam'},
'country': ('django_countries.fields.CountryField', [], {'max_length': '2', 'blank': 'True'}),
'course_id': ('xmodule_django.models.CourseKeyField', [], {'max_length': '255', 'db_index': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'language': ('student.models.LanguageField', [], {'max_length': '16', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'team_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
'topic_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}),
'users': ('django.db.models.fields.related.ManyToManyField', [], {'db_index': 'True', 'related_name': "'teams'", 'symmetrical': 'False', 'through': "orm['teams.CourseTeamMembership']", 'to': "orm['auth.User']"})
},
'teams.courseteammembership': {
'Meta': {'unique_together': "(('user', 'team'),)", 'object_name': 'CourseTeamMembership'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'team': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'membership'", 'to': "orm['teams.CourseTeam']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
}
}
complete_apps = ['teams']
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
1208,
492,
2197,
63,
1208,
465,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
327,
12934,
1402,
283,
6979,
13126,
7,
267,
1592,
14,
981,
63,
1224,
360,
19048,
63,
1972,
5969,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
5969,
63,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2299,
1826,
288,
661,
354,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
288,
661,
374,
63,
2682,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
549,
1826,
288,
661,
1972,
63,
344,
297,
291,
14,
7102,
360,
14293,
63,
1176,
14,
992,
14,
18806,
792,
7533,
988,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
5746,
63,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
697,
63,
1080,
29,
549,
12,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
1826,
288,
661,
602,
63,
3966,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2495,
63,
2131,
63,
525,
29,
549,
12,
4596,
29,
549,
1826,
288,
661,
1802,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
5863,
1826,
288,
661,
6063,
297,
291,
14,
7102,
360,
1176,
63,
23598,
14,
955,
14,
17393,
792,
7533,
988,
63,
1267,
29,
18,
12,
4596,
29,
549,
1826,
288,
661,
3671,
297,
291,
14,
7102,
360,
5500,
14,
992,
14,
8493,
792,
7533,
988,
63,
1267,
29,
975,
12,
4596,
29,
549,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
19048,
297,
788,
6979,
13126,
1105,
398,
327,
12934,
1402,
283,
6979,
13126,
19480,
7,
267,
1592,
14,
981,
63,
1224,
360,
19048,
63,
1972,
5969,
13105,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
751,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
475,
29,
1025,
459,
1178,
14,
1899,
16607,
288,
661,
5969,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
13105,
297,
370,
29,
1025,
459,
19048,
14,
6979,
13126,
16607,
288,
661,
602,
63,
11806,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2495,
63,
2131,
63,
525,
29,
549,
12,
4596,
29,
549,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
19048,
297,
788,
6979,
13126,
19480,
1105,
398,
327,
12934,
3747,
5828,
641,
283,
6979,
13126,
19480,
297,
1504,
788,
751,
297,
283,
5969,
418,
267,
1592,
14,
981,
63,
3235,
360,
19048,
63,
1972,
5969,
13105,
297,
788,
751,
63,
344,
297,
283,
5969,
63,
344,
1105,
2378,
347,
8552,
8,
277,
12,
9813,
304,
267,
327,
29343,
3747,
5828,
641,
283,
6979,
13126,
19480,
297,
1504,
788,
751,
297,
283,
5969,
418,
267,
1592,
14,
1807,
63,
3235,
360,
19048,
63,
1972,
5969,
13105,
297,
788,
751,
63,
344,
297,
283,
5969,
63,
344,
1105,
398,
327,
15920,
1402,
283,
6979,
13126,
7,
267,
1592,
14,
1807,
63,
1224,
360,
19048,
63,
1972,
5969,
358,
398,
327,
15920,
1402,
283,
6979,
13126,
19480,
7,
267,
1592,
14,
1807,
63,
1224,
360,
19048,
63,
1972,
5969,
13105,
358,
2378,
1709,
275,
469,
267,
283,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
283,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
16111,
1317,
63,
466,
363,
571,
63,
1302,
297,
283,
1317,
63,
466,
363,
1238,
297,
283,
11879,
18106,
283,
3235,
63,
6314,
356,
9510,
1317,
63,
466,
297,
283,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
283,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2246,
63,
354,
356,
661
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
1208,
492,
2197,
63,
1208,
465,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
327,
12934,
1402,
283,
6979,
13126,
7,
267,
1592,
14,
981,
63,
1224,
360,
19048,
63,
1972,
5969,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
5969,
63,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
3235,
29,
549,
12,
1390,
63,
1267,
29,
2299,
1826,
288,
661,
354,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
2299,
1826,
288,
661,
374,
63,
2682,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
7533,
885,
29,
549,
1826,
288,
661,
1972,
63,
344,
297,
291,
14,
7102,
360,
14293,
63,
1176,
14,
992,
14,
18806,
792,
7533,
988,
63,
1267,
29,
2299,
12,
1592,
63,
1080,
29,
549,
1826,
288,
661,
5746,
63,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
697,
63,
1080,
29,
549,
12,
1390,
63,
1267,
29,
2299,
12,
4596,
29,
549,
1826,
288,
661,
602,
63,
3966,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2495,
63,
2131,
63,
525,
29,
549,
12,
4596,
29,
549,
1826,
288,
661,
1802,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
7533,
988,
63,
1267,
29,
5863,
1826,
288,
661,
6063,
297,
291,
14,
7102,
360,
1176,
63,
23598,
14,
955,
14,
17393,
792,
7533,
988,
63,
1267,
29,
18,
12,
4596,
29,
549,
1826,
288,
661,
3671,
297,
291,
14,
7102,
360,
5500,
14,
992,
14,
8493,
792,
7533,
988,
63,
1267,
29,
975,
12,
4596,
29,
549,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
19048,
297,
788,
6979,
13126,
1105,
398,
327,
12934,
1402,
283,
6979,
13126,
19480,
7,
267,
1592,
14,
981,
63,
1224,
360,
19048,
63,
1972,
5969,
13105,
297,
334,
288,
661,
344,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
7533,
3327,
63,
498,
29,
549,
1826,
288,
661,
751,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
475,
29,
1025,
459,
1178,
14,
1899,
16607,
288,
661,
5969,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2407,
63,
354,
534,
13105,
297,
370,
29,
1025,
459,
19048,
14,
6979,
13126,
16607,
288,
661,
602,
63,
11806,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2495,
63,
2131,
63,
525,
29,
549,
12,
4596,
29,
549,
1826,
267,
5082,
267,
1592,
14,
2254,
63,
981,
63,
4653,
360,
19048,
297,
788,
6979,
13126,
19480,
1105,
398,
327,
12934,
3747,
5828,
641,
283,
6979,
13126,
19480,
297,
1504,
788,
751,
297,
283,
5969,
418,
267,
1592,
14,
981,
63,
3235,
360,
19048,
63,
1972,
5969,
13105,
297,
788,
751,
63,
344,
297,
283,
5969,
63,
344,
1105,
2378,
347,
8552,
8,
277,
12,
9813,
304,
267,
327,
29343,
3747,
5828,
641,
283,
6979,
13126,
19480,
297,
1504,
788,
751,
297,
283,
5969,
418,
267,
1592,
14,
1807,
63,
3235,
360,
19048,
63,
1972,
5969,
13105,
297,
788,
751,
63,
344,
297,
283,
5969,
63,
344,
1105,
398,
327,
15920,
1402,
283,
6979,
13126,
7,
267,
1592,
14,
1807,
63,
1224,
360,
19048,
63,
1972,
5969,
358,
398,
327,
15920,
1402,
283,
6979,
13126,
19480,
7,
267,
1592,
14,
1807,
63,
1224,
360,
19048,
63,
1972,
5969,
13105,
358,
2378,
1709,
275,
469,
267,
283,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
283,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
16111,
1317,
63,
466,
363,
571,
63,
1302,
297,
283,
1317,
63,
466,
363,
1238,
297,
283,
11879,
18106,
283,
3235,
63,
6314,
356,
9510,
1317,
63,
466,
297,
283,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
283,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2246,
63,
354,
356,
661,
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,
1
] |
pastephens/pysal
|
pysal/spreg/ols_regimes.py
|
15
|
25402
|
"""
Ordinary Least Squares regression with regimes.
"""
__author__ = "Luc Anselin luc.anselin@asu.edu, Pedro V. Amaral pedro.amaral@asu.edu, Daniel Arribas-Bel darribas@asu.edu"
import regimes as REGI
import user_output as USER
import multiprocessing as mp
from ols import BaseOLS
from utils import set_warn, spbroadcast, RegressionProps_basic, RegressionPropsY, spdot
from robust import hac_multi
import summary_output as SUMMARY
import numpy as np
from platform import system
import scipy.sparse as SP
class OLS_Regimes(BaseOLS, REGI.Regimes_Frame, RegressionPropsY):
"""
Ordinary least squares with results and diagnostics.
Parameters
----------
y : array
nx1 array for dependent variable
x : array
Two dimensional array with n rows and one column for each
independent (exogenous) variable, excluding the constant
regimes : list
List of n values with the mapping of each
observation to a regime. Assumed to be aligned with 'x'.
w : pysal W object
Spatial weights object (required if running spatial
diagnostics)
robust : string
If 'white', then a White consistent estimator of the
variance-covariance matrix is given. If 'hac', then a
HAC consistent estimator of the variance-covariance
matrix is given. Default set to None.
gwk : pysal W object
Kernel spatial weights needed for HAC estimation. Note:
matrix must have ones along the main diagonal.
sig2n_k : boolean
If True, then use n-k to estimate sigma^2. If False, use n.
nonspat_diag : boolean
If True, then compute non-spatial diagnostics on
the regression.
spat_diag : boolean
If True, then compute Lagrange multiplier tests (requires
w). Note: see moran for further tests.
moran : boolean
If True, compute Moran's I on the residuals. Note:
requires spat_diag=True.
white_test : boolean
If True, compute White's specification robust test.
(requires nonspat_diag=True)
vm : boolean
If True, include variance-covariance matrix in summary
results
constant_regi: ['one', 'many']
Switcher controlling the constant term setup. It may take
the following values:
* 'one': a vector of ones is appended to x and held
constant across regimes
* 'many': a vector of ones is appended to x and considered
different per regime (default)
cols2regi : list, 'all'
Argument indicating whether each
column of x should be considered as different per regime
or held constant across regimes (False).
If a list, k booleans indicating for each variable the
option (True if one per regime, False to be held constant).
If 'all' (default), all the variables vary by regime.
regime_err_sep : boolean
If True, a separate regression is run for each regime.
cores : boolean
Specifies if multiprocessing is to be used
Default: no multiprocessing, cores = False
Note: Multiprocessing may not work on all platforms.
name_y : string
Name of dependent variable for use in output
name_x : list of strings
Names of independent variables for use in output
name_w : string
Name of weights matrix for use in output
name_gwk : string
Name of kernel weights matrix for use in output
name_ds : string
Name of dataset for use in output
name_regimes : string
Name of regime variable for use in the output
Attributes
----------
summary : string
Summary of regression results and diagnostics (note: use in
conjunction with the print command)
betas : array
kx1 array of estimated coefficients
u : array
nx1 array of residuals
predy : array
nx1 array of predicted y values
n : integer
Number of observations
k : integer
Number of variables for which coefficients are estimated
(including the constant)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
y : array
nx1 array for dependent variable
x : array
Two dimensional array with n rows and one column for each
independent (exogenous) variable, including the constant
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
robust : string
Adjustment for robust standard errors
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
mean_y : float
Mean of dependent variable
std_y : float
Standard deviation of dependent variable
vm : array
Variance covariance matrix (kxk)
r2 : float
R squared
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
ar2 : float
Adjusted R squared
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
utu : float
Sum of squared residuals
sig2 : float
Sigma squared used in computations
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
sig2ML : float
Sigma squared (maximum likelihood)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
f_stat : tuple
Statistic (float), p-value (float)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
logll : float
Log likelihood
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
aic : float
Akaike information criterion
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
schwarz : float
Schwarz information criterion
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
std_err : array
1xk array of standard errors of the betas
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
t_stat : list of tuples
t statistic; each tuple contains the pair (statistic,
p-value), where each is a float
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
mulColli : float
Multicollinearity condition number
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
jarque_bera : dictionary
'jb': Jarque-Bera statistic (float); 'pvalue': p-value
(float); 'df': degrees of freedom (int)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
breusch_pagan : dictionary
'bp': Breusch-Pagan statistic (float); 'pvalue': p-value
(float); 'df': degrees of freedom (int)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
koenker_bassett : dictionary
'kb': Koenker-Bassett statistic (float); 'pvalue':
p-value (float); 'df': degrees of freedom (int)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
white : dictionary
'wh': White statistic (float); 'pvalue': p-value (float);
'df': degrees of freedom (int)
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
lm_error : tuple
Lagrange multiplier test for spatial error model; tuple
contains the pair (statistic, p-value), where each is a
float
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
lm_lag : tuple
Lagrange multiplier test for spatial lag model; tuple
contains the pair (statistic, p-value), where each is a
float
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
rlm_error : tuple
Robust lagrange multiplier test for spatial error model;
tuple contains the pair (statistic, p-value), where each
is a float
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
rlm_lag : tuple
Robust lagrange multiplier test for spatial lag model;
tuple contains the pair (statistic, p-value), where each
is a float
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
lm_sarma : tuple
Lagrange multiplier test for spatial SARMA model; tuple
contains the pair (statistic, p-value), where each is a
float
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
moran_res : tuple
Moran's I for the residuals; tuple containing the triple
(Moran's I, standardized Moran's I, p-value)
name_y : string
Name of dependent variable for use in output
name_x : list of strings
Names of independent variables for use in output
name_w : string
Name of weights matrix for use in output
name_gwk : string
Name of kernel weights matrix for use in output
name_ds : string
Name of dataset for use in output
name_regimes : string
Name of regime variable for use in the output
title : string
Name of the regression method used
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
sig2n : float
Sigma squared (computed with n in the denominator)
sig2n_k : float
Sigma squared (computed with n-k in the denominator)
xtx : float
X'X
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
xtxi : float
(X'X)^-1
Only available in dictionary 'multi' when multiple regressions
(see 'multi' below for details)
regimes : list
List of n values with the mapping of each
observation to a regime. Assumed to be aligned with 'x'.
constant_regi: ['one', 'many']
Ignored if regimes=False. Constant option for regimes.
Switcher controlling the constant term setup. It may take
the following values:
* 'one': a vector of ones is appended to x and held
constant across regimes
* 'many': a vector of ones is appended to x and considered
different per regime
cols2regi : list, 'all'
Ignored if regimes=False. Argument indicating whether each
column of x should be considered as different per regime
or held constant across regimes (False).
If a list, k booleans indicating for each variable the
option (True if one per regime, False to be held constant).
If 'all', all the variables vary by regime.
regime_err_sep : boolean
If True, a separate regression is run for each regime.
kr : int
Number of variables/columns to be "regimized" or subject
to change by regime. These will result in one parameter
estimate by regime for each variable (i.e. nr parameters per
variable)
kf : int
Number of variables/columns to be considered fixed or
global across regimes and hence only obtain one parameter
estimate
nr : int
Number of different regimes in the 'regimes' list
multi : dictionary
Only available when multiple regressions are estimated,
i.e. when regime_err_sep=True and no variable is fixed
across regimes.
Contains all attributes of each individual regression
Examples
--------
>>> import numpy as np
>>> import pysal
Open data on NCOVR US County Homicides (3085 areas) using pysal.open().
This is the DBF associated with the NAT shapefile. Note that
pysal.open() also reads data in CSV format; since the actual class
requires data to be passed in as numpy arrays, the user can read their
data in using any method.
>>> db = pysal.open(pysal.examples.get_path("NAT.dbf"),'r')
Extract the HR90 column (homicide rates in 1990) from the DBF file and make it
the dependent variable for the regression. Note that PySAL requires this to be
an numpy array of shape (n, 1) as opposed to the also common shape of (n, )
that other packages accept.
>>> y_var = 'HR90'
>>> y = db.by_col(y_var)
>>> y = np.array(y).reshape(len(y), 1)
Extract UE90 (unemployment rate) and PS90 (population structure) vectors from
the DBF to be used as independent variables in the regression. Other variables
can be inserted by adding their names to x_var, such as x_var = ['Var1','Var2','...]
Note that PySAL requires this to be an nxj numpy array, where j is the
number of independent variables (not including a constant). By default
this model adds a vector of ones to the independent variables passed in.
>>> x_var = ['PS90','UE90']
>>> x = np.array([db.by_col(name) for name in x_var]).T
The different regimes in this data are given according to the North and
South dummy (SOUTH).
>>> r_var = 'SOUTH'
>>> regimes = db.by_col(r_var)
We can now run the regression and then have a summary of the output
by typing: olsr.summary
Alternatively, we can just check the betas and standard errors of the
parameters:
>>> olsr = OLS_Regimes(y, x, regimes, nonspat_diag=False, name_y=y_var, name_x=['PS90','UE90'], name_regimes=r_var, name_ds='NAT')
>>> olsr.betas
array([[ 0.39642899],
[ 0.65583299],
[ 0.48703937],
[ 5.59835 ],
[ 1.16210453],
[ 0.53163886]])
>>> np.sqrt(olsr.vm.diagonal())
array([ 0.24816345, 0.09662678, 0.03628629, 0.46894564, 0.21667395,
0.05945651])
>>> olsr.cols2regi
'all'
"""
def __init__(self, y, x, regimes,
w=None, robust=None, gwk=None, sig2n_k=True,
nonspat_diag=True, spat_diag=False, moran=False, white_test=False,
vm=False, constant_regi='many', cols2regi='all',
regime_err_sep=True, cores=False,
name_y=None, name_x=None, name_regimes=None,
name_w=None, name_gwk=None, name_ds=None):
n = USER.check_arrays(y, x)
USER.check_y(y, n)
USER.check_weights(w, y)
USER.check_robust(robust, gwk)
USER.check_spat_diag(spat_diag, w)
self.name_x_r = USER.set_name_x(name_x, x)
self.constant_regi = constant_regi
self.cols2regi = cols2regi
self.name_w = USER.set_name_w(name_w, w)
self.name_gwk = USER.set_name_w(name_gwk, gwk)
self.name_ds = USER.set_name_ds(name_ds)
self.name_y = USER.set_name_y(name_y)
self.name_regimes = USER.set_name_ds(name_regimes)
self.n = n
cols2regi = REGI.check_cols2regi(
constant_regi, cols2regi, x, add_cons=False)
self.regimes_set = REGI._get_regimes_set(regimes)
self.regimes = regimes
USER.check_regimes(self.regimes_set, self.n, x.shape[1])
if regime_err_sep == True and robust == 'hac':
set_warn(
self, "Error by regimes is incompatible with HAC estimation. Hence, error by regimes has been disabled for this model.")
regime_err_sep = False
self.regime_err_sep = regime_err_sep
if regime_err_sep == True and set(cols2regi) == set([True]) and constant_regi == 'many':
self.y = y
name_x = USER.set_name_x(name_x, x)
regi_ids = dict(
(r, list(np.where(np.array(regimes) == r)[0])) for r in self.regimes_set)
self._ols_regimes_multi(x, w, regi_ids, cores,
gwk, sig2n_k, robust, nonspat_diag, spat_diag, vm, name_x, moran, white_test)
else:
name_x = USER.set_name_x(name_x, x, constant=True)
x, self.name_x = REGI.Regimes_Frame.__init__(self, x,
regimes, constant_regi, cols2regi, name_x)
BaseOLS.__init__(
self, y=y, x=x, robust=robust, gwk=gwk, sig2n_k=sig2n_k)
if regime_err_sep == True and robust == None:
y2, x2 = REGI._get_weighted_var(
regimes, self.regimes_set, sig2n_k, self.u, y, x)
ols2 = BaseOLS(y=y2, x=x2, sig2n_k=sig2n_k)
RegressionProps_basic(self, betas=ols2.betas, vm=ols2.vm)
self.title = "ORDINARY LEAST SQUARES - REGIMES (Group-wise heteroskedasticity)"
nonspat_diag = None
set_warn(
self, "Residuals treated as homoskedastic for the purpose of diagnostics.")
else:
self.title = "ORDINARY LEAST SQUARES - REGIMES"
self.robust = USER.set_robust(robust)
self.chow = REGI.Chow(self)
SUMMARY.OLS(reg=self, vm=vm, w=w, nonspat_diag=nonspat_diag,
spat_diag=spat_diag, moran=moran, white_test=white_test, regimes=True)
def _ols_regimes_multi(self, x, w, regi_ids, cores,
gwk, sig2n_k, robust, nonspat_diag, spat_diag, vm, name_x, moran, white_test):
results_p = {}
"""
for r in self.regimes_set:
if system() == 'Windows':
is_win = True
results_p[r] = _work(*(self.y,x,w,regi_ids,r,robust,sig2n_k,self.name_ds,self.name_y,name_x,self.name_w,self.name_regimes))
else:
pool = mp.Pool(cores)
results_p[r] = pool.apply_async(_work,args=(self.y,x,w,regi_ids,r,robust,sig2n_k,self.name_ds,self.name_y,name_x,self.name_w,self.name_regimes))
is_win = False
"""
for r in self.regimes_set:
if cores:
pool = mp.Pool(None)
results_p[r] = pool.apply_async(_work, args=(
self.y, x, w, regi_ids, r, robust, sig2n_k, self.name_ds, self.name_y, name_x, self.name_w, self.name_regimes))
else:
results_p[r] = _work(*(self.y, x, w, regi_ids, r, robust, sig2n_k,
self.name_ds, self.name_y, name_x, self.name_w, self.name_regimes))
self.kryd = 0
self.kr = x.shape[1] + 1
self.kf = 0
self.nr = len(self.regimes_set)
self.vm = np.zeros((self.nr * self.kr, self.nr * self.kr), float)
self.betas = np.zeros((self.nr * self.kr, 1), float)
self.u = np.zeros((self.n, 1), float)
self.predy = np.zeros((self.n, 1), float)
"""
if not is_win:
pool.close()
pool.join()
"""
if cores:
pool.close()
pool.join()
results = {}
self.name_y, self.name_x = [], []
counter = 0
for r in self.regimes_set:
"""
if is_win:
results[r] = results_p[r]
else:
results[r] = results_p[r].get()
"""
if not cores:
results[r] = results_p[r]
else:
results[r] = results_p[r].get()
self.vm[(counter * self.kr):((counter + 1) * self.kr),
(counter * self.kr):((counter + 1) * self.kr)] = results[r].vm
self.betas[
(counter * self.kr):((counter + 1) * self.kr), ] = results[r].betas
self.u[regi_ids[r], ] = results[r].u
self.predy[regi_ids[r], ] = results[r].predy
self.name_y += results[r].name_y
self.name_x += results[r].name_x
counter += 1
self.multi = results
self.hac_var = x
if robust == 'hac':
hac_multi(self, gwk)
self.chow = REGI.Chow(self)
if spat_diag:
self._get_spat_diag_props(x, sig2n_k)
SUMMARY.OLS_multi(reg=self, multireg=self.multi, vm=vm, nonspat_diag=nonspat_diag,
spat_diag=spat_diag, moran=moran, white_test=white_test, regimes=True, w=w)
def _get_spat_diag_props(self, x, sig2n_k):
self.k = self.kr
self._cache = {}
x = np.hstack((np.ones((x.shape[0], 1)), x))
self.x = REGI.regimeX_setup(
x, self.regimes, [True] * x.shape[1], self.regimes_set)
self.xtx = spdot(self.x.T, self.x)
self.xtxi = np.linalg.inv(self.xtx)
def _work(y, x, w, regi_ids, r, robust, sig2n_k, name_ds, name_y, name_x, name_w, name_regimes):
y_r = y[regi_ids[r]]
x_r = x[regi_ids[r]]
x_constant = USER.check_constant(x_r)
if robust == 'hac':
robust = None
model = BaseOLS(y_r, x_constant, robust=robust, sig2n_k=sig2n_k)
model.title = "ORDINARY LEAST SQUARES ESTIMATION - REGIME %s" % r
model.robust = USER.set_robust(robust)
model.name_ds = name_ds
model.name_y = '%s_%s' % (str(r), name_y)
model.name_x = ['%s_%s' % (str(r), i) for i in name_x]
model.name_w = name_w
model.name_regimes = name_regimes
if w:
w_r, warn = REGI.w_regime(w, regi_ids[r], r, transform=True)
set_warn(model, warn)
model.w = w_r
return model
def _test():
import doctest
start_suppress = np.get_printoptions()['suppress']
np.set_printoptions(suppress=True)
doctest.testmod()
np.set_printoptions(suppress=start_suppress)
if __name__ == '__main__':
_test()
import numpy as np
import pysal
db = pysal.open(pysal.examples.get_path('columbus.dbf'), 'r')
y_var = 'CRIME'
y = np.array([db.by_col(y_var)]).reshape(49, 1)
x_var = ['INC', 'HOVAL']
x = np.array([db.by_col(name) for name in x_var]).T
r_var = 'NSA'
regimes = db.by_col(r_var)
w = pysal.rook_from_shapefile(pysal.examples.get_path("columbus.shp"))
w.transform = 'r'
olsr = OLS_Regimes(y, x, regimes, w=w, constant_regi='many', nonspat_diag=False, spat_diag=False, name_y=y_var, name_x=['INC', 'HOVAL'],
name_ds='columbus', name_regimes=r_var, name_w='columbus.gal', regime_err_sep=True, cols2regi=[True, True], sig2n_k=True, robust='white')
print olsr.summary
|
bsd-3-clause
|
[
624,
199,
2844,
68,
5354,
7005,
1810,
428,
392,
11044,
10864,
543,
1295,
29778,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
44,
947,
1626,
261,
472,
634,
947,
14,
290,
261,
472,
32,
305,
85,
14,
8654,
12,
510,
379,
293,
812,
14,
437,
4584,
279,
299,
379,
293,
14,
455,
285,
279,
32,
305,
85,
14,
8654,
12,
24747,
14769,
1952,
30759,
305,
13,
34,
352,
366,
285,
30759,
305,
32,
305,
85,
14,
8654,
2,
199,
199,
646,
1295,
29778,
465,
14142,
41,
199,
646,
922,
63,
1199,
465,
13044,
199,
646,
12866,
465,
6118,
199,
504,
312,
478,
492,
3523,
2228,
51,
199,
504,
3778,
492,
663,
63,
4050,
12,
2249,
10786,
12,
13262,
24188,
63,
4316,
12,
13262,
24188,
57,
12,
2249,
3287,
199,
504,
23399,
492,
394,
645,
63,
3029,
199,
646,
6212,
63,
1199,
465,
24558,
24794,
199,
646,
2680,
465,
980,
199,
504,
4298,
492,
2656,
199,
646,
7026,
14,
4421,
465,
6988,
421,
199,
533,
593,
5296,
63,
2872,
29778,
8,
1563,
2228,
51,
12,
14142,
41,
14,
2872,
29778,
63,
3160,
12,
13262,
24188,
57,
304,
339,
408,
272,
4236,
68,
5354,
5210,
26170,
543,
2058,
436,
8348,
21204,
14,
339,
3897,
272,
4143,
272,
612,
3322,
520,
1625,
673,
8484,
17,
1625,
367,
11410,
1750,
272,
671,
3322,
520,
1625,
673,
16853,
28341,
1625,
543,
302,
4730,
436,
1373,
2763,
367,
1924,
673,
12717,
334,
23919,
287,
1785,
9,
1750,
12,
28529,
314,
4413,
272,
1295,
29778,
420,
520,
769,
673,
3820,
402,
302,
1338,
543,
314,
4412,
402,
1924,
673,
20038,
370,
282,
1295,
1036,
14,
16269,
68,
370,
506,
22569,
543,
283,
88,
1370,
272,
336,
3322,
520,
10382,
279,
644,
909,
673,
13423,
4931,
909,
334,
2427,
340,
3879,
11469,
673,
8348,
21204,
9,
272,
23399,
755,
520,
1059,
673,
982,
283,
7510,
297,
2066,
282,
2816,
1175,
12137,
8943,
402,
314,
673,
11773,
13,
15024,
3634,
365,
1627,
14,
221,
982,
283,
72,
645,
297,
2066,
282,
673,
869,
1348,
12137,
8943,
402,
314,
11773,
13,
15024,
673,
3634,
365,
1627,
14,
3758,
663,
370,
488,
14,
5591,
486,
14947,
3515,
520,
10382,
279,
644,
909,
673,
24901,
11469,
4931,
4346,
367,
869,
1348,
27156,
14,
3390,
26,
673,
3634,
1471,
1172,
7869,
3180,
314,
2446,
16788,
14,
272,
5259,
18,
78,
63,
75,
420,
520,
5046,
673,
982,
715,
12,
2066,
675,
302,
13,
75,
370,
14497,
10819,
62,
18,
14,
982,
756,
12,
675,
302,
14,
272,
2222,
681,
292,
63,
6706,
520,
5046,
673,
982,
715,
12,
2066,
4526,
2222,
13,
11679,
8348,
21204,
641,
673,
314,
10864,
14,
272,
2249,
292,
63,
6706,
259,
520,
5046,
673,
982,
715,
12,
2066,
4526,
491,
643,
1842,
22215,
2295,
334,
6537,
673,
336,
680,
3390,
26,
1937,
21333,
290,
367,
9848,
2295,
14,
272,
21333,
290,
263,
520,
5046,
673,
982,
715,
12,
4526,
603,
269,
290,
1159,
473,
641,
314,
16731,
83,
14,
3390,
26,
673,
5074,
2249,
292,
63,
6706,
29,
549,
14,
272,
10424,
63,
396,
257,
520,
5046,
673,
982,
715,
12,
4526,
2816,
1175,
1159,
8929,
23399,
511,
14,
673,
334,
6537,
2222,
681,
292,
63,
6706,
29,
549,
9,
272,
4169,
3698,
520,
5046,
673,
982,
715,
12,
2387,
11773,
13,
15024,
3634,
315,
6212,
673,
2058,
272,
4413,
63,
1135,
73,
26,
788,
368,
297,
283,
3479,
418,
673,
17711,
281,
30350,
314,
4413,
6707,
3272,
14,
2779,
1443,
5452,
673,
314,
2569,
1338,
26,
2151,
627,
221,
283,
368,
356,
282,
5477,
402,
7869,
365,
11544,
370,
671,
436,
23608,
3044,
4413,
9371,
1295,
29778,
2151,
627,
283,
3479,
356,
282,
5477,
402,
7869,
365,
11544,
370,
671,
436,
8652,
3044,
3365,
1126,
1295,
1036,
334,
885,
9,
272,
8850,
18,
1135,
73,
259,
520,
769,
12,
283,
452,
7,
673,
5886,
9297,
3775,
1924,
673,
2763,
402,
671,
1077,
506,
8652,
465,
3365,
1126,
1295,
1036,
673,
503,
23608,
4413,
9371,
1295,
29778,
334,
797,
680,
673,
982,
282,
769,
12,
1022,
1234,
16721,
796,
9297,
367,
1924,
1750,
314,
673,
945,
334,
549,
340,
1373,
1126,
1295,
1036,
12,
756,
370,
506,
23608,
4413,
680,
673,
982,
283,
452,
7,
334,
885,
395,
1006,
314,
2860,
17083,
701,
1295,
1036,
14,
272,
1295,
1036,
63,
1508,
63,
4127,
221,
520,
5046,
673,
982,
715,
12,
282,
7396,
10864,
365,
1255,
367,
1924,
1295,
1036,
14,
272,
23857,
263,
520,
5046,
673,
11015,
340,
12866,
365,
370,
506,
1202,
673,
3758,
26,
949,
12866,
12,
23857,
275,
756,
673,
3390,
26,
6879,
6338,
1443,
440,
1736,
641,
1006,
10677,
14,
272,
536,
63,
89,
755,
520,
1059,
673,
2812,
402,
11410,
1750,
367,
675,
315,
1072,
272,
536,
63,
88,
755,
520,
769,
402,
3326,
673,
23923,
402,
12717,
2860,
367,
675,
315,
1072,
272,
536,
63,
87,
755,
520,
1059,
673,
2812,
402,
4931,
3634,
367,
675,
315,
1072,
272,
536,
63,
8392,
75,
258,
520,
1059,
673,
2812,
402,
5114,
4931,
3634,
367,
675,
315,
1072,
272,
536,
63,
795,
420,
520,
1059,
673,
2812,
402,
4789,
367,
675,
315,
1072,
272,
536,
63,
1135,
29778,
520,
1059,
673,
2812,
402,
1295,
1036,
1750,
367,
675,
315,
314,
1072,
2378,
9382,
272,
4143,
272,
6212,
420,
520,
1059,
673,
22486,
402,
10864,
2058,
436,
8348,
21204,
334,
4610,
26,
675,
315,
673,
22888,
543,
314,
870,
1414,
9,
272,
2907,
305,
263,
520,
1625,
673,
1022,
88,
17,
1625,
402,
20077,
12343,
272,
399,
3322,
520,
1625,
673,
8484,
17,
1625,
402,
16731,
83,
272,
8869,
89,
263,
520,
1625,
673,
8484,
17,
1625,
402,
14746,
612,
1338,
272,
302,
3322,
520,
3000,
673,
4860,
402,
19739,
272,
1022,
3322,
520,
3000,
673,
4860,
402,
2860,
367,
1314,
12343,
787,
20077,
673,
334,
15768,
314,
4413,
9,
673,
5972,
2808,
315,
2600,
283,
3029,
7,
1380,
3663,
1295,
6274,
673,
334,
3239,
283,
3029,
7,
5084,
367,
2436,
9,
272,
612,
3322,
520,
1625,
673,
8484,
17,
1625,
367,
11410,
1750,
272,
671,
3322,
520,
1625,
673,
16853,
28341,
1625,
543,
302,
4730,
436,
1373,
2763,
367,
1924,
673,
12717,
334,
23919,
287,
1785
] |
[
199,
2844,
68,
5354,
7005,
1810,
428,
392,
11044,
10864,
543,
1295,
29778,
14,
199,
624,
199,
199,
363,
2502,
363,
275,
298,
44,
947,
1626,
261,
472,
634,
947,
14,
290,
261,
472,
32,
305,
85,
14,
8654,
12,
510,
379,
293,
812,
14,
437,
4584,
279,
299,
379,
293,
14,
455,
285,
279,
32,
305,
85,
14,
8654,
12,
24747,
14769,
1952,
30759,
305,
13,
34,
352,
366,
285,
30759,
305,
32,
305,
85,
14,
8654,
2,
199,
199,
646,
1295,
29778,
465,
14142,
41,
199,
646,
922,
63,
1199,
465,
13044,
199,
646,
12866,
465,
6118,
199,
504,
312,
478,
492,
3523,
2228,
51,
199,
504,
3778,
492,
663,
63,
4050,
12,
2249,
10786,
12,
13262,
24188,
63,
4316,
12,
13262,
24188,
57,
12,
2249,
3287,
199,
504,
23399,
492,
394,
645,
63,
3029,
199,
646,
6212,
63,
1199,
465,
24558,
24794,
199,
646,
2680,
465,
980,
199,
504,
4298,
492,
2656,
199,
646,
7026,
14,
4421,
465,
6988,
421,
199,
533,
593,
5296,
63,
2872,
29778,
8,
1563,
2228,
51,
12,
14142,
41,
14,
2872,
29778,
63,
3160,
12,
13262,
24188,
57,
304,
339,
408,
272,
4236,
68,
5354,
5210,
26170,
543,
2058,
436,
8348,
21204,
14,
339,
3897,
272,
4143,
272,
612,
3322,
520,
1625,
673,
8484,
17,
1625,
367,
11410,
1750,
272,
671,
3322,
520,
1625,
673,
16853,
28341,
1625,
543,
302,
4730,
436,
1373,
2763,
367,
1924,
673,
12717,
334,
23919,
287,
1785,
9,
1750,
12,
28529,
314,
4413,
272,
1295,
29778,
420,
520,
769,
673,
3820,
402,
302,
1338,
543,
314,
4412,
402,
1924,
673,
20038,
370,
282,
1295,
1036,
14,
16269,
68,
370,
506,
22569,
543,
283,
88,
1370,
272,
336,
3322,
520,
10382,
279,
644,
909,
673,
13423,
4931,
909,
334,
2427,
340,
3879,
11469,
673,
8348,
21204,
9,
272,
23399,
755,
520,
1059,
673,
982,
283,
7510,
297,
2066,
282,
2816,
1175,
12137,
8943,
402,
314,
673,
11773,
13,
15024,
3634,
365,
1627,
14,
221,
982,
283,
72,
645,
297,
2066,
282,
673,
869,
1348,
12137,
8943,
402,
314,
11773,
13,
15024,
673,
3634,
365,
1627,
14,
3758,
663,
370,
488,
14,
5591,
486,
14947,
3515,
520,
10382,
279,
644,
909,
673,
24901,
11469,
4931,
4346,
367,
869,
1348,
27156,
14,
3390,
26,
673,
3634,
1471,
1172,
7869,
3180,
314,
2446,
16788,
14,
272,
5259,
18,
78,
63,
75,
420,
520,
5046,
673,
982,
715,
12,
2066,
675,
302,
13,
75,
370,
14497,
10819,
62,
18,
14,
982,
756,
12,
675,
302,
14,
272,
2222,
681,
292,
63,
6706,
520,
5046,
673,
982,
715,
12,
2066,
4526,
2222,
13,
11679,
8348,
21204,
641,
673,
314,
10864,
14,
272,
2249,
292,
63,
6706,
259,
520,
5046,
673,
982,
715,
12,
2066,
4526,
491,
643,
1842,
22215,
2295,
334,
6537,
673,
336,
680,
3390,
26,
1937,
21333,
290,
367,
9848,
2295,
14,
272,
21333,
290,
263,
520,
5046,
673,
982,
715,
12,
4526,
603,
269,
290,
1159,
473,
641,
314,
16731,
83,
14,
3390,
26,
673,
5074,
2249,
292,
63,
6706,
29,
549,
14,
272,
10424,
63,
396,
257,
520,
5046,
673,
982,
715,
12,
4526,
2816,
1175,
1159,
8929,
23399,
511,
14,
673,
334,
6537,
2222,
681,
292,
63,
6706,
29,
549,
9,
272,
4169,
3698,
520,
5046,
673,
982,
715,
12,
2387,
11773,
13,
15024,
3634,
315,
6212,
673,
2058,
272,
4413,
63,
1135,
73,
26,
788,
368,
297,
283,
3479,
418,
673,
17711,
281,
30350,
314,
4413,
6707,
3272,
14,
2779,
1443,
5452,
673,
314,
2569,
1338,
26,
2151,
627,
221,
283,
368,
356,
282,
5477,
402,
7869,
365,
11544,
370,
671,
436,
23608,
3044,
4413,
9371,
1295,
29778,
2151,
627,
283,
3479,
356,
282,
5477,
402,
7869,
365,
11544,
370,
671,
436,
8652,
3044,
3365,
1126,
1295,
1036,
334,
885,
9,
272,
8850,
18,
1135,
73,
259,
520,
769,
12,
283,
452,
7,
673,
5886,
9297,
3775,
1924,
673,
2763,
402,
671,
1077,
506,
8652,
465,
3365,
1126,
1295,
1036,
673,
503,
23608,
4413,
9371,
1295,
29778,
334,
797,
680,
673,
982,
282,
769,
12,
1022,
1234,
16721,
796,
9297,
367,
1924,
1750,
314,
673,
945,
334,
549,
340,
1373,
1126,
1295,
1036,
12,
756,
370,
506,
23608,
4413,
680,
673,
982,
283,
452,
7,
334,
885,
395,
1006,
314,
2860,
17083,
701,
1295,
1036,
14,
272,
1295,
1036,
63,
1508,
63,
4127,
221,
520,
5046,
673,
982,
715,
12,
282,
7396,
10864,
365,
1255,
367,
1924,
1295,
1036,
14,
272,
23857,
263,
520,
5046,
673,
11015,
340,
12866,
365,
370,
506,
1202,
673,
3758,
26,
949,
12866,
12,
23857,
275,
756,
673,
3390,
26,
6879,
6338,
1443,
440,
1736,
641,
1006,
10677,
14,
272,
536,
63,
89,
755,
520,
1059,
673,
2812,
402,
11410,
1750,
367,
675,
315,
1072,
272,
536,
63,
88,
755,
520,
769,
402,
3326,
673,
23923,
402,
12717,
2860,
367,
675,
315,
1072,
272,
536,
63,
87,
755,
520,
1059,
673,
2812,
402,
4931,
3634,
367,
675,
315,
1072,
272,
536,
63,
8392,
75,
258,
520,
1059,
673,
2812,
402,
5114,
4931,
3634,
367,
675,
315,
1072,
272,
536,
63,
795,
420,
520,
1059,
673,
2812,
402,
4789,
367,
675,
315,
1072,
272,
536,
63,
1135,
29778,
520,
1059,
673,
2812,
402,
1295,
1036,
1750,
367,
675,
315,
314,
1072,
2378,
9382,
272,
4143,
272,
6212,
420,
520,
1059,
673,
22486,
402,
10864,
2058,
436,
8348,
21204,
334,
4610,
26,
675,
315,
673,
22888,
543,
314,
870,
1414,
9,
272,
2907,
305,
263,
520,
1625,
673,
1022,
88,
17,
1625,
402,
20077,
12343,
272,
399,
3322,
520,
1625,
673,
8484,
17,
1625,
402,
16731,
83,
272,
8869,
89,
263,
520,
1625,
673,
8484,
17,
1625,
402,
14746,
612,
1338,
272,
302,
3322,
520,
3000,
673,
4860,
402,
19739,
272,
1022,
3322,
520,
3000,
673,
4860,
402,
2860,
367,
1314,
12343,
787,
20077,
673,
334,
15768,
314,
4413,
9,
673,
5972,
2808,
315,
2600,
283,
3029,
7,
1380,
3663,
1295,
6274,
673,
334,
3239,
283,
3029,
7,
5084,
367,
2436,
9,
272,
612,
3322,
520,
1625,
673,
8484,
17,
1625,
367,
11410,
1750,
272,
671,
3322,
520,
1625,
673,
16853,
28341,
1625,
543,
302,
4730,
436,
1373,
2763,
367,
1924,
673,
12717,
334,
23919,
287,
1785,
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,
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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
] |
lalitkumarj/NEXT-psych
|
gui/base/app_manager/PoolBasedTripletMDS/PoolBasedTripletMDS.py
|
1
|
9004
|
import csv, json, os, requests, sys
from wtforms import Form, FieldList, FloatField, FormField, TextField, IntegerField, SelectField, validators, RadioField
from jinja2 import Environment, FileSystemLoader
import copy
from base.models import Experiment
from flask import render_template
from base.settings import Config
from base.app_manager.app_resource_prototype import AppResourcePrototype
config = Config()
TEMPLATES_DIRECTORY = os.path.dirname(__file__)
loader = FileSystemLoader(TEMPLATES_DIRECTORY)
env = Environment(loader=loader)
class PoolBasedTripletMDS(AppResourcePrototype):
"""
PoolBased TripletMDS
Author: Lalit Jain
App resource for PoolBasedTripletMDS.
"""
def get_experiment_params(self, args=None):
"""
Return a form with specific params for the new experiment form.
"""
alg_list = ['RandomSampling', 'UncertaintySampling','CrowdKernel']
# Alg row: follow this post: http://stackoverflow.com/questions/11402627/how-to-get-a-build-a-form-with-repeated-elements-well
class AlgorithmDefinitionRowForm(Form):
alg_label = TextField('Algorithm Label')
alg_id = SelectField('Algorithm Id', choices=[(algorithm, algorithm) for algorithm in alg_list])
alg_proportion = FloatField('Algorithm Proportion')
class PoolBasedTripletMDSParamsForm(Form):
d = IntegerField('Dimension', validators=[validators.required()], default=2)
failure_probability = FloatField('Confidence Level', validators=[validators.required()], default=0.95)
algorithm_management = RadioField('Algorithm Management',
choices=[('fixed_proportions','Fixed Proportions'),
('pure_exploration','Pure Exploration'),
('explore_exploit','Explore Exploit')],
default='fixed_proportions')
participant_to_algorithm_management = RadioField('Participant to Algorithm Management',
choices=[('one_to_many','One-to-many'),
('one_to_one','One-to-one')],
default='one_to_many')
# process the experiment parameters
def process_experiment_params(self):
return True
# List field of the rows of algorithm labels and alg id's
alg_rows = FieldList(FormField(AlgorithmDefinitionRowForm))
template = env.get_template("new_experiment_params.html")
return template, PoolBasedTripletMDSParamsForm
def get_experiment_dashboard(self, args=None):
"""
Return template with embedded widgets/plots/data for the dashboard.
"""
template = env.get_template("experiment_dashboard.html")
html = render_template(template)
return html
def get_formatted_participant_data(self, current_experiment, args=None):
"""
Return formatted participant logs that are app specific.
"""
# Use frontend base local url
url = "http://"+config.NEXT_BACKEND_HOST+":"+config.NEXT_BACKEND_PORT+"/api/experiment/"+current_experiment.exp_uid+"/"+current_experiment.exp_key+"/participants"
# Make a request to next_backend for the responses
try:
response = requests.get(url)
response_dict = eval(response.text)
except (requests.HTTPError, requests.ConnectionError) as e:
print "excepted e", e
raise
print response_dict
# Parse them into a csv
# The rows are participant_id, timestamp, center, left, right, target winner, alg_label
participant_responses = []
participant_responses.append(",".join(["Participant ID", "Timestamp","Center", "Left", "Right", "Answer", "Alg Label"]))
for participant_id, response_list in response_dict['participant_responses'].iteritems():
for response in response_list:
line = [participant_id, response['timestamp_query_generated']]
targets = {}
# This index is not a backend index! It is just one of the target_indices
for index in response['target_indices']:
targets[index['label']] = index
# Check for the index winner in this response
# Shouldn't we check for target_winner?
if 'index_winner' in response.keys() and response["index_winner"] == index['index']:
target_winner = index
# Append the center, left, right targets
line.extend([targets['center']['target']['target_id'], targets['left']['target']['target_id'], targets['right']['target']['target_id']])
# Append the target winner
line.append(target_winner['target']['target_id'])
# Append the alg_label
line.append(response['alg_label'])
participant_responses.append(",".join(line))
return participant_responses
def run_experiment(self, current_experiment, args=None):
"""
Run an initExp call on the frontend base level.
"""
# Set up request dictionary for api initExp call
initExp_dict = {}
initExp_dict['app_id'] = current_experiment.app_id
initExp_dict['site_id'] = config.SITE_ID
initExp_dict['site_key'] = config.SITE_KEY
initExp_dict['args'] = {}
# Set up args for api initExp call
initExp_dict['args']['instructions'] = current_experiment.instructions
initExp_dict['args']['debrief'] = current_experiment.debrief
initExp_dict['args']['d'] = current_experiment.params['d']
initExp_dict['args']['n'] = len(current_experiment.target_set.targets)
initExp_dict['args']['failure_probability'] = current_experiment.params['failure_probability']
initExp_dict['args']['participant_to_algorithm_management'] = current_experiment.params['participant_to_algorithm_management']
initExp_dict['args']['algorithm_management_settings'] = {}
initExp_dict['args']['algorithm_management_settings']['mode'] = current_experiment.params['algorithm_management']
initExp_dict['args']['algorithm_management_settings']['params'] = {}
initExp_dict['args']['algorithm_management_settings']['params']['proportions'] = []
initExp_dict['args']['alg_list'] = []
for alg in current_experiment.params['alg_rows']:
params_dict = copy.deepcopy(alg)
params_dict['params'] = {}
params_dict['test_alg_label'] = 'Test'
del params_dict['alg_proportion']
initExp_dict['args']['alg_list'].append(params_dict)
proportions_dict = {}
proportions_dict['alg_label'] = alg['alg_label']
proportions_dict['proportion'] = alg['alg_proportion']
initExp_dict['args']['algorithm_management_settings']['params']['proportions'].append(proportions_dict)
# Make request for initExp
try:
url = "http://"+config.NEXT_BACKEND_HOST+":"+config.NEXT_BACKEND_PORT+"/api/experiment"
response = requests.post(url,
json.dumps(initExp_dict),
headers={'content-type':'application/json'})
response_dict = eval(response.text)
except:
exc_class, exc, tb = sys.exc_info()
new_exc = Exception("%s. Error connecting to backend."%(exc or exc_class))
raise new_exc.__class__,new_exc, tb
return response_dict
def get_query(self, app_id, exp_uid, widget_key, args=None):
"""
Render custom query for app type
"""
# Make this more flexible
next_backend_url = "http://"+config.NEXT_BACKEND_GLOBAL_HOST+":"+config.NEXT_BACKEND_GLOBAL_PORT
# pass in cookie dependent data
requested_experiment = Experiment.objects(exp_uid=exp_uid)[0]
query_tries = requested_experiment.query_tries
debrief = requested_experiment.debrief
instructions = requested_experiment.instructions
template = env.get_template("query.html")
return render_template(template,
app_id=app_id,
exp_uid = exp_uid,
widget_key = widget_key,
next_backend_url=next_backend_url,
query_tries = query_tries,
debrief = debrief,
instructions = instructions)
|
apache-2.0
|
[
646,
7392,
12,
2022,
12,
747,
12,
4145,
12,
984,
199,
504,
24756,
3351,
492,
8204,
12,
5024,
1296,
12,
11140,
792,
12,
8204,
792,
12,
4516,
792,
12,
26141,
12,
221,
9496,
792,
12,
14370,
12,
13514,
792,
199,
504,
10321,
18,
492,
9711,
12,
23754,
5455,
199,
646,
1331,
199,
504,
1300,
14,
992,
492,
23997,
199,
504,
7209,
492,
3795,
63,
1160,
199,
199,
504,
1300,
14,
1751,
492,
4094,
199,
504,
1300,
14,
571,
63,
2609,
14,
571,
63,
1927,
63,
16141,
492,
4693,
4031,
25565,
199,
888,
275,
4094,
342,
199,
199,
25437,
63,
16436,
275,
747,
14,
515,
14,
3475,
3460,
493,
3368,
199,
3422,
275,
23754,
5455,
8,
25437,
63,
16436,
9,
199,
1813,
275,
9711,
8,
3422,
29,
3422,
9,
421,
199,
533,
15553,
20409,
32220,
2723,
45,
3177,
8,
2640,
4031,
25565,
304,
272,
408,
272,
15553,
20409,
12480,
80,
2723,
45,
3177,
272,
6529,
26,
491,
279,
390,
1603,
1581,
339,
4693,
2073,
367,
15553,
20409,
32220,
2723,
45,
3177,
14,
5591,
408,
339,
347,
664,
63,
10873,
63,
1162,
8,
277,
12,
1249,
29,
403,
304,
267,
408,
267,
1432,
282,
1824,
543,
2488,
1862,
367,
314,
892,
11805,
1824,
14,
267,
408,
267,
15760,
63,
513,
275,
788,
3883,
12226,
8922,
297,
283,
1358,
20226,
369,
12226,
8922,
1673,
35,
1143,
68,
14127,
418,
267,
327,
4580,
71,
1962,
26,
2035,
642,
2963,
26,
1455,
921,
23153,
14,
957,
15,
16069,
15,
7636,
14842,
1465,
15,
1917,
13,
475,
13,
362,
13,
65,
13,
1506,
13,
65,
13,
964,
13,
1045,
13,
7593,
13,
5527,
13,
20501,
267,
1021,
23823,
10701,
5810,
2821,
8,
2821,
304,
288,
15760,
63,
1302,
275,
4516,
792,
360,
11570,
10354,
358,
288,
15760,
63,
344,
275,
9496,
792,
360,
11570,
15418,
297,
3415,
17497,
8833,
12,
5563,
9,
367,
5563,
315,
15760,
63,
513,
566,
288,
15760,
63,
4469,
15029,
275,
11140,
792,
360,
11570,
2165,
7314,
296,
358,
2728,
1021,
15553,
20409,
32220,
2723,
45,
3177,
6007,
2821,
8,
2821,
304,
288,
366,
275,
26141,
360,
17905,
297,
14370,
1524,
11346,
14,
2427,
15618,
849,
29,
18,
9,
288,
5988,
63,
17210,
275,
11140,
792,
360,
714,
8866,
20400,
297,
14370,
1524,
11346,
14,
2427,
15618,
849,
29,
16,
14,
2720,
9,
288,
5563,
63,
8110,
275,
13514,
792,
360,
11570,
8259,
297,
221,
6059,
3415,
11699,
5964,
63,
4469,
18434,
1673,
9515,
2165,
7314,
852,
659,
9144,
661,
5115,
63,
29028,
1673,
28928,
1316,
18361,
659,
9144,
661,
16971,
264,
63,
16971,
390,
1673,
4527,
28037,
7910,
320,
390,
2665,
6059,
849,
534,
5964,
63,
4469,
18434,
358,
288,
623,
16448,
63,
475,
63,
8833,
63,
8110,
275,
13514,
792,
360,
1262,
16448,
370,
23823,
8259,
297,
221,
17743,
3415,
11699,
368,
63,
475,
63,
3479,
1673,
4395,
13,
475,
13,
3479,
659,
6684,
3515,
661,
368,
63,
475,
63,
368,
1673,
4395,
13,
475,
13,
368,
2665,
17743,
849,
534,
368,
63,
475,
63,
3479,
358,
953,
327,
2112,
314,
11805,
2633,
288,
347,
2112,
63,
10873,
63,
1162,
8,
277,
304,
355,
372,
715,
953,
327,
3820,
901,
402,
314,
4730,
402,
5563,
3628,
436,
15760,
1305,
1159,
288,
15760,
63,
3838,
275,
5024,
1296,
8,
2821,
792,
8,
11570,
10701,
5810,
2821,
430,
398,
1978,
275,
2589,
14,
362,
63,
1160,
480,
1222,
63,
10873,
63,
1162,
14,
1360,
531,
267,
372,
1978,
12,
15553,
20409,
32220,
2723,
45,
3177,
6007,
2821,
339,
347,
664,
63,
10873,
63,
9743,
8,
277,
12,
1249,
29,
403,
304,
267,
408,
267,
1432,
1978,
543,
12169,
11114,
15,
13701,
15,
576,
367,
314,
17216,
14,
267,
408,
267,
1978,
275,
2589,
14,
362,
63,
1160,
480,
10873,
63,
9743,
14,
1360,
531,
267,
3517,
275,
3795,
63,
1160,
8,
1160,
9,
267,
372,
3517,
2286,
347,
664,
63,
15317,
63,
29253,
63,
576,
8,
277,
12,
1453,
63,
10873,
12,
1249,
29,
403,
304,
267,
408,
267,
1432,
7871,
623,
16448,
9610,
626,
787,
1145,
2488,
14,
267,
408,
267,
327,
3645,
22523,
1300,
2257,
1166,
267,
1166,
275,
298,
1014,
921,
7709,
888,
14,
21917,
63,
18145,
63,
5449,
11,
5122,
11,
888,
14,
21917,
63,
18145,
63,
3657,
24792,
1246,
15,
10873,
25976,
1818,
63,
10873,
14,
1474,
63,
1535,
5207,
25976,
1818,
63,
10873,
14,
1474,
63,
498,
24792,
31790,
2,
398,
327,
4155,
282,
1056,
370,
2163,
63,
4620,
367,
314,
9320,
267,
862,
26,
288,
1177,
275,
4145,
14,
362,
8,
633,
9,
288,
1177,
63,
807,
275,
3468,
8,
1310,
14,
505,
9,
267,
871,
334,
6615,
14,
12815,
12,
4145,
14,
20349,
9,
465,
325,
26,
288,
870,
298,
476,
7203,
325,
401,
325,
288,
746,
267,
870,
1177,
63,
807,
267,
327,
6077,
3062,
1901,
282,
7392,
267,
327,
710,
4730,
787,
623,
16448,
63,
344,
12,
4913,
12,
8126,
12,
3602,
12,
2451,
12,
1347,
4747,
1372,
12,
15760,
63,
1302,
267,
623,
16448,
63,
10360,
275,
942,
267,
623,
16448,
63,
10360,
14,
740,
11854,
1674,
904,
5234,
1262,
16448,
2870,
401,
298,
10239,
2266,
13551,
401,
298,
8185,
401,
298,
9121,
401,
298,
19104,
401,
298,
28846,
10354,
13045,
267,
367,
623,
16448,
63,
344,
12,
1177,
63,
513,
315,
1177,
63,
807,
459,
29253,
63,
10360,
2278,
4611,
837,
288,
367,
1177,
315,
1177,
63,
513,
26,
355,
1004,
275,
359,
29253,
63,
344,
12,
1177,
459,
3954,
63,
1131,
63,
10176,
6538,
355,
4545,
275,
1052,
355,
327,
961,
1478,
365,
440,
282,
4865,
1478,
1,
2779,
365,
2951,
1373,
402,
314,
1347,
63,
4108,
355,
367,
1478,
315,
1177,
459,
1375,
63,
4108,
2565,
490,
4545,
59,
1080,
459,
1302,
6538,
275,
1478,
490,
327,
2670,
367,
314,
1478,
4747,
1372,
315,
642,
1177,
490,
327,
7719,
78,
1133,
781,
1104,
367,
1347,
63,
2676,
1372,
31,
490,
340,
283,
1080,
63,
2676,
1372,
7,
315,
1177,
14,
1612,
342,
436,
1177,
905,
1080,
63,
2676,
1372,
937,
508,
1478,
459,
1080,
2565,
1169,
1347,
63,
2676,
1372,
275,
1478,
355,
327,
18726,
314,
8126,
12,
3602,
12,
2451,
4545,
355,
1004,
14,
2880,
779,
4684,
459,
4218,
2545,
1375
] |
[
7392,
12,
2022,
12,
747,
12,
4145,
12,
984,
199,
504,
24756,
3351,
492,
8204,
12,
5024,
1296,
12,
11140,
792,
12,
8204,
792,
12,
4516,
792,
12,
26141,
12,
221,
9496,
792,
12,
14370,
12,
13514,
792,
199,
504,
10321,
18,
492,
9711,
12,
23754,
5455,
199,
646,
1331,
199,
504,
1300,
14,
992,
492,
23997,
199,
504,
7209,
492,
3795,
63,
1160,
199,
199,
504,
1300,
14,
1751,
492,
4094,
199,
504,
1300,
14,
571,
63,
2609,
14,
571,
63,
1927,
63,
16141,
492,
4693,
4031,
25565,
199,
888,
275,
4094,
342,
199,
199,
25437,
63,
16436,
275,
747,
14,
515,
14,
3475,
3460,
493,
3368,
199,
3422,
275,
23754,
5455,
8,
25437,
63,
16436,
9,
199,
1813,
275,
9711,
8,
3422,
29,
3422,
9,
421,
199,
533,
15553,
20409,
32220,
2723,
45,
3177,
8,
2640,
4031,
25565,
304,
272,
408,
272,
15553,
20409,
12480,
80,
2723,
45,
3177,
272,
6529,
26,
491,
279,
390,
1603,
1581,
339,
4693,
2073,
367,
15553,
20409,
32220,
2723,
45,
3177,
14,
5591,
408,
339,
347,
664,
63,
10873,
63,
1162,
8,
277,
12,
1249,
29,
403,
304,
267,
408,
267,
1432,
282,
1824,
543,
2488,
1862,
367,
314,
892,
11805,
1824,
14,
267,
408,
267,
15760,
63,
513,
275,
788,
3883,
12226,
8922,
297,
283,
1358,
20226,
369,
12226,
8922,
1673,
35,
1143,
68,
14127,
418,
267,
327,
4580,
71,
1962,
26,
2035,
642,
2963,
26,
1455,
921,
23153,
14,
957,
15,
16069,
15,
7636,
14842,
1465,
15,
1917,
13,
475,
13,
362,
13,
65,
13,
1506,
13,
65,
13,
964,
13,
1045,
13,
7593,
13,
5527,
13,
20501,
267,
1021,
23823,
10701,
5810,
2821,
8,
2821,
304,
288,
15760,
63,
1302,
275,
4516,
792,
360,
11570,
10354,
358,
288,
15760,
63,
344,
275,
9496,
792,
360,
11570,
15418,
297,
3415,
17497,
8833,
12,
5563,
9,
367,
5563,
315,
15760,
63,
513,
566,
288,
15760,
63,
4469,
15029,
275,
11140,
792,
360,
11570,
2165,
7314,
296,
358,
2728,
1021,
15553,
20409,
32220,
2723,
45,
3177,
6007,
2821,
8,
2821,
304,
288,
366,
275,
26141,
360,
17905,
297,
14370,
1524,
11346,
14,
2427,
15618,
849,
29,
18,
9,
288,
5988,
63,
17210,
275,
11140,
792,
360,
714,
8866,
20400,
297,
14370,
1524,
11346,
14,
2427,
15618,
849,
29,
16,
14,
2720,
9,
288,
5563,
63,
8110,
275,
13514,
792,
360,
11570,
8259,
297,
221,
6059,
3415,
11699,
5964,
63,
4469,
18434,
1673,
9515,
2165,
7314,
852,
659,
9144,
661,
5115,
63,
29028,
1673,
28928,
1316,
18361,
659,
9144,
661,
16971,
264,
63,
16971,
390,
1673,
4527,
28037,
7910,
320,
390,
2665,
6059,
849,
534,
5964,
63,
4469,
18434,
358,
288,
623,
16448,
63,
475,
63,
8833,
63,
8110,
275,
13514,
792,
360,
1262,
16448,
370,
23823,
8259,
297,
221,
17743,
3415,
11699,
368,
63,
475,
63,
3479,
1673,
4395,
13,
475,
13,
3479,
659,
6684,
3515,
661,
368,
63,
475,
63,
368,
1673,
4395,
13,
475,
13,
368,
2665,
17743,
849,
534,
368,
63,
475,
63,
3479,
358,
953,
327,
2112,
314,
11805,
2633,
288,
347,
2112,
63,
10873,
63,
1162,
8,
277,
304,
355,
372,
715,
953,
327,
3820,
901,
402,
314,
4730,
402,
5563,
3628,
436,
15760,
1305,
1159,
288,
15760,
63,
3838,
275,
5024,
1296,
8,
2821,
792,
8,
11570,
10701,
5810,
2821,
430,
398,
1978,
275,
2589,
14,
362,
63,
1160,
480,
1222,
63,
10873,
63,
1162,
14,
1360,
531,
267,
372,
1978,
12,
15553,
20409,
32220,
2723,
45,
3177,
6007,
2821,
339,
347,
664,
63,
10873,
63,
9743,
8,
277,
12,
1249,
29,
403,
304,
267,
408,
267,
1432,
1978,
543,
12169,
11114,
15,
13701,
15,
576,
367,
314,
17216,
14,
267,
408,
267,
1978,
275,
2589,
14,
362,
63,
1160,
480,
10873,
63,
9743,
14,
1360,
531,
267,
3517,
275,
3795,
63,
1160,
8,
1160,
9,
267,
372,
3517,
2286,
347,
664,
63,
15317,
63,
29253,
63,
576,
8,
277,
12,
1453,
63,
10873,
12,
1249,
29,
403,
304,
267,
408,
267,
1432,
7871,
623,
16448,
9610,
626,
787,
1145,
2488,
14,
267,
408,
267,
327,
3645,
22523,
1300,
2257,
1166,
267,
1166,
275,
298,
1014,
921,
7709,
888,
14,
21917,
63,
18145,
63,
5449,
11,
5122,
11,
888,
14,
21917,
63,
18145,
63,
3657,
24792,
1246,
15,
10873,
25976,
1818,
63,
10873,
14,
1474,
63,
1535,
5207,
25976,
1818,
63,
10873,
14,
1474,
63,
498,
24792,
31790,
2,
398,
327,
4155,
282,
1056,
370,
2163,
63,
4620,
367,
314,
9320,
267,
862,
26,
288,
1177,
275,
4145,
14,
362,
8,
633,
9,
288,
1177,
63,
807,
275,
3468,
8,
1310,
14,
505,
9,
267,
871,
334,
6615,
14,
12815,
12,
4145,
14,
20349,
9,
465,
325,
26,
288,
870,
298,
476,
7203,
325,
401,
325,
288,
746,
267,
870,
1177,
63,
807,
267,
327,
6077,
3062,
1901,
282,
7392,
267,
327,
710,
4730,
787,
623,
16448,
63,
344,
12,
4913,
12,
8126,
12,
3602,
12,
2451,
12,
1347,
4747,
1372,
12,
15760,
63,
1302,
267,
623,
16448,
63,
10360,
275,
942,
267,
623,
16448,
63,
10360,
14,
740,
11854,
1674,
904,
5234,
1262,
16448,
2870,
401,
298,
10239,
2266,
13551,
401,
298,
8185,
401,
298,
9121,
401,
298,
19104,
401,
298,
28846,
10354,
13045,
267,
367,
623,
16448,
63,
344,
12,
1177,
63,
513,
315,
1177,
63,
807,
459,
29253,
63,
10360,
2278,
4611,
837,
288,
367,
1177,
315,
1177,
63,
513,
26,
355,
1004,
275,
359,
29253,
63,
344,
12,
1177,
459,
3954,
63,
1131,
63,
10176,
6538,
355,
4545,
275,
1052,
355,
327,
961,
1478,
365,
440,
282,
4865,
1478,
1,
2779,
365,
2951,
1373,
402,
314,
1347,
63,
4108,
355,
367,
1478,
315,
1177,
459,
1375,
63,
4108,
2565,
490,
4545,
59,
1080,
459,
1302,
6538,
275,
1478,
490,
327,
2670,
367,
314,
1478,
4747,
1372,
315,
642,
1177,
490,
327,
7719,
78,
1133,
781,
1104,
367,
1347,
63,
2676,
1372,
31,
490,
340,
283,
1080,
63,
2676,
1372,
7,
315,
1177,
14,
1612,
342,
436,
1177,
905,
1080,
63,
2676,
1372,
937,
508,
1478,
459,
1080,
2565,
1169,
1347,
63,
2676,
1372,
275,
1478,
355,
327,
18726,
314,
8126,
12,
3602,
12,
2451,
4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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
bpramod/azure-linux-extensions
|
CustomScript/test/test_file_download.py
|
8
|
1456
|
#!/usr/bin/env python
#
#CustomScript extension
#
# Copyright 2014 Microsoft Corporation
#
# 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.
import unittest
import os
import tempfile
import customscript as cs
class TestFileDownload(unittest.TestCase):
def test_download_blob(self):
pass
def download_to_tmp(self, uri):
tmpFile = tempfile.TemporaryFile()
file_path = os.path.abspath(tmpFile.name)
cs.download_and_save_file(uri, file_path)
file_size = os.path.getsize(file_path)
self.assertNotEqual(file_size, 0)
tmpFile.close()
os.unlink(tmpFile.name)
def test_download_bin_file(self):
uri = "http://www.bing.com/rms/Homepage$HPBottomBrand_default/ic/1f76acf2/d3a8cfeb.png"
self.download_to_tmp(uri)
def test_download_text_file(self):
uri = "http://www.bing.com/"
self.download_to_tmp(uri)
if __name__ == '__main__':
unittest.main()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
7223,
5229,
3329,
199,
3,
199,
3,
1898,
6927,
15332,
11098,
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,
646,
2882,
199,
646,
747,
199,
646,
5549,
199,
646,
3537,
1579,
465,
7117,
199,
199,
533,
1379,
1173,
11950,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4249,
63,
6582,
8,
277,
304,
267,
986,
339,
347,
5235,
63,
475,
63,
2791,
8,
277,
12,
5108,
304,
267,
3529,
1173,
275,
5549,
14,
13271,
342,
267,
570,
63,
515,
275,
747,
14,
515,
14,
4832,
8,
2791,
1173,
14,
354,
9,
267,
7117,
14,
4249,
63,
460,
63,
2117,
63,
493,
8,
2302,
12,
570,
63,
515,
9,
267,
570,
63,
890,
275,
747,
14,
515,
14,
20733,
8,
493,
63,
515,
9,
267,
291,
14,
7418,
8,
493,
63,
890,
12,
378,
9,
267,
3529,
1173,
14,
1600,
342,
267,
747,
14,
7162,
8,
2791,
1173,
14,
354,
9,
5493,
347,
511,
63,
4249,
63,
1393,
63,
493,
8,
277,
304,
267,
5108,
275,
298,
1014,
921,
1544,
14,
10911,
14,
957,
15,
24444,
15,
12054,
1606,
4,
40,
13167,
357,
3151,
34,
3759,
63,
885,
15,
530,
15,
17,
70,
2114,
29533,
18,
15,
68,
19,
65,
24,
67,
29204,
14,
4524,
2,
267,
291,
14,
4249,
63,
475,
63,
2791,
8,
2302,
9,
339,
347,
511,
63,
4249,
63,
505,
63,
493,
8,
277,
304,
267,
5108,
275,
298,
1014,
921,
1544,
14,
10911,
14,
957,
6687,
267,
291,
14,
4249,
63,
475,
63,
2791,
8,
2302,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
7223,
5229,
3329,
199,
3,
199,
3,
1898,
6927,
15332,
11098,
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,
646,
2882,
199,
646,
747,
199,
646,
5549,
199,
646,
3537,
1579,
465,
7117,
199,
199,
533,
1379,
1173,
11950,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
4249,
63,
6582,
8,
277,
304,
267,
986,
339,
347,
5235,
63,
475,
63,
2791,
8,
277,
12,
5108,
304,
267,
3529,
1173,
275,
5549,
14,
13271,
342,
267,
570,
63,
515,
275,
747,
14,
515,
14,
4832,
8,
2791,
1173,
14,
354,
9,
267,
7117,
14,
4249,
63,
460,
63,
2117,
63,
493,
8,
2302,
12,
570,
63,
515,
9,
267,
570,
63,
890,
275,
747,
14,
515,
14,
20733,
8,
493,
63,
515,
9,
267,
291,
14,
7418,
8,
493,
63,
890,
12,
378,
9,
267,
3529,
1173,
14,
1600,
342,
267,
747,
14,
7162,
8,
2791,
1173,
14,
354,
9,
5493,
347,
511,
63,
4249,
63,
1393,
63,
493,
8,
277,
304,
267,
5108,
275,
298,
1014,
921,
1544,
14,
10911,
14,
957,
15,
24444,
15,
12054,
1606,
4,
40,
13167,
357,
3151,
34,
3759,
63,
885,
15,
530,
15,
17,
70,
2114,
29533,
18,
15,
68,
19,
65,
24,
67,
29204,
14,
4524,
2,
267,
291,
14,
4249,
63,
475,
63,
2791,
8,
2302,
9,
339,
347,
511,
63,
4249,
63,
505,
63,
493,
8,
277,
304,
267,
5108,
275,
298,
1014,
921,
1544,
14,
10911,
14,
957,
6687,
267,
291,
14,
4249,
63,
475,
63,
2791,
8,
2302,
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,
32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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
] |
oberlin/django
|
django/conf/locale/ml/formats.py
|
1007
|
1815
|
# -*- encoding: utf-8 -*-
# This file is distributed under the same license as the Django package.
#
from __future__ import unicode_literals
# The *_FORMAT strings use the Django date format syntax,
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'N j, Y'
TIME_FORMAT = 'P'
DATETIME_FORMAT = 'N j, Y, P'
YEAR_MONTH_FORMAT = 'F Y'
MONTH_DAY_FORMAT = 'F j'
SHORT_DATE_FORMAT = 'm/d/Y'
SHORT_DATETIME_FORMAT = 'm/d/Y P'
FIRST_DAY_OF_WEEK = 0 # Sunday
# The *_INPUT_FORMATS strings use the Python strftime format syntax,
# see http://docs.python.org/library/datetime.html#strftime-strptime-behavior
# Kept ISO formats as they are in first position
DATE_INPUT_FORMATS = [
'%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
# '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006'
# '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006'
# '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006'
# '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
]
DATETIME_INPUT_FORMATS = [
'%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'
'%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200'
'%Y-%m-%d %H:%M', # '2006-10-25 14:30'
'%Y-%m-%d', # '2006-10-25'
'%m/%d/%Y %H:%M:%S', # '10/25/2006 14:30:59'
'%m/%d/%Y %H:%M:%S.%f', # '10/25/2006 14:30:59.000200'
'%m/%d/%Y %H:%M', # '10/25/2006 14:30'
'%m/%d/%Y', # '10/25/2006'
'%m/%d/%y %H:%M:%S', # '10/25/06 14:30:59'
'%m/%d/%y %H:%M:%S.%f', # '10/25/06 14:30:59.000200'
'%m/%d/%y %H:%M', # '10/25/06 14:30'
'%m/%d/%y', # '10/25/06'
]
DECIMAL_SEPARATOR = '.'
THOUSAND_SEPARATOR = ','
NUMBER_GROUPING = 3
|
bsd-3-clause
|
[
3,
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
283,
46,
1335,
12,
1488,
7,
199,
4961,
63,
4807,
275,
283,
48,
7,
199,
12488,
63,
4807,
275,
283,
46,
1335,
12,
1488,
12,
510,
7,
199,
19216,
63,
16413,
63,
4807,
275,
283,
38,
1488,
7,
199,
16413,
63,
11655,
63,
4807,
275,
283,
38,
1335,
7,
199,
13003,
63,
5390,
63,
4807,
275,
283,
77,
15,
68,
15,
57,
7,
199,
13003,
63,
12488,
63,
4807,
275,
283,
77,
15,
68,
15,
57,
510,
7,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
378,
221,
327,
428,
24759,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
3,
25645,
541,
9055,
6752,
465,
2985,
787,
315,
1642,
3421,
199,
5390,
63,
7321,
63,
14019,
275,
359,
272,
1543,
57,
3295,
77,
3295,
68,
297,
1543,
77,
3149,
68,
3149,
57,
297,
1543,
77,
3149,
68,
3149,
89,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
297,
283,
709,
15,
821,
15,
7968,
297,
283,
709,
15,
821,
15,
1690,
7,
272,
327,
1543,
66,
450,
68,
450,
57,
297,
1543,
66,
450,
68,
12,
450,
57,
297,
3322,
327,
283,
17584,
5661,
8315,
297,
283,
17584,
5661,
12,
8315,
7,
272,
327,
1543,
68,
450,
66,
450,
57,
297,
1543,
68,
450,
66,
12,
450,
57,
297,
3322,
327,
283,
821,
18365,
8315,
297,
283,
821,
18365,
12,
8315,
7,
272,
327,
1543,
34,
450,
68,
450,
57,
297,
1543,
34,
450,
68,
12,
450,
57,
297,
3322,
327,
283,
17584,
22459,
5661,
8315,
297,
283,
17584,
22459,
5661,
12,
8315,
7,
272,
327,
1543,
68,
450,
34,
450,
57,
297,
1543,
68,
450,
34,
12,
450,
57,
297,
3322,
327,
283,
821,
18365,
22459,
8315,
297,
283,
821,
18365,
22459,
12,
8315,
7,
199,
61,
199,
12488,
63,
7321,
63,
14019,
275,
359,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
297,
263,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
4519,
327,
283,
7968,
13,
709,
13,
821,
7,
272,
1543,
77,
3149,
68,
3149,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
709,
15,
821,
15,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
77,
3149,
68,
3149,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
709,
15,
821,
15,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
77,
3149,
68,
3149,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
709,
15,
821,
15,
7968,
4329,
26,
1216,
7,
272,
1543,
77,
3149,
68,
3149,
57,
297,
4519,
327,
283,
709,
15,
821,
15,
7968,
7,
272,
1543,
77,
3149,
68,
3149,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
709,
15,
821,
15,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
77,
3149,
68,
3149,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
709,
15,
821,
15,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
77,
3149,
68,
3149,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
709,
15,
821,
15,
1690,
4329,
26,
1216,
7,
272,
1543,
77,
3149,
68,
3149,
89,
297,
4519,
327,
283,
709,
15,
821,
15,
1690,
7,
199,
61,
199,
23925,
63,
15828,
275,
7815,
199,
28714,
63,
15828,
275,
13647,
199,
9190,
63,
7823,
1206,
275,
650,
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
] |
[
1882,
2644,
26,
2774,
13,
24,
1882,
199,
3,
961,
570,
365,
1854,
1334,
314,
2011,
4190,
465,
314,
5634,
2559,
14,
199,
3,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
3,
710,
20841,
4807,
3326,
675,
314,
5634,
1434,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
14013,
14,
957,
15,
287,
15,
2374,
15,
1121,
15,
5876,
15,
10372,
12645,
602,
199,
5390,
63,
4807,
275,
283,
46,
1335,
12,
1488,
7,
199,
4961,
63,
4807,
275,
283,
48,
7,
199,
12488,
63,
4807,
275,
283,
46,
1335,
12,
1488,
12,
510,
7,
199,
19216,
63,
16413,
63,
4807,
275,
283,
38,
1488,
7,
199,
16413,
63,
11655,
63,
4807,
275,
283,
38,
1335,
7,
199,
13003,
63,
5390,
63,
4807,
275,
283,
77,
15,
68,
15,
57,
7,
199,
13003,
63,
12488,
63,
4807,
275,
283,
77,
15,
68,
15,
57,
510,
7,
199,
12903,
63,
11655,
63,
3359,
63,
24929,
275,
378,
221,
327,
428,
24759,
199,
199,
3,
710,
20841,
7321,
63,
14019,
3326,
675,
314,
2018,
14053,
1475,
6302,
12,
199,
3,
1937,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
4342,
15,
2083,
14,
1360,
3,
6205,
13,
9866,
13,
17537,
199,
3,
25645,
541,
9055,
6752,
465,
2985,
787,
315,
1642,
3421,
199,
5390,
63,
7321,
63,
14019,
275,
359,
272,
1543,
57,
3295,
77,
3295,
68,
297,
1543,
77,
3149,
68,
3149,
57,
297,
1543,
77,
3149,
68,
3149,
89,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
297,
283,
709,
15,
821,
15,
7968,
297,
283,
709,
15,
821,
15,
1690,
7,
272,
327,
1543,
66,
450,
68,
450,
57,
297,
1543,
66,
450,
68,
12,
450,
57,
297,
3322,
327,
283,
17584,
5661,
8315,
297,
283,
17584,
5661,
12,
8315,
7,
272,
327,
1543,
68,
450,
66,
450,
57,
297,
1543,
68,
450,
66,
12,
450,
57,
297,
3322,
327,
283,
821,
18365,
8315,
297,
283,
821,
18365,
12,
8315,
7,
272,
327,
1543,
34,
450,
68,
450,
57,
297,
1543,
34,
450,
68,
12,
450,
57,
297,
3322,
327,
283,
17584,
22459,
5661,
8315,
297,
283,
17584,
22459,
5661,
12,
8315,
7,
272,
327,
1543,
68,
450,
34,
450,
57,
297,
1543,
68,
450,
34,
12,
450,
57,
297,
3322,
327,
283,
821,
18365,
22459,
8315,
297,
283,
821,
18365,
22459,
12,
8315,
7,
199,
61,
199,
12488,
63,
7321,
63,
14019,
275,
359,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
57,
3295,
77,
3295,
68,
450,
40,
2689,
45,
297,
263,
327,
283,
7968,
13,
709,
13,
821,
4329,
26,
1216,
7,
272,
1543,
57,
3295,
77,
3295,
68,
297,
4519,
327,
283,
7968,
13,
709,
13,
821,
7,
272,
1543,
77,
3149,
68,
3149,
57,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
709,
15,
821,
15,
7968,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
77,
3149,
68,
3149,
57,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
709,
15,
821,
15,
7968,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
77,
3149,
68,
3149,
57,
450,
40,
2689,
45,
297,
263,
327,
283,
709,
15,
821,
15,
7968,
4329,
26,
1216,
7,
272,
1543,
77,
3149,
68,
3149,
57,
297,
4519,
327,
283,
709,
15,
821,
15,
7968,
7,
272,
1543,
77,
3149,
68,
3149,
89,
450,
40,
2689,
45,
2689,
51,
297,
258,
327,
283,
709,
15,
821,
15,
1690,
4329,
26,
1216,
26,
1427,
7,
272,
1543,
77,
3149,
68,
3149,
89,
450,
40,
2689,
45,
2689,
51,
4111,
70,
297,
221,
327,
283,
709,
15,
821,
15,
1690,
4329,
26,
1216,
26,
1427,
14,
25080,
7,
272,
1543,
77,
3149,
68,
3149,
89,
450,
40,
2689,
45,
297,
263,
327,
283,
709,
15,
821,
15,
1690,
4329,
26,
1216,
7,
272,
1543,
77,
3149,
68,
3149,
89,
297,
4519,
327,
283,
709,
15,
821,
15,
1690,
7,
199,
61,
199,
23925,
63,
15828,
275,
7815,
199,
28714,
63,
15828,
275,
13647,
199,
9190,
63,
7823,
1206,
275,
650,
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,
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,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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
] |
anjel-ershova/python_training
|
fixture/fixture_group.py
|
1
|
4896
|
from model.model_group import Group
import random
class GroupHelper:
def __init__(self, app):
self.app = app
def select_group_by_index(self, index):
wd = self.app.wd
wd.find_elements_by_name("selected[]")[index].click()
def select_group_by_id(self, id):
wd = self.app.wd
wd.find_element_by_css_selector("input[value='%s']" % id).click()
def select_first_group(self):
wd = self.app.wd
self.select_group_by_index(0)
def edit_if_not_none(self, field, text):
wd = self.app.wd
if text is not None:
wd.find_element_by_name(field).click()
wd.find_element_by_name(field).clear()
wd.find_element_by_name(field).send_keys(text)
else:
pass
def fill_group_form(self, group):
wd = self.app.wd
self.edit_if_not_none("group_name", group.name)
self.edit_if_not_none("group_header", group.header)
self.edit_if_not_none("group_footer", group.footer)
def create(self, group):
wd = self.app.wd
# open_groups_page
wd.find_element_by_link_text("groups").click()
# init group creation
wd.find_element_by_name("new").click()
self.fill_group_form(group)
# submit group creation
wd.find_element_by_name("submit").click()
self.return_to_groups_page()
self.group_cache = None
def edit_first_group(self):
wd = self.app.wd
self.edit_group_by_index(0)
def edit_group_by_index(self, index, new_group_data):
wd = self.app.wd
self.app.navigation.open_groups_page()
self.select_group_by_index(index)
# click edit button
wd.find_element_by_name("edit").click()
self.fill_group_form(new_group_data)
# submit edition
wd.find_element_by_name("update").click()
self.return_to_groups_page()
self.group_cache = None
def edit_group_by_id(self, id, new_group_data):
wd = self.app.wd
self.app.navigation.open_groups_page()
self.select_group_by_id(id)
# click edit button
wd.find_element_by_name("edit").click()
self.fill_group_form(new_group_data)
# submit edition
wd.find_element_by_name("update").click()
self.return_to_groups_page()
self.group_cache = None
def add_selected_contact_to_selected_group_by_id(self, target_group):
wd = self.app.wd
# открыть выпадающий список
to_group = wd.find_element_by_name("to_group")
to_group.click()
# выбор произвольной группы по value
to_group.find_element_by_css_selector("[value='%s']" % target_group.id).click()
wd.find_element_by_name("add").click()
def select_some_group_to_view(self, target_group):
wd = self.app.wd
# открыть выпадающий список
view_group = wd.find_element_by_name("group")
view_group.click()
# выбор произвольной группы по value
view_group.find_element_by_css_selector("[value='%s']" % target_group.id).click()
# def click_add_contact_to_group_button(self):
# wd = self.app.wd
# wd.find_element_by_name("add").click()
# self.app.navigation.open_home_page()
def delete_first_group(self):
wd = self.app.wd
self.delete_group_by_index(0)
def delete_group_by_index(self, index):
wd = self.app.wd
self.app.navigation.open_groups_page()
self.select_group_by_index(index)
# submit deletion
wd.find_element_by_name("delete").click()
self.return_to_groups_page()
self.group_cache = None
def delete_group_by_id(self, id):
wd = self.app.wd
self.app.navigation.open_groups_page()
self.select_group_by_id(id)
wd.find_element_by_name("delete").click()
self.return_to_groups_page()
self.group_cache = None
def return_to_groups_page(self):
wd = self.app.wd
wd.find_element_by_link_text("group page").click()
def count(self):
wd = self.app.wd
self.app.navigation.open_groups_page()
return len(wd.find_elements_by_name("selected[]"))
group_cache = None
def get_group_list(self):
if self.group_cache is None:
wd = self.app.wd
self.app.navigation.open_groups_page()
self.group_cache = []
wd.find_elements_by_css_selector("span.group")
for element in wd.find_elements_by_css_selector("span.group"):
text = element.text
id = int(element.find_element_by_name("selected[]").get_attribute("value"))
self.group_cache.append(Group(name=text, id=id))
return list(self.group_cache)
|
apache-2.0
|
[
504,
1402,
14,
1238,
63,
923,
492,
5611,
199,
646,
2196,
199,
199,
533,
5611,
4433,
26,
272,
347,
636,
826,
721,
277,
12,
1145,
304,
267,
291,
14,
571,
275,
1145,
339,
347,
3504,
63,
923,
63,
991,
63,
1080,
8,
277,
12,
1478,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
20792,
14,
1623,
63,
5527,
63,
991,
63,
354,
480,
5511,
8607,
9981,
1080,
1055,
4891,
342,
339,
347,
3504,
63,
923,
63,
991,
63,
344,
8,
277,
12,
1305,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
3919,
63,
6662,
480,
1210,
59,
585,
9569,
83,
18721,
450,
1305,
680,
4891,
342,
339,
347,
3504,
63,
2246,
63,
923,
8,
277,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
2416,
63,
923,
63,
991,
63,
1080,
8,
16,
9,
339,
347,
5283,
63,
692,
63,
1397,
63,
3592,
8,
277,
12,
901,
12,
1318,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
340,
1318,
365,
440,
488,
26,
288,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
8,
698,
680,
4891,
342,
288,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
8,
698,
680,
3584,
342,
288,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
8,
698,
680,
2254,
63,
1612,
8,
505,
9,
267,
587,
26,
288,
986,
339,
347,
5554,
63,
923,
63,
964,
8,
277,
12,
1572,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
3773,
63,
692,
63,
1397,
63,
3592,
480,
923,
63,
354,
401,
1572,
14,
354,
9,
267,
291,
14,
3773,
63,
692,
63,
1397,
63,
3592,
480,
923,
63,
1291,
401,
1572,
14,
1291,
9,
267,
291,
14,
3773,
63,
692,
63,
1397,
63,
3592,
480,
923,
63,
12781,
401,
1572,
14,
12781,
9,
339,
347,
1218,
8,
277,
12,
1572,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
327,
1551,
63,
2634,
63,
1606,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
1073,
63,
505,
480,
2634,
3471,
4891,
342,
267,
327,
4205,
1572,
7143,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
1222,
3471,
4891,
342,
267,
291,
14,
4498,
63,
923,
63,
964,
8,
923,
9,
267,
327,
11482,
1572,
7143,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
7275,
3471,
4891,
342,
267,
291,
14,
1107,
63,
475,
63,
2634,
63,
1606,
342,
267,
291,
14,
923,
63,
1637,
275,
488,
339,
347,
5283,
63,
2246,
63,
923,
8,
277,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
3773,
63,
923,
63,
991,
63,
1080,
8,
16,
9,
339,
347,
5283,
63,
923,
63,
991,
63,
1080,
8,
277,
12,
1478,
12,
892,
63,
923,
63,
576,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
571,
14,
24148,
14,
1490,
63,
2634,
63,
1606,
342,
267,
291,
14,
2416,
63,
923,
63,
991,
63,
1080,
8,
1080,
9,
267,
327,
8968,
5283,
5528,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
3773,
3471,
4891,
342,
267,
291,
14,
4498,
63,
923,
63,
964,
8,
1222,
63,
923,
63,
576,
9,
267,
327,
11482,
325,
1671,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
873,
3471,
4891,
342,
267,
291,
14,
1107,
63,
475,
63,
2634,
63,
1606,
342,
267,
291,
14,
923,
63,
1637,
275,
488,
339,
347,
5283,
63,
923,
63,
991,
63,
344,
8,
277,
12,
1305,
12,
892,
63,
923,
63,
576,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
571,
14,
24148,
14,
1490,
63,
2634,
63,
1606,
342,
267,
291,
14,
2416,
63,
923,
63,
991,
63,
344,
8,
344,
9,
267,
327,
8968,
5283,
5528,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
3773,
3471,
4891,
342,
267,
291,
14,
4498,
63,
923,
63,
964,
8,
1222,
63,
923,
63,
576,
9,
267,
327,
11482,
325,
1671,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
873,
3471,
4891,
342,
267,
291,
14,
1107,
63,
475,
63,
2634,
63,
1606,
342,
267,
291,
14,
923,
63,
1637,
275,
488,
339,
347,
1050,
63,
5511,
63,
7811,
63,
475,
63,
5511,
63,
923,
63,
991,
63,
344,
8,
277,
12,
1347,
63,
923,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
327,
221,
5806,
7413,
11487,
7753,
17445,
7413,
16961,
22213,
17445,
23645,
13111,
113,
5657,
31235,
142,
232,
16863,
118,
24071,
23645,
6500,
8474,
8381,
119,
267,
370,
63,
923,
275,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
475,
63,
923,
531,
267,
370,
63,
923,
14,
4891,
342,
267,
327,
22213,
17445,
141,
110,
26438,
19820,
7753,
5806,
16863,
116,
19630,
26927,
16961,
7592,
8381,
118,
7038,
112,
7753,
12195,
23645,
23645,
17445,
19820,
5806,
574,
267,
370,
63,
923,
14,
1623,
63,
2108,
63,
991,
63,
3919,
63,
6662,
10994,
585,
9569,
83,
18721,
450,
1347,
63,
923,
14,
344,
680,
4891,
342,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
525,
3471,
4891,
342,
339,
347,
3504,
63,
3972,
63,
923,
63,
475,
63,
1345,
8,
277,
12,
1347,
63,
923,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
327,
221,
5806,
7413,
11487,
7753,
17445,
7413,
16961,
22213,
17445,
23645,
13111,
113,
5657,
31235,
142,
232,
16863,
118,
24071,
23645,
6500,
8474,
8381,
119,
267,
2455,
63,
923,
275,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
923,
531,
267,
2455,
63,
923,
14,
4891,
342,
267,
327,
22213,
17445,
141,
110,
26438,
19820,
7753,
5806,
16863,
116,
19630,
26927,
16961,
7592,
8381,
118,
7038,
112,
7753,
12195,
23645,
23645,
17445,
19820,
5806,
574,
267,
2455,
63,
923,
14,
1623,
63,
2108,
63,
991,
63,
3919,
63,
6662,
10994,
585,
9569,
83,
18721,
450,
1347,
63,
923,
14,
344,
680,
4891,
342,
199,
199,
3,
259,
347,
8968,
63,
525,
63,
7811,
63,
475,
63,
923,
63,
3887,
8,
277,
304,
199,
327,
755,
20792,
275,
291,
14,
571
] |
[
1402,
14,
1238,
63,
923,
492,
5611,
199,
646,
2196,
199,
199,
533,
5611,
4433,
26,
272,
347,
636,
826,
721,
277,
12,
1145,
304,
267,
291,
14,
571,
275,
1145,
339,
347,
3504,
63,
923,
63,
991,
63,
1080,
8,
277,
12,
1478,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
20792,
14,
1623,
63,
5527,
63,
991,
63,
354,
480,
5511,
8607,
9981,
1080,
1055,
4891,
342,
339,
347,
3504,
63,
923,
63,
991,
63,
344,
8,
277,
12,
1305,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
3919,
63,
6662,
480,
1210,
59,
585,
9569,
83,
18721,
450,
1305,
680,
4891,
342,
339,
347,
3504,
63,
2246,
63,
923,
8,
277,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
2416,
63,
923,
63,
991,
63,
1080,
8,
16,
9,
339,
347,
5283,
63,
692,
63,
1397,
63,
3592,
8,
277,
12,
901,
12,
1318,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
340,
1318,
365,
440,
488,
26,
288,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
8,
698,
680,
4891,
342,
288,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
8,
698,
680,
3584,
342,
288,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
8,
698,
680,
2254,
63,
1612,
8,
505,
9,
267,
587,
26,
288,
986,
339,
347,
5554,
63,
923,
63,
964,
8,
277,
12,
1572,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
3773,
63,
692,
63,
1397,
63,
3592,
480,
923,
63,
354,
401,
1572,
14,
354,
9,
267,
291,
14,
3773,
63,
692,
63,
1397,
63,
3592,
480,
923,
63,
1291,
401,
1572,
14,
1291,
9,
267,
291,
14,
3773,
63,
692,
63,
1397,
63,
3592,
480,
923,
63,
12781,
401,
1572,
14,
12781,
9,
339,
347,
1218,
8,
277,
12,
1572,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
327,
1551,
63,
2634,
63,
1606,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
1073,
63,
505,
480,
2634,
3471,
4891,
342,
267,
327,
4205,
1572,
7143,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
1222,
3471,
4891,
342,
267,
291,
14,
4498,
63,
923,
63,
964,
8,
923,
9,
267,
327,
11482,
1572,
7143,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
7275,
3471,
4891,
342,
267,
291,
14,
1107,
63,
475,
63,
2634,
63,
1606,
342,
267,
291,
14,
923,
63,
1637,
275,
488,
339,
347,
5283,
63,
2246,
63,
923,
8,
277,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
3773,
63,
923,
63,
991,
63,
1080,
8,
16,
9,
339,
347,
5283,
63,
923,
63,
991,
63,
1080,
8,
277,
12,
1478,
12,
892,
63,
923,
63,
576,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
571,
14,
24148,
14,
1490,
63,
2634,
63,
1606,
342,
267,
291,
14,
2416,
63,
923,
63,
991,
63,
1080,
8,
1080,
9,
267,
327,
8968,
5283,
5528,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
3773,
3471,
4891,
342,
267,
291,
14,
4498,
63,
923,
63,
964,
8,
1222,
63,
923,
63,
576,
9,
267,
327,
11482,
325,
1671,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
873,
3471,
4891,
342,
267,
291,
14,
1107,
63,
475,
63,
2634,
63,
1606,
342,
267,
291,
14,
923,
63,
1637,
275,
488,
339,
347,
5283,
63,
923,
63,
991,
63,
344,
8,
277,
12,
1305,
12,
892,
63,
923,
63,
576,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
291,
14,
571,
14,
24148,
14,
1490,
63,
2634,
63,
1606,
342,
267,
291,
14,
2416,
63,
923,
63,
991,
63,
344,
8,
344,
9,
267,
327,
8968,
5283,
5528,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
3773,
3471,
4891,
342,
267,
291,
14,
4498,
63,
923,
63,
964,
8,
1222,
63,
923,
63,
576,
9,
267,
327,
11482,
325,
1671,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
873,
3471,
4891,
342,
267,
291,
14,
1107,
63,
475,
63,
2634,
63,
1606,
342,
267,
291,
14,
923,
63,
1637,
275,
488,
339,
347,
1050,
63,
5511,
63,
7811,
63,
475,
63,
5511,
63,
923,
63,
991,
63,
344,
8,
277,
12,
1347,
63,
923,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
327,
221,
5806,
7413,
11487,
7753,
17445,
7413,
16961,
22213,
17445,
23645,
13111,
113,
5657,
31235,
142,
232,
16863,
118,
24071,
23645,
6500,
8474,
8381,
119,
267,
370,
63,
923,
275,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
475,
63,
923,
531,
267,
370,
63,
923,
14,
4891,
342,
267,
327,
22213,
17445,
141,
110,
26438,
19820,
7753,
5806,
16863,
116,
19630,
26927,
16961,
7592,
8381,
118,
7038,
112,
7753,
12195,
23645,
23645,
17445,
19820,
5806,
574,
267,
370,
63,
923,
14,
1623,
63,
2108,
63,
991,
63,
3919,
63,
6662,
10994,
585,
9569,
83,
18721,
450,
1347,
63,
923,
14,
344,
680,
4891,
342,
267,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
525,
3471,
4891,
342,
339,
347,
3504,
63,
3972,
63,
923,
63,
475,
63,
1345,
8,
277,
12,
1347,
63,
923,
304,
267,
20792,
275,
291,
14,
571,
14,
2989,
267,
327,
221,
5806,
7413,
11487,
7753,
17445,
7413,
16961,
22213,
17445,
23645,
13111,
113,
5657,
31235,
142,
232,
16863,
118,
24071,
23645,
6500,
8474,
8381,
119,
267,
2455,
63,
923,
275,
20792,
14,
1623,
63,
2108,
63,
991,
63,
354,
480,
923,
531,
267,
2455,
63,
923,
14,
4891,
342,
267,
327,
22213,
17445,
141,
110,
26438,
19820,
7753,
5806,
16863,
116,
19630,
26927,
16961,
7592,
8381,
118,
7038,
112,
7753,
12195,
23645,
23645,
17445,
19820,
5806,
574,
267,
2455,
63,
923,
14,
1623,
63,
2108,
63,
991,
63,
3919,
63,
6662,
10994,
585,
9569,
83,
18721,
450,
1347,
63,
923,
14,
344,
680,
4891,
342,
199,
199,
3,
259,
347,
8968,
63,
525,
63,
7811,
63,
475,
63,
923,
63,
3887,
8,
277,
304,
199,
327,
755,
20792,
275,
291,
14,
571,
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,
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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
] |
raphaelfruneaux/thumbor
|
thumbor/detectors/local_detector.py
|
14
|
2401
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# thumbor imaging service
# https://github.com/globocom/thumbor/wiki
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com timehome@corp.globo.com
from os.path import join, dirname, abspath, isabs
try:
import cv
except ImportError:
import cv2.cv as cv
from thumbor.point import FocalPoint
from thumbor.detectors import BaseDetector
class CascadeLoaderDetector(BaseDetector):
def load_cascade_file(self, module_path, cascade_file_path):
if not hasattr(self.__class__, 'cascade'):
if isabs(cascade_file_path):
cascade_file = cascade_file_path
else:
cascade_file = join(abspath(dirname(module_path)), cascade_file_path)
self.__class__.cascade = cv.Load(cascade_file)
def get_min_size_for(self, size):
ratio = int(min(size) / 15)
ratio = max(20, ratio)
return (ratio, ratio)
def get_features(self):
engine = self.context.modules.engine
mode, converted_image = engine.image_data_as_rgb(False)
size = engine.size
image = cv.CreateImageHeader(size, cv.IPL_DEPTH_8U, 3)
cv.SetData(image, converted_image)
gray = cv.CreateImage(size, 8, 1)
convert_mode = getattr(cv, 'CV_%s2GRAY' % mode)
cv.CvtColor(image, gray, convert_mode)
min_size = self.get_min_size_for(size)
haar_scale = 1.2
min_neighbors = 3
cv.EqualizeHist(gray, gray)
faces = cv.HaarDetectObjects(
gray,
self.__class__.cascade, cv.CreateMemStorage(0),
haar_scale, min_neighbors,
cv.CV_HAAR_DO_CANNY_PRUNING, min_size)
faces_scaled = []
for ((x, y, w, h), n) in faces:
# the input to cv.HaarDetectObjects was resized, so scale the
# bounding box of each face and convert it to two CvPoints
x2, y2 = (x + w), (y + h)
faces_scaled.append(((x, y, x2 - x, y2 - y), n))
return faces_scaled
def detect(self, callback):
features = self.get_features()
if features:
for square, neighbors in features:
self.context.request.focal_points.append(FocalPoint.from_square(*square))
callback()
else:
self.next(callback)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
21541,
269,
18884,
1540,
2435,
199,
3,
4178,
921,
5031,
14,
957,
15,
30737,
656,
957,
15,
16534,
269,
15,
6797,
199,
199,
3,
3909,
1334,
314,
10697,
4190,
26,
199,
3,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
199,
3,
1898,
334,
67,
9,
7760,
486,
320,
656,
14,
957,
900,
4219,
32,
989,
80,
14,
30737,
656,
14,
957,
199,
199,
504,
747,
14,
515,
492,
4263,
12,
9017,
12,
19529,
12,
365,
2101,
199,
199,
893,
26,
272,
492,
6277,
199,
2590,
3545,
26,
272,
492,
6277,
18,
14,
5107,
465,
6277,
199,
199,
504,
21541,
269,
14,
1403,
492,
481,
24560,
3428,
199,
504,
21541,
269,
14,
19401,
83,
492,
3523,
24402,
421,
199,
533,
445,
305,
9490,
5455,
24402,
8,
1563,
24402,
304,
339,
347,
2248,
63,
15377,
63,
493,
8,
277,
12,
859,
63,
515,
12,
22809,
63,
493,
63,
515,
304,
267,
340,
440,
2688,
8,
277,
855,
533,
3108,
283,
15377,
735,
288,
340,
365,
2101,
8,
15377,
63,
493,
63,
515,
304,
355,
22809,
63,
493,
275,
22809,
63,
493,
63,
515,
288,
587,
26,
355,
22809,
63,
493,
275,
4263,
8,
4832,
8,
3475,
8,
578,
63,
515,
1826,
22809,
63,
493,
63,
515,
9,
288,
291,
855,
533,
4343,
15377,
275,
6277,
14,
6200,
8,
15377,
63,
493,
9,
339,
347,
664,
63,
827,
63,
890,
63,
509,
8,
277,
12,
1568,
304,
267,
10463,
275,
1109,
8,
827,
8,
890,
9,
1182,
4114,
9,
267,
10463,
275,
1390,
8,
1165,
12,
10463,
9,
267,
372,
334,
6884,
12,
10463,
9,
339,
347,
664,
63,
3179,
8,
277,
304,
267,
6869,
275,
291,
14,
1100,
14,
3112,
14,
3908,
398,
818,
12,
6702,
63,
1569,
275,
6869,
14,
1569,
63,
576,
63,
305,
63,
10090,
8,
797,
9,
267,
1568,
275,
6869,
14,
890,
398,
1834,
275,
6277,
14,
2499,
3491,
2567,
8,
890,
12,
6277,
14,
1772,
44,
63,
19715,
63,
24,
53,
12,
650,
9,
267,
6277,
14,
1084,
1451,
8,
1569,
12,
6702,
63,
1569,
9,
398,
21977,
275,
6277,
14,
2499,
3491,
8,
890,
12,
1695,
12,
413,
9,
267,
3957,
63,
632,
275,
2519,
8,
5107,
12,
283,
12847,
4970,
83,
18,
18583,
57,
7,
450,
818,
9,
267,
6277,
14,
35,
5941,
4117,
8,
1569,
12,
21977,
12,
3957,
63,
632,
9,
398,
1748,
63,
890,
275,
291,
14,
362,
63,
827,
63,
890,
63,
509,
8,
890,
9,
267,
18251,
285,
63,
3467,
275,
413,
14,
18,
267,
1748,
63,
11113,
275,
650,
398,
6277,
14,
591,
794,
27785,
8,
12150,
12,
21977,
9,
398,
21143,
275,
6277,
14,
15739,
285,
20064,
11188,
8,
288,
21977,
12,
288,
291,
855,
533,
4343,
15377,
12,
6277,
14,
2499,
14169,
6408,
8,
16,
395,
288,
18251,
285,
63,
3467,
12,
1748,
63,
11113,
12,
288,
6277,
14,
12847,
63,
6294,
689,
63,
1649,
63,
18988,
27437,
63,
3311,
1734,
1206,
12,
1748,
63,
890,
9,
398,
21143,
63,
15120,
275,
942,
398,
367,
3666,
88,
12,
612,
12,
336,
12,
394,
395,
302,
9,
315,
21143,
26,
288,
327,
314,
1324,
370,
6277,
14,
15739,
285,
20064,
11188,
1990,
295,
15308,
12,
880,
4666,
314,
288,
327,
16842,
5689,
402,
1924,
8870,
436,
3957,
652,
370,
2877,
445,
86,
10225,
288,
671,
18,
12,
612,
18,
275,
334,
88,
435,
336,
395,
334,
89,
435,
394,
9,
288,
21143,
63,
15120,
14,
740,
12925,
88,
12,
612,
12,
671,
18,
446,
671,
12,
612,
18,
446,
612,
395,
302,
430,
398,
372,
21143,
63,
15120,
339,
347,
9696,
8,
277,
12,
3233,
304,
267,
4534,
275,
291,
14,
362,
63,
3179,
342,
398,
340,
4534,
26,
288,
367,
12386,
12,
15845,
315,
4534,
26,
355,
291,
14,
1100,
14,
1069,
14,
545,
915,
63,
3438,
14,
740,
8,
38,
24560,
3428,
14,
504,
63,
9646,
2031,
9646,
430,
288,
3233,
342,
267,
587,
26,
288,
291,
14,
2184,
8,
3058,
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
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
21541,
269,
18884,
1540,
2435,
199,
3,
4178,
921,
5031,
14,
957,
15,
30737,
656,
957,
15,
16534,
269,
15,
6797,
199,
199,
3,
3909,
1334,
314,
10697,
4190,
26,
199,
3,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
199,
3,
1898,
334,
67,
9,
7760,
486,
320,
656,
14,
957,
900,
4219,
32,
989,
80,
14,
30737,
656,
14,
957,
199,
199,
504,
747,
14,
515,
492,
4263,
12,
9017,
12,
19529,
12,
365,
2101,
199,
199,
893,
26,
272,
492,
6277,
199,
2590,
3545,
26,
272,
492,
6277,
18,
14,
5107,
465,
6277,
199,
199,
504,
21541,
269,
14,
1403,
492,
481,
24560,
3428,
199,
504,
21541,
269,
14,
19401,
83,
492,
3523,
24402,
421,
199,
533,
445,
305,
9490,
5455,
24402,
8,
1563,
24402,
304,
339,
347,
2248,
63,
15377,
63,
493,
8,
277,
12,
859,
63,
515,
12,
22809,
63,
493,
63,
515,
304,
267,
340,
440,
2688,
8,
277,
855,
533,
3108,
283,
15377,
735,
288,
340,
365,
2101,
8,
15377,
63,
493,
63,
515,
304,
355,
22809,
63,
493,
275,
22809,
63,
493,
63,
515,
288,
587,
26,
355,
22809,
63,
493,
275,
4263,
8,
4832,
8,
3475,
8,
578,
63,
515,
1826,
22809,
63,
493,
63,
515,
9,
288,
291,
855,
533,
4343,
15377,
275,
6277,
14,
6200,
8,
15377,
63,
493,
9,
339,
347,
664,
63,
827,
63,
890,
63,
509,
8,
277,
12,
1568,
304,
267,
10463,
275,
1109,
8,
827,
8,
890,
9,
1182,
4114,
9,
267,
10463,
275,
1390,
8,
1165,
12,
10463,
9,
267,
372,
334,
6884,
12,
10463,
9,
339,
347,
664,
63,
3179,
8,
277,
304,
267,
6869,
275,
291,
14,
1100,
14,
3112,
14,
3908,
398,
818,
12,
6702,
63,
1569,
275,
6869,
14,
1569,
63,
576,
63,
305,
63,
10090,
8,
797,
9,
267,
1568,
275,
6869,
14,
890,
398,
1834,
275,
6277,
14,
2499,
3491,
2567,
8,
890,
12,
6277,
14,
1772,
44,
63,
19715,
63,
24,
53,
12,
650,
9,
267,
6277,
14,
1084,
1451,
8,
1569,
12,
6702,
63,
1569,
9,
398,
21977,
275,
6277,
14,
2499,
3491,
8,
890,
12,
1695,
12,
413,
9,
267,
3957,
63,
632,
275,
2519,
8,
5107,
12,
283,
12847,
4970,
83,
18,
18583,
57,
7,
450,
818,
9,
267,
6277,
14,
35,
5941,
4117,
8,
1569,
12,
21977,
12,
3957,
63,
632,
9,
398,
1748,
63,
890,
275,
291,
14,
362,
63,
827,
63,
890,
63,
509,
8,
890,
9,
267,
18251,
285,
63,
3467,
275,
413,
14,
18,
267,
1748,
63,
11113,
275,
650,
398,
6277,
14,
591,
794,
27785,
8,
12150,
12,
21977,
9,
398,
21143,
275,
6277,
14,
15739,
285,
20064,
11188,
8,
288,
21977,
12,
288,
291,
855,
533,
4343,
15377,
12,
6277,
14,
2499,
14169,
6408,
8,
16,
395,
288,
18251,
285,
63,
3467,
12,
1748,
63,
11113,
12,
288,
6277,
14,
12847,
63,
6294,
689,
63,
1649,
63,
18988,
27437,
63,
3311,
1734,
1206,
12,
1748,
63,
890,
9,
398,
21143,
63,
15120,
275,
942,
398,
367,
3666,
88,
12,
612,
12,
336,
12,
394,
395,
302,
9,
315,
21143,
26,
288,
327,
314,
1324,
370,
6277,
14,
15739,
285,
20064,
11188,
1990,
295,
15308,
12,
880,
4666,
314,
288,
327,
16842,
5689,
402,
1924,
8870,
436,
3957,
652,
370,
2877,
445,
86,
10225,
288,
671,
18,
12,
612,
18,
275,
334,
88,
435,
336,
395,
334,
89,
435,
394,
9,
288,
21143,
63,
15120,
14,
740,
12925,
88,
12,
612,
12,
671,
18,
446,
671,
12,
612,
18,
446,
612,
395,
302,
430,
398,
372,
21143,
63,
15120,
339,
347,
9696,
8,
277,
12,
3233,
304,
267,
4534,
275,
291,
14,
362,
63,
3179,
342,
398,
340,
4534,
26,
288,
367,
12386,
12,
15845,
315,
4534,
26,
355,
291,
14,
1100,
14,
1069,
14,
545,
915,
63,
3438,
14,
740,
8,
38,
24560,
3428,
14,
504,
63,
9646,
2031,
9646,
430,
288,
3233,
342,
267,
587,
26,
288,
291,
14,
2184,
8,
3058,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
subdigital/nsdateformatter.com
|
node_modules/node-gyp/gyp/pylib/gyp/common.py
|
64
|
20173
|
# 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.
from __future__ import with_statement
import collections
import errno
import filecmp
import os.path
import re
import tempfile
import sys
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
# among other "problems".
class memoize(object):
def __init__(self, func):
self.func = func
self.cache = {}
def __call__(self, *args):
try:
return self.cache[args]
except KeyError:
result = self.func(*args)
self.cache[args] = result
return result
class GypError(Exception):
"""Error class representing an error, which is to be presented
to the user. The main entry point will catch and display this.
"""
pass
def ExceptionAppend(e, msg):
"""Append a message to the given exception's message."""
if not e.args:
e.args = (msg,)
elif len(e.args) == 1:
e.args = (str(e.args[0]) + ' ' + msg,)
else:
e.args = (str(e.args[0]) + ' ' + msg,) + e.args[1:]
def FindQualifiedTargets(target, qualified_list):
"""
Given a list of qualified targets, return the qualified targets for the
specified |target|.
"""
return [t for t in qualified_list if ParseQualifiedTarget(t)[1] == target]
def ParseQualifiedTarget(target):
# Splits a qualified target into a build file, target name and toolset.
# NOTE: rsplit is used to disambiguate the Windows drive letter separator.
target_split = target.rsplit(':', 1)
if len(target_split) == 2:
[build_file, target] = target_split
else:
build_file = None
target_split = target.rsplit('#', 1)
if len(target_split) == 2:
[target, toolset] = target_split
else:
toolset = None
return [build_file, target, toolset]
def ResolveTarget(build_file, target, toolset):
# This function resolves a target into a canonical form:
# - a fully defined build file, either absolute or relative to the current
# directory
# - a target name
# - a toolset
#
# build_file is the file relative to which 'target' is defined.
# target is the qualified target.
# toolset is the default toolset for that target.
[parsed_build_file, target, parsed_toolset] = ParseQualifiedTarget(target)
if parsed_build_file:
if build_file:
# If a relative path, parsed_build_file is relative to the directory
# containing build_file. If build_file is not in the current directory,
# parsed_build_file is not a usable path as-is. Resolve it by
# interpreting it as relative to build_file. If parsed_build_file is
# absolute, it is usable as a path regardless of the current directory,
# and os.path.join will return it as-is.
build_file = os.path.normpath(os.path.join(os.path.dirname(build_file),
parsed_build_file))
# Further (to handle cases like ../cwd), make it relative to cwd)
if not os.path.isabs(build_file):
build_file = RelativePath(build_file, '.')
else:
build_file = parsed_build_file
if parsed_toolset:
toolset = parsed_toolset
return [build_file, target, toolset]
def BuildFile(fully_qualified_target):
# Extracts the build file from the fully qualified target.
return ParseQualifiedTarget(fully_qualified_target)[0]
def GetEnvironFallback(var_list, default):
"""Look up a key in the environment, with fallback to secondary keys
and finally falling back to a default value."""
for var in var_list:
if var in os.environ:
return os.environ[var]
return default
def QualifiedTarget(build_file, target, toolset):
# "Qualified" means the file that a target was defined in and the target
# name, separated by a colon, suffixed by a # and the toolset name:
# /path/to/file.gyp:target_name#toolset
fully_qualified = build_file + ':' + target
if toolset:
fully_qualified = fully_qualified + '#' + toolset
return fully_qualified
@memoize
def RelativePath(path, relative_to, follow_path_symlink=True):
# Assuming both |path| and |relative_to| are relative to the current
# directory, returns a relative path that identifies path relative to
# relative_to.
# If |follow_symlink_path| is true (default) and |path| is a symlink, then
# this method returns a path to the real file represented by |path|. If it is
# false, this method returns a path to the symlink. If |path| is not a
# symlink, this option has no effect.
# Convert to normalized (and therefore absolute paths).
if follow_path_symlink:
path = os.path.realpath(path)
else:
path = os.path.abspath(path)
relative_to = os.path.realpath(relative_to)
# On Windows, we can't create a relative path to a different drive, so just
# use the absolute path.
if sys.platform == 'win32':
if (os.path.splitdrive(path)[0].lower() !=
os.path.splitdrive(relative_to)[0].lower()):
return path
# Split the paths into components.
path_split = path.split(os.path.sep)
relative_to_split = relative_to.split(os.path.sep)
# Determine how much of the prefix the two paths share.
prefix_len = len(os.path.commonprefix([path_split, relative_to_split]))
# Put enough ".." components to back up out of relative_to to the common
# prefix, and then append the part of path_split after the common prefix.
relative_split = [os.path.pardir] * (len(relative_to_split) - prefix_len) + \
path_split[prefix_len:]
if len(relative_split) == 0:
# The paths were the same.
return ''
# Turn it back into a string and we're done.
return os.path.join(*relative_split)
@memoize
def InvertRelativePath(path, toplevel_dir=None):
"""Given a path like foo/bar that is relative to toplevel_dir, return
the inverse relative path back to the toplevel_dir.
E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path)))
should always produce the empty string, unless the path contains symlinks.
"""
if not path:
return path
toplevel_dir = '.' if toplevel_dir is None else toplevel_dir
return RelativePath(toplevel_dir, os.path.join(toplevel_dir, path))
def FixIfRelativePath(path, relative_to):
# Like RelativePath but returns |path| unchanged if it is absolute.
if os.path.isabs(path):
return path
return RelativePath(path, relative_to)
def UnrelativePath(path, relative_to):
# Assuming that |relative_to| is relative to the current directory, and |path|
# is a path relative to the dirname of |relative_to|, returns a path that
# identifies |path| relative to the current directory.
rel_dir = os.path.dirname(relative_to)
return os.path.normpath(os.path.join(rel_dir, path))
# re objects used by EncodePOSIXShellArgument. See IEEE 1003.1 XCU.2.2 at
# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02
# and the documentation for various shells.
# _quote is a pattern that should match any argument that needs to be quoted
# with double-quotes by EncodePOSIXShellArgument. It matches the following
# characters appearing anywhere in an argument:
# \t, \n, space parameter separators
# # comments
# $ expansions (quoted to always expand within one argument)
# % called out by IEEE 1003.1 XCU.2.2
# & job control
# ' quoting
# (, ) subshell execution
# *, ?, [ pathname expansion
# ; command delimiter
# <, >, | redirection
# = assignment
# {, } brace expansion (bash)
# ~ tilde expansion
# It also matches the empty string, because "" (or '') is the only way to
# represent an empty string literal argument to a POSIX shell.
#
# This does not match the characters in _escape, because those need to be
# backslash-escaped regardless of whether they appear in a double-quoted
# string.
_quote = re.compile('[\t\n #$%&\'()*;<=>?[{|}~]|^$')
# _escape is a pattern that should match any character that needs to be
# escaped with a backslash, whether or not the argument matched the _quote
# pattern. _escape is used with re.sub to backslash anything in _escape's
# first match group, hence the (parentheses) in the regular expression.
#
# _escape matches the following characters appearing anywhere in an argument:
# " to prevent POSIX shells from interpreting this character for quoting
# \ to prevent POSIX shells from interpreting this character for escaping
# ` to prevent POSIX shells from interpreting this character for command
# substitution
# Missing from this list is $, because the desired behavior of
# EncodePOSIXShellArgument is to permit parameter (variable) expansion.
#
# Also missing from this list is !, which bash will interpret as the history
# expansion character when history is enabled. bash does not enable history
# by default in non-interactive shells, so this is not thought to be a problem.
# ! was omitted from this list because bash interprets "\!" as a literal string
# including the backslash character (avoiding history expansion but retaining
# the backslash), which would not be correct for argument encoding. Handling
# this case properly would also be problematic because bash allows the history
# character to be changed with the histchars shell variable. Fortunately,
# as history is not enabled in non-interactive shells and
# EncodePOSIXShellArgument is only expected to encode for non-interactive
# shells, there is no room for error here by ignoring !.
_escape = re.compile(r'(["\\`])')
def EncodePOSIXShellArgument(argument):
"""Encodes |argument| suitably for consumption by POSIX shells.
argument may be quoted and escaped as necessary to ensure that POSIX shells
treat the returned value as a literal representing the argument passed to
this function. Parameter (variable) expansions beginning with $ are allowed
to remain intact without escaping the $, to allow the argument to contain
references to variables to be expanded by the shell.
"""
if not isinstance(argument, str):
argument = str(argument)
if _quote.search(argument):
quote = '"'
else:
quote = ''
encoded = quote + re.sub(_escape, r'\\\1', argument) + quote
return encoded
def EncodePOSIXShellList(list):
"""Encodes |list| suitably for consumption by POSIX shells.
Returns EncodePOSIXShellArgument for each item in list, and joins them
together using the space character as an argument separator.
"""
encoded_arguments = []
for argument in list:
encoded_arguments.append(EncodePOSIXShellArgument(argument))
return ' '.join(encoded_arguments)
def DeepDependencyTargets(target_dicts, roots):
"""Returns the recursive list of target dependencies."""
dependencies = set()
pending = set(roots)
while pending:
# Pluck out one.
r = pending.pop()
# Skip if visited already.
if r in dependencies:
continue
# Add it.
dependencies.add(r)
# Add its children.
spec = target_dicts[r]
pending.update(set(spec.get('dependencies', [])))
pending.update(set(spec.get('dependencies_original', [])))
return list(dependencies - set(roots))
def BuildFileTargets(target_list, build_file):
"""From a target_list, returns the subset from the specified build_file.
"""
return [p for p in target_list if BuildFile(p) == build_file]
def AllTargets(target_list, target_dicts, build_file):
"""Returns all targets (direct and dependencies) for the specified build_file.
"""
bftargets = BuildFileTargets(target_list, build_file)
deptargets = DeepDependencyTargets(target_dicts, bftargets)
return bftargets + deptargets
def WriteOnDiff(filename):
"""Write to a file only if the new contents differ.
Arguments:
filename: name of the file to potentially write to.
Returns:
A file like object which will write to temporary file and only overwrite
the target if it differs (on close).
"""
class Writer(object):
"""Wrapper around file which only covers the target if it differs."""
def __init__(self):
# Pick temporary file.
tmp_fd, self.tmp_path = tempfile.mkstemp(
suffix='.tmp',
prefix=os.path.split(filename)[1] + '.gyp.',
dir=os.path.split(filename)[0])
try:
self.tmp_file = os.fdopen(tmp_fd, 'wb')
except Exception:
# Don't leave turds behind.
os.unlink(self.tmp_path)
raise
def __getattr__(self, attrname):
# Delegate everything else to self.tmp_file
return getattr(self.tmp_file, attrname)
def close(self):
try:
# Close tmp file.
self.tmp_file.close()
# Determine if different.
same = False
try:
same = filecmp.cmp(self.tmp_path, filename, False)
except OSError, e:
if e.errno != errno.ENOENT:
raise
if same:
# The new file is identical to the old one, just get rid of the new
# one.
os.unlink(self.tmp_path)
else:
# The new file is different from the old one, or there is no old one.
# Rename the new file to the permanent name.
#
# tempfile.mkstemp uses an overly restrictive mode, resulting in a
# file that can only be read by the owner, regardless of the umask.
# There's no reason to not respect the umask here, which means that
# an extra hoop is required to fetch it and reset the new file's mode.
#
# No way to get the umask without setting a new one? Set a safe one
# and then set it back to the old value.
umask = os.umask(077)
os.umask(umask)
os.chmod(self.tmp_path, 0666 & ~umask)
if sys.platform == 'win32' and os.path.exists(filename):
# NOTE: on windows (but not cygwin) rename will not replace an
# existing file, so it must be preceded with a remove. Sadly there
# is no way to make the switch atomic.
os.remove(filename)
os.rename(self.tmp_path, filename)
except Exception:
# Don't leave turds behind.
os.unlink(self.tmp_path)
raise
return Writer()
def EnsureDirExists(path):
"""Make sure the directory for |path| exists."""
try:
os.makedirs(os.path.dirname(path))
except OSError:
pass
def GetFlavor(params):
"""Returns |params.flavor| if it's set, the system's default flavor else."""
flavors = {
'cygwin': 'win',
'win32': 'win',
'darwin': 'mac',
}
if 'flavor' in params:
return params['flavor']
if sys.platform in flavors:
return flavors[sys.platform]
if sys.platform.startswith('sunos'):
return 'solaris'
if sys.platform.startswith('freebsd'):
return 'freebsd'
if sys.platform.startswith('openbsd'):
return 'openbsd'
if sys.platform.startswith('netbsd'):
return 'netbsd'
if sys.platform.startswith('aix'):
return 'aix'
if sys.platform.startswith('zos'):
return 'zos'
if sys.platform.startswith('os390'):
return 'zos'
return 'linux'
def CopyTool(flavor, out_path):
"""Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it
to |out_path|."""
# aix and solaris just need flock emulation. mac and win use more complicated
# support scripts.
prefix = {
'aix': 'flock',
'solaris': 'flock',
'mac': 'mac',
'win': 'win'
}.get(flavor, None)
if not prefix:
return
# Slurp input file.
source_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), '%s_tool.py' % prefix)
with open(source_path) as source_file:
source = source_file.readlines()
# Add header and write it out.
tool_path = os.path.join(out_path, 'gyp-%s-tool' % prefix)
with open(tool_path, 'w') as tool_file:
tool_file.write(
''.join([source[0], '# Generated by gyp. Do not edit.\n'] + source[1:]))
# Make file executable.
os.chmod(tool_path, 0755)
# From Alex Martelli,
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560
# ASPN: Python Cookbook: Remove duplicates from a sequence
# First comment, dated 2001/10/13.
# (Also in the printed Python Cookbook.)
def uniquer(seq, idfun=None):
if idfun is None:
idfun = lambda x: x
seen = {}
result = []
for item in seq:
marker = idfun(item)
if marker in seen: continue
seen[marker] = 1
result.append(item)
return result
# Based on http://code.activestate.com/recipes/576694/.
class OrderedSet(collections.MutableSet):
def __init__(self, iterable=None):
self.end = end = []
end += [None, end, end] # sentinel node for doubly linked list
self.map = {} # key --> [key, prev, next]
if iterable is not None:
self |= iterable
def __len__(self):
return len(self.map)
def __contains__(self, key):
return key in self.map
def add(self, key):
if key not in self.map:
end = self.end
curr = end[1]
curr[2] = end[1] = self.map[key] = [key, curr, end]
def discard(self, key):
if key in self.map:
key, prev_item, next_item = self.map.pop(key)
prev_item[2] = next_item
next_item[1] = prev_item
def __iter__(self):
end = self.end
curr = end[2]
while curr is not end:
yield curr[0]
curr = curr[2]
def __reversed__(self):
end = self.end
curr = end[1]
while curr is not end:
yield curr[0]
curr = curr[1]
# The second argument is an addition that causes a pylint warning.
def pop(self, last=True): # pylint: disable=W0221
if not self:
raise KeyError('set is empty')
key = self.end[1][0] if last else self.end[2][0]
self.discard(key)
return key
def __repr__(self):
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, list(self))
def __eq__(self, other):
if isinstance(other, OrderedSet):
return len(self) == len(other) and list(self) == list(other)
return set(self) == set(other)
# Extensions to the recipe.
def update(self, iterable):
for i in iterable:
if i not in self:
self.add(i)
class CycleError(Exception):
"""An exception raised when an unexpected cycle is detected."""
def __init__(self, nodes):
self.nodes = nodes
def __str__(self):
return 'CycleError: cycle involving: ' + str(self.nodes)
def TopologicallySorted(graph, get_edges):
r"""Topologically sort based on a user provided edge definition.
Args:
graph: A list of node names.
get_edges: A function mapping from node name to a hashable collection
of node names which this node has outgoing edges to.
Returns:
A list containing all of the node in graph in topological order.
It is assumed that calling get_edges once for each node and caching is
cheaper than repeatedly calling get_edges.
Raises:
CycleError in the event of a cycle.
Example:
graph = {'a': '$(b) $(c)', 'b': 'hi', 'c': '$(b)'}
def GetEdges(node):
return re.findall(r'\$\(([^))]\)', graph[node])
print TopologicallySorted(graph.keys(), GetEdges)
==>
['a', 'c', b']
"""
get_edges = memoize(get_edges)
visited = set()
visiting = set()
ordered_nodes = []
def Visit(node):
if node in visiting:
raise CycleError(visiting)
if node in visited:
return
visited.add(node)
visiting.add(node)
for neighbor in get_edges(node):
Visit(neighbor)
visiting.remove(node)
ordered_nodes.insert(0, node)
for node in sorted(graph):
Visit(node)
return ordered_nodes
def CrossCompileRequested():
# TODO: figure out how to not build extra host objects in the
# non-cross-compile case when this is enabled, and enable unconditionally.
return (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'))
|
mit
|
[
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,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
570,
5730,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
5549,
199,
646,
984,
421,
199,
3,
437,
13460,
11955,
9147,
7531,
14,
2779,
7171,
28511,
1536,
340,
314,
1249,
10621,
1133,
17092,
12,
199,
3,
16885,
1163,
298,
22959,
1674,
199,
533,
11955,
794,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
2562,
304,
272,
291,
14,
1532,
275,
2562,
272,
291,
14,
1637,
275,
1052,
523,
347,
636,
1250,
721,
277,
12,
627,
589,
304,
272,
862,
26,
489,
372,
291,
14,
1637,
59,
589,
61,
272,
871,
4067,
26,
489,
754,
275,
291,
14,
1532,
2031,
589,
9,
489,
291,
14,
1637,
59,
589,
61,
275,
754,
489,
372,
754,
421,
199,
533,
18151,
8,
1726,
304,
523,
408,
547,
1021,
6144,
376,
1125,
12,
1314,
365,
370,
506,
26568,
523,
370,
314,
922,
14,
221,
710,
2446,
2397,
2376,
911,
8579,
436,
2929,
642,
14,
523,
408,
523,
986,
421,
199,
318,
2186,
8310,
8,
69,
12,
1499,
304,
523,
408,
8310,
282,
1245,
370,
314,
1627,
1919,
1159,
1245,
1041,
523,
340,
440,
325,
14,
589,
26,
272,
325,
14,
589,
275,
334,
1328,
4258,
523,
916,
822,
8,
69,
14,
589,
9,
508,
413,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
523,
587,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
435,
325,
14,
589,
59,
17,
2938,
421,
199,
318,
6668,
23279,
14126,
8,
1375,
12,
12313,
63,
513,
304,
523,
408,
523,
9138,
282,
769,
402,
12313,
4545,
12,
372,
314,
12313,
4545,
367,
314,
523,
2013,
1204,
1375,
18257,
523,
408,
523,
372,
359,
84,
367,
307,
315,
12313,
63,
513,
340,
6077,
30663,
8,
84,
2788,
17,
61,
508,
1347,
61,
421,
199,
318,
6077,
30663,
8,
1375,
304,
523,
327,
11740,
83,
282,
12313,
1347,
1901,
282,
1900,
570,
12,
1347,
536,
436,
20070,
14,
819,
327,
6944,
26,
519,
1294,
365,
1202,
370,
2153,
16902,
4767,
314,
5417,
12912,
8082,
9432,
14,
523,
1347,
63,
1294,
275,
1347,
14,
13490,
16451,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1506,
63,
493,
12,
1347,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
1900,
63,
493,
275,
488,
819,
1347,
63,
1294,
275,
1347,
14,
13490,
7863,
297,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1375,
12,
20070,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
20070,
275,
488,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
31096,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
961,
805,
32253,
282,
1347,
1901,
282,
11358,
1824,
26,
523,
327,
446,
282,
9999,
3247,
1900,
570,
12,
1902,
3679,
503,
3847,
370,
314,
1453,
523,
327,
2082,
523,
327,
446,
282,
1347,
536,
523,
327,
446,
282,
20070,
523,
327,
523,
327,
1900,
63,
493,
365,
314,
570,
3847,
370,
1314,
283,
1375,
7,
365,
3247,
14,
523,
327,
1347,
365,
314,
12313,
1347,
14,
523,
327,
20070,
365,
314,
849,
20070,
367,
626,
1347,
14,
523,
359,
6751,
63,
1506,
63,
493,
12,
1347,
12,
4565,
63,
12081,
61,
275,
6077,
30663,
8,
1375,
9,
819,
340,
4565,
63,
1506,
63,
493,
26,
272,
340,
1900,
63,
493,
26,
489,
327,
982,
282,
3847,
931,
12,
4565,
63,
1506,
63,
493,
365,
3847,
370,
314,
2082,
489,
327,
3035,
1900,
63,
493,
14,
221,
982,
1900,
63,
493,
365,
440,
315,
314,
1453,
2082,
12,
489,
327,
4565,
63,
1506,
63,
493,
365,
440,
282,
18025,
931,
465,
13,
374,
14,
221,
31096,
652,
701,
489,
327,
6421,
1337,
652,
465,
3847,
370,
1900,
63,
493,
14,
221,
982,
4565,
63,
1506,
63,
493,
365,
489,
327,
3679,
12,
652,
365,
18025,
465,
282,
931,
15270,
402,
314,
1453,
2082,
12,
489,
327,
436,
747,
14,
515,
14,
904,
911,
372,
652,
465,
13,
374,
14,
489,
1900,
63,
493,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
1506,
63,
493,
395,
1740,
4565,
63,
1506,
63,
493,
430,
489,
327,
28876,
334,
475,
2429,
5560,
2839,
24272,
6525,
395,
1852,
652,
3847,
370,
8288,
9,
489,
340,
440,
747,
14,
515,
14,
17896,
8,
1506,
63,
493,
304,
267,
1900,
63,
493,
275,
22419,
2042,
8,
1506,
63,
493,
12,
20093,
272,
587,
26,
489,
1900,
63,
493,
275,
4565,
63,
1506,
63,
493,
819,
340,
4565,
63,
12081,
26,
272,
20070,
275,
4565,
63,
12081,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
6516,
1173,
8,
5836,
63,
11661,
63,
1375,
304,
523,
327,
12892,
83,
314,
1900,
570,
687,
314,
9999,
12313,
1347,
14,
523,
372,
6077,
30663,
8,
5836,
63,
11661,
63,
1375,
2788,
16,
61,
421,
199,
318,
2372,
23027,
21860,
8,
1391,
63,
513,
12,
849,
304,
523,
408,
20926,
1536,
282,
790,
315,
314,
3734,
12,
543,
9567,
370,
13851,
2883,
523,
436,
3753,
32039,
1771,
370,
282,
849,
574,
1041,
523,
367,
2729,
315,
2729,
63,
513,
26,
272,
340,
2729,
315,
747,
14,
2314,
26,
489,
372,
747,
14,
2314,
59,
1391,
61,
523,
372,
849,
421,
199,
318,
19933,
4541,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
298,
23279,
2,
4910,
314,
570,
626,
282,
1347,
1990,
3247,
315,
436,
314,
1347,
523,
327,
536,
12,
11673,
701,
282,
18307,
12,
4739,
379,
701,
282,
327,
436,
314,
20070,
536,
26,
523,
327,
1182,
515,
15,
475,
15,
493,
14,
6179,
26,
1375,
63,
354,
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,
504,
636,
2443,
363,
492,
543,
63,
6242,
199,
199,
646,
5055,
199,
646,
7554,
199,
646,
570,
5730,
199,
646,
747,
14,
515,
199,
646,
295,
199,
646,
5549,
199,
646,
984,
421,
199,
3,
437,
13460,
11955,
9147,
7531,
14,
2779,
7171,
28511,
1536,
340,
314,
1249,
10621,
1133,
17092,
12,
199,
3,
16885,
1163,
298,
22959,
1674,
199,
533,
11955,
794,
8,
785,
304,
523,
347,
636,
826,
721,
277,
12,
2562,
304,
272,
291,
14,
1532,
275,
2562,
272,
291,
14,
1637,
275,
1052,
523,
347,
636,
1250,
721,
277,
12,
627,
589,
304,
272,
862,
26,
489,
372,
291,
14,
1637,
59,
589,
61,
272,
871,
4067,
26,
489,
754,
275,
291,
14,
1532,
2031,
589,
9,
489,
291,
14,
1637,
59,
589,
61,
275,
754,
489,
372,
754,
421,
199,
533,
18151,
8,
1726,
304,
523,
408,
547,
1021,
6144,
376,
1125,
12,
1314,
365,
370,
506,
26568,
523,
370,
314,
922,
14,
221,
710,
2446,
2397,
2376,
911,
8579,
436,
2929,
642,
14,
523,
408,
523,
986,
421,
199,
318,
2186,
8310,
8,
69,
12,
1499,
304,
523,
408,
8310,
282,
1245,
370,
314,
1627,
1919,
1159,
1245,
1041,
523,
340,
440,
325,
14,
589,
26,
272,
325,
14,
589,
275,
334,
1328,
4258,
523,
916,
822,
8,
69,
14,
589,
9,
508,
413,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
523,
587,
26,
272,
325,
14,
589,
275,
334,
495,
8,
69,
14,
589,
59,
16,
566,
435,
283,
283,
435,
1499,
4258,
435,
325,
14,
589,
59,
17,
2938,
421,
199,
318,
6668,
23279,
14126,
8,
1375,
12,
12313,
63,
513,
304,
523,
408,
523,
9138,
282,
769,
402,
12313,
4545,
12,
372,
314,
12313,
4545,
367,
314,
523,
2013,
1204,
1375,
18257,
523,
408,
523,
372,
359,
84,
367,
307,
315,
12313,
63,
513,
340,
6077,
30663,
8,
84,
2788,
17,
61,
508,
1347,
61,
421,
199,
318,
6077,
30663,
8,
1375,
304,
523,
327,
11740,
83,
282,
12313,
1347,
1901,
282,
1900,
570,
12,
1347,
536,
436,
20070,
14,
819,
327,
6944,
26,
519,
1294,
365,
1202,
370,
2153,
16902,
4767,
314,
5417,
12912,
8082,
9432,
14,
523,
1347,
63,
1294,
275,
1347,
14,
13490,
16451,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1506,
63,
493,
12,
1347,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
1900,
63,
493,
275,
488,
819,
1347,
63,
1294,
275,
1347,
14,
13490,
7863,
297,
413,
9,
523,
340,
822,
8,
1375,
63,
1294,
9,
508,
499,
26,
272,
359,
1375,
12,
20070,
61,
275,
1347,
63,
1294,
523,
587,
26,
272,
20070,
275,
488,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
31096,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
961,
805,
32253,
282,
1347,
1901,
282,
11358,
1824,
26,
523,
327,
446,
282,
9999,
3247,
1900,
570,
12,
1902,
3679,
503,
3847,
370,
314,
1453,
523,
327,
2082,
523,
327,
446,
282,
1347,
536,
523,
327,
446,
282,
20070,
523,
327,
523,
327,
1900,
63,
493,
365,
314,
570,
3847,
370,
1314,
283,
1375,
7,
365,
3247,
14,
523,
327,
1347,
365,
314,
12313,
1347,
14,
523,
327,
20070,
365,
314,
849,
20070,
367,
626,
1347,
14,
523,
359,
6751,
63,
1506,
63,
493,
12,
1347,
12,
4565,
63,
12081,
61,
275,
6077,
30663,
8,
1375,
9,
819,
340,
4565,
63,
1506,
63,
493,
26,
272,
340,
1900,
63,
493,
26,
489,
327,
982,
282,
3847,
931,
12,
4565,
63,
1506,
63,
493,
365,
3847,
370,
314,
2082,
489,
327,
3035,
1900,
63,
493,
14,
221,
982,
1900,
63,
493,
365,
440,
315,
314,
1453,
2082,
12,
489,
327,
4565,
63,
1506,
63,
493,
365,
440,
282,
18025,
931,
465,
13,
374,
14,
221,
31096,
652,
701,
489,
327,
6421,
1337,
652,
465,
3847,
370,
1900,
63,
493,
14,
221,
982,
4565,
63,
1506,
63,
493,
365,
489,
327,
3679,
12,
652,
365,
18025,
465,
282,
931,
15270,
402,
314,
1453,
2082,
12,
489,
327,
436,
747,
14,
515,
14,
904,
911,
372,
652,
465,
13,
374,
14,
489,
1900,
63,
493,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
1506,
63,
493,
395,
1740,
4565,
63,
1506,
63,
493,
430,
489,
327,
28876,
334,
475,
2429,
5560,
2839,
24272,
6525,
395,
1852,
652,
3847,
370,
8288,
9,
489,
340,
440,
747,
14,
515,
14,
17896,
8,
1506,
63,
493,
304,
267,
1900,
63,
493,
275,
22419,
2042,
8,
1506,
63,
493,
12,
20093,
272,
587,
26,
489,
1900,
63,
493,
275,
4565,
63,
1506,
63,
493,
819,
340,
4565,
63,
12081,
26,
272,
20070,
275,
4565,
63,
12081,
819,
372,
359,
1506,
63,
493,
12,
1347,
12,
20070,
61,
421,
199,
318,
6516,
1173,
8,
5836,
63,
11661,
63,
1375,
304,
523,
327,
12892,
83,
314,
1900,
570,
687,
314,
9999,
12313,
1347,
14,
523,
372,
6077,
30663,
8,
5836,
63,
11661,
63,
1375,
2788,
16,
61,
421,
199,
318,
2372,
23027,
21860,
8,
1391,
63,
513,
12,
849,
304,
523,
408,
20926,
1536,
282,
790,
315,
314,
3734,
12,
543,
9567,
370,
13851,
2883,
523,
436,
3753,
32039,
1771,
370,
282,
849,
574,
1041,
523,
367,
2729,
315,
2729,
63,
513,
26,
272,
340,
2729,
315,
747,
14,
2314,
26,
489,
372,
747,
14,
2314,
59,
1391,
61,
523,
372,
849,
421,
199,
318,
19933,
4541,
4277,
8,
1506,
63,
493,
12,
1347,
12,
20070,
304,
523,
327,
298,
23279,
2,
4910,
314,
570,
626,
282,
1347,
1990,
3247,
315,
436,
314,
1347,
523,
327,
536,
12,
11673,
701,
282,
18307,
12,
4739,
379,
701,
282,
327,
436,
314,
20070,
536,
26,
523,
327,
1182,
515,
15,
475,
15,
493,
14,
6179,
26,
1375,
63,
354,
3,
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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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
] |
tongwang01/tensorflow
|
tensorflow/models/rnn/ptb/reader.py
|
24
|
3992
|
# Copyright 2015 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.
# ==============================================================================
"""Utilities for parsing PTB text files."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import os
import tensorflow as tf
def _read_words(filename):
with tf.gfile.GFile(filename, "r") as f:
return f.read().decode("utf-8").replace("\n", "<eos>").split()
def _build_vocab(filename):
data = _read_words(filename)
counter = collections.Counter(data)
count_pairs = sorted(counter.items(), key=lambda x: (-x[1], x[0]))
words, _ = list(zip(*count_pairs))
word_to_id = dict(zip(words, range(len(words))))
return word_to_id
def _file_to_word_ids(filename, word_to_id):
data = _read_words(filename)
return [word_to_id[word] for word in data if word in word_to_id]
def ptb_raw_data(data_path=None):
"""Load PTB raw data from data directory "data_path".
Reads PTB text files, converts strings to integer ids,
and performs mini-batching of the inputs.
The PTB dataset comes from Tomas Mikolov's webpage:
http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz
Args:
data_path: string path to the directory where simple-examples.tgz has
been extracted.
Returns:
tuple (train_data, valid_data, test_data, vocabulary)
where each of the data objects can be passed to PTBIterator.
"""
train_path = os.path.join(data_path, "ptb.train.txt")
valid_path = os.path.join(data_path, "ptb.valid.txt")
test_path = os.path.join(data_path, "ptb.test.txt")
word_to_id = _build_vocab(train_path)
train_data = _file_to_word_ids(train_path, word_to_id)
valid_data = _file_to_word_ids(valid_path, word_to_id)
test_data = _file_to_word_ids(test_path, word_to_id)
vocabulary = len(word_to_id)
return train_data, valid_data, test_data, vocabulary
def ptb_producer(raw_data, batch_size, num_steps, name=None):
"""Iterate on the raw PTB data.
This chunks up raw_data into batches of examples and returns Tensors that
are drawn from these batches.
Args:
raw_data: one of the raw data outputs from ptb_raw_data.
batch_size: int, the batch size.
num_steps: int, the number of unrolls.
name: the name of this operation (optional).
Returns:
A pair of Tensors, each shaped [batch_size, num_steps]. The second element
of the tuple is the same data time-shifted to the right by one.
Raises:
tf.errors.InvalidArgumentError: if batch_size or num_steps are too high.
"""
with tf.name_scope(name, "PTBProducer", [raw_data, batch_size, num_steps]):
raw_data = tf.convert_to_tensor(raw_data, name="raw_data", dtype=tf.int32)
data_len = tf.size(raw_data)
batch_len = data_len // batch_size
data = tf.reshape(raw_data[0 : batch_size * batch_len],
[batch_size, batch_len])
epoch_size = (batch_len - 1) // num_steps
assertion = tf.assert_positive(
epoch_size,
message="epoch_size == 0, decrease batch_size or num_steps")
with tf.control_dependencies([assertion]):
epoch_size = tf.identity(epoch_size, name="epoch_size")
i = tf.train.range_input_producer(epoch_size, shuffle=False).dequeue()
x = tf.slice(data, [0, i * num_steps], [batch_size, num_steps])
y = tf.slice(data, [0, i * num_steps + 1], [batch_size, num_steps])
return x, y
|
apache-2.0
|
[
3,
1898,
6900,
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,
421,
199,
624,
22905,
367,
6057,
510,
20098,
1318,
1584,
1041,
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,
646,
5055,
199,
646,
747,
199,
199,
646,
3228,
465,
2833,
421,
199,
318,
485,
739,
63,
3148,
8,
1501,
304,
523,
543,
2833,
14,
30325,
14,
39,
1173,
8,
1501,
12,
298,
82,
531,
465,
289,
26,
272,
372,
289,
14,
739,
1252,
2708,
480,
1624,
13,
24,
3471,
1814,
4582,
78,
401,
3886,
24909,
30,
3471,
1294,
342,
421,
199,
318,
485,
1506,
63,
9953,
8,
1501,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
819,
7055,
275,
5055,
14,
11348,
8,
576,
9,
523,
2338,
63,
7322,
275,
3355,
8,
5337,
14,
1744,
1062,
790,
29,
2734,
671,
26,
5868,
88,
59,
17,
467,
671,
59,
16,
2459,
819,
5932,
12,
485,
275,
769,
8,
3065,
2031,
835,
63,
7322,
430,
523,
4349,
63,
475,
63,
344,
275,
1211,
8,
3065,
8,
3148,
12,
1425,
8,
552,
8,
3148,
7845,
819,
372,
4349,
63,
475,
63,
344,
421,
199,
318,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1501,
12,
4349,
63,
475,
63,
344,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
523,
372,
359,
1027,
63,
475,
63,
344,
59,
1027,
61,
367,
4349,
315,
666,
340,
4349,
315,
4349,
63,
475,
63,
344,
61,
421,
199,
318,
299,
5842,
63,
1773,
63,
576,
8,
576,
63,
515,
29,
403,
304,
523,
408,
6200,
510,
20098,
3066,
666,
687,
666,
2082,
298,
576,
63,
515,
1674,
819,
26129,
510,
20098,
1318,
1584,
12,
15373,
3326,
370,
3000,
2762,
12,
523,
436,
18628,
20536,
13,
2912,
316,
402,
314,
4153,
14,
819,
710,
510,
20098,
4789,
12477,
687,
21644,
305,
603,
16625,
32555,
1159,
9248,
26,
819,
1455,
921,
1544,
14,
3269,
14,
86,
337,
3289,
14,
16823,
22500,
1017,
16625,
32555,
15,
12845,
14344,
15,
4129,
13,
8589,
14,
27220,
819,
3033,
26,
272,
666,
63,
515,
26,
1059,
931,
370,
314,
2082,
2382,
3486,
13,
8589,
14,
27220,
965,
489,
2757,
12509,
14,
819,
1803,
26,
272,
2008,
334,
2834,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
9,
272,
2382,
1924,
402,
314,
666,
2251,
883,
506,
3032,
370,
510,
20098,
3585,
14,
523,
408,
819,
3560,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
2834,
14,
2424,
531,
523,
1686,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
1078,
14,
2424,
531,
523,
511,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
396,
14,
2424,
531,
819,
4349,
63,
475,
63,
344,
275,
485,
1506,
63,
9953,
8,
2834,
63,
515,
9,
523,
3560,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
2834,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
1686,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1078,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
511,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
396,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
17515,
275,
822,
8,
1027,
63,
475,
63,
344,
9,
523,
372,
3560,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
421,
199,
318,
299,
5842,
63,
16376,
8,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
12,
536,
29,
403,
304,
523,
408,
3315,
323,
641,
314,
3066,
510,
20098,
666,
14,
819,
961,
8291,
1536,
3066,
63,
576,
1901,
19593,
402,
7251,
436,
2529,
28373,
626,
523,
787,
19341,
687,
3520,
19593,
14,
819,
3033,
26,
272,
3066,
63,
576,
26,
1373,
402,
314,
3066,
666,
4704,
687,
299,
5842,
63,
1773,
63,
576,
14,
272,
3522,
63,
890,
26,
1109,
12,
314,
3522,
1568,
14,
272,
1967,
63,
5895,
26,
1109,
12,
314,
1329,
402,
625,
8459,
478,
14,
272,
536,
26,
314,
536,
402,
642,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
4092,
402,
28373,
12,
1924,
2215,
68,
359,
2912,
63,
890,
12,
1967,
63,
5895,
1055,
710,
3499,
1819,
272,
402,
314,
2008,
365,
314,
2011,
666,
900,
13,
26063,
471,
370,
314,
2451,
701,
1373,
14,
819,
6218,
26,
272,
2833,
14,
2550,
14,
32116,
26,
340,
3522,
63,
890,
503,
1967,
63,
5895,
787,
4634,
4721,
14,
523,
408,
523,
543,
2833,
14,
354,
63,
2645,
8,
354,
12,
298,
4189,
34,
15532,
401,
359,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
4682,
272,
3066,
63,
576,
275,
2833,
14,
3916,
63,
475,
63,
3128,
8,
1773,
63,
576,
12,
536,
628,
1773,
63,
576,
401,
2152,
29,
3249,
14,
442,
708,
9,
339,
666,
63,
552,
275,
2833,
14,
890,
8,
1773,
63,
576,
9,
272,
3522,
63,
552,
275,
666,
63,
552,
5001,
3522,
63,
890,
272,
666,
275,
2833,
14,
5217,
8,
1773,
63,
576,
59,
16,
520,
3522,
63,
890,
627,
3522,
63,
552,
467,
1993,
359,
2912,
63,
890,
12,
3522,
63,
552,
566
] |
[
1898,
6900,
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,
421,
199,
624,
22905,
367,
6057,
510,
20098,
1318,
1584,
1041,
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,
646,
5055,
199,
646,
747,
199,
199,
646,
3228,
465,
2833,
421,
199,
318,
485,
739,
63,
3148,
8,
1501,
304,
523,
543,
2833,
14,
30325,
14,
39,
1173,
8,
1501,
12,
298,
82,
531,
465,
289,
26,
272,
372,
289,
14,
739,
1252,
2708,
480,
1624,
13,
24,
3471,
1814,
4582,
78,
401,
3886,
24909,
30,
3471,
1294,
342,
421,
199,
318,
485,
1506,
63,
9953,
8,
1501,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
819,
7055,
275,
5055,
14,
11348,
8,
576,
9,
523,
2338,
63,
7322,
275,
3355,
8,
5337,
14,
1744,
1062,
790,
29,
2734,
671,
26,
5868,
88,
59,
17,
467,
671,
59,
16,
2459,
819,
5932,
12,
485,
275,
769,
8,
3065,
2031,
835,
63,
7322,
430,
523,
4349,
63,
475,
63,
344,
275,
1211,
8,
3065,
8,
3148,
12,
1425,
8,
552,
8,
3148,
7845,
819,
372,
4349,
63,
475,
63,
344,
421,
199,
318,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1501,
12,
4349,
63,
475,
63,
344,
304,
523,
666,
275,
485,
739,
63,
3148,
8,
1501,
9,
523,
372,
359,
1027,
63,
475,
63,
344,
59,
1027,
61,
367,
4349,
315,
666,
340,
4349,
315,
4349,
63,
475,
63,
344,
61,
421,
199,
318,
299,
5842,
63,
1773,
63,
576,
8,
576,
63,
515,
29,
403,
304,
523,
408,
6200,
510,
20098,
3066,
666,
687,
666,
2082,
298,
576,
63,
515,
1674,
819,
26129,
510,
20098,
1318,
1584,
12,
15373,
3326,
370,
3000,
2762,
12,
523,
436,
18628,
20536,
13,
2912,
316,
402,
314,
4153,
14,
819,
710,
510,
20098,
4789,
12477,
687,
21644,
305,
603,
16625,
32555,
1159,
9248,
26,
819,
1455,
921,
1544,
14,
3269,
14,
86,
337,
3289,
14,
16823,
22500,
1017,
16625,
32555,
15,
12845,
14344,
15,
4129,
13,
8589,
14,
27220,
819,
3033,
26,
272,
666,
63,
515,
26,
1059,
931,
370,
314,
2082,
2382,
3486,
13,
8589,
14,
27220,
965,
489,
2757,
12509,
14,
819,
1803,
26,
272,
2008,
334,
2834,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
9,
272,
2382,
1924,
402,
314,
666,
2251,
883,
506,
3032,
370,
510,
20098,
3585,
14,
523,
408,
819,
3560,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
2834,
14,
2424,
531,
523,
1686,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
1078,
14,
2424,
531,
523,
511,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
515,
12,
298,
541,
66,
14,
396,
14,
2424,
531,
819,
4349,
63,
475,
63,
344,
275,
485,
1506,
63,
9953,
8,
2834,
63,
515,
9,
523,
3560,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
2834,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
1686,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
1078,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
511,
63,
576,
275,
485,
493,
63,
475,
63,
1027,
63,
1580,
8,
396,
63,
515,
12,
4349,
63,
475,
63,
344,
9,
523,
17515,
275,
822,
8,
1027,
63,
475,
63,
344,
9,
523,
372,
3560,
63,
576,
12,
1686,
63,
576,
12,
511,
63,
576,
12,
17515,
421,
199,
318,
299,
5842,
63,
16376,
8,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
12,
536,
29,
403,
304,
523,
408,
3315,
323,
641,
314,
3066,
510,
20098,
666,
14,
819,
961,
8291,
1536,
3066,
63,
576,
1901,
19593,
402,
7251,
436,
2529,
28373,
626,
523,
787,
19341,
687,
3520,
19593,
14,
819,
3033,
26,
272,
3066,
63,
576,
26,
1373,
402,
314,
3066,
666,
4704,
687,
299,
5842,
63,
1773,
63,
576,
14,
272,
3522,
63,
890,
26,
1109,
12,
314,
3522,
1568,
14,
272,
1967,
63,
5895,
26,
1109,
12,
314,
1329,
402,
625,
8459,
478,
14,
272,
536,
26,
314,
536,
402,
642,
3439,
334,
4144,
680,
819,
1803,
26,
272,
437,
4092,
402,
28373,
12,
1924,
2215,
68,
359,
2912,
63,
890,
12,
1967,
63,
5895,
1055,
710,
3499,
1819,
272,
402,
314,
2008,
365,
314,
2011,
666,
900,
13,
26063,
471,
370,
314,
2451,
701,
1373,
14,
819,
6218,
26,
272,
2833,
14,
2550,
14,
32116,
26,
340,
3522,
63,
890,
503,
1967,
63,
5895,
787,
4634,
4721,
14,
523,
408,
523,
543,
2833,
14,
354,
63,
2645,
8,
354,
12,
298,
4189,
34,
15532,
401,
359,
1773,
63,
576,
12,
3522,
63,
890,
12,
1967,
63,
5895,
4682,
272,
3066,
63,
576,
275,
2833,
14,
3916,
63,
475,
63,
3128,
8,
1773,
63,
576,
12,
536,
628,
1773,
63,
576,
401,
2152,
29,
3249,
14,
442,
708,
9,
339,
666,
63,
552,
275,
2833,
14,
890,
8,
1773,
63,
576,
9,
272,
3522,
63,
552,
275,
666,
63,
552,
5001,
3522,
63,
890,
272,
666,
275,
2833,
14,
5217,
8,
1773,
63,
576,
59,
16,
520,
3522,
63,
890,
627,
3522,
63,
552,
467,
1993,
359,
2912,
63,
890,
12,
3522,
63,
552,
566,
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,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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
] |
40223112/w16test
|
static/Brython3.1.3-20150514-095342/Lib/os.py
|
635
|
35582
|
r"""OS routines for Mac, NT, or Posix depending on what system we're on.
This exports:
- all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
- os.path is either posixpath or ntpath
- os.name is either 'posix', 'nt', 'os2' or 'ce'.
- os.curdir is a string representing the current directory ('.' or ':')
- os.pardir is a string representing the parent directory ('..' or '::')
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
- os.extsep is the extension separator (always '.')
- os.altsep is the alternate pathname separator (None or '/')
- os.pathsep is the component separator used in $PATH etc
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
- os.defpath is the default search path for executables
- os.devnull is the file path of the null device ('/dev/null', etc.)
Programs that import and use 'os' stand a better chance of being
portable between different platforms. Of course, they must then
only use functions that are defined by all platforms (e.g., unlink
and opendir), and leave all pathname manipulation to os.path
(e.g., split and join).
"""
import sys, errno
import stat as st
_names = sys.builtin_module_names
# Note: more names are added to __all__ later.
__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
"defpath", "name", "path", "devnull", "SEEK_SET", "SEEK_CUR",
"SEEK_END", "fsencode", "fsdecode", "get_exec_path", "fdopen",
"popen", "extsep"]
def _exists(name):
return name in globals()
def _get_exports_list(module):
try:
return list(module.__all__)
except AttributeError:
return [n for n in dir(module) if n[0] != '_']
# Any new dependencies of the os module and/or changes in path separator
# requires updating importlib as well.
if 'posix' in _names:
name = 'posix'
linesep = '\n'
from posix import *
try:
from posix import _exit
__all__.append('_exit')
except ImportError:
pass
import posixpath as path
try:
from posix import _have_functions
except ImportError:
pass
elif 'nt' in _names:
name = 'nt'
linesep = '\r\n'
from nt import *
try:
from nt import _exit
__all__.append('_exit')
except ImportError:
pass
import ntpath as path
import nt
__all__.extend(_get_exports_list(nt))
del nt
try:
from nt import _have_functions
except ImportError:
pass
elif 'os2' in _names:
name = 'os2'
linesep = '\r\n'
from os2 import *
try:
from os2 import _exit
__all__.append('_exit')
except ImportError:
pass
if sys.version.find('EMX GCC') == -1:
import ntpath as path
else:
import os2emxpath as path
from _emx_link import link
import os2
__all__.extend(_get_exports_list(os2))
del os2
try:
from os2 import _have_functions
except ImportError:
pass
elif 'ce' in _names:
name = 'ce'
linesep = '\r\n'
from ce import *
try:
from ce import _exit
__all__.append('_exit')
except ImportError:
pass
# We can use the standard Windows path.
import ntpath as path
import ce
__all__.extend(_get_exports_list(ce))
del ce
try:
from ce import _have_functions
except ImportError:
pass
else:
raise ImportError('no os specific module found')
sys.modules['os.path'] = path
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
devnull)
del _names
if _exists("_have_functions"):
_globals = globals()
def _add(str, fn):
if (fn in _globals) and (str in _have_functions):
_set.add(_globals[fn])
_set = set()
_add("HAVE_FACCESSAT", "access")
_add("HAVE_FCHMODAT", "chmod")
_add("HAVE_FCHOWNAT", "chown")
_add("HAVE_FSTATAT", "stat")
_add("HAVE_FUTIMESAT", "utime")
_add("HAVE_LINKAT", "link")
_add("HAVE_MKDIRAT", "mkdir")
_add("HAVE_MKFIFOAT", "mkfifo")
_add("HAVE_MKNODAT", "mknod")
_add("HAVE_OPENAT", "open")
_add("HAVE_READLINKAT", "readlink")
_add("HAVE_RENAMEAT", "rename")
_add("HAVE_SYMLINKAT", "symlink")
_add("HAVE_UNLINKAT", "unlink")
_add("HAVE_UNLINKAT", "rmdir")
_add("HAVE_UTIMENSAT", "utime")
supports_dir_fd = _set
_set = set()
_add("HAVE_FACCESSAT", "access")
supports_effective_ids = _set
_set = set()
_add("HAVE_FCHDIR", "chdir")
_add("HAVE_FCHMOD", "chmod")
_add("HAVE_FCHOWN", "chown")
_add("HAVE_FDOPENDIR", "listdir")
_add("HAVE_FEXECVE", "execve")
_set.add(stat) # fstat always works
_add("HAVE_FTRUNCATE", "truncate")
_add("HAVE_FUTIMENS", "utime")
_add("HAVE_FUTIMES", "utime")
_add("HAVE_FPATHCONF", "pathconf")
if _exists("statvfs") and _exists("fstatvfs"): # mac os x10.3
_add("HAVE_FSTATVFS", "statvfs")
supports_fd = _set
_set = set()
_add("HAVE_FACCESSAT", "access")
# Some platforms don't support lchmod(). Often the function exists
# anyway, as a stub that always returns ENOSUP or perhaps EOPNOTSUPP.
# (No, I don't know why that's a good design.) ./configure will detect
# this and reject it--so HAVE_LCHMOD still won't be defined on such
# platforms. This is Very Helpful.
#
# However, sometimes platforms without a working lchmod() *do* have
# fchmodat(). (Examples: Linux kernel 3.2 with glibc 2.15,
# OpenIndiana 3.x.) And fchmodat() has a flag that theoretically makes
# it behave like lchmod(). So in theory it would be a suitable
# replacement for lchmod(). But when lchmod() doesn't work, fchmodat()'s
# flag doesn't work *either*. Sadly ./configure isn't sophisticated
# enough to detect this condition--it only determines whether or not
# fchmodat() minimally works.
#
# Therefore we simply ignore fchmodat() when deciding whether or not
# os.chmod supports follow_symlinks. Just checking lchmod() is
# sufficient. After all--if you have a working fchmodat(), your
# lchmod() almost certainly works too.
#
# _add("HAVE_FCHMODAT", "chmod")
_add("HAVE_FCHOWNAT", "chown")
_add("HAVE_FSTATAT", "stat")
_add("HAVE_LCHFLAGS", "chflags")
_add("HAVE_LCHMOD", "chmod")
if _exists("lchown"): # mac os x10.3
_add("HAVE_LCHOWN", "chown")
_add("HAVE_LINKAT", "link")
_add("HAVE_LUTIMES", "utime")
_add("HAVE_LSTAT", "stat")
_add("HAVE_FSTATAT", "stat")
_add("HAVE_UTIMENSAT", "utime")
_add("MS_WINDOWS", "stat")
supports_follow_symlinks = _set
del _set
del _have_functions
del _globals
del _add
# Python uses fixed values for the SEEK_ constants; they are mapped
# to native constants if necessary in posixmodule.c
# Other possible SEEK values are directly imported from posixmodule.c
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
def _get_masked_mode(mode):
mask = umask(0)
umask(mask)
return mode & ~mask
# Super directory utilities.
# (Inspired by Eric Raymond; the doc strings are mostly his)
def makedirs(name, mode=0o777, exist_ok=False):
"""makedirs(path [, mode=0o777][, exist_ok=False])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
just the rightmost) will be created if it does not exist. If the
target directory with the same mode as we specified already exists,
raises an OSError if exist_ok is False, otherwise no exception is
raised. This is recursive.
"""
head, tail = path.split(name)
if not tail:
head, tail = path.split(head)
if head and tail and not path.exists(head):
try:
makedirs(head, mode, exist_ok)
except OSError as e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
cdir = curdir
if isinstance(tail, bytes):
cdir = bytes(curdir, 'ASCII')
if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists
return
try:
mkdir(name, mode)
except OSError as e:
dir_exists = path.isdir(name)
expected_mode = _get_masked_mode(mode)
if dir_exists:
# S_ISGID is automatically copied by the OS from parent to child
# directories on mkdir. Don't consider it being set to be a mode
# mismatch as mkdir does not unset it when not specified in mode.
actual_mode = st.S_IMODE(lstat(name).st_mode) & ~st.S_ISGID
else:
actual_mode = -1
if not (e.errno == errno.EEXIST and exist_ok and dir_exists and
actual_mode == expected_mode):
if dir_exists and actual_mode != expected_mode:
e.strerror += ' (mode %o != expected mode %o)' % (
actual_mode, expected_mode)
raise
def removedirs(name):
"""removedirs(path)
Super-rmdir; remove a leaf directory and all empty intermediate
ones. Works like rmdir except that, if the leaf directory is
successfully removed, directories corresponding to rightmost path
segments will be pruned away until either the whole path is
consumed or an error occurs. Errors during this latter phase are
ignored -- they generally mean that a directory was not empty.
"""
rmdir(name)
head, tail = path.split(name)
if not tail:
head, tail = path.split(head)
while head and tail:
try:
rmdir(head)
except error:
break
head, tail = path.split(head)
def renames(old, new):
"""renames(old, new)
Super-rename; create directories as necessary and delete any left
empty. Works like rename, except creation of any intermediate
directories needed to make the new pathname good is attempted
first. After the rename, directories corresponding to rightmost
path segments of the old name will be pruned way until either the
whole path is consumed or a nonempty directory is found.
Note: this function can fail with the new directory structure made
if you lack permissions needed to unlink the leaf directory or
file.
"""
head, tail = path.split(new)
if head and tail and not path.exists(head):
makedirs(head)
rename(old, new)
head, tail = path.split(old)
if head and tail:
try:
removedirs(head)
except error:
pass
__all__.extend(["makedirs", "removedirs", "renames"])
def walk(top, topdown=True, onerror=None, followlinks=False):
"""Directory tree generator.
For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple
dirpath, dirnames, filenames
dirpath is a string, the path to the directory. dirnames is a list of
the names of the subdirectories in dirpath (excluding '.' and '..').
filenames is a list of the names of the non-directory files in dirpath.
Note that the names in the lists are just names, with no path components.
To get a full path (which begins with top) to a file or directory in
dirpath, do os.path.join(dirpath, name).
If optional arg 'topdown' is true or not specified, the triple for a
directory is generated before the triples for any of its subdirectories
(directories are generated top down). If topdown is false, the triple
for a directory is generated after the triples for all of its
subdirectories (directories are generated bottom up).
When topdown is true, the caller can modify the dirnames list in-place
(e.g., via del or slice assignment), and walk will only recurse into the
subdirectories whose names remain in dirnames; this can be used to prune
the search, or to impose a specific order of visiting. Modifying
dirnames when topdown is false is ineffective, since the directories in
dirnames have already been generated by the time dirnames itself is
generated.
By default errors from the os.listdir() call are ignored. If
optional arg 'onerror' is specified, it should be a function; it
will be called with one argument, an os.error instance. It can
report the error to continue with the walk, or raise the exception
to abort the walk. Note that the filename is available as the
filename attribute of the exception object.
By default, os.walk does not follow symbolic links to subdirectories on
systems that support them. In order to get this functionality, set the
optional argument 'followlinks' to true.
Caution: if you pass a relative pathname for top, don't change the
current working directory between resumptions of walk. walk never
changes the current directory, and assumes that the client doesn't
either.
Example:
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
print(root, "consumes", end="")
print(sum([getsize(join(root, name)) for name in files]), end="")
print("bytes in", len(files), "non-directory files")
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
"""
islink, join, isdir = path.islink, path.join, path.isdir
# We may not have read permission for top, in which case we can't
# get a list of the files the directory contains. os.walk
# always suppressed the exception then, rather than blow up for a
# minor reason when (say) a thousand readable directories are still
# left to visit. That logic is copied here.
try:
# Note that listdir and error are globals in this module due
# to earlier import-*.
names = listdir(top)
except error as err:
if onerror is not None:
onerror(err)
return
dirs, nondirs = [], []
for name in names:
if isdir(join(top, name)):
dirs.append(name)
else:
nondirs.append(name)
if topdown:
yield top, dirs, nondirs
for name in dirs:
new_path = join(top, name)
if followlinks or not islink(new_path):
yield from walk(new_path, topdown, onerror, followlinks)
if not topdown:
yield top, dirs, nondirs
__all__.append("walk")
if {open, stat} <= supports_dir_fd and {listdir, stat} <= supports_fd:
def fwalk(top=".", topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=None):
"""Directory tree generator.
This behaves exactly like walk(), except that it yields a 4-tuple
dirpath, dirnames, filenames, dirfd
`dirpath`, `dirnames` and `filenames` are identical to walk() output,
and `dirfd` is a file descriptor referring to the directory `dirpath`.
The advantage of fwalk() over walk() is that it's safe against symlink
races (when follow_symlinks is False).
If dir_fd is not None, it should be a file descriptor open to a directory,
and top should be relative; top will then be relative to that directory.
(dir_fd is always supported for fwalk.)
Caution:
Since fwalk() yields file descriptors, those are only valid until the
next iteration step, so you should dup() them if you want to keep them
for a longer period.
Example:
import os
for root, dirs, files, rootfd in os.fwalk('python/Lib/email'):
print(root, "consumes", end="")
print(sum([os.stat(name, dir_fd=rootfd).st_size for name in files]),
end="")
print("bytes in", len(files), "non-directory files")
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
"""
# Note: To guard against symlink races, we use the standard
# lstat()/open()/fstat() trick.
orig_st = stat(top, follow_symlinks=False, dir_fd=dir_fd)
topfd = open(top, O_RDONLY, dir_fd=dir_fd)
try:
if (follow_symlinks or (st.S_ISDIR(orig_st.st_mode) and
path.samestat(orig_st, stat(topfd)))):
yield from _fwalk(topfd, top, topdown, onerror, follow_symlinks)
finally:
close(topfd)
def _fwalk(topfd, toppath, topdown, onerror, follow_symlinks):
# Note: This uses O(depth of the directory tree) file descriptors: if
# necessary, it can be adapted to only require O(1) FDs, see issue
# #13734.
names = listdir(topfd)
dirs, nondirs = [], []
for name in names:
try:
# Here, we don't use AT_SYMLINK_NOFOLLOW to be consistent with
# walk() which reports symlinks to directories as directories.
# We do however check for symlinks before recursing into
# a subdirectory.
if st.S_ISDIR(stat(name, dir_fd=topfd).st_mode):
dirs.append(name)
else:
nondirs.append(name)
except FileNotFoundError:
try:
# Add dangling symlinks, ignore disappeared files
if st.S_ISLNK(stat(name, dir_fd=topfd, follow_symlinks=False)
.st_mode):
nondirs.append(name)
except FileNotFoundError:
continue
if topdown:
yield toppath, dirs, nondirs, topfd
for name in dirs:
try:
orig_st = stat(name, dir_fd=topfd, follow_symlinks=follow_symlinks)
dirfd = open(name, O_RDONLY, dir_fd=topfd)
except error as err:
if onerror is not None:
onerror(err)
return
try:
if follow_symlinks or path.samestat(orig_st, stat(dirfd)):
dirpath = path.join(toppath, name)
yield from _fwalk(dirfd, dirpath, topdown, onerror, follow_symlinks)
finally:
close(dirfd)
if not topdown:
yield toppath, dirs, nondirs, topfd
__all__.append("fwalk")
# Make sure os.environ exists, at least
try:
environ
except NameError:
environ = {}
def execl(file, *args):
"""execl(file, *args)
Execute the executable file with argument list args, replacing the
current process. """
execv(file, args)
def execle(file, *args):
"""execle(file, *args, env)
Execute the executable file with argument list args and
environment env, replacing the current process. """
env = args[-1]
execve(file, args[:-1], env)
def execlp(file, *args):
"""execlp(file, *args)
Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process. """
execvp(file, args)
def execlpe(file, *args):
"""execlpe(file, *args, env)
Execute the executable file (which is searched for along $PATH)
with argument list args and environment env, replacing the current
process. """
env = args[-1]
execvpe(file, args[:-1], env)
def execvp(file, args):
"""execvp(file, args)
Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process.
args may be a list or tuple of strings. """
_execvpe(file, args)
def execvpe(file, args, env):
"""execvpe(file, args, env)
Execute the executable file (which is searched for along $PATH)
with argument list args and environment env , replacing the
current process.
args may be a list or tuple of strings. """
_execvpe(file, args, env)
__all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])
def _execvpe(file, args, env=None):
if env is not None:
exec_func = execve
argrest = (args, env)
else:
exec_func = execv
argrest = (args,)
env = environ
head, tail = path.split(file)
if head:
exec_func(file, *argrest)
return
last_exc = saved_exc = None
saved_tb = None
path_list = get_exec_path(env)
if name != 'nt':
file = fsencode(file)
path_list = map(fsencode, path_list)
for dir in path_list:
fullname = path.join(dir, file)
try:
exec_func(fullname, *argrest)
except error as e:
last_exc = e
tb = sys.exc_info()[2]
if (e.errno != errno.ENOENT and e.errno != errno.ENOTDIR
and saved_exc is None):
saved_exc = e
saved_tb = tb
if saved_exc:
raise saved_exc.with_traceback(saved_tb)
raise last_exc.with_traceback(tb)
def get_exec_path(env=None):
"""Returns the sequence of directories that will be searched for the
named executable (similar to a shell) when launching a process.
*env* must be an environment variable dict or None. If *env* is None,
os.environ will be used.
"""
# Use a local import instead of a global import to limit the number of
# modules loaded at startup: the os module is always loaded at startup by
# Python. It may also avoid a bootstrap issue.
import warnings
if env is None:
env = environ
# {b'PATH': ...}.get('PATH') and {'PATH': ...}.get(b'PATH') emit a
# BytesWarning when using python -b or python -bb: ignore the warning
with warnings.catch_warnings():
warnings.simplefilter("ignore", BytesWarning)
try:
path_list = env.get('PATH')
except TypeError:
path_list = None
if supports_bytes_environ:
try:
path_listb = env[b'PATH']
except (KeyError, TypeError):
pass
else:
if path_list is not None:
raise ValueError(
"env cannot contain 'PATH' and b'PATH' keys")
path_list = path_listb
if path_list is not None and isinstance(path_list, bytes):
path_list = fsdecode(path_list)
if path_list is None:
path_list = defpath
return path_list.split(pathsep)
# Change environ to automatically call putenv(), unsetenv if they exist.
from collections.abc import MutableMapping
class _Environ(MutableMapping):
def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv):
self.encodekey = encodekey
self.decodekey = decodekey
self.encodevalue = encodevalue
self.decodevalue = decodevalue
self.putenv = putenv
self.unsetenv = unsetenv
self._data = data
def __getitem__(self, key):
try:
value = self._data[self.encodekey(key)]
except KeyError:
# raise KeyError with the original key value
raise KeyError(key) from None
return self.decodevalue(value)
def __setitem__(self, key, value):
key = self.encodekey(key)
value = self.encodevalue(value)
self.putenv(key, value)
self._data[key] = value
def __delitem__(self, key):
encodedkey = self.encodekey(key)
self.unsetenv(encodedkey)
try:
del self._data[encodedkey]
except KeyError:
# raise KeyError with the original key value
raise KeyError(key) from None
def __iter__(self):
for key in self._data:
yield self.decodekey(key)
def __len__(self):
return len(self._data)
def __repr__(self):
return 'environ({{{}}})'.format(', '.join(
('{!r}: {!r}'.format(self.decodekey(key), self.decodevalue(value))
for key, value in self._data.items())))
def copy(self):
return dict(self)
def setdefault(self, key, value):
if key not in self:
self[key] = value
return self[key]
try:
_putenv = putenv
except NameError:
_putenv = lambda key, value: None
else:
__all__.append("putenv")
try:
_unsetenv = unsetenv
except NameError:
_unsetenv = lambda key: _putenv(key, "")
else:
__all__.append("unsetenv")
def _createenviron():
if name in ('os2', 'nt'):
# Where Env Var Names Must Be UPPERCASE
def check_str(value):
if not isinstance(value, str):
raise TypeError("str expected, not %s" % type(value).__name__)
return value
encode = check_str
decode = str
def encodekey(key):
return encode(key).upper()
data = {}
for key, value in environ.items():
data[encodekey(key)] = value
else:
# Where Env Var Names Can Be Mixed Case
encoding = sys.getfilesystemencoding()
def encode(value):
if not isinstance(value, str):
raise TypeError("str expected, not %s" % type(value).__name__)
return value.encode(encoding, 'surrogateescape')
def decode(value):
return value.decode(encoding, 'surrogateescape')
encodekey = encode
data = environ
return _Environ(data,
encodekey, decode,
encode, decode,
_putenv, _unsetenv)
# unicode environ
environ = _createenviron()
del _createenviron
def getenv(key, default=None):
"""Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default.
key, default and the result are str."""
return environ.get(key, default)
supports_bytes_environ = name not in ('os2', 'nt')
__all__.extend(("getenv", "supports_bytes_environ"))
if supports_bytes_environ:
def _check_bytes(value):
if not isinstance(value, bytes):
raise TypeError("bytes expected, not %s" % type(value).__name__)
return value
# bytes environ
environb = _Environ(environ._data,
_check_bytes, bytes,
_check_bytes, bytes,
_putenv, _unsetenv)
del _check_bytes
def getenvb(key, default=None):
"""Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default.
key, default and the result are bytes."""
return environb.get(key, default)
__all__.extend(("environb", "getenvb"))
def _fscodec():
encoding = sys.getfilesystemencoding()
if encoding == 'mbcs':
errors = 'strict'
else:
errors = 'surrogateescape'
def fsencode(filename):
"""
Encode filename to the filesystem encoding with 'surrogateescape' error
handler, return bytes unchanged. On Windows, use 'strict' error handler if
the file system encoding is 'mbcs' (which is the default encoding).
"""
if isinstance(filename, bytes):
return filename
elif isinstance(filename, str):
return filename.encode(encoding, errors)
else:
raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
def fsdecode(filename):
"""
Decode filename from the filesystem encoding with 'surrogateescape' error
handler, return str unchanged. On Windows, use 'strict' error handler if
the file system encoding is 'mbcs' (which is the default encoding).
"""
if isinstance(filename, str):
return filename
elif isinstance(filename, bytes):
return filename.decode(encoding, errors)
else:
raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
return fsencode, fsdecode
fsencode, fsdecode = _fscodec()
del _fscodec
# Supply spawn*() (probably only for Unix)
if _exists("fork") and not _exists("spawnv") and _exists("execv"):
P_WAIT = 0
P_NOWAIT = P_NOWAITO = 1
__all__.extend(["P_WAIT", "P_NOWAIT", "P_NOWAITO"])
# XXX Should we support P_DETACH? I suppose it could fork()**2
# and close the std I/O streams. Also, P_OVERLAY is the same
# as execv*()?
def _spawnvef(mode, file, args, env, func):
# Internal helper; func is the exec*() function to use
pid = fork()
if not pid:
# Child
try:
if env is None:
func(file, args)
else:
func(file, args, env)
except:
_exit(127)
else:
# Parent
if mode == P_NOWAIT:
return pid # Caller is responsible for waiting!
while 1:
wpid, sts = waitpid(pid, 0)
if WIFSTOPPED(sts):
continue
elif WIFSIGNALED(sts):
return -WTERMSIG(sts)
elif WIFEXITED(sts):
return WEXITSTATUS(sts)
else:
raise error("Not stopped, signaled or exited???")
def spawnv(mode, file, args):
"""spawnv(mode, file, args) -> integer
Execute file with arguments from args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
return _spawnvef(mode, file, args, None, execv)
def spawnve(mode, file, args, env):
"""spawnve(mode, file, args, env) -> integer
Execute file with arguments from args in a subprocess with the
specified environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
return _spawnvef(mode, file, args, env, execve)
# Note: spawnvp[e] is't currently supported on Windows
def spawnvp(mode, file, args):
"""spawnvp(mode, file, args) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
return _spawnvef(mode, file, args, None, execvp)
def spawnvpe(mode, file, args, env):
"""spawnvpe(mode, file, args, env) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
return _spawnvef(mode, file, args, env, execvpe)
if _exists("spawnv"):
# These aren't supplied by the basic Windows code
# but can be easily implemented in Python
def spawnl(mode, file, *args):
"""spawnl(mode, file, *args) -> integer
Execute file with arguments from args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
return spawnv(mode, file, args)
def spawnle(mode, file, *args):
"""spawnle(mode, file, *args, env) -> integer
Execute file with arguments from args in a subprocess with the
supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
env = args[-1]
return spawnve(mode, file, args[:-1], env)
__all__.extend(["spawnv", "spawnve", "spawnl", "spawnle",])
if _exists("spawnvp"):
# At the moment, Windows doesn't implement spawnvp[e],
# so it won't have spawnlp[e] either.
def spawnlp(mode, file, *args):
"""spawnlp(mode, file, *args) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
return spawnvp(mode, file, args)
def spawnlpe(mode, file, *args):
"""spawnlpe(mode, file, *args, env) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it. """
env = args[-1]
return spawnvpe(mode, file, args[:-1], env)
__all__.extend(["spawnvp", "spawnvpe", "spawnlp", "spawnlpe",])
import copyreg as _copyreg
def _make_stat_result(tup, dict):
return stat_result(tup, dict)
def _pickle_stat_result(sr):
(type, args) = sr.__reduce__()
return (_make_stat_result, args)
try:
_copyreg.pickle(stat_result, _pickle_stat_result, _make_stat_result)
except NameError: # stat_result may not exist
pass
def _make_statvfs_result(tup, dict):
return statvfs_result(tup, dict)
def _pickle_statvfs_result(sr):
(type, args) = sr.__reduce__()
return (_make_statvfs_result, args)
try:
_copyreg.pickle(statvfs_result, _pickle_statvfs_result,
_make_statvfs_result)
except NameError: # statvfs_result may not exist
pass
# Supply os.popen()
def popen(cmd, mode="r", buffering=-1):
if not isinstance(cmd, str):
raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))
if mode not in ("r", "w"):
raise ValueError("invalid mode %r" % mode)
if buffering == 0 or buffering is None:
raise ValueError("popen() does not support unbuffered streams")
import subprocess, io
if mode == "r":
proc = subprocess.Popen(cmd,
shell=True,
stdout=subprocess.PIPE,
bufsize=buffering)
return _wrap_close(io.TextIOWrapper(proc.stdout), proc)
else:
proc = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
bufsize=buffering)
return _wrap_close(io.TextIOWrapper(proc.stdin), proc)
# Helper for popen() -- a proxy for a file whose close waits for the process
class _wrap_close:
def __init__(self, stream, proc):
self._stream = stream
self._proc = proc
def close(self):
self._stream.close()
returncode = self._proc.wait()
if returncode == 0:
return None
if name == 'nt':
return returncode
else:
return returncode << 8 # Shift left to match old behavior
def __enter__(self):
return self
def __exit__(self, *args):
self.close()
def __getattr__(self, name):
return getattr(self._stream, name)
def __iter__(self):
return iter(self._stream)
# Supply os.fdopen()
def fdopen(fd, *args, **kwargs):
if not isinstance(fd, int):
raise TypeError("invalid fd type (%s, expected integer)" % type(fd))
import io
return io.open(fd, *args, **kwargs)
|
agpl-3.0
|
[
82,
624,
3100,
14975,
367,
10444,
12,
23350,
12,
503,
4376,
4174,
10298,
641,
4052,
2656,
781,
3984,
641,
14,
199,
199,
2765,
22609,
26,
523,
446,
1006,
3423,
687,
10694,
12,
13377,
12,
747,
18,
12,
503,
10142,
12,
325,
14,
71,
14,
17002,
12,
5672,
12,
5423,
14,
523,
446,
747,
14,
515,
365,
1902,
15454,
503,
13377,
515,
523,
446,
747,
14,
354,
365,
1902,
283,
9228,
297,
283,
343,
297,
283,
736,
18,
7,
503,
283,
301,
1370,
523,
446,
747,
14,
15594,
365,
282,
1059,
6144,
314,
1453,
2082,
661,
3530,
503,
7596,
358,
523,
446,
747,
14,
21386,
365,
282,
1059,
6144,
314,
1676,
2082,
661,
703,
7,
503,
19069,
358,
523,
446,
747,
14,
4127,
365,
314,
334,
269,
282,
4750,
2863,
9,
11776,
9432,
661,
4805,
503,
10871,
503,
6468,
358,
523,
446,
747,
14,
832,
4127,
365,
314,
3329,
9432,
334,
9223,
20093,
523,
446,
747,
14,
4478,
4127,
365,
314,
18034,
11776,
9432,
334,
403,
503,
15107,
523,
446,
747,
14,
17843,
365,
314,
3931,
9432,
1202,
315,
2672,
3243,
5423,
523,
446,
747,
14,
19254,
365,
314,
1004,
9432,
315,
1318,
1584,
17485,
82,
7,
503,
1557,
78,
7,
503,
1557,
82,
60,
78,
358,
523,
446,
747,
14,
318,
515,
365,
314,
849,
2754,
931,
367,
31172,
523,
446,
747,
14,
19778,
365,
314,
570,
931,
402,
314,
2973,
2243,
14606,
2374,
15,
2307,
297,
5423,
4959,
199,
199,
919,
9292,
626,
492,
436,
675,
283,
736,
7,
10584,
282,
8034,
22044,
402,
3769,
199,
719,
461,
3382,
3365,
10677,
14,
221,
24545,
2518,
12,
2985,
1471,
2066,
199,
2118,
675,
3423,
626,
787,
3247,
701,
1006,
10677,
334,
69,
14,
71,
2020,
17002,
199,
460,
1551,
694,
395,
436,
10137,
1006,
11776,
26212,
370,
747,
14,
515,
199,
8,
69,
14,
71,
2020,
3715,
436,
4263,
680,
199,
624,
199,
199,
646,
984,
12,
7554,
199,
646,
5672,
465,
410,
199,
199,
63,
1247,
275,
984,
14,
5351,
63,
578,
63,
1247,
199,
199,
3,
3390,
26,
221,
1655,
1561,
787,
3483,
370,
636,
452,
363,
2945,
14,
199,
363,
452,
363,
275,
2097,
4478,
4127,
401,
298,
15594,
401,
298,
21386,
401,
298,
4127,
401,
298,
17843,
401,
298,
19254,
401,
1779,
298,
318,
515,
401,
298,
354,
401,
298,
515,
401,
298,
19778,
401,
298,
18439,
63,
3597,
401,
298,
18439,
63,
7013,
401,
1779,
298,
18439,
63,
3902,
401,
298,
70,
2464,
600,
401,
298,
2319,
2708,
401,
298,
362,
63,
1628,
63,
515,
401,
298,
23140,
401,
1779,
298,
12207,
401,
298,
832,
4127,
937,
199,
199,
318,
485,
2444,
8,
354,
304,
272,
372,
536,
315,
7992,
342,
199,
199,
318,
485,
362,
63,
20775,
63,
513,
8,
578,
304,
272,
862,
26,
267,
372,
769,
8,
578,
855,
452,
3368,
272,
871,
4281,
26,
267,
372,
359,
78,
367,
302,
315,
2935,
8,
578,
9,
340,
302,
59,
16,
61,
1137,
2513,
418,
199,
199,
3,
6184,
892,
5124,
402,
314,
747,
859,
436,
15,
269,
4493,
315,
931,
9432,
199,
3,
5074,
12928,
14802,
465,
5521,
14,
199,
692,
283,
9228,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
9228,
7,
272,
1004,
4127,
275,
1557,
78,
7,
272,
687,
10694,
492,
627,
272,
862,
26,
267,
687,
10694,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
492,
15454,
465,
931,
339,
862,
26,
267,
687,
10694,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
4164,
283,
343,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
343,
7,
272,
1004,
4127,
275,
1557,
82,
60,
78,
7,
272,
687,
13377,
492,
627,
272,
862,
26,
267,
687,
13377,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
492,
13377,
515,
465,
931,
339,
492,
13377,
272,
636,
452,
4343,
2880,
1547,
362,
63,
20775,
63,
513,
8,
343,
430,
272,
2150,
13377,
339,
862,
26,
267,
687,
13377,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
4164,
283,
736,
18,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
736,
18,
7,
272,
1004,
4127,
275,
1557,
82,
60,
78,
7,
272,
687,
747,
18,
492,
627,
272,
862,
26,
267,
687,
747,
18,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
340,
984,
14,
1023,
14,
1623,
360,
2769,
56,
598,
2571,
358,
508,
446,
17,
26,
267,
492,
13377,
515,
465,
931,
272,
587,
26,
267,
492,
747,
18,
5633,
8006,
465,
931,
267,
687,
485,
5633,
88,
63,
1073,
492,
2142,
339,
492,
747,
18,
272,
636,
452,
4343,
2880,
1547,
362,
63,
20775,
63,
513,
8,
736,
18,
430,
272,
2150,
747,
18,
339,
862,
26,
267,
687,
747,
18,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
4164,
283,
301,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
301,
7,
272,
1004,
4127,
275,
1557,
82,
60,
78,
7,
272,
687,
10142,
492,
627,
272,
862,
26,
267,
687,
10142,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
327,
2136,
883,
675,
314,
4465,
5417,
931,
14,
272,
492,
13377,
515,
465,
931,
339,
492,
10142,
272,
636,
452,
4343,
2880,
1547,
362,
63,
20775,
63,
513,
8,
301,
430,
272,
2150,
10142,
339,
862,
26,
267,
687,
10142,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
2836,
26,
272,
746,
3545,
360,
889,
747,
2488,
859,
1911,
358,
199,
199,
1274,
14,
3112,
459,
736,
14,
515,
418,
275,
931,
199,
504,
747,
14,
515,
492,
334,
15594,
12,
623,
694,
12,
7375,
12,
931,
4127,
12,
347,
515,
12,
1599,
4127,
12,
8791,
4127,
12,
272,
4866,
2307,
9,
199,
199,
2264,
485,
1247,
421,
199,
692,
485,
2444,
11008,
7804,
63,
5777,
2349,
272,
485,
8473,
275,
7992,
342,
272,
347,
485,
525,
8,
495,
12,
4325,
304,
267,
340,
334,
2324,
315,
485
] |
[
624,
3100,
14975,
367,
10444,
12,
23350,
12,
503,
4376,
4174,
10298,
641,
4052,
2656,
781,
3984,
641,
14,
199,
199,
2765,
22609,
26,
523,
446,
1006,
3423,
687,
10694,
12,
13377,
12,
747,
18,
12,
503,
10142,
12,
325,
14,
71,
14,
17002,
12,
5672,
12,
5423,
14,
523,
446,
747,
14,
515,
365,
1902,
15454,
503,
13377,
515,
523,
446,
747,
14,
354,
365,
1902,
283,
9228,
297,
283,
343,
297,
283,
736,
18,
7,
503,
283,
301,
1370,
523,
446,
747,
14,
15594,
365,
282,
1059,
6144,
314,
1453,
2082,
661,
3530,
503,
7596,
358,
523,
446,
747,
14,
21386,
365,
282,
1059,
6144,
314,
1676,
2082,
661,
703,
7,
503,
19069,
358,
523,
446,
747,
14,
4127,
365,
314,
334,
269,
282,
4750,
2863,
9,
11776,
9432,
661,
4805,
503,
10871,
503,
6468,
358,
523,
446,
747,
14,
832,
4127,
365,
314,
3329,
9432,
334,
9223,
20093,
523,
446,
747,
14,
4478,
4127,
365,
314,
18034,
11776,
9432,
334,
403,
503,
15107,
523,
446,
747,
14,
17843,
365,
314,
3931,
9432,
1202,
315,
2672,
3243,
5423,
523,
446,
747,
14,
19254,
365,
314,
1004,
9432,
315,
1318,
1584,
17485,
82,
7,
503,
1557,
78,
7,
503,
1557,
82,
60,
78,
358,
523,
446,
747,
14,
318,
515,
365,
314,
849,
2754,
931,
367,
31172,
523,
446,
747,
14,
19778,
365,
314,
570,
931,
402,
314,
2973,
2243,
14606,
2374,
15,
2307,
297,
5423,
4959,
199,
199,
919,
9292,
626,
492,
436,
675,
283,
736,
7,
10584,
282,
8034,
22044,
402,
3769,
199,
719,
461,
3382,
3365,
10677,
14,
221,
24545,
2518,
12,
2985,
1471,
2066,
199,
2118,
675,
3423,
626,
787,
3247,
701,
1006,
10677,
334,
69,
14,
71,
2020,
17002,
199,
460,
1551,
694,
395,
436,
10137,
1006,
11776,
26212,
370,
747,
14,
515,
199,
8,
69,
14,
71,
2020,
3715,
436,
4263,
680,
199,
624,
199,
199,
646,
984,
12,
7554,
199,
646,
5672,
465,
410,
199,
199,
63,
1247,
275,
984,
14,
5351,
63,
578,
63,
1247,
199,
199,
3,
3390,
26,
221,
1655,
1561,
787,
3483,
370,
636,
452,
363,
2945,
14,
199,
363,
452,
363,
275,
2097,
4478,
4127,
401,
298,
15594,
401,
298,
21386,
401,
298,
4127,
401,
298,
17843,
401,
298,
19254,
401,
1779,
298,
318,
515,
401,
298,
354,
401,
298,
515,
401,
298,
19778,
401,
298,
18439,
63,
3597,
401,
298,
18439,
63,
7013,
401,
1779,
298,
18439,
63,
3902,
401,
298,
70,
2464,
600,
401,
298,
2319,
2708,
401,
298,
362,
63,
1628,
63,
515,
401,
298,
23140,
401,
1779,
298,
12207,
401,
298,
832,
4127,
937,
199,
199,
318,
485,
2444,
8,
354,
304,
272,
372,
536,
315,
7992,
342,
199,
199,
318,
485,
362,
63,
20775,
63,
513,
8,
578,
304,
272,
862,
26,
267,
372,
769,
8,
578,
855,
452,
3368,
272,
871,
4281,
26,
267,
372,
359,
78,
367,
302,
315,
2935,
8,
578,
9,
340,
302,
59,
16,
61,
1137,
2513,
418,
199,
199,
3,
6184,
892,
5124,
402,
314,
747,
859,
436,
15,
269,
4493,
315,
931,
9432,
199,
3,
5074,
12928,
14802,
465,
5521,
14,
199,
692,
283,
9228,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
9228,
7,
272,
1004,
4127,
275,
1557,
78,
7,
272,
687,
10694,
492,
627,
272,
862,
26,
267,
687,
10694,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
492,
15454,
465,
931,
339,
862,
26,
267,
687,
10694,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
4164,
283,
343,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
343,
7,
272,
1004,
4127,
275,
1557,
82,
60,
78,
7,
272,
687,
13377,
492,
627,
272,
862,
26,
267,
687,
13377,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
492,
13377,
515,
465,
931,
339,
492,
13377,
272,
636,
452,
4343,
2880,
1547,
362,
63,
20775,
63,
513,
8,
343,
430,
272,
2150,
13377,
339,
862,
26,
267,
687,
13377,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
4164,
283,
736,
18,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
736,
18,
7,
272,
1004,
4127,
275,
1557,
82,
60,
78,
7,
272,
687,
747,
18,
492,
627,
272,
862,
26,
267,
687,
747,
18,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
340,
984,
14,
1023,
14,
1623,
360,
2769,
56,
598,
2571,
358,
508,
446,
17,
26,
267,
492,
13377,
515,
465,
931,
272,
587,
26,
267,
492,
747,
18,
5633,
8006,
465,
931,
267,
687,
485,
5633,
88,
63,
1073,
492,
2142,
339,
492,
747,
18,
272,
636,
452,
4343,
2880,
1547,
362,
63,
20775,
63,
513,
8,
736,
18,
430,
272,
2150,
747,
18,
339,
862,
26,
267,
687,
747,
18,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
4164,
283,
301,
7,
315,
485,
1247,
26,
272,
536,
275,
283,
301,
7,
272,
1004,
4127,
275,
1557,
82,
60,
78,
7,
272,
687,
10142,
492,
627,
272,
862,
26,
267,
687,
10142,
492,
485,
2224,
267,
636,
452,
4343,
740,
6412,
2224,
358,
272,
871,
3545,
26,
267,
986,
272,
327,
2136,
883,
675,
314,
4465,
5417,
931,
14,
272,
492,
13377,
515,
465,
931,
339,
492,
10142,
272,
636,
452,
4343,
2880,
1547,
362,
63,
20775,
63,
513,
8,
301,
430,
272,
2150,
10142,
339,
862,
26,
267,
687,
10142,
492,
485,
7804,
63,
5777,
272,
871,
3545,
26,
267,
986,
199,
199,
2836,
26,
272,
746,
3545,
360,
889,
747,
2488,
859,
1911,
358,
199,
199,
1274,
14,
3112,
459,
736,
14,
515,
418,
275,
931,
199,
504,
747,
14,
515,
492,
334,
15594,
12,
623,
694,
12,
7375,
12,
931,
4127,
12,
347,
515,
12,
1599,
4127,
12,
8791,
4127,
12,
272,
4866,
2307,
9,
199,
199,
2264,
485,
1247,
421,
199,
692,
485,
2444,
11008,
7804,
63,
5777,
2349,
272,
485,
8473,
275,
7992,
342,
272,
347,
485,
525,
8,
495,
12,
4325,
304,
267,
340,
334,
2324,
315,
485,
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
] |
aerickson/OctoPrint
|
src/octoprint/server/api/timelapse.py
|
9
|
2551
|
# coding=utf-8
__author__ = "Gina Häußge <osd@foosel.net>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
import os
from flask import request, jsonify, url_for
from werkzeug.utils import secure_filename
import octoprint.timelapse
import octoprint.util as util
from octoprint.settings import settings, valid_boolean_trues
from octoprint.server import restricted_access, admin_permission
from octoprint.server.util import redirectToTornado
from octoprint.server.api import api
#~~ timelapse handling
@api.route("/timelapse", methods=["GET"])
def getTimelapseData():
timelapse = octoprint.timelapse.current
config = {"type": "off"}
if timelapse is not None and isinstance(timelapse, octoprint.timelapse.ZTimelapse):
config["type"] = "zchange"
config["postRoll"] = timelapse.postRoll()
elif timelapse is not None and isinstance(timelapse, octoprint.timelapse.TimedTimelapse):
config["type"] = "timed"
config["postRoll"] = timelapse.postRoll()
config.update({
"interval": timelapse.interval()
})
files = octoprint.timelapse.getFinishedTimelapses()
for file in files:
file["url"] = url_for("index") + "downloads/timelapse/" + file["name"]
return jsonify({
"config": config,
"files": files
})
@api.route("/timelapse/<filename>", methods=["GET"])
def downloadTimelapse(filename):
return redirectToTornado(request, url_for("index") + "downloads/timelapse/" + filename)
@api.route("/timelapse/<filename>", methods=["DELETE"])
@restricted_access
def deleteTimelapse(filename):
if util.isAllowedFile(filename, {"mpg"}):
secure = os.path.join(settings().getBaseFolder("timelapse"), secure_filename(filename))
if os.path.exists(secure):
os.remove(secure)
return getTimelapseData()
@api.route("/timelapse", methods=["POST"])
@restricted_access
def setTimelapseConfig():
if "type" in request.values:
config = {
"type": request.values["type"],
"postRoll": 0,
"options": {}
}
if "postRoll" in request.values:
try:
config["postRoll"] = int(request.values["postRoll"])
except ValueError:
pass
if "interval" in request.values:
interval = 10
try:
interval = int(request.values["interval"])
except ValueError:
pass
config["options"] = {
"interval": interval
}
if admin_permission.can() and "save" in request.values and request.values["save"] in valid_boolean_trues:
octoprint.timelapse.configureTimelapse(config, True)
else:
octoprint.timelapse.configureTimelapse(config)
return getTimelapseData()
|
agpl-3.0
|
[
3,
2803,
29,
1624,
13,
24,
199,
363,
2502,
363,
275,
298,
39,
13765,
869,
13733,
85,
128,
254,
303,
665,
736,
68,
32,
1421,
5891,
14,
846,
4335,
199,
363,
1682,
363,
275,
283,
17732,
4265,
1696,
1684,
844,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
14,
1360,
7,
199,
199,
646,
747,
199,
199,
504,
7209,
492,
1056,
12,
23819,
12,
1166,
63,
509,
199,
504,
10380,
14,
1208,
492,
11153,
63,
1501,
199,
199,
646,
17162,
411,
672,
14,
521,
12057,
199,
646,
17162,
411,
672,
14,
1974,
465,
4884,
199,
504,
17162,
411,
672,
14,
1751,
492,
2202,
12,
1686,
63,
4871,
63,
2052,
83,
199,
199,
504,
17162,
411,
672,
14,
1000,
492,
15297,
63,
2732,
12,
4628,
63,
5693,
199,
504,
17162,
411,
672,
14,
1000,
14,
1974,
492,
4660,
1378,
52,
8622,
199,
504,
17162,
411,
672,
14,
1000,
14,
1246,
492,
2986,
421,
199,
3,
1714,
900,
12057,
7252,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
401,
3102,
6270,
2970,
3135,
199,
318,
664,
1366,
12057,
1451,
837,
199,
198,
521,
12057,
275,
17162,
411,
672,
14,
521,
12057,
14,
1818,
421,
198,
888,
275,
2420,
466,
582,
298,
1997,
3570,
199,
198,
692,
900,
12057,
365,
440,
488,
436,
1228,
8,
521,
12057,
12,
17162,
411,
672,
14,
521,
12057,
14,
58,
1366,
12057,
304,
507,
198,
888,
905,
466,
937,
275,
298,
90,
1461,
2,
507,
198,
888,
905,
1932,
24363,
937,
275,
900,
12057,
14,
1932,
24363,
342,
199,
198,
4164,
900,
12057,
365,
440,
488,
436,
1228,
8,
521,
12057,
12,
17162,
411,
672,
14,
521,
12057,
14,
28682,
1366,
12057,
304,
507,
198,
888,
905,
466,
937,
275,
298,
26687,
2,
507,
198,
888,
905,
1932,
24363,
937,
275,
900,
12057,
14,
1932,
24363,
342,
507,
198,
888,
14,
873,
2561,
686,
198,
2,
4284,
582,
900,
12057,
14,
4284,
342,
507,
198,
1552,
421,
198,
1725,
275,
17162,
411,
672,
14,
521,
12057,
14,
362,
13430,
1366,
4762,
874,
342,
199,
198,
509,
570,
315,
1584,
26,
507,
198,
493,
905,
633,
937,
275,
1166,
63,
509,
480,
1080,
531,
435,
298,
20373,
15,
521,
12057,
6687,
435,
570,
905,
354,
937,
421,
198,
1107,
23819,
2561,
507,
198,
2,
888,
582,
1101,
12,
507,
198,
2,
1725,
582,
1584,
199,
198,
1552,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
8316,
1501,
7166,
3102,
6270,
2970,
3135,
199,
318,
5235,
1366,
12057,
8,
1501,
304,
199,
198,
1107,
4660,
1378,
52,
8622,
8,
1069,
12,
1166,
63,
509,
480,
1080,
531,
435,
298,
20373,
15,
521,
12057,
6687,
435,
1788,
9,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
8316,
1501,
7166,
3102,
6270,
7014,
3135,
199,
32,
17973,
63,
2732,
199,
318,
3145,
1366,
12057,
8,
1501,
304,
199,
198,
692,
4884,
14,
374,
16070,
1173,
8,
1501,
12,
2420,
311,
71,
3570,
304,
507,
198,
7817,
275,
747,
14,
515,
14,
904,
8,
1751,
1252,
362,
1563,
7850,
480,
521,
12057,
1288,
11153,
63,
1501,
8,
1501,
430,
507,
198,
692,
747,
14,
515,
14,
2444,
8,
7817,
304,
686,
198,
736,
14,
2168,
8,
7817,
9,
199,
198,
1107,
664,
1366,
12057,
1451,
342,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
401,
3102,
6270,
4030,
3135,
199,
32,
17973,
63,
2732,
199,
318,
663,
1366,
12057,
2028,
837,
199,
198,
692,
298,
466,
2,
315,
1056,
14,
1459,
26,
507,
198,
888,
275,
469,
686,
198,
2,
466,
582,
1056,
14,
1459,
905,
466,
2255,
686,
198,
2,
1932,
24363,
582,
378,
12,
686,
198,
2,
1419,
582,
1052,
507,
198,
93,
421,
507,
198,
692,
298,
1932,
24363,
2,
315,
1056,
14,
1459,
26,
686,
198,
893,
26,
1585,
198,
888,
905,
1932,
24363,
937,
275,
1109,
8,
1069,
14,
1459,
905,
1932,
24363,
3135,
686,
198,
2590,
1722,
26,
1585,
198,
1529,
2742,
198,
692,
298,
4284,
2,
315,
1056,
14,
1459,
26,
686,
198,
4284,
275,
1616,
686,
198,
893,
26,
1585,
198,
4284,
275,
1109,
8,
1069,
14,
1459,
905,
4284,
3135,
686,
198,
2590,
1722,
26,
1585,
198,
1529,
6319,
198,
888,
905,
1419,
937,
275,
469,
1585,
198,
2,
4284,
582,
6252,
686,
198,
93,
2742,
198,
692,
4628,
63,
5693,
14,
2425,
342,
436,
298,
2117,
2,
315,
1056,
14,
1459,
436,
1056,
14,
1459,
905,
2117,
937,
315,
1686,
63,
4871,
63,
2052,
83,
26,
686,
198,
15560,
411,
672,
14,
521,
12057,
14,
6472,
1366,
12057,
8,
888,
12,
715,
9,
507,
198,
2836,
26,
686,
198,
15560,
411,
672,
14,
521,
12057,
14,
6472,
1366,
12057,
8,
888,
9,
421,
198,
1107,
664,
1366,
12057,
1451,
342,
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
] |
[
2803,
29,
1624,
13,
24,
199,
363,
2502,
363,
275,
298,
39,
13765,
869,
13733,
85,
128,
254,
303,
665,
736,
68,
32,
1421,
5891,
14,
846,
4335,
199,
363,
1682,
363,
275,
283,
17732,
4265,
1696,
1684,
844,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
643,
1168,
14,
1360,
7,
199,
199,
646,
747,
199,
199,
504,
7209,
492,
1056,
12,
23819,
12,
1166,
63,
509,
199,
504,
10380,
14,
1208,
492,
11153,
63,
1501,
199,
199,
646,
17162,
411,
672,
14,
521,
12057,
199,
646,
17162,
411,
672,
14,
1974,
465,
4884,
199,
504,
17162,
411,
672,
14,
1751,
492,
2202,
12,
1686,
63,
4871,
63,
2052,
83,
199,
199,
504,
17162,
411,
672,
14,
1000,
492,
15297,
63,
2732,
12,
4628,
63,
5693,
199,
504,
17162,
411,
672,
14,
1000,
14,
1974,
492,
4660,
1378,
52,
8622,
199,
504,
17162,
411,
672,
14,
1000,
14,
1246,
492,
2986,
421,
199,
3,
1714,
900,
12057,
7252,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
401,
3102,
6270,
2970,
3135,
199,
318,
664,
1366,
12057,
1451,
837,
199,
198,
521,
12057,
275,
17162,
411,
672,
14,
521,
12057,
14,
1818,
421,
198,
888,
275,
2420,
466,
582,
298,
1997,
3570,
199,
198,
692,
900,
12057,
365,
440,
488,
436,
1228,
8,
521,
12057,
12,
17162,
411,
672,
14,
521,
12057,
14,
58,
1366,
12057,
304,
507,
198,
888,
905,
466,
937,
275,
298,
90,
1461,
2,
507,
198,
888,
905,
1932,
24363,
937,
275,
900,
12057,
14,
1932,
24363,
342,
199,
198,
4164,
900,
12057,
365,
440,
488,
436,
1228,
8,
521,
12057,
12,
17162,
411,
672,
14,
521,
12057,
14,
28682,
1366,
12057,
304,
507,
198,
888,
905,
466,
937,
275,
298,
26687,
2,
507,
198,
888,
905,
1932,
24363,
937,
275,
900,
12057,
14,
1932,
24363,
342,
507,
198,
888,
14,
873,
2561,
686,
198,
2,
4284,
582,
900,
12057,
14,
4284,
342,
507,
198,
1552,
421,
198,
1725,
275,
17162,
411,
672,
14,
521,
12057,
14,
362,
13430,
1366,
4762,
874,
342,
199,
198,
509,
570,
315,
1584,
26,
507,
198,
493,
905,
633,
937,
275,
1166,
63,
509,
480,
1080,
531,
435,
298,
20373,
15,
521,
12057,
6687,
435,
570,
905,
354,
937,
421,
198,
1107,
23819,
2561,
507,
198,
2,
888,
582,
1101,
12,
507,
198,
2,
1725,
582,
1584,
199,
198,
1552,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
8316,
1501,
7166,
3102,
6270,
2970,
3135,
199,
318,
5235,
1366,
12057,
8,
1501,
304,
199,
198,
1107,
4660,
1378,
52,
8622,
8,
1069,
12,
1166,
63,
509,
480,
1080,
531,
435,
298,
20373,
15,
521,
12057,
6687,
435,
1788,
9,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
8316,
1501,
7166,
3102,
6270,
7014,
3135,
199,
32,
17973,
63,
2732,
199,
318,
3145,
1366,
12057,
8,
1501,
304,
199,
198,
692,
4884,
14,
374,
16070,
1173,
8,
1501,
12,
2420,
311,
71,
3570,
304,
507,
198,
7817,
275,
747,
14,
515,
14,
904,
8,
1751,
1252,
362,
1563,
7850,
480,
521,
12057,
1288,
11153,
63,
1501,
8,
1501,
430,
507,
198,
692,
747,
14,
515,
14,
2444,
8,
7817,
304,
686,
198,
736,
14,
2168,
8,
7817,
9,
199,
198,
1107,
664,
1366,
12057,
1451,
342,
421,
199,
32,
1246,
14,
4449,
4769,
521,
12057,
401,
3102,
6270,
4030,
3135,
199,
32,
17973,
63,
2732,
199,
318,
663,
1366,
12057,
2028,
837,
199,
198,
692,
298,
466,
2,
315,
1056,
14,
1459,
26,
507,
198,
888,
275,
469,
686,
198,
2,
466,
582,
1056,
14,
1459,
905,
466,
2255,
686,
198,
2,
1932,
24363,
582,
378,
12,
686,
198,
2,
1419,
582,
1052,
507,
198,
93,
421,
507,
198,
692,
298,
1932,
24363,
2,
315,
1056,
14,
1459,
26,
686,
198,
893,
26,
1585,
198,
888,
905,
1932,
24363,
937,
275,
1109,
8,
1069,
14,
1459,
905,
1932,
24363,
3135,
686,
198,
2590,
1722,
26,
1585,
198,
1529,
2742,
198,
692,
298,
4284,
2,
315,
1056,
14,
1459,
26,
686,
198,
4284,
275,
1616,
686,
198,
893,
26,
1585,
198,
4284,
275,
1109,
8,
1069,
14,
1459,
905,
4284,
3135,
686,
198,
2590,
1722,
26,
1585,
198,
1529,
6319,
198,
888,
905,
1419,
937,
275,
469,
1585,
198,
2,
4284,
582,
6252,
686,
198,
93,
2742,
198,
692,
4628,
63,
5693,
14,
2425,
342,
436,
298,
2117,
2,
315,
1056,
14,
1459,
436,
1056,
14,
1459,
905,
2117,
937,
315,
1686,
63,
4871,
63,
2052,
83,
26,
686,
198,
15560,
411,
672,
14,
521,
12057,
14,
6472,
1366,
12057,
8,
888,
12,
715,
9,
507,
198,
2836,
26,
686,
198,
15560,
411,
672,
14,
521,
12057,
14,
6472,
1366,
12057,
8,
888,
9,
421,
198,
1107,
664,
1366,
12057,
1451,
342,
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,
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,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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
] |
cyberark-bizdev/ansible
|
lib/ansible/modules/cloud/openstack/os_keystone_endpoint.py
|
20
|
6464
|
#!/usr/bin/python
# Copyright: (c) 2017, VEXXHOST, 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: os_keystone_endpoint
short_description: Manage OpenStack Identity service endpoints
extends_documentation_fragment: openstack
author:
- Mohammed Naser (@mnaser)
- Alberto Murillo (@albertomurillo)
version_added: "2.5"
description:
- Create, update, or delete OpenStack Identity service endpoints. If a
service with the same combination of I(service), I(interface) and I(region)
exist, the I(url) and I(state) (C(present) or C(absent)) will be updated.
options:
service:
description:
- Name or id of the service.
required: true
interface:
description:
- Interface of the service.
choices: [admin, public, internal]
required: true
url:
description:
- URL of the service.
required: true
region:
description:
- Region that the service belongs to. Note that I(region_name) is used for authentication.
enabled:
description:
- Is the service enabled.
default: True
state:
description:
- Should the resource be C(present) or C(absent).
choices: [present, absent]
default: present
requirements:
- shade >= 1.11.0
'''
EXAMPLES = '''
- name: Create a service for glance
os_keystone_endpoint:
cloud: mycloud
service: glance
endpoint_interface: public
url: http://controller:9292
region: RegionOne
state: present
- name: Delete a service for nova
os_keystone_endpoint:
cloud: mycloud
service: nova
endpoint_interface: public
region: RegionOne
state: absent
'''
RETURN = '''
endpoint:
description: Dictionary describing the endpoint.
returned: On success when I(state) is C(present)
type: complex
contains:
id:
description: Endpoint ID.
type: string
sample: 3292f020780b4d5baf27ff7e1d224c44
region:
description: Region Name.
type: string
sample: RegionOne
service_id:
description: Service ID.
type: string
sample: b91f1318f735494a825a55388ee118f3
interface:
description: Endpoint Interface.
type: string
sample: public
url:
description: Service URL.
type: string
sample: http://controller:9292
enabled:
description: Service status.
type: boolean
sample: True
'''
from distutils.version import StrictVersion
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
def _needs_update(module, endpoint):
if endpoint.enabled != module.params['enabled']:
return True
if endpoint.url != module.params['url']:
return True
return False
def _system_state_change(module, endpoint):
state = module.params['state']
if state == 'absent' and endpoint:
return True
if state == 'present':
if endpoint is None:
return True
return _needs_update(module, endpoint)
return False
def main():
argument_spec = openstack_full_argument_spec(
service=dict(type='str', required=True),
endpoint_interface=dict(type='str', required=True, choices=['admin', 'public', 'internal']),
url=dict(type='str', required=True),
region=dict(type='str'),
enabled=dict(type='bool', default=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
shade, cloud = openstack_cloud_from_module(module, min_version='1.11.0')
service_name_or_id = module.params['service']
interface = module.params['endpoint_interface']
url = module.params['url']
region = module.params['region']
enabled = module.params['enabled']
state = module.params['state']
try:
cloud = shade.operator_cloud(**module.params)
service = cloud.get_service(service_name_or_id)
if service is None:
module.fail_json(msg='Service %s does not exist' % service_name_or_id)
filters = dict(service_id=service.id, interface=interface)
if region is not None:
filters['region'] = region
endpoints = cloud.search_endpoints(filters=filters)
if len(endpoints) > 1:
module.fail_json(msg='Service %s, interface %s and region %s are '
'not unique' %
(service_name_or_id, interface, region))
elif len(endpoints) == 1:
endpoint = endpoints[0]
else:
endpoint = None
if module.check_mode:
module.exit_json(changed=_system_state_change(module, endpoint))
if state == 'present':
if endpoint is None:
result = cloud.create_endpoint(service_name_or_id=service,
url=url, interface=interface,
region=region, enabled=enabled)
endpoint = result[0]
changed = True
else:
if _needs_update(module, endpoint):
endpoint = cloud.update_endpoint(
endpoint.id, url=url, enabled=enabled)
changed = True
else:
changed = False
module.exit_json(changed=changed, endpoint=endpoint)
elif state == 'absent':
if endpoint is None:
changed = False
else:
cloud.delete_endpoint(endpoint.id)
changed = True
module.exit_json(changed=changed)
except shade.OpenStackCloudException as e:
module.fail_json(msg=str(e))
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
199,
3,
1898,
26,
334,
67,
9,
9708,
12,
812,
1438,
56,
5449,
12,
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,
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,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
747,
63,
19143,
63,
6520,
199,
3612,
63,
1802,
26,
14944,
14260,
22034,
2435,
16173,
199,
11036,
63,
9970,
63,
7677,
26,
13869,
199,
2502,
26,
272,
446,
3930,
10670,
3594,
11290,
332,
8593,
77,
3540,
332,
9,
272,
446,
4580,
605,
475,
603,
300,
382,
320,
8593,
279,
605,
3151,
300,
382,
320,
9,
199,
1023,
63,
3270,
26,
298,
18,
14,
21,
2,
199,
1802,
26,
272,
446,
2790,
12,
1678,
12,
503,
3145,
14260,
22034,
2435,
16173,
14,
982,
282,
489,
2435,
543,
314,
2011,
14665,
402,
473,
8,
1364,
395,
473,
8,
3266,
9,
436,
473,
8,
4551,
9,
489,
2187,
12,
314,
473,
8,
633,
9,
436,
473,
8,
929,
9,
334,
35,
8,
1881,
9,
503,
445,
8,
5575,
430,
911,
506,
4588,
14,
199,
1419,
26,
2043,
2435,
26,
1362,
1369,
26,
267,
446,
2812,
503,
1305,
402,
314,
2435,
14,
1362,
1415,
26,
2549,
2043,
3217,
26,
1362,
1369,
26,
267,
446,
14816,
402,
314,
2435,
14,
1362,
3415,
26,
359,
2113,
12,
4575,
12,
5007,
61,
1362,
1415,
26,
2549,
2043,
1166,
26,
1362,
1369,
26,
267,
446,
2851,
402,
314,
2435,
14,
1362,
1415,
26,
2549,
2043,
4897,
26,
1362,
1369,
26,
267,
446,
22240,
626,
314,
2435,
15006,
370,
14,
3390,
626,
473,
8,
4551,
63,
354,
9,
365,
1202,
367,
6299,
14,
2043,
5223,
26,
1362,
1369,
26,
267,
446,
6596,
314,
2435,
5223,
14,
1362,
849,
26,
715,
2043,
1174,
26,
1362,
1369,
26,
2126,
446,
7719,
314,
2073,
506,
445,
8,
1881,
9,
503,
445,
8,
5575,
680,
1362,
3415,
26,
359,
1881,
12,
9552,
61,
1362,
849,
26,
3451,
199,
7538,
26,
272,
446,
32250,
2356,
413,
14,
845,
14,
16,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
2790,
282,
2435,
367,
21785,
523,
747,
63,
19143,
63,
6520,
26,
1362,
8002,
26,
3002,
4091,
1362,
2435,
26,
21785,
1362,
6037,
63,
3266,
26,
4575,
1362,
1166,
26,
1455,
921,
5538,
26,
25,
17027,
1362,
4897,
26,
22240,
4395,
1362,
1174,
26,
3451,
199,
199,
13,
536,
26,
8496,
282,
2435,
367,
5913,
523,
747,
63,
19143,
63,
6520,
26,
1362,
8002,
26,
3002,
4091,
1362,
2435,
26,
5913,
1362,
6037,
63,
3266,
26,
4575,
1362,
4897,
26,
22240,
4395,
1362,
1174,
26,
9552,
199,
2344,
199,
199,
9677,
275,
1449,
199,
6520,
26,
272,
1369,
26,
11932,
13660,
314,
6037,
14,
272,
2138,
26,
4068,
3182,
1380,
473,
8,
929,
9,
365,
445,
8,
1881,
9,
272,
730,
26,
6114,
272,
3509,
26,
267,
1305,
26,
288,
1369,
26,
9599,
1403,
2870,
14,
288,
730,
26,
1059,
288,
2690,
26,
650,
17027,
70,
996,
1780,
1257,
66,
20,
68,
21,
25485,
1465,
556,
23,
69,
17,
68,
8731,
67,
1602,
267,
4897,
26,
288,
1369,
26,
22240,
2812,
14,
288,
730,
26,
1059,
288,
2690,
26,
22240,
4395,
267,
2435,
63,
344,
26,
288,
1369,
26,
7591,
2870,
14,
288,
730,
26,
1059,
288,
2690,
26,
330,
3328,
70,
969,
1085,
70,
31327,
19422,
65,
29208,
65,
1229,
11403,
1024,
7906,
70,
19,
267,
3217,
26,
288,
1369,
26,
9599,
1403,
14816,
14,
288,
730,
26,
1059,
288,
2690,
26,
4575,
267,
1166,
26,
288,
1369,
26,
7591,
2851,
14,
288,
730,
26,
1059,
288,
2690,
26,
1455,
921,
5538,
26,
25,
17027,
267,
5223,
26,
288,
1369,
26,
7591,
2004,
14,
288,
730,
26,
5046,
288,
2690,
26,
715,
199,
2344,
199,
199,
504,
7065,
14,
1023,
492,
23052,
3353,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
8512,
492,
13869,
63,
2861,
63,
2094,
63,
1650,
12,
13869,
63,
578,
63,
958,
12,
13869,
63,
4091,
63,
504,
63,
578,
421,
199,
318,
485,
10065,
63,
873,
8,
578,
12,
6037,
304,
272,
340,
6037,
14,
3827,
1137,
859,
14,
1162,
459,
3827,
2565,
267,
372,
715,
272,
340,
6037,
14,
633,
1137,
859,
14,
1162,
459,
633,
2565,
267,
372,
715,
272,
372,
756,
421,
199,
318,
485,
2253,
63,
929,
63,
1461,
8,
578,
12,
6037,
304,
272,
1174,
275,
859,
14,
1162,
459,
929,
418,
272,
340,
1174,
508,
283,
5575,
7,
436,
6037,
26,
267,
372,
715,
339,
340,
1174,
508,
283,
1881,
356,
267,
340,
6037,
365,
488,
26,
288,
372,
715,
267,
372,
485,
10065,
63,
873,
8,
578,
12,
6037,
9,
339,
372,
756,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
13869,
63,
2861,
63,
2094,
63,
1650,
8,
267,
2435,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
6037,
63,
3266,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
12,
3415,
2968,
2113,
297,
283,
3455,
297,
283,
4672,
3815,
267,
1166,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
4897,
29,
807,
8,
466,
534,
495,
659,
267,
5223,
29,
807,
8,
466,
534,
2245,
297,
849,
29,
549,
395,
267,
1174,
29,
807,
8,
466,
534,
495,
297,
849,
534,
1881,
297,
3415,
2968,
5575,
297,
283,
1881,
3815,
272,
776,
339,
859,
63,
958,
275,
13869,
63,
578,
63,
958,
342,
272,
859,
275,
6953,
8,
2094,
63,
1650,
12,
2574,
5171,
63,
1074,
63,
632,
29,
549,
12,
2574,
1011,
578,
63,
958,
9,
339,
32250,
12,
8002,
275,
13869,
63,
4091,
63,
504,
63,
578,
8,
578,
12,
1748,
63,
1023,
534,
17,
14
] |
[
2647,
15,
1393,
15,
1548,
199,
199,
3,
1898,
26,
334,
67,
9,
9708,
12,
812,
1438,
56,
5449,
12,
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,
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,
199,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
747,
63,
19143,
63,
6520,
199,
3612,
63,
1802,
26,
14944,
14260,
22034,
2435,
16173,
199,
11036,
63,
9970,
63,
7677,
26,
13869,
199,
2502,
26,
272,
446,
3930,
10670,
3594,
11290,
332,
8593,
77,
3540,
332,
9,
272,
446,
4580,
605,
475,
603,
300,
382,
320,
8593,
279,
605,
3151,
300,
382,
320,
9,
199,
1023,
63,
3270,
26,
298,
18,
14,
21,
2,
199,
1802,
26,
272,
446,
2790,
12,
1678,
12,
503,
3145,
14260,
22034,
2435,
16173,
14,
982,
282,
489,
2435,
543,
314,
2011,
14665,
402,
473,
8,
1364,
395,
473,
8,
3266,
9,
436,
473,
8,
4551,
9,
489,
2187,
12,
314,
473,
8,
633,
9,
436,
473,
8,
929,
9,
334,
35,
8,
1881,
9,
503,
445,
8,
5575,
430,
911,
506,
4588,
14,
199,
1419,
26,
2043,
2435,
26,
1362,
1369,
26,
267,
446,
2812,
503,
1305,
402,
314,
2435,
14,
1362,
1415,
26,
2549,
2043,
3217,
26,
1362,
1369,
26,
267,
446,
14816,
402,
314,
2435,
14,
1362,
3415,
26,
359,
2113,
12,
4575,
12,
5007,
61,
1362,
1415,
26,
2549,
2043,
1166,
26,
1362,
1369,
26,
267,
446,
2851,
402,
314,
2435,
14,
1362,
1415,
26,
2549,
2043,
4897,
26,
1362,
1369,
26,
267,
446,
22240,
626,
314,
2435,
15006,
370,
14,
3390,
626,
473,
8,
4551,
63,
354,
9,
365,
1202,
367,
6299,
14,
2043,
5223,
26,
1362,
1369,
26,
267,
446,
6596,
314,
2435,
5223,
14,
1362,
849,
26,
715,
2043,
1174,
26,
1362,
1369,
26,
2126,
446,
7719,
314,
2073,
506,
445,
8,
1881,
9,
503,
445,
8,
5575,
680,
1362,
3415,
26,
359,
1881,
12,
9552,
61,
1362,
849,
26,
3451,
199,
7538,
26,
272,
446,
32250,
2356,
413,
14,
845,
14,
16,
199,
2344,
199,
199,
8918,
275,
1449,
199,
13,
536,
26,
2790,
282,
2435,
367,
21785,
523,
747,
63,
19143,
63,
6520,
26,
1362,
8002,
26,
3002,
4091,
1362,
2435,
26,
21785,
1362,
6037,
63,
3266,
26,
4575,
1362,
1166,
26,
1455,
921,
5538,
26,
25,
17027,
1362,
4897,
26,
22240,
4395,
1362,
1174,
26,
3451,
199,
199,
13,
536,
26,
8496,
282,
2435,
367,
5913,
523,
747,
63,
19143,
63,
6520,
26,
1362,
8002,
26,
3002,
4091,
1362,
2435,
26,
5913,
1362,
6037,
63,
3266,
26,
4575,
1362,
4897,
26,
22240,
4395,
1362,
1174,
26,
9552,
199,
2344,
199,
199,
9677,
275,
1449,
199,
6520,
26,
272,
1369,
26,
11932,
13660,
314,
6037,
14,
272,
2138,
26,
4068,
3182,
1380,
473,
8,
929,
9,
365,
445,
8,
1881,
9,
272,
730,
26,
6114,
272,
3509,
26,
267,
1305,
26,
288,
1369,
26,
9599,
1403,
2870,
14,
288,
730,
26,
1059,
288,
2690,
26,
650,
17027,
70,
996,
1780,
1257,
66,
20,
68,
21,
25485,
1465,
556,
23,
69,
17,
68,
8731,
67,
1602,
267,
4897,
26,
288,
1369,
26,
22240,
2812,
14,
288,
730,
26,
1059,
288,
2690,
26,
22240,
4395,
267,
2435,
63,
344,
26,
288,
1369,
26,
7591,
2870,
14,
288,
730,
26,
1059,
288,
2690,
26,
330,
3328,
70,
969,
1085,
70,
31327,
19422,
65,
29208,
65,
1229,
11403,
1024,
7906,
70,
19,
267,
3217,
26,
288,
1369,
26,
9599,
1403,
14816,
14,
288,
730,
26,
1059,
288,
2690,
26,
4575,
267,
1166,
26,
288,
1369,
26,
7591,
2851,
14,
288,
730,
26,
1059,
288,
2690,
26,
1455,
921,
5538,
26,
25,
17027,
267,
5223,
26,
288,
1369,
26,
7591,
2004,
14,
288,
730,
26,
5046,
288,
2690,
26,
715,
199,
2344,
199,
199,
504,
7065,
14,
1023,
492,
23052,
3353,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
8512,
492,
13869,
63,
2861,
63,
2094,
63,
1650,
12,
13869,
63,
578,
63,
958,
12,
13869,
63,
4091,
63,
504,
63,
578,
421,
199,
318,
485,
10065,
63,
873,
8,
578,
12,
6037,
304,
272,
340,
6037,
14,
3827,
1137,
859,
14,
1162,
459,
3827,
2565,
267,
372,
715,
272,
340,
6037,
14,
633,
1137,
859,
14,
1162,
459,
633,
2565,
267,
372,
715,
272,
372,
756,
421,
199,
318,
485,
2253,
63,
929,
63,
1461,
8,
578,
12,
6037,
304,
272,
1174,
275,
859,
14,
1162,
459,
929,
418,
272,
340,
1174,
508,
283,
5575,
7,
436,
6037,
26,
267,
372,
715,
339,
340,
1174,
508,
283,
1881,
356,
267,
340,
6037,
365,
488,
26,
288,
372,
715,
267,
372,
485,
10065,
63,
873,
8,
578,
12,
6037,
9,
339,
372,
756,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
13869,
63,
2861,
63,
2094,
63,
1650,
8,
267,
2435,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
6037,
63,
3266,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
12,
3415,
2968,
2113,
297,
283,
3455,
297,
283,
4672,
3815,
267,
1166,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
4897,
29,
807,
8,
466,
534,
495,
659,
267,
5223,
29,
807,
8,
466,
534,
2245,
297,
849,
29,
549,
395,
267,
1174,
29,
807,
8,
466,
534,
495,
297,
849,
534,
1881,
297,
3415,
2968,
5575,
297,
283,
1881,
3815,
272,
776,
339,
859,
63,
958,
275,
13869,
63,
578,
63,
958,
342,
272,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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
] |
stefanodoni/HTperf
|
main-live-ack.py
|
2
|
3411
|
#!/usr/bin/env python3
from argparse import ArgumentParser
from functools import partial
from asyncio import get_event_loop, Future, Queue
from toolrack.script import Script
from toolrack.async import ProcessParserProtocol
class CommandOutputParser:
'''Parse process output and push parsed samples to a queue.'''
def __init__(self, loop, queue):
self._loop = loop
self._queue = queue
async def __call__(self, parser):
'''Run a a process and parse its output using the parser.'''
future = Future(loop=self._loop)
parser_func = partial(self._out_parser, parser.parse_line)
protocol = ProcessParserProtocol(future, out_parser=parser_func)
transport, _ = await self._loop.subprocess_exec(
lambda: protocol, *parser.cmdline)
result = await future
transport.close()
await self._queue.put(None) # To end processing
return result
def _out_parser(self, parser_func, line):
value = parser_func(line)
if value is not None:
self._queue.put_nowait(value)
class Collector:
'''Collect samples from a queue and process them.'''
def __init__(self, queue, sample_count):
self._queue = queue
self._sample_count = sample_count
self._samples = []
async def __call__(self, processor):
'''Process samples from a queue using the processor.'''
while True:
sample = await self._queue.get()
if sample is None:
self._process_pending_samples(processor)
return
self._samples.append(sample)
if len(self._samples) == self._sample_count:
self._process_pending_samples(processor)
def _process_pending_samples(self, processor):
'''Process the list of pending samples.'''
samples, self._samples = self._samples, []
if samples:
processor.process(samples)
class ProcessParser:
'''Parse a process output line by line.'''
cmdline = ['vmstat', '1']
#cmdline = ['sudo', 'perf', 'stat', '-I', '1000', '-aAe', 'cycles,instructions']
def parse_line(self, line):
'''Parse a line of process output.
It must return the sample to queue.
'''
tokens = line.split()
try:
return int(tokens[3])
except ValueError:
pass
class SampleProcessor:
'''Process samples.'''
def process(self, samples):
'''Process a list of samples.'''
print(float(sum(samples)) / len(samples))
class AggregatorScript(Script):
def get_parser(self):
parser = ArgumentParser(
description='Parse process output and aggregate samples.')
parser.add_argument(
'-c', '--sample-count', type=int, default=5,
help='number of samples to aggregate')
return parser
def main(self, args):
loop = get_event_loop()
loop.run_until_complete(self._main(loop, args))
loop.close()
async def _main(self, loop, args):
queue = Queue(loop=loop)
parser = CommandOutputParser(loop, queue)
collector = Collector(queue, args.sample_count)
task = loop.create_task(collector(SampleProcessor()))
await parser(ProcessParser())
await task
if __name__ == '__main__':
script = AggregatorScript()
script()
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
199,
504,
7534,
492,
27615,
199,
504,
9143,
492,
7417,
199,
504,
16195,
492,
664,
63,
1430,
63,
3813,
12,
20799,
12,
10703,
199,
199,
504,
4744,
8085,
14,
1579,
492,
14914,
199,
504,
4744,
8085,
14,
4146,
492,
7132,
2842,
3658,
421,
199,
533,
5817,
2959,
2842,
26,
272,
1449,
4003,
2112,
1072,
436,
6675,
4565,
5845,
370,
282,
4126,
10595,
339,
347,
636,
826,
721,
277,
12,
4438,
12,
4126,
304,
267,
291,
423,
3813,
275,
4438,
267,
291,
423,
1825,
275,
4126,
339,
5316,
347,
636,
1250,
721,
277,
12,
1798,
304,
267,
1449,
2540,
282,
282,
2112,
436,
2198,
2399,
1072,
1808,
314,
1798,
10595,
267,
6466,
275,
20799,
8,
3813,
29,
277,
423,
3813,
9,
267,
1798,
63,
1532,
275,
7417,
8,
277,
423,
548,
63,
2087,
12,
1798,
14,
1122,
63,
604,
9,
267,
4113,
275,
7132,
2842,
3658,
8,
2443,
12,
734,
63,
2087,
29,
2087,
63,
1532,
9,
267,
7773,
12,
485,
275,
5517,
291,
423,
3813,
14,
5781,
63,
1628,
8,
288,
2400,
26,
4113,
12,
627,
2087,
14,
15612,
9,
267,
754,
275,
5517,
6466,
267,
7773,
14,
1600,
342,
267,
5517,
291,
423,
1825,
14,
524,
8,
403,
9,
221,
327,
4005,
1284,
6661,
267,
372,
754,
339,
347,
485,
548,
63,
2087,
8,
277,
12,
1798,
63,
1532,
12,
1004,
304,
267,
574,
275,
1798,
63,
1532,
8,
604,
9,
267,
340,
574,
365,
440,
488,
26,
288,
291,
423,
1825,
14,
524,
63,
20870,
8,
585,
9,
421,
199,
533,
3626,
3283,
26,
272,
1449,
25023,
5845,
687,
282,
4126,
436,
2112,
3062,
10595,
339,
347,
636,
826,
721,
277,
12,
4126,
12,
2690,
63,
835,
304,
267,
291,
423,
1825,
275,
4126,
267,
291,
423,
3271,
63,
835,
275,
2690,
63,
835,
267,
291,
423,
3356,
275,
942,
339,
5316,
347,
636,
1250,
721,
277,
12,
12495,
304,
267,
1449,
3498,
5845,
687,
282,
4126,
1808,
314,
12495,
10595,
267,
1830,
715,
26,
288,
2690,
275,
5517,
291,
423,
1825,
14,
362,
342,
288,
340,
2690,
365,
488,
26,
355,
291,
423,
1412,
63,
6455,
63,
3356,
8,
6459,
9,
355,
372,
288,
291,
423,
3356,
14,
740,
8,
3271,
9,
288,
340,
822,
8,
277,
423,
3356,
9,
508,
291,
423,
3271,
63,
835,
26,
355,
291,
423,
1412,
63,
6455,
63,
3356,
8,
6459,
9,
339,
347,
485,
1412,
63,
6455,
63,
3356,
8,
277,
12,
12495,
304,
267,
1449,
3498,
314,
769,
402,
9413,
5845,
10595,
267,
5845,
12,
291,
423,
3356,
275,
291,
423,
3356,
12,
942,
267,
340,
5845,
26,
288,
12495,
14,
1412,
8,
3356,
9,
421,
199,
533,
7132,
2842,
26,
272,
1449,
4003,
282,
2112,
1072,
1004,
701,
1004,
10595,
339,
21206,
275,
788,
2611,
3736,
297,
283,
17,
418,
272,
327,
15612,
275,
788,
12095,
297,
283,
9452,
297,
283,
3736,
297,
2475,
41,
297,
283,
5279,
297,
2475,
65,
33,
69,
297,
283,
23356,
12,
20718,
418,
339,
347,
2198,
63,
604,
8,
277,
12,
1004,
304,
267,
1449,
4003,
282,
1004,
402,
2112,
1072,
14,
398,
2779,
1471,
372,
314,
2690,
370,
4126,
14,
267,
1449,
398,
4645,
275,
1004,
14,
1294,
342,
267,
862,
26,
288,
372,
1109,
8,
4504,
59,
19,
566,
267,
871,
1722,
26,
288,
986,
199,
199,
533,
15227,
10438,
26,
272,
1449,
3498,
5845,
10595,
339,
347,
2112,
8,
277,
12,
5845,
304,
267,
1449,
3498,
282,
769,
402,
5845,
10595,
267,
870,
8,
1609,
8,
1838,
8,
3356,
430,
1182,
822,
8,
3356,
430,
421,
199,
533,
21369,
707,
5229,
8,
5229,
304,
339,
347,
664,
63,
2087,
8,
277,
304,
267,
1798,
275,
27615,
8,
288,
1369,
534,
4003,
2112,
1072,
436,
9531,
5845,
2659,
267,
1798,
14,
525,
63,
2094,
8,
288,
2475,
67,
297,
2850,
3271,
13,
835,
297,
730,
29,
442,
12,
849,
29,
21,
12,
288,
1720,
534,
1955,
402,
5845,
370,
9531,
358,
267,
372,
1798,
339,
347,
2446,
8,
277,
12,
1249,
304,
267,
4438,
275,
664,
63,
1430,
63,
3813,
342,
267,
4438,
14,
1065,
63,
8111,
63,
4883,
8,
277,
423,
973,
8,
3813,
12,
1249,
430,
267,
4438,
14,
1600,
342,
339,
5316,
347,
485,
973,
8,
277,
12,
4438,
12,
1249,
304,
267,
4126,
275,
10703,
8,
3813,
29,
3813,
9,
267,
1798,
275,
5817,
2959,
2842,
8,
3813,
12,
4126,
9,
267,
14910,
275,
3626,
3283,
8,
1825,
12,
1249,
14,
3271,
63,
835,
9,
267,
2120,
275,
4438,
14,
981,
63,
1765,
8,
10946,
8,
8176,
10438,
4059,
267,
5517,
1798,
8,
3498,
2842,
1012,
267,
5517,
2120,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2884,
275,
21369,
707,
5229,
342,
272,
2884,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
199,
504,
7534,
492,
27615,
199,
504,
9143,
492,
7417,
199,
504,
16195,
492,
664,
63,
1430,
63,
3813,
12,
20799,
12,
10703,
199,
199,
504,
4744,
8085,
14,
1579,
492,
14914,
199,
504,
4744,
8085,
14,
4146,
492,
7132,
2842,
3658,
421,
199,
533,
5817,
2959,
2842,
26,
272,
1449,
4003,
2112,
1072,
436,
6675,
4565,
5845,
370,
282,
4126,
10595,
339,
347,
636,
826,
721,
277,
12,
4438,
12,
4126,
304,
267,
291,
423,
3813,
275,
4438,
267,
291,
423,
1825,
275,
4126,
339,
5316,
347,
636,
1250,
721,
277,
12,
1798,
304,
267,
1449,
2540,
282,
282,
2112,
436,
2198,
2399,
1072,
1808,
314,
1798,
10595,
267,
6466,
275,
20799,
8,
3813,
29,
277,
423,
3813,
9,
267,
1798,
63,
1532,
275,
7417,
8,
277,
423,
548,
63,
2087,
12,
1798,
14,
1122,
63,
604,
9,
267,
4113,
275,
7132,
2842,
3658,
8,
2443,
12,
734,
63,
2087,
29,
2087,
63,
1532,
9,
267,
7773,
12,
485,
275,
5517,
291,
423,
3813,
14,
5781,
63,
1628,
8,
288,
2400,
26,
4113,
12,
627,
2087,
14,
15612,
9,
267,
754,
275,
5517,
6466,
267,
7773,
14,
1600,
342,
267,
5517,
291,
423,
1825,
14,
524,
8,
403,
9,
221,
327,
4005,
1284,
6661,
267,
372,
754,
339,
347,
485,
548,
63,
2087,
8,
277,
12,
1798,
63,
1532,
12,
1004,
304,
267,
574,
275,
1798,
63,
1532,
8,
604,
9,
267,
340,
574,
365,
440,
488,
26,
288,
291,
423,
1825,
14,
524,
63,
20870,
8,
585,
9,
421,
199,
533,
3626,
3283,
26,
272,
1449,
25023,
5845,
687,
282,
4126,
436,
2112,
3062,
10595,
339,
347,
636,
826,
721,
277,
12,
4126,
12,
2690,
63,
835,
304,
267,
291,
423,
1825,
275,
4126,
267,
291,
423,
3271,
63,
835,
275,
2690,
63,
835,
267,
291,
423,
3356,
275,
942,
339,
5316,
347,
636,
1250,
721,
277,
12,
12495,
304,
267,
1449,
3498,
5845,
687,
282,
4126,
1808,
314,
12495,
10595,
267,
1830,
715,
26,
288,
2690,
275,
5517,
291,
423,
1825,
14,
362,
342,
288,
340,
2690,
365,
488,
26,
355,
291,
423,
1412,
63,
6455,
63,
3356,
8,
6459,
9,
355,
372,
288,
291,
423,
3356,
14,
740,
8,
3271,
9,
288,
340,
822,
8,
277,
423,
3356,
9,
508,
291,
423,
3271,
63,
835,
26,
355,
291,
423,
1412,
63,
6455,
63,
3356,
8,
6459,
9,
339,
347,
485,
1412,
63,
6455,
63,
3356,
8,
277,
12,
12495,
304,
267,
1449,
3498,
314,
769,
402,
9413,
5845,
10595,
267,
5845,
12,
291,
423,
3356,
275,
291,
423,
3356,
12,
942,
267,
340,
5845,
26,
288,
12495,
14,
1412,
8,
3356,
9,
421,
199,
533,
7132,
2842,
26,
272,
1449,
4003,
282,
2112,
1072,
1004,
701,
1004,
10595,
339,
21206,
275,
788,
2611,
3736,
297,
283,
17,
418,
272,
327,
15612,
275,
788,
12095,
297,
283,
9452,
297,
283,
3736,
297,
2475,
41,
297,
283,
5279,
297,
2475,
65,
33,
69,
297,
283,
23356,
12,
20718,
418,
339,
347,
2198,
63,
604,
8,
277,
12,
1004,
304,
267,
1449,
4003,
282,
1004,
402,
2112,
1072,
14,
398,
2779,
1471,
372,
314,
2690,
370,
4126,
14,
267,
1449,
398,
4645,
275,
1004,
14,
1294,
342,
267,
862,
26,
288,
372,
1109,
8,
4504,
59,
19,
566,
267,
871,
1722,
26,
288,
986,
199,
199,
533,
15227,
10438,
26,
272,
1449,
3498,
5845,
10595,
339,
347,
2112,
8,
277,
12,
5845,
304,
267,
1449,
3498,
282,
769,
402,
5845,
10595,
267,
870,
8,
1609,
8,
1838,
8,
3356,
430,
1182,
822,
8,
3356,
430,
421,
199,
533,
21369,
707,
5229,
8,
5229,
304,
339,
347,
664,
63,
2087,
8,
277,
304,
267,
1798,
275,
27615,
8,
288,
1369,
534,
4003,
2112,
1072,
436,
9531,
5845,
2659,
267,
1798,
14,
525,
63,
2094,
8,
288,
2475,
67,
297,
2850,
3271,
13,
835,
297,
730,
29,
442,
12,
849,
29,
21,
12,
288,
1720,
534,
1955,
402,
5845,
370,
9531,
358,
267,
372,
1798,
339,
347,
2446,
8,
277,
12,
1249,
304,
267,
4438,
275,
664,
63,
1430,
63,
3813,
342,
267,
4438,
14,
1065,
63,
8111,
63,
4883,
8,
277,
423,
973,
8,
3813,
12,
1249,
430,
267,
4438,
14,
1600,
342,
339,
5316,
347,
485,
973,
8,
277,
12,
4438,
12,
1249,
304,
267,
4126,
275,
10703,
8,
3813,
29,
3813,
9,
267,
1798,
275,
5817,
2959,
2842,
8,
3813,
12,
4126,
9,
267,
14910,
275,
3626,
3283,
8,
1825,
12,
1249,
14,
3271,
63,
835,
9,
267,
2120,
275,
4438,
14,
981,
63,
1765,
8,
10946,
8,
8176,
10438,
4059,
267,
5517,
1798,
8,
3498,
2842,
1012,
267,
5517,
2120,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2884,
275,
21369,
707,
5229,
342,
272,
2884,
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,
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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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
] |
bb111189/Arky2
|
boilerplate/external/pycountry/__init__.py
|
1
|
3459
|
# vim:fileencoding=utf-8
# Copyright (c) 2008-2011 gocept gmbh & co. kg
# See also LICENSE.txt
# $Id$
"""pycountry"""
import os.path
import pycountry.db
LOCALES_DIR = os.path.join(os.path.dirname(__file__), 'locales')
DATABASE_DIR = os.path.join(os.path.dirname(__file__), 'databases')
class Countries(pycountry.db.Database):
"""Provides access to an ISO 3166 database (Countries)."""
field_map = dict(alpha_2_code='alpha2',
alpha_3_code='alpha3',
numeric_code='numeric',
name='name',
official_name='official_name',
common_name='common_name')
data_class_name = 'Country'
xml_tag = 'iso_3166_entry'
class Scripts(pycountry.db.Database):
"""Providess access to an ISO 15924 database (Scripts)."""
field_map = dict(alpha_4_code='alpha4',
numeric_code='numeric',
name='name')
data_class_name = 'Script'
xml_tag = 'iso_15924_entry'
class Currencies(pycountry.db.Database):
"""Providess access to an ISO 4217 database (Currencies)."""
field_map = dict(letter_code='letter',
numeric_code='numeric',
currency_name='name')
data_class_name = 'Currency'
xml_tag = 'iso_4217_entry'
class Languages(pycountry.db.Database):
"""Providess access to an ISO 639-1/2 database (Languages)."""
field_map = dict(iso_639_2B_code='bibliographic',
iso_639_2T_code='terminology',
iso_639_1_code='alpha2',
common_name='common_name',
name='name')
data_class_name = 'Language'
xml_tag = 'iso_639_entry'
class Subdivision(pycountry.db.Data):
parent_code = None
def __init__(self, element, **kw):
super(Subdivision, self).__init__(element, **kw)
self.type = element.parentNode.attributes.get('type').value
self.country_code = self.code.split('-')[0]
if self.parent_code is not None:
self.parent_code = '%s-%s' % (self.country_code, self.parent_code)
@property
def country(self):
return countries.get(alpha2=self.country_code)
@property
def parent(self):
return subdivisions.get(code=self.parent_code)
class Subdivisions(pycountry.db.Database):
# Note: subdivisions can be hierarchical to other subdivisions. The
# parent_code attribute is related to other subdivisons, *not*
# the country!
xml_tag = 'iso_3166_2_entry'
data_class_base = Subdivision
data_class_name = 'Subdivision'
field_map = dict(code='code',
name='name',
parent='parent_code')
no_index = ['name', 'parent_code']
def __init__(self, *args, **kw):
super(Subdivisions, self).__init__(*args, **kw)
# Add index for the country code.
self.indices['country_code'] = {}
for subdivision in self:
divs = self.indices['country_code'].setdefault(
subdivision.country_code, set())
divs.add(subdivision)
countries = Countries(os.path.join(DATABASE_DIR, 'iso3166.xml'))
scripts = Scripts(os.path.join(DATABASE_DIR, 'iso15924.xml'))
currencies = Currencies(os.path.join(DATABASE_DIR, 'iso4217.xml'))
languages = Languages(os.path.join(DATABASE_DIR, 'iso639.xml'))
subdivisions = Subdivisions(os.path.join(DATABASE_DIR, 'iso3166_2.xml'))
|
lgpl-3.0
|
[
3,
6695,
26,
493,
2991,
29,
1624,
13,
24,
199,
3,
1898,
334,
67,
9,
9079,
13,
8128,
2621,
716,
486,
887,
72,
1253,
512,
14,
31746,
199,
3,
1666,
2597,
5113,
14,
2424,
199,
3,
2672,
1304,
4,
199,
624,
647,
6063,
624,
199,
199,
646,
747,
14,
515,
199,
199,
646,
1134,
6063,
14,
697,
421,
199,
7486,
654,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
24763,
358,
199,
17873,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
17439,
358,
421,
199,
533,
1849,
324,
6264,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
17473,
2879,
370,
376,
9055,
650,
10642,
3050,
334,
24532,
6264,
10477,
339,
901,
63,
1130,
275,
1211,
8,
4468,
63,
18,
63,
600,
534,
4468,
18,
297,
2151,
5131,
63,
19,
63,
600,
534,
4468,
19,
297,
2151,
8950,
63,
600,
534,
6677,
297,
2151,
536,
534,
354,
297,
2151,
25410,
63,
354,
534,
29260,
63,
354,
297,
2151,
2863,
63,
354,
534,
2330,
63,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
17393,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
19,
10642,
63,
2373,
7,
421,
199,
533,
14914,
83,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
25107,
385,
2879,
370,
376,
9055,
413,
1427,
1194,
3050,
334,
25681,
10477,
339,
901,
63,
1130,
275,
1211,
8,
4468,
63,
20,
63,
600,
534,
4468,
20,
297,
2151,
8950,
63,
600,
534,
6677,
297,
2151,
536,
534,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
5229,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
9327,
1194,
63,
2373,
7,
421,
199,
533,
7319,
828,
2578,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
25107,
385,
2879,
370,
376,
9055,
5685,
1196,
3050,
334,
3864,
828,
2578,
10477,
339,
901,
63,
1130,
275,
1211,
8,
9269,
63,
600,
534,
9269,
297,
2151,
8950,
63,
600,
534,
6677,
297,
2151,
9952,
63,
354,
534,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
19567,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
2260,
1196,
63,
2373,
7,
421,
199,
533,
8466,
83,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
25107,
385,
2879,
370,
376,
9055,
1227,
1355,
13,
17,
15,
18,
3050,
334,
8493,
83,
10477,
339,
901,
63,
1130,
275,
1211,
8,
4595,
63,
26723,
63,
18,
34,
63,
600,
534,
30892,
297,
2151,
11601,
63,
26723,
63,
18,
52,
63,
600,
534,
2704,
7085,
297,
2151,
11601,
63,
26723,
63,
17,
63,
600,
534,
4468,
18,
297,
2151,
2863,
63,
354,
534,
2330,
63,
354,
297,
2151,
536,
534,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
8493,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
26723,
63,
2373,
7,
421,
199,
533,
4804,
25035,
8,
647,
6063,
14,
697,
14,
1451,
304,
339,
1676,
63,
600,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1819,
12,
1011,
829,
304,
267,
1613,
8,
2610,
25035,
12,
291,
2843,
826,
721,
2108,
12,
1011,
829,
9,
267,
291,
14,
466,
275,
1819,
14,
24899,
14,
2987,
14,
362,
360,
466,
1959,
585,
267,
291,
14,
6063,
63,
600,
275,
291,
14,
600,
14,
1294,
3654,
5832,
16,
61,
267,
340,
291,
14,
1708,
63,
600,
365,
440,
488,
26,
288,
291,
14,
1708,
63,
600,
275,
1543,
83,
3295,
83,
7,
450,
334,
277,
14,
6063,
63,
600,
12,
291,
14,
1708,
63,
600,
9,
339,
768,
1829,
272,
347,
9023,
8,
277,
304,
267,
372,
26013,
14,
362,
8,
4468,
18,
29,
277,
14,
6063,
63,
600,
9,
339,
768,
1829,
272,
347,
1676,
8,
277,
304,
267,
372,
1007,
328,
13193,
14,
362,
8,
600,
29,
277,
14,
1708,
63,
600,
9,
421,
199,
533,
4804,
328,
13193,
8,
647,
6063,
14,
697,
14,
7243,
304,
339,
327,
3390,
26,
1007,
328,
13193,
883,
506,
24787,
370,
1163,
1007,
328,
13193,
14,
710,
272,
327,
1676,
63,
600,
2225,
365,
4048,
370,
1163,
1007,
3015,
374,
4654,
12,
627,
1397,
10,
272,
327,
314,
9023,
1,
339,
2748,
63,
1450,
275,
283,
4595,
63,
19,
10642,
63,
18,
63,
2373,
7,
272,
666,
63,
533,
63,
1095,
275,
4804,
25035,
272,
666,
63,
533,
63,
354,
275,
283,
2610,
25035,
7,
272,
901,
63,
1130,
275,
1211,
8,
600,
534,
600,
297,
2151,
536,
534,
354,
297,
2151,
1676,
534,
1708,
63,
600,
358,
272,
949,
63,
1080,
275,
788,
354,
297,
283,
1708,
63,
600,
418,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
1613,
8,
2610,
328,
13193,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
398,
327,
2654,
1478,
367,
314,
9023,
1233,
14,
267,
291,
14,
4108,
459,
6063,
63,
600,
418,
275,
1052,
267,
367,
1007,
25035,
315,
291,
26,
288,
487,
3122,
275,
291,
14,
4108,
459,
6063,
63,
600,
2278,
5486,
8,
355,
1007,
25035,
14,
6063,
63,
600,
12,
663,
1012,
288,
487,
3122,
14,
525,
8,
954,
25035,
9,
421,
199,
23598,
275,
1849,
324,
6264,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
19,
10642,
14,
1652,
1333,
199,
6429,
275,
14914,
83,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
9327,
1194,
14,
1652,
1333,
199,
895,
828,
2578,
275,
7319,
828,
2578,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
2260,
1196,
14,
1652,
1333,
199,
13209,
275,
8466,
83,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
26723,
14,
1652,
1333,
199,
954,
328,
13193,
275,
4804,
328,
13193,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
19,
10642,
63,
18,
14,
1652,
1333,
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
] |
[
6695,
26,
493,
2991,
29,
1624,
13,
24,
199,
3,
1898,
334,
67,
9,
9079,
13,
8128,
2621,
716,
486,
887,
72,
1253,
512,
14,
31746,
199,
3,
1666,
2597,
5113,
14,
2424,
199,
3,
2672,
1304,
4,
199,
624,
647,
6063,
624,
199,
199,
646,
747,
14,
515,
199,
199,
646,
1134,
6063,
14,
697,
421,
199,
7486,
654,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
24763,
358,
199,
17873,
63,
3022,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
17439,
358,
421,
199,
533,
1849,
324,
6264,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
17473,
2879,
370,
376,
9055,
650,
10642,
3050,
334,
24532,
6264,
10477,
339,
901,
63,
1130,
275,
1211,
8,
4468,
63,
18,
63,
600,
534,
4468,
18,
297,
2151,
5131,
63,
19,
63,
600,
534,
4468,
19,
297,
2151,
8950,
63,
600,
534,
6677,
297,
2151,
536,
534,
354,
297,
2151,
25410,
63,
354,
534,
29260,
63,
354,
297,
2151,
2863,
63,
354,
534,
2330,
63,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
17393,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
19,
10642,
63,
2373,
7,
421,
199,
533,
14914,
83,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
25107,
385,
2879,
370,
376,
9055,
413,
1427,
1194,
3050,
334,
25681,
10477,
339,
901,
63,
1130,
275,
1211,
8,
4468,
63,
20,
63,
600,
534,
4468,
20,
297,
2151,
8950,
63,
600,
534,
6677,
297,
2151,
536,
534,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
5229,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
9327,
1194,
63,
2373,
7,
421,
199,
533,
7319,
828,
2578,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
25107,
385,
2879,
370,
376,
9055,
5685,
1196,
3050,
334,
3864,
828,
2578,
10477,
339,
901,
63,
1130,
275,
1211,
8,
9269,
63,
600,
534,
9269,
297,
2151,
8950,
63,
600,
534,
6677,
297,
2151,
9952,
63,
354,
534,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
19567,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
2260,
1196,
63,
2373,
7,
421,
199,
533,
8466,
83,
8,
647,
6063,
14,
697,
14,
7243,
304,
272,
408,
25107,
385,
2879,
370,
376,
9055,
1227,
1355,
13,
17,
15,
18,
3050,
334,
8493,
83,
10477,
339,
901,
63,
1130,
275,
1211,
8,
4595,
63,
26723,
63,
18,
34,
63,
600,
534,
30892,
297,
2151,
11601,
63,
26723,
63,
18,
52,
63,
600,
534,
2704,
7085,
297,
2151,
11601,
63,
26723,
63,
17,
63,
600,
534,
4468,
18,
297,
2151,
2863,
63,
354,
534,
2330,
63,
354,
297,
2151,
536,
534,
354,
358,
272,
666,
63,
533,
63,
354,
275,
283,
8493,
7,
272,
2748,
63,
1450,
275,
283,
4595,
63,
26723,
63,
2373,
7,
421,
199,
533,
4804,
25035,
8,
647,
6063,
14,
697,
14,
1451,
304,
339,
1676,
63,
600,
275,
488,
339,
347,
636,
826,
721,
277,
12,
1819,
12,
1011,
829,
304,
267,
1613,
8,
2610,
25035,
12,
291,
2843,
826,
721,
2108,
12,
1011,
829,
9,
267,
291,
14,
466,
275,
1819,
14,
24899,
14,
2987,
14,
362,
360,
466,
1959,
585,
267,
291,
14,
6063,
63,
600,
275,
291,
14,
600,
14,
1294,
3654,
5832,
16,
61,
267,
340,
291,
14,
1708,
63,
600,
365,
440,
488,
26,
288,
291,
14,
1708,
63,
600,
275,
1543,
83,
3295,
83,
7,
450,
334,
277,
14,
6063,
63,
600,
12,
291,
14,
1708,
63,
600,
9,
339,
768,
1829,
272,
347,
9023,
8,
277,
304,
267,
372,
26013,
14,
362,
8,
4468,
18,
29,
277,
14,
6063,
63,
600,
9,
339,
768,
1829,
272,
347,
1676,
8,
277,
304,
267,
372,
1007,
328,
13193,
14,
362,
8,
600,
29,
277,
14,
1708,
63,
600,
9,
421,
199,
533,
4804,
328,
13193,
8,
647,
6063,
14,
697,
14,
7243,
304,
339,
327,
3390,
26,
1007,
328,
13193,
883,
506,
24787,
370,
1163,
1007,
328,
13193,
14,
710,
272,
327,
1676,
63,
600,
2225,
365,
4048,
370,
1163,
1007,
3015,
374,
4654,
12,
627,
1397,
10,
272,
327,
314,
9023,
1,
339,
2748,
63,
1450,
275,
283,
4595,
63,
19,
10642,
63,
18,
63,
2373,
7,
272,
666,
63,
533,
63,
1095,
275,
4804,
25035,
272,
666,
63,
533,
63,
354,
275,
283,
2610,
25035,
7,
272,
901,
63,
1130,
275,
1211,
8,
600,
534,
600,
297,
2151,
536,
534,
354,
297,
2151,
1676,
534,
1708,
63,
600,
358,
272,
949,
63,
1080,
275,
788,
354,
297,
283,
1708,
63,
600,
418,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
1613,
8,
2610,
328,
13193,
12,
291,
2843,
826,
9308,
589,
12,
1011,
829,
9,
398,
327,
2654,
1478,
367,
314,
9023,
1233,
14,
267,
291,
14,
4108,
459,
6063,
63,
600,
418,
275,
1052,
267,
367,
1007,
25035,
315,
291,
26,
288,
487,
3122,
275,
291,
14,
4108,
459,
6063,
63,
600,
2278,
5486,
8,
355,
1007,
25035,
14,
6063,
63,
600,
12,
663,
1012,
288,
487,
3122,
14,
525,
8,
954,
25035,
9,
421,
199,
23598,
275,
1849,
324,
6264,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
19,
10642,
14,
1652,
1333,
199,
6429,
275,
14914,
83,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
9327,
1194,
14,
1652,
1333,
199,
895,
828,
2578,
275,
7319,
828,
2578,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
2260,
1196,
14,
1652,
1333,
199,
13209,
275,
8466,
83,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
26723,
14,
1652,
1333,
199,
954,
328,
13193,
275,
4804,
328,
13193,
8,
736,
14,
515,
14,
904,
8,
17873,
63,
3022,
12,
283,
4595,
19,
10642,
63,
18,
14,
1652,
1333,
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,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
malept/youtube-dl
|
youtube_dl/extractor/mangomolo.py
|
43
|
1834
|
# coding: utf-8
from __future__ import unicode_literals
import base64
from .common import InfoExtractor
from ..compat import compat_urllib_parse_unquote
from ..utils import (
int_or_none,
)
class MangomoloBaseIE(InfoExtractor):
def _get_real_id(self, page_id):
return page_id
def _real_extract(self, url):
page_id = self._get_real_id(self._match_id(url))
webpage = self._download_webpage(url, page_id)
hidden_inputs = self._hidden_inputs(webpage)
m3u8_entry_protocol = 'm3u8' if self._IS_LIVE else 'm3u8_native'
format_url = self._html_search_regex(
[
r'file\s*:\s*"(https?://[^"]+?/playlist.m3u8)',
r'<a[^>]+href="(rtsp://[^"]+)"'
], webpage, 'format url')
formats = self._extract_wowza_formats(
format_url, page_id, m3u8_entry_protocol, ['smil'])
self._sort_formats(formats)
return {
'id': page_id,
'title': self._live_title(page_id) if self._IS_LIVE else page_id,
'uploader_id': hidden_inputs.get('userid'),
'duration': int_or_none(hidden_inputs.get('duration')),
'is_live': self._IS_LIVE,
'formats': formats,
}
class MangomoloVideoIE(MangomoloBaseIE):
IE_NAME = 'mangomolo:video'
_VALID_URL = r'https?://admin\.mangomolo\.com/analytics/index\.php/customers/embed/video\?.*?\bid=(?P<id>\d+)'
_IS_LIVE = False
class MangomoloLiveIE(MangomoloBaseIE):
IE_NAME = 'mangomolo:live'
_VALID_URL = r'https?://admin\.mangomolo\.com/analytics/index\.php/customers/embed/index\?.*?\bchannelid=(?P<id>(?:[A-Za-z0-9+/=]|%2B|%2F|%3D)+)'
_IS_LIVE = True
def _get_real_id(self, page_id):
return base64.b64decode(compat_urllib_parse_unquote(page_id).encode()).decode()
|
unlicense
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1300,
772,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
8434,
63,
4078,
63,
1122,
63,
12240,
199,
504,
2508,
1208,
492,
334,
272,
1109,
63,
269,
63,
3592,
12,
199,
9,
421,
199,
533,
603,
17771,
573,
320,
1563,
4332,
8,
18283,
304,
272,
347,
485,
362,
63,
3093,
63,
344,
8,
277,
12,
2034,
63,
344,
304,
267,
372,
2034,
63,
344,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
2034,
63,
344,
275,
291,
423,
362,
63,
3093,
63,
344,
8,
277,
423,
1431,
63,
344,
8,
633,
430,
267,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
2034,
63,
344,
9,
267,
8752,
63,
3711,
275,
291,
423,
5642,
63,
3711,
8,
12022,
9,
267,
333,
19,
85,
24,
63,
2373,
63,
3922,
275,
283,
77,
19,
85,
24,
7,
340,
291,
423,
1311,
63,
31541,
587,
283,
77,
19,
85,
24,
63,
6106,
7,
398,
1475,
63,
633,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
359,
355,
519,
7,
493,
60,
83,
10,
3427,
83,
12469,
8,
2859,
14144,
25153,
23778,
15,
10411,
14,
77,
19,
85,
24,
3196,
355,
519,
7601,
65,
25524,
6399,
628,
8,
2591,
681,
921,
25153,
20415,
7,
288,
2156,
9248,
12,
283,
908,
1166,
358,
267,
6752,
275,
291,
423,
5005,
63,
87,
583,
8076,
63,
6321,
8,
288,
1475,
63,
633,
12,
2034,
63,
344,
12,
333,
19,
85,
24,
63,
2373,
63,
3922,
12,
788,
3300,
382,
1105,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
372,
469,
288,
283,
344,
356,
2034,
63,
344,
12,
288,
283,
1213,
356,
291,
423,
6442,
63,
1213,
8,
1606,
63,
344,
9,
340,
291,
423,
1311,
63,
31541,
587,
2034,
63,
344,
12,
288,
283,
13671,
63,
344,
356,
8752,
63,
3711,
14,
362,
360,
19737,
659,
288,
283,
5553,
356,
1109,
63,
269,
63,
3592,
8,
5642,
63,
3711,
14,
362,
360,
5553,
3855,
288,
283,
374,
63,
6442,
356,
291,
423,
1311,
63,
31541,
12,
288,
283,
6321,
356,
6752,
12,
267,
789,
421,
199,
533,
603,
17771,
573,
320,
9166,
4332,
8,
45,
17771,
573,
320,
1563,
4332,
304,
272,
15292,
63,
2339,
275,
283,
77,
17771,
573,
320,
26,
3722,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
14144,
2113,
4537,
77,
17771,
573,
320,
4537,
957,
15,
20211,
15,
1080,
4537,
8624,
15,
67,
28078,
15,
6427,
15,
3722,
29635,
21040,
17949,
29,
2229,
48,
28,
344,
3072,
68,
29600,
272,
485,
1311,
63,
31541,
275,
756,
421,
199,
533,
603,
17771,
573,
320,
17458,
4332,
8,
45,
17771,
573,
320,
1563,
4332,
304,
272,
15292,
63,
2339,
275,
283,
77,
17771,
573,
320,
26,
6442,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
14144,
2113,
4537,
77,
17771,
573,
320,
4537,
957,
15,
20211,
15,
1080,
4537,
8624,
15,
67,
28078,
15,
6427,
15,
1080,
29635,
21040,
66,
11984,
685,
7401,
29,
2229,
48,
28,
344,
30,
25060,
33,
13,
13163,
13,
90,
16,
13,
25,
19616,
29,
11752,
5,
18,
34,
15287,
18,
38,
15287,
19,
36,
6393,
3171,
272,
485,
1311,
63,
31541,
275,
715,
339,
347,
485,
362,
63,
3093,
63,
344,
8,
277,
12,
2034,
63,
344,
304,
267,
372,
1300,
772,
14,
66,
772,
2708,
8,
5819,
63,
4078,
63,
1122,
63,
12240,
8,
1606,
63,
344,
680,
2143,
8801,
2708,
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
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
1300,
772,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
8434,
63,
4078,
63,
1122,
63,
12240,
199,
504,
2508,
1208,
492,
334,
272,
1109,
63,
269,
63,
3592,
12,
199,
9,
421,
199,
533,
603,
17771,
573,
320,
1563,
4332,
8,
18283,
304,
272,
347,
485,
362,
63,
3093,
63,
344,
8,
277,
12,
2034,
63,
344,
304,
267,
372,
2034,
63,
344,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
2034,
63,
344,
275,
291,
423,
362,
63,
3093,
63,
344,
8,
277,
423,
1431,
63,
344,
8,
633,
430,
267,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
2034,
63,
344,
9,
267,
8752,
63,
3711,
275,
291,
423,
5642,
63,
3711,
8,
12022,
9,
267,
333,
19,
85,
24,
63,
2373,
63,
3922,
275,
283,
77,
19,
85,
24,
7,
340,
291,
423,
1311,
63,
31541,
587,
283,
77,
19,
85,
24,
63,
6106,
7,
398,
1475,
63,
633,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
359,
355,
519,
7,
493,
60,
83,
10,
3427,
83,
12469,
8,
2859,
14144,
25153,
23778,
15,
10411,
14,
77,
19,
85,
24,
3196,
355,
519,
7601,
65,
25524,
6399,
628,
8,
2591,
681,
921,
25153,
20415,
7,
288,
2156,
9248,
12,
283,
908,
1166,
358,
267,
6752,
275,
291,
423,
5005,
63,
87,
583,
8076,
63,
6321,
8,
288,
1475,
63,
633,
12,
2034,
63,
344,
12,
333,
19,
85,
24,
63,
2373,
63,
3922,
12,
788,
3300,
382,
1105,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
372,
469,
288,
283,
344,
356,
2034,
63,
344,
12,
288,
283,
1213,
356,
291,
423,
6442,
63,
1213,
8,
1606,
63,
344,
9,
340,
291,
423,
1311,
63,
31541,
587,
2034,
63,
344,
12,
288,
283,
13671,
63,
344,
356,
8752,
63,
3711,
14,
362,
360,
19737,
659,
288,
283,
5553,
356,
1109,
63,
269,
63,
3592,
8,
5642,
63,
3711,
14,
362,
360,
5553,
3855,
288,
283,
374,
63,
6442,
356,
291,
423,
1311,
63,
31541,
12,
288,
283,
6321,
356,
6752,
12,
267,
789,
421,
199,
533,
603,
17771,
573,
320,
9166,
4332,
8,
45,
17771,
573,
320,
1563,
4332,
304,
272,
15292,
63,
2339,
275,
283,
77,
17771,
573,
320,
26,
3722,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
14144,
2113,
4537,
77,
17771,
573,
320,
4537,
957,
15,
20211,
15,
1080,
4537,
8624,
15,
67,
28078,
15,
6427,
15,
3722,
29635,
21040,
17949,
29,
2229,
48,
28,
344,
3072,
68,
29600,
272,
485,
1311,
63,
31541,
275,
756,
421,
199,
533,
603,
17771,
573,
320,
17458,
4332,
8,
45,
17771,
573,
320,
1563,
4332,
304,
272,
15292,
63,
2339,
275,
283,
77,
17771,
573,
320,
26,
6442,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
2859,
14144,
2113,
4537,
77,
17771,
573,
320,
4537,
957,
15,
20211,
15,
1080,
4537,
8624,
15,
67,
28078,
15,
6427,
15,
1080,
29635,
21040,
66,
11984,
685,
7401,
29,
2229,
48,
28,
344,
30,
25060,
33,
13,
13163,
13,
90,
16,
13,
25,
19616,
29,
11752,
5,
18,
34,
15287,
18,
38,
15287,
19,
36,
6393,
3171,
272,
485,
1311,
63,
31541,
275,
715,
339,
347,
485,
362,
63,
3093,
63,
344,
8,
277,
12,
2034,
63,
344,
304,
267,
372,
1300,
772,
14,
66,
772,
2708,
8,
5819,
63,
4078,
63,
1122,
63,
12240,
8,
1606,
63,
344,
680,
2143,
8801,
2708,
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,
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,
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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
] |
abilian/abilian-core
|
src/abilian/core/models/tests/test_blob.py
|
1
|
3462
|
""""""
import uuid
from io import StringIO
from flask import Flask
from abilian.core.models.blob import Blob
from abilian.core.sqlalchemy import SQLAlchemy
from abilian.services import repository_service as repository
from abilian.services import session_repository_service as session_repository
#
# Unit tests
#
def test_auto_uuid() -> None:
blob = Blob()
assert blob.uuid is not None
assert isinstance(blob.uuid, uuid.UUID)
# test provided uuid is not replaced by a new one
u = uuid.UUID("4f80f02f-52e3-4fe2-b9f2-2c3e99449ce9")
blob = Blob(uuid=u)
assert isinstance(blob.uuid, uuid.UUID)
assert blob.uuid, u
def test_meta() -> None:
blob = Blob()
assert blob.meta == {}
#
# Integration tests
#
def test_md5(app: Flask, db: SQLAlchemy) -> None:
blob = Blob("test md5")
assert "md5" in blob.meta
assert blob.meta["md5"] == "0e4e3b2681e8931c067a23c583c878d5"
def test_size(app: Flask, db: SQLAlchemy) -> None:
blob = Blob("test")
assert blob.size == 4
def test_filename(app: Flask, db: SQLAlchemy) -> None:
content = StringIO("test")
content.filename = "test.txt"
blob = Blob(content)
assert "filename" in blob.meta
assert blob.meta["filename"] == "test.txt"
def test_mimetype(app: Flask, db: SQLAlchemy) -> None:
content = StringIO("test")
content.content_type = "text/plain"
blob = Blob(content)
assert "mimetype" in blob.meta
assert blob.meta["mimetype"] == "text/plain"
def test_nonzero(app: Flask, db: SQLAlchemy) -> None:
blob = Blob("test md5")
assert bool(blob)
# change uuid: repository will return None for blob.file
blob.uuid = uuid.uuid4()
assert not bool(blob)
# def test_query(app, db):
# session = db.session
# content = b"content"
# b = Blob(content)
# session.add(b)
# session.flush()
#
# assert Blob.query.by_uuid(b.uuid) is b
# assert Blob.query.by_uuid(str(b.uuid)) is b
#
# u = uuid.uuid4()
# assert Blob.query.by_uuid(u) is None
def test_value(app: Flask, db: SQLAlchemy) -> None:
session = db.session
content = b"content"
blob = Blob(content)
tr = session.begin(nested=True)
session.add(blob)
tr.commit()
assert repository.get(blob.uuid) is None
assert session_repository.get(blob, blob.uuid).open("rb").read() == content
assert blob.value == content
session.commit()
assert repository.get(blob.uuid).open("rb").read() == content
assert blob.value == content
session.begin(nested=True) # match session.rollback
with session.begin(nested=True):
session.delete(blob)
# object marked for deletion, but instance attribute should still be
# readable
fd = session_repository.get(blob, blob.uuid).open("rb")
assert fd.read() == content
# commit in transaction: session_repository has no content, 'physical'
# repository still has content
assert session_repository.get(blob, blob.uuid) is None
assert repository.get(blob.uuid).open("rb").read() == content
# rollback: session_repository has content again
session.rollback()
assert session_repository.get(blob, blob.uuid).open("rb").read() == content
session.delete(blob)
session.flush()
assert session_repository.get(blob, blob.uuid) is None
assert repository.get(blob.uuid).open("rb").read() == content
session.commit()
assert repository.get(blob.uuid) is None
|
lgpl-2.1
|
[
341,
341,
341,
199,
646,
5377,
199,
504,
5890,
492,
5228,
199,
199,
504,
7209,
492,
16704,
199,
199,
504,
2236,
1638,
290,
14,
1018,
14,
992,
14,
6582,
492,
31745,
199,
504,
2236,
1638,
290,
14,
1018,
14,
14536,
492,
14303,
199,
504,
2236,
1638,
290,
14,
5950,
492,
7611,
63,
1364,
465,
7611,
199,
504,
2236,
1638,
290,
14,
5950,
492,
2351,
63,
8421,
63,
1364,
465,
2351,
63,
8421,
421,
199,
3,
199,
3,
12008,
2295,
199,
3,
199,
318,
511,
63,
2495,
63,
2580,
342,
1035,
488,
26,
272,
9182,
275,
31745,
342,
272,
702,
9182,
14,
2580,
365,
440,
488,
272,
702,
1228,
8,
6582,
14,
2580,
12,
5377,
14,
8757,
9,
339,
327,
511,
2741,
5377,
365,
440,
8717,
701,
282,
892,
1373,
272,
399,
275,
5377,
14,
8757,
480,
20,
70,
1257,
70,
996,
70,
13,
2528,
69,
19,
13,
20,
771,
18,
13,
66,
25,
70,
18,
13,
18,
67,
19,
69,
1020,
19738,
301,
25,
531,
272,
9182,
275,
31745,
8,
2580,
29,
85,
9,
272,
702,
1228,
8,
6582,
14,
2580,
12,
5377,
14,
8757,
9,
272,
702,
9182,
14,
2580,
12,
399,
421,
199,
318,
511,
63,
2024,
342,
1035,
488,
26,
272,
9182,
275,
31745,
342,
272,
702,
9182,
14,
2024,
508,
1052,
421,
199,
3,
199,
3,
27561,
2295,
199,
3,
199,
318,
511,
63,
1064,
21,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
9182,
275,
31745,
480,
396,
6128,
21,
531,
272,
702,
298,
1064,
21,
2,
315,
9182,
14,
2024,
272,
702,
9182,
14,
2024,
905,
1064,
21,
937,
508,
298,
16,
69,
20,
69,
19,
66,
1479,
2835,
69,
1407,
2192,
67,
19338,
65,
1789,
67,
16793,
67,
14681,
68,
21,
2,
421,
199,
318,
511,
63,
890,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
9182,
275,
31745,
480,
396,
531,
272,
702,
9182,
14,
890,
508,
841,
421,
199,
318,
511,
63,
1501,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
1564,
275,
5228,
480,
396,
531,
272,
1564,
14,
1501,
275,
298,
396,
14,
2424,
2,
272,
9182,
275,
31745,
8,
1317,
9,
272,
702,
298,
1501,
2,
315,
9182,
14,
2024,
272,
702,
9182,
14,
2024,
905,
1501,
937,
508,
298,
396,
14,
2424,
2,
421,
199,
318,
511,
63,
17450,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
1564,
275,
5228,
480,
396,
531,
272,
1564,
14,
1317,
63,
466,
275,
298,
505,
15,
6104,
2,
272,
9182,
275,
31745,
8,
1317,
9,
272,
702,
298,
17450,
2,
315,
9182,
14,
2024,
272,
702,
9182,
14,
2024,
905,
17450,
937,
508,
298,
505,
15,
6104,
2,
421,
199,
318,
511,
63,
10262,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
9182,
275,
31745,
480,
396,
6128,
21,
531,
272,
702,
2155,
8,
6582,
9,
339,
327,
1570,
5377,
26,
7611,
911,
372,
488,
367,
9182,
14,
493,
272,
9182,
14,
2580,
275,
5377,
14,
2580,
20,
342,
272,
702,
440,
2155,
8,
6582,
9,
421,
199,
3,
347,
511,
63,
1131,
8,
571,
12,
1592,
304,
199,
3,
258,
2351,
275,
1592,
14,
1730,
199,
3,
258,
1564,
275,
330,
2,
1317,
2,
199,
3,
258,
330,
275,
31745,
8,
1317,
9,
199,
3,
258,
2351,
14,
525,
8,
66,
9,
199,
3,
258,
2351,
14,
4939,
342,
199,
3,
199,
3,
258,
702,
31745,
14,
1131,
14,
991,
63,
2580,
8,
66,
14,
2580,
9,
365,
330,
199,
3,
258,
702,
31745,
14,
1131,
14,
991,
63,
2580,
8,
495,
8,
66,
14,
2580,
430,
365,
330,
199,
3,
199,
3,
258,
399,
275,
5377,
14,
2580,
20,
342,
199,
3,
258,
702,
31745,
14,
1131,
14,
991,
63,
2580,
8,
85,
9,
365,
488,
421,
199,
318,
511,
63,
585,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
2351,
275,
1592,
14,
1730,
272,
1564,
275,
330,
2,
1317,
2,
272,
9182,
275,
31745,
8,
1317,
9,
339,
5651,
275,
2351,
14,
5037,
8,
6376,
29,
549,
9,
272,
2351,
14,
525,
8,
6582,
9,
272,
5651,
14,
3543,
342,
339,
702,
7611,
14,
362,
8,
6582,
14,
2580,
9,
365,
488,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
272,
702,
9182,
14,
585,
508,
1564,
339,
2351,
14,
3543,
342,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
272,
702,
9182,
14,
585,
508,
1564,
339,
2351,
14,
5037,
8,
6376,
29,
549,
9,
221,
327,
1336,
2351,
14,
10437,
339,
543,
2351,
14,
5037,
8,
6376,
29,
549,
304,
267,
2351,
14,
1807,
8,
6582,
9,
267,
327,
909,
11584,
367,
14068,
12,
1325,
1256,
2225,
1077,
5139,
506,
267,
327,
12701,
267,
6111,
275,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
680,
1490,
480,
4848,
531,
267,
702,
6111,
14,
739,
342,
508,
1564,
339,
327,
5532,
315,
6008,
26,
2351,
63,
8421,
965,
949,
1564,
12,
283,
15020,
7,
272,
327,
7611,
5139,
965,
1564,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
9,
365,
488,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
339,
327,
16475,
26,
2351,
63,
8421,
965,
1564,
4020,
272,
2351,
14,
10437,
342,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
339,
2351,
14,
1807,
8,
6582,
9,
272,
2351,
14,
4939,
342,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
9,
365,
488,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
339,
2351,
14,
3543,
342,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
9,
365,
488,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
341,
341,
199,
646,
5377,
199,
504,
5890,
492,
5228,
199,
199,
504,
7209,
492,
16704,
199,
199,
504,
2236,
1638,
290,
14,
1018,
14,
992,
14,
6582,
492,
31745,
199,
504,
2236,
1638,
290,
14,
1018,
14,
14536,
492,
14303,
199,
504,
2236,
1638,
290,
14,
5950,
492,
7611,
63,
1364,
465,
7611,
199,
504,
2236,
1638,
290,
14,
5950,
492,
2351,
63,
8421,
63,
1364,
465,
2351,
63,
8421,
421,
199,
3,
199,
3,
12008,
2295,
199,
3,
199,
318,
511,
63,
2495,
63,
2580,
342,
1035,
488,
26,
272,
9182,
275,
31745,
342,
272,
702,
9182,
14,
2580,
365,
440,
488,
272,
702,
1228,
8,
6582,
14,
2580,
12,
5377,
14,
8757,
9,
339,
327,
511,
2741,
5377,
365,
440,
8717,
701,
282,
892,
1373,
272,
399,
275,
5377,
14,
8757,
480,
20,
70,
1257,
70,
996,
70,
13,
2528,
69,
19,
13,
20,
771,
18,
13,
66,
25,
70,
18,
13,
18,
67,
19,
69,
1020,
19738,
301,
25,
531,
272,
9182,
275,
31745,
8,
2580,
29,
85,
9,
272,
702,
1228,
8,
6582,
14,
2580,
12,
5377,
14,
8757,
9,
272,
702,
9182,
14,
2580,
12,
399,
421,
199,
318,
511,
63,
2024,
342,
1035,
488,
26,
272,
9182,
275,
31745,
342,
272,
702,
9182,
14,
2024,
508,
1052,
421,
199,
3,
199,
3,
27561,
2295,
199,
3,
199,
318,
511,
63,
1064,
21,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
9182,
275,
31745,
480,
396,
6128,
21,
531,
272,
702,
298,
1064,
21,
2,
315,
9182,
14,
2024,
272,
702,
9182,
14,
2024,
905,
1064,
21,
937,
508,
298,
16,
69,
20,
69,
19,
66,
1479,
2835,
69,
1407,
2192,
67,
19338,
65,
1789,
67,
16793,
67,
14681,
68,
21,
2,
421,
199,
318,
511,
63,
890,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
9182,
275,
31745,
480,
396,
531,
272,
702,
9182,
14,
890,
508,
841,
421,
199,
318,
511,
63,
1501,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
1564,
275,
5228,
480,
396,
531,
272,
1564,
14,
1501,
275,
298,
396,
14,
2424,
2,
272,
9182,
275,
31745,
8,
1317,
9,
272,
702,
298,
1501,
2,
315,
9182,
14,
2024,
272,
702,
9182,
14,
2024,
905,
1501,
937,
508,
298,
396,
14,
2424,
2,
421,
199,
318,
511,
63,
17450,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
1564,
275,
5228,
480,
396,
531,
272,
1564,
14,
1317,
63,
466,
275,
298,
505,
15,
6104,
2,
272,
9182,
275,
31745,
8,
1317,
9,
272,
702,
298,
17450,
2,
315,
9182,
14,
2024,
272,
702,
9182,
14,
2024,
905,
17450,
937,
508,
298,
505,
15,
6104,
2,
421,
199,
318,
511,
63,
10262,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
9182,
275,
31745,
480,
396,
6128,
21,
531,
272,
702,
2155,
8,
6582,
9,
339,
327,
1570,
5377,
26,
7611,
911,
372,
488,
367,
9182,
14,
493,
272,
9182,
14,
2580,
275,
5377,
14,
2580,
20,
342,
272,
702,
440,
2155,
8,
6582,
9,
421,
199,
3,
347,
511,
63,
1131,
8,
571,
12,
1592,
304,
199,
3,
258,
2351,
275,
1592,
14,
1730,
199,
3,
258,
1564,
275,
330,
2,
1317,
2,
199,
3,
258,
330,
275,
31745,
8,
1317,
9,
199,
3,
258,
2351,
14,
525,
8,
66,
9,
199,
3,
258,
2351,
14,
4939,
342,
199,
3,
199,
3,
258,
702,
31745,
14,
1131,
14,
991,
63,
2580,
8,
66,
14,
2580,
9,
365,
330,
199,
3,
258,
702,
31745,
14,
1131,
14,
991,
63,
2580,
8,
495,
8,
66,
14,
2580,
430,
365,
330,
199,
3,
199,
3,
258,
399,
275,
5377,
14,
2580,
20,
342,
199,
3,
258,
702,
31745,
14,
1131,
14,
991,
63,
2580,
8,
85,
9,
365,
488,
421,
199,
318,
511,
63,
585,
8,
571,
26,
16704,
12,
1592,
26,
14303,
9,
1035,
488,
26,
272,
2351,
275,
1592,
14,
1730,
272,
1564,
275,
330,
2,
1317,
2,
272,
9182,
275,
31745,
8,
1317,
9,
339,
5651,
275,
2351,
14,
5037,
8,
6376,
29,
549,
9,
272,
2351,
14,
525,
8,
6582,
9,
272,
5651,
14,
3543,
342,
339,
702,
7611,
14,
362,
8,
6582,
14,
2580,
9,
365,
488,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
272,
702,
9182,
14,
585,
508,
1564,
339,
2351,
14,
3543,
342,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
272,
702,
9182,
14,
585,
508,
1564,
339,
2351,
14,
5037,
8,
6376,
29,
549,
9,
221,
327,
1336,
2351,
14,
10437,
339,
543,
2351,
14,
5037,
8,
6376,
29,
549,
304,
267,
2351,
14,
1807,
8,
6582,
9,
267,
327,
909,
11584,
367,
14068,
12,
1325,
1256,
2225,
1077,
5139,
506,
267,
327,
12701,
267,
6111,
275,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
680,
1490,
480,
4848,
531,
267,
702,
6111,
14,
739,
342,
508,
1564,
339,
327,
5532,
315,
6008,
26,
2351,
63,
8421,
965,
949,
1564,
12,
283,
15020,
7,
272,
327,
7611,
5139,
965,
1564,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
9,
365,
488,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
339,
327,
16475,
26,
2351,
63,
8421,
965,
1564,
4020,
272,
2351,
14,
10437,
342,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
339,
2351,
14,
1807,
8,
6582,
9,
272,
2351,
14,
4939,
342,
272,
702,
2351,
63,
8421,
14,
362,
8,
6582,
12,
9182,
14,
2580,
9,
365,
488,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
680,
1490,
480,
4848,
3471,
739,
342,
508,
1564,
339,
2351,
14,
3543,
342,
272,
702,
7611,
14,
362,
8,
6582,
14,
2580,
9,
365,
488,
199,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
Phonemetra/TurboCoin
|
test/functional/rpc_getblockstats.py
|
1
|
6826
|
#!/usr/bin/env python3
# Copyright (c) 2017-2019 TurboCoin
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test getblockstats rpc call
#
from test_framework.test_framework import TurbocoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
)
import json
import os
TESTSDIR = os.path.dirname(os.path.realpath(__file__))
class GetblockstatsTest(TurbocoinTestFramework):
start_height = 101
max_stat_pos = 2
def add_options(self, parser):
parser.add_argument('--gen-test-data', dest='gen_test_data',
default=False, action='store_true',
help='Generate test data')
parser.add_argument('--test-data', dest='test_data',
default='data/rpc_getblockstats.json',
action='store', metavar='FILE',
help='Test data file')
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
def get_stats(self):
return [self.nodes[0].getblockstats(hash_or_height=self.start_height + i) for i in range(self.max_stat_pos+1)]
def generate_test_data(self, filename):
mocktime = 1525107225
self.nodes[0].setmocktime(mocktime)
self.nodes[0].generate(101)
address = self.nodes[0].get_deterministic_priv_key().address
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
self.nodes[0].generate(1)
self.sync_all()
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=False)
self.nodes[0].settxfee(amount=0.003)
self.nodes[0].sendtoaddress(address=address, amount=1, subtractfeefromamount=True)
self.sync_all()
self.nodes[0].generate(1)
self.expected_stats = self.get_stats()
blocks = []
tip = self.nodes[0].getbestblockhash()
blockhash = None
height = 0
while tip != blockhash:
blockhash = self.nodes[0].getblockhash(height)
blocks.append(self.nodes[0].getblock(blockhash, 0))
height += 1
to_dump = {
'blocks': blocks,
'mocktime': int(mocktime),
'stats': self.expected_stats,
}
with open(filename, 'w', encoding="utf8") as f:
json.dump(to_dump, f, sort_keys=True, indent=2)
def load_test_data(self, filename):
with open(filename, 'r', encoding="utf8") as f:
d = json.load(f)
blocks = d['blocks']
mocktime = d['mocktime']
self.expected_stats = d['stats']
# Set the timestamps from the file so that the nodes can get out of Initial Block Download
self.nodes[0].setmocktime(mocktime)
self.sync_all()
for b in blocks:
self.nodes[0].submitblock(b)
def run_test(self):
test_data = os.path.join(TESTSDIR, self.options.test_data)
if self.options.gen_test_data:
self.generate_test_data(test_data)
else:
self.load_test_data(test_data)
self.sync_all()
stats = self.get_stats()
# Make sure all valid statistics are included but nothing else is
expected_keys = self.expected_stats[0].keys()
assert_equal(set(stats[0].keys()), set(expected_keys))
assert_equal(stats[0]['height'], self.start_height)
assert_equal(stats[self.max_stat_pos]['height'], self.start_height + self.max_stat_pos)
for i in range(self.max_stat_pos+1):
self.log.info('Checking block %d\n' % (i))
assert_equal(stats[i], self.expected_stats[i])
# Check selecting block by hash too
blockhash = self.expected_stats[i]['blockhash']
stats_by_hash = self.nodes[0].getblockstats(hash_or_height=blockhash)
assert_equal(stats_by_hash, self.expected_stats[i])
# Make sure each stat can be queried on its own
for stat in expected_keys:
for i in range(self.max_stat_pos+1):
result = self.nodes[0].getblockstats(hash_or_height=self.start_height + i, stats=[stat])
assert_equal(list(result.keys()), [stat])
if result[stat] != self.expected_stats[i][stat]:
self.log.info('result[%s] (%d) failed, %r != %r' % (
stat, i, result[stat], self.expected_stats[i][stat]))
assert_equal(result[stat], self.expected_stats[i][stat])
# Make sure only the selected statistics are included (more than one)
some_stats = {'minfee', 'maxfee'}
stats = self.nodes[0].getblockstats(hash_or_height=1, stats=list(some_stats))
assert_equal(set(stats.keys()), some_stats)
# Test invalid parameters raise the proper json exceptions
tip = self.start_height + self.max_stat_pos
assert_raises_rpc_error(-8, 'Target block height %d after current tip %d' % (tip+1, tip),
self.nodes[0].getblockstats, hash_or_height=tip+1)
assert_raises_rpc_error(-8, 'Target block height %d is negative' % (-1),
self.nodes[0].getblockstats, hash_or_height=-1)
# Make sure not valid stats aren't allowed
inv_sel_stat = 'asdfghjkl'
inv_stats = [
[inv_sel_stat],
['minfee' , inv_sel_stat],
[inv_sel_stat, 'minfee'],
['minfee', inv_sel_stat, 'maxfee'],
]
for inv_stat in inv_stats:
assert_raises_rpc_error(-8, 'Invalid selected statistic %s' % inv_sel_stat,
self.nodes[0].getblockstats, hash_or_height=1, stats=inv_stat)
# Make sure we aren't always returning inv_sel_stat as the culprit stat
assert_raises_rpc_error(-8, 'Invalid selected statistic aaa%s' % inv_sel_stat,
self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee' , 'aaa%s' % inv_sel_stat])
# Mainchain's genesis block shouldn't be found on regtest
assert_raises_rpc_error(-5, 'Block not found', self.nodes[0].getblockstats,
hash_or_height='000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f')
# Invalid number of args
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats, '00', 1, 2)
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats)
if __name__ == '__main__':
GetblockstatsTest().main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
9708,
13,
14982,
377,
300,
656,
967,
262,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
199,
3,
199,
3,
1379,
664,
1457,
3200,
8985,
1240,
199,
3,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
377,
300,
656,
9061,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
334,
272,
702,
63,
1452,
12,
272,
702,
63,
3536,
63,
4354,
63,
705,
12,
199,
9,
199,
646,
2022,
199,
646,
747,
199,
199,
7569,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
199,
199,
533,
2372,
1457,
3200,
774,
8,
27438,
656,
9061,
26203,
304,
339,
1343,
63,
3333,
275,
14313,
272,
1390,
63,
3736,
63,
1712,
275,
499,
339,
347,
1050,
63,
1419,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
63,
2094,
4517,
2268,
13,
396,
13,
576,
297,
2053,
534,
2268,
63,
396,
63,
576,
297,
1169,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
1169,
1720,
534,
6864,
511,
666,
358,
267,
1798,
14,
525,
63,
2094,
4517,
396,
13,
576,
297,
2053,
534,
396,
63,
576,
297,
1169,
849,
534,
576,
15,
4354,
63,
17785,
3200,
14,
1001,
297,
1169,
1595,
534,
1617,
297,
8214,
534,
3817,
297,
1169,
1720,
534,
774,
666,
570,
358,
339,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
1507,
63,
2415,
275,
413,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
715,
339,
347,
664,
63,
3200,
8,
277,
304,
267,
372,
359,
277,
14,
2415,
59,
16,
1055,
17785,
3200,
8,
2227,
63,
269,
63,
3333,
29,
277,
14,
928,
63,
3333,
435,
284,
9,
367,
284,
315,
1425,
8,
277,
14,
988,
63,
3736,
63,
1712,
11,
17,
1874,
339,
347,
3550,
63,
396,
63,
576,
8,
277,
12,
1788,
304,
267,
1683,
521,
275,
4114,
27873,
2819,
821,
267,
291,
14,
2415,
59,
16,
1055,
409,
1805,
521,
8,
1805,
521,
9,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
4893,
9,
398,
2287,
275,
291,
14,
2415,
59,
16,
1055,
362,
63,
30709,
63,
10605,
63,
498,
1252,
1562,
267,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
709,
12,
24129,
771,
2829,
293,
391,
3956,
29,
549,
9,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
267,
291,
14,
5186,
63,
452,
342,
398,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
709,
12,
24129,
771,
2829,
293,
391,
3956,
29,
549,
9,
267,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
709,
12,
24129,
771,
2829,
293,
391,
3956,
29,
797,
9,
267,
291,
14,
2415,
59,
16,
1055,
409,
2347,
11195,
8,
4606,
29,
16,
14,
8262,
9,
267,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
17,
12,
24129,
771,
2829,
293,
391,
3956,
29,
549,
9,
267,
291,
14,
5186,
63,
452,
342,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
398,
291,
14,
2062,
63,
3200,
275,
291,
14,
362,
63,
3200,
342,
398,
5664,
275,
942,
267,
19201,
275,
291,
14,
2415,
59,
16,
1055,
362,
7010,
25848,
342,
267,
1853,
2227,
275,
488,
267,
4569,
275,
378,
267,
1830,
19201,
1137,
1853,
2227,
26,
288,
1853,
2227,
275,
291,
14,
2415,
59,
16,
1055,
17785,
2227,
8,
3333,
9,
288,
5664,
14,
740,
8,
277,
14,
2415,
59,
16,
1055,
17785,
8,
25848,
12,
378,
430,
288,
4569,
847,
413,
398,
370,
63,
2724,
275,
469,
288,
283,
4166,
356,
5664,
12,
288,
283,
1805,
521,
356,
1109,
8,
1805,
521,
395,
288,
283,
3200,
356,
291,
14,
2062,
63,
3200,
12,
267,
789,
267,
543,
1551,
8,
1501,
12,
283,
87,
297,
2644,
628,
1624,
24,
531,
465,
289,
26,
288,
2022,
14,
2724,
8,
475,
63,
2724,
12,
289,
12,
4069,
63,
1612,
29,
549,
12,
4363,
29,
18,
9,
339,
347,
2248,
63,
396,
63,
576,
8,
277,
12,
1788,
304,
267,
543,
1551,
8,
1501,
12,
283,
82,
297,
2644,
628,
1624,
24,
531,
465,
289,
26,
288,
366,
275,
2022,
14,
912,
8,
70,
9,
288,
5664,
275,
366,
459,
4166,
418,
288,
1683,
521,
275,
366,
459,
1805,
521,
418,
288,
291,
14,
2062,
63,
3200,
275,
366,
459,
3200,
418,
398,
327,
2494,
314,
22496,
687,
314,
570,
880,
626,
314,
3380,
883,
664,
734,
402,
6026,
8651,
17955,
267,
291,
14,
2415,
59,
16,
1055,
409,
1805,
521,
8,
1805,
521,
9,
267,
291,
14,
5186,
63,
452,
342,
398,
367,
330,
315,
5664,
26,
288,
291,
14,
2415,
59,
16,
1055,
7275,
1457,
8,
66,
9,
2378,
347,
1255,
63,
396,
8,
277,
304,
267,
511,
63,
576,
275,
747,
14,
515,
14,
904,
8,
7569,
3022,
12,
291,
14,
1419,
14,
396,
63,
576,
9,
267,
340,
291,
14,
1419,
14,
2268,
63,
396,
63,
576,
26,
288,
291,
14,
4208,
63,
396,
63,
576,
8,
396,
63,
576,
9,
267,
587,
26,
288,
291,
14,
912,
63,
396,
63,
576,
8,
396,
63,
576,
9,
398,
291,
14,
5186,
63,
452,
342,
267,
5020,
275,
291,
14,
362,
63,
3200,
342,
398,
327,
4155,
3238,
1006,
1686,
11076,
787,
5120,
1325,
6548,
587,
365,
267,
1420,
63,
1612,
275,
291,
14,
2062,
63,
3200,
59,
16,
1055,
1612,
342,
267,
702,
63,
1452,
8,
409,
8,
3200,
59,
16,
1055,
1612,
4000,
663,
8,
2062,
63,
1612,
430,
398,
702,
63,
1452,
8,
3200,
59,
16,
2733,
3333,
995,
291,
14,
928,
63,
3333,
9,
267,
702,
63,
1452,
8,
3200,
59,
277,
14,
988,
63,
3736,
63,
1712,
2733,
3333,
995,
291,
14,
928,
63,
3333,
435,
291,
14,
988,
63,
3736,
63,
1712,
9,
398,
367,
284,
315,
1425,
8,
277,
14,
988,
63
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
334,
67,
9,
9708,
13,
14982,
377,
300,
656,
967,
262,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
199,
3,
199,
3,
1379,
664,
1457,
3200,
8985,
1240,
199,
3,
199,
504,
511,
63,
4857,
14,
396,
63,
4857,
492,
377,
300,
656,
9061,
26203,
199,
504,
511,
63,
4857,
14,
1974,
492,
334,
272,
702,
63,
1452,
12,
272,
702,
63,
3536,
63,
4354,
63,
705,
12,
199,
9,
199,
646,
2022,
199,
646,
747,
199,
199,
7569,
3022,
275,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
8964,
199,
199,
533,
2372,
1457,
3200,
774,
8,
27438,
656,
9061,
26203,
304,
339,
1343,
63,
3333,
275,
14313,
272,
1390,
63,
3736,
63,
1712,
275,
499,
339,
347,
1050,
63,
1419,
8,
277,
12,
1798,
304,
267,
1798,
14,
525,
63,
2094,
4517,
2268,
13,
396,
13,
576,
297,
2053,
534,
2268,
63,
396,
63,
576,
297,
1169,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
1169,
1720,
534,
6864,
511,
666,
358,
267,
1798,
14,
525,
63,
2094,
4517,
396,
13,
576,
297,
2053,
534,
396,
63,
576,
297,
1169,
849,
534,
576,
15,
4354,
63,
17785,
3200,
14,
1001,
297,
1169,
1595,
534,
1617,
297,
8214,
534,
3817,
297,
1169,
1720,
534,
774,
666,
570,
358,
339,
347,
663,
63,
396,
63,
1162,
8,
277,
304,
267,
291,
14,
1507,
63,
2415,
275,
413,
267,
291,
14,
2758,
63,
3118,
63,
4429,
275,
715,
339,
347,
664,
63,
3200,
8,
277,
304,
267,
372,
359,
277,
14,
2415,
59,
16,
1055,
17785,
3200,
8,
2227,
63,
269,
63,
3333,
29,
277,
14,
928,
63,
3333,
435,
284,
9,
367,
284,
315,
1425,
8,
277,
14,
988,
63,
3736,
63,
1712,
11,
17,
1874,
339,
347,
3550,
63,
396,
63,
576,
8,
277,
12,
1788,
304,
267,
1683,
521,
275,
4114,
27873,
2819,
821,
267,
291,
14,
2415,
59,
16,
1055,
409,
1805,
521,
8,
1805,
521,
9,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
4893,
9,
398,
2287,
275,
291,
14,
2415,
59,
16,
1055,
362,
63,
30709,
63,
10605,
63,
498,
1252,
1562,
267,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
709,
12,
24129,
771,
2829,
293,
391,
3956,
29,
549,
9,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
267,
291,
14,
5186,
63,
452,
342,
398,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
709,
12,
24129,
771,
2829,
293,
391,
3956,
29,
549,
9,
267,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
709,
12,
24129,
771,
2829,
293,
391,
3956,
29,
797,
9,
267,
291,
14,
2415,
59,
16,
1055,
409,
2347,
11195,
8,
4606,
29,
16,
14,
8262,
9,
267,
291,
14,
2415,
59,
16,
1055,
23267,
1562,
8,
1562,
29,
1562,
12,
5982,
29,
17,
12,
24129,
771,
2829,
293,
391,
3956,
29,
549,
9,
267,
291,
14,
5186,
63,
452,
342,
267,
291,
14,
2415,
59,
16,
1055,
4208,
8,
17,
9,
398,
291,
14,
2062,
63,
3200,
275,
291,
14,
362,
63,
3200,
342,
398,
5664,
275,
942,
267,
19201,
275,
291,
14,
2415,
59,
16,
1055,
362,
7010,
25848,
342,
267,
1853,
2227,
275,
488,
267,
4569,
275,
378,
267,
1830,
19201,
1137,
1853,
2227,
26,
288,
1853,
2227,
275,
291,
14,
2415,
59,
16,
1055,
17785,
2227,
8,
3333,
9,
288,
5664,
14,
740,
8,
277,
14,
2415,
59,
16,
1055,
17785,
8,
25848,
12,
378,
430,
288,
4569,
847,
413,
398,
370,
63,
2724,
275,
469,
288,
283,
4166,
356,
5664,
12,
288,
283,
1805,
521,
356,
1109,
8,
1805,
521,
395,
288,
283,
3200,
356,
291,
14,
2062,
63,
3200,
12,
267,
789,
267,
543,
1551,
8,
1501,
12,
283,
87,
297,
2644,
628,
1624,
24,
531,
465,
289,
26,
288,
2022,
14,
2724,
8,
475,
63,
2724,
12,
289,
12,
4069,
63,
1612,
29,
549,
12,
4363,
29,
18,
9,
339,
347,
2248,
63,
396,
63,
576,
8,
277,
12,
1788,
304,
267,
543,
1551,
8,
1501,
12,
283,
82,
297,
2644,
628,
1624,
24,
531,
465,
289,
26,
288,
366,
275,
2022,
14,
912,
8,
70,
9,
288,
5664,
275,
366,
459,
4166,
418,
288,
1683,
521,
275,
366,
459,
1805,
521,
418,
288,
291,
14,
2062,
63,
3200,
275,
366,
459,
3200,
418,
398,
327,
2494,
314,
22496,
687,
314,
570,
880,
626,
314,
3380,
883,
664,
734,
402,
6026,
8651,
17955,
267,
291,
14,
2415,
59,
16,
1055,
409,
1805,
521,
8,
1805,
521,
9,
267,
291,
14,
5186,
63,
452,
342,
398,
367,
330,
315,
5664,
26,
288,
291,
14,
2415,
59,
16,
1055,
7275,
1457,
8,
66,
9,
2378,
347,
1255,
63,
396,
8,
277,
304,
267,
511,
63,
576,
275,
747,
14,
515,
14,
904,
8,
7569,
3022,
12,
291,
14,
1419,
14,
396,
63,
576,
9,
267,
340,
291,
14,
1419,
14,
2268,
63,
396,
63,
576,
26,
288,
291,
14,
4208,
63,
396,
63,
576,
8,
396,
63,
576,
9,
267,
587,
26,
288,
291,
14,
912,
63,
396,
63,
576,
8,
396,
63,
576,
9,
398,
291,
14,
5186,
63,
452,
342,
267,
5020,
275,
291,
14,
362,
63,
3200,
342,
398,
327,
4155,
3238,
1006,
1686,
11076,
787,
5120,
1325,
6548,
587,
365,
267,
1420,
63,
1612,
275,
291,
14,
2062,
63,
3200,
59,
16,
1055,
1612,
342,
267,
702,
63,
1452,
8,
409,
8,
3200,
59,
16,
1055,
1612,
4000,
663,
8,
2062,
63,
1612,
430,
398,
702,
63,
1452,
8,
3200,
59,
16,
2733,
3333,
995,
291,
14,
928,
63,
3333,
9,
267,
702,
63,
1452,
8,
3200,
59,
277,
14,
988,
63,
3736,
63,
1712,
2733,
3333,
995,
291,
14,
928,
63,
3333,
435,
291,
14,
988,
63,
3736,
63,
1712,
9,
398,
367,
284,
315,
1425,
8,
277,
14,
988,
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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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
] |
Universal-Model-Converter/UMC3.0a
|
data/Python/x86/Lib/site-packages/OpenGL/GL/NV/shader_buffer_store.py
|
2
|
1943
|
'''OpenGL extension NV.shader_buffer_store
This module customises the behaviour of the
OpenGL.raw.GL.NV.shader_buffer_store to provide a more
Python-friendly API
Overview (from the spec)
This extension builds upon the mechanisms added by the
NV_shader_buffer_load extension to allow shaders to perform random-access
reads to buffer object memory without using dedicated buffer object
binding points. Instead, it allowed an application to make a buffer
object resident, query a GPU address (pointer) for the buffer object, and
then use that address as a pointer in shader code. This approach allows
shaders to access a large number of buffer objects without needing to
repeatedly bind buffers to a limited number of fixed-functionality binding
points.
This extension lifts the restriction from NV_shader_buffer_load that
disallows writes. In particular, the MakeBufferResidentNV function now
allows READ_WRITE and WRITE_ONLY access modes, and the shading language is
extended to allow shaders to write through (GPU address) pointers.
Additionally, the extension provides built-in functions to perform atomic
memory transactions to buffer object memory.
As with the shader writes provided by the EXT_shader_image_load_store
extension, writes to buffer object memory using this extension are weakly
ordered to allow for parallel or distributed shader execution. The
EXT_shader_image_load_store extension provides mechanisms allowing for
finer control of memory transaction order, and those mechanisms apply
equally to buffer object stores using this extension.
The official definition of this extension is available here:
http://www.opengl.org/registry/specs/NV/shader_buffer_store.txt
'''
from OpenGL import platform, constants, constant, arrays
from OpenGL import extensions, wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.NV.shader_buffer_store import *
### END AUTOGENERATED SECTION
|
mit
|
[
2344,
4299,
2226,
3329,
653,
54,
14,
18116,
63,
2738,
63,
1617,
199,
199,
2765,
859,
3537,
1388,
314,
13942,
402,
314,
221,
199,
4299,
2226,
14,
1773,
14,
2226,
14,
7312,
14,
18116,
63,
2738,
63,
1617,
370,
5647,
282,
1655,
221,
199,
4718,
13,
17317,
3261,
199,
199,
28077,
334,
504,
314,
3158,
9,
8299,
198,
2765,
3329,
14723,
12188,
314,
562,
10832,
706,
3483,
701,
314,
199,
198,
7312,
63,
18116,
63,
2738,
63,
912,
3329,
370,
2040,
25958,
83,
370,
5147,
2196,
13,
2732,
199,
198,
15656,
370,
3335,
909,
4402,
1928,
1808,
29711,
3335,
909,
199,
198,
9140,
4501,
14,
221,
15345,
12,
652,
4370,
376,
4223,
370,
1852,
282,
3335,
199,
198,
785,
28633,
1326,
12,
1827,
282,
18613,
2287,
334,
3929,
9,
367,
314,
3335,
909,
12,
436,
199,
198,
12726,
675,
626,
2287,
465,
282,
7849,
315,
25958,
1233,
14,
221,
961,
18140,
6127,
199,
198,
18116,
83,
370,
2879,
282,
7031,
1329,
402,
3335,
2251,
1928,
1929,
316,
370,
199,
198,
7593,
590,
5398,
19383,
370,
282,
13988,
1329,
402,
6317,
13,
1593,
6712,
11696,
199,
198,
3438,
14,
8299,
198,
2765,
3329,
221,
853,
1086,
314,
10588,
687,
653,
54,
63,
18116,
63,
2738,
63,
912,
626,
199,
198,
2297,
24077,
14511,
14,
221,
1010,
6770,
12,
314,
4155,
3299,
497,
338,
1326,
7312,
805,
3063,
199,
198,
24077,
16767,
63,
10387,
436,
32280,
63,
10452,
2879,
12404,
12,
436,
314,
1033,
5384,
2637,
365,
199,
198,
10525,
370,
2040,
25958,
83,
370,
2218,
4012,
334,
20769,
2287,
9,
21116,
14,
199,
198,
2767,
22565,
12,
314,
3329,
6571,
6137,
13,
262,
3423,
370,
5147,
15374,
199,
198,
4844,
15809,
370,
3335,
909,
4402,
14,
8299,
198,
2822,
543,
314,
25958,
14511,
2741,
701,
314,
20203,
63,
18116,
63,
1569,
63,
912,
63,
1617,
199,
198,
3435,
12,
14511,
370,
3335,
909,
4402,
1808,
642,
3329,
787,
9282,
590,
199,
198,
8235,
370,
2040,
367,
9861,
503,
1854,
25958,
6451,
14,
221,
710,
199,
198,
2472,
63,
18116,
63,
1569,
63,
912,
63,
1617,
3329,
6571,
562,
10832,
706,
17266,
367,
199,
198,
2408,
281,
3304,
402,
4402,
6008,
1865,
12,
436,
5204,
562,
10832,
706,
4838,
199,
198,
15788,
1183,
370,
3335,
909,
14086,
1808,
642,
3329,
14,
8299,
199,
1918,
25410,
5492,
402,
642,
3329,
365,
2808,
2348,
26,
199,
1014,
921,
1544,
14,
32477,
14,
1308,
15,
5189,
15,
7273,
15,
7312,
15,
18116,
63,
2738,
63,
1617,
14,
2424,
199,
2344,
199,
504,
24374,
492,
4298,
12,
5262,
12,
4413,
12,
6572,
199,
504,
24374,
492,
5478,
12,
4975,
199,
504,
24374,
14,
2226,
492,
6482,
362,
199,
646,
5577,
199,
504,
24374,
14,
1773,
14,
2226,
14,
7312,
14,
18116,
63,
2738,
63,
1617,
492,
627,
199,
5680,
7729,
25420,
12795,
6989,
29074,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
4299,
2226,
3329,
653,
54,
14,
18116,
63,
2738,
63,
1617,
199,
199,
2765,
859,
3537,
1388,
314,
13942,
402,
314,
221,
199,
4299,
2226,
14,
1773,
14,
2226,
14,
7312,
14,
18116,
63,
2738,
63,
1617,
370,
5647,
282,
1655,
221,
199,
4718,
13,
17317,
3261,
199,
199,
28077,
334,
504,
314,
3158,
9,
8299,
198,
2765,
3329,
14723,
12188,
314,
562,
10832,
706,
3483,
701,
314,
199,
198,
7312,
63,
18116,
63,
2738,
63,
912,
3329,
370,
2040,
25958,
83,
370,
5147,
2196,
13,
2732,
199,
198,
15656,
370,
3335,
909,
4402,
1928,
1808,
29711,
3335,
909,
199,
198,
9140,
4501,
14,
221,
15345,
12,
652,
4370,
376,
4223,
370,
1852,
282,
3335,
199,
198,
785,
28633,
1326,
12,
1827,
282,
18613,
2287,
334,
3929,
9,
367,
314,
3335,
909,
12,
436,
199,
198,
12726,
675,
626,
2287,
465,
282,
7849,
315,
25958,
1233,
14,
221,
961,
18140,
6127,
199,
198,
18116,
83,
370,
2879,
282,
7031,
1329,
402,
3335,
2251,
1928,
1929,
316,
370,
199,
198,
7593,
590,
5398,
19383,
370,
282,
13988,
1329,
402,
6317,
13,
1593,
6712,
11696,
199,
198,
3438,
14,
8299,
198,
2765,
3329,
221,
853,
1086,
314,
10588,
687,
653,
54,
63,
18116,
63,
2738,
63,
912,
626,
199,
198,
2297,
24077,
14511,
14,
221,
1010,
6770,
12,
314,
4155,
3299,
497,
338,
1326,
7312,
805,
3063,
199,
198,
24077,
16767,
63,
10387,
436,
32280,
63,
10452,
2879,
12404,
12,
436,
314,
1033,
5384,
2637,
365,
199,
198,
10525,
370,
2040,
25958,
83,
370,
2218,
4012,
334,
20769,
2287,
9,
21116,
14,
199,
198,
2767,
22565,
12,
314,
3329,
6571,
6137,
13,
262,
3423,
370,
5147,
15374,
199,
198,
4844,
15809,
370,
3335,
909,
4402,
14,
8299,
198,
2822,
543,
314,
25958,
14511,
2741,
701,
314,
20203,
63,
18116,
63,
1569,
63,
912,
63,
1617,
199,
198,
3435,
12,
14511,
370,
3335,
909,
4402,
1808,
642,
3329,
787,
9282,
590,
199,
198,
8235,
370,
2040,
367,
9861,
503,
1854,
25958,
6451,
14,
221,
710,
199,
198,
2472,
63,
18116,
63,
1569,
63,
912,
63,
1617,
3329,
6571,
562,
10832,
706,
17266,
367,
199,
198,
2408,
281,
3304,
402,
4402,
6008,
1865,
12,
436,
5204,
562,
10832,
706,
4838,
199,
198,
15788,
1183,
370,
3335,
909,
14086,
1808,
642,
3329,
14,
8299,
199,
1918,
25410,
5492,
402,
642,
3329,
365,
2808,
2348,
26,
199,
1014,
921,
1544,
14,
32477,
14,
1308,
15,
5189,
15,
7273,
15,
7312,
15,
18116,
63,
2738,
63,
1617,
14,
2424,
199,
2344,
199,
504,
24374,
492,
4298,
12,
5262,
12,
4413,
12,
6572,
199,
504,
24374,
492,
5478,
12,
4975,
199,
504,
24374,
14,
2226,
492,
6482,
362,
199,
646,
5577,
199,
504,
24374,
14,
1773,
14,
2226,
14,
7312,
14,
18116,
63,
2738,
63,
1617,
492,
627,
199,
5680,
7729,
25420,
12795,
6989,
29074,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
ddzialak/boto
|
tests/integration/s3/test_bucket.py
|
88
|
12516
|
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Mitch Garnaat http://garnaat.org/
# All rights reserved.
#
# 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.
"""
Some unit tests for the S3 Bucket
"""
from mock import patch, Mock
import unittest
import time
from boto.exception import S3ResponseError
from boto.s3.connection import S3Connection
from boto.s3.bucketlogging import BucketLogging
from boto.s3.lifecycle import Lifecycle
from boto.s3.lifecycle import Transition
from boto.s3.lifecycle import Expiration
from boto.s3.lifecycle import Rule
from boto.s3.acl import Grant
from boto.s3.tagging import Tags, TagSet
from boto.s3.website import RedirectLocation
from boto.compat import urllib
class S3BucketTest (unittest.TestCase):
s3 = True
def setUp(self):
self.conn = S3Connection()
self.bucket_name = 'bucket-%d' % int(time.time())
self.bucket = self.conn.create_bucket(self.bucket_name)
def tearDown(self):
for key in self.bucket:
key.delete()
self.bucket.delete()
def test_next_marker(self):
expected = ["a/", "b", "c"]
for key_name in expected:
key = self.bucket.new_key(key_name)
key.set_contents_from_string(key_name)
# Normal list of first 2 keys will have
# no NextMarker set, so we use last key to iterate
# last element will be "b" so no issue.
rs = self.bucket.get_all_keys(max_keys=2)
for element in rs:
pass
self.assertEqual(element.name, "b")
self.assertEqual(rs.next_marker, None)
# list using delimiter of first 2 keys will have
# a NextMarker set (when truncated). As prefixes
# are grouped together at the end, we get "a/" as
# last element, but luckily we have next_marker.
rs = self.bucket.get_all_keys(max_keys=2, delimiter="/")
for element in rs:
pass
self.assertEqual(element.name, "a/")
self.assertEqual(rs.next_marker, "b")
# ensure bucket.list() still works by just
# popping elements off the front of expected.
rs = self.bucket.list()
for element in rs:
self.assertEqual(element.name, expected.pop(0))
self.assertEqual(expected, [])
def test_list_with_url_encoding(self):
expected = ["α", "β", "γ"]
for key_name in expected:
key = self.bucket.new_key(key_name)
key.set_contents_from_string(key_name)
# ensure bucket.list() still works by just
# popping elements off the front of expected.
orig_getall = self.bucket._get_all
getall = lambda *a, **k: orig_getall(*a, max_keys=2, **k)
with patch.object(self.bucket, '_get_all', getall):
rs = self.bucket.list(encoding_type="url")
for element in rs:
name = urllib.parse.unquote(element.name.encode('utf-8'))
self.assertEqual(name, expected.pop(0))
self.assertEqual(expected, [])
def test_logging(self):
# use self.bucket as the target bucket so that teardown
# will delete any log files that make it into the bucket
# automatically and all we have to do is delete the
# source bucket.
sb_name = "src-" + self.bucket_name
sb = self.conn.create_bucket(sb_name)
# grant log write perms to target bucket using canned-acl
self.bucket.set_acl("log-delivery-write")
target_bucket = self.bucket_name
target_prefix = u"jp/ログ/"
# Check existing status is disabled
bls = sb.get_logging_status()
self.assertEqual(bls.target, None)
# Create a logging status and grant auth users READ PERM
authuri = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
authr = Grant(permission="READ", type="Group", uri=authuri)
sb.enable_logging(target_bucket, target_prefix=target_prefix, grants=[authr])
# Check the status and confirm its set.
bls = sb.get_logging_status()
self.assertEqual(bls.target, target_bucket)
self.assertEqual(bls.prefix, target_prefix)
self.assertEqual(len(bls.grants), 1)
self.assertEqual(bls.grants[0].type, "Group")
self.assertEqual(bls.grants[0].uri, authuri)
# finally delete the src bucket
sb.delete()
def test_tagging(self):
tagging = """
<Tagging>
<TagSet>
<Tag>
<Key>tagkey</Key>
<Value>tagvalue</Value>
</Tag>
</TagSet>
</Tagging>
"""
self.bucket.set_xml_tags(tagging)
response = self.bucket.get_tags()
self.assertEqual(response[0][0].key, 'tagkey')
self.assertEqual(response[0][0].value, 'tagvalue')
self.bucket.delete_tags()
try:
self.bucket.get_tags()
except S3ResponseError as e:
self.assertEqual(e.code, 'NoSuchTagSet')
except Exception as e:
self.fail("Wrong exception raised (expected S3ResponseError): %s"
% e)
else:
self.fail("Expected S3ResponseError, but no exception raised.")
def test_tagging_from_objects(self):
"""Create tags from python objects rather than raw xml."""
t = Tags()
tag_set = TagSet()
tag_set.add_tag('akey', 'avalue')
tag_set.add_tag('anotherkey', 'anothervalue')
t.add_tag_set(tag_set)
self.bucket.set_tags(t)
response = self.bucket.get_tags()
self.assertEqual(response[0][0].key, 'akey')
self.assertEqual(response[0][0].value, 'avalue')
self.assertEqual(response[0][1].key, 'anotherkey')
self.assertEqual(response[0][1].value, 'anothervalue')
def test_website_configuration(self):
response = self.bucket.configure_website('index.html')
self.assertTrue(response)
config = self.bucket.get_website_configuration()
self.assertEqual(config, {'WebsiteConfiguration':
{'IndexDocument': {'Suffix': 'index.html'}}})
config2, xml = self.bucket.get_website_configuration_with_xml()
self.assertEqual(config, config2)
self.assertTrue('<Suffix>index.html</Suffix>' in xml, xml)
def test_website_redirect_all_requests(self):
response = self.bucket.configure_website(
redirect_all_requests_to=RedirectLocation('example.com'))
config = self.bucket.get_website_configuration()
self.assertEqual(config, {
'WebsiteConfiguration': {
'RedirectAllRequestsTo': {
'HostName': 'example.com'}}})
# Can configure the protocol as well.
response = self.bucket.configure_website(
redirect_all_requests_to=RedirectLocation('example.com', 'https'))
config = self.bucket.get_website_configuration()
self.assertEqual(config, {
'WebsiteConfiguration': {'RedirectAllRequestsTo': {
'HostName': 'example.com',
'Protocol': 'https',
}}}
)
def test_lifecycle(self):
lifecycle = Lifecycle()
lifecycle.add_rule('myid', '', 'Enabled', 30)
self.assertTrue(self.bucket.configure_lifecycle(lifecycle))
response = self.bucket.get_lifecycle_config()
self.assertEqual(len(response), 1)
actual_lifecycle = response[0]
self.assertEqual(actual_lifecycle.id, 'myid')
self.assertEqual(actual_lifecycle.prefix, '')
self.assertEqual(actual_lifecycle.status, 'Enabled')
self.assertEqual(actual_lifecycle.transition, None)
def test_lifecycle_with_glacier_transition(self):
lifecycle = Lifecycle()
transition = Transition(days=30, storage_class='GLACIER')
rule = Rule('myid', prefix='', status='Enabled', expiration=None,
transition=transition)
lifecycle.append(rule)
self.assertTrue(self.bucket.configure_lifecycle(lifecycle))
response = self.bucket.get_lifecycle_config()
transition = response[0].transition
self.assertEqual(transition.days, 30)
self.assertEqual(transition.storage_class, 'GLACIER')
self.assertEqual(transition.date, None)
def test_lifecycle_multi(self):
date = '2022-10-12T00:00:00.000Z'
sc = 'GLACIER'
lifecycle = Lifecycle()
lifecycle.add_rule("1", "1/", "Enabled", 1)
lifecycle.add_rule("2", "2/", "Enabled", Expiration(days=2))
lifecycle.add_rule("3", "3/", "Enabled", Expiration(date=date))
lifecycle.add_rule("4", "4/", "Enabled", None,
Transition(days=4, storage_class=sc))
lifecycle.add_rule("5", "5/", "Enabled", None,
Transition(date=date, storage_class=sc))
# set the lifecycle
self.bucket.configure_lifecycle(lifecycle)
# read the lifecycle back
readlifecycle = self.bucket.get_lifecycle_config();
for rule in readlifecycle:
if rule.id == "1":
self.assertEqual(rule.prefix, "1/")
self.assertEqual(rule.expiration.days, 1)
elif rule.id == "2":
self.assertEqual(rule.prefix, "2/")
self.assertEqual(rule.expiration.days, 2)
elif rule.id == "3":
self.assertEqual(rule.prefix, "3/")
self.assertEqual(rule.expiration.date, date)
elif rule.id == "4":
self.assertEqual(rule.prefix, "4/")
self.assertEqual(rule.transition.days, 4)
self.assertEqual(rule.transition.storage_class, sc)
elif rule.id == "5":
self.assertEqual(rule.prefix, "5/")
self.assertEqual(rule.transition.date, date)
self.assertEqual(rule.transition.storage_class, sc)
else:
self.fail("unexpected id %s" % rule.id)
def test_lifecycle_jp(self):
# test lifecycle with Japanese prefix
name = "Japanese files"
prefix = "日本語/"
days = 30
lifecycle = Lifecycle()
lifecycle.add_rule(name, prefix, "Enabled", days)
# set the lifecycle
self.bucket.configure_lifecycle(lifecycle)
# read the lifecycle back
readlifecycle = self.bucket.get_lifecycle_config();
for rule in readlifecycle:
self.assertEqual(rule.id, name)
self.assertEqual(rule.expiration.days, days)
#Note: Boto seems correct? AWS seems broken?
#self.assertEqual(rule.prefix, prefix)
def test_lifecycle_with_defaults(self):
lifecycle = Lifecycle()
lifecycle.add_rule(expiration=30)
self.assertTrue(self.bucket.configure_lifecycle(lifecycle))
response = self.bucket.get_lifecycle_config()
self.assertEqual(len(response), 1)
actual_lifecycle = response[0]
self.assertNotEqual(len(actual_lifecycle.id), 0)
self.assertEqual(actual_lifecycle.prefix, '')
def test_lifecycle_rule_xml(self):
# create a rule directly with id, prefix defaults
rule = Rule(status='Enabled', expiration=30)
s = rule.to_xml()
# Confirm no ID is set in the rule.
self.assertEqual(s.find("<ID>"), -1)
# Confirm Prefix is '' and not set to 'None'
self.assertNotEqual(s.find("<Prefix></Prefix>"), -1)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
67,
9,
7760,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
2900,
4481,
4644,
14,
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,
199,
624,
199,
7700,
4137,
2295,
367,
314,
428,
19,
31479,
199,
624,
199,
199,
504,
1683,
492,
3371,
12,
4420,
199,
646,
2882,
199,
646,
900,
199,
199,
504,
6055,
14,
1971,
492,
428,
19,
19712,
199,
504,
6055,
14,
83,
19,
14,
2105,
492,
428,
19,
3225,
199,
504,
6055,
14,
83,
19,
14,
4623,
4806,
492,
31479,
14054,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
491,
692,
29816,
2265,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
19894,
1588,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
1316,
1038,
1754,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
11949,
199,
504,
6055,
14,
83,
19,
14,
5853,
492,
598,
17633,
199,
504,
6055,
14,
83,
19,
14,
1450,
1540,
492,
25204,
12,
8053,
1084,
199,
504,
6055,
14,
83,
19,
14,
7360,
492,
18532,
6592,
199,
504,
6055,
14,
5819,
492,
4011,
421,
199,
533,
428,
19,
12311,
774,
334,
2796,
14,
1746,
304,
272,
308,
19,
275,
715,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1631,
275,
428,
19,
3225,
342,
267,
291,
14,
4623,
63,
354,
275,
283,
4623,
3295,
68,
7,
450,
1109,
8,
521,
14,
521,
1012,
267,
291,
14,
4623,
275,
291,
14,
1631,
14,
981,
63,
4623,
8,
277,
14,
4623,
63,
354,
9,
339,
347,
6766,
8,
277,
304,
267,
367,
790,
315,
291,
14,
4623,
26,
288,
790,
14,
1807,
342,
267,
291,
14,
4623,
14,
1807,
342,
339,
347,
511,
63,
2184,
63,
4211,
8,
277,
304,
267,
1420,
275,
2097,
65,
10665,
298,
66,
401,
298,
67,
937,
267,
367,
790,
63,
354,
315,
1420,
26,
288,
790,
275,
291,
14,
4623,
14,
1222,
63,
498,
8,
498,
63,
354,
9,
288,
790,
14,
409,
63,
4407,
63,
504,
63,
875,
8,
498,
63,
354,
9,
398,
327,
11514,
769,
402,
1642,
499,
2883,
911,
1172,
267,
327,
949,
16840,
12825,
663,
12,
880,
781,
675,
2061,
790,
370,
13974,
267,
327,
2061,
1819,
911,
506,
298,
66,
2,
880,
949,
4976,
14,
267,
10717,
275,
291,
14,
4623,
14,
362,
63,
452,
63,
1612,
8,
988,
63,
1612,
29,
18,
9,
267,
367,
1819,
315,
10717,
26,
288,
986,
267,
291,
14,
629,
8,
2108,
14,
354,
12,
298,
66,
531,
267,
291,
14,
629,
8,
2393,
14,
2184,
63,
4211,
12,
488,
9,
398,
327,
769,
1808,
11172,
402,
1642,
499,
2883,
911,
1172,
267,
327,
282,
16840,
12825,
663,
334,
6526,
17661,
680,
3709,
13158,
267,
327,
787,
16251,
10451,
737,
314,
1284,
12,
781,
664,
298,
65,
6687,
465,
267,
327,
2061,
1819,
12,
1325,
634,
10112,
3444,
781,
1172,
2163,
63,
4211,
14,
267,
10717,
275,
291,
14,
4623,
14,
362,
63,
452,
63,
1612,
8,
988,
63,
1612,
29,
18,
12,
11172,
9555,
531,
267,
367,
1819,
315,
10717,
26,
288,
986,
267,
291,
14,
629,
8,
2108,
14,
354,
12,
298,
65,
13589,
267,
291,
14,
629,
8,
2393,
14,
2184,
63,
4211,
12,
298,
66,
531,
398,
327,
4868,
5315,
14,
513,
342,
5139,
5419,
701,
2951,
267,
327,
4560,
4073,
4008,
2331,
314,
13738,
402,
1420,
14,
267,
10717,
275,
291,
14,
4623,
14,
513,
342,
267,
367,
1819,
315,
10717,
26,
288,
291,
14,
629,
8,
2108,
14,
354,
12,
1420,
14,
1935,
8,
16,
430,
267,
291,
14,
629,
8,
2062,
12,
3073,
339,
347,
511,
63,
513,
63,
1045,
63,
633,
63,
2991,
8,
277,
304,
267,
1420,
275,
2097,
13500,
401,
298,
139,
111,
401,
298,
28916,
937,
267,
367,
790,
63,
354,
315,
1420,
26,
288,
790,
275,
291,
14,
4623,
14,
1222,
63,
498,
8,
498,
63,
354,
9,
288,
790,
14,
409,
63,
4407,
63,
504,
63,
875,
8,
498,
63,
354,
9,
398,
327,
4868,
5315,
14,
513,
342,
5139,
5419,
701,
2951,
267,
327,
4560,
4073,
4008,
2331,
314,
13738,
402,
1420,
14,
267,
2306,
63,
362,
452,
275,
291,
14,
4623,
423,
362,
63,
452,
267,
664,
452,
275,
2400,
627,
65,
12,
1011,
75,
26,
2306,
63,
362,
452,
2031,
65,
12,
1390,
63,
1612,
29,
18,
12,
1011,
75,
9,
267,
543,
3371,
14,
785,
8,
277,
14,
4623,
12,
2513,
362,
63,
452,
297,
664,
452,
304,
288,
10717,
275,
291,
14,
4623,
14,
513,
8,
2991,
63,
466,
628,
633,
531,
288,
367,
1819,
315,
10717,
26,
355,
536,
275,
4011,
14,
1122,
14,
12240,
8,
2108,
14,
354,
14,
2143,
360,
1624,
13,
24,
1333,
355,
291,
14,
629,
8,
354,
12
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
334,
67,
9,
7760,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
2900,
4481,
4644,
14,
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,
199,
624,
199,
7700,
4137,
2295,
367,
314,
428,
19,
31479,
199,
624,
199,
199,
504,
1683,
492,
3371,
12,
4420,
199,
646,
2882,
199,
646,
900,
199,
199,
504,
6055,
14,
1971,
492,
428,
19,
19712,
199,
504,
6055,
14,
83,
19,
14,
2105,
492,
428,
19,
3225,
199,
504,
6055,
14,
83,
19,
14,
4623,
4806,
492,
31479,
14054,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
491,
692,
29816,
2265,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
19894,
1588,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
1316,
1038,
1754,
199,
504,
6055,
14,
83,
19,
14,
28346,
492,
11949,
199,
504,
6055,
14,
83,
19,
14,
5853,
492,
598,
17633,
199,
504,
6055,
14,
83,
19,
14,
1450,
1540,
492,
25204,
12,
8053,
1084,
199,
504,
6055,
14,
83,
19,
14,
7360,
492,
18532,
6592,
199,
504,
6055,
14,
5819,
492,
4011,
421,
199,
533,
428,
19,
12311,
774,
334,
2796,
14,
1746,
304,
272,
308,
19,
275,
715,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1631,
275,
428,
19,
3225,
342,
267,
291,
14,
4623,
63,
354,
275,
283,
4623,
3295,
68,
7,
450,
1109,
8,
521,
14,
521,
1012,
267,
291,
14,
4623,
275,
291,
14,
1631,
14,
981,
63,
4623,
8,
277,
14,
4623,
63,
354,
9,
339,
347,
6766,
8,
277,
304,
267,
367,
790,
315,
291,
14,
4623,
26,
288,
790,
14,
1807,
342,
267,
291,
14,
4623,
14,
1807,
342,
339,
347,
511,
63,
2184,
63,
4211,
8,
277,
304,
267,
1420,
275,
2097,
65,
10665,
298,
66,
401,
298,
67,
937,
267,
367,
790,
63,
354,
315,
1420,
26,
288,
790,
275,
291,
14,
4623,
14,
1222,
63,
498,
8,
498,
63,
354,
9,
288,
790,
14,
409,
63,
4407,
63,
504,
63,
875,
8,
498,
63,
354,
9,
398,
327,
11514,
769,
402,
1642,
499,
2883,
911,
1172,
267,
327,
949,
16840,
12825,
663,
12,
880,
781,
675,
2061,
790,
370,
13974,
267,
327,
2061,
1819,
911,
506,
298,
66,
2,
880,
949,
4976,
14,
267,
10717,
275,
291,
14,
4623,
14,
362,
63,
452,
63,
1612,
8,
988,
63,
1612,
29,
18,
9,
267,
367,
1819,
315,
10717,
26,
288,
986,
267,
291,
14,
629,
8,
2108,
14,
354,
12,
298,
66,
531,
267,
291,
14,
629,
8,
2393,
14,
2184,
63,
4211,
12,
488,
9,
398,
327,
769,
1808,
11172,
402,
1642,
499,
2883,
911,
1172,
267,
327,
282,
16840,
12825,
663,
334,
6526,
17661,
680,
3709,
13158,
267,
327,
787,
16251,
10451,
737,
314,
1284,
12,
781,
664,
298,
65,
6687,
465,
267,
327,
2061,
1819,
12,
1325,
634,
10112,
3444,
781,
1172,
2163,
63,
4211,
14,
267,
10717,
275,
291,
14,
4623,
14,
362,
63,
452,
63,
1612,
8,
988,
63,
1612,
29,
18,
12,
11172,
9555,
531,
267,
367,
1819,
315,
10717,
26,
288,
986,
267,
291,
14,
629,
8,
2108,
14,
354,
12,
298,
65,
13589,
267,
291,
14,
629,
8,
2393,
14,
2184,
63,
4211,
12,
298,
66,
531,
398,
327,
4868,
5315,
14,
513,
342,
5139,
5419,
701,
2951,
267,
327,
4560,
4073,
4008,
2331,
314,
13738,
402,
1420,
14,
267,
10717,
275,
291,
14,
4623,
14,
513,
342,
267,
367,
1819,
315,
10717,
26,
288,
291,
14,
629,
8,
2108,
14,
354,
12,
1420,
14,
1935,
8,
16,
430,
267,
291,
14,
629,
8,
2062,
12,
3073,
339,
347,
511,
63,
513,
63,
1045,
63,
633,
63,
2991,
8,
277,
304,
267,
1420,
275,
2097,
13500,
401,
298,
139,
111,
401,
298,
28916,
937,
267,
367,
790,
63,
354,
315,
1420,
26,
288,
790,
275,
291,
14,
4623,
14,
1222,
63,
498,
8,
498,
63,
354,
9,
288,
790,
14,
409,
63,
4407,
63,
504,
63,
875,
8,
498,
63,
354,
9,
398,
327,
4868,
5315,
14,
513,
342,
5139,
5419,
701,
2951,
267,
327,
4560,
4073,
4008,
2331,
314,
13738,
402,
1420,
14,
267,
2306,
63,
362,
452,
275,
291,
14,
4623,
423,
362,
63,
452,
267,
664,
452,
275,
2400,
627,
65,
12,
1011,
75,
26,
2306,
63,
362,
452,
2031,
65,
12,
1390,
63,
1612,
29,
18,
12,
1011,
75,
9,
267,
543,
3371,
14,
785,
8,
277,
14,
4623,
12,
2513,
362,
63,
452,
297,
664,
452,
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
] |
savioabuga/django-geonames-field
|
docs/conf.py
|
1
|
8231
|
# -*- coding: utf-8 -*-
#
# complexity documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.
#
# 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.
import sys, os
# 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.insert(0, os.path.abspath('.'))
cwd = os.getcwd()
parent = os.path.dirname(cwd)
sys.path.append(parent)
import geonames_field
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# 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.viewcode']
# 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-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'django-geonames-field'
copyright = u'2015, Savio Abuga'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = geonames_field.__version__
# The full version, including alpha/beta/rc tags.
release = geonames_field.__version__
# 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 patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# 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 = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
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_domain_indices = 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, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = 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 = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'django-geonames-fielddoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-geonames-field.tex', u'django-geonames-field Documentation',
u'Savio Abuga', '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
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-geonames-field', u'django-geonames-field Documentation',
[u'Savio Abuga'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'django-geonames-field', u'django-geonames-field Documentation',
u'Savio Abuga', 'django-geonames-field', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
6114,
1209,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
377,
310,
1603,
348,
221,
1749,
6928,
26,
1479,
26,
1344,
6171,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
12,
747,
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,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
6525,
275,
747,
14,
9458,
342,
199,
1708,
275,
747,
14,
515,
14,
3475,
8,
6525,
9,
199,
1274,
14,
515,
14,
740,
8,
1708,
9,
199,
199,
646,
2312,
265,
14015,
63,
698,
199,
199,
3,
1553,
1696,
2897,
9527,
9858,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
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,
1345,
600,
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,
13,
4093,
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,
1715,
275,
399,
5121,
858,
13,
303,
265,
14015,
13,
698,
7,
199,
7307,
275,
399,
7,
7806,
12,
428,
7194,
79,
437,
1266,
65,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
2312,
265,
14015,
63,
698,
855,
1023,
363,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
2312,
265,
14015,
63,
698,
855,
1023,
363,
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,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
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,
199,
199,
3,
982,
2549,
12,
4215,
3598,
465,
298,
2253,
1245,
2,
26603,
315,
314,
6137,
8247,
14,
199,
3,
3250,
63,
5451,
275,
756,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
9527,
2595,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
6114,
1209,
3794,
1900,
2897,
570,
12,
2737,
701,
199,
3,
15882,
13,
28957,
641,
377,
310,
1603,
348,
221,
1749,
6928,
26,
1479,
26,
1344,
6171,
14,
199,
3,
199,
3,
961,
570,
365,
22711,
342,
68,
543,
314,
1453,
2082,
663,
370,
2399,
3035,
2935,
14,
199,
3,
199,
3,
3390,
626,
440,
1006,
3962,
2897,
1338,
787,
3451,
315,
642,
199,
3,
18392,
570,
14,
199,
3,
199,
3,
2900,
2897,
1338,
1172,
282,
849,
27,
1338,
626,
787,
21804,
734,
199,
3,
14062,
370,
2498,
314,
849,
14,
199,
199,
646,
984,
12,
747,
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,
3176,
8,
16,
12,
747,
14,
515,
14,
4832,
24535,
199,
199,
6525,
275,
747,
14,
9458,
342,
199,
1708,
275,
747,
14,
515,
14,
3475,
8,
6525,
9,
199,
1274,
14,
515,
14,
740,
8,
1708,
9,
199,
199,
646,
2312,
265,
14015,
63,
698,
199,
199,
3,
1553,
1696,
2897,
9527,
9858,
199,
199,
3,
982,
2195,
3794,
4839,
282,
13460,
10229,
1015,
12,
1174,
652,
2348,
14,
199,
3,
10065,
63,
8008,
275,
283,
17,
14,
16,
7,
199,
199,
3,
2654,
1263,
10229,
3329,
859,
1561,
2348,
12,
465,
3326,
14,
9322,
883,
506,
5478,
199,
3,
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,
1345,
600,
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,
13,
4093,
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,
1715,
275,
399,
5121,
858,
13,
303,
265,
14015,
13,
698,
7,
199,
7307,
275,
399,
7,
7806,
12,
428,
7194,
79,
437,
1266,
65,
7,
199,
199,
3,
710,
1015,
2256,
367,
314,
2199,
1265,
3984,
29904,
12,
17795,
465,
8343,
367,
199,
3,
1204,
1023,
92,
436,
1204,
3221,
18712,
2597,
1202,
315,
7750,
1163,
9825,
23088,
314,
199,
3,
6137,
8247,
14,
199,
3,
199,
3,
710,
3974,
1323,
14,
57,
1015,
14,
199,
1023,
275,
2312,
265,
14015,
63,
698,
855,
1023,
363,
199,
3,
710,
2615,
1015,
12,
5893,
5131,
15,
5683,
15,
1195,
3762,
14,
199,
3221,
275,
2312,
265,
14015,
63,
698,
855,
1023,
363,
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,
7970,
12,
3847,
370,
1350,
2082,
12,
626,
1336,
1584,
436,
199,
3,
6602,
370,
3686,
1380,
10023,
367,
1350,
1584,
14,
199,
5473,
63,
7435,
275,
4044,
1506,
418,
199,
199,
3,
710,
20883,
849,
4719,
334,
2972,
367,
642,
9189,
26,
658,
505,
10522,
370,
675,
367,
1006,
8247,
14,
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,
199,
199,
3,
982,
2549,
12,
4215,
3598,
465,
298,
2253,
1245,
2,
26603,
315,
314,
6137,
8247,
14,
199,
3,
3250,
63,
5451,
275,
756,
421,
199,
3,
1553,
8394,
367,
4163,
1072,
9527,
2595,
199,
199,
3,
710,
8879,
370,
675,
367,
4163,
436,
4163,
15456,
6497,
14,
221,
1666,
314,
3794,
367,
199,
3,
282,
769,
402,
6762,
17915,
14,
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,
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,
1
] |
chachan/nodeshot
|
nodeshot/core/base/mixins.py
|
5
|
1879
|
"""
reusable restframework mixins for API views
"""
import reversion
from rest_framework.response import Response
class ACLMixin(object):
""" implements ACL in views """
def get_queryset(self):
"""
Returns only objects which are accessible to the current user.
If user is not authenticated all public objects will be returned.
Model must implement AccessLevelManager!
"""
return self.queryset.all().accessible_to(user=self.request.user)
class RevisionUpdate(object):
"""
Mixin that adds compatibility with django reversion for PUT and PATCH requests
"""
def put(self, request, *args, **kwargs):
""" custom put method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
return self.update(request, *args, **kwargs)
def patch(self, request, *args, **kwargs):
""" custom patch method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('changed through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
kwargs['partial'] = True
return self.update(request, *args, **kwargs)
class RevisionCreate(object):
"""
Mixin that adds compatibility with django reversion for POST requests
"""
def post(self, request, *args, **kwargs):
""" custom put method to support django-reversion """
with reversion.create_revision():
reversion.set_user(request.user)
reversion.set_comment('created through the RESTful API from ip %s' % request.META['REMOTE_ADDR'])
return self.create(request, *args, **kwargs)
|
gpl-3.0
|
[
624,
199,
264,
14418,
4618,
4857,
13667,
3617,
367,
3261,
6858,
199,
624,
199,
199,
646,
295,
1023,
199,
504,
4618,
63,
4857,
14,
1310,
492,
7232,
421,
199,
533,
16543,
4256,
8,
785,
304,
272,
408,
9031,
16543,
315,
6858,
408,
339,
347,
664,
63,
7924,
8,
277,
304,
267,
408,
267,
1803,
1454,
2251,
1314,
787,
17909,
370,
314,
1453,
922,
14,
267,
982,
922,
365,
440,
15082,
1006,
4575,
2251,
911,
506,
2138,
14,
398,
5822,
1471,
5669,
11003,
4670,
2988,
1,
267,
408,
267,
372,
291,
14,
7924,
14,
452,
1252,
24669,
63,
475,
8,
751,
29,
277,
14,
1069,
14,
751,
9,
421,
199,
533,
27095,
4152,
8,
785,
304,
272,
408,
272,
28438,
626,
9584,
7163,
543,
1639,
295,
1023,
367,
18337,
436,
510,
8078,
4145,
272,
408,
339,
347,
5324,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
3537,
5324,
1083,
370,
2291,
1639,
13,
264,
1023,
408,
267,
543,
295,
1023,
14,
981,
63,
5792,
837,
288,
295,
1023,
14,
409,
63,
751,
8,
1069,
14,
751,
9,
288,
295,
1023,
14,
409,
63,
3349,
360,
2489,
4012,
314,
14880,
1893,
3261,
687,
3384,
450,
83,
7,
450,
1056,
14,
10614,
459,
16058,
63,
7803,
1105,
288,
372,
291,
14,
873,
8,
1069,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3371,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
3537,
3371,
1083,
370,
2291,
1639,
13,
264,
1023,
408,
267,
543,
295,
1023,
14,
981,
63,
5792,
837,
288,
295,
1023,
14,
409,
63,
751,
8,
1069,
14,
751,
9,
288,
295,
1023,
14,
409,
63,
3349,
360,
2489,
4012,
314,
14880,
1893,
3261,
687,
3384,
450,
83,
7,
450,
1056,
14,
10614,
459,
16058,
63,
7803,
1105,
288,
2074,
459,
6672,
418,
275,
715,
288,
372,
291,
14,
873,
8,
1069,
12,
627,
589,
12,
1011,
958,
9,
421,
199,
533,
27095,
2499,
8,
785,
304,
272,
408,
272,
28438,
626,
9584,
7163,
543,
1639,
295,
1023,
367,
8761,
4145,
272,
408,
339,
347,
2963,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
3537,
5324,
1083,
370,
2291,
1639,
13,
264,
1023,
408,
267,
543,
295,
1023,
14,
981,
63,
5792,
837,
288,
295,
1023,
14,
409,
63,
751,
8,
1069,
14,
751,
9,
288,
295,
1023,
14,
409,
63,
3349,
360,
3966,
4012,
314,
14880,
1893,
3261,
687,
3384,
450,
83,
7,
450,
1056,
14,
10614,
459,
16058,
63,
7803,
1105,
288,
372,
291,
14,
981,
8,
1069,
12,
627,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
264,
14418,
4618,
4857,
13667,
3617,
367,
3261,
6858,
199,
624,
199,
199,
646,
295,
1023,
199,
504,
4618,
63,
4857,
14,
1310,
492,
7232,
421,
199,
533,
16543,
4256,
8,
785,
304,
272,
408,
9031,
16543,
315,
6858,
408,
339,
347,
664,
63,
7924,
8,
277,
304,
267,
408,
267,
1803,
1454,
2251,
1314,
787,
17909,
370,
314,
1453,
922,
14,
267,
982,
922,
365,
440,
15082,
1006,
4575,
2251,
911,
506,
2138,
14,
398,
5822,
1471,
5669,
11003,
4670,
2988,
1,
267,
408,
267,
372,
291,
14,
7924,
14,
452,
1252,
24669,
63,
475,
8,
751,
29,
277,
14,
1069,
14,
751,
9,
421,
199,
533,
27095,
4152,
8,
785,
304,
272,
408,
272,
28438,
626,
9584,
7163,
543,
1639,
295,
1023,
367,
18337,
436,
510,
8078,
4145,
272,
408,
339,
347,
5324,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
3537,
5324,
1083,
370,
2291,
1639,
13,
264,
1023,
408,
267,
543,
295,
1023,
14,
981,
63,
5792,
837,
288,
295,
1023,
14,
409,
63,
751,
8,
1069,
14,
751,
9,
288,
295,
1023,
14,
409,
63,
3349,
360,
2489,
4012,
314,
14880,
1893,
3261,
687,
3384,
450,
83,
7,
450,
1056,
14,
10614,
459,
16058,
63,
7803,
1105,
288,
372,
291,
14,
873,
8,
1069,
12,
627,
589,
12,
1011,
958,
9,
339,
347,
3371,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
3537,
3371,
1083,
370,
2291,
1639,
13,
264,
1023,
408,
267,
543,
295,
1023,
14,
981,
63,
5792,
837,
288,
295,
1023,
14,
409,
63,
751,
8,
1069,
14,
751,
9,
288,
295,
1023,
14,
409,
63,
3349,
360,
2489,
4012,
314,
14880,
1893,
3261,
687,
3384,
450,
83,
7,
450,
1056,
14,
10614,
459,
16058,
63,
7803,
1105,
288,
2074,
459,
6672,
418,
275,
715,
288,
372,
291,
14,
873,
8,
1069,
12,
627,
589,
12,
1011,
958,
9,
421,
199,
533,
27095,
2499,
8,
785,
304,
272,
408,
272,
28438,
626,
9584,
7163,
543,
1639,
295,
1023,
367,
8761,
4145,
272,
408,
339,
347,
2963,
8,
277,
12,
1056,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
3537,
5324,
1083,
370,
2291,
1639,
13,
264,
1023,
408,
267,
543,
295,
1023,
14,
981,
63,
5792,
837,
288,
295,
1023,
14,
409,
63,
751,
8,
1069,
14,
751,
9,
288,
295,
1023,
14,
409,
63,
3349,
360,
3966,
4012,
314,
14880,
1893,
3261,
687,
3384,
450,
83,
7,
450,
1056,
14,
10614,
459,
16058,
63,
7803,
1105,
288,
372,
291,
14,
981,
8,
1069,
12,
627,
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,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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,
0,
0,
0
] |
sharifmamun/ansible
|
v1/ansible/runner/lookup_plugins/pipe.py
|
162
|
1951
|
# (c) 2012, Daniel Hokka Zakrisson <daniel@hozac.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/>.
import subprocess
from ansible import utils, errors
class LookupModule(object):
def __init__(self, basedir=None, **kwargs):
self.basedir = basedir
def run(self, terms, inject=None, **kwargs):
terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject)
if isinstance(terms, basestring):
terms = [ terms ]
ret = []
for term in terms:
'''
http://docs.python.org/2/library/subprocess.html#popen-constructor
The shell argument (which defaults to False) specifies whether to use the
shell as the program to execute. If shell is True, it is recommended to pass
args as a string rather than as a sequence
https://github.com/ansible/ansible/issues/6550
'''
term = str(term)
p = subprocess.Popen(term, cwd=self.basedir, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if p.returncode == 0:
ret.append(stdout.decode("utf-8").rstrip())
else:
raise errors.AnsibleError("lookup_plugin.pipe(%s) returned %d" % (term, p.returncode))
return ret
|
gpl-3.0
|
[
3,
334,
67,
9,
6029,
12,
24747,
14769,
869,
745,
7351,
3107,
1151,
322,
385,
265,
665,
24863,
14769,
32,
526,
90,
645,
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,
646,
3873,
199,
504,
3242,
492,
3778,
12,
2552,
199,
199,
533,
12785,
2377,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
19380,
29,
403,
12,
1011,
958,
304,
267,
291,
14,
12484,
275,
19380,
339,
347,
1255,
8,
277,
12,
2895,
12,
16182,
29,
403,
12,
1011,
958,
304,
398,
2895,
275,
3778,
14,
513,
2021,
63,
3892,
63,
2718,
63,
9187,
8,
9187,
12,
291,
14,
12484,
12,
16182,
9,
24807,
340,
1228,
8,
9187,
12,
7116,
304,
288,
2895,
275,
359,
2895,
1622,
24807,
2203,
275,
942,
267,
367,
6707,
315,
2895,
26,
288,
1449,
288,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
18,
15,
4342,
15,
5781,
14,
1360,
3,
12207,
13,
1880,
953,
710,
5218,
1423,
334,
6777,
4243,
370,
756,
9,
9314,
3775,
370,
675,
314,
7205,
5218,
465,
314,
2240,
370,
5341,
14,
982,
5218,
365,
715,
12,
652,
365,
14318,
370,
986,
7205,
1249,
465,
282,
1059,
7830,
2419,
465,
282,
3414,
953,
4178,
921,
5031,
14,
957,
15,
4853,
15,
4853,
15,
10115,
15,
10027,
16,
288,
1449,
288,
6707,
275,
620,
8,
5125,
9,
953,
299,
275,
3873,
14,
7942,
8,
5125,
12,
8288,
29,
277,
14,
12484,
12,
5218,
29,
549,
12,
9009,
29,
5781,
14,
6089,
12,
3839,
29,
5781,
14,
6089,
9,
288,
334,
2703,
12,
4635,
9,
275,
299,
14,
10664,
342,
288,
340,
299,
14,
9913,
508,
378,
26,
355,
2203,
14,
740,
8,
2703,
14,
2708,
480,
1624,
13,
24,
3471,
6735,
1012,
288,
587,
26,
355,
746,
2552,
14,
29107,
480,
3892,
63,
2718,
14,
4990,
4042,
83,
9,
2138,
450,
68,
2,
450,
334,
5125,
12,
299,
14,
9913,
430,
267,
372,
2203,
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
] |
[
334,
67,
9,
6029,
12,
24747,
14769,
869,
745,
7351,
3107,
1151,
322,
385,
265,
665,
24863,
14769,
32,
526,
90,
645,
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,
646,
3873,
199,
504,
3242,
492,
3778,
12,
2552,
199,
199,
533,
12785,
2377,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
19380,
29,
403,
12,
1011,
958,
304,
267,
291,
14,
12484,
275,
19380,
339,
347,
1255,
8,
277,
12,
2895,
12,
16182,
29,
403,
12,
1011,
958,
304,
398,
2895,
275,
3778,
14,
513,
2021,
63,
3892,
63,
2718,
63,
9187,
8,
9187,
12,
291,
14,
12484,
12,
16182,
9,
24807,
340,
1228,
8,
9187,
12,
7116,
304,
288,
2895,
275,
359,
2895,
1622,
24807,
2203,
275,
942,
267,
367,
6707,
315,
2895,
26,
288,
1449,
288,
1455,
921,
4757,
14,
1548,
14,
1308,
15,
18,
15,
4342,
15,
5781,
14,
1360,
3,
12207,
13,
1880,
953,
710,
5218,
1423,
334,
6777,
4243,
370,
756,
9,
9314,
3775,
370,
675,
314,
7205,
5218,
465,
314,
2240,
370,
5341,
14,
982,
5218,
365,
715,
12,
652,
365,
14318,
370,
986,
7205,
1249,
465,
282,
1059,
7830,
2419,
465,
282,
3414,
953,
4178,
921,
5031,
14,
957,
15,
4853,
15,
4853,
15,
10115,
15,
10027,
16,
288,
1449,
288,
6707,
275,
620,
8,
5125,
9,
953,
299,
275,
3873,
14,
7942,
8,
5125,
12,
8288,
29,
277,
14,
12484,
12,
5218,
29,
549,
12,
9009,
29,
5781,
14,
6089,
12,
3839,
29,
5781,
14,
6089,
9,
288,
334,
2703,
12,
4635,
9,
275,
299,
14,
10664,
342,
288,
340,
299,
14,
9913,
508,
378,
26,
355,
2203,
14,
740,
8,
2703,
14,
2708,
480,
1624,
13,
24,
3471,
6735,
1012,
288,
587,
26,
355,
746,
2552,
14,
29107,
480,
3892,
63,
2718,
14,
4990,
4042,
83,
9,
2138,
450,
68,
2,
450,
334,
5125,
12,
299,
14,
9913,
430,
267,
372,
2203,
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,
32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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
tuanavu/python-cookbook-3rd
|
src/6/reading_nested_and_variable_sized_binary_structures/example2.py
|
5
|
1825
|
# Example 2: Introduction of a metaclass
import struct
class StructField:
def __init__(self, format, offset):
self.format = format
self.offset = offset
def __get__(self, instance, cls):
if instance is None:
return self
else:
r = struct.unpack_from(self.format,
instance._buffer, self.offset)
return r[0] if len(r) == 1 else r
class StructureMeta(type):
'''
Metaclass that automatically creates StructField descriptors
'''
def __init__(self, clsname, bases, clsdict):
fields = getattr(self, '_fields_', [])
byte_order = ''
offset = 0
for format, fieldname in fields:
if format.startswith(('<','>','!','@')):
byte_order = format[0]
format = format[1:]
format = byte_order + format
setattr(self, fieldname, StructField(format, offset))
offset += struct.calcsize(format)
setattr(self, 'struct_size', offset)
class Structure(metaclass=StructureMeta):
def __init__(self, bytedata):
self._buffer = memoryview(bytedata)
@classmethod
def from_file(cls, f):
return cls(f.read(cls.struct_size))
if __name__ == '__main__':
class PolyHeader(Structure):
_fields_ = [
('<i', 'file_code'),
('d', 'min_x'),
('d', 'min_y'),
('d', 'max_x'),
('d', 'max_y'),
('i', 'num_polys')
]
f = open('polys.bin','rb')
phead = PolyHeader.from_file(f)
print(phead.file_code == 0x1234)
print('min_x=', phead.min_x)
print('max_x=', phead.max_x)
print('min_y=', phead.min_y)
print('max_y=', phead.max_y)
print('num_polys=', phead.num_polys)
|
mit
|
[
3,
5679,
499,
26,
9805,
293,
5199,
402,
282,
17074,
199,
199,
646,
2702,
199,
199,
533,
13039,
792,
26,
272,
347,
636,
826,
721,
277,
12,
1475,
12,
3268,
304,
267,
291,
14,
908,
275,
1475,
267,
291,
14,
2743,
275,
3268,
272,
347,
636,
362,
721,
277,
12,
1256,
12,
843,
304,
267,
340,
1256,
365,
488,
26,
288,
372,
291,
267,
587,
26,
288,
519,
275,
221,
2702,
14,
5301,
63,
504,
8,
277,
14,
908,
12,
221,
2511,
1256,
423,
2738,
12,
291,
14,
2743,
9,
288,
372,
519,
59,
16,
61,
340,
822,
8,
82,
9,
508,
413,
587,
519,
268,
199,
533,
21730,
3396,
8,
466,
304,
272,
1449,
272,
6288,
533,
626,
5847,
8491,
13039,
792,
15428,
272,
1449,
272,
347,
636,
826,
721,
277,
12,
843,
354,
12,
9768,
12,
843,
807,
304,
267,
1504,
275,
2519,
8,
277,
12,
2513,
955,
14474,
3073,
267,
3696,
63,
1648,
275,
2125,
267,
3268,
275,
378,
267,
367,
1475,
12,
18887,
315,
1504,
26,
288,
340,
1475,
14,
2460,
4725,
28,
1673,
30,
1673,
1,
1673,
32,
8109,
355,
3696,
63,
1648,
275,
1475,
59,
16,
61,
355,
1475,
275,
1475,
59,
17,
2938,
288,
1475,
275,
3696,
63,
1648,
435,
1475,
288,
5371,
8,
277,
12,
18887,
12,
13039,
792,
8,
908,
12,
3268,
430,
288,
3268,
847,
2702,
14,
21691,
8,
908,
9,
267,
5371,
8,
277,
12,
283,
1820,
63,
890,
297,
3268,
9,
199,
199,
533,
21730,
8,
6577,
29,
10766,
3396,
304,
272,
347,
636,
826,
721,
277,
12,
701,
471,
419,
304,
267,
291,
423,
2738,
275,
20228,
8,
991,
471,
419,
9,
339,
768,
3744,
272,
347,
687,
63,
493,
8,
1886,
12,
289,
304,
267,
372,
843,
8,
70,
14,
739,
8,
1886,
14,
1820,
63,
890,
430,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1021,
16869,
2567,
8,
10766,
304,
267,
485,
955,
63,
275,
359,
288,
19990,
73,
297,
283,
493,
63,
600,
659,
288,
661,
68,
297,
283,
827,
63,
88,
659,
288,
661,
68,
297,
283,
827,
63,
89,
659,
288,
661,
68,
297,
283,
988,
63,
88,
659,
288,
661,
68,
297,
283,
988,
63,
89,
659,
288,
661,
73,
297,
283,
1507,
63,
15743,
358,
288,
1622,
339,
289,
275,
1551,
360,
15743,
14,
1393,
1673,
4848,
358,
272,
299,
2993,
275,
16869,
2567,
14,
504,
63,
493,
8,
70,
9,
272,
870,
8,
80,
2993,
14,
493,
63,
600,
508,
378,
88,
4321,
9,
272,
870,
360,
827,
63,
88,
4009,
299,
2993,
14,
827,
63,
88,
9,
272,
870,
360,
988,
63,
88,
4009,
299,
2993,
14,
988,
63,
88,
9,
272,
870,
360,
827,
63,
89,
4009,
299,
2993,
14,
827,
63,
89,
9,
272,
870,
360,
988,
63,
89,
4009,
299,
2993,
14,
988,
63,
89,
9,
272,
870,
360,
1507,
63,
15743,
4009,
299,
2993,
14,
1507,
63,
15743,
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
] |
[
5679,
499,
26,
9805,
293,
5199,
402,
282,
17074,
199,
199,
646,
2702,
199,
199,
533,
13039,
792,
26,
272,
347,
636,
826,
721,
277,
12,
1475,
12,
3268,
304,
267,
291,
14,
908,
275,
1475,
267,
291,
14,
2743,
275,
3268,
272,
347,
636,
362,
721,
277,
12,
1256,
12,
843,
304,
267,
340,
1256,
365,
488,
26,
288,
372,
291,
267,
587,
26,
288,
519,
275,
221,
2702,
14,
5301,
63,
504,
8,
277,
14,
908,
12,
221,
2511,
1256,
423,
2738,
12,
291,
14,
2743,
9,
288,
372,
519,
59,
16,
61,
340,
822,
8,
82,
9,
508,
413,
587,
519,
268,
199,
533,
21730,
3396,
8,
466,
304,
272,
1449,
272,
6288,
533,
626,
5847,
8491,
13039,
792,
15428,
272,
1449,
272,
347,
636,
826,
721,
277,
12,
843,
354,
12,
9768,
12,
843,
807,
304,
267,
1504,
275,
2519,
8,
277,
12,
2513,
955,
14474,
3073,
267,
3696,
63,
1648,
275,
2125,
267,
3268,
275,
378,
267,
367,
1475,
12,
18887,
315,
1504,
26,
288,
340,
1475,
14,
2460,
4725,
28,
1673,
30,
1673,
1,
1673,
32,
8109,
355,
3696,
63,
1648,
275,
1475,
59,
16,
61,
355,
1475,
275,
1475,
59,
17,
2938,
288,
1475,
275,
3696,
63,
1648,
435,
1475,
288,
5371,
8,
277,
12,
18887,
12,
13039,
792,
8,
908,
12,
3268,
430,
288,
3268,
847,
2702,
14,
21691,
8,
908,
9,
267,
5371,
8,
277,
12,
283,
1820,
63,
890,
297,
3268,
9,
199,
199,
533,
21730,
8,
6577,
29,
10766,
3396,
304,
272,
347,
636,
826,
721,
277,
12,
701,
471,
419,
304,
267,
291,
423,
2738,
275,
20228,
8,
991,
471,
419,
9,
339,
768,
3744,
272,
347,
687,
63,
493,
8,
1886,
12,
289,
304,
267,
372,
843,
8,
70,
14,
739,
8,
1886,
14,
1820,
63,
890,
430,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1021,
16869,
2567,
8,
10766,
304,
267,
485,
955,
63,
275,
359,
288,
19990,
73,
297,
283,
493,
63,
600,
659,
288,
661,
68,
297,
283,
827,
63,
88,
659,
288,
661,
68,
297,
283,
827,
63,
89,
659,
288,
661,
68,
297,
283,
988,
63,
88,
659,
288,
661,
68,
297,
283,
988,
63,
89,
659,
288,
661,
73,
297,
283,
1507,
63,
15743,
358,
288,
1622,
339,
289,
275,
1551,
360,
15743,
14,
1393,
1673,
4848,
358,
272,
299,
2993,
275,
16869,
2567,
14,
504,
63,
493,
8,
70,
9,
272,
870,
8,
80,
2993,
14,
493,
63,
600,
508,
378,
88,
4321,
9,
272,
870,
360,
827,
63,
88,
4009,
299,
2993,
14,
827,
63,
88,
9,
272,
870,
360,
988,
63,
88,
4009,
299,
2993,
14,
988,
63,
88,
9,
272,
870,
360,
827,
63,
89,
4009,
299,
2993,
14,
827,
63,
89,
9,
272,
870,
360,
988,
63,
89,
4009,
299,
2993,
14,
988,
63,
89,
9,
272,
870,
360,
1507,
63,
15743,
4009,
299,
2993,
14,
1507,
63,
15743,
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,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,
0,
0
] |
stvstnfrd/edx-platform
|
openedx/core/lib/hash_utils.py
|
9
|
1136
|
"""
Utilities related to hashing
This duplicates functionality in django-oauth-provider,
specifically long_token and short token functions which was used to create
random tokens
"""
import hashlib
from django.utils.encoding import force_bytes
from django.utils.crypto import get_random_string
from django.conf import settings
def create_hash256(max_length=None):
"""
Generate a hash that can be used as an application secret
Warning: this is not sufficiently secure for tasks like encription
Currently, this is just meant to create sufficiently random tokens
"""
hash_object = hashlib.sha256(force_bytes(get_random_string(32)))
hash_object.update(force_bytes(settings.SECRET_KEY))
output_hash = hash_object.hexdigest()
if max_length is not None and len(output_hash) > max_length:
return output_hash[:max_length]
return output_hash
def short_token():
"""
Generates a hash of length 32
Warning: this is not sufficiently secure for tasks like encription
Currently, this is just meant to create sufficiently random tokens
"""
return create_hash256(max_length=32)
|
agpl-3.0
|
[
624,
199,
22905,
4048,
370,
25223,
199,
199,
2765,
15755,
9330,
315,
1639,
13,
6126,
13,
3780,
12,
199,
6100,
1183,
1846,
63,
1418,
436,
3974,
1526,
3423,
1314,
1990,
1202,
370,
1218,
199,
2355,
4645,
199,
624,
199,
646,
8337,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
199,
504,
1639,
14,
1208,
14,
10316,
492,
664,
63,
2355,
63,
875,
199,
504,
1639,
14,
2190,
492,
2202,
421,
199,
318,
1218,
63,
2227,
3912,
8,
988,
63,
1267,
29,
403,
304,
272,
408,
272,
7958,
282,
2631,
626,
883,
506,
1202,
465,
376,
4223,
7565,
272,
15902,
26,
642,
365,
440,
19258,
590,
11153,
367,
6527,
2839,
655,
4802,
272,
13550,
12,
642,
365,
2951,
18329,
370,
1218,
19258,
590,
2196,
4645,
272,
408,
272,
2631,
63,
785,
275,
8337,
14,
4835,
3912,
8,
3990,
63,
2394,
8,
362,
63,
2355,
63,
875,
8,
708,
1724,
272,
2631,
63,
785,
14,
873,
8,
3990,
63,
2394,
8,
1751,
14,
12961,
63,
3078,
430,
272,
1072,
63,
2227,
275,
2631,
63,
785,
14,
11453,
342,
272,
340,
1390,
63,
1267,
365,
440,
488,
436,
822,
8,
1199,
63,
2227,
9,
690,
1390,
63,
1267,
26,
267,
372,
1072,
63,
2227,
1491,
988,
63,
1267,
61,
272,
372,
1072,
63,
2227,
421,
199,
318,
3974,
63,
1418,
837,
272,
408,
272,
21687,
282,
2631,
402,
2582,
4337,
272,
15902,
26,
642,
365,
440,
19258,
590,
11153,
367,
6527,
2839,
655,
4802,
272,
13550,
12,
642,
365,
2951,
18329,
370,
1218,
19258,
590,
2196,
4645,
272,
408,
272,
372,
1218,
63,
2227,
3912,
8,
988,
63,
1267,
29,
708,
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,
32768,
32768,
32768,
32768,
32768
] |
[
199,
22905,
4048,
370,
25223,
199,
199,
2765,
15755,
9330,
315,
1639,
13,
6126,
13,
3780,
12,
199,
6100,
1183,
1846,
63,
1418,
436,
3974,
1526,
3423,
1314,
1990,
1202,
370,
1218,
199,
2355,
4645,
199,
624,
199,
646,
8337,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2394,
199,
504,
1639,
14,
1208,
14,
10316,
492,
664,
63,
2355,
63,
875,
199,
504,
1639,
14,
2190,
492,
2202,
421,
199,
318,
1218,
63,
2227,
3912,
8,
988,
63,
1267,
29,
403,
304,
272,
408,
272,
7958,
282,
2631,
626,
883,
506,
1202,
465,
376,
4223,
7565,
272,
15902,
26,
642,
365,
440,
19258,
590,
11153,
367,
6527,
2839,
655,
4802,
272,
13550,
12,
642,
365,
2951,
18329,
370,
1218,
19258,
590,
2196,
4645,
272,
408,
272,
2631,
63,
785,
275,
8337,
14,
4835,
3912,
8,
3990,
63,
2394,
8,
362,
63,
2355,
63,
875,
8,
708,
1724,
272,
2631,
63,
785,
14,
873,
8,
3990,
63,
2394,
8,
1751,
14,
12961,
63,
3078,
430,
272,
1072,
63,
2227,
275,
2631,
63,
785,
14,
11453,
342,
272,
340,
1390,
63,
1267,
365,
440,
488,
436,
822,
8,
1199,
63,
2227,
9,
690,
1390,
63,
1267,
26,
267,
372,
1072,
63,
2227,
1491,
988,
63,
1267,
61,
272,
372,
1072,
63,
2227,
421,
199,
318,
3974,
63,
1418,
837,
272,
408,
272,
21687,
282,
2631,
402,
2582,
4337,
272,
15902,
26,
642,
365,
440,
19258,
590,
11153,
367,
6527,
2839,
655,
4802,
272,
13550,
12,
642,
365,
2951,
18329,
370,
1218,
19258,
590,
2196,
4645,
272,
408,
272,
372,
1218,
63,
2227,
3912,
8,
988,
63,
1267,
29,
708,
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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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
] |
rzhxeo/youtube-dl
|
youtube_dl/extractor/motorsport.py
|
129
|
1797
|
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import (
compat_urlparse,
)
class MotorsportIE(InfoExtractor):
IE_DESC = 'motorsport.com'
_VALID_URL = r'http://www\.motorsport\.com/[^/?#]+/video/(?:[^/?#]+/)(?P<id>[^/]+)/?(?:$|[?#])'
_TEST = {
'url': 'http://www.motorsport.com/f1/video/main-gallery/red-bull-racing-2014-rules-explained/',
'info_dict': {
'id': '2-T3WuR-KMM',
'ext': 'mp4',
'title': 'Red Bull Racing: 2014 Rules Explained',
'duration': 208,
'description': 'A new clip from Red Bull sees Daniel Ricciardo and Sebastian Vettel explain the 2014 Formula One regulations – which are arguably the most complex the sport has ever seen.',
'uploader': 'mcomstaff',
'uploader_id': 'UC334JIYKkVnyFoNCclfZtHQ',
'upload_date': '20140903',
'thumbnail': r're:^https?://.+\.jpg$'
},
'add_ie': ['Youtube'],
'params': {
'skip_download': True,
},
}
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
iframe_path = self._html_search_regex(
r'<iframe id="player_iframe"[^>]+src="([^"]+)"', webpage,
'iframe path')
iframe = self._download_webpage(
compat_urlparse.urljoin(url, iframe_path), display_id,
'Downloading iframe')
youtube_id = self._search_regex(
r'www.youtube.com/embed/(.{11})', iframe, 'youtube id')
return {
'_type': 'url_transparent',
'display_id': display_id,
'url': 'https://youtube.com/watch?v=%s' % youtube_id,
}
|
unlicense
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
334,
272,
8434,
63,
10290,
12,
199,
9,
421,
199,
533,
603,
13147,
3275,
4332,
8,
18283,
304,
272,
15292,
63,
15119,
275,
283,
27840,
3275,
14,
957,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
1014,
921,
1544,
4537,
27840,
3275,
4537,
957,
15,
4735,
10197,
3,
2807,
15,
3722,
32576,
4735,
10197,
3,
2807,
15,
18168,
48,
28,
344,
26906,
2447,
31,
5169,
4,
17884,
31,
3,
566,
7,
272,
485,
2864,
275,
469,
267,
283,
633,
356,
283,
1014,
921,
1544,
14,
27840,
3275,
14,
957,
15,
70,
17,
15,
3722,
15,
973,
13,
25372,
15,
581,
13,
66,
979,
13,
345,
4477,
13,
7280,
13,
4423,
13,
1474,
23918,
3678,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
18,
13,
52,
19,
25728,
50,
13,
43,
3218,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
10858,
699,
979,
820,
645,
316,
26,
6927,
24259,
7910,
23918,
297,
288,
283,
5553,
356,
29203,
12,
288,
283,
1802,
356,
283,
33,
892,
11353,
687,
9572,
699,
979,
542,
397,
24747,
14769,
820,
530,
559,
1005,
79,
436,
428,
2871,
1810,
5653,
812,
386,
14146,
27797,
314,
6927,
8204,
7586,
7309,
1295,
21429,
27430,
242,
1314,
787,
1680,
85,
6665,
314,
4750,
6114,
314,
308,
719,
965,
14433,
6775,
3130,
288,
283,
13671,
356,
283,
77,
957,
7018,
297,
288,
283,
13671,
63,
344,
356,
283,
13371,
8425,
32126,
57,
43,
75,
54,
9745,
15563,
6389,
9694,
58,
84,
27497,
297,
288,
283,
5064,
63,
602,
356,
283,
7280,
1643,
1644,
297,
288,
283,
8311,
356,
519,
3984,
23497,
2859,
14144,
6977,
4537,
8476,
12913,
267,
1660,
267,
283,
525,
63,
1873,
356,
788,
57,
7715,
995,
267,
283,
1162,
356,
469,
288,
283,
2759,
63,
4249,
356,
715,
12,
267,
1660,
272,
789,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
2929,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
267,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
2929,
63,
344,
9,
398,
340,
1186,
63,
515,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7601,
20052,
1305,
628,
6147,
63,
20052,
2,
25524,
2164,
32391,
297,
9248,
12,
288,
283,
20052,
931,
358,
267,
340,
1186,
275,
291,
423,
4249,
63,
12022,
8,
288,
8434,
63,
10290,
14,
17755,
8,
633,
12,
340,
1186,
63,
515,
395,
2929,
63,
344,
12,
288,
283,
18085,
340,
1186,
358,
267,
22378,
63,
344,
275,
291,
423,
1733,
63,
3821,
8,
288,
519,
7,
1544,
14,
9788,
14,
957,
15,
6427,
7985,
23379,
845,
25583,
340,
1186,
12,
283,
9788,
1305,
358,
398,
372,
469,
288,
2513,
466,
356,
283,
633,
63,
24420,
297,
288,
283,
2918,
63,
344,
356,
2929,
63,
344,
12,
288,
283,
633,
356,
283,
2859,
921,
9788,
14,
957,
15,
6821,
31,
86,
2458,
83,
7,
450,
22378,
63,
344,
12,
267,
789,
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
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
334,
272,
8434,
63,
10290,
12,
199,
9,
421,
199,
533,
603,
13147,
3275,
4332,
8,
18283,
304,
272,
15292,
63,
15119,
275,
283,
27840,
3275,
14,
957,
7,
272,
485,
5600,
63,
2632,
275,
519,
7,
1014,
921,
1544,
4537,
27840,
3275,
4537,
957,
15,
4735,
10197,
3,
2807,
15,
3722,
32576,
4735,
10197,
3,
2807,
15,
18168,
48,
28,
344,
26906,
2447,
31,
5169,
4,
17884,
31,
3,
566,
7,
272,
485,
2864,
275,
469,
267,
283,
633,
356,
283,
1014,
921,
1544,
14,
27840,
3275,
14,
957,
15,
70,
17,
15,
3722,
15,
973,
13,
25372,
15,
581,
13,
66,
979,
13,
345,
4477,
13,
7280,
13,
4423,
13,
1474,
23918,
3678,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
18,
13,
52,
19,
25728,
50,
13,
43,
3218,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
10858,
699,
979,
820,
645,
316,
26,
6927,
24259,
7910,
23918,
297,
288,
283,
5553,
356,
29203,
12,
288,
283,
1802,
356,
283,
33,
892,
11353,
687,
9572,
699,
979,
542,
397,
24747,
14769,
820,
530,
559,
1005,
79,
436,
428,
2871,
1810,
5653,
812,
386,
14146,
27797,
314,
6927,
8204,
7586,
7309,
1295,
21429,
27430,
242,
1314,
787,
1680,
85,
6665,
314,
4750,
6114,
314,
308,
719,
965,
14433,
6775,
3130,
288,
283,
13671,
356,
283,
77,
957,
7018,
297,
288,
283,
13671,
63,
344,
356,
283,
13371,
8425,
32126,
57,
43,
75,
54,
9745,
15563,
6389,
9694,
58,
84,
27497,
297,
288,
283,
5064,
63,
602,
356,
283,
7280,
1643,
1644,
297,
288,
283,
8311,
356,
519,
3984,
23497,
2859,
14144,
6977,
4537,
8476,
12913,
267,
1660,
267,
283,
525,
63,
1873,
356,
788,
57,
7715,
995,
267,
283,
1162,
356,
469,
288,
283,
2759,
63,
4249,
356,
715,
12,
267,
1660,
272,
789,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
2929,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
267,
9248,
275,
291,
423,
4249,
63,
12022,
8,
633,
12,
2929,
63,
344,
9,
398,
340,
1186,
63,
515,
275,
291,
423,
1360,
63,
1733,
63,
3821,
8,
288,
519,
7601,
20052,
1305,
628,
6147,
63,
20052,
2,
25524,
2164,
32391,
297,
9248,
12,
288,
283,
20052,
931,
358,
267,
340,
1186,
275,
291,
423,
4249,
63,
12022,
8,
288,
8434,
63,
10290,
14,
17755,
8,
633,
12,
340,
1186,
63,
515,
395,
2929,
63,
344,
12,
288,
283,
18085,
340,
1186,
358,
267,
22378,
63,
344,
275,
291,
423,
1733,
63,
3821,
8,
288,
519,
7,
1544,
14,
9788,
14,
957,
15,
6427,
7985,
23379,
845,
25583,
340,
1186,
12,
283,
9788,
1305,
358,
398,
372,
469,
288,
2513,
466,
356,
283,
633,
63,
24420,
297,
288,
283,
2918,
63,
344,
356,
2929,
63,
344,
12,
288,
283,
633,
356,
283,
2859,
921,
9788,
14,
957,
15,
6821,
31,
86,
2458,
83,
7,
450,
22378,
63,
344,
12,
267,
789,
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,
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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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
] |
movermeyer/cabot
|
cabot/cabotapp/migrations/0015_auto__add_field_alertacknowledgement_cancelled_time__add_field_alertac.py
|
5
|
16689
|
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'AlertAcknowledgement.cancelled_time'
db.add_column(u'cabotapp_alertacknowledgement', 'cancelled_time',
self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True),
keep_default=False)
# Adding field 'AlertAcknowledgement.cancelled_user'
db.add_column(u'cabotapp_alertacknowledgement', 'cancelled_user',
self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='cancelleduser_set', null=True, to=orm['auth.User']),
keep_default=False)
def backwards(self, orm):
# Deleting field 'AlertAcknowledgement.cancelled_time'
db.delete_column(u'cabotapp_alertacknowledgement', 'cancelled_time')
# Deleting field 'AlertAcknowledgement.cancelled_user'
db.delete_column(u'cabotapp_alertacknowledgement', 'cancelled_user_id')
models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'cabotapp.alertacknowledgement': {
'Meta': {'object_name': 'AlertAcknowledgement'},
'cancelled_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'cancelled_user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'cancelleduser_set'", 'null': 'True', 'to': u"orm['auth.User']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'service': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['cabotapp.Service']"}),
'time': ('django.db.models.fields.DateTimeField', [], {}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
},
u'cabotapp.alertplugin': {
'Meta': {'object_name': 'AlertPlugin'},
'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'polymorphic_cabotapp.alertplugin_set'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}),
'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'cabotapp.alertpluginuserdata': {
'Meta': {'unique_together': "(('title', 'user'),)", 'object_name': 'AlertPluginUserData'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'polymorphic_cabotapp.alertpluginuserdata_set'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['cabotapp.UserProfile']"})
},
u'cabotapp.instance': {
'Meta': {'ordering': "['name']", 'object_name': 'Instance'},
'address': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'alerts': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['cabotapp.AlertPlugin']", 'symmetrical': 'False', 'blank': 'True'}),
'alerts_enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'email_alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'hackpad_id': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'hipchat_alert': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_alert_sent': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'old_overall_status': ('django.db.models.fields.TextField', [], {'default': "'PASSING'"}),
'overall_status': ('django.db.models.fields.TextField', [], {'default': "'PASSING'"}),
'sms_alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'status_checks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['cabotapp.StatusCheck']", 'symmetrical': 'False', 'blank': 'True'}),
'telephone_alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'users_to_notify': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.User']", 'symmetrical': 'False', 'blank': 'True'})
},
u'cabotapp.instancestatussnapshot': {
'Meta': {'object_name': 'InstanceStatusSnapshot'},
'did_send_alert': ('django.db.models.fields.IntegerField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instance': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'snapshots'", 'to': u"orm['cabotapp.Instance']"}),
'num_checks_active': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'num_checks_failing': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'num_checks_passing': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'overall_status': ('django.db.models.fields.TextField', [], {'default': "'PASSING'"}),
'time': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'})
},
u'cabotapp.service': {
'Meta': {'ordering': "['name']", 'object_name': 'Service'},
'alerts': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['cabotapp.AlertPlugin']", 'symmetrical': 'False', 'blank': 'True'}),
'alerts_enabled': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'email_alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'hackpad_id': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'hipchat_alert': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instances': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['cabotapp.Instance']", 'symmetrical': 'False', 'blank': 'True'}),
'last_alert_sent': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'old_overall_status': ('django.db.models.fields.TextField', [], {'default': "'PASSING'"}),
'overall_status': ('django.db.models.fields.TextField', [], {'default': "'PASSING'"}),
'sms_alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'status_checks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['cabotapp.StatusCheck']", 'symmetrical': 'False', 'blank': 'True'}),
'telephone_alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'url': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'users_to_notify': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.User']", 'symmetrical': 'False', 'blank': 'True'})
},
u'cabotapp.servicestatussnapshot': {
'Meta': {'object_name': 'ServiceStatusSnapshot'},
'did_send_alert': ('django.db.models.fields.IntegerField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'num_checks_active': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'num_checks_failing': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'num_checks_passing': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'overall_status': ('django.db.models.fields.TextField', [], {'default': "'PASSING'"}),
'service': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'snapshots'", 'to': u"orm['cabotapp.Service']"}),
'time': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'})
},
u'cabotapp.shift': {
'Meta': {'object_name': 'Shift'},
'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'end': ('django.db.models.fields.DateTimeField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'start': ('django.db.models.fields.DateTimeField', [], {}),
'uid': ('django.db.models.fields.TextField', [], {}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
},
u'cabotapp.statuscheck': {
'Meta': {'ordering': "['name']", 'object_name': 'StatusCheck'},
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'allowed_num_failures': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True'}),
'cached_health': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'calculated_status': ('django.db.models.fields.CharField', [], {'default': "'passing'", 'max_length': '50', 'blank': 'True'}),
'check_type': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'}),
'debounce': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True'}),
'endpoint': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'expected_num_hosts': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True'}),
'frequency': ('django.db.models.fields.IntegerField', [], {'default': '5'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'importance': ('django.db.models.fields.CharField', [], {'default': "'ERROR'", 'max_length': '30'}),
'last_run': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'max_queued_build_time': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
'metric': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'password': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'polymorphic_cabotapp.statuscheck_set'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}),
'status_code': ('django.db.models.fields.TextField', [], {'default': '200', 'null': 'True'}),
'text_match': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'timeout': ('django.db.models.fields.IntegerField', [], {'default': '30', 'null': 'True'}),
'username': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'value': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'verify_ssl_certificate': ('django.db.models.fields.BooleanField', [], {'default': 'True'})
},
u'cabotapp.statuscheckresult': {
'Meta': {'ordering': "['-time_complete']", 'object_name': 'StatusCheckResult'},
'check': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['cabotapp.StatusCheck']"}),
'error': ('django.db.models.fields.TextField', [], {'null': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'job_number': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'raw_data': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'succeeded': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'time': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
'time_complete': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'})
},
u'cabotapp.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'fallback_alert_user': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'hipchat_alias': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'mobile_number': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'blank': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': u"orm['auth.User']"})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
}
}
complete_apps = ['cabotapp']
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
1208,
492,
2197,
63,
1208,
465,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
327,
12934,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
521,
7,
267,
1592,
14,
525,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
521,
297,
1993,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
1993,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
751,
7,
267,
1592,
14,
525,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
751,
297,
1993,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2500,
29,
549,
12,
4048,
63,
354,
534,
21924,
751,
63,
409,
297,
2973,
29,
549,
12,
370,
29,
1025,
459,
1178,
14,
1899,
3815,
1993,
4215,
63,
885,
29,
797,
9,
2378,
347,
8552,
8,
277,
12,
9813,
304,
267,
327,
15920,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
521,
7,
267,
1592,
14,
1807,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
521,
358,
398,
327,
15920,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
751,
7,
267,
1592,
14,
1807,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
751,
63,
344,
358,
2378,
1709,
275,
469,
267,
399,
7,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
288,
399,
7,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
399,
2,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
399,
7,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
7340,
85,
7,
1317,
63,
466,
363,
571,
63,
1302,
297,
399,
7,
1317,
63,
466,
363,
1238,
297,
399,
7,
11879,
18106,
283,
3235,
63,
6314,
356,
298,
1332,
85,
7,
1317,
63,
466,
297,
399,
7,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
399,
2,
1025,
459,
10778,
14,
11282,
6097,
288,
399,
7,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
399,
7,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2246,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2634,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
10247,
356,
283,
797,
297,
283,
2407,
63,
354,
356,
298,
85,
7,
751,
63,
409,
4662,
283,
2500,
356,
283,
549,
297,
283,
475,
356,
399,
2,
1025,
459,
1178,
14,
2448,
6097,
288,
399,
7,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
2682,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
549,
1604,
288,
283,
374,
63,
7018,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
374,
63,
11434,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
2019,
63,
2886,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2019,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
3933,
1604,
288,
283,
751,
63,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
10247,
356,
283,
797,
297,
283,
2407,
63,
354,
356,
298,
85,
7,
751,
63,
409,
4662,
283,
2500,
356,
283,
549,
297,
283,
475,
356,
399,
2,
1025,
459,
1178,
14,
7980,
6097,
288,
283,
2473,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1216,
3071,
267,
1660,
267,
399,
7,
26481,
357,
571,
14,
29706,
13058
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
504,
12919,
14,
1208,
492,
2197,
63,
1208,
465,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
421,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
267,
327,
12934,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
521,
7,
267,
1592,
14,
525,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
521,
297,
1993,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
1993,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
751,
7,
267,
1592,
14,
525,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
751,
297,
1993,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
7533,
2500,
29,
549,
12,
4048,
63,
354,
534,
21924,
751,
63,
409,
297,
2973,
29,
549,
12,
370,
29,
1025,
459,
1178,
14,
1899,
3815,
1993,
4215,
63,
885,
29,
797,
9,
2378,
347,
8552,
8,
277,
12,
9813,
304,
267,
327,
15920,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
521,
7,
267,
1592,
14,
1807,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
521,
358,
398,
327,
15920,
901,
283,
18758,
9940,
23504,
434,
14,
21924,
63,
751,
7,
267,
1592,
14,
1807,
63,
2301,
8,
85,
7,
26481,
357,
571,
63,
29706,
13058,
23504,
434,
297,
283,
21924,
63,
751,
63,
344,
358,
2378,
1709,
275,
469,
267,
399,
7,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
288,
399,
7,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
399,
2,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
399,
7,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
7128,
356,
7340,
85,
7,
1317,
63,
466,
363,
571,
63,
1302,
297,
399,
7,
1317,
63,
466,
363,
1238,
297,
399,
7,
11879,
18106,
283,
3235,
63,
6314,
356,
298,
1332,
85,
7,
1317,
63,
466,
297,
399,
7,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
399,
2,
1025,
459,
10778,
14,
11282,
6097,
288,
399,
7,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
399,
7,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2246,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2634,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
10247,
356,
283,
797,
297,
283,
2407,
63,
354,
356,
298,
85,
7,
751,
63,
409,
4662,
283,
2500,
356,
283,
549,
297,
283,
475,
356,
399,
2,
1025,
459,
1178,
14,
2448,
6097,
288,
399,
7,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
2682,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
549,
1604,
288,
283,
374,
63,
7018,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
374,
63,
11434,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
1604,
288,
283,
2019,
63,
2886,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2019,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
3933,
1604,
288,
283,
751,
63,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
10247,
356,
283,
797,
297,
283,
2407,
63,
354,
356,
298,
85,
7,
751,
63,
409,
4662,
283,
2500,
356,
283,
549,
297,
283,
475,
356,
399,
2,
1025,
459,
1178,
14,
7980,
6097,
288,
283,
2473,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1216,
3071,
267,
1660,
267,
399,
7,
26481,
357,
571,
14,
29706,
13058,
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,
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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
] |
jeremiahmarks/sl4a
|
python/src/Lib/bsddb/test/test_dbshelve.py
|
33
|
11290
|
"""
TestCases for checking dbShelve objects.
"""
import os, string
import random
import unittest
from test_all import db, dbshelve, test_support, verbose, \
get_new_environment_path, get_new_database_path
#----------------------------------------------------------------------
# We want the objects to be comparable so we can test dbshelve.values
# later on.
class DataClass:
def __init__(self):
self.value = random.random()
def __repr__(self) : # For Python 3.0 comparison
return "DataClass %f" %self.value
def __cmp__(self, other): # For Python 2.x comparison
return cmp(self.value, other)
class DBShelveTestCase(unittest.TestCase):
def setUp(self):
import sys
if sys.version_info[0] >= 3 :
from test_all import do_proxy_db_py3k
self._flag_proxy_db_py3k = do_proxy_db_py3k(False)
self.filename = get_new_database_path()
self.do_open()
def tearDown(self):
import sys
if sys.version_info[0] >= 3 :
from test_all import do_proxy_db_py3k
do_proxy_db_py3k(self._flag_proxy_db_py3k)
self.do_close()
test_support.unlink(self.filename)
def mk(self, key):
"""Turn key into an appropriate key type for this db"""
# override in child class for RECNO
import sys
if sys.version_info[0] < 3 :
return key
else :
return bytes(key, "iso8859-1") # 8 bits
def populateDB(self, d):
for x in string.letters:
d[self.mk('S' + x)] = 10 * x # add a string
d[self.mk('I' + x)] = ord(x) # add an integer
d[self.mk('L' + x)] = [x] * 10 # add a list
inst = DataClass() # add an instance
inst.S = 10 * x
inst.I = ord(x)
inst.L = [x] * 10
d[self.mk('O' + x)] = inst
# overridable in derived classes to affect how the shelf is created/opened
def do_open(self):
self.d = dbshelve.open(self.filename)
# and closed...
def do_close(self):
self.d.close()
def test01_basics(self):
if verbose:
print '\n', '-=' * 30
print "Running %s.test01_basics..." % self.__class__.__name__
self.populateDB(self.d)
self.d.sync()
self.do_close()
self.do_open()
d = self.d
l = len(d)
k = d.keys()
s = d.stat()
f = d.fd()
if verbose:
print "length:", l
print "keys:", k
print "stats:", s
self.assertEqual(0, d.has_key(self.mk('bad key')))
self.assertEqual(1, d.has_key(self.mk('IA')))
self.assertEqual(1, d.has_key(self.mk('OA')))
d.delete(self.mk('IA'))
del d[self.mk('OA')]
self.assertEqual(0, d.has_key(self.mk('IA')))
self.assertEqual(0, d.has_key(self.mk('OA')))
self.assertEqual(len(d), l-2)
values = []
for key in d.keys():
value = d[key]
values.append(value)
if verbose:
print "%s: %s" % (key, value)
self.checkrec(key, value)
dbvalues = d.values()
self.assertEqual(len(dbvalues), len(d.keys()))
import sys
if sys.version_info[0] < 3 :
values.sort()
dbvalues.sort()
self.assertEqual(values, dbvalues)
else : # XXX: Convert all to strings. Please, improve
values.sort(key=lambda x : str(x))
dbvalues.sort(key=lambda x : str(x))
self.assertEqual(repr(values), repr(dbvalues))
items = d.items()
self.assertEqual(len(items), len(values))
for key, value in items:
self.checkrec(key, value)
self.assertEqual(d.get(self.mk('bad key')), None)
self.assertEqual(d.get(self.mk('bad key'), None), None)
self.assertEqual(d.get(self.mk('bad key'), 'a string'), 'a string')
self.assertEqual(d.get(self.mk('bad key'), [1, 2, 3]), [1, 2, 3])
d.set_get_returns_none(0)
self.assertRaises(db.DBNotFoundError, d.get, self.mk('bad key'))
d.set_get_returns_none(1)
d.put(self.mk('new key'), 'new data')
self.assertEqual(d.get(self.mk('new key')), 'new data')
self.assertEqual(d[self.mk('new key')], 'new data')
def test02_cursors(self):
if verbose:
print '\n', '-=' * 30
print "Running %s.test02_cursors..." % self.__class__.__name__
self.populateDB(self.d)
d = self.d
count = 0
c = d.cursor()
rec = c.first()
while rec is not None:
count = count + 1
if verbose:
print rec
key, value = rec
self.checkrec(key, value)
# Hack to avoid conversion by 2to3 tool
rec = getattr(c, "next")()
del c
self.assertEqual(count, len(d))
count = 0
c = d.cursor()
rec = c.last()
while rec is not None:
count = count + 1
if verbose:
print rec
key, value = rec
self.checkrec(key, value)
rec = c.prev()
self.assertEqual(count, len(d))
c.set(self.mk('SS'))
key, value = c.current()
self.checkrec(key, value)
del c
def test03_append(self):
# NOTE: this is overridden in RECNO subclass, don't change its name.
if verbose:
print '\n', '-=' * 30
print "Running %s.test03_append..." % self.__class__.__name__
self.assertRaises(dbshelve.DBShelveError,
self.d.append, 'unit test was here')
def checkrec(self, key, value):
# override this in a subclass if the key type is different
import sys
if sys.version_info[0] >= 3 :
if isinstance(key, bytes) :
key = key.decode("iso8859-1") # 8 bits
x = key[1]
if key[0] == 'S':
self.assertEqual(type(value), str)
self.assertEqual(value, 10 * x)
elif key[0] == 'I':
self.assertEqual(type(value), int)
self.assertEqual(value, ord(x))
elif key[0] == 'L':
self.assertEqual(type(value), list)
self.assertEqual(value, [x] * 10)
elif key[0] == 'O':
import sys
if sys.version_info[0] < 3 :
from types import InstanceType
self.assertEqual(type(value), InstanceType)
else :
self.assertEqual(type(value), DataClass)
self.assertEqual(value.S, 10 * x)
self.assertEqual(value.I, ord(x))
self.assertEqual(value.L, [x] * 10)
else:
self.assert_(0, 'Unknown key type, fix the test')
#----------------------------------------------------------------------
class BasicShelveTestCase(DBShelveTestCase):
def do_open(self):
self.d = dbshelve.DBShelf()
self.d.open(self.filename, self.dbtype, self.dbflags)
def do_close(self):
self.d.close()
class BTreeShelveTestCase(BasicShelveTestCase):
dbtype = db.DB_BTREE
dbflags = db.DB_CREATE
class HashShelveTestCase(BasicShelveTestCase):
dbtype = db.DB_HASH
dbflags = db.DB_CREATE
class ThreadBTreeShelveTestCase(BasicShelveTestCase):
dbtype = db.DB_BTREE
dbflags = db.DB_CREATE | db.DB_THREAD
class ThreadHashShelveTestCase(BasicShelveTestCase):
dbtype = db.DB_HASH
dbflags = db.DB_CREATE | db.DB_THREAD
#----------------------------------------------------------------------
class BasicEnvShelveTestCase(DBShelveTestCase):
def do_open(self):
self.env = db.DBEnv()
self.env.open(self.homeDir,
self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE)
self.filename = os.path.split(self.filename)[1]
self.d = dbshelve.DBShelf(self.env)
self.d.open(self.filename, self.dbtype, self.dbflags)
def do_close(self):
self.d.close()
self.env.close()
def setUp(self) :
self.homeDir = get_new_environment_path()
DBShelveTestCase.setUp(self)
def tearDown(self):
import sys
if sys.version_info[0] >= 3 :
from test_all import do_proxy_db_py3k
do_proxy_db_py3k(self._flag_proxy_db_py3k)
self.do_close()
test_support.rmtree(self.homeDir)
class EnvBTreeShelveTestCase(BasicEnvShelveTestCase):
envflags = 0
dbtype = db.DB_BTREE
dbflags = db.DB_CREATE
class EnvHashShelveTestCase(BasicEnvShelveTestCase):
envflags = 0
dbtype = db.DB_HASH
dbflags = db.DB_CREATE
class EnvThreadBTreeShelveTestCase(BasicEnvShelveTestCase):
envflags = db.DB_THREAD
dbtype = db.DB_BTREE
dbflags = db.DB_CREATE | db.DB_THREAD
class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
envflags = db.DB_THREAD
dbtype = db.DB_HASH
dbflags = db.DB_CREATE | db.DB_THREAD
#----------------------------------------------------------------------
# test cases for a DBShelf in a RECNO DB.
class RecNoShelveTestCase(BasicShelveTestCase):
dbtype = db.DB_RECNO
dbflags = db.DB_CREATE
def setUp(self):
BasicShelveTestCase.setUp(self)
# pool to assign integer key values out of
self.key_pool = list(range(1, 5000))
self.key_map = {} # map string keys to the number we gave them
self.intkey_map = {} # reverse map of above
def mk(self, key):
if key not in self.key_map:
self.key_map[key] = self.key_pool.pop(0)
self.intkey_map[self.key_map[key]] = key
return self.key_map[key]
def checkrec(self, intkey, value):
key = self.intkey_map[intkey]
BasicShelveTestCase.checkrec(self, key, value)
def test03_append(self):
if verbose:
print '\n', '-=' * 30
print "Running %s.test03_append..." % self.__class__.__name__
self.d[1] = 'spam'
self.d[5] = 'eggs'
self.assertEqual(6, self.d.append('spam'))
self.assertEqual(7, self.d.append('baked beans'))
self.assertEqual('spam', self.d.get(6))
self.assertEqual('spam', self.d.get(1))
self.assertEqual('baked beans', self.d.get(7))
self.assertEqual('eggs', self.d.get(5))
#----------------------------------------------------------------------
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(DBShelveTestCase))
suite.addTest(unittest.makeSuite(BTreeShelveTestCase))
suite.addTest(unittest.makeSuite(HashShelveTestCase))
suite.addTest(unittest.makeSuite(ThreadBTreeShelveTestCase))
suite.addTest(unittest.makeSuite(ThreadHashShelveTestCase))
suite.addTest(unittest.makeSuite(EnvBTreeShelveTestCase))
suite.addTest(unittest.makeSuite(EnvHashShelveTestCase))
suite.addTest(unittest.makeSuite(EnvThreadBTreeShelveTestCase))
suite.addTest(unittest.makeSuite(EnvThreadHashShelveTestCase))
suite.addTest(unittest.makeSuite(RecNoShelveTestCase))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
|
apache-2.0
|
[
624,
199,
19346,
367,
7907,
1592,
2662,
15320,
2251,
14,
199,
624,
199,
199,
646,
747,
12,
1059,
199,
646,
2196,
199,
646,
2882,
421,
199,
504,
511,
63,
452,
492,
1592,
12,
1592,
609,
15320,
12,
511,
63,
4058,
12,
3376,
12,
971,
267,
664,
63,
1222,
63,
5418,
63,
515,
12,
664,
63,
1222,
63,
4659,
63,
515,
4388,
199,
7656,
8648,
199,
199,
3,
2136,
2934,
314,
2251,
370,
506,
1013,
19816,
880,
781,
883,
511,
1592,
609,
15320,
14,
1459,
199,
3,
2945,
641,
14,
199,
533,
3918,
2543,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
585,
275,
2196,
14,
2355,
342,
339,
347,
636,
2722,
721,
277,
9,
520,
221,
327,
2104,
2018,
650,
14,
16,
9132,
267,
372,
298,
1451,
2543,
450,
70,
2,
450,
277,
14,
585,
339,
347,
636,
5730,
721,
277,
12,
1163,
304,
221,
327,
2104,
2018,
499,
14,
88,
9132,
267,
372,
10467,
8,
277,
14,
585,
12,
1163,
9,
421,
199,
533,
6249,
2662,
15320,
1746,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
520,
288,
687,
511,
63,
452,
492,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
288,
291,
423,
4173,
63,
3280,
63,
697,
63,
647,
19,
75,
275,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
8,
797,
9,
267,
291,
14,
1501,
275,
664,
63,
1222,
63,
4659,
63,
515,
342,
267,
291,
14,
1117,
63,
1490,
342,
339,
347,
6766,
8,
277,
304,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
520,
288,
687,
511,
63,
452,
492,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
288,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
8,
277,
423,
4173,
63,
3280,
63,
697,
63,
647,
19,
75,
9,
267,
291,
14,
1117,
63,
1600,
342,
267,
511,
63,
4058,
14,
7162,
8,
277,
14,
1501,
9,
339,
347,
9199,
8,
277,
12,
790,
304,
267,
408,
16838,
790,
1901,
376,
5827,
790,
730,
367,
642,
1592,
624,
267,
327,
4278,
315,
1982,
1021,
367,
19461,
2826,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
520,
288,
372,
790,
267,
587,
520,
288,
372,
2783,
8,
498,
12,
298,
4595,
4830,
13,
17,
531,
221,
327,
1695,
5821,
339,
347,
13904,
2846,
8,
277,
12,
366,
304,
267,
367,
671,
315,
1059,
14,
16415,
26,
288,
366,
59,
277,
14,
3880,
360,
51,
7,
435,
671,
1874,
275,
1616,
627,
671,
3698,
327,
1050,
282,
1059,
288,
366,
59,
277,
14,
3880,
360,
41,
7,
435,
671,
1874,
275,
6206,
8,
88,
9,
3698,
327,
1050,
376,
3000,
288,
366,
59,
277,
14,
3880,
360,
44,
7,
435,
671,
1874,
275,
359,
88,
61,
627,
1616,
260,
327,
1050,
282,
769,
953,
2727,
275,
3918,
2543,
342,
3322,
327,
1050,
376,
1256,
288,
2727,
14,
51,
275,
1616,
627,
671,
288,
2727,
14,
41,
275,
6206,
8,
88,
9,
288,
2727,
14,
44,
275,
359,
88,
61,
627,
1616,
288,
366,
59,
277,
14,
3880,
360,
47,
7,
435,
671,
1874,
275,
2727,
2378,
327,
1806,
1677,
461,
315,
7131,
3992,
370,
12787,
4212,
314,
21920,
276,
365,
2737,
15,
19234,
272,
347,
886,
63,
1490,
8,
277,
304,
267,
291,
14,
68,
275,
1592,
609,
15320,
14,
1490,
8,
277,
14,
1501,
9,
339,
327,
436,
6876,
1396,
272,
347,
886,
63,
1600,
8,
277,
304,
267,
291,
14,
68,
14,
1600,
342,
16478,
347,
511,
614,
63,
4316,
83,
8,
277,
304,
267,
340,
3376,
26,
288,
870,
1557,
78,
297,
2475,
534,
627,
4233,
288,
870,
298,
9602,
450,
83,
14,
396,
614,
63,
4316,
83,
11500,
450,
291,
855,
533,
4914,
354,
363,
398,
291,
14,
13817,
2846,
8,
277,
14,
68,
9,
267,
291,
14,
68,
14,
5186,
342,
267,
291,
14,
1117,
63,
1600,
342,
267,
291,
14,
1117,
63,
1490,
342,
267,
366,
275,
291,
14,
68,
398,
634,
275,
822,
8,
68,
9,
267,
1022,
275,
366,
14,
1612,
342,
267,
308,
275,
366,
14,
3736,
342,
267,
289,
275,
366,
14,
2592,
342,
398,
340,
3376,
26,
288,
870,
298,
1267,
6783,
634,
288,
870,
298,
1612,
6783,
1022,
288,
870,
298,
3200,
6783,
308,
398,
291,
14,
629,
8,
16,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
4087,
790,
7058,
267,
291,
14,
629,
8,
17,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
13033,
7058,
267,
291,
14,
629,
8,
17,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
47,
33,
7058,
398,
366,
14,
1807,
8,
277,
14,
3880,
360,
13033,
1333,
267,
2150,
366,
59,
277,
14,
3880,
360,
47,
33,
5440,
267,
291,
14,
629,
8,
16,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
13033,
7058,
267,
291,
14,
629,
8,
16,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
47,
33,
7058,
267,
291,
14,
629,
8,
552,
8,
68,
395,
634,
13,
18,
9,
398,
1338,
275,
942,
267,
367,
790,
315,
366,
14,
1612,
837,
288,
574,
275,
366,
59,
498,
61,
288,
1338,
14,
740,
8,
585,
9,
288,
340,
3376,
26,
355,
870,
2071,
83,
26,
450,
83,
2,
450,
334,
498,
12,
574,
9,
288,
291,
14,
1074,
2761,
8,
498,
12,
574,
9,
398,
1592,
1459,
275,
366,
14,
1459,
342,
267,
291,
14,
629,
8,
552,
8,
697,
1459,
395,
822,
8,
68,
14,
1612,
4059,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
520,
288,
1338,
14,
3191,
342,
288,
1592,
1459,
14,
3191,
342,
288,
291,
14,
629,
8,
1459,
12,
1592,
1459,
9,
267,
587,
520,
221,
327,
5787,
26,
7905,
1006,
370,
3326,
14,
7754,
12,
19053,
288,
1338,
14,
3191,
8,
498,
29,
2734,
671,
520,
620,
8,
88,
430,
288,
1592,
1459,
14,
3191,
8,
498,
29,
2734,
671,
520,
620,
8,
88,
430,
288
] |
[
199,
19346,
367,
7907,
1592,
2662,
15320,
2251,
14,
199,
624,
199,
199,
646,
747,
12,
1059,
199,
646,
2196,
199,
646,
2882,
421,
199,
504,
511,
63,
452,
492,
1592,
12,
1592,
609,
15320,
12,
511,
63,
4058,
12,
3376,
12,
971,
267,
664,
63,
1222,
63,
5418,
63,
515,
12,
664,
63,
1222,
63,
4659,
63,
515,
4388,
199,
7656,
8648,
199,
199,
3,
2136,
2934,
314,
2251,
370,
506,
1013,
19816,
880,
781,
883,
511,
1592,
609,
15320,
14,
1459,
199,
3,
2945,
641,
14,
199,
533,
3918,
2543,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
585,
275,
2196,
14,
2355,
342,
339,
347,
636,
2722,
721,
277,
9,
520,
221,
327,
2104,
2018,
650,
14,
16,
9132,
267,
372,
298,
1451,
2543,
450,
70,
2,
450,
277,
14,
585,
339,
347,
636,
5730,
721,
277,
12,
1163,
304,
221,
327,
2104,
2018,
499,
14,
88,
9132,
267,
372,
10467,
8,
277,
14,
585,
12,
1163,
9,
421,
199,
533,
6249,
2662,
15320,
1746,
8,
2796,
14,
1746,
304,
272,
347,
3613,
8,
277,
304,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
520,
288,
687,
511,
63,
452,
492,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
288,
291,
423,
4173,
63,
3280,
63,
697,
63,
647,
19,
75,
275,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
8,
797,
9,
267,
291,
14,
1501,
275,
664,
63,
1222,
63,
4659,
63,
515,
342,
267,
291,
14,
1117,
63,
1490,
342,
339,
347,
6766,
8,
277,
304,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
2356,
650,
520,
288,
687,
511,
63,
452,
492,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
288,
886,
63,
3280,
63,
697,
63,
647,
19,
75,
8,
277,
423,
4173,
63,
3280,
63,
697,
63,
647,
19,
75,
9,
267,
291,
14,
1117,
63,
1600,
342,
267,
511,
63,
4058,
14,
7162,
8,
277,
14,
1501,
9,
339,
347,
9199,
8,
277,
12,
790,
304,
267,
408,
16838,
790,
1901,
376,
5827,
790,
730,
367,
642,
1592,
624,
267,
327,
4278,
315,
1982,
1021,
367,
19461,
2826,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
520,
288,
372,
790,
267,
587,
520,
288,
372,
2783,
8,
498,
12,
298,
4595,
4830,
13,
17,
531,
221,
327,
1695,
5821,
339,
347,
13904,
2846,
8,
277,
12,
366,
304,
267,
367,
671,
315,
1059,
14,
16415,
26,
288,
366,
59,
277,
14,
3880,
360,
51,
7,
435,
671,
1874,
275,
1616,
627,
671,
3698,
327,
1050,
282,
1059,
288,
366,
59,
277,
14,
3880,
360,
41,
7,
435,
671,
1874,
275,
6206,
8,
88,
9,
3698,
327,
1050,
376,
3000,
288,
366,
59,
277,
14,
3880,
360,
44,
7,
435,
671,
1874,
275,
359,
88,
61,
627,
1616,
260,
327,
1050,
282,
769,
953,
2727,
275,
3918,
2543,
342,
3322,
327,
1050,
376,
1256,
288,
2727,
14,
51,
275,
1616,
627,
671,
288,
2727,
14,
41,
275,
6206,
8,
88,
9,
288,
2727,
14,
44,
275,
359,
88,
61,
627,
1616,
288,
366,
59,
277,
14,
3880,
360,
47,
7,
435,
671,
1874,
275,
2727,
2378,
327,
1806,
1677,
461,
315,
7131,
3992,
370,
12787,
4212,
314,
21920,
276,
365,
2737,
15,
19234,
272,
347,
886,
63,
1490,
8,
277,
304,
267,
291,
14,
68,
275,
1592,
609,
15320,
14,
1490,
8,
277,
14,
1501,
9,
339,
327,
436,
6876,
1396,
272,
347,
886,
63,
1600,
8,
277,
304,
267,
291,
14,
68,
14,
1600,
342,
16478,
347,
511,
614,
63,
4316,
83,
8,
277,
304,
267,
340,
3376,
26,
288,
870,
1557,
78,
297,
2475,
534,
627,
4233,
288,
870,
298,
9602,
450,
83,
14,
396,
614,
63,
4316,
83,
11500,
450,
291,
855,
533,
4914,
354,
363,
398,
291,
14,
13817,
2846,
8,
277,
14,
68,
9,
267,
291,
14,
68,
14,
5186,
342,
267,
291,
14,
1117,
63,
1600,
342,
267,
291,
14,
1117,
63,
1490,
342,
267,
366,
275,
291,
14,
68,
398,
634,
275,
822,
8,
68,
9,
267,
1022,
275,
366,
14,
1612,
342,
267,
308,
275,
366,
14,
3736,
342,
267,
289,
275,
366,
14,
2592,
342,
398,
340,
3376,
26,
288,
870,
298,
1267,
6783,
634,
288,
870,
298,
1612,
6783,
1022,
288,
870,
298,
3200,
6783,
308,
398,
291,
14,
629,
8,
16,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
4087,
790,
7058,
267,
291,
14,
629,
8,
17,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
13033,
7058,
267,
291,
14,
629,
8,
17,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
47,
33,
7058,
398,
366,
14,
1807,
8,
277,
14,
3880,
360,
13033,
1333,
267,
2150,
366,
59,
277,
14,
3880,
360,
47,
33,
5440,
267,
291,
14,
629,
8,
16,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
13033,
7058,
267,
291,
14,
629,
8,
16,
12,
366,
14,
1989,
63,
498,
8,
277,
14,
3880,
360,
47,
33,
7058,
267,
291,
14,
629,
8,
552,
8,
68,
395,
634,
13,
18,
9,
398,
1338,
275,
942,
267,
367,
790,
315,
366,
14,
1612,
837,
288,
574,
275,
366,
59,
498,
61,
288,
1338,
14,
740,
8,
585,
9,
288,
340,
3376,
26,
355,
870,
2071,
83,
26,
450,
83,
2,
450,
334,
498,
12,
574,
9,
288,
291,
14,
1074,
2761,
8,
498,
12,
574,
9,
398,
1592,
1459,
275,
366,
14,
1459,
342,
267,
291,
14,
629,
8,
552,
8,
697,
1459,
395,
822,
8,
68,
14,
1612,
4059,
267,
492,
984,
267,
340,
984,
14,
1023,
63,
815,
59,
16,
61,
665,
650,
520,
288,
1338,
14,
3191,
342,
288,
1592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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
] |
huxh10/iSDX
|
pctrl-sgdx/mds_lib.py
|
4
|
3123
|
def decompose_verbrokenheimerschnitzel(row_2_cols):
""" Input is a dictionary with matrix row IDs as keys and a list of each
row's contents (column indices of nonzero row entries) as a value.
BROKEN. DONUT USE.
"""
item_2_group = {}
item_buddies = {}
for group in row_2_cols.values():
for item in group:
# if we haven't seen this item before
if item not in item_2_group:
# initialize his mapping
item_2_group[item] = [group]
# and assume all his neighbors are buddies
item_buddies[item] = set(group)
# if we have seen him before
else:
# remove any fake buddies
item_buddies[item].intersection_update(group)
# update the mapping
item_2_group[item].append(group)
for item, buddies in item_buddies.iteritems():
item_buddies[item] = frozenset(buddies)
final_sets = {}
for row, group in row_2_cols.iteritems():
final_set = set([])
# add in all the corresponding prefix groups
for item in group:
final_set.add(item_buddies[item])
final_sets[row] = final_set
return final_sets
def decompose_sequential(col_2_rows):
""" Input is a dictionary with column IDs as keys and a list of each
column's contents (row indices of nonzero entries) as a value.
Input is a dictionary with prefixes as keys and lists of participants
as values. If a participant A has a route to p1, it will appear as
'sA' in the value list. If A is the default next-hop to p1, it will
also appear as 'bA' in the list.
Example: With participants [A,B,C] and prefixes [p1,p2,p3,p4],
an input could be {p1:[sA], p2:[sA,sB], p3:[sA,sB], p4:[sB,sC]}
Output is participant to prefix-group mapping.
Example: {sA:[[p1], [p2,p3]], sB:[[p2,p3], [p4]], sC:[[p4]]}
"""
# We will convert each column to a frozenset so that it can be hashed.
# By doing this, we can discover identical columns via hashing collisions.
# this dict recovers the original column IDs from each frozenset
froset_2_col = {}
# for each column
for col_id, col_contents in col_2_rows.iteritems():
# convert to a frozenset
froset = frozenset(col_contents)
# if we haven't see this exact column before
if froset not in froset_2_col:
# add a hash table entry
froset_2_col[froset] = []
# add it to the list of columns identical to it
froset_2_col[froset].append(col_id)
# The keys of froset_2_col are the unique columns we found.
# Unique columns correspond to prefix groups.
# For each participant in the column, add the associated prefix group
# to that participant's list of prefix groups
# this will be the final outout (i.e. participant_2_prefixGroups)
final_sets = {}
for froset, cols in froset_2_col.iteritems():
for row_id in froset:
if row_id not in final_sets:
final_sets[row_id] = []
final_sets[row_id].append(cols)
return final_sets
if __name__ == '__main__':
groups = {'a':[1,2,3], 'b':[2,3,4], 'c':[4]}
spuorg = {}
for key, values in groups.iteritems():
for item in values:
if item not in spuorg:
spuorg[item] = []
spuorg[item].append(key)
print groups
#print spuorg
print decompose_sequential(spuorg)
|
apache-2.0
|
[
318,
477,
12607,
63,
422,
15697,
426,
1036,
2393,
11019,
23751,
352,
8,
1143,
63,
18,
63,
4574,
304,
199,
198,
624,
6924,
365,
282,
2600,
543,
3634,
1962,
11449,
465,
2883,
436,
282,
769,
402,
1924,
507,
198,
1143,
1159,
4072,
334,
2301,
4918,
402,
23338,
1962,
4811,
9,
465,
282,
574,
14,
507,
198,
21111,
6945,
14,
577,
615,
934,
4815,
14,
199,
198,
624,
199,
198,
1053,
63,
18,
63,
923,
275,
1052,
199,
198,
1053,
63,
464,
68,
18245,
275,
1052,
199,
198,
509,
1572,
315,
1962,
63,
18,
63,
4574,
14,
1459,
837,
507,
198,
509,
1242,
315,
1572,
26,
686,
198,
3,
340,
781,
19051,
1133,
6775,
642,
1242,
2544,
686,
198,
692,
1242,
440,
315,
1242,
63,
18,
63,
923,
26,
1585,
198,
3,
8265,
17049,
4412,
1585,
198,
1053,
63,
18,
63,
923,
59,
1053,
61,
275,
359,
923,
61,
1585,
198,
3,
436,
5534,
1006,
17049,
15845,
787,
1032,
68,
18245,
1585,
198,
1053,
63,
464,
68,
18245,
59,
1053,
61,
275,
663,
8,
923,
9,
686,
198,
3,
340,
781,
1172,
6775,
26457,
2544,
686,
198,
2836,
26,
1585,
198,
3,
2813,
1263,
4026,
1032,
68,
18245,
1585,
198,
1053,
63,
464,
68,
18245,
59,
1053,
1055,
12569,
63,
873,
8,
923,
9,
1585,
198,
3,
1678,
314,
4412,
1585,
198,
1053,
63,
18,
63,
923,
59,
1053,
1055,
740,
8,
923,
9,
4388,
198,
509,
1242,
12,
1032,
68,
18245,
315,
1242,
63,
464,
68,
18245,
14,
4611,
837,
507,
198,
1053,
63,
464,
68,
18245,
59,
1053,
61,
275,
9522,
8,
464,
68,
18245,
9,
421,
198,
5094,
63,
2193,
275,
1052,
421,
198,
509,
1962,
12,
1572,
315,
1962,
63,
18,
63,
4574,
14,
4611,
837,
507,
198,
5094,
63,
409,
275,
663,
4157,
507,
198,
3,
1050,
315,
1006,
314,
5226,
2403,
4652,
507,
198,
509,
1242,
315,
1572,
26,
686,
198,
5094,
63,
409,
14,
525,
8,
1053,
63,
464,
68,
18245,
59,
1053,
566,
2742,
198,
5094,
63,
2193,
59,
1143,
61,
275,
4242,
63,
409,
4388,
198,
1107,
4242,
63,
2193,
6905,
421,
199,
318,
477,
12607,
63,
16211,
8,
761,
63,
18,
63,
3838,
304,
199,
198,
624,
6924,
365,
282,
2600,
543,
2763,
11449,
465,
2883,
436,
282,
769,
402,
1924,
507,
198,
2301,
1159,
4072,
334,
1143,
4918,
402,
23338,
4811,
9,
465,
282,
574,
14,
2742,
198,
3205,
365,
282,
2600,
543,
13158,
465,
2883,
436,
5548,
402,
623,
20989,
507,
198,
305,
1338,
14,
982,
282,
623,
16448,
437,
965,
282,
7475,
370,
299,
17,
12,
652,
911,
7468,
465,
507,
198,
1159,
33,
7,
315,
314,
574,
769,
14,
982,
437,
365,
314,
849,
2163,
13,
13376,
370,
299,
17,
12,
652,
911,
507,
198,
12344,
7468,
465,
283,
66,
33,
7,
315,
314,
769,
14,
2742,
198,
9846,
26,
8777,
623,
20989,
359,
33,
12,
34,
12,
35,
61,
436,
13158,
359,
80,
17,
12,
80,
18,
12,
80,
19,
12,
80,
20,
467,
507,
198,
290,
1324,
4293,
506,
469,
80,
17,
7766,
83,
33,
467,
299,
18,
7766,
83,
33,
12,
83,
34,
467,
299,
19,
7766,
83,
33,
12,
83,
34,
467,
299,
20,
7766,
83,
34,
12,
83,
35,
9420,
2742,
198,
2959,
365,
623,
16448,
370,
2403,
13,
923,
4412,
14,
507,
198,
9846,
26,
469,
83,
33,
7766,
59,
80,
17,
467,
359,
80,
18,
12,
80,
19,
2365,
308,
34,
7766,
59,
80,
18,
12,
80,
19,
467,
359,
80,
20,
2365,
308,
35,
7766,
59,
80,
20,
2677,
93,
199,
198,
624,
4388,
198,
3,
2136,
911,
3957,
1924,
2763,
370,
282,
9522,
880,
626,
652,
883,
506,
19871,
14,
199,
198,
3,
4885,
9689,
642,
12,
781,
883,
20131,
13130,
4362,
4799,
25223,
30063,
14,
421,
198,
3,
642,
1211,
22803,
83,
314,
3379,
2763,
11449,
687,
1924,
9522,
199,
198,
21775,
409,
63,
18,
63,
761,
275,
1052,
421,
198,
3,
367,
1924,
2763,
199,
198,
509,
1048,
63,
344,
12,
1048,
63,
4407,
315,
1048,
63,
18,
63,
3838,
14,
4611,
837,
507,
198,
3,
3957,
370,
282,
9522,
507,
198,
21775,
409,
275,
9522,
8,
761,
63,
4407,
9,
507,
198,
3,
340,
781,
19051,
1133,
1937,
642,
5835,
2763,
2544,
507,
198,
692,
26226,
409,
440,
315,
26226,
409,
63,
18,
63,
761,
26,
686,
198,
3,
1050,
282,
2631,
1817,
2397,
686,
198,
21775,
409,
63,
18,
63,
761,
59,
21775,
409,
61,
275,
942,
507,
198,
3,
1050,
652,
370,
314,
769,
402,
4362,
13130,
370,
652,
507,
198,
21775,
409,
63,
18,
63,
761,
59,
21775,
409,
1055,
740,
8,
761,
63,
344,
9,
4388,
198,
3,
710,
2883,
402,
26226,
409,
63,
18,
63,
761,
787,
314,
3747,
4362,
781,
1911,
14,
199,
198,
3,
18276,
4362,
17118,
370,
2403,
4652,
14,
421,
198,
3,
2104,
1924,
623,
16448,
315,
314,
2763,
12,
1050,
314,
4568,
2403,
1572,
199,
198,
3,
370,
626,
623,
16448,
1159,
769,
402,
2403,
4652,
421,
198,
3,
642,
911,
506,
314,
4242,
734,
548,
334,
73,
14,
69,
14,
623,
16448,
63,
18,
63,
1861,
10177,
9,
199,
198,
5094,
63,
2193,
275,
1052,
4388,
198,
509,
26226,
409,
12,
8850,
315,
26226,
409,
63,
18,
63,
761,
14,
4611,
837,
507,
198,
509,
1962,
63,
344,
315,
26226,
409,
26,
686,
198,
692,
1962,
63,
344,
440,
315,
4242,
63,
2193,
26,
1585,
198,
5094,
63,
2193,
59,
1143,
63,
344,
61,
275,
942,
686,
198,
5094,
63,
2193,
59,
1143,
63,
344,
1055,
740,
8,
4574,
9,
4388,
198,
1107,
4242,
63,
2193,
6905,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
198,
421,
198,
2634,
275,
791,
65,
15211,
17,
12,
18,
12,
19,
467,
283,
66,
15211,
18,
12,
19,
12,
20,
467,
283,
67,
15211,
20,
9420,
421,
198,
681,
85,
1308,
275,
1052,
199,
198,
509,
790,
12,
1338,
315,
4652,
14,
4611,
837,
507,
198,
509,
1242,
315,
1338,
26,
686,
198,
692,
1242,
440,
315,
2249,
85,
1308,
26,
1585,
198,
681,
85,
1308,
59,
1053,
61,
275,
942,
686,
198,
681,
85,
1308,
59,
1053,
1055
] |
[
477,
12607,
63,
422,
15697,
426,
1036,
2393,
11019,
23751,
352,
8,
1143,
63,
18,
63,
4574,
304,
199,
198,
624,
6924,
365,
282,
2600,
543,
3634,
1962,
11449,
465,
2883,
436,
282,
769,
402,
1924,
507,
198,
1143,
1159,
4072,
334,
2301,
4918,
402,
23338,
1962,
4811,
9,
465,
282,
574,
14,
507,
198,
21111,
6945,
14,
577,
615,
934,
4815,
14,
199,
198,
624,
199,
198,
1053,
63,
18,
63,
923,
275,
1052,
199,
198,
1053,
63,
464,
68,
18245,
275,
1052,
199,
198,
509,
1572,
315,
1962,
63,
18,
63,
4574,
14,
1459,
837,
507,
198,
509,
1242,
315,
1572,
26,
686,
198,
3,
340,
781,
19051,
1133,
6775,
642,
1242,
2544,
686,
198,
692,
1242,
440,
315,
1242,
63,
18,
63,
923,
26,
1585,
198,
3,
8265,
17049,
4412,
1585,
198,
1053,
63,
18,
63,
923,
59,
1053,
61,
275,
359,
923,
61,
1585,
198,
3,
436,
5534,
1006,
17049,
15845,
787,
1032,
68,
18245,
1585,
198,
1053,
63,
464,
68,
18245,
59,
1053,
61,
275,
663,
8,
923,
9,
686,
198,
3,
340,
781,
1172,
6775,
26457,
2544,
686,
198,
2836,
26,
1585,
198,
3,
2813,
1263,
4026,
1032,
68,
18245,
1585,
198,
1053,
63,
464,
68,
18245,
59,
1053,
1055,
12569,
63,
873,
8,
923,
9,
1585,
198,
3,
1678,
314,
4412,
1585,
198,
1053,
63,
18,
63,
923,
59,
1053,
1055,
740,
8,
923,
9,
4388,
198,
509,
1242,
12,
1032,
68,
18245,
315,
1242,
63,
464,
68,
18245,
14,
4611,
837,
507,
198,
1053,
63,
464,
68,
18245,
59,
1053,
61,
275,
9522,
8,
464,
68,
18245,
9,
421,
198,
5094,
63,
2193,
275,
1052,
421,
198,
509,
1962,
12,
1572,
315,
1962,
63,
18,
63,
4574,
14,
4611,
837,
507,
198,
5094,
63,
409,
275,
663,
4157,
507,
198,
3,
1050,
315,
1006,
314,
5226,
2403,
4652,
507,
198,
509,
1242,
315,
1572,
26,
686,
198,
5094,
63,
409,
14,
525,
8,
1053,
63,
464,
68,
18245,
59,
1053,
566,
2742,
198,
5094,
63,
2193,
59,
1143,
61,
275,
4242,
63,
409,
4388,
198,
1107,
4242,
63,
2193,
6905,
421,
199,
318,
477,
12607,
63,
16211,
8,
761,
63,
18,
63,
3838,
304,
199,
198,
624,
6924,
365,
282,
2600,
543,
2763,
11449,
465,
2883,
436,
282,
769,
402,
1924,
507,
198,
2301,
1159,
4072,
334,
1143,
4918,
402,
23338,
4811,
9,
465,
282,
574,
14,
2742,
198,
3205,
365,
282,
2600,
543,
13158,
465,
2883,
436,
5548,
402,
623,
20989,
507,
198,
305,
1338,
14,
982,
282,
623,
16448,
437,
965,
282,
7475,
370,
299,
17,
12,
652,
911,
7468,
465,
507,
198,
1159,
33,
7,
315,
314,
574,
769,
14,
982,
437,
365,
314,
849,
2163,
13,
13376,
370,
299,
17,
12,
652,
911,
507,
198,
12344,
7468,
465,
283,
66,
33,
7,
315,
314,
769,
14,
2742,
198,
9846,
26,
8777,
623,
20989,
359,
33,
12,
34,
12,
35,
61,
436,
13158,
359,
80,
17,
12,
80,
18,
12,
80,
19,
12,
80,
20,
467,
507,
198,
290,
1324,
4293,
506,
469,
80,
17,
7766,
83,
33,
467,
299,
18,
7766,
83,
33,
12,
83,
34,
467,
299,
19,
7766,
83,
33,
12,
83,
34,
467,
299,
20,
7766,
83,
34,
12,
83,
35,
9420,
2742,
198,
2959,
365,
623,
16448,
370,
2403,
13,
923,
4412,
14,
507,
198,
9846,
26,
469,
83,
33,
7766,
59,
80,
17,
467,
359,
80,
18,
12,
80,
19,
2365,
308,
34,
7766,
59,
80,
18,
12,
80,
19,
467,
359,
80,
20,
2365,
308,
35,
7766,
59,
80,
20,
2677,
93,
199,
198,
624,
4388,
198,
3,
2136,
911,
3957,
1924,
2763,
370,
282,
9522,
880,
626,
652,
883,
506,
19871,
14,
199,
198,
3,
4885,
9689,
642,
12,
781,
883,
20131,
13130,
4362,
4799,
25223,
30063,
14,
421,
198,
3,
642,
1211,
22803,
83,
314,
3379,
2763,
11449,
687,
1924,
9522,
199,
198,
21775,
409,
63,
18,
63,
761,
275,
1052,
421,
198,
3,
367,
1924,
2763,
199,
198,
509,
1048,
63,
344,
12,
1048,
63,
4407,
315,
1048,
63,
18,
63,
3838,
14,
4611,
837,
507,
198,
3,
3957,
370,
282,
9522,
507,
198,
21775,
409,
275,
9522,
8,
761,
63,
4407,
9,
507,
198,
3,
340,
781,
19051,
1133,
1937,
642,
5835,
2763,
2544,
507,
198,
692,
26226,
409,
440,
315,
26226,
409,
63,
18,
63,
761,
26,
686,
198,
3,
1050,
282,
2631,
1817,
2397,
686,
198,
21775,
409,
63,
18,
63,
761,
59,
21775,
409,
61,
275,
942,
507,
198,
3,
1050,
652,
370,
314,
769,
402,
4362,
13130,
370,
652,
507,
198,
21775,
409,
63,
18,
63,
761,
59,
21775,
409,
1055,
740,
8,
761,
63,
344,
9,
4388,
198,
3,
710,
2883,
402,
26226,
409,
63,
18,
63,
761,
787,
314,
3747,
4362,
781,
1911,
14,
199,
198,
3,
18276,
4362,
17118,
370,
2403,
4652,
14,
421,
198,
3,
2104,
1924,
623,
16448,
315,
314,
2763,
12,
1050,
314,
4568,
2403,
1572,
199,
198,
3,
370,
626,
623,
16448,
1159,
769,
402,
2403,
4652,
421,
198,
3,
642,
911,
506,
314,
4242,
734,
548,
334,
73,
14,
69,
14,
623,
16448,
63,
18,
63,
1861,
10177,
9,
199,
198,
5094,
63,
2193,
275,
1052,
4388,
198,
509,
26226,
409,
12,
8850,
315,
26226,
409,
63,
18,
63,
761,
14,
4611,
837,
507,
198,
509,
1962,
63,
344,
315,
26226,
409,
26,
686,
198,
692,
1962,
63,
344,
440,
315,
4242,
63,
2193,
26,
1585,
198,
5094,
63,
2193,
59,
1143,
63,
344,
61,
275,
942,
686,
198,
5094,
63,
2193,
59,
1143,
63,
344,
1055,
740,
8,
4574,
9,
4388,
198,
1107,
4242,
63,
2193,
6905,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
198,
421,
198,
2634,
275,
791,
65,
15211,
17,
12,
18,
12,
19,
467,
283,
66,
15211,
18,
12,
19,
12,
20,
467,
283,
67,
15211,
20,
9420,
421,
198,
681,
85,
1308,
275,
1052,
199,
198,
509,
790,
12,
1338,
315,
4652,
14,
4611,
837,
507,
198,
509,
1242,
315,
1338,
26,
686,
198,
692,
1242,
440,
315,
2249,
85,
1308,
26,
1585,
198,
681,
85,
1308,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
MiltosD/CEF-ELRC
|
lib/python2.7/site-packages/django/utils/crypto.py
|
245
|
1443
|
"""
Django's standard crypto functions and utilities.
"""
import hmac
from django.conf import settings
from django.utils.hashcompat import sha_constructor, sha_hmac
def salted_hmac(key_salt, value, secret=None):
"""
Returns the HMAC-SHA1 of 'value', using a key generated from key_salt and a
secret (which defaults to settings.SECRET_KEY).
A different key_salt should be passed in for every application of HMAC.
"""
if secret is None:
secret = settings.SECRET_KEY
# We need to generate a derived key from our base key. We can do this by
# passing the key_salt and our base key through a pseudo-random function and
# SHA1 works nicely.
key = sha_constructor(key_salt + secret).digest()
# If len(key_salt + secret) > sha_constructor().block_size, the above
# line is redundant and could be replaced by key = key_salt + secret, since
# the hmac module does the same thing for keys longer than the block size.
# However, we need to ensure that we *always* do this.
return hmac.new(key, msg=value, digestmod=sha_hmac)
def constant_time_compare(val1, val2):
"""
Returns True if the two strings are equal, False otherwise.
The time taken is independent of the number of characters that match.
"""
if len(val1) != len(val2):
return False
result = 0
for x, y in zip(val1, val2):
result |= ord(x) ^ ord(y)
return result == 0
|
bsd-3-clause
|
[
624,
199,
9323,
1159,
4465,
13230,
3423,
436,
15841,
14,
199,
624,
199,
646,
20330,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
14,
2227,
5819,
492,
7793,
63,
1880,
12,
7793,
63,
18537,
421,
199,
318,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
12,
7565,
29,
403,
304,
272,
408,
272,
1803,
314,
29817,
13,
8461,
17,
402,
283,
585,
297,
1808,
282,
790,
4046,
687,
790,
63,
12597,
436,
282,
272,
7565,
334,
6777,
4243,
370,
2202,
14,
12961,
63,
3078,
680,
339,
437,
3365,
790,
63,
12597,
1077,
506,
3032,
315,
367,
4036,
4223,
402,
29817,
14,
272,
408,
272,
340,
7565,
365,
488,
26,
267,
7565,
275,
2202,
14,
12961,
63,
3078,
339,
327,
2136,
1929,
370,
3550,
282,
7131,
790,
687,
4154,
1300,
790,
14,
221,
2136,
883,
886,
642,
701,
272,
327,
9476,
314,
790,
63,
12597,
436,
4154,
1300,
790,
4012,
282,
15984,
13,
2355,
805,
436,
272,
327,
12002,
17,
5419,
14213,
590,
14,
339,
790,
275,
7793,
63,
1880,
8,
498,
63,
12597,
435,
7565,
680,
5671,
342,
339,
327,
982,
822,
8,
498,
63,
12597,
435,
7565,
9,
690,
7793,
63,
1880,
1252,
1457,
63,
890,
12,
314,
3432,
272,
327,
1004,
365,
22649,
436,
4293,
506,
8717,
701,
790,
275,
790,
63,
12597,
435,
7565,
12,
3967,
272,
327,
314,
20330,
859,
1630,
314,
2011,
8377,
367,
2883,
8088,
2419,
314,
1853,
1568,
14,
272,
327,
9738,
12,
781,
1929,
370,
4868,
626,
781,
627,
9223,
10,
886,
642,
14,
339,
372,
20330,
14,
1222,
8,
498,
12,
1499,
29,
585,
12,
10017,
1494,
29,
4835,
63,
18537,
9,
421,
199,
318,
4413,
63,
521,
63,
5785,
8,
637,
17,
12,
1139,
18,
304,
272,
408,
272,
1803,
715,
340,
314,
2877,
3326,
787,
4472,
12,
756,
4257,
14,
339,
710,
900,
9394,
365,
12717,
402,
314,
1329,
402,
4110,
626,
1336,
14,
272,
408,
272,
340,
822,
8,
637,
17,
9,
1137,
822,
8,
637,
18,
304,
267,
372,
756,
272,
754,
275,
378,
272,
367,
671,
12,
612,
315,
3482,
8,
637,
17,
12,
1139,
18,
304,
267,
754,
8901,
6206,
8,
88,
9,
7167,
6206,
8,
89,
9,
272,
372,
754,
508,
378,
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
] |
[
199,
9323,
1159,
4465,
13230,
3423,
436,
15841,
14,
199,
624,
199,
646,
20330,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1208,
14,
2227,
5819,
492,
7793,
63,
1880,
12,
7793,
63,
18537,
421,
199,
318,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
12,
7565,
29,
403,
304,
272,
408,
272,
1803,
314,
29817,
13,
8461,
17,
402,
283,
585,
297,
1808,
282,
790,
4046,
687,
790,
63,
12597,
436,
282,
272,
7565,
334,
6777,
4243,
370,
2202,
14,
12961,
63,
3078,
680,
339,
437,
3365,
790,
63,
12597,
1077,
506,
3032,
315,
367,
4036,
4223,
402,
29817,
14,
272,
408,
272,
340,
7565,
365,
488,
26,
267,
7565,
275,
2202,
14,
12961,
63,
3078,
339,
327,
2136,
1929,
370,
3550,
282,
7131,
790,
687,
4154,
1300,
790,
14,
221,
2136,
883,
886,
642,
701,
272,
327,
9476,
314,
790,
63,
12597,
436,
4154,
1300,
790,
4012,
282,
15984,
13,
2355,
805,
436,
272,
327,
12002,
17,
5419,
14213,
590,
14,
339,
790,
275,
7793,
63,
1880,
8,
498,
63,
12597,
435,
7565,
680,
5671,
342,
339,
327,
982,
822,
8,
498,
63,
12597,
435,
7565,
9,
690,
7793,
63,
1880,
1252,
1457,
63,
890,
12,
314,
3432,
272,
327,
1004,
365,
22649,
436,
4293,
506,
8717,
701,
790,
275,
790,
63,
12597,
435,
7565,
12,
3967,
272,
327,
314,
20330,
859,
1630,
314,
2011,
8377,
367,
2883,
8088,
2419,
314,
1853,
1568,
14,
272,
327,
9738,
12,
781,
1929,
370,
4868,
626,
781,
627,
9223,
10,
886,
642,
14,
339,
372,
20330,
14,
1222,
8,
498,
12,
1499,
29,
585,
12,
10017,
1494,
29,
4835,
63,
18537,
9,
421,
199,
318,
4413,
63,
521,
63,
5785,
8,
637,
17,
12,
1139,
18,
304,
272,
408,
272,
1803,
715,
340,
314,
2877,
3326,
787,
4472,
12,
756,
4257,
14,
339,
710,
900,
9394,
365,
12717,
402,
314,
1329,
402,
4110,
626,
1336,
14,
272,
408,
272,
340,
822,
8,
637,
17,
9,
1137,
822,
8,
637,
18,
304,
267,
372,
756,
272,
754,
275,
378,
272,
367,
671,
12,
612,
315,
3482,
8,
637,
17,
12,
1139,
18,
304,
267,
754,
8901,
6206,
8,
88,
9,
7167,
6206,
8,
89,
9,
272,
372,
754,
508,
378,
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,
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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
] |
guettli/django
|
tests/utils_tests/test_timezone.py
|
13
|
8369
|
import datetime
import pickle
import pytz
from django.test import SimpleTestCase, mock, override_settings
from django.utils import timezone
CET = pytz.timezone("Europe/Paris")
EAT = timezone.get_fixed_timezone(180) # Africa/Nairobi
ICT = timezone.get_fixed_timezone(420) # Asia/Bangkok
class TimezoneTests(SimpleTestCase):
def test_now(self):
with override_settings(USE_TZ=True):
self.assertTrue(timezone.is_aware(timezone.now()))
with override_settings(USE_TZ=False):
self.assertTrue(timezone.is_naive(timezone.now()))
def test_localdate(self):
naive = datetime.datetime(2015, 1, 1, 0, 0, 1)
with self.assertRaisesMessage(ValueError, 'localtime() cannot be applied to a naive datetime'):
timezone.localdate(naive)
with self.assertRaisesMessage(ValueError, 'localtime() cannot be applied to a naive datetime'):
timezone.localdate(naive, timezone=EAT)
aware = datetime.datetime(2015, 1, 1, 0, 0, 1, tzinfo=ICT)
self.assertEqual(timezone.localdate(aware, timezone=EAT), datetime.date(2014, 12, 31))
with timezone.override(EAT):
self.assertEqual(timezone.localdate(aware), datetime.date(2014, 12, 31))
with mock.patch('django.utils.timezone.now', return_value=aware):
self.assertEqual(timezone.localdate(timezone=EAT), datetime.date(2014, 12, 31))
with timezone.override(EAT):
self.assertEqual(timezone.localdate(), datetime.date(2014, 12, 31))
def test_override(self):
default = timezone.get_default_timezone()
try:
timezone.activate(ICT)
with timezone.override(EAT):
self.assertIs(EAT, timezone.get_current_timezone())
self.assertIs(ICT, timezone.get_current_timezone())
with timezone.override(None):
self.assertIs(default, timezone.get_current_timezone())
self.assertIs(ICT, timezone.get_current_timezone())
timezone.deactivate()
with timezone.override(EAT):
self.assertIs(EAT, timezone.get_current_timezone())
self.assertIs(default, timezone.get_current_timezone())
with timezone.override(None):
self.assertIs(default, timezone.get_current_timezone())
self.assertIs(default, timezone.get_current_timezone())
finally:
timezone.deactivate()
def test_override_decorator(self):
default = timezone.get_default_timezone()
@timezone.override(EAT)
def func_tz_eat():
self.assertIs(EAT, timezone.get_current_timezone())
@timezone.override(None)
def func_tz_none():
self.assertIs(default, timezone.get_current_timezone())
try:
timezone.activate(ICT)
func_tz_eat()
self.assertIs(ICT, timezone.get_current_timezone())
func_tz_none()
self.assertIs(ICT, timezone.get_current_timezone())
timezone.deactivate()
func_tz_eat()
self.assertIs(default, timezone.get_current_timezone())
func_tz_none()
self.assertIs(default, timezone.get_current_timezone())
finally:
timezone.deactivate()
def test_override_string_tz(self):
with timezone.override('Asia/Bangkok'):
self.assertEqual(timezone.get_current_timezone_name(), 'Asia/Bangkok')
def test_override_fixed_offset(self):
with timezone.override(timezone.FixedOffset(0, 'tzname')):
self.assertEqual(timezone.get_current_timezone_name(), 'tzname')
def test_activate_invalid_timezone(self):
with self.assertRaisesMessage(ValueError, 'Invalid timezone: None'):
timezone.activate(None)
def test_is_aware(self):
self.assertTrue(timezone.is_aware(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)))
self.assertFalse(timezone.is_aware(datetime.datetime(2011, 9, 1, 13, 20, 30)))
def test_is_naive(self):
self.assertFalse(timezone.is_naive(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)))
self.assertTrue(timezone.is_naive(datetime.datetime(2011, 9, 1, 13, 20, 30)))
def test_make_aware(self):
self.assertEqual(
timezone.make_aware(datetime.datetime(2011, 9, 1, 13, 20, 30), EAT),
datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT))
with self.assertRaises(ValueError):
timezone.make_aware(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), EAT)
def test_make_naive(self):
self.assertEqual(
timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), EAT),
datetime.datetime(2011, 9, 1, 13, 20, 30))
self.assertEqual(
timezone.make_naive(datetime.datetime(2011, 9, 1, 17, 20, 30, tzinfo=ICT), EAT),
datetime.datetime(2011, 9, 1, 13, 20, 30))
with self.assertRaisesMessage(ValueError, 'make_naive() cannot be applied to a naive datetime'):
timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30), EAT)
def test_make_naive_no_tz(self):
self.assertEqual(
timezone.make_naive(datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)),
datetime.datetime(2011, 9, 1, 5, 20, 30)
)
def test_make_aware_no_tz(self):
self.assertEqual(
timezone.make_aware(datetime.datetime(2011, 9, 1, 13, 20, 30)),
datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=timezone.get_fixed_timezone(-300))
)
def test_make_aware2(self):
self.assertEqual(
timezone.make_aware(datetime.datetime(2011, 9, 1, 12, 20, 30), CET),
CET.localize(datetime.datetime(2011, 9, 1, 12, 20, 30)))
with self.assertRaises(ValueError):
timezone.make_aware(CET.localize(datetime.datetime(2011, 9, 1, 12, 20, 30)), CET)
def test_make_aware_pytz(self):
self.assertEqual(
timezone.make_naive(CET.localize(datetime.datetime(2011, 9, 1, 12, 20, 30)), CET),
datetime.datetime(2011, 9, 1, 12, 20, 30))
self.assertEqual(
timezone.make_naive(
pytz.timezone("Asia/Bangkok").localize(datetime.datetime(2011, 9, 1, 17, 20, 30)), CET
),
datetime.datetime(2011, 9, 1, 12, 20, 30))
with self.assertRaisesMessage(ValueError, 'make_naive() cannot be applied to a naive datetime'):
timezone.make_naive(datetime.datetime(2011, 9, 1, 12, 20, 30), CET)
def test_make_aware_pytz_ambiguous(self):
# 2:30 happens twice, once before DST ends and once after
ambiguous = datetime.datetime(2015, 10, 25, 2, 30)
with self.assertRaises(pytz.AmbiguousTimeError):
timezone.make_aware(ambiguous, timezone=CET)
std = timezone.make_aware(ambiguous, timezone=CET, is_dst=False)
dst = timezone.make_aware(ambiguous, timezone=CET, is_dst=True)
self.assertEqual(std - dst, datetime.timedelta(hours=1))
self.assertEqual(std.tzinfo.utcoffset(std), datetime.timedelta(hours=1))
self.assertEqual(dst.tzinfo.utcoffset(dst), datetime.timedelta(hours=2))
def test_make_aware_pytz_non_existent(self):
# 2:30 never happened due to DST
non_existent = datetime.datetime(2015, 3, 29, 2, 30)
with self.assertRaises(pytz.NonExistentTimeError):
timezone.make_aware(non_existent, timezone=CET)
std = timezone.make_aware(non_existent, timezone=CET, is_dst=False)
dst = timezone.make_aware(non_existent, timezone=CET, is_dst=True)
self.assertEqual(std - dst, datetime.timedelta(hours=1))
self.assertEqual(std.tzinfo.utcoffset(std), datetime.timedelta(hours=1))
self.assertEqual(dst.tzinfo.utcoffset(dst), datetime.timedelta(hours=2))
def test_get_default_timezone(self):
self.assertEqual(timezone.get_default_timezone_name(), 'America/Chicago')
def test_fixedoffset_timedelta(self):
delta = datetime.timedelta(hours=1)
self.assertEqual(timezone.get_fixed_timezone(delta).utcoffset(''), delta)
def test_fixedoffset_pickle(self):
self.assertEqual(pickle.loads(pickle.dumps(timezone.FixedOffset(0, 'tzname'))).tzname(''), 'tzname')
|
bsd-3-clause
|
[
646,
2197,
199,
646,
5927,
199,
199,
646,
15444,
199,
199,
504,
1639,
14,
396,
492,
24424,
12,
1683,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
492,
7137,
199,
199,
35,
775,
275,
15444,
14,
7145,
480,
15201,
15,
1262,
374,
531,
199,
37,
619,
275,
7137,
14,
362,
63,
5964,
63,
7145,
8,
7663,
9,
420,
327,
437,
70,
7127,
15,
46,
5789,
293,
4492,
199,
6196,
275,
7137,
14,
362,
63,
5964,
63,
7145,
8,
25102,
9,
420,
327,
437,
10971,
15,
34,
621,
75,
745,
421,
199,
533,
4703,
2619,
2925,
8,
17968,
304,
339,
347,
511,
63,
2131,
8,
277,
304,
267,
543,
4278,
63,
1751,
8,
4701,
63,
14226,
29,
549,
304,
288,
291,
14,
1815,
8,
7145,
14,
374,
63,
14600,
8,
7145,
14,
2131,
4059,
267,
543,
4278,
63,
1751,
8,
4701,
63,
14226,
29,
797,
304,
288,
291,
14,
1815,
8,
7145,
14,
374,
63,
21578,
8,
7145,
14,
2131,
4059,
339,
347,
511,
63,
1832,
602,
8,
277,
304,
267,
19995,
275,
2197,
14,
2083,
8,
7806,
12,
413,
12,
413,
12,
378,
12,
378,
12,
413,
9,
267,
543,
291,
14,
14638,
8,
3393,
12,
283,
15198,
342,
3913,
506,
6781,
370,
282,
19995,
2197,
735,
288,
7137,
14,
1832,
602,
8,
21578,
9,
267,
543,
291,
14,
14638,
8,
3393,
12,
283,
15198,
342,
3913,
506,
6781,
370,
282,
19995,
2197,
735,
288,
7137,
14,
1832,
602,
8,
21578,
12,
7137,
29,
37,
619,
9,
398,
20381,
275,
2197,
14,
2083,
8,
7806,
12,
413,
12,
413,
12,
378,
12,
378,
12,
413,
12,
10313,
29,
6196,
9,
267,
291,
14,
629,
8,
7145,
14,
1832,
602,
8,
14600,
12,
7137,
29,
37,
619,
395,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
267,
543,
7137,
14,
4415,
8,
37,
619,
304,
288,
291,
14,
629,
8,
7145,
14,
1832,
602,
8,
14600,
395,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
398,
543,
1683,
14,
2068,
360,
1176,
14,
1208,
14,
7145,
14,
2131,
297,
372,
63,
585,
29,
14600,
304,
288,
291,
14,
629,
8,
7145,
14,
1832,
602,
8,
7145,
29,
37,
619,
395,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
288,
543,
7137,
14,
4415,
8,
37,
619,
304,
355,
291,
14,
629,
8,
7145,
14,
1832,
602,
1062,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
339,
347,
511,
63,
4415,
8,
277,
304,
267,
849,
275,
7137,
14,
362,
63,
885,
63,
7145,
342,
267,
862,
26,
288,
7137,
14,
8222,
8,
6196,
9,
953,
543,
7137,
14,
4415,
8,
37,
619,
304,
355,
291,
14,
3436,
8,
37,
619,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
543,
7137,
14,
4415,
8,
403,
304,
355,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
7137,
14,
24891,
342,
953,
543,
7137,
14,
4415,
8,
37,
619,
304,
355,
291,
14,
3436,
8,
37,
619,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
543,
7137,
14,
4415,
8,
403,
304,
355,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
267,
3753,
26,
288,
7137,
14,
24891,
342,
339,
347,
511,
63,
4415,
63,
11547,
8,
277,
304,
267,
849,
275,
7137,
14,
362,
63,
885,
63,
7145,
342,
398,
768,
7145,
14,
4415,
8,
37,
619,
9,
267,
347,
2562,
63,
3903,
63,
69,
292,
837,
288,
291,
14,
3436,
8,
37,
619,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
398,
768,
7145,
14,
4415,
8,
403,
9,
267,
347,
2562,
63,
3903,
63,
3592,
837,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
398,
862,
26,
288,
7137,
14,
8222,
8,
6196,
9,
953,
2562,
63,
3903,
63,
69,
292,
342,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
2562,
63,
3903,
63,
3592,
342,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
7137,
14,
24891,
342,
953,
2562,
63,
3903,
63,
69,
292,
342,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
2562,
63,
3903,
63,
3592,
342,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
267,
3753,
26,
288,
7137,
14,
24891,
342,
339,
347,
511,
63,
4415,
63,
875,
63,
3903,
8,
277,
304,
267,
543,
7137,
14,
4415,
360,
13878,
15,
34,
621,
75,
745,
735,
288,
291,
14,
629,
8,
7145,
14,
362,
63,
1818,
63,
7145,
63,
354,
1062,
283,
13878,
15,
34,
621,
75,
745,
358,
339,
347,
511,
63,
4415,
63,
5964,
63,
2743,
8,
277,
304,
267,
543,
7137,
14,
4415,
8,
7145,
14,
9515,
6397,
8,
16,
12,
283,
20027,
8109,
288,
291,
14,
629,
8,
7145,
14,
362,
63,
1818,
63,
7145,
63,
354,
1062,
283,
20027,
358,
339,
347,
511,
63,
8222,
63,
3197,
63,
7145,
8,
277,
304,
267,
543,
291,
14,
14638,
8,
3393,
12,
283,
3364,
7137,
26,
488,
735,
288,
7137,
14,
8222,
8,
403,
9,
339,
347,
511,
63,
374,
63,
14600,
8,
277,
304,
267,
291,
14,
1815,
8,
7145,
14,
374,
63,
14600,
8,
2083,
14,
2083,
8,
8128,
12,
1749,
12,
413,
12,
4944,
12,
3388,
12,
4233,
12,
10313,
29,
37,
619,
1724,
267,
291,
14,
3334,
8,
7145,
14,
374,
63,
14600,
8,
2083,
14,
2083,
8,
8128,
12,
1749,
12,
413,
12,
4944,
12,
3388,
12,
4233,
1724,
339,
347,
511,
63,
374,
63,
21578,
8,
277,
304,
267,
291,
14,
3334,
8,
7145,
14,
374,
63,
21578,
8,
2083,
14,
2083,
8,
8128,
12,
1749
] |
[
2197,
199,
646,
5927,
199,
199,
646,
15444,
199,
199,
504,
1639,
14,
396,
492,
24424,
12,
1683,
12,
4278,
63,
1751,
199,
504,
1639,
14,
1208,
492,
7137,
199,
199,
35,
775,
275,
15444,
14,
7145,
480,
15201,
15,
1262,
374,
531,
199,
37,
619,
275,
7137,
14,
362,
63,
5964,
63,
7145,
8,
7663,
9,
420,
327,
437,
70,
7127,
15,
46,
5789,
293,
4492,
199,
6196,
275,
7137,
14,
362,
63,
5964,
63,
7145,
8,
25102,
9,
420,
327,
437,
10971,
15,
34,
621,
75,
745,
421,
199,
533,
4703,
2619,
2925,
8,
17968,
304,
339,
347,
511,
63,
2131,
8,
277,
304,
267,
543,
4278,
63,
1751,
8,
4701,
63,
14226,
29,
549,
304,
288,
291,
14,
1815,
8,
7145,
14,
374,
63,
14600,
8,
7145,
14,
2131,
4059,
267,
543,
4278,
63,
1751,
8,
4701,
63,
14226,
29,
797,
304,
288,
291,
14,
1815,
8,
7145,
14,
374,
63,
21578,
8,
7145,
14,
2131,
4059,
339,
347,
511,
63,
1832,
602,
8,
277,
304,
267,
19995,
275,
2197,
14,
2083,
8,
7806,
12,
413,
12,
413,
12,
378,
12,
378,
12,
413,
9,
267,
543,
291,
14,
14638,
8,
3393,
12,
283,
15198,
342,
3913,
506,
6781,
370,
282,
19995,
2197,
735,
288,
7137,
14,
1832,
602,
8,
21578,
9,
267,
543,
291,
14,
14638,
8,
3393,
12,
283,
15198,
342,
3913,
506,
6781,
370,
282,
19995,
2197,
735,
288,
7137,
14,
1832,
602,
8,
21578,
12,
7137,
29,
37,
619,
9,
398,
20381,
275,
2197,
14,
2083,
8,
7806,
12,
413,
12,
413,
12,
378,
12,
378,
12,
413,
12,
10313,
29,
6196,
9,
267,
291,
14,
629,
8,
7145,
14,
1832,
602,
8,
14600,
12,
7137,
29,
37,
619,
395,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
267,
543,
7137,
14,
4415,
8,
37,
619,
304,
288,
291,
14,
629,
8,
7145,
14,
1832,
602,
8,
14600,
395,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
398,
543,
1683,
14,
2068,
360,
1176,
14,
1208,
14,
7145,
14,
2131,
297,
372,
63,
585,
29,
14600,
304,
288,
291,
14,
629,
8,
7145,
14,
1832,
602,
8,
7145,
29,
37,
619,
395,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
288,
543,
7137,
14,
4415,
8,
37,
619,
304,
355,
291,
14,
629,
8,
7145,
14,
1832,
602,
1062,
2197,
14,
602,
8,
7280,
12,
3144,
12,
7105,
430,
339,
347,
511,
63,
4415,
8,
277,
304,
267,
849,
275,
7137,
14,
362,
63,
885,
63,
7145,
342,
267,
862,
26,
288,
7137,
14,
8222,
8,
6196,
9,
953,
543,
7137,
14,
4415,
8,
37,
619,
304,
355,
291,
14,
3436,
8,
37,
619,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
543,
7137,
14,
4415,
8,
403,
304,
355,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
7137,
14,
24891,
342,
953,
543,
7137,
14,
4415,
8,
37,
619,
304,
355,
291,
14,
3436,
8,
37,
619,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
543,
7137,
14,
4415,
8,
403,
304,
355,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
267,
3753,
26,
288,
7137,
14,
24891,
342,
339,
347,
511,
63,
4415,
63,
11547,
8,
277,
304,
267,
849,
275,
7137,
14,
362,
63,
885,
63,
7145,
342,
398,
768,
7145,
14,
4415,
8,
37,
619,
9,
267,
347,
2562,
63,
3903,
63,
69,
292,
837,
288,
291,
14,
3436,
8,
37,
619,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
398,
768,
7145,
14,
4415,
8,
403,
9,
267,
347,
2562,
63,
3903,
63,
3592,
837,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
398,
862,
26,
288,
7137,
14,
8222,
8,
6196,
9,
953,
2562,
63,
3903,
63,
69,
292,
342,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
2562,
63,
3903,
63,
3592,
342,
288,
291,
14,
3436,
8,
6196,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
7137,
14,
24891,
342,
953,
2562,
63,
3903,
63,
69,
292,
342,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
953,
2562,
63,
3903,
63,
3592,
342,
288,
291,
14,
3436,
8,
885,
12,
7137,
14,
362,
63,
1818,
63,
7145,
1012,
267,
3753,
26,
288,
7137,
14,
24891,
342,
339,
347,
511,
63,
4415,
63,
875,
63,
3903,
8,
277,
304,
267,
543,
7137,
14,
4415,
360,
13878,
15,
34,
621,
75,
745,
735,
288,
291,
14,
629,
8,
7145,
14,
362,
63,
1818,
63,
7145,
63,
354,
1062,
283,
13878,
15,
34,
621,
75,
745,
358,
339,
347,
511,
63,
4415,
63,
5964,
63,
2743,
8,
277,
304,
267,
543,
7137,
14,
4415,
8,
7145,
14,
9515,
6397,
8,
16,
12,
283,
20027,
8109,
288,
291,
14,
629,
8,
7145,
14,
362,
63,
1818,
63,
7145,
63,
354,
1062,
283,
20027,
358,
339,
347,
511,
63,
8222,
63,
3197,
63,
7145,
8,
277,
304,
267,
543,
291,
14,
14638,
8,
3393,
12,
283,
3364,
7137,
26,
488,
735,
288,
7137,
14,
8222,
8,
403,
9,
339,
347,
511,
63,
374,
63,
14600,
8,
277,
304,
267,
291,
14,
1815,
8,
7145,
14,
374,
63,
14600,
8,
2083,
14,
2083,
8,
8128,
12,
1749,
12,
413,
12,
4944,
12,
3388,
12,
4233,
12,
10313,
29,
37,
619,
1724,
267,
291,
14,
3334,
8,
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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
] |
atopuzov/nitro-python
|
nssrc/com/citrix/netscaler/nitro/resource/config/cr/crvserver_lbvserver_binding.py
|
3
|
6480
|
#
# Copyright (c) 2008-2015 Citrix Systems, Inc.
#
# 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 nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_resource
from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_response
from nssrc.com.citrix.netscaler.nitro.service.options import options
from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception
from nssrc.com.citrix.netscaler.nitro.util.nitro_util import nitro_util
class crvserver_lbvserver_binding(base_resource) :
""" Binding class showing the lbvserver that can be bound to crvserver.
"""
def __init__(self) :
self._lbvserver = ""
self._hits = 0
self._name = ""
self.___count = 0
@property
def lbvserver(self) :
ur"""The Default target server name.<br/>Minimum length = 1.
"""
try :
return self._lbvserver
except Exception as e:
raise e
@lbvserver.setter
def lbvserver(self, lbvserver) :
ur"""The Default target server name.<br/>Minimum length = 1
"""
try :
self._lbvserver = lbvserver
except Exception as e:
raise e
@property
def name(self) :
ur"""Name of the cache redirection virtual server to which to bind the cache redirection policy.<br/>Minimum length = 1.
"""
try :
return self._name
except Exception as e:
raise e
@name.setter
def name(self, name) :
ur"""Name of the cache redirection virtual server to which to bind the cache redirection policy.<br/>Minimum length = 1
"""
try :
self._name = name
except Exception as e:
raise e
@property
def hits(self) :
ur"""Number of hits.
"""
try :
return self._hits
except Exception as e:
raise e
def _get_nitro_response(self, service, response) :
ur""" converts nitro response into object and returns the object array in case of get request.
"""
try :
result = service.payload_formatter.string_to_resource(crvserver_lbvserver_binding_response, response, self.__class__.__name__)
if(result.errorcode != 0) :
if (result.errorcode == 444) :
service.clear_session(self)
if result.severity :
if (result.severity == "ERROR") :
raise nitro_exception(result.errorcode, str(result.message), str(result.severity))
else :
raise nitro_exception(result.errorcode, str(result.message), str(result.severity))
return result.crvserver_lbvserver_binding
except Exception as e :
raise e
def _get_object_name(self) :
ur""" Returns the value of object identifier argument
"""
try :
if self.name is not None :
return str(self.name)
return None
except Exception as e :
raise e
@classmethod
def add(cls, client, resource) :
try :
if resource and type(resource) is not list :
updateresource = crvserver_lbvserver_binding()
updateresource.name = resource.name
updateresource.lbvserver = resource.lbvserver
return updateresource.update_resource(client)
else :
if resource and len(resource) > 0 :
updateresources = [crvserver_lbvserver_binding() for _ in range(len(resource))]
for i in range(len(resource)) :
updateresources[i].name = resource[i].name
updateresources[i].lbvserver = resource[i].lbvserver
return cls.update_bulk_request(client, updateresources)
except Exception as e :
raise e
@classmethod
def delete(cls, client, resource) :
try :
if resource and type(resource) is not list :
deleteresource = crvserver_lbvserver_binding()
deleteresource.name = resource.name
deleteresource.lbvserver = resource.lbvserver
return deleteresource.delete_resource(client)
else :
if resource and len(resource) > 0 :
deleteresources = [crvserver_lbvserver_binding() for _ in range(len(resource))]
for i in range(len(resource)) :
deleteresources[i].name = resource[i].name
deleteresources[i].lbvserver = resource[i].lbvserver
return cls.delete_bulk_request(client, deleteresources)
except Exception as e :
raise e
@classmethod
def get(cls, service, name) :
ur""" Use this API to fetch crvserver_lbvserver_binding resources.
"""
try :
obj = crvserver_lbvserver_binding()
obj.name = name
response = obj.get_resources(service)
return response
except Exception as e:
raise e
@classmethod
def get_filtered(cls, service, name, filter_) :
ur""" Use this API to fetch filtered set of crvserver_lbvserver_binding resources.
Filter string should be in JSON format.eg: "port:80,servicetype:HTTP".
"""
try :
obj = crvserver_lbvserver_binding()
obj.name = name
option_ = options()
option_.filter = filter_
response = obj.getfiltered(service, option_)
return response
except Exception as e:
raise e
@classmethod
def count(cls, service, name) :
ur""" Use this API to count crvserver_lbvserver_binding resources configued on NetScaler.
"""
try :
obj = crvserver_lbvserver_binding()
obj.name = name
option_ = options()
option_.count = True
response = obj.get_resources(service, option_)
if response :
return response[0].__dict__['___count']
return 0
except Exception as e:
raise e
@classmethod
def count_filtered(cls, service, name, filter_) :
ur""" Use this API to count the filtered set of crvserver_lbvserver_binding resources.
Filter string should be in JSON format.eg: "port:80,servicetype:HTTP".
"""
try :
obj = crvserver_lbvserver_binding()
obj.name = name
option_ = options()
option_.count = True
option_.filter = filter_
response = obj.getfiltered(service, option_)
if response :
return response[0].__dict__['___count']
return 0
except Exception as e:
raise e
class crvserver_lbvserver_binding_response(base_response) :
def __init__(self, length=1) :
self.crvserver_lbvserver_binding = []
self.errorcode = 0
self.message = ""
self.severity = ""
self.sessionid = ""
self.crvserver_lbvserver_binding = [crvserver_lbvserver_binding() for _ in range(length)]
|
apache-2.0
|
[
3,
199,
3,
1898,
334,
67,
9,
9079,
13,
7806,
445,
390,
1904,
15285,
12,
3277,
14,
199,
3,
199,
3,
257,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
531,
199,
3,
257,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
257,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
755,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
221,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
257,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
257,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
257,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
257,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1927,
14,
1095,
14,
1095,
63,
1927,
492,
1300,
63,
1927,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1927,
14,
1095,
14,
1095,
63,
1927,
492,
1300,
63,
1310,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1364,
14,
1419,
492,
1511,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1971,
14,
18893,
63,
1971,
492,
20107,
63,
1971,
199,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1974,
14,
18893,
63,
1974,
492,
20107,
63,
1974,
199,
199,
533,
2467,
16120,
63,
6374,
16120,
63,
9140,
8,
1095,
63,
1927,
9,
520,
199,
198,
624,
22630,
316,
1021,
21207,
314,
11104,
16120,
626,
883,
506,
3914,
370,
2467,
16120,
14,
199,
198,
624,
199,
198,
318,
636,
826,
721,
277,
9,
520,
507,
198,
277,
423,
6374,
16120,
275,
3087,
507,
198,
277,
423,
16595,
275,
378,
507,
198,
277,
423,
354,
275,
3087,
507,
198,
277,
855,
63,
835,
275,
378,
421,
198,
32,
1829,
199,
198,
318,
11104,
16120,
8,
277,
9,
520,
507,
198,
300,
624,
1918,
3758,
1347,
1654,
536,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1107,
291,
423,
6374,
16120,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
6374,
16120,
14,
8345,
199,
198,
318,
11104,
16120,
8,
277,
12,
11104,
16120,
9,
520,
507,
198,
300,
624,
1918,
3758,
1347,
1654,
536,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
507,
198,
624,
507,
198,
893,
520,
686,
198,
277,
423,
6374,
16120,
275,
11104,
16120,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
1829,
199,
198,
318,
536,
8,
277,
9,
520,
507,
198,
300,
624,
985,
402,
314,
2581,
23713,
5791,
1654,
370,
1314,
370,
5398,
314,
2581,
23713,
4592,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1107,
291,
423,
354,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
354,
14,
8345,
199,
198,
318,
536,
8,
277,
12,
536,
9,
520,
507,
198,
300,
624,
985,
402,
314,
2581,
23713,
5791,
1654,
370,
1314,
370,
5398,
314,
2581,
23713,
4592,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
507,
198,
624,
507,
198,
893,
520,
686,
198,
277,
423,
354,
275,
536,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
1829,
199,
198,
318,
19745,
8,
277,
9,
520,
507,
198,
300,
624,
3259,
402,
19745,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1107,
291,
423,
16595,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
318,
485,
362,
63,
18893,
63,
1310,
8,
277,
12,
2435,
12,
1177,
9,
520,
507,
198,
300,
624,
15373,
20107,
1177,
1901,
909,
436,
2529,
314,
909,
1625,
315,
1930,
402,
664,
1056,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1099,
275,
2435,
14,
4749,
63,
8911,
14,
875,
63,
475,
63,
1927,
8,
1556,
16120,
63,
6374,
16120,
63,
9140,
63,
1310,
12,
1177,
12,
291,
855,
533,
4914,
354,
3368,
686,
198,
692,
8,
1099,
14,
28857,
1137,
378,
9,
520,
1585,
198,
692,
334,
1099,
14,
28857,
508,
841,
1602,
9,
520,
1871,
198,
1364,
14,
3584,
63,
1730,
8,
277,
9,
1585,
198,
692,
754,
14,
20394,
520,
1871,
198,
692,
334,
1099,
14,
20394,
508,
298,
3170,
531,
520,
4671,
198,
3730,
20107,
63,
1971,
8,
1099,
14,
28857,
12,
620,
8,
1099,
14,
1188,
395,
620,
8,
1099,
14,
20394,
430,
1585,
198,
2836,
520,
1871,
198,
3730,
20107,
63,
1971,
8,
1099,
14,
28857,
12,
620,
8,
1099,
14,
1188,
395,
620,
8,
1099,
14,
20394,
430,
686,
198,
1107,
754,
14,
1556,
16120,
63,
6374,
16120,
63,
9140,
507,
198,
2590,
2186,
465,
325,
520,
686,
198,
3730,
325,
421,
198,
318,
485,
362,
63,
785,
63,
354,
8,
277,
9,
520,
507,
198,
300,
624,
1803,
314,
574,
402,
909,
5148,
1423,
507,
198,
624,
507,
198,
893,
520,
686,
198,
692,
291,
14,
354,
365,
440,
488,
520,
1585,
198,
1107,
620,
8,
277,
14,
354,
9,
686,
198,
1107,
488,
507,
198,
2590,
2186,
465,
325,
520,
686,
198,
3730,
325,
6905,
198,
32,
3744,
199,
198,
318,
1050,
8,
1886,
12,
1890,
12,
2073,
9,
520,
507,
198,
893,
520,
686,
198,
692,
2073,
436,
730,
8,
1927,
9,
365,
440,
769,
520,
1585,
198,
873,
1927,
275,
2467,
16120,
63,
6374,
16120,
63,
9140,
342,
1585,
198,
873,
1927,
14,
354,
275,
2073,
14,
354,
1585,
198,
873,
1927,
14,
6374,
16120,
275,
2073,
14,
6374,
16120,
1585,
198,
1107,
1678,
1927,
14,
873,
63,
1927,
8,
1258,
9,
686,
198,
2836,
520,
1585,
198,
692,
2073,
436,
822,
8,
1927,
9,
690,
378,
520,
1871,
198,
873,
4435,
275,
359,
1556,
16120,
63,
6374,
16120,
63,
9140,
342
] |
[
199,
3,
1898,
334,
67,
9,
9079,
13,
7806,
445,
390,
1904,
15285,
12,
3277,
14,
199,
3,
199,
3,
257,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
531,
199,
3,
257,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
257,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
755,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
221,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
257,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
257,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
257,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
257,
4204,
1334,
314,
844,
14,
199,
3,
199,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1927,
14,
1095,
14,
1095,
63,
1927,
492,
1300,
63,
1927,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1927,
14,
1095,
14,
1095,
63,
1927,
492,
1300,
63,
1310,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1364,
14,
1419,
492,
1511,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1971,
14,
18893,
63,
1971,
492,
20107,
63,
1971,
199,
199,
504,
302,
32231,
14,
957,
14,
14422,
1904,
14,
18860,
14,
18893,
14,
1974,
14,
18893,
63,
1974,
492,
20107,
63,
1974,
199,
199,
533,
2467,
16120,
63,
6374,
16120,
63,
9140,
8,
1095,
63,
1927,
9,
520,
199,
198,
624,
22630,
316,
1021,
21207,
314,
11104,
16120,
626,
883,
506,
3914,
370,
2467,
16120,
14,
199,
198,
624,
199,
198,
318,
636,
826,
721,
277,
9,
520,
507,
198,
277,
423,
6374,
16120,
275,
3087,
507,
198,
277,
423,
16595,
275,
378,
507,
198,
277,
423,
354,
275,
3087,
507,
198,
277,
855,
63,
835,
275,
378,
421,
198,
32,
1829,
199,
198,
318,
11104,
16120,
8,
277,
9,
520,
507,
198,
300,
624,
1918,
3758,
1347,
1654,
536,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1107,
291,
423,
6374,
16120,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
6374,
16120,
14,
8345,
199,
198,
318,
11104,
16120,
8,
277,
12,
11104,
16120,
9,
520,
507,
198,
300,
624,
1918,
3758,
1347,
1654,
536,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
507,
198,
624,
507,
198,
893,
520,
686,
198,
277,
423,
6374,
16120,
275,
11104,
16120,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
1829,
199,
198,
318,
536,
8,
277,
9,
520,
507,
198,
300,
624,
985,
402,
314,
2581,
23713,
5791,
1654,
370,
1314,
370,
5398,
314,
2581,
23713,
4592,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1107,
291,
423,
354,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
354,
14,
8345,
199,
198,
318,
536,
8,
277,
12,
536,
9,
520,
507,
198,
300,
624,
985,
402,
314,
2581,
23713,
5791,
1654,
370,
1314,
370,
5398,
314,
2581,
23713,
4592,
21455,
3289,
3133,
12092,
2582,
275,
221,
413,
507,
198,
624,
507,
198,
893,
520,
686,
198,
277,
423,
354,
275,
536,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
32,
1829,
199,
198,
318,
19745,
8,
277,
9,
520,
507,
198,
300,
624,
3259,
402,
19745,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1107,
291,
423,
16595,
507,
198,
2590,
2186,
465,
325,
26,
686,
198,
3730,
325,
421,
198,
318,
485,
362,
63,
18893,
63,
1310,
8,
277,
12,
2435,
12,
1177,
9,
520,
507,
198,
300,
624,
15373,
20107,
1177,
1901,
909,
436,
2529,
314,
909,
1625,
315,
1930,
402,
664,
1056,
14,
507,
198,
624,
507,
198,
893,
520,
686,
198,
1099,
275,
2435,
14,
4749,
63,
8911,
14,
875,
63,
475,
63,
1927,
8,
1556,
16120,
63,
6374,
16120,
63,
9140,
63,
1310,
12,
1177,
12,
291,
855,
533,
4914,
354,
3368,
686,
198,
692,
8,
1099,
14,
28857,
1137,
378,
9,
520,
1585,
198,
692,
334,
1099,
14,
28857,
508,
841,
1602,
9,
520,
1871,
198,
1364,
14,
3584,
63,
1730,
8,
277,
9,
1585,
198,
692,
754,
14,
20394,
520,
1871,
198,
692,
334,
1099,
14,
20394,
508,
298,
3170,
531,
520,
4671,
198,
3730,
20107,
63,
1971,
8,
1099,
14,
28857,
12,
620,
8,
1099,
14,
1188,
395,
620,
8,
1099,
14,
20394,
430,
1585,
198,
2836,
520,
1871,
198,
3730,
20107,
63,
1971,
8,
1099,
14,
28857,
12,
620,
8,
1099,
14,
1188,
395,
620,
8,
1099,
14,
20394,
430,
686,
198,
1107,
754,
14,
1556,
16120,
63,
6374,
16120,
63,
9140,
507,
198,
2590,
2186,
465,
325,
520,
686,
198,
3730,
325,
421,
198,
318,
485,
362,
63,
785,
63,
354,
8,
277,
9,
520,
507,
198,
300,
624,
1803,
314,
574,
402,
909,
5148,
1423,
507,
198,
624,
507,
198,
893,
520,
686,
198,
692,
291,
14,
354,
365,
440,
488,
520,
1585,
198,
1107,
620,
8,
277,
14,
354,
9,
686,
198,
1107,
488,
507,
198,
2590,
2186,
465,
325,
520,
686,
198,
3730,
325,
6905,
198,
32,
3744,
199,
198,
318,
1050,
8,
1886,
12,
1890,
12,
2073,
9,
520,
507,
198,
893,
520,
686,
198,
692,
2073,
436,
730,
8,
1927,
9,
365,
440,
769,
520,
1585,
198,
873,
1927,
275,
2467,
16120,
63,
6374,
16120,
63,
9140,
342,
1585,
198,
873,
1927,
14,
354,
275,
2073,
14,
354,
1585,
198,
873,
1927,
14,
6374,
16120,
275,
2073,
14,
6374,
16120,
1585,
198,
1107,
1678,
1927,
14,
873,
63,
1927,
8,
1258,
9,
686,
198,
2836,
520,
1585,
198,
692,
2073,
436,
822,
8,
1927,
9,
690,
378,
520,
1871,
198,
873,
4435,
275,
359,
1556,
16120,
63,
6374,
16120,
63,
9140,
342,
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,
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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
] |
zploskey/servo
|
tests/wpt/css-tests/tools/pywebsocket/src/mod_pywebsocket/extensions.py
|
489
|
31780
|
# Copyright 2012, 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.
from mod_pywebsocket import common
from mod_pywebsocket import util
from mod_pywebsocket.http_header_util import quote_if_necessary
# The list of available server side extension processor classes.
_available_processors = {}
_compression_extension_names = []
class ExtensionProcessorInterface(object):
def __init__(self, request):
self._logger = util.get_class_logger(self)
self._request = request
self._active = True
def request(self):
return self._request
def name(self):
return None
def check_consistency_with_other_processors(self, processors):
pass
def set_active(self, active):
self._active = active
def is_active(self):
return self._active
def _get_extension_response_internal(self):
return None
def get_extension_response(self):
if not self._active:
self._logger.debug('Extension %s is deactivated', self.name())
return None
response = self._get_extension_response_internal()
if response is None:
self._active = False
return response
def _setup_stream_options_internal(self, stream_options):
pass
def setup_stream_options(self, stream_options):
if self._active:
self._setup_stream_options_internal(stream_options)
def _log_outgoing_compression_ratio(
logger, original_bytes, filtered_bytes, average_ratio):
# Print inf when ratio is not available.
ratio = float('inf')
if original_bytes != 0:
ratio = float(filtered_bytes) / original_bytes
logger.debug('Outgoing compression ratio: %f (average: %f)' %
(ratio, average_ratio))
def _log_incoming_compression_ratio(
logger, received_bytes, filtered_bytes, average_ratio):
# Print inf when ratio is not available.
ratio = float('inf')
if filtered_bytes != 0:
ratio = float(received_bytes) / filtered_bytes
logger.debug('Incoming compression ratio: %f (average: %f)' %
(ratio, average_ratio))
def _parse_window_bits(bits):
"""Return parsed integer value iff the given string conforms to the
grammar of the window bits extension parameters.
"""
if bits is None:
raise ValueError('Value is required')
# For non integer values such as "10.0", ValueError will be raised.
int_bits = int(bits)
# First condition is to drop leading zero case e.g. "08".
if bits != str(int_bits) or int_bits < 8 or int_bits > 15:
raise ValueError('Invalid value: %r' % bits)
return int_bits
class _AverageRatioCalculator(object):
"""Stores total bytes of original and result data, and calculates average
result / original ratio.
"""
def __init__(self):
self._total_original_bytes = 0
self._total_result_bytes = 0
def add_original_bytes(self, value):
self._total_original_bytes += value
def add_result_bytes(self, value):
self._total_result_bytes += value
def get_average_ratio(self):
if self._total_original_bytes != 0:
return (float(self._total_result_bytes) /
self._total_original_bytes)
else:
return float('inf')
class DeflateFrameExtensionProcessor(ExtensionProcessorInterface):
"""deflate-frame extension processor.
Specification:
http://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate
"""
_WINDOW_BITS_PARAM = 'max_window_bits'
_NO_CONTEXT_TAKEOVER_PARAM = 'no_context_takeover'
def __init__(self, request):
ExtensionProcessorInterface.__init__(self, request)
self._logger = util.get_class_logger(self)
self._response_window_bits = None
self._response_no_context_takeover = False
self._bfinal = False
# Calculates
# (Total outgoing bytes supplied to this filter) /
# (Total bytes sent to the network after applying this filter)
self._outgoing_average_ratio_calculator = _AverageRatioCalculator()
# Calculates
# (Total bytes received from the network) /
# (Total incoming bytes obtained after applying this filter)
self._incoming_average_ratio_calculator = _AverageRatioCalculator()
def name(self):
return common.DEFLATE_FRAME_EXTENSION
def _get_extension_response_internal(self):
# Any unknown parameter will be just ignored.
window_bits = None
if self._request.has_parameter(self._WINDOW_BITS_PARAM):
window_bits = self._request.get_parameter_value(
self._WINDOW_BITS_PARAM)
try:
window_bits = _parse_window_bits(window_bits)
except ValueError, e:
return None
no_context_takeover = self._request.has_parameter(
self._NO_CONTEXT_TAKEOVER_PARAM)
if (no_context_takeover and
self._request.get_parameter_value(
self._NO_CONTEXT_TAKEOVER_PARAM) is not None):
return None
self._rfc1979_deflater = util._RFC1979Deflater(
window_bits, no_context_takeover)
self._rfc1979_inflater = util._RFC1979Inflater()
self._compress_outgoing = True
response = common.ExtensionParameter(self._request.name())
if self._response_window_bits is not None:
response.add_parameter(
self._WINDOW_BITS_PARAM, str(self._response_window_bits))
if self._response_no_context_takeover:
response.add_parameter(
self._NO_CONTEXT_TAKEOVER_PARAM, None)
self._logger.debug(
'Enable %s extension ('
'request: window_bits=%s; no_context_takeover=%r, '
'response: window_wbits=%s; no_context_takeover=%r)' %
(self._request.name(),
window_bits,
no_context_takeover,
self._response_window_bits,
self._response_no_context_takeover))
return response
def _setup_stream_options_internal(self, stream_options):
class _OutgoingFilter(object):
def __init__(self, parent):
self._parent = parent
def filter(self, frame):
self._parent._outgoing_filter(frame)
class _IncomingFilter(object):
def __init__(self, parent):
self._parent = parent
def filter(self, frame):
self._parent._incoming_filter(frame)
stream_options.outgoing_frame_filters.append(
_OutgoingFilter(self))
stream_options.incoming_frame_filters.insert(
0, _IncomingFilter(self))
def set_response_window_bits(self, value):
self._response_window_bits = value
def set_response_no_context_takeover(self, value):
self._response_no_context_takeover = value
def set_bfinal(self, value):
self._bfinal = value
def enable_outgoing_compression(self):
self._compress_outgoing = True
def disable_outgoing_compression(self):
self._compress_outgoing = False
def _outgoing_filter(self, frame):
"""Transform outgoing frames. This method is called only by
an _OutgoingFilter instance.
"""
original_payload_size = len(frame.payload)
self._outgoing_average_ratio_calculator.add_original_bytes(
original_payload_size)
if (not self._compress_outgoing or
common.is_control_opcode(frame.opcode)):
self._outgoing_average_ratio_calculator.add_result_bytes(
original_payload_size)
return
frame.payload = self._rfc1979_deflater.filter(
frame.payload, bfinal=self._bfinal)
frame.rsv1 = 1
filtered_payload_size = len(frame.payload)
self._outgoing_average_ratio_calculator.add_result_bytes(
filtered_payload_size)
_log_outgoing_compression_ratio(
self._logger,
original_payload_size,
filtered_payload_size,
self._outgoing_average_ratio_calculator.get_average_ratio())
def _incoming_filter(self, frame):
"""Transform incoming frames. This method is called only by
an _IncomingFilter instance.
"""
received_payload_size = len(frame.payload)
self._incoming_average_ratio_calculator.add_result_bytes(
received_payload_size)
if frame.rsv1 != 1 or common.is_control_opcode(frame.opcode):
self._incoming_average_ratio_calculator.add_original_bytes(
received_payload_size)
return
frame.payload = self._rfc1979_inflater.filter(frame.payload)
frame.rsv1 = 0
filtered_payload_size = len(frame.payload)
self._incoming_average_ratio_calculator.add_original_bytes(
filtered_payload_size)
_log_incoming_compression_ratio(
self._logger,
received_payload_size,
filtered_payload_size,
self._incoming_average_ratio_calculator.get_average_ratio())
_available_processors[common.DEFLATE_FRAME_EXTENSION] = (
DeflateFrameExtensionProcessor)
_compression_extension_names.append(common.DEFLATE_FRAME_EXTENSION)
_available_processors[common.X_WEBKIT_DEFLATE_FRAME_EXTENSION] = (
DeflateFrameExtensionProcessor)
_compression_extension_names.append(common.X_WEBKIT_DEFLATE_FRAME_EXTENSION)
def _parse_compression_method(data):
"""Parses the value of "method" extension parameter."""
return common.parse_extensions(data)
def _create_accepted_method_desc(method_name, method_params):
"""Creates accepted-method-desc from given method name and parameters"""
extension = common.ExtensionParameter(method_name)
for name, value in method_params:
extension.add_parameter(name, value)
return common.format_extension(extension)
class CompressionExtensionProcessorBase(ExtensionProcessorInterface):
"""Base class for perframe-compress and permessage-compress extension."""
_METHOD_PARAM = 'method'
def __init__(self, request):
ExtensionProcessorInterface.__init__(self, request)
self._logger = util.get_class_logger(self)
self._compression_method_name = None
self._compression_processor = None
self._compression_processor_hook = None
def name(self):
return ''
def _lookup_compression_processor(self, method_desc):
return None
def _get_compression_processor_response(self):
"""Looks up the compression processor based on the self._request and
returns the compression processor's response.
"""
method_list = self._request.get_parameter_value(self._METHOD_PARAM)
if method_list is None:
return None
methods = _parse_compression_method(method_list)
if methods is None:
return None
comression_processor = None
# The current implementation tries only the first method that matches
# supported algorithm. Following methods aren't tried even if the
# first one is rejected.
# TODO(bashi): Need to clarify this behavior.
for method_desc in methods:
compression_processor = self._lookup_compression_processor(
method_desc)
if compression_processor is not None:
self._compression_method_name = method_desc.name()
break
if compression_processor is None:
return None
if self._compression_processor_hook:
self._compression_processor_hook(compression_processor)
processor_response = compression_processor.get_extension_response()
if processor_response is None:
return None
self._compression_processor = compression_processor
return processor_response
def _get_extension_response_internal(self):
processor_response = self._get_compression_processor_response()
if processor_response is None:
return None
response = common.ExtensionParameter(self._request.name())
accepted_method_desc = _create_accepted_method_desc(
self._compression_method_name,
processor_response.get_parameters())
response.add_parameter(self._METHOD_PARAM, accepted_method_desc)
self._logger.debug(
'Enable %s extension (method: %s)' %
(self._request.name(), self._compression_method_name))
return response
def _setup_stream_options_internal(self, stream_options):
if self._compression_processor is None:
return
self._compression_processor.setup_stream_options(stream_options)
def set_compression_processor_hook(self, hook):
self._compression_processor_hook = hook
def get_compression_processor(self):
return self._compression_processor
class PerMessageDeflateExtensionProcessor(ExtensionProcessorInterface):
"""permessage-deflate extension processor. It's also used for
permessage-compress extension when the deflate method is chosen.
Specification:
http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-08
"""
_SERVER_MAX_WINDOW_BITS_PARAM = 'server_max_window_bits'
_SERVER_NO_CONTEXT_TAKEOVER_PARAM = 'server_no_context_takeover'
_CLIENT_MAX_WINDOW_BITS_PARAM = 'client_max_window_bits'
_CLIENT_NO_CONTEXT_TAKEOVER_PARAM = 'client_no_context_takeover'
def __init__(self, request, draft08=True):
"""Construct PerMessageDeflateExtensionProcessor
Args:
draft08: Follow the constraints on the parameters that were not
specified for permessage-compress but are specified for
permessage-deflate as on
draft-ietf-hybi-permessage-compression-08.
"""
ExtensionProcessorInterface.__init__(self, request)
self._logger = util.get_class_logger(self)
self._preferred_client_max_window_bits = None
self._client_no_context_takeover = False
self._draft08 = draft08
def name(self):
return 'deflate'
def _get_extension_response_internal(self):
if self._draft08:
for name in self._request.get_parameter_names():
if name not in [self._SERVER_MAX_WINDOW_BITS_PARAM,
self._SERVER_NO_CONTEXT_TAKEOVER_PARAM,
self._CLIENT_MAX_WINDOW_BITS_PARAM]:
self._logger.debug('Unknown parameter: %r', name)
return None
else:
# Any unknown parameter will be just ignored.
pass
server_max_window_bits = None
if self._request.has_parameter(self._SERVER_MAX_WINDOW_BITS_PARAM):
server_max_window_bits = self._request.get_parameter_value(
self._SERVER_MAX_WINDOW_BITS_PARAM)
try:
server_max_window_bits = _parse_window_bits(
server_max_window_bits)
except ValueError, e:
self._logger.debug('Bad %s parameter: %r',
self._SERVER_MAX_WINDOW_BITS_PARAM,
e)
return None
server_no_context_takeover = self._request.has_parameter(
self._SERVER_NO_CONTEXT_TAKEOVER_PARAM)
if (server_no_context_takeover and
self._request.get_parameter_value(
self._SERVER_NO_CONTEXT_TAKEOVER_PARAM) is not None):
self._logger.debug('%s parameter must not have a value: %r',
self._SERVER_NO_CONTEXT_TAKEOVER_PARAM,
server_no_context_takeover)
return None
# client_max_window_bits from a client indicates whether the client can
# accept client_max_window_bits from a server or not.
client_client_max_window_bits = self._request.has_parameter(
self._CLIENT_MAX_WINDOW_BITS_PARAM)
if (self._draft08 and
client_client_max_window_bits and
self._request.get_parameter_value(
self._CLIENT_MAX_WINDOW_BITS_PARAM) is not None):
self._logger.debug('%s parameter must not have a value in a '
'client\'s opening handshake: %r',
self._CLIENT_MAX_WINDOW_BITS_PARAM,
client_client_max_window_bits)
return None
self._rfc1979_deflater = util._RFC1979Deflater(
server_max_window_bits, server_no_context_takeover)
# Note that we prepare for incoming messages compressed with window
# bits upto 15 regardless of the client_max_window_bits value to be
# sent to the client.
self._rfc1979_inflater = util._RFC1979Inflater()
self._framer = _PerMessageDeflateFramer(
server_max_window_bits, server_no_context_takeover)
self._framer.set_bfinal(False)
self._framer.set_compress_outgoing_enabled(True)
response = common.ExtensionParameter(self._request.name())
if server_max_window_bits is not None:
response.add_parameter(
self._SERVER_MAX_WINDOW_BITS_PARAM,
str(server_max_window_bits))
if server_no_context_takeover:
response.add_parameter(
self._SERVER_NO_CONTEXT_TAKEOVER_PARAM, None)
if self._preferred_client_max_window_bits is not None:
if self._draft08 and not client_client_max_window_bits:
self._logger.debug('Processor is configured to use %s but '
'the client cannot accept it',
self._CLIENT_MAX_WINDOW_BITS_PARAM)
return None
response.add_parameter(
self._CLIENT_MAX_WINDOW_BITS_PARAM,
str(self._preferred_client_max_window_bits))
if self._client_no_context_takeover:
response.add_parameter(
self._CLIENT_NO_CONTEXT_TAKEOVER_PARAM, None)
self._logger.debug(
'Enable %s extension ('
'request: server_max_window_bits=%s; '
'server_no_context_takeover=%r, '
'response: client_max_window_bits=%s; '
'client_no_context_takeover=%r)' %
(self._request.name(),
server_max_window_bits,
server_no_context_takeover,
self._preferred_client_max_window_bits,
self._client_no_context_takeover))
return response
def _setup_stream_options_internal(self, stream_options):
self._framer.setup_stream_options(stream_options)
def set_client_max_window_bits(self, value):
"""If this option is specified, this class adds the
client_max_window_bits extension parameter to the handshake response,
but doesn't reduce the LZ77 sliding window size of its inflater.
I.e., you can use this for testing client implementation but cannot
reduce memory usage of this class.
If this method has been called with True and an offer without the
client_max_window_bits extension parameter is received,
- (When processing the permessage-deflate extension) this processor
declines the request.
- (When processing the permessage-compress extension) this processor
accepts the request.
"""
self._preferred_client_max_window_bits = value
def set_client_no_context_takeover(self, value):
"""If this option is specified, this class adds the
client_no_context_takeover extension parameter to the handshake
response, but doesn't reset inflater for each message. I.e., you can
use this for testing client implementation but cannot reduce memory
usage of this class.
"""
self._client_no_context_takeover = value
def set_bfinal(self, value):
self._framer.set_bfinal(value)
def enable_outgoing_compression(self):
self._framer.set_compress_outgoing_enabled(True)
def disable_outgoing_compression(self):
self._framer.set_compress_outgoing_enabled(False)
class _PerMessageDeflateFramer(object):
"""A framer for extensions with per-message DEFLATE feature."""
def __init__(self, deflate_max_window_bits, deflate_no_context_takeover):
self._logger = util.get_class_logger(self)
self._rfc1979_deflater = util._RFC1979Deflater(
deflate_max_window_bits, deflate_no_context_takeover)
self._rfc1979_inflater = util._RFC1979Inflater()
self._bfinal = False
self._compress_outgoing_enabled = False
# True if a message is fragmented and compression is ongoing.
self._compress_ongoing = False
# Calculates
# (Total outgoing bytes supplied to this filter) /
# (Total bytes sent to the network after applying this filter)
self._outgoing_average_ratio_calculator = _AverageRatioCalculator()
# Calculates
# (Total bytes received from the network) /
# (Total incoming bytes obtained after applying this filter)
self._incoming_average_ratio_calculator = _AverageRatioCalculator()
def set_bfinal(self, value):
self._bfinal = value
def set_compress_outgoing_enabled(self, value):
self._compress_outgoing_enabled = value
def _process_incoming_message(self, message, decompress):
if not decompress:
return message
received_payload_size = len(message)
self._incoming_average_ratio_calculator.add_result_bytes(
received_payload_size)
message = self._rfc1979_inflater.filter(message)
filtered_payload_size = len(message)
self._incoming_average_ratio_calculator.add_original_bytes(
filtered_payload_size)
_log_incoming_compression_ratio(
self._logger,
received_payload_size,
filtered_payload_size,
self._incoming_average_ratio_calculator.get_average_ratio())
return message
def _process_outgoing_message(self, message, end, binary):
if not binary:
message = message.encode('utf-8')
if not self._compress_outgoing_enabled:
return message
original_payload_size = len(message)
self._outgoing_average_ratio_calculator.add_original_bytes(
original_payload_size)
message = self._rfc1979_deflater.filter(
message, end=end, bfinal=self._bfinal)
filtered_payload_size = len(message)
self._outgoing_average_ratio_calculator.add_result_bytes(
filtered_payload_size)
_log_outgoing_compression_ratio(
self._logger,
original_payload_size,
filtered_payload_size,
self._outgoing_average_ratio_calculator.get_average_ratio())
if not self._compress_ongoing:
self._outgoing_frame_filter.set_compression_bit()
self._compress_ongoing = not end
return message
def _process_incoming_frame(self, frame):
if frame.rsv1 == 1 and not common.is_control_opcode(frame.opcode):
self._incoming_message_filter.decompress_next_message()
frame.rsv1 = 0
def _process_outgoing_frame(self, frame, compression_bit):
if (not compression_bit or
common.is_control_opcode(frame.opcode)):
return
frame.rsv1 = 1
def setup_stream_options(self, stream_options):
"""Creates filters and sets them to the StreamOptions."""
class _OutgoingMessageFilter(object):
def __init__(self, parent):
self._parent = parent
def filter(self, message, end=True, binary=False):
return self._parent._process_outgoing_message(
message, end, binary)
class _IncomingMessageFilter(object):
def __init__(self, parent):
self._parent = parent
self._decompress_next_message = False
def decompress_next_message(self):
self._decompress_next_message = True
def filter(self, message):
message = self._parent._process_incoming_message(
message, self._decompress_next_message)
self._decompress_next_message = False
return message
self._outgoing_message_filter = _OutgoingMessageFilter(self)
self._incoming_message_filter = _IncomingMessageFilter(self)
stream_options.outgoing_message_filters.append(
self._outgoing_message_filter)
stream_options.incoming_message_filters.append(
self._incoming_message_filter)
class _OutgoingFrameFilter(object):
def __init__(self, parent):
self._parent = parent
self._set_compression_bit = False
def set_compression_bit(self):
self._set_compression_bit = True
def filter(self, frame):
self._parent._process_outgoing_frame(
frame, self._set_compression_bit)
self._set_compression_bit = False
class _IncomingFrameFilter(object):
def __init__(self, parent):
self._parent = parent
def filter(self, frame):
self._parent._process_incoming_frame(frame)
self._outgoing_frame_filter = _OutgoingFrameFilter(self)
self._incoming_frame_filter = _IncomingFrameFilter(self)
stream_options.outgoing_frame_filters.append(
self._outgoing_frame_filter)
stream_options.incoming_frame_filters.append(
self._incoming_frame_filter)
stream_options.encode_text_message_to_utf8 = False
_available_processors[common.PERMESSAGE_DEFLATE_EXTENSION] = (
PerMessageDeflateExtensionProcessor)
# TODO(tyoshino): Reorganize class names.
_compression_extension_names.append('deflate')
class PerMessageCompressExtensionProcessor(
CompressionExtensionProcessorBase):
"""permessage-compress extension processor.
Specification:
http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression
"""
_DEFLATE_METHOD = 'deflate'
def __init__(self, request):
CompressionExtensionProcessorBase.__init__(self, request)
def name(self):
return common.PERMESSAGE_COMPRESSION_EXTENSION
def _lookup_compression_processor(self, method_desc):
if method_desc.name() == self._DEFLATE_METHOD:
return PerMessageDeflateExtensionProcessor(method_desc, False)
return None
_available_processors[common.PERMESSAGE_COMPRESSION_EXTENSION] = (
PerMessageCompressExtensionProcessor)
_compression_extension_names.append(common.PERMESSAGE_COMPRESSION_EXTENSION)
class MuxExtensionProcessor(ExtensionProcessorInterface):
"""WebSocket multiplexing extension processor."""
_QUOTA_PARAM = 'quota'
def __init__(self, request):
ExtensionProcessorInterface.__init__(self, request)
self._quota = 0
self._extensions = []
def name(self):
return common.MUX_EXTENSION
def check_consistency_with_other_processors(self, processors):
before_mux = True
for processor in processors:
name = processor.name()
if name == self.name():
before_mux = False
continue
if not processor.is_active():
continue
if before_mux:
# Mux extension cannot be used after extensions
# that depend on frame boundary, extension data field, or any
# reserved bits which are attributed to each frame.
if (name == common.DEFLATE_FRAME_EXTENSION or
name == common.X_WEBKIT_DEFLATE_FRAME_EXTENSION):
self.set_active(False)
return
else:
# Mux extension should not be applied before any history-based
# compression extension.
if (name == common.DEFLATE_FRAME_EXTENSION or
name == common.X_WEBKIT_DEFLATE_FRAME_EXTENSION or
name == common.PERMESSAGE_COMPRESSION_EXTENSION or
name == common.X_WEBKIT_PERMESSAGE_COMPRESSION_EXTENSION):
self.set_active(False)
return
def _get_extension_response_internal(self):
self._active = False
quota = self._request.get_parameter_value(self._QUOTA_PARAM)
if quota is not None:
try:
quota = int(quota)
except ValueError, e:
return None
if quota < 0 or quota >= 2 ** 32:
return None
self._quota = quota
self._active = True
return common.ExtensionParameter(common.MUX_EXTENSION)
def _setup_stream_options_internal(self, stream_options):
pass
def set_quota(self, quota):
self._quota = quota
def quota(self):
return self._quota
def set_extensions(self, extensions):
self._extensions = extensions
def extensions(self):
return self._extensions
_available_processors[common.MUX_EXTENSION] = MuxExtensionProcessor
def get_extension_processor(extension_request):
"""Given an ExtensionParameter representing an extension offer received
from a client, configures and returns an instance of the corresponding
extension processor class.
"""
processor_class = _available_processors.get(extension_request.name())
if processor_class is None:
return None
return processor_class(extension_request)
def is_compression_extension(extension_name):
return extension_name in _compression_extension_names
# vi:sts=4 sw=4 et
|
mpl-2.0
|
[
3,
1898,
6029,
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,
421,
199,
504,
3413,
63,
21387,
492,
2863,
199,
504,
3413,
63,
21387,
492,
4884,
199,
504,
3413,
63,
21387,
14,
1014,
63,
1291,
63,
1974,
492,
6313,
63,
692,
63,
17927,
421,
199,
3,
710,
769,
402,
2808,
1654,
5366,
3329,
12495,
3992,
14,
199,
63,
4561,
63,
10547,
275,
1052,
199,
63,
12849,
63,
3435,
63,
1247,
275,
942,
421,
199,
533,
13282,
10438,
4267,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1056,
304,
267,
291,
423,
2921,
275,
4884,
14,
362,
63,
533,
63,
2921,
8,
277,
9,
398,
291,
423,
1069,
275,
1056,
267,
291,
423,
2682,
275,
715,
339,
347,
1056,
8,
277,
304,
267,
372,
291,
423,
1069,
339,
347,
536,
8,
277,
304,
267,
372,
488,
339,
347,
1104,
63,
20249,
63,
1045,
63,
1848,
63,
10547,
8,
277,
12,
21620,
304,
267,
986,
339,
347,
663,
63,
2682,
8,
277,
12,
4702,
304,
267,
291,
423,
2682,
275,
4702,
339,
347,
365,
63,
2682,
8,
277,
304,
267,
372,
291,
423,
2682,
339,
347,
485,
362,
63,
3435,
63,
1310,
63,
4672,
8,
277,
304,
267,
372,
488,
339,
347,
664,
63,
3435,
63,
1310,
8,
277,
304,
267,
340,
440,
291,
423,
2682,
26,
288,
291,
423,
2921,
14,
1757,
360,
6382,
450,
83,
365,
477,
18218,
297,
291,
14,
354,
1012,
288,
372,
488,
398,
1177,
275,
291,
423,
362,
63,
3435,
63,
1310,
63,
4672,
342,
267,
340,
1177,
365,
488,
26,
288,
291,
423,
2682,
275,
756,
267,
372,
1177,
339,
347,
485,
2758,
63,
1745,
63,
1419,
63,
4672,
8,
277,
12,
2547,
63,
1419,
304,
267,
986,
339,
347,
3272,
63,
1745,
63,
1419,
8,
277,
12,
2547,
63,
1419,
304,
267,
340,
291,
423,
2682,
26,
288,
291,
423,
2758,
63,
1745,
63,
1419,
63,
4672,
8,
1745,
63,
1419,
9,
421,
199,
318,
485,
793,
63,
19388,
63,
12849,
63,
6884,
8,
267,
2512,
12,
3379,
63,
2394,
12,
9806,
63,
2394,
12,
8095,
63,
6884,
304,
272,
327,
9101,
10739,
1380,
10463,
365,
440,
2808,
14,
272,
10463,
275,
2069,
360,
4904,
358,
272,
340,
3379,
63,
2394,
1137,
378,
26,
267,
10463,
275,
2069,
8,
11142,
63,
2394,
9,
1182,
3379,
63,
2394,
339,
2512,
14,
1757,
360,
2204,
10947,
10291,
10463,
26,
450,
70,
334,
8536,
26,
450,
70,
3171,
450,
288,
334,
6884,
12,
8095,
63,
6884,
430,
421,
199,
318,
485,
793,
63,
15994,
63,
12849,
63,
6884,
8,
267,
2512,
12,
3086,
63,
2394,
12,
9806,
63,
2394,
12,
8095,
63,
6884,
304,
272,
327,
9101,
10739,
1380,
10463,
365,
440,
2808,
14,
272,
10463,
275,
2069,
360,
4904,
358,
272,
340,
9806,
63,
2394,
1137,
378,
26,
267,
10463,
275,
2069,
8,
9226,
63,
2394,
9,
1182,
9806,
63,
2394,
339,
2512,
14,
1757,
360,
607,
7909,
10291,
10463,
26,
450,
70,
334,
8536,
26,
450,
70,
3171,
450,
288,
334,
6884,
12,
8095,
63,
6884,
430,
421,
199,
318,
485,
1122,
63,
3806,
63,
5609,
8,
5609,
304,
272,
408,
1767,
4565,
3000,
574,
17963,
314,
1627,
1059,
406,
3351,
370,
314,
272,
12528,
402,
314,
4353,
5821,
3329,
2633,
14,
272,
408,
339,
340,
5821,
365,
488,
26,
267,
746,
1722,
360,
1110,
365,
1415,
358,
339,
327,
2104,
2222,
3000,
1338,
4066,
465,
298,
709,
14,
16,
401,
1722,
911,
506,
4915,
14,
272,
1109,
63,
5609,
275,
1109,
8,
5609,
9,
339,
327,
7758,
5558,
365,
370,
5978,
9186,
4697,
1930,
325,
14,
71,
14,
298,
2036,
1674,
272,
340,
5821,
1137,
620,
8,
442,
63,
5609,
9,
503,
1109,
63,
5609,
665,
1695,
503,
1109,
63,
5609,
690,
4114,
26,
267,
746,
1722,
360,
3364,
574,
26,
450,
82,
7,
450,
5821,
9,
339,
372,
1109,
63,
5609,
421,
199,
533,
485,
17400,
13971,
20000,
8,
785,
304,
272,
408,
4759,
470,
3141,
2783,
402,
3379,
436,
754,
666,
12,
436,
6966,
2335,
8095,
272,
754,
1182,
3379,
10463,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2923,
63,
5043,
63,
2394,
275,
378,
267,
291,
423,
2923,
63,
1099,
63,
2394,
275,
378,
339,
347,
1050,
63,
5043,
63,
2394,
8,
277,
12,
574,
304,
267,
291
] |
[
1898,
6029,
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,
421,
199,
504,
3413,
63,
21387,
492,
2863,
199,
504,
3413,
63,
21387,
492,
4884,
199,
504,
3413,
63,
21387,
14,
1014,
63,
1291,
63,
1974,
492,
6313,
63,
692,
63,
17927,
421,
199,
3,
710,
769,
402,
2808,
1654,
5366,
3329,
12495,
3992,
14,
199,
63,
4561,
63,
10547,
275,
1052,
199,
63,
12849,
63,
3435,
63,
1247,
275,
942,
421,
199,
533,
13282,
10438,
4267,
8,
785,
304,
339,
347,
636,
826,
721,
277,
12,
1056,
304,
267,
291,
423,
2921,
275,
4884,
14,
362,
63,
533,
63,
2921,
8,
277,
9,
398,
291,
423,
1069,
275,
1056,
267,
291,
423,
2682,
275,
715,
339,
347,
1056,
8,
277,
304,
267,
372,
291,
423,
1069,
339,
347,
536,
8,
277,
304,
267,
372,
488,
339,
347,
1104,
63,
20249,
63,
1045,
63,
1848,
63,
10547,
8,
277,
12,
21620,
304,
267,
986,
339,
347,
663,
63,
2682,
8,
277,
12,
4702,
304,
267,
291,
423,
2682,
275,
4702,
339,
347,
365,
63,
2682,
8,
277,
304,
267,
372,
291,
423,
2682,
339,
347,
485,
362,
63,
3435,
63,
1310,
63,
4672,
8,
277,
304,
267,
372,
488,
339,
347,
664,
63,
3435,
63,
1310,
8,
277,
304,
267,
340,
440,
291,
423,
2682,
26,
288,
291,
423,
2921,
14,
1757,
360,
6382,
450,
83,
365,
477,
18218,
297,
291,
14,
354,
1012,
288,
372,
488,
398,
1177,
275,
291,
423,
362,
63,
3435,
63,
1310,
63,
4672,
342,
267,
340,
1177,
365,
488,
26,
288,
291,
423,
2682,
275,
756,
267,
372,
1177,
339,
347,
485,
2758,
63,
1745,
63,
1419,
63,
4672,
8,
277,
12,
2547,
63,
1419,
304,
267,
986,
339,
347,
3272,
63,
1745,
63,
1419,
8,
277,
12,
2547,
63,
1419,
304,
267,
340,
291,
423,
2682,
26,
288,
291,
423,
2758,
63,
1745,
63,
1419,
63,
4672,
8,
1745,
63,
1419,
9,
421,
199,
318,
485,
793,
63,
19388,
63,
12849,
63,
6884,
8,
267,
2512,
12,
3379,
63,
2394,
12,
9806,
63,
2394,
12,
8095,
63,
6884,
304,
272,
327,
9101,
10739,
1380,
10463,
365,
440,
2808,
14,
272,
10463,
275,
2069,
360,
4904,
358,
272,
340,
3379,
63,
2394,
1137,
378,
26,
267,
10463,
275,
2069,
8,
11142,
63,
2394,
9,
1182,
3379,
63,
2394,
339,
2512,
14,
1757,
360,
2204,
10947,
10291,
10463,
26,
450,
70,
334,
8536,
26,
450,
70,
3171,
450,
288,
334,
6884,
12,
8095,
63,
6884,
430,
421,
199,
318,
485,
793,
63,
15994,
63,
12849,
63,
6884,
8,
267,
2512,
12,
3086,
63,
2394,
12,
9806,
63,
2394,
12,
8095,
63,
6884,
304,
272,
327,
9101,
10739,
1380,
10463,
365,
440,
2808,
14,
272,
10463,
275,
2069,
360,
4904,
358,
272,
340,
9806,
63,
2394,
1137,
378,
26,
267,
10463,
275,
2069,
8,
9226,
63,
2394,
9,
1182,
9806,
63,
2394,
339,
2512,
14,
1757,
360,
607,
7909,
10291,
10463,
26,
450,
70,
334,
8536,
26,
450,
70,
3171,
450,
288,
334,
6884,
12,
8095,
63,
6884,
430,
421,
199,
318,
485,
1122,
63,
3806,
63,
5609,
8,
5609,
304,
272,
408,
1767,
4565,
3000,
574,
17963,
314,
1627,
1059,
406,
3351,
370,
314,
272,
12528,
402,
314,
4353,
5821,
3329,
2633,
14,
272,
408,
339,
340,
5821,
365,
488,
26,
267,
746,
1722,
360,
1110,
365,
1415,
358,
339,
327,
2104,
2222,
3000,
1338,
4066,
465,
298,
709,
14,
16,
401,
1722,
911,
506,
4915,
14,
272,
1109,
63,
5609,
275,
1109,
8,
5609,
9,
339,
327,
7758,
5558,
365,
370,
5978,
9186,
4697,
1930,
325,
14,
71,
14,
298,
2036,
1674,
272,
340,
5821,
1137,
620,
8,
442,
63,
5609,
9,
503,
1109,
63,
5609,
665,
1695,
503,
1109,
63,
5609,
690,
4114,
26,
267,
746,
1722,
360,
3364,
574,
26,
450,
82,
7,
450,
5821,
9,
339,
372,
1109,
63,
5609,
421,
199,
533,
485,
17400,
13971,
20000,
8,
785,
304,
272,
408,
4759,
470,
3141,
2783,
402,
3379,
436,
754,
666,
12,
436,
6966,
2335,
8095,
272,
754,
1182,
3379,
10463,
14,
272,
408,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2923,
63,
5043,
63,
2394,
275,
378,
267,
291,
423,
2923,
63,
1099,
63,
2394,
275,
378,
339,
347,
1050,
63,
5043,
63,
2394,
8,
277,
12,
574,
304,
267,
291,
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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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
] |
Nick-OpusVL/odoo
|
addons/association/__openerp__.py
|
260
|
1700
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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/>.
#
##############################################################################
{
'name': 'Associations Management',
'version': '0.1',
'category': 'Specific Industry Applications',
'description': """
This module is to configure modules related to an association.
==============================================================
It installs the profile for associations to manage events, registrations, memberships,
membership products (schemes).
""",
'author': 'OpenERP SA',
'depends': ['base_setup', 'membership', 'event'],
'data': ['security/ir.model.access.csv', 'profile_association.xml'],
'demo': [],
'installable': True,
'auto_install': False,
'website': 'https://www.odoo.com'
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
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,
421,
199,
91,
272,
283,
354,
356,
283,
14889,
1298,
8259,
297,
272,
283,
1023,
356,
283,
16,
14,
17,
297,
272,
283,
3710,
356,
283,
16786,
473,
977,
11409,
89,
24636,
297,
272,
283,
1802,
356,
408,
199,
2765,
859,
365,
370,
7908,
4621,
4048,
370,
376,
20640,
14,
199,
12813,
17224,
199,
199,
7940,
25801,
314,
4690,
367,
4035,
1298,
370,
9635,
4474,
12,
25483,
3801,
12,
14616,
83,
12,
221,
199,
13105,
7585,
334,
26818,
680,
272,
10327,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
8912,
356,
788,
1095,
63,
2758,
297,
283,
13105,
297,
283,
1430,
995,
272,
283,
576,
356,
788,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
283,
2913,
63,
20252,
14,
1652,
995,
272,
283,
8768,
356,
990,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
272,
283,
7360,
356,
283,
2859,
921,
1544,
14,
22058,
14,
957,
7,
199,
93,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
6542,
11947,
12361,
8642,
1014,
921,
9864,
14,
1235,
10121,
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,
421,
199,
91,
272,
283,
354,
356,
283,
14889,
1298,
8259,
297,
272,
283,
1023,
356,
283,
16,
14,
17,
297,
272,
283,
3710,
356,
283,
16786,
473,
977,
11409,
89,
24636,
297,
272,
283,
1802,
356,
408,
199,
2765,
859,
365,
370,
7908,
4621,
4048,
370,
376,
20640,
14,
199,
12813,
17224,
199,
199,
7940,
25801,
314,
4690,
367,
4035,
1298,
370,
9635,
4474,
12,
25483,
3801,
12,
14616,
83,
12,
221,
199,
13105,
7585,
334,
26818,
680,
272,
10327,
272,
283,
2502,
356,
283,
25347,
13950,
297,
272,
283,
8912,
356,
788,
1095,
63,
2758,
297,
283,
13105,
297,
283,
1430,
995,
272,
283,
576,
356,
788,
4416,
15,
723,
14,
1238,
14,
2732,
14,
4737,
297,
283,
2913,
63,
20252,
14,
1652,
995,
272,
283,
8768,
356,
990,
272,
283,
21762,
356,
715,
12,
272,
283,
2495,
63,
3174,
356,
756,
12,
272,
283,
7360,
356,
283,
2859,
921,
1544,
14,
22058,
14,
957,
7,
199,
93,
199,
3,
6695,
26,
10379,
26,
10558,
26,
6492,
29,
20,
26,
10503,
29,
20,
26,
10425,
29,
20,
26,
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,
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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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
] |
gangadhar-kadam/sapphire_app
|
hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
|
2
|
2974
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, cint
from webnotes import msgprint, _
def execute(filters=None):
if not filters: filters = {}
conditions, filters = get_conditions(filters)
columns = get_columns(filters)
att_map = get_attendance_list(conditions, filters)
emp_map = get_employee_details()
data = []
for emp in sorted(att_map):
emp_det = emp_map.get(emp)
row = [emp, emp_det.employee_name, emp_det.branch, emp_det.department, emp_det.designation,
emp_det.company]
total_p = total_a = 0.0
for day in range(filters["total_days_in_month"]):
status = att_map.get(emp).get(day + 1, "Absent")
status_map = {"Present": "P", "Absent": "A", "Half Day": "HD"}
row.append(status_map[status])
if status == "Present":
total_p += 1
elif status == "Absent":
total_a += 1
elif status == "Half Day":
total_p += 0.5
total_a += 0.5
row += [total_p, total_a]
data.append(row)
return columns, data
def get_columns(filters):
columns = [
"Employee:Link/Employee:120", "Employee Name::140", "Branch:Link/Branch:120",
"Department:Link/Department:120", "Designation:Link/Designation:120",
"Company:Link/Company:120"
]
for day in range(filters["total_days_in_month"]):
columns.append(cstr(day+1) +"::20")
columns += ["Total Present:Float:80", "Total Absent:Float:80"]
return columns
def get_attendance_list(conditions, filters):
attendance_list = webnotes.conn.sql("""select employee, day(att_date) as day_of_month,
status from tabAttendance where docstatus = 1 %s order by employee, att_date""" %
conditions, filters, as_dict=1)
att_map = {}
for d in attendance_list:
att_map.setdefault(d.employee, webnotes._dict()).setdefault(d.day_of_month, "")
att_map[d.employee][d.day_of_month] = d.status
return att_map
def get_conditions(filters):
if not (filters.get("month") and filters.get("fiscal_year")):
msgprint(_("Please select month and year"), raise_exception=1)
filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec"].index(filters["month"]) + 1
from calendar import monthrange
filters["total_days_in_month"] = monthrange(cint(filters["fiscal_year"].split("-")[-1]),
filters["month"])[1]
conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s"
if filters.get("company"): conditions += " and company = %(company)s"
if filters.get("employee"): conditions += " and employee = %(employee)s"
return conditions, filters
def get_employee_details():
employee = webnotes.conn.sql("""select name, employee_name, designation, department,
branch, company from tabEmployee where docstatus < 2 and status = 'Active'""", as_dict=1)
emp_map = {}
for emp in employee:
emp_map[emp.name] = emp
return emp_map
|
agpl-3.0
|
[
3,
1898,
334,
67,
9,
6171,
12,
6001,
8144,
19215,
29053,
14,
12126,
14,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
23154,
199,
504,
23154,
14,
1208,
492,
286,
495,
12,
286,
442,
199,
504,
23154,
492,
1499,
1361,
12,
485,
199,
199,
318,
5341,
8,
4273,
29,
403,
304,
199,
198,
692,
440,
4766,
26,
4766,
275,
1052,
8299,
198,
9855,
12,
4766,
275,
664,
63,
9855,
8,
4273,
9,
199,
198,
3406,
275,
664,
63,
3406,
8,
4273,
9,
199,
198,
6796,
63,
1130,
275,
664,
63,
23985,
63,
513,
8,
9855,
12,
4766,
9,
199,
198,
2109,
63,
1130,
275,
664,
63,
10103,
63,
5087,
342,
8299,
198,
576,
275,
942,
199,
198,
509,
9052,
315,
3355,
8,
6796,
63,
1130,
304,
507,
198,
2109,
63,
9886,
275,
9052,
63,
1130,
14,
362,
8,
2109,
9,
507,
198,
1143,
275,
359,
2109,
12,
9052,
63,
9886,
14,
10103,
63,
354,
12,
9052,
63,
9886,
14,
4694,
12,
9052,
63,
9886,
14,
19623,
12,
9052,
63,
9886,
14,
14748,
425,
12,
20866,
198,
2109,
63,
9886,
14,
4627,
61,
1585,
507,
198,
2923,
63,
80,
275,
3141,
63,
65,
275,
378,
14,
16,
507,
198,
509,
5382,
315,
1425,
8,
4273,
905,
2923,
63,
4899,
63,
262,
63,
4482,
21473,
686,
198,
1205,
275,
15115,
63,
1130,
14,
362,
8,
2109,
680,
362,
8,
2977,
435,
413,
12,
298,
5583,
1150,
531,
686,
198,
1205,
63,
1130,
275,
2420,
19794,
582,
298,
48,
401,
298,
5583,
1150,
582,
298,
33,
401,
298,
21132,
28358,
582,
298,
14903,
3570,
686,
198,
1143,
14,
740,
8,
1205,
63,
1130,
59,
1205,
566,
26140,
198,
692,
2004,
508,
298,
19794,
582,
1585,
198,
2923,
63,
80,
847,
413,
686,
198,
4164,
2004,
508,
298,
5583,
1150,
582,
1585,
198,
2923,
63,
65,
847,
413,
686,
198,
4164,
2004,
508,
298,
21132,
28358,
582,
1585,
198,
2923,
63,
80,
847,
378,
14,
21,
1585,
198,
2923,
63,
65,
847,
378,
14,
21,
28550,
198,
1143,
847,
359,
2923,
63,
80,
12,
3141,
63,
65,
61,
9068,
198,
576,
14,
740,
8,
1143,
9,
8299,
198,
1107,
4362,
12,
666,
507,
199,
318,
664,
63,
3406,
8,
4273,
304,
199,
198,
3406,
275,
359,
507,
198,
2,
22635,
26,
3834,
15,
22635,
26,
6708,
401,
298,
22635,
2812,
447,
10037,
401,
298,
12526,
26,
3834,
15,
12526,
26,
6708,
401,
11083,
198,
2,
872,
12493,
26,
3834,
15,
872,
12493,
26,
6708,
401,
298,
20924,
425,
26,
3834,
15,
20924,
425,
26,
6708,
401,
686,
298,
16063,
26,
3834,
15,
16063,
26,
6708,
2,
199,
198,
61,
8299,
198,
509,
5382,
315,
1425,
8,
4273,
905,
2923,
63,
4899,
63,
262,
63,
4482,
21473,
507,
198,
3406,
14,
740,
8,
67,
495,
8,
2977,
11,
17,
9,
435,
2,
447,
1165,
531,
18118,
198,
3406,
847,
2097,
7316,
5543,
1150,
26,
5136,
26,
1257,
401,
298,
7316,
8351,
1150,
26,
5136,
26,
1257,
937,
199,
198,
1107,
4362,
507,
199,
318,
664,
63,
23985,
63,
513,
8,
9855,
12,
4766,
304,
199,
198,
23985,
63,
513,
275,
23154,
14,
1631,
14,
3009,
4852,
2416,
15778,
12,
5382,
8,
6796,
63,
602,
9,
465,
5382,
63,
1618,
63,
4482,
12,
11083,
198,
1205,
687,
5174,
1271,
7169,
554,
2382,
1382,
1205,
275,
413,
450,
83,
1865,
701,
15778,
12,
15115,
63,
602,
624,
450,
11083,
198,
9855,
12,
4766,
12,
465,
63,
807,
29,
17,
9,
18118,
198,
6796,
63,
1130,
275,
1052,
199,
198,
509,
366,
315,
737,
7169,
554,
63,
513,
26,
507,
198,
6796,
63,
1130,
14,
5486,
8,
68,
14,
10103,
12,
23154,
423,
807,
8801,
5486,
8,
68,
14,
2977,
63,
1618,
63,
4482,
12,
6899,
507,
198,
6796,
63,
1130,
59,
68,
14,
10103,
1527,
68,
14,
2977,
63,
1618,
63,
4482,
61,
275,
366,
14,
1205,
421,
198,
1107,
15115,
63,
1130,
507,
199,
318,
664,
63,
9855,
8,
4273,
304,
198,
199,
198,
692,
440,
334,
4273,
14,
362,
480,
4482,
531,
436,
4766,
14,
362,
480,
18646,
63,
3403,
14150,
507,
198,
1328,
1361,
6115,
8254,
3504,
5794,
436,
5361,
1288,
746,
63,
1971,
29,
17,
9,
18118,
198,
4273,
905,
4482,
937,
275,
2097,
19825,
401,
298,
27717,
401,
298,
10570,
401,
298,
33,
2700,
401,
298,
15586,
401,
298,
42,
324,
401,
298,
42,
348,
401,
298,
21640,
401,
298,
23337,
401,
298,
17584,
401,
298,
1944,
86,
401,
11083,
198,
2,
8584,
4140,
1080,
8,
4273,
905,
4482,
3135,
435,
413,
8299,
198,
504,
11234,
492,
5794,
1842,
198,
199,
198,
4273,
905,
2923,
63,
4899,
63,
262,
63,
4482,
937,
275,
5794,
1842,
8,
67,
442,
8,
4273,
905,
18646,
63,
3403,
4140,
1294,
6096,
531,
1988,
17,
2522,
11083,
198,
4273,
905,
4482,
3135,
59,
17,
61,
8299,
198,
9855,
275,
298,
436,
5794,
8,
6796,
63,
602,
9,
275,
2818,
4482,
9,
83,
436,
18672,
63,
3403,
275,
2818,
18646,
63,
3403,
9,
83,
2,
8299,
198,
692,
4766,
14,
362,
480,
4627,
2349,
3704,
847,
298,
436,
7233,
275,
2818,
4627,
9,
83,
2,
199,
198,
692,
4766,
14,
362,
480,
10103,
2349,
3704,
847,
298,
436,
15778,
275,
2818,
10103,
9,
83,
2,
8299,
198,
1107,
3704,
12,
4766,
507,
199,
318,
664,
63,
10103,
63,
5087,
837,
199,
198,
10103,
275,
23154,
14,
1631,
14,
3009,
4852,
2416,
536,
12,
15778,
63,
354,
12,
12899,
425,
12,
27669,
12,
11083,
198,
4694,
12,
7233,
687,
5174,
22635,
2382,
1382,
1205,
665,
499,
436,
2004,
275,
283,
7472,
7,
7208,
465,
63,
807,
29,
17,
9,
8299,
198,
2109,
63,
1130,
275,
1052,
199,
198,
509,
9052,
315,
15778,
26,
507,
198,
2109,
63,
1130,
59,
2109,
14,
354,
61,
275,
9052,
18118,
198,
1107,
9052,
63,
1130,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
6171,
12,
6001,
8144,
19215,
29053,
14,
12126,
14,
199,
3,
844,
26,
1664,
1696,
1684,
844,
373,
19,
14,
1666,
4190,
14,
2424,
199,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
646,
23154,
199,
504,
23154,
14,
1208,
492,
286,
495,
12,
286,
442,
199,
504,
23154,
492,
1499,
1361,
12,
485,
199,
199,
318,
5341,
8,
4273,
29,
403,
304,
199,
198,
692,
440,
4766,
26,
4766,
275,
1052,
8299,
198,
9855,
12,
4766,
275,
664,
63,
9855,
8,
4273,
9,
199,
198,
3406,
275,
664,
63,
3406,
8,
4273,
9,
199,
198,
6796,
63,
1130,
275,
664,
63,
23985,
63,
513,
8,
9855,
12,
4766,
9,
199,
198,
2109,
63,
1130,
275,
664,
63,
10103,
63,
5087,
342,
8299,
198,
576,
275,
942,
199,
198,
509,
9052,
315,
3355,
8,
6796,
63,
1130,
304,
507,
198,
2109,
63,
9886,
275,
9052,
63,
1130,
14,
362,
8,
2109,
9,
507,
198,
1143,
275,
359,
2109,
12,
9052,
63,
9886,
14,
10103,
63,
354,
12,
9052,
63,
9886,
14,
4694,
12,
9052,
63,
9886,
14,
19623,
12,
9052,
63,
9886,
14,
14748,
425,
12,
20866,
198,
2109,
63,
9886,
14,
4627,
61,
1585,
507,
198,
2923,
63,
80,
275,
3141,
63,
65,
275,
378,
14,
16,
507,
198,
509,
5382,
315,
1425,
8,
4273,
905,
2923,
63,
4899,
63,
262,
63,
4482,
21473,
686,
198,
1205,
275,
15115,
63,
1130,
14,
362,
8,
2109,
680,
362,
8,
2977,
435,
413,
12,
298,
5583,
1150,
531,
686,
198,
1205,
63,
1130,
275,
2420,
19794,
582,
298,
48,
401,
298,
5583,
1150,
582,
298,
33,
401,
298,
21132,
28358,
582,
298,
14903,
3570,
686,
198,
1143,
14,
740,
8,
1205,
63,
1130,
59,
1205,
566,
26140,
198,
692,
2004,
508,
298,
19794,
582,
1585,
198,
2923,
63,
80,
847,
413,
686,
198,
4164,
2004,
508,
298,
5583,
1150,
582,
1585,
198,
2923,
63,
65,
847,
413,
686,
198,
4164,
2004,
508,
298,
21132,
28358,
582,
1585,
198,
2923,
63,
80,
847,
378,
14,
21,
1585,
198,
2923,
63,
65,
847,
378,
14,
21,
28550,
198,
1143,
847,
359,
2923,
63,
80,
12,
3141,
63,
65,
61,
9068,
198,
576,
14,
740,
8,
1143,
9,
8299,
198,
1107,
4362,
12,
666,
507,
199,
318,
664,
63,
3406,
8,
4273,
304,
199,
198,
3406,
275,
359,
507,
198,
2,
22635,
26,
3834,
15,
22635,
26,
6708,
401,
298,
22635,
2812,
447,
10037,
401,
298,
12526,
26,
3834,
15,
12526,
26,
6708,
401,
11083,
198,
2,
872,
12493,
26,
3834,
15,
872,
12493,
26,
6708,
401,
298,
20924,
425,
26,
3834,
15,
20924,
425,
26,
6708,
401,
686,
298,
16063,
26,
3834,
15,
16063,
26,
6708,
2,
199,
198,
61,
8299,
198,
509,
5382,
315,
1425,
8,
4273,
905,
2923,
63,
4899,
63,
262,
63,
4482,
21473,
507,
198,
3406,
14,
740,
8,
67,
495,
8,
2977,
11,
17,
9,
435,
2,
447,
1165,
531,
18118,
198,
3406,
847,
2097,
7316,
5543,
1150,
26,
5136,
26,
1257,
401,
298,
7316,
8351,
1150,
26,
5136,
26,
1257,
937,
199,
198,
1107,
4362,
507,
199,
318,
664,
63,
23985,
63,
513,
8,
9855,
12,
4766,
304,
199,
198,
23985,
63,
513,
275,
23154,
14,
1631,
14,
3009,
4852,
2416,
15778,
12,
5382,
8,
6796,
63,
602,
9,
465,
5382,
63,
1618,
63,
4482,
12,
11083,
198,
1205,
687,
5174,
1271,
7169,
554,
2382,
1382,
1205,
275,
413,
450,
83,
1865,
701,
15778,
12,
15115,
63,
602,
624,
450,
11083,
198,
9855,
12,
4766,
12,
465,
63,
807,
29,
17,
9,
18118,
198,
6796,
63,
1130,
275,
1052,
199,
198,
509,
366,
315,
737,
7169,
554,
63,
513,
26,
507,
198,
6796,
63,
1130,
14,
5486,
8,
68,
14,
10103,
12,
23154,
423,
807,
8801,
5486,
8,
68,
14,
2977,
63,
1618,
63,
4482,
12,
6899,
507,
198,
6796,
63,
1130,
59,
68,
14,
10103,
1527,
68,
14,
2977,
63,
1618,
63,
4482,
61,
275,
366,
14,
1205,
421,
198,
1107,
15115,
63,
1130,
507,
199,
318,
664,
63,
9855,
8,
4273,
304,
198,
199,
198,
692,
440,
334,
4273,
14,
362,
480,
4482,
531,
436,
4766,
14,
362,
480,
18646,
63,
3403,
14150,
507,
198,
1328,
1361,
6115,
8254,
3504,
5794,
436,
5361,
1288,
746,
63,
1971,
29,
17,
9,
18118,
198,
4273,
905,
4482,
937,
275,
2097,
19825,
401,
298,
27717,
401,
298,
10570,
401,
298,
33,
2700,
401,
298,
15586,
401,
298,
42,
324,
401,
298,
42,
348,
401,
298,
21640,
401,
298,
23337,
401,
298,
17584,
401,
298,
1944,
86,
401,
11083,
198,
2,
8584,
4140,
1080,
8,
4273,
905,
4482,
3135,
435,
413,
8299,
198,
504,
11234,
492,
5794,
1842,
198,
199,
198,
4273,
905,
2923,
63,
4899,
63,
262,
63,
4482,
937,
275,
5794,
1842,
8,
67,
442,
8,
4273,
905,
18646,
63,
3403,
4140,
1294,
6096,
531,
1988,
17,
2522,
11083,
198,
4273,
905,
4482,
3135,
59,
17,
61,
8299,
198,
9855,
275,
298,
436,
5794,
8,
6796,
63,
602,
9,
275,
2818,
4482,
9,
83,
436,
18672,
63,
3403,
275,
2818,
18646,
63,
3403,
9,
83,
2,
8299,
198,
692,
4766,
14,
362,
480,
4627,
2349,
3704,
847,
298,
436,
7233,
275,
2818,
4627,
9,
83,
2,
199,
198,
692,
4766,
14,
362,
480,
10103,
2349,
3704,
847,
298,
436,
15778,
275,
2818,
10103,
9,
83,
2,
8299,
198,
1107,
3704,
12,
4766,
507,
199,
318,
664,
63,
10103,
63,
5087,
837,
199,
198,
10103,
275,
23154,
14,
1631,
14,
3009,
4852,
2416,
536,
12,
15778,
63,
354,
12,
12899,
425,
12,
27669,
12,
11083,
198,
4694,
12,
7233,
687,
5174,
22635,
2382,
1382,
1205,
665,
499,
436,
2004,
275,
283,
7472,
7,
7208,
465,
63,
807,
29,
17,
9,
8299,
198,
2109,
63,
1130,
275,
1052,
199,
198,
509,
9052,
315,
15778,
26,
507,
198,
2109,
63,
1130,
59,
2109,
14,
354,
61,
275,
9052,
18118,
198,
1107,
9052,
63,
1130,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nattayamairittha/MeanStack
|
MyProject/node_modules/node-sass-middleware/node_modules/node-sass/node_modules/node-gyp/gyp/tools/pretty_gyp.py
|
2618
|
4756
|
#!/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.
"""Pretty-prints the contents of a GYP file."""
import sys
import re
# Regex to remove comments when we're counting braces.
COMMENT_RE = re.compile(r'\s*#.*')
# Regex to remove quoted strings when we're counting braces.
# It takes into account quoted quotes, and makes sure that the quotes match.
# NOTE: It does not handle quotes that span more than one line, or
# cases where an escaped quote is preceeded by an escaped backslash.
QUOTE_RE_STR = r'(?P<q>[\'"])(.*?)(?<![^\\][\\])(?P=q)'
QUOTE_RE = re.compile(QUOTE_RE_STR)
def comment_replace(matchobj):
return matchobj.group(1) + matchobj.group(2) + '#' * len(matchobj.group(3))
def mask_comments(input):
"""Mask the quoted strings so we skip braces inside quoted strings."""
search_re = re.compile(r'(.*?)(#)(.*)')
return [search_re.sub(comment_replace, line) for line in input]
def quote_replace(matchobj):
return "%s%s%s%s" % (matchobj.group(1),
matchobj.group(2),
'x'*len(matchobj.group(3)),
matchobj.group(2))
def mask_quotes(input):
"""Mask the quoted strings so we skip braces inside quoted strings."""
search_re = re.compile(r'(.*?)' + QUOTE_RE_STR)
return [search_re.sub(quote_replace, line) for line in input]
def do_split(input, masked_input, search_re):
output = []
mask_output = []
for (line, masked_line) in zip(input, masked_input):
m = search_re.match(masked_line)
while m:
split = len(m.group(1))
line = line[:split] + r'\n' + line[split:]
masked_line = masked_line[:split] + r'\n' + masked_line[split:]
m = search_re.match(masked_line)
output.extend(line.split(r'\n'))
mask_output.extend(masked_line.split(r'\n'))
return (output, mask_output)
def split_double_braces(input):
"""Masks out the quotes and comments, and then splits appropriate
lines (lines that matche the double_*_brace re's above) before
indenting them below.
These are used to split lines which have multiple braces on them, so
that the indentation looks prettier when all laid out (e.g. closing
braces make a nice diagonal line).
"""
double_open_brace_re = re.compile(r'(.*?[\[\{\(,])(\s*)([\[\{\(])')
double_close_brace_re = re.compile(r'(.*?[\]\}\)],?)(\s*)([\]\}\)])')
masked_input = mask_quotes(input)
masked_input = mask_comments(masked_input)
(output, mask_output) = do_split(input, masked_input, double_open_brace_re)
(output, mask_output) = do_split(output, mask_output, double_close_brace_re)
return output
def count_braces(line):
"""keeps track of the number of braces on a given line and returns the result.
It starts at zero and subtracts for closed braces, and adds for open braces.
"""
open_braces = ['[', '(', '{']
close_braces = [']', ')', '}']
closing_prefix_re = re.compile(r'(.*?[^\s\]\}\)]+.*?)([\]\}\)],?)\s*$')
cnt = 0
stripline = COMMENT_RE.sub(r'', line)
stripline = QUOTE_RE.sub(r"''", stripline)
for char in stripline:
for brace in open_braces:
if char == brace:
cnt += 1
for brace in close_braces:
if char == brace:
cnt -= 1
after = False
if cnt > 0:
after = True
# This catches the special case of a closing brace having something
# other than just whitespace ahead of it -- we don't want to
# unindent that until after this line is printed so it stays with
# the previous indentation level.
if cnt < 0 and closing_prefix_re.match(stripline):
after = True
return (cnt, after)
def prettyprint_input(lines):
"""Does the main work of indenting the input based on the brace counts."""
indent = 0
basic_offset = 2
last_line = ""
for line in lines:
if COMMENT_RE.match(line):
print line
else:
line = line.strip('\r\n\t ') # Otherwise doesn't strip \r on Unix.
if len(line) > 0:
(brace_diff, after) = count_braces(line)
if brace_diff != 0:
if after:
print " " * (basic_offset * indent) + line
indent += brace_diff
else:
indent += brace_diff
print " " * (basic_offset * indent) + line
else:
print " " * (basic_offset * indent) + line
else:
print ""
last_line = line
def main():
if len(sys.argv) > 1:
data = open(sys.argv[1]).read().splitlines()
else:
data = sys.stdin.read().splitlines()
# Split up the double braces.
lines = split_double_braces(data)
# Indent and print the output.
prettyprint_input(lines)
return 0
if __name__ == '__main__':
sys.exit(main())
|
mit
|
[
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,
27153,
13,
29593,
314,
4072,
402,
282,
25686,
570,
1041,
199,
199,
646,
984,
199,
646,
295,
421,
199,
3,
12939,
370,
2813,
6786,
1380,
781,
3984,
23190,
27158,
14,
199,
10973,
63,
907,
275,
295,
14,
2014,
8,
82,
1154,
83,
10,
3,
24915,
199,
199,
3,
12939,
370,
2813,
10999,
3326,
1380,
781,
3984,
23190,
27158,
14,
199,
3,
2779,
6181,
1901,
2933,
10999,
9344,
12,
436,
7704,
3238,
626,
314,
9344,
1336,
14,
199,
3,
6944,
26,
2779,
1630,
440,
2429,
9344,
626,
13598,
1655,
2419,
1373,
1004,
12,
503,
199,
3,
5560,
2382,
376,
11077,
6313,
365,
9222,
6133,
701,
376,
11077,
13831,
14,
199,
18495,
63,
907,
63,
3027,
275,
519,
10120,
48,
28,
81,
9514,
3985,
3135,
17140,
18168,
11230,
4735,
1103,
1527,
1103,
566,
2229,
48,
29,
81,
3171,
199,
18495,
63,
907,
275,
295,
14,
2014,
8,
18495,
63,
907,
63,
3027,
9,
421,
199,
318,
3721,
63,
1814,
8,
1431,
1113,
304,
523,
372,
1336,
1113,
14,
923,
8,
17,
9,
435,
1336,
1113,
14,
923,
8,
18,
9,
435,
19619,
627,
822,
8,
1431,
1113,
14,
923,
8,
19,
430,
421,
199,
318,
3656,
63,
6223,
8,
1210,
304,
523,
408,
5144,
314,
10999,
3326,
880,
781,
3372,
27158,
6272,
10999,
3326,
1041,
523,
2754,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
5130,
3,
5130,
2795,
5942,
523,
372,
359,
1733,
63,
264,
14,
954,
8,
3349,
63,
1814,
12,
1004,
9,
367,
1004,
315,
1324,
61,
421,
199,
318,
6313,
63,
1814,
8,
1431,
1113,
304,
523,
372,
2071,
83,
5,
83,
5,
83,
5,
83,
2,
450,
334,
1431,
1113,
14,
923,
8,
17,
395,
2432,
1336,
1113,
14,
923,
8,
18,
395,
2432,
283,
88,
16804,
552,
8,
1431,
1113,
14,
923,
8,
19,
1826,
2432,
1336,
1113,
14,
923,
8,
18,
430,
421,
199,
318,
3656,
63,
14005,
8,
1210,
304,
523,
408,
5144,
314,
10999,
3326,
880,
781,
3372,
27158,
6272,
10999,
3326,
1041,
523,
2754,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
3171,
435,
7813,
9407,
63,
907,
63,
3027,
9,
523,
372,
359,
1733,
63,
264,
14,
954,
8,
3513,
63,
1814,
12,
1004,
9,
367,
1004,
315,
1324,
61,
421,
199,
318,
886,
63,
1294,
8,
1210,
12,
9742,
63,
1210,
12,
2754,
63,
264,
304,
523,
1072,
275,
942,
523,
3656,
63,
1199,
275,
942,
523,
367,
334,
604,
12,
9742,
63,
604,
9,
315,
3482,
8,
1210,
12,
9742,
63,
1210,
304,
272,
333,
275,
2754,
63,
264,
14,
1431,
8,
11018,
63,
604,
9,
272,
1830,
333,
26,
489,
3715,
275,
822,
8,
77,
14,
923,
8,
17,
430,
489,
1004,
275,
1004,
1491,
1294,
61,
435,
519,
1154,
78,
7,
435,
1004,
59,
1294,
2938,
489,
9742,
63,
604,
275,
9742,
63,
604,
1491,
1294,
61,
435,
519,
1154,
78,
7,
435,
9742,
63,
604,
59,
1294,
2938,
489,
333,
275,
2754,
63,
264,
14,
1431,
8,
11018,
63,
604,
9,
272,
1072,
14,
2880,
8,
604,
14,
1294,
8,
82,
1154,
78,
1333,
272,
3656,
63,
1199,
14,
2880,
8,
11018,
63,
604,
14,
1294,
8,
82,
1154,
78,
1333,
523,
372,
334,
1199,
12,
3656,
63,
1199,
9,
421,
199,
318,
3715,
63,
3157,
63,
7828,
823,
8,
1210,
304,
523,
408,
5144,
83,
734,
314,
9344,
436,
6786,
12,
436,
2066,
19115,
5827,
523,
2385,
334,
1278,
626,
2530,
595,
314,
4270,
15192,
63,
22359,
295,
1159,
3432,
9,
2544,
523,
4363,
316,
3062,
5084,
14,
819,
5723,
787,
1202,
370,
3715,
2385,
1314,
1172,
3663,
27158,
641,
3062,
12,
880,
523,
626,
314,
14311,
10734,
876,
84,
13949,
1380,
1006,
1127,
344,
734,
334,
69,
14,
71,
14,
11261,
523,
27158,
1852,
282,
14213,
16788,
1004,
680,
523,
408,
523,
4270,
63,
1490,
63,
22359,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
7023,
7023,
12911,
8,
30453,
2961,
83,
13278,
16510,
7023,
12911,
8,
566,
358,
523,
4270,
63,
1600,
63,
22359,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
7023,
7272,
4988,
4360,
31,
10127,
83,
13278,
16510,
7272,
4988,
3948,
358,
819,
9742,
63,
1210,
275,
3656,
63,
14005,
8,
1210,
9,
523,
9742,
63,
1210,
275,
3656,
63,
6223,
8,
11018,
63,
1210,
9,
819,
334,
1199,
12,
3656,
63,
1199,
9,
275,
886,
63,
1294,
8,
1210,
12,
9742,
63,
1210,
12,
4270,
63,
1490,
63,
22359,
63,
264,
9,
523,
334,
1199,
12,
3656,
63,
1199,
9,
275,
886,
63,
1294,
8,
1199,
12,
3656,
63,
1199,
12,
4270,
63,
1600,
63,
22359,
63,
264,
9,
819,
372,
1072,
421,
199,
318,
2338,
63,
7828,
823,
8,
604,
304,
523,
408,
415,
8277,
4426,
402,
314,
1329,
402,
27158,
641,
282,
1627,
1004,
436,
2529,
314,
754,
14,
819,
2779,
9174,
737,
4697,
436,
1007,
1239,
3021,
367,
6876,
27158,
12,
436,
9584,
367,
1551,
27158,
14,
523,
408,
523,
1551,
63,
7828,
823,
275,
788,
59,
297,
283,
5102,
5041,
418,
523,
4002,
63,
7828,
823,
275,
359,
418,
297,
283,
3196,
28544,
418,
523,
11261,
63,
1861,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
16045,
83,
60,
7272,
4988,
1874,
11,
6697,
9,
16510,
7272,
4988,
4360,
31,
2862,
83,
10,
9988,
523,
12703,
275,
378,
523,
6202,
604,
275,
25071,
63,
907,
14,
954,
8,
82,
6448,
1004,
9,
523,
6202,
604,
275,
7813,
9407,
63,
907,
14,
954,
8,
82,
2,
891,
401,
6202,
604,
9,
523,
367,
1495,
315,
6202,
604,
26,
272,
367,
23549,
315,
1551,
63,
7828,
823,
26,
489,
340,
1495,
508,
23549,
26,
267,
12703,
847,
413,
272,
367,
23549,
315,
4002,
63,
7828,
823,
26,
489,
340,
1495,
508,
23549,
26,
267,
12703,
4862,
413,
819,
2410,
275,
756,
523,
340,
12703,
690,
378,
26,
272,
2410,
275
] |
[
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,
27153,
13,
29593,
314,
4072,
402,
282,
25686,
570,
1041,
199,
199,
646,
984,
199,
646,
295,
421,
199,
3,
12939,
370,
2813,
6786,
1380,
781,
3984,
23190,
27158,
14,
199,
10973,
63,
907,
275,
295,
14,
2014,
8,
82,
1154,
83,
10,
3,
24915,
199,
199,
3,
12939,
370,
2813,
10999,
3326,
1380,
781,
3984,
23190,
27158,
14,
199,
3,
2779,
6181,
1901,
2933,
10999,
9344,
12,
436,
7704,
3238,
626,
314,
9344,
1336,
14,
199,
3,
6944,
26,
2779,
1630,
440,
2429,
9344,
626,
13598,
1655,
2419,
1373,
1004,
12,
503,
199,
3,
5560,
2382,
376,
11077,
6313,
365,
9222,
6133,
701,
376,
11077,
13831,
14,
199,
18495,
63,
907,
63,
3027,
275,
519,
10120,
48,
28,
81,
9514,
3985,
3135,
17140,
18168,
11230,
4735,
1103,
1527,
1103,
566,
2229,
48,
29,
81,
3171,
199,
18495,
63,
907,
275,
295,
14,
2014,
8,
18495,
63,
907,
63,
3027,
9,
421,
199,
318,
3721,
63,
1814,
8,
1431,
1113,
304,
523,
372,
1336,
1113,
14,
923,
8,
17,
9,
435,
1336,
1113,
14,
923,
8,
18,
9,
435,
19619,
627,
822,
8,
1431,
1113,
14,
923,
8,
19,
430,
421,
199,
318,
3656,
63,
6223,
8,
1210,
304,
523,
408,
5144,
314,
10999,
3326,
880,
781,
3372,
27158,
6272,
10999,
3326,
1041,
523,
2754,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
5130,
3,
5130,
2795,
5942,
523,
372,
359,
1733,
63,
264,
14,
954,
8,
3349,
63,
1814,
12,
1004,
9,
367,
1004,
315,
1324,
61,
421,
199,
318,
6313,
63,
1814,
8,
1431,
1113,
304,
523,
372,
2071,
83,
5,
83,
5,
83,
5,
83,
2,
450,
334,
1431,
1113,
14,
923,
8,
17,
395,
2432,
1336,
1113,
14,
923,
8,
18,
395,
2432,
283,
88,
16804,
552,
8,
1431,
1113,
14,
923,
8,
19,
1826,
2432,
1336,
1113,
14,
923,
8,
18,
430,
421,
199,
318,
3656,
63,
14005,
8,
1210,
304,
523,
408,
5144,
314,
10999,
3326,
880,
781,
3372,
27158,
6272,
10999,
3326,
1041,
523,
2754,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
3171,
435,
7813,
9407,
63,
907,
63,
3027,
9,
523,
372,
359,
1733,
63,
264,
14,
954,
8,
3513,
63,
1814,
12,
1004,
9,
367,
1004,
315,
1324,
61,
421,
199,
318,
886,
63,
1294,
8,
1210,
12,
9742,
63,
1210,
12,
2754,
63,
264,
304,
523,
1072,
275,
942,
523,
3656,
63,
1199,
275,
942,
523,
367,
334,
604,
12,
9742,
63,
604,
9,
315,
3482,
8,
1210,
12,
9742,
63,
1210,
304,
272,
333,
275,
2754,
63,
264,
14,
1431,
8,
11018,
63,
604,
9,
272,
1830,
333,
26,
489,
3715,
275,
822,
8,
77,
14,
923,
8,
17,
430,
489,
1004,
275,
1004,
1491,
1294,
61,
435,
519,
1154,
78,
7,
435,
1004,
59,
1294,
2938,
489,
9742,
63,
604,
275,
9742,
63,
604,
1491,
1294,
61,
435,
519,
1154,
78,
7,
435,
9742,
63,
604,
59,
1294,
2938,
489,
333,
275,
2754,
63,
264,
14,
1431,
8,
11018,
63,
604,
9,
272,
1072,
14,
2880,
8,
604,
14,
1294,
8,
82,
1154,
78,
1333,
272,
3656,
63,
1199,
14,
2880,
8,
11018,
63,
604,
14,
1294,
8,
82,
1154,
78,
1333,
523,
372,
334,
1199,
12,
3656,
63,
1199,
9,
421,
199,
318,
3715,
63,
3157,
63,
7828,
823,
8,
1210,
304,
523,
408,
5144,
83,
734,
314,
9344,
436,
6786,
12,
436,
2066,
19115,
5827,
523,
2385,
334,
1278,
626,
2530,
595,
314,
4270,
15192,
63,
22359,
295,
1159,
3432,
9,
2544,
523,
4363,
316,
3062,
5084,
14,
819,
5723,
787,
1202,
370,
3715,
2385,
1314,
1172,
3663,
27158,
641,
3062,
12,
880,
523,
626,
314,
14311,
10734,
876,
84,
13949,
1380,
1006,
1127,
344,
734,
334,
69,
14,
71,
14,
11261,
523,
27158,
1852,
282,
14213,
16788,
1004,
680,
523,
408,
523,
4270,
63,
1490,
63,
22359,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
7023,
7023,
12911,
8,
30453,
2961,
83,
13278,
16510,
7023,
12911,
8,
566,
358,
523,
4270,
63,
1600,
63,
22359,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
7023,
7272,
4988,
4360,
31,
10127,
83,
13278,
16510,
7272,
4988,
3948,
358,
819,
9742,
63,
1210,
275,
3656,
63,
14005,
8,
1210,
9,
523,
9742,
63,
1210,
275,
3656,
63,
6223,
8,
11018,
63,
1210,
9,
819,
334,
1199,
12,
3656,
63,
1199,
9,
275,
886,
63,
1294,
8,
1210,
12,
9742,
63,
1210,
12,
4270,
63,
1490,
63,
22359,
63,
264,
9,
523,
334,
1199,
12,
3656,
63,
1199,
9,
275,
886,
63,
1294,
8,
1199,
12,
3656,
63,
1199,
12,
4270,
63,
1600,
63,
22359,
63,
264,
9,
819,
372,
1072,
421,
199,
318,
2338,
63,
7828,
823,
8,
604,
304,
523,
408,
415,
8277,
4426,
402,
314,
1329,
402,
27158,
641,
282,
1627,
1004,
436,
2529,
314,
754,
14,
819,
2779,
9174,
737,
4697,
436,
1007,
1239,
3021,
367,
6876,
27158,
12,
436,
9584,
367,
1551,
27158,
14,
523,
408,
523,
1551,
63,
7828,
823,
275,
788,
59,
297,
283,
5102,
5041,
418,
523,
4002,
63,
7828,
823,
275,
359,
418,
297,
283,
3196,
28544,
418,
523,
11261,
63,
1861,
63,
264,
275,
295,
14,
2014,
8,
82,
6774,
6697,
16045,
83,
60,
7272,
4988,
1874,
11,
6697,
9,
16510,
7272,
4988,
4360,
31,
2862,
83,
10,
9988,
523,
12703,
275,
378,
523,
6202,
604,
275,
25071,
63,
907,
14,
954,
8,
82,
6448,
1004,
9,
523,
6202,
604,
275,
7813,
9407,
63,
907,
14,
954,
8,
82,
2,
891,
401,
6202,
604,
9,
523,
367,
1495,
315,
6202,
604,
26,
272,
367,
23549,
315,
1551,
63,
7828,
823,
26,
489,
340,
1495,
508,
23549,
26,
267,
12703,
847,
413,
272,
367,
23549,
315,
4002,
63,
7828,
823,
26,
489,
340,
1495,
508,
23549,
26,
267,
12703,
4862,
413,
819,
2410,
275,
756,
523,
340,
12703,
690,
378,
26,
272,
2410,
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,
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
] |
starcraftman/pakit
|
pakit/main.py
|
2
|
14538
|
"""
The main entry point for pakit.
Acts as an intermediary between program arguments and pakit Tasks.
"""
from __future__ import absolute_import, print_function
import argparse
from argparse import RawDescriptionHelpFormatter as RawDescriptionHelp
import logging
import logging.handlers
import os
import sys
import pakit.conf
import pakit.recipe
import pakit.shell
from pakit import __version__
from pakit.conf import Config, InstallDB
from pakit.exc import PakitError, PakitDBError
from pakit.graph import DiGraph, topological_sort
from pakit.task import (
InstallTask, RemoveTask, UpdateTask, ListInstalled, ListAvailable,
DisplayTask, RelinkRecipes, SearchTask, CreateConfig, PurgeTask
)
PLOG = logging.getLogger('pakit').info
def create_args_parser():
"""
Create the program argument parser.
Returns:
An argparse parser object.
"""
prog_name = os.path.basename(os.path.dirname(sys.argv[0]))
mesg = """
{0} is a build tool providing a package manager like interface
to build & install recipes into local paths.
First Time Run:
Run in shell: `{1} --create-conf`
This writes the default config to $HOME/.pakit.yml
Run in shell: `export PATH=/tmp/pakit/links/bin:$PATH`
This is where all program bins will link to by default.
For project development or to report bugs:
https://github.com/starcraftman/pakit
Additional Information:
man pakit
man pakit_recipes
pydoc pakit
Recipes:
User made recipes can be put in $HOME/.pakit/recipes by default.
If two recipes have same name, last one in will be executed.
Example recipes can be found in the `pakit_recipes` module.
A good example is `pakit_recipes/ag.py`.
""".format(prog_name.capitalize(), prog_name)
mesg = mesg[0:-5]
parser = argparse.ArgumentParser(prog=prog_name, description=mesg,
formatter_class=RawDescriptionHelp)
parser.add_argument('-v', '--version', action='version',
version='pakit {0}\nALPHA!'.format(__version__))
parser.add_argument('-c', '--conf', help='the yaml config file to use')
subs = parser.add_subparsers(title='subcommands',
description='For additional help: '
'pakit <subcommand> -h')
sub = subs.add_parser('install',
description='Install specified RECIPE(s).')
sub.add_argument('recipes', nargs='+', metavar='RECIPE',
help='one or more RECIPE(s) to install')
sub.set_defaults(func=parse_install)
sub = subs.add_parser('remove', description='Remove specified RECIPE(s).')
sub.add_argument('recipes', nargs='+', metavar='RECIPE',
help='one or more RECIPE(s) to remove')
sub.set_defaults(func=parse_remove)
sub = subs.add_parser('update',
description='Update all recipes installed. '
'Alternatively, just specified RECIPE(s)')
sub.add_argument('recipes', nargs='*', default=(), metavar='RECIPE',
help='zero or more RECIPE(s) to update')
sub.set_defaults(func=parse_update)
sub = subs.add_parser('list',
description='List currently installed recipe(s).')
sub.add_argument('--short', default=False, action='store_true',
help='terse output format')
sub.set_defaults(func=parse_list)
sub = subs.add_parser('available',
description='List recipes available to install.')
sub.add_argument('--short', default=False, action='store_true',
help='terse output format')
sub.set_defaults(func=parse_available)
sub = subs.add_parser('display',
description='Information about selected RECIPE(s).')
sub.add_argument('recipes', nargs='+', metavar='RECIPE',
help='display information for one or more RECIPE(s)')
sub.set_defaults(func=parse_display)
desc = """Search for WORD(s) in the recipe database.
The matches for each WORD will be ORed together.
Default options:
- Substring match
- Case insensitive
- Matches against recipe name or description"""
sub = subs.add_parser('search', description=desc,
formatter_class=RawDescriptionHelp)
sub.add_argument('words', nargs='+', metavar='WORD',
help='search names & descriptions for WORD')
sub.add_argument('--case', default=False, action='store_true',
help='enable case sensitivity, default off')
sub.add_argument('--names', default=False, action='store_true',
help='only search against recipe name,'
' default name and description')
sub.set_defaults(func=parse_search)
sub = subs.add_parser('relink',
description='Relink all installed RECIPE(s).'
'\nAlternatively, relink specified RECIPE(s).',
formatter_class=RawDescriptionHelp)
sub.add_argument('recipes', nargs='*', metavar='RECIPE',
help='the RECIPE(s) to manage')
sub.set_defaults(func=parse_relink)
sub = subs.add_parser('create-conf',
description='(Over)write the selected pakit config.')
sub.set_defaults(func=parse_create_conf)
desc = """Remove most traces of pakit. No undo!
Will delete ...
- all links from the link directory to pakit's programs.
- all programs pakit built, including the source trees.
- all downloaded recipes.
- all logs and configs EXCEPT the pakit.yml file."""
sub = subs.add_parser('purge', description=desc,
formatter_class=RawDescriptionHelp)
sub.set_defaults(func=parse_purge)
return parser
def environment_check(config):
"""
Check the environment is correct.
Ensure network connection works.
Guarantee built programs always first in $PATH for Commands.
"""
bin_dir = os.path.join(config.path_to('link'), 'bin')
if os.environ['PATH'].find(bin_dir) == -1:
PLOG('To use built recipes %s must be on shell $PATH.', bin_dir)
PLOG(' For Most Shells: export PATH=%s:$PATH', bin_dir)
os.environ['PATH'] = bin_dir + ':' + os.environ['PATH']
def global_init(config_file):
"""
Performs global configuration of pakit.
Must be called before using pakit. Will ...
- Read user configuration.
- Initialize the logging system.
- Populate the recipe database.
- Create configured folders.
- Setup pakit man page.
Args:
config_file: The YAML configuration filename.
Returns:
The loaded config object.
"""
config = Config(config_file)
pakit.conf.CONFIG = config
log_init(config)
logging.debug('Global Config: %s', config)
PLOG('Loaded config from: ' + config.filename)
for path in config.get('pakit.paths').values():
try:
os.makedirs(path)
except OSError:
pass
prefix = config.path_to('prefix')
pakit.conf.IDB = InstallDB(os.path.join(prefix, 'idb.yml'))
logging.debug('InstallDB: %s', pakit.conf.IDB)
manager = pakit.recipe.RecipeManager(config)
manager.check_for_deletions()
manager.check_for_updates()
manager.init_new_uris()
recipe_db = pakit.recipe.RecipeDB(config)
for path in manager.paths:
recipe_db.index(path)
pakit.recipe.RDB = recipe_db
pakit.shell.link_man_pages(config.path_to('link'))
environment_check(config)
return config
def log_init(config):
"""
Setup project wide logging.
Specifically this will setup both file and console logging.
"""
log_file = config.get('pakit.log.file')
try:
os.makedirs(os.path.dirname(log_file))
except OSError:
pass
root = logging.getLogger()
root.setLevel(logging.DEBUG)
log_fmt = '%(levelname)s %(asctime)s %(threadName)s ' \
'%(filename)s %(message)s'
my_fmt = logging.Formatter(fmt=log_fmt, datefmt='[%d/%m %H%M.%S]')
while len(root.handlers):
root.removeHandler(root.handlers[0])
rot = logging.handlers.RotatingFileHandler(log_file,
mode='a',
maxBytes=2 ** 22,
backupCount=4)
rot.setLevel(logging.DEBUG)
rot.setFormatter(my_fmt)
root.addHandler(rot)
stream = logging.StreamHandler()
stream.setLevel(logging.ERROR)
stream.setFormatter(my_fmt)
root.addHandler(stream)
# Logger for informing user
pak = logging.getLogger('pakit')
while len(pak.handlers):
pak.removeHandler(pak.handlers[0])
pak.setLevel(logging.INFO)
pak_fmt = 'pakit %(asctime)s %(message)s'
pak_info = logging.Formatter(fmt=pak_fmt, datefmt='[%H:%M:%S]')
pak_stream = logging.StreamHandler()
pak_stream.setFormatter(pak_info)
pak.addHandler(pak_stream)
def add_deps_for(recipe_name, graph):
"""
Recursively add a recipe_name and all reqirements to the graph.
NOTE: Cycles may be present in the graph when recursion terminates.
Even so, this function will NOT recurse endlessly.
Args:
graph: A directed graph.
recipe_name: A recipe in RecipeDB.
Raises:
PakitDBError: No matching recipe in RecipeDB.
CycleInGraphError: A cycle was detected in the recursion.
"""
if recipe_name in graph:
return
recipe = pakit.recipe.RDB.get(recipe_name)
graph.add_vertex(recipe_name)
requires = getattr(recipe, 'requires', [])
graph.add_edges(recipe_name, requires)
for requirement in requires:
add_deps_for(requirement, graph)
def order_tasks(recipe_names, task_class):
"""
Order the recipes so that all dependencies can be met.
Args:
recipe_names: List of recipe names.
task_class: The Task to be carried out on the recipes.
Returns:
A list of task_class instances ordered to meet dependencies.
Raises:
CycleInGraphError: The dependencies could not be resolved
as there was a cycle in the dependency graph.
"""
graph = DiGraph()
for recipe_name in recipe_names:
add_deps_for(recipe_name, graph)
return [task_class(recipe_name) for recipe_name in topological_sort(graph)]
def parse_install(args):
"""
Parse args for InstallTask(s).
"""
return order_tasks(args.recipes, InstallTask)
def parse_remove(args):
"""
Parse args for RemoveTask(s).
"""
return [RemoveTask(recipe) for recipe in args.recipes]
def parse_update(args):
"""
Parse args for UpdateTask(s).
"""
tasks = None
if len(args.recipes) == 0:
to_update = [recipe for recipe in pakit.conf.IDB]
tasks = order_tasks(to_update, UpdateTask)
else:
to_update = [recipe for recipe in args.recipes
if recipe in pakit.conf.IDB]
not_installed = sorted(set(args.recipes).difference(to_update))
if len(not_installed):
PLOG('Recipe(s) not installed: ' + ', '.join(not_installed))
tasks = order_tasks(to_update, UpdateTask)
if len(tasks) == 0:
PLOG('Nothing to update.')
return tasks
def parse_display(args):
"""
Parse args for DisplayTasks.
"""
return [DisplayTask(prog) for prog in args.recipes]
def parse_available(args):
"""
Parse args for ListAvailable task.
"""
return [ListAvailable(args.short)]
def parse_list(args):
"""
Parse args for ListInstalled task.
"""
return [ListInstalled(args.short)]
def parse_relink(_):
"""
Parse args for RelinkRecipes task.
"""
return [RelinkRecipes()]
def parse_search(args):
"""
Parse args for DisplayTask(s).
"""
return [SearchTask(args)]
def parse_create_conf(args):
"""
Parse args for CreateConfig
"""
return [CreateConfig(args.conf)]
def parse_purge(_):
"""
Parse args for PurgeTask
"""
return [PurgeTask()]
def search_for_config(default_config=None):
"""
Search for the most relevant configuration file.
Will search from current dir upwards until root for config files matching:
- .pakit.yml
- .pakit.yaml
- pakit.yml
- pakit.yaml
If nothing found, search in $HOME and then $HOME/.pakit for same files.
If still nothing found, return default_config.
Args:
default_config: The default config if nothing else present.
Returns:
If a path existed, return found filename.
If no paths matched an existing file return the default_config.
"""
folders = [os.getcwd()]
cur_dir = os.path.dirname(os.getcwd())
while cur_dir != '/':
folders.append(cur_dir)
cur_dir = os.path.dirname(cur_dir)
folders.append(os.path.expanduser('~'))
folders.append(os.path.expanduser('~/.pakit'))
for folder in folders:
for conf in ['.pakit.yml', '.pakit.yaml', 'pakit.yml', 'pakit.yaml']:
config_file = os.path.join(folder, conf)
if os.path.exists(config_file):
return config_file
return default_config
def main(argv=None):
"""
The main entry point for this program.
Args:
argv: A list of program options, if None use sys.argv.
"""
if argv is None:
argv = sys.argv
parser = create_args_parser()
if len(argv) == 1:
logging.error('No arguments. What should I do?')
parser.print_usage()
sys.exit(1)
try:
args = parser.parse_args(argv[1:])
if not args.conf:
args.conf = search_for_config(os.path.expanduser('~/.pakit.yml'))
global_init(args.conf)
logging.debug('CLI: %s', args)
for task in args.func(args):
PLOG('Running: %s', str(task))
task.run()
except PakitDBError as exc:
PLOG(str(exc))
except PakitError as exc:
if not pakit.shell.check_connectivity():
logging.error('You do not seem to be connected to the internet.')
logging.error("Pakit can't do much without it!")
else:
logging.error(exc)
raise
if __name__ == '__main__':
main() # pragma: no cover
|
bsd-3-clause
|
[
624,
199,
1918,
2446,
2397,
2376,
367,
691,
6065,
14,
199,
199,
33,
3021,
465,
376,
1640,
30747,
3382,
2240,
2368,
436,
691,
6065,
8495,
83,
14,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
870,
63,
1593,
199,
646,
7534,
199,
504,
7534,
492,
13480,
5831,
22779,
465,
13480,
5831,
8673,
199,
646,
2050,
199,
646,
2050,
14,
5586,
199,
646,
747,
199,
646,
984,
199,
199,
646,
691,
6065,
14,
2190,
199,
646,
691,
6065,
14,
13191,
199,
646,
691,
6065,
14,
5641,
199,
504,
691,
6065,
492,
636,
1023,
363,
199,
504,
691,
6065,
14,
2190,
492,
4094,
12,
13276,
2846,
199,
504,
691,
6065,
14,
2804,
492,
510,
1151,
390,
547,
12,
510,
1151,
390,
2846,
547,
199,
504,
691,
6065,
14,
2180,
492,
3757,
4578,
12,
11111,
7954,
63,
3191,
199,
504,
691,
6065,
14,
1765,
492,
334,
272,
13276,
4476,
12,
5852,
4476,
12,
6162,
4476,
12,
3820,
21268,
12,
3820,
11464,
12,
272,
12175,
4476,
12,
9781,
2292,
25879,
83,
12,
8730,
4476,
12,
2790,
2028,
12,
23177,
303,
4476,
199,
9,
421,
199,
48,
4947,
275,
2050,
14,
5572,
360,
387,
6065,
1959,
815,
421,
199,
318,
1218,
63,
589,
63,
2087,
837,
272,
408,
272,
2790,
314,
2240,
1423,
1798,
14,
339,
1803,
26,
267,
1626,
7534,
1798,
909,
14,
272,
408,
272,
13205,
63,
354,
275,
747,
14,
515,
14,
4846,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2459,
272,
562,
1226,
275,
408,
272,
469,
16,
93,
365,
282,
1900,
4744,
13070,
282,
2559,
5256,
2839,
3217,
272,
370,
1900,
1253,
3907,
17121,
83,
1901,
2257,
3792,
14,
339,
7758,
4703,
3378,
26,
267,
3378,
315,
5218,
26,
658,
91,
17,
93,
1553,
981,
13,
2190,
64,
288,
961,
14511,
314,
849,
1101,
370,
2672,
9524,
8083,
387,
6065,
14,
11714,
398,
3378,
315,
5218,
26,
658,
3790,
15097,
13043,
2791,
15,
387,
6065,
15,
4614,
15,
1393,
26,
4,
3243,
64,
288,
961,
365,
2382,
1006,
2240,
13341,
911,
2142,
370,
701,
849,
14,
339,
2104,
2199,
16367,
503,
370,
3622,
18227,
26,
267,
4178,
921,
5031,
14,
957,
15,
7848,
32342,
1237,
15,
387,
6065,
339,
10961,
17064,
26,
267,
2169,
691,
6065,
267,
2169,
691,
6065,
63,
25200,
267,
29164,
691,
6065,
339,
799,
8233,
83,
26,
267,
2876,
6326,
17121,
83,
883,
506,
5324,
315,
2672,
9524,
8083,
387,
6065,
15,
25200,
701,
849,
14,
267,
982,
2877,
17121,
83,
1172,
2011,
536,
12,
2061,
1373,
315,
911,
506,
7934,
14,
267,
5679,
17121,
83,
883,
506,
1911,
315,
314,
658,
387,
6065,
63,
25200,
64,
859,
14,
267,
437,
6954,
2893,
365,
658,
387,
6065,
63,
25200,
15,
643,
14,
647,
2313,
272,
30512,
908,
8,
6595,
63,
354,
14,
18351,
1062,
13205,
63,
354,
9,
272,
562,
1226,
275,
562,
1226,
59,
16,
6809,
21,
61,
272,
1798,
275,
7534,
14,
10730,
8,
6595,
29,
6595,
63,
354,
12,
1369,
29,
10528,
12,
3660,
9698,
63,
533,
29,
7963,
5831,
8673,
9,
272,
1798,
14,
525,
63,
2094,
3654,
86,
297,
2850,
1023,
297,
1595,
534,
1023,
297,
717,
1015,
534,
387,
6065,
469,
16,
4988,
78,
18554,
1,
1370,
908,
3460,
1023,
8964,
272,
1798,
14,
525,
63,
2094,
3654,
67,
297,
2850,
2190,
297,
1720,
534,
1589,
8864,
1101,
570,
370,
675,
358,
272,
13868,
275,
1798,
14,
525,
63,
954,
11531,
8,
1213,
534,
954,
4405,
297,
639,
1369,
534,
1858,
4722,
1720,
26,
283,
639,
283,
387,
6065,
665,
954,
1531,
30,
446,
72,
358,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
3174,
297,
2079,
1369,
534,
8154,
2013,
5363,
3553,
1510,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7386,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
368,
503,
1655,
5363,
3553,
1510,
8,
83,
9,
370,
3907,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
3174,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
2168,
297,
1369,
534,
5587,
2013,
5363,
3553,
1510,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7386,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
368,
503,
1655,
5363,
3553,
1510,
8,
83,
9,
370,
2813,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
2168,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
873,
297,
2079,
1369,
534,
4152,
1006,
17121,
83,
4903,
14,
283,
2079,
283,
19978,
17330,
12,
2951,
2013,
5363,
3553,
1510,
8,
83,
5942,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7693,
849,
16729,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
4262,
503,
1655,
5363,
3553,
1510,
8,
83,
9,
370,
1678,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
873,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
513,
297,
2079,
1369,
534,
1296,
5544,
4903,
17121,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
4517,
3612,
297,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
2151,
1720,
534,
351,
261,
1072,
1475,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
513,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
4561,
297,
2079,
1369,
534,
1296,
17121,
83,
2808,
370,
3907,
2659,
272,
1007,
14,
525,
63,
2094,
4517,
3612,
297,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
2151,
1720,
534,
351,
261,
1072,
1475,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
4561,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
2918,
297,
2079,
1369,
534,
4935,
3595,
4895,
5363,
3553,
1510,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7386,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
2918,
2556,
367,
1373,
503,
1655,
5363,
3553,
1510,
8,
83,
5942,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
2918,
9,
339,
4328,
275,
408,
5278,
367,
31858,
8,
83,
9,
315,
314,
17121,
3050,
14,
272,
710,
4450,
367,
1924,
31858
] |
[
199,
1918,
2446,
2397,
2376,
367,
691,
6065,
14,
199,
199,
33,
3021,
465,
376,
1640,
30747,
3382,
2240,
2368,
436,
691,
6065,
8495,
83,
14,
199,
624,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
870,
63,
1593,
199,
646,
7534,
199,
504,
7534,
492,
13480,
5831,
22779,
465,
13480,
5831,
8673,
199,
646,
2050,
199,
646,
2050,
14,
5586,
199,
646,
747,
199,
646,
984,
199,
199,
646,
691,
6065,
14,
2190,
199,
646,
691,
6065,
14,
13191,
199,
646,
691,
6065,
14,
5641,
199,
504,
691,
6065,
492,
636,
1023,
363,
199,
504,
691,
6065,
14,
2190,
492,
4094,
12,
13276,
2846,
199,
504,
691,
6065,
14,
2804,
492,
510,
1151,
390,
547,
12,
510,
1151,
390,
2846,
547,
199,
504,
691,
6065,
14,
2180,
492,
3757,
4578,
12,
11111,
7954,
63,
3191,
199,
504,
691,
6065,
14,
1765,
492,
334,
272,
13276,
4476,
12,
5852,
4476,
12,
6162,
4476,
12,
3820,
21268,
12,
3820,
11464,
12,
272,
12175,
4476,
12,
9781,
2292,
25879,
83,
12,
8730,
4476,
12,
2790,
2028,
12,
23177,
303,
4476,
199,
9,
421,
199,
48,
4947,
275,
2050,
14,
5572,
360,
387,
6065,
1959,
815,
421,
199,
318,
1218,
63,
589,
63,
2087,
837,
272,
408,
272,
2790,
314,
2240,
1423,
1798,
14,
339,
1803,
26,
267,
1626,
7534,
1798,
909,
14,
272,
408,
272,
13205,
63,
354,
275,
747,
14,
515,
14,
4846,
8,
736,
14,
515,
14,
3475,
8,
1274,
14,
3020,
59,
16,
2459,
272,
562,
1226,
275,
408,
272,
469,
16,
93,
365,
282,
1900,
4744,
13070,
282,
2559,
5256,
2839,
3217,
272,
370,
1900,
1253,
3907,
17121,
83,
1901,
2257,
3792,
14,
339,
7758,
4703,
3378,
26,
267,
3378,
315,
5218,
26,
658,
91,
17,
93,
1553,
981,
13,
2190,
64,
288,
961,
14511,
314,
849,
1101,
370,
2672,
9524,
8083,
387,
6065,
14,
11714,
398,
3378,
315,
5218,
26,
658,
3790,
15097,
13043,
2791,
15,
387,
6065,
15,
4614,
15,
1393,
26,
4,
3243,
64,
288,
961,
365,
2382,
1006,
2240,
13341,
911,
2142,
370,
701,
849,
14,
339,
2104,
2199,
16367,
503,
370,
3622,
18227,
26,
267,
4178,
921,
5031,
14,
957,
15,
7848,
32342,
1237,
15,
387,
6065,
339,
10961,
17064,
26,
267,
2169,
691,
6065,
267,
2169,
691,
6065,
63,
25200,
267,
29164,
691,
6065,
339,
799,
8233,
83,
26,
267,
2876,
6326,
17121,
83,
883,
506,
5324,
315,
2672,
9524,
8083,
387,
6065,
15,
25200,
701,
849,
14,
267,
982,
2877,
17121,
83,
1172,
2011,
536,
12,
2061,
1373,
315,
911,
506,
7934,
14,
267,
5679,
17121,
83,
883,
506,
1911,
315,
314,
658,
387,
6065,
63,
25200,
64,
859,
14,
267,
437,
6954,
2893,
365,
658,
387,
6065,
63,
25200,
15,
643,
14,
647,
2313,
272,
30512,
908,
8,
6595,
63,
354,
14,
18351,
1062,
13205,
63,
354,
9,
272,
562,
1226,
275,
562,
1226,
59,
16,
6809,
21,
61,
272,
1798,
275,
7534,
14,
10730,
8,
6595,
29,
6595,
63,
354,
12,
1369,
29,
10528,
12,
3660,
9698,
63,
533,
29,
7963,
5831,
8673,
9,
272,
1798,
14,
525,
63,
2094,
3654,
86,
297,
2850,
1023,
297,
1595,
534,
1023,
297,
717,
1015,
534,
387,
6065,
469,
16,
4988,
78,
18554,
1,
1370,
908,
3460,
1023,
8964,
272,
1798,
14,
525,
63,
2094,
3654,
67,
297,
2850,
2190,
297,
1720,
534,
1589,
8864,
1101,
570,
370,
675,
358,
272,
13868,
275,
1798,
14,
525,
63,
954,
11531,
8,
1213,
534,
954,
4405,
297,
639,
1369,
534,
1858,
4722,
1720,
26,
283,
639,
283,
387,
6065,
665,
954,
1531,
30,
446,
72,
358,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
3174,
297,
2079,
1369,
534,
8154,
2013,
5363,
3553,
1510,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7386,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
368,
503,
1655,
5363,
3553,
1510,
8,
83,
9,
370,
3907,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
3174,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
2168,
297,
1369,
534,
5587,
2013,
5363,
3553,
1510,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7386,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
368,
503,
1655,
5363,
3553,
1510,
8,
83,
9,
370,
2813,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
2168,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
873,
297,
2079,
1369,
534,
4152,
1006,
17121,
83,
4903,
14,
283,
2079,
283,
19978,
17330,
12,
2951,
2013,
5363,
3553,
1510,
8,
83,
5942,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7693,
849,
16729,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
4262,
503,
1655,
5363,
3553,
1510,
8,
83,
9,
370,
1678,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
873,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
513,
297,
2079,
1369,
534,
1296,
5544,
4903,
17121,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
4517,
3612,
297,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
2151,
1720,
534,
351,
261,
1072,
1475,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
513,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
4561,
297,
2079,
1369,
534,
1296,
17121,
83,
2808,
370,
3907,
2659,
272,
1007,
14,
525,
63,
2094,
4517,
3612,
297,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
2151,
1720,
534,
351,
261,
1072,
1475,
358,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
4561,
9,
339,
1007,
275,
13868,
14,
525,
63,
2087,
360,
2918,
297,
2079,
1369,
534,
4935,
3595,
4895,
5363,
3553,
1510,
8,
83,
28583,
272,
1007,
14,
525,
63,
2094,
360,
25200,
297,
9237,
534,
7386,
8214,
534,
907,
3553,
1510,
297,
2151,
1720,
534,
2918,
2556,
367,
1373,
503,
1655,
5363,
3553,
1510,
8,
83,
5942,
272,
1007,
14,
409,
63,
4322,
8,
1532,
29,
1122,
63,
2918,
9,
339,
4328,
275,
408,
5278,
367,
31858,
8,
83,
9,
315,
314,
17121,
3050,
14,
272,
710,
4450,
367,
1924,
31858,
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,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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
] |
x111ong/odoo
|
addons/mail/mail_group.py
|
247
|
12877
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2010-today OpenERP SA (<http://www.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/>
#
##############################################################################
import openerp
import openerp.tools as tools
from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.safe_eval import safe_eval as eval
from openerp import SUPERUSER_ID
from openerp.tools.translate import _
class mail_group(osv.Model):
""" A mail_group is a collection of users sharing messages in a discussion
group. The group mechanics are based on the followers. """
_description = 'Discussion group'
_name = 'mail.group'
_mail_flat_thread = False
_inherit = ['mail.thread']
_inherits = {'mail.alias': 'alias_id'}
def _get_image(self, cr, uid, ids, name, args, context=None):
result = {}
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = tools.image_get_resized_images(obj.image)
return result
def _set_image(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
_columns = {
'name': fields.char('Name', required=True, translate=True),
'description': fields.text('Description'),
'menu_id': fields.many2one('ir.ui.menu', string='Related Menu', required=True, ondelete="cascade"),
'public': fields.selection([('public', 'Public'), ('private', 'Private'), ('groups', 'Selected Group Only')], 'Privacy', required=True,
help='This group is visible by non members. \
Invisible groups can add members through the invite button.'),
'group_public_id': fields.many2one('res.groups', string='Authorized Group'),
'group_ids': fields.many2many('res.groups', rel='mail_group_res_group_rel',
id1='mail_group_id', id2='groups_id', string='Auto Subscription',
help="Members of those groups will automatically added as followers. "\
"Note that they will be able to manage their subscription manually "\
"if necessary."),
# image: all image fields are base64 encoded and PIL-supported
'image': fields.binary("Photo",
help="This field holds the image used as photo for the group, limited to 1024x1024px."),
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
string="Medium-sized photo", type="binary", multi="_get_image",
store={
'mail.group': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="Medium-sized photo of the group. It is automatically "\
"resized as a 128x128px image, with aspect ratio preserved. "\
"Use this field in form views or some kanban views."),
'image_small': fields.function(_get_image, fnct_inv=_set_image,
string="Small-sized photo", type="binary", multi="_get_image",
store={
'mail.group': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="Small-sized photo of the group. It is automatically "\
"resized as a 64x64px image, with aspect ratio preserved. "\
"Use this field anywhere a small image is required."),
'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
help="The email address associated with this group. New emails received will automatically "
"create new topics."),
}
def _get_default_employee_group(self, cr, uid, context=None):
ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user')
return ref and ref[1] or False
def _get_default_image(self, cr, uid, context=None):
image_path = openerp.modules.get_module_resource('mail', 'static/src/img', 'groupdefault.png')
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
_defaults = {
'public': 'groups',
'group_public_id': _get_default_employee_group,
'image': _get_default_image,
}
def _generate_header_description(self, cr, uid, group, context=None):
header = ''
if group.description:
header = '%s' % group.description
if group.alias_id and group.alias_name and group.alias_domain:
if header:
header = '%s<br/>' % header
return '%sGroup email gateway: %s@%s' % (header, group.alias_name, group.alias_domain)
return header
def _subscribe_users(self, cr, uid, ids, context=None):
for mail_group in self.browse(cr, uid, ids, context=context):
partner_ids = []
for group in mail_group.group_ids:
partner_ids += [user.partner_id.id for user in group.users]
self.message_subscribe(cr, uid, ids, partner_ids, context=context)
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
# get parent menu
menu_parent = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'mail_group_root')
menu_parent = menu_parent and menu_parent[1] or False
# Create menu id
mobj = self.pool.get('ir.ui.menu')
menu_id = mobj.create(cr, SUPERUSER_ID, {'name': vals['name'], 'parent_id': menu_parent}, context=context)
vals['menu_id'] = menu_id
# Create group and alias
create_context = dict(context, alias_model_name=self._name, alias_parent_model_name=self._name, mail_create_nolog=True)
mail_group_id = super(mail_group, self).create(cr, uid, vals, context=create_context)
group = self.browse(cr, uid, mail_group_id, context=context)
self.pool.get('mail.alias').write(cr, uid, [group.alias_id.id], {"alias_force_thread_id": mail_group_id, 'alias_parent_thread_id': mail_group_id}, context)
group = self.browse(cr, uid, mail_group_id, context=context)
# Create client action for this group and link the menu to it
ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'action_mail_group_feeds')
if ref:
search_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'view_message_search')
params = {
'search_view_id': search_ref and search_ref[1] or False,
'domain': [
('model', '=', 'mail.group'),
('res_id', '=', mail_group_id),
],
'context': {
'default_model': 'mail.group',
'default_res_id': mail_group_id,
},
'res_model': 'mail.message',
'thread_level': 1,
'header_description': self._generate_header_description(cr, uid, group, context=context),
'view_mailbox': True,
'compose_placeholder': 'Send a message to the group',
}
cobj = self.pool.get('ir.actions.client')
newref = cobj.copy(cr, SUPERUSER_ID, ref[1], default={'params': str(params), 'name': vals['name']}, context=context)
mobj.write(cr, SUPERUSER_ID, menu_id, {'action': 'ir.actions.client,' + str(newref), 'mail_group_id': mail_group_id}, context=context)
if vals.get('group_ids'):
self._subscribe_users(cr, uid, [mail_group_id], context=context)
return mail_group_id
def unlink(self, cr, uid, ids, context=None):
groups = self.browse(cr, uid, ids, context=context)
alias_ids = [group.alias_id.id for group in groups if group.alias_id]
menu_ids = [group.menu_id.id for group in groups if group.menu_id]
# Delete mail_group
try:
all_emp_group = self.pool['ir.model.data'].get_object_reference(cr, uid, 'mail', 'group_all_employees')[1]
except ValueError:
all_emp_group = None
if all_emp_group and all_emp_group in ids:
raise osv.except_osv(_('Warning!'), _('You cannot delete those groups, as the Whole Company group is required by other modules.'))
res = super(mail_group, self).unlink(cr, uid, ids, context=context)
# Cascade-delete mail aliases as well, as they should not exist without the mail group.
self.pool.get('mail.alias').unlink(cr, SUPERUSER_ID, alias_ids, context=context)
# Cascade-delete menu entries as well
self.pool.get('ir.ui.menu').unlink(cr, SUPERUSER_ID, menu_ids, context=context)
return res
def write(self, cr, uid, ids, vals, context=None):
result = super(mail_group, self).write(cr, uid, ids, vals, context=context)
if vals.get('group_ids'):
self._subscribe_users(cr, uid, ids, context=context)
# if description, name or alias is changed: update client action
if vals.get('description') or vals.get('name') or vals.get('alias_id') or vals.get('alias_name'):
cobj = self.pool.get('ir.actions.client')
for action in [group.menu_id.action for group in self.browse(cr, uid, ids, context=context)]:
new_params = action.params
new_params['header_description'] = self._generate_header_description(cr, uid, group, context=context)
cobj.write(cr, SUPERUSER_ID, [action.id], {'params': str(new_params)}, context=context)
# if name is changed: update menu
if vals.get('name'):
mobj = self.pool.get('ir.ui.menu')
mobj.write(cr, SUPERUSER_ID,
[group.menu_id.id for group in self.browse(cr, uid, ids, context=context)],
{'name': vals.get('name')}, context=context)
return result
def action_follow(self, cr, uid, ids, context=None):
""" Wrapper because message_subscribe_users take a user_ids=None
that receive the context without the wrapper. """
return self.message_subscribe_users(cr, uid, ids, context=context)
def action_unfollow(self, cr, uid, ids, context=None):
""" Wrapper because message_unsubscribe_users take a user_ids=None
that receive the context without the wrapper. """
return self.message_unsubscribe_users(cr, uid, ids, context=context)
def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
"""Show the suggestion of groups if display_groups_suggestions if the
user perference allows it."""
user = self.pool.get('res.users').browse(cr, uid, uid, context)
if not user.display_groups_suggestions:
return []
else:
return super(mail_group, self).get_suggested_thread(cr, uid, removed_suggested_threads, context)
def message_get_email_values(self, cr, uid, id, notif_mail=None, context=None):
res = super(mail_group, self).message_get_email_values(cr, uid, id, notif_mail=notif_mail, context=context)
group = self.browse(cr, uid, id, context=context)
headers = {}
if res.get('headers'):
try:
headers.update(eval(res['headers']))
except Exception:
pass
headers['Precedence'] = 'list'
# avoid out-of-office replies from MS Exchange
# http://blogs.technet.com/b/exchange/archive/2006/10/06/3395024.aspx
headers['X-Auto-Response-Suppress'] = 'OOF'
if group.alias_domain and group.alias_name:
headers['List-Id'] = '%s.%s' % (group.alias_name, group.alias_domain)
headers['List-Post'] = '<mailto:%s@%s>' % (group.alias_name, group.alias_domain)
# Avoid users thinking it was a personal message
# X-Forge-To: will replace To: after SMTP envelope is determined by ir.mail.server
list_to = '"%s" <%s@%s>' % (group.name, group.alias_name, group.alias_domain)
headers['X-Forge-To'] = list_to
res['headers'] = repr(headers)
return res
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
8136,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
18956,
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,
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,
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,
3133,
199,
3,
199,
4605,
199,
199,
646,
5166,
199,
646,
5166,
14,
2537,
465,
7249,
199,
504,
5166,
14,
4795,
492,
9506,
199,
504,
5166,
14,
4795,
492,
1504,
199,
504,
5166,
14,
2537,
14,
3489,
63,
2579,
492,
5048,
63,
2579,
465,
3468,
199,
504,
5166,
492,
12824,
63,
998,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
6016,
63,
923,
8,
4795,
14,
1685,
304,
272,
408,
437,
6016,
63,
923,
365,
282,
3245,
402,
4390,
26994,
3788,
315,
282,
16582,
267,
1572,
14,
710,
1572,
562,
11984,
2932,
787,
4079,
641,
314,
31474,
14,
408,
272,
485,
1802,
275,
283,
31410,
1572,
7,
272,
485,
354,
275,
283,
1198,
14,
923,
7,
272,
485,
1198,
63,
7088,
63,
2671,
275,
756,
272,
485,
6486,
275,
788,
1198,
14,
2671,
418,
272,
485,
20882,
275,
791,
1198,
14,
3620,
356,
283,
3620,
63,
344,
936,
339,
347,
485,
362,
63,
1569,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
536,
12,
1249,
12,
1067,
29,
403,
304,
267,
754,
275,
1052,
267,
367,
1559,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
754,
59,
1113,
14,
344,
61,
275,
7249,
14,
1569,
63,
362,
63,
264,
15308,
63,
4782,
8,
1113,
14,
1569,
9,
267,
372,
754,
339,
347,
485,
409,
63,
1569,
8,
277,
12,
2467,
12,
1747,
12,
1305,
12,
536,
12,
574,
12,
1249,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
952,
8,
1556,
12,
1747,
12,
359,
344,
467,
791,
1569,
356,
7249,
14,
1569,
63,
8709,
63,
1569,
63,
5076,
8,
585,
16658,
1067,
29,
1100,
9,
339,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
985,
297,
1415,
29,
549,
12,
9028,
29,
549,
395,
267,
283,
1802,
356,
1504,
14,
505,
360,
5831,
659,
267,
283,
4470,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1907,
14,
4470,
297,
1059,
534,
13885,
18281,
297,
1415,
29,
549,
12,
16549,
628,
15377,
1288,
267,
283,
3455,
356,
1504,
14,
5592,
8318,
3455,
297,
283,
9885,
659,
661,
4239,
297,
283,
12185,
659,
661,
2634,
297,
283,
12461,
5611,
5972,
2665,
283,
4562,
86,
4085,
297,
1415,
29,
549,
12,
288,
1720,
534,
2765,
1572,
365,
8917,
701,
2222,
7556,
14,
971,
288,
1010,
6604,
4652,
883,
1050,
7556,
4012,
314,
24542,
5528,
8038,
267,
283,
923,
63,
3455,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
470,
14,
2634,
297,
1059,
534,
29284,
5611,
659,
267,
283,
923,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
2634,
297,
4668,
534,
1198,
63,
923,
63,
470,
63,
923,
63,
3369,
297,
288,
1305,
17,
534,
1198,
63,
923,
63,
344,
297,
1305,
18,
534,
2634,
63,
344,
297,
1059,
534,
3358,
29763,
297,
288,
1720,
628,
23056,
402,
5204,
4652,
911,
5847,
3483,
465,
31474,
14,
1867,
326,
298,
7443,
626,
2985,
911,
506,
7688,
370,
9635,
3932,
9966,
10250,
1867,
326,
298,
692,
5784,
7651,
267,
327,
1834,
26,
1006,
1834,
1504,
787,
1300,
772,
5737,
436,
14937,
13,
4946,
267,
283,
1569,
356,
1504,
14,
3008,
480,
21258,
401,
288,
1720,
628,
2765,
901,
15164,
314,
1834,
1202,
465,
19397,
367,
314,
1572,
12,
13988,
370,
6619,
88,
7727,
5326,
7651,
267,
283,
1569,
63,
14345,
356,
1504,
14,
1593,
1547,
362,
63,
1569,
12,
4325,
319,
63,
5350,
3699,
409,
63,
1569,
12,
288,
1059,
628,
26139,
13,
15308,
19397,
401,
730,
628,
3008,
401,
3510,
19667,
362,
63,
1569,
401,
288,
3877,
3126,
355,
283,
1198,
14,
923,
356,
334,
2734,
291,
12,
2467,
12,
1747,
12,
2762,
12,
286,
7622,
26,
2762,
12,
788,
1569,
995,
1616,
395,
288,
1660,
288,
1720,
628,
26139,
13,
15308,
19397,
402,
314,
1572,
14,
2779,
365,
5847,
1867,
326,
298,
264,
15308,
465,
282,
7960,
88,
3933,
5326,
1834,
12,
543,
17435,
10463,
17731,
14,
1867,
326,
298,
6119,
642,
901,
315,
1824,
6858,
503,
2005,
1022,
290,
13206,
6858,
7651,
267,
283,
1569,
63,
7241,
356,
1504,
14,
1593,
1547,
362,
63,
1569,
12,
4325,
319,
63,
5350,
3699,
409,
63,
1569,
12,
288,
1059,
628,
10712,
13,
15308,
19397,
401,
730,
628,
3008,
401,
3510,
19667,
362,
63,
1569,
401,
288,
3877,
3126,
355,
283,
1198,
14,
923,
356,
334,
2734,
291,
12,
2467,
12,
1747,
12,
2762,
12,
286,
7622,
26,
2762,
12,
788,
1569,
995,
1616,
395,
288,
1660,
288,
1720,
628,
10712,
13,
15308,
19397,
402,
314,
1572,
14,
2779,
365,
5847,
1867,
326,
298,
264,
15308,
465,
282,
5049,
88,
772,
5326,
1834,
12,
543,
17435,
10463,
17731,
14,
1867,
326,
298,
6119,
642,
901,
26523,
282,
7425,
1834,
365,
1415,
7651,
267,
283,
3620,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
1198,
14,
3620,
297,
283,
14149,
297,
16549,
628,
22188,
401,
1415,
29,
549,
12
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
7129,
13,
8136,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
18956,
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,
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,
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,
3133,
199,
3,
199,
4605,
199,
199,
646,
5166,
199,
646,
5166,
14,
2537,
465,
7249,
199,
504,
5166,
14,
4795,
492,
9506,
199,
504,
5166,
14,
4795,
492,
1504,
199,
504,
5166,
14,
2537,
14,
3489,
63,
2579,
492,
5048,
63,
2579,
465,
3468,
199,
504,
5166,
492,
12824,
63,
998,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
199,
533,
6016,
63,
923,
8,
4795,
14,
1685,
304,
272,
408,
437,
6016,
63,
923,
365,
282,
3245,
402,
4390,
26994,
3788,
315,
282,
16582,
267,
1572,
14,
710,
1572,
562,
11984,
2932,
787,
4079,
641,
314,
31474,
14,
408,
272,
485,
1802,
275,
283,
31410,
1572,
7,
272,
485,
354,
275,
283,
1198,
14,
923,
7,
272,
485,
1198,
63,
7088,
63,
2671,
275,
756,
272,
485,
6486,
275,
788,
1198,
14,
2671,
418,
272,
485,
20882,
275,
791,
1198,
14,
3620,
356,
283,
3620,
63,
344,
936,
339,
347,
485,
362,
63,
1569,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
536,
12,
1249,
12,
1067,
29,
403,
304,
267,
754,
275,
1052,
267,
367,
1559,
315,
291,
14,
4570,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
29,
1100,
304,
288,
754,
59,
1113,
14,
344,
61,
275,
7249,
14,
1569,
63,
362,
63,
264,
15308,
63,
4782,
8,
1113,
14,
1569,
9,
267,
372,
754,
339,
347,
485,
409,
63,
1569,
8,
277,
12,
2467,
12,
1747,
12,
1305,
12,
536,
12,
574,
12,
1249,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
952,
8,
1556,
12,
1747,
12,
359,
344,
467,
791,
1569,
356,
7249,
14,
1569,
63,
8709,
63,
1569,
63,
5076,
8,
585,
16658,
1067,
29,
1100,
9,
339,
485,
3406,
275,
469,
267,
283,
354,
356,
1504,
14,
1560,
360,
985,
297,
1415,
29,
549,
12,
9028,
29,
549,
395,
267,
283,
1802,
356,
1504,
14,
505,
360,
5831,
659,
267,
283,
4470,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
723,
14,
1907,
14,
4470,
297,
1059,
534,
13885,
18281,
297,
1415,
29,
549,
12,
16549,
628,
15377,
1288,
267,
283,
3455,
356,
1504,
14,
5592,
8318,
3455,
297,
283,
9885,
659,
661,
4239,
297,
283,
12185,
659,
661,
2634,
297,
283,
12461,
5611,
5972,
2665,
283,
4562,
86,
4085,
297,
1415,
29,
549,
12,
288,
1720,
534,
2765,
1572,
365,
8917,
701,
2222,
7556,
14,
971,
288,
1010,
6604,
4652,
883,
1050,
7556,
4012,
314,
24542,
5528,
8038,
267,
283,
923,
63,
3455,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
470,
14,
2634,
297,
1059,
534,
29284,
5611,
659,
267,
283,
923,
63,
1580,
356,
1504,
14,
3479,
18,
3479,
360,
470,
14,
2634,
297,
4668,
534,
1198,
63,
923,
63,
470,
63,
923,
63,
3369,
297,
288,
1305,
17,
534,
1198,
63,
923,
63,
344,
297,
1305,
18,
534,
2634,
63,
344,
297,
1059,
534,
3358,
29763,
297,
288,
1720,
628,
23056,
402,
5204,
4652,
911,
5847,
3483,
465,
31474,
14,
1867,
326,
298,
7443,
626,
2985,
911,
506,
7688,
370,
9635,
3932,
9966,
10250,
1867,
326,
298,
692,
5784,
7651,
267,
327,
1834,
26,
1006,
1834,
1504,
787,
1300,
772,
5737,
436,
14937,
13,
4946,
267,
283,
1569,
356,
1504,
14,
3008,
480,
21258,
401,
288,
1720,
628,
2765,
901,
15164,
314,
1834,
1202,
465,
19397,
367,
314,
1572,
12,
13988,
370,
6619,
88,
7727,
5326,
7651,
267,
283,
1569,
63,
14345,
356,
1504,
14,
1593,
1547,
362,
63,
1569,
12,
4325,
319,
63,
5350,
3699,
409,
63,
1569,
12,
288,
1059,
628,
26139,
13,
15308,
19397,
401,
730,
628,
3008,
401,
3510,
19667,
362,
63,
1569,
401,
288,
3877,
3126,
355,
283,
1198,
14,
923,
356,
334,
2734,
291,
12,
2467,
12,
1747,
12,
2762,
12,
286,
7622,
26,
2762,
12,
788,
1569,
995,
1616,
395,
288,
1660,
288,
1720,
628,
26139,
13,
15308,
19397,
402,
314,
1572,
14,
2779,
365,
5847,
1867,
326,
298,
264,
15308,
465,
282,
7960,
88,
3933,
5326,
1834,
12,
543,
17435,
10463,
17731,
14,
1867,
326,
298,
6119,
642,
901,
315,
1824,
6858,
503,
2005,
1022,
290,
13206,
6858,
7651,
267,
283,
1569,
63,
7241,
356,
1504,
14,
1593,
1547,
362,
63,
1569,
12,
4325,
319,
63,
5350,
3699,
409,
63,
1569,
12,
288,
1059,
628,
10712,
13,
15308,
19397,
401,
730,
628,
3008,
401,
3510,
19667,
362,
63,
1569,
401,
288,
3877,
3126,
355,
283,
1198,
14,
923,
356,
334,
2734,
291,
12,
2467,
12,
1747,
12,
2762,
12,
286,
7622,
26,
2762,
12,
788,
1569,
995,
1616,
395,
288,
1660,
288,
1720,
628,
10712,
13,
15308,
19397,
402,
314,
1572,
14,
2779,
365,
5847,
1867,
326,
298,
264,
15308,
465,
282,
5049,
88,
772,
5326,
1834,
12,
543,
17435,
10463,
17731,
14,
1867,
326,
298,
6119,
642,
901,
26523,
282,
7425,
1834,
365,
1415,
7651,
267,
283,
3620,
63,
344,
356,
1504,
14,
3479,
18,
368,
360,
1198,
14,
3620,
297,
283,
14149,
297,
16549,
628,
22188,
401,
1415,
29,
549,
12,
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,
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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
] |
annarev/tensorflow
|
tensorflow/python/ops/parallel_for/array_test.py
|
9
|
16317
|
# Copyright 2018 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.
# ==============================================================================
"""Tests for vectorization of array kernels."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.eager import backprop
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import test_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn
from tensorflow.python.ops import random_ops
from tensorflow.python.ops import tensor_array_grad # pylint: disable=unused-import
from tensorflow.python.ops.parallel_for import control_flow_ops as pfor_control_flow_ops
from tensorflow.python.ops.parallel_for.test_util import PForTestCase
from tensorflow.python.platform import test
@test_util.run_all_in_graph_and_eager_modes
class ArrayTest(PForTestCase):
def test_gather(self):
x = random_ops.random_uniform([3, 3, 3, 3])
x2 = array_ops.placeholder_with_default(x, shape=None) # Has dynamic shape.
def loop_fn(i):
outputs = []
x_i = array_ops.gather(x, i)
for y in [x, x2, x_i]:
for axis in [0, 2, -1]:
outputs.append(array_ops.gather(y, 2, axis=axis))
outputs.append(
array_ops.gather(y, math_ops.cast(2, dtypes.int64), axis=axis))
outputs.append(
array_ops.gather(y, 2, axis=math_ops.cast(axis, dtypes.int64)))
outputs.append(
array_ops.gather(y, math_ops.cast(i, dtypes.int64), axis=axis))
outputs.append(array_ops.gather(y, [i], axis=axis))
outputs.append(array_ops.gather(y, [i, 2], axis=axis))
outputs.append(array_ops.gather(y, [[2, i], [i, 1]], axis=axis))
outputs.append(array_ops.gather(y, [0, 1, 2], axis=1, batch_dims=1))
outputs.append(array_ops.gather(y, [i, 1, 2], axis=2, batch_dims=1))
outputs.append(array_ops.gather(y, [[2, i], [i, 1], [2, 1]],
axis=-1, batch_dims=1))
outputs.append(
array_ops.gather(y, [[0, 1, 2]] * 3, axis=2, batch_dims=2))
outputs.append(array_ops.gather(y, [0, 1, 2], axis=1, batch_dims=-1))
outputs.append(
array_ops.gather(y, [[0, 1, 2]] * 3, axis=2, batch_dims=-2))
return outputs
self._test_loop_fn(loop_fn, 3)
def test_gather_nd(self):
x = random_ops.random_uniform([3, 3, 3])
def loop_fn(i):
outputs = []
x_i = array_ops.gather(x, i)
outputs.append(array_ops.gather_nd(x_i, [0], batch_dims=0))
outputs.append(array_ops.gather_nd(x_i, [i], batch_dims=0))
outputs.append(array_ops.gather_nd(x_i, [[i], [i], [i]], batch_dims=1))
return outputs
self._test_loop_fn(loop_fn, 3)
def test_shape(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x_i = array_ops.gather(x, i)
return array_ops.shape(x_i), array_ops.shape(x_i, out_type=dtypes.int64)
self._test_loop_fn(loop_fn, 3)
def test_size(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x_i = array_ops.gather(x, i)
return array_ops.size(x_i), array_ops.size(x_i, out_type=dtypes.int64)
self._test_loop_fn(loop_fn, 3)
def test_rank(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x_i = array_ops.gather(x, i)
return array_ops.rank(x_i)
self._test_loop_fn(loop_fn, 3)
def test_shape_n(self):
x = random_ops.random_uniform([3, 2, 3])
y = random_ops.random_uniform([3])
def loop_fn(i):
x_i = array_ops.gather(x, i)
y_i = array_ops.gather(y, i)
return array_ops.shape_n([x_i, x, y,
y_i]), array_ops.shape_n([x_i, x, y, y_i],
out_type=dtypes.int64)
self._test_loop_fn(loop_fn, 3)
def test_reshape(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.reshape(x1, [-1]), array_ops.reshape(x1, [1, 3, 1, -1])
self._test_loop_fn(loop_fn, 3)
def test_fill(self):
def loop_fn(i):
return array_ops.fill((2, 3), i)
self._test_loop_fn(loop_fn, 3)
def test_broadcast_to(self):
x = random_ops.random_uniform([3, 2, 1, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return (array_ops.broadcast_to(x1, [2, 2, 3]),
array_ops.broadcast_to(x1, [1, 2, 1, 3]))
self._test_loop_fn(loop_fn, 3)
def test_expand_dims(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return [
array_ops.expand_dims(x1, axis=-1),
array_ops.expand_dims(x1, axis=1),
array_ops.expand_dims(
x1, axis=constant_op.constant(1, dtype=dtypes.int64))
]
self._test_loop_fn(loop_fn, 3)
def test_one_hot(self):
indices = random_ops.random_uniform([3, 2, 3],
minval=0,
maxval=4,
dtype=dtypes.int32)
def loop_fn(i):
indices_i = array_ops.gather(indices, i)
return (array_ops.one_hot(indices_i, depth=4, on_value=2., off_value=-2.),
array_ops.one_hot(indices_i, depth=4, axis=1))
self._test_loop_fn(loop_fn, 3)
def test_searchsorted(self):
sorted_inputs = math_ops.cumsum(
random_ops.random_uniform([3, 2, 4]), axis=-1)
values = random_ops.random_uniform([2, 3], minval=-1, maxval=4.5)
def loop_fn(i):
inputs_i = array_ops.gather(sorted_inputs, i)
return [
array_ops.searchsorted(
inputs_i, values, out_type=dtypes.int32,
side="left"), # creates LowerBound op.
array_ops.searchsorted(
inputs_i, values, out_type=dtypes.int64, side="right")
] # creates UpperBound op.
self._test_loop_fn(loop_fn, 3)
def test_slice(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.slice(x1, begin=(0, 1), size=(2, 1))
self._test_loop_fn(loop_fn, 3)
def test_tile(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.tile(x1, [2, 1])
self._test_loop_fn(loop_fn, 3)
def test_tile_loop_dependent(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.tile(x1, [i, 1])
with self.assertRaisesRegex(ValueError, "expected to be loop invariant"):
pfor_control_flow_ops.pfor(loop_fn, 2, fallback_to_while_loop=False)
def test_pack(self):
x = random_ops.random_uniform([3, 2, 3])
y = random_ops.random_uniform([2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.stack([x1, y], axis=-1)
self._test_loop_fn(loop_fn, 1)
def test_unpack(self):
x = random_ops.random_uniform([3, 2, 3, 4])
def loop_fn(i):
x_i = array_ops.gather(x, i)
return array_ops.unstack(
x_i, 4, axis=-1), array_ops.unstack(
x_i, 3, axis=1)
self._test_loop_fn(loop_fn, 3)
def test_pad(self):
x = random_ops.random_uniform([3, 2, 3])
padding = constant_op.constant([[1, 2], [3, 4]])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.pad(x1, padding, mode="CONSTANT")
self._test_loop_fn(loop_fn, 3)
def test_split(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.split(x1, 2, axis=0), array_ops.split(x1, 3, axis=-1)
self._test_loop_fn(loop_fn, 3)
def test_split_v(self):
x = random_ops.random_uniform([3, 6, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return (array_ops.split(x1, [2, 1, 3],
axis=0), array_ops.split(x1, [3], axis=-1))
self._test_loop_fn(loop_fn, 3)
def test_squeeze(self):
x = random_ops.random_uniform([5, 1, 2, 1])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return (array_ops.squeeze(x1, axis=0), array_ops.squeeze(x1, axis=-1),
array_ops.squeeze(x1))
self._test_loop_fn(loop_fn, 3)
def test_reverse(self):
x = random_ops.random_uniform([3, 4, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return (array_ops.reverse(x1, axis=[0]),
array_ops.reverse(x1, axis=[-1]),
array_ops.reverse(x1, axis=[1, -1]))
self._test_loop_fn(loop_fn, 3)
def test_transpose(self):
x = random_ops.random_uniform([3, 2, 3, 4])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.transpose(x1, [2, 1, 0])
self._test_loop_fn(loop_fn, 3)
def test_conjugate_transpose(self):
x = math_ops.complex(
random_ops.random_uniform([3, 2, 3, 4]),
random_ops.random_uniform([3, 2, 3, 4]))
def loop_fn(i):
x_i = array_ops.gather(x, i)
return array_ops.conjugate_transpose(x_i, [2, 1, 0])
self._test_loop_fn(loop_fn, 3)
def test_zeros_like(self):
x = random_ops.random_uniform([3, 2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
z = array_ops.zeros_like(x1),
return z, z + x1
self._test_loop_fn(loop_fn, 3)
def test_concat_v2(self):
x = random_ops.random_uniform([3, 2, 3])
y = random_ops.random_uniform([2, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return [
array_ops.concat([x1, x1, y], axis=0),
array_ops.concat([x1, x1, y], axis=-1),
array_ops.concat([x1, x1, y],
axis=constant_op.constant(0, dtype=dtypes.int64))
]
self._test_loop_fn(loop_fn, 3)
def test_unary_cwise_ops(self):
for op in [array_ops.identity, array_ops.stop_gradient]:
with backprop.GradientTape(persistent=True) as g:
x = random_ops.random_uniform([3, 5])
g.watch(x)
# pylint: disable=cell-var-from-loop
def loop_fn(i):
with g:
x1 = array_ops.gather(x, i)
y = op(x1) + x1
loss = nn.l2_loss(y)
return op(x), y, g.gradient(loss, x1)
# pylint: enable=cell-var-from-loop
self._test_loop_fn(loop_fn, 3)
def test_identity_n(self):
x = random_ops.random_uniform([3, 4])
def loop_fn(i):
return array_ops.identity_n([x, array_ops.gather(x, i)])
self._test_loop_fn(loop_fn, 3)
def test_matrix_band_part(self):
x = random_ops.random_uniform([3, 4, 2, 2])
for num_lower, num_upper in ((0, -1), (-1, 0), (1, 1)):
# pylint: disable=cell-var-from-loop
def loop_fn(i):
return array_ops.matrix_band_part(
array_ops.gather(x, i), num_lower=num_lower, num_upper=num_upper)
# pylint: enable=cell-var-from-loop
self._test_loop_fn(loop_fn, 3)
def test_matrix_diag(self):
x = random_ops.random_uniform([3, 2, 4])
def loop_fn(i):
diagonal = array_ops.gather(x, i)
return array_ops.matrix_diag(
diagonal, k=(0, 1), num_rows=4, num_cols=5, align="RIGHT_LEFT")
self._test_loop_fn(loop_fn, 3)
def test_matrix_diag_part(self):
x = random_ops.random_uniform([3, 4, 6])
def loop_fn(i):
input = array_ops.gather(x, i) # pylint: disable=redefined-builtin
return array_ops.matrix_diag_part(
input, k=(-2, 0), padding_value=3, align="RIGHT_LEFT")
self._test_loop_fn(loop_fn, 3)
def test_diag(self):
for x in (random_ops.random_uniform([3, 4]),
random_ops.random_uniform([3, 4, 2])):
# pylint: disable=cell-var-from-loop
def loop_fn(i):
inp = array_ops.gather(x, i)
return array_ops.diag(inp)
# pylint: disable=cell-var-from-loop
self._test_loop_fn(loop_fn, 3)
def test_diag_part(self):
for x in (random_ops.random_uniform([3, 2, 2]),
random_ops.random_uniform([3, 4, 2, 4, 2])):
# pylint: disable=cell-var-from-loop
def loop_fn(i):
inp = array_ops.gather(x, i) # pylint: disable=redefined-builtin
return array_ops.diag_part(inp)
# pylint: disable=cell-var-from-loop
self._test_loop_fn(loop_fn, 3)
def test_matrix_set_diag(self):
matrices = random_ops.random_uniform([3, 4, 4])
diags = random_ops.random_uniform([3, 4])
bands = random_ops.random_uniform([3, 3, 4])
def loop_fn(i):
matrix_i = array_ops.gather(matrices, i)
diag_i = array_ops.gather(diags, i)
results = [
array_ops.matrix_set_diag(matrix_i, diag_i),
array_ops.matrix_set_diag(matrices[0, ...], diag_i),
array_ops.matrix_set_diag(matrix_i, diags[0, ...]),
]
k = (-1, 1)
band_i = array_ops.gather(bands, i)
for align in ["RIGHT_LEFT", "LEFT_RIGHT"]:
results.extend([
array_ops.matrix_set_diag(matrix_i, band_i, k=k, align=align),
array_ops.matrix_set_diag(
matrices[0, ...], band_i, k=k, align=align),
array_ops.matrix_set_diag(
matrix_i, bands[0, ...], k=k, align=align)
])
return results
self._test_loop_fn(loop_fn, 3)
def test_strided_slice(self):
with backprop.GradientTape(persistent=True) as g:
x = random_ops.random_uniform([3, 3, 4, 4, 2, 2, 2])
g.watch(x)
def loop_fn(i):
with g:
x_i = array_ops.gather(x, i)
y = x_i[:2, ::2, 1::3, ..., array_ops.newaxis, 1]
loss = nn.l2_loss(y)
return y, g.gradient(loss, x_i)
self._test_loop_fn(loop_fn, 3)
def test_strided_slice_loop_variant(self):
x = random_ops.random_uniform([3, 3, 4, 4, 2, 2, 2])
def loop_fn(i):
x_i = array_ops.gather(x, i)
return x_i[i:i+1, ...]
# Test the fallback to while loop for a ConversionNotImplementedError is
# handled.
self._test_loop_fn(loop_fn, 3, fallback_to_while_loop=True)
# Without fallback, ValueError is thrown.
with self.assertRaisesRegex(ValueError, "expected to be loop invariant"):
self._test_loop_fn(loop_fn, 3, fallback_to_while_loop=False)
def test_depth_to_space(self):
x = random_ops.random_uniform([2, 3, 2, 2, 12])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.depth_to_space(x1, 2, data_format="NHWC")
self._test_loop_fn(loop_fn, 2)
def test_space_to_depth(self):
x = random_ops.random_uniform([2, 3, 12, 12, 3])
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.space_to_depth(x1, 2, data_format="NHWC")
self._test_loop_fn(loop_fn, 2)
def test_batch_to_space_nd(self):
x = random_ops.random_uniform([7, 5 * 2 * 3, 2, 2, 3, 2])
block_shapes = [2, 3]
crops = [[1, 2], [1, 0]]
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.batch_to_space_nd(x1, block_shapes, crops)
self._test_loop_fn(loop_fn, 7)
def test_space_to_batch_nd(self):
x = random_ops.random_uniform([7, 5, 2 * 2 - 3, 2 * 3 - 1, 3, 2])
block_shapes = [2, 3]
paddings = [[1, 2], [1, 0]]
def loop_fn(i):
x1 = array_ops.gather(x, i)
return array_ops.space_to_batch_nd(x1, block_shapes, paddings)
self._test_loop_fn(loop_fn, 7)
def test_check_numerics(self):
x = random_ops.random_uniform([2, 3, 4])
def loop_fn(i):
x_i = array_ops.gather(x, i)
return array_ops.check_numerics(x_i, "test_message")
self._test_loop_fn(loop_fn, 2)
if __name__ == "__main__":
test.main()
|
apache-2.0
|
[
3,
1898,
14894,
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,
2925,
367,
5477,
2072,
402,
1625,
26091,
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,
10283,
492,
1771,
4469,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
511,
63,
1974,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
199,
504,
3228,
14,
1548,
14,
1483,
492,
2196,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
2345,
63,
1144,
63,
6017,
221,
327,
4287,
26,
3507,
29,
8618,
13,
646,
199,
504,
3228,
14,
1548,
14,
1483,
14,
11887,
63,
509,
492,
3304,
63,
1659,
63,
1483,
465,
299,
509,
63,
2785,
63,
1659,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
11887,
63,
509,
14,
396,
63,
1974,
492,
510,
1858,
1746,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
32,
396,
63,
1974,
14,
1065,
63,
452,
63,
262,
63,
2180,
63,
460,
63,
10283,
63,
10433,
199,
533,
8725,
774,
8,
48,
1858,
1746,
304,
819,
347,
511,
63,
13737,
8,
277,
304,
272,
671,
275,
2196,
63,
1483,
14,
2355,
63,
8830,
779,
19,
12,
650,
12,
650,
12,
650,
566,
272,
671,
18,
275,
1625,
63,
1483,
14,
6199,
63,
1045,
63,
885,
8,
88,
12,
2215,
29,
403,
9,
221,
327,
13481,
8336,
2215,
14,
339,
347,
4438,
63,
2324,
8,
73,
304,
489,
4704,
275,
942,
489,
671,
63,
73,
275,
1625,
63,
1483,
14,
13737,
8,
88,
12,
284,
9,
489,
367,
612,
315,
359,
88,
12,
671,
18,
12,
671,
63,
73,
2189,
267,
367,
3114,
315,
359,
16,
12,
499,
12,
446,
17,
2189,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
499,
12,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1598,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3473,
63,
1483,
14,
2931,
8,
18,
12,
6674,
14,
442,
772,
395,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1598,
1625,
63,
1483,
14,
13737,
8,
89,
12,
499,
12,
3114,
29,
3442,
63,
1483,
14,
2931,
8,
3127,
12,
6674,
14,
442,
772,
1724,
881,
4704,
14,
740,
8,
1598,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3473,
63,
1483,
14,
2931,
8,
73,
12,
6674,
14,
442,
772,
395,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
73,
467,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
73,
12,
499,
467,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
3474,
18,
12,
284,
467,
359,
73,
12,
413,
2365,
3114,
29,
3127,
430,
398,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
16,
12,
413,
12,
499,
467,
3114,
29,
17,
12,
3522,
63,
5380,
29,
17,
430,
267,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
73,
12,
413,
12,
499,
467,
3114,
29,
18,
12,
3522,
63,
5380,
29,
17,
430,
267,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
3474,
18,
12,
284,
467,
359,
73,
12,
413,
467,
359,
18,
12,
413,
2365,
3147,
3114,
4022,
17,
12,
3522,
63,
5380,
29,
17,
430,
267,
4704,
14,
740,
8,
288,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3474,
16,
12,
413,
12,
499,
2677,
627,
650,
12,
3114,
29,
18,
12,
3522,
63,
5380,
29,
18,
430,
267,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
16,
12,
413,
12,
499,
467,
3114,
29,
17,
12,
3522,
63,
5380,
4022,
17,
430,
267,
4704,
14,
740,
8,
288,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3474,
16,
12,
413,
12,
499,
2677,
627,
650,
12,
3114,
29,
18,
12,
3522,
63,
5380,
4022,
18,
430,
2541,
372,
4704,
339,
291,
423,
396,
63,
3813,
63,
2324,
8,
3813,
63,
2324,
12,
650,
9,
819,
347,
511,
63,
13737,
63,
977,
8,
277,
304,
272,
671,
275,
2196,
63,
1483,
14,
2355,
63,
8830,
779,
19,
12,
650,
12,
650,
566,
339,
347,
4438,
63,
2324,
8,
73,
304,
489,
4704,
275,
942,
489,
671,
63,
73,
275,
1625,
63,
1483,
14,
13737,
8,
88,
12,
284,
9,
489,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
63,
977,
8,
88,
63,
73,
12,
359,
16,
467,
3522,
63,
5380,
29,
16,
430,
489,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
63,
977,
8,
88,
63,
73,
12,
359,
73,
467,
3522,
63,
5380,
29,
16,
430,
489,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
63,
977,
8,
88,
63,
73,
12,
3474,
73,
467,
359,
73,
467,
359,
73,
2365,
3522,
63,
5380,
29,
17,
430,
489,
372,
4704,
339,
291,
423,
396,
63,
3813,
63,
2324,
8,
3813,
63
] |
[
1898,
14894,
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,
2925,
367,
5477,
2072,
402,
1625,
26091,
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,
10283,
492,
1771,
4469,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
511,
63,
1974,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
199,
504,
3228,
14,
1548,
14,
1483,
492,
2196,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
2345,
63,
1144,
63,
6017,
221,
327,
4287,
26,
3507,
29,
8618,
13,
646,
199,
504,
3228,
14,
1548,
14,
1483,
14,
11887,
63,
509,
492,
3304,
63,
1659,
63,
1483,
465,
299,
509,
63,
2785,
63,
1659,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
11887,
63,
509,
14,
396,
63,
1974,
492,
510,
1858,
1746,
199,
504,
3228,
14,
1548,
14,
3246,
492,
511,
421,
199,
32,
396,
63,
1974,
14,
1065,
63,
452,
63,
262,
63,
2180,
63,
460,
63,
10283,
63,
10433,
199,
533,
8725,
774,
8,
48,
1858,
1746,
304,
819,
347,
511,
63,
13737,
8,
277,
304,
272,
671,
275,
2196,
63,
1483,
14,
2355,
63,
8830,
779,
19,
12,
650,
12,
650,
12,
650,
566,
272,
671,
18,
275,
1625,
63,
1483,
14,
6199,
63,
1045,
63,
885,
8,
88,
12,
2215,
29,
403,
9,
221,
327,
13481,
8336,
2215,
14,
339,
347,
4438,
63,
2324,
8,
73,
304,
489,
4704,
275,
942,
489,
671,
63,
73,
275,
1625,
63,
1483,
14,
13737,
8,
88,
12,
284,
9,
489,
367,
612,
315,
359,
88,
12,
671,
18,
12,
671,
63,
73,
2189,
267,
367,
3114,
315,
359,
16,
12,
499,
12,
446,
17,
2189,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
499,
12,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1598,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3473,
63,
1483,
14,
2931,
8,
18,
12,
6674,
14,
442,
772,
395,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1598,
1625,
63,
1483,
14,
13737,
8,
89,
12,
499,
12,
3114,
29,
3442,
63,
1483,
14,
2931,
8,
3127,
12,
6674,
14,
442,
772,
1724,
881,
4704,
14,
740,
8,
1598,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3473,
63,
1483,
14,
2931,
8,
73,
12,
6674,
14,
442,
772,
395,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
73,
467,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
73,
12,
499,
467,
3114,
29,
3127,
430,
881,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
3474,
18,
12,
284,
467,
359,
73,
12,
413,
2365,
3114,
29,
3127,
430,
398,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
16,
12,
413,
12,
499,
467,
3114,
29,
17,
12,
3522,
63,
5380,
29,
17,
430,
267,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
73,
12,
413,
12,
499,
467,
3114,
29,
18,
12,
3522,
63,
5380,
29,
17,
430,
267,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
3474,
18,
12,
284,
467,
359,
73,
12,
413,
467,
359,
18,
12,
413,
2365,
3147,
3114,
4022,
17,
12,
3522,
63,
5380,
29,
17,
430,
267,
4704,
14,
740,
8,
288,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3474,
16,
12,
413,
12,
499,
2677,
627,
650,
12,
3114,
29,
18,
12,
3522,
63,
5380,
29,
18,
430,
267,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
8,
89,
12,
359,
16,
12,
413,
12,
499,
467,
3114,
29,
17,
12,
3522,
63,
5380,
4022,
17,
430,
267,
4704,
14,
740,
8,
288,
1625,
63,
1483,
14,
13737,
8,
89,
12,
3474,
16,
12,
413,
12,
499,
2677,
627,
650,
12,
3114,
29,
18,
12,
3522,
63,
5380,
4022,
18,
430,
2541,
372,
4704,
339,
291,
423,
396,
63,
3813,
63,
2324,
8,
3813,
63,
2324,
12,
650,
9,
819,
347,
511,
63,
13737,
63,
977,
8,
277,
304,
272,
671,
275,
2196,
63,
1483,
14,
2355,
63,
8830,
779,
19,
12,
650,
12,
650,
566,
339,
347,
4438,
63,
2324,
8,
73,
304,
489,
4704,
275,
942,
489,
671,
63,
73,
275,
1625,
63,
1483,
14,
13737,
8,
88,
12,
284,
9,
489,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
63,
977,
8,
88,
63,
73,
12,
359,
16,
467,
3522,
63,
5380,
29,
16,
430,
489,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
63,
977,
8,
88,
63,
73,
12,
359,
73,
467,
3522,
63,
5380,
29,
16,
430,
489,
4704,
14,
740,
8,
1144,
63,
1483,
14,
13737,
63,
977,
8,
88,
63,
73,
12,
3474,
73,
467,
359,
73,
467,
359,
73,
2365,
3522,
63,
5380,
29,
17,
430,
489,
372,
4704,
339,
291,
423,
396,
63,
3813,
63,
2324,
8,
3813,
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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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
] |
vmindru/ansible
|
lib/ansible/modules/network/aci/mso_schema_template_anp_epg_subnet.py
|
4
|
7529
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
# 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 = r'''
---
module: mso_schema_template_anp_epg_subnet
short_description: Manage EPG subnets in schema templates
description:
- Manage EPG subnets in schema templates on Cisco ACI Multi-Site.
author:
- Dag Wieers (@dagwieers)
version_added: '2.8'
options:
schema:
description:
- The name of the schema.
type: str
required: yes
template:
description:
- The name of the template to change.
type: list
required: yes
anp:
description:
- The name of the ANP.
type: str
required: yes
epg:
description:
- The name of the EPG to manage.
type: str
required: yes
ip:
description:
- The IP range in CIDR notation.
type: str
required: true
description:
description:
- The description of this subnet.
type: str
scope:
description:
- The scope of the subnet.
type: str
choices: [ private, public ]
shared:
description:
- Whether this subnet is shared between VRFs.
type: bool
no_default_gateway:
description:
- Whether this subnet has a default gateway.
type: bool
state:
description:
- Use C(present) or C(absent) for adding or removing.
- Use C(query) for listing an object or multiple objects.
type: str
choices: [ absent, present, query ]
default: present
notes:
- Due to restrictions of the MSO REST API concurrent modifications to EPG subnets can be dangerous and corrupt data.
extends_documentation_fragment: mso
'''
EXAMPLES = r'''
- name: Add a new subnet to an EPG
mso_schema_template_anp_subnet:
host: mso_host
username: admin
password: SomeSecretPassword
schema: Schema 1
template: Template 1
anp: ANP 1
epg: EPG 1
ip: 10.0.0.0/24
state: present
delegate_to: localhost
- name: Remove an EPG
mso_schema_template_anp_epg:
host: mso_host
username: admin
password: SomeSecretPassword
schema: Schema 1
template: Template 1
anp: ANP 1
epg: EPG 1
ip: 10.0.0.0/24
state: absent
delegate_to: localhost
- name: Query a specific EPG
mso_schema_template_anp_epg:
host: mso_host
username: admin
password: SomeSecretPassword
schema: Schema 1
template: Template 1
anp: ANP 1
epg: EPG 1
ip: 10.0.0.0/24
state: query
delegate_to: localhost
register: query_result
- name: Query all EPGs
mso_schema_template_anp_epg:
host: mso_host
username: admin
password: SomeSecretPassword
schema: Schema 1
template: Template 1
anp: ANP 1
state: query
delegate_to: localhost
register: query_result
'''
RETURN = r'''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, mso_reference_spec, mso_subnet_spec
def main():
argument_spec = mso_argument_spec()
argument_spec.update(
schema=dict(type='str', required=True),
template=dict(type='str', required=True),
anp=dict(type='str', required=True),
epg=dict(type='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
)
argument_spec.update(mso_subnet_spec())
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[
['state', 'absent', ['ip']],
['state', 'present', ['ip']],
],
)
schema = module.params['schema']
template = module.params['template']
anp = module.params['anp']
epg = module.params['epg']
ip = module.params['ip']
description = module.params['description']
scope = module.params['scope']
shared = module.params['shared']
no_default_gateway = module.params['no_default_gateway']
state = module.params['state']
mso = MSOModule(module)
# Get schema
schema_obj = mso.get_obj('schemas', displayName=schema)
if not schema_obj:
mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema))
schema_path = 'schemas/{id}'.format(**schema_obj)
# Get template
templates = [t['name'] for t in schema_obj['templates']]
if template not in templates:
mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template,
templates=', '.join(templates)))
template_idx = templates.index(template)
# Get ANP
anps = [a['name'] for a in schema_obj['templates'][template_idx]['anps']]
if anp not in anps:
mso.fail_json(msg="Provided anp '{anp}' does not exist. Existing anps: {anps}".format(anp=anp, anps=', '.join(anps)))
anp_idx = anps.index(anp)
# Get EPG
epgs = [e['name'] for e in schema_obj['templates'][template_idx]['anps'][anp_idx]['epgs']]
if epg not in epgs:
mso.fail_json(msg="Provided epg '{epg}' does not exist. Existing epgs: {epgs}".format(epg=epg, epgs=', '.join(epgs)))
epg_idx = epgs.index(epg)
# Get Subnet
subnets = [s['ip'] for s in schema_obj['templates'][template_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets']]
if ip in subnets:
ip_idx = subnets.index(ip)
# FIXME: Changes based on index are DANGEROUS
subnet_path = '/templates/{0}/anps/{1}/epgs/{2}/subnets/{3}'.format(template, anp, epg, ip_idx)
mso.existing = schema_obj['templates'][template_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets'][ip_idx]
if state == 'query':
if ip is None:
mso.existing = schema_obj['templates'][template_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets']
elif not mso.existing:
mso.fail_json(msg="Subnet '{ip}' not found".format(ip=ip))
mso.exit_json()
subnets_path = '/templates/{0}/anps/{1}/epgs/{2}/subnets'.format(template, anp, epg)
ops = []
mso.previous = mso.existing
if state == 'absent':
if mso.existing:
mso.existing = {}
ops.append(dict(op='remove', path=subnet_path))
elif state == 'present':
if description is None and not mso.existing:
description = ip
if scope is None and not mso.existing:
scope = 'private'
if shared is None and not mso.existing:
shared = False
if no_default_gateway is None and not mso.existing:
no_default_gateway = False
payload = dict(
ip=ip,
description=description,
scope=scope,
shared=shared,
noDefaultGateway=no_default_gateway,
)
mso.sanitize(payload, collate=True)
if mso.existing:
ops.append(dict(op='replace', path=subnet_path, value=mso.sent))
else:
ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent))
mso.existing = mso.proposed
if not module.check_mode:
mso.request(schema_path, method='PATCH', data=ops)
mso.exit_json()
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,
1898,
26,
334,
67,
9,
14894,
12,
26110,
644,
1873,
1192,
8593,
7406,
87,
1873,
1192,
9,
665,
7406,
32,
87,
1873,
1192,
14,
957,
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,
199,
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,
519,
2344,
199,
2595,
199,
578,
26,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
63,
5327,
199,
3612,
63,
1802,
26,
14944,
662,
11115,
18709,
315,
4177,
7009,
199,
1802,
26,
199,
13,
14944,
662,
11115,
18709,
315,
4177,
7009,
641,
28356,
437,
3553,
6879,
13,
8972,
14,
199,
2502,
26,
199,
13,
26110,
644,
1873,
1192,
8593,
7406,
87,
1873,
1192,
9,
199,
1023,
63,
3270,
26,
283,
18,
14,
24,
7,
199,
1419,
26,
523,
4177,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
4177,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
523,
1978,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
1978,
370,
1570,
14,
272,
730,
26,
769,
272,
1415,
26,
9456,
523,
376,
80,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
1261,
48,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
523,
325,
4198,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
662,
11115,
370,
9635,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
523,
3384,
26,
272,
1369,
26,
272,
446,
710,
3531,
1425,
315,
29215,
15843,
14,
272,
730,
26,
620,
272,
1415,
26,
2549,
523,
1369,
26,
272,
1369,
26,
272,
446,
710,
1369,
402,
642,
6303,
14,
272,
730,
26,
620,
523,
4194,
26,
272,
1369,
26,
272,
446,
710,
4194,
402,
314,
6303,
14,
272,
730,
26,
620,
272,
3415,
26,
359,
5726,
12,
4575,
1622,
523,
5709,
26,
272,
1369,
26,
272,
446,
7480,
642,
6303,
365,
5709,
3382,
812,
11778,
83,
14,
272,
730,
26,
2155,
523,
949,
63,
885,
63,
7019,
26,
272,
1369,
26,
272,
446,
7480,
642,
6303,
965,
282,
849,
10391,
14,
272,
730,
26,
2155,
523,
1174,
26,
272,
1369,
26,
272,
446,
3645,
445,
8,
1881,
9,
503,
445,
8,
5575,
9,
367,
7791,
503,
12881,
14,
272,
446,
3645,
445,
8,
1131,
9,
367,
13778,
376,
909,
503,
3663,
2251,
14,
272,
730,
26,
620,
272,
3415,
26,
359,
9552,
12,
3451,
12,
1827,
1622,
272,
849,
26,
3451,
199,
5983,
26,
199,
13,
25855,
370,
24488,
402,
314,
603,
4118,
14880,
3261,
23002,
23070,
370,
662,
11115,
18709,
883,
506,
366,
21480,
436,
29221,
666,
14,
199,
11036,
63,
9970,
63,
7677,
26,
333,
1152,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
2654,
282,
892,
6303,
370,
376,
662,
11115,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
5327,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
325,
4198,
26,
662,
11115,
413,
272,
3384,
26,
1616,
14,
16,
14,
16,
14,
16,
15,
1194,
272,
1174,
26,
3451,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
5852,
376,
662,
11115,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
325,
4198,
26,
662,
11115,
413,
272,
3384,
26,
1616,
14,
16,
14,
16,
14,
16,
15,
1194,
272,
1174,
26,
9552,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
8133,
282,
2488,
662,
11115,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
325,
4198,
26,
662,
11115,
413,
272,
3384,
26,
1616,
14,
16,
14,
16,
14,
16,
15,
1194,
272,
1174,
26,
1827,
523,
13080,
63,
475,
26,
11667,
523,
2274,
26,
1827,
63,
1099,
199,
199,
13,
536,
26,
8133,
1006,
662,
11115,
83,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
1174,
26,
1827,
523,
13080,
63,
475,
26,
11667,
523,
2274,
26,
1827,
63,
1099,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
1200,
14,
22832,
14,
706,
79,
492,
603,
4118,
2377,
12,
333,
1152,
63,
2094,
63,
1650,
12,
333,
1152,
63,
4443,
63,
1650,
12,
333,
1152,
63,
5327,
63,
1650,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
333,
1152,
63,
2094,
63,
1650,
342,
272,
1423,
63,
1650,
14,
873,
8,
267,
4177,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
1978,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
376,
80,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
325,
4198,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
1174,
29,
807,
8,
466,
534,
495,
297,
849,
534,
1881,
297,
3415,
2968,
5575,
297,
283,
1881,
297,
283,
1131
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
14894,
12,
26110,
644,
1873,
1192,
8593,
7406,
87,
1873,
1192,
9,
665,
7406,
32,
87,
1873,
1192,
14,
957,
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,
199,
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,
519,
2344,
199,
2595,
199,
578,
26,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
63,
5327,
199,
3612,
63,
1802,
26,
14944,
662,
11115,
18709,
315,
4177,
7009,
199,
1802,
26,
199,
13,
14944,
662,
11115,
18709,
315,
4177,
7009,
641,
28356,
437,
3553,
6879,
13,
8972,
14,
199,
2502,
26,
199,
13,
26110,
644,
1873,
1192,
8593,
7406,
87,
1873,
1192,
9,
199,
1023,
63,
3270,
26,
283,
18,
14,
24,
7,
199,
1419,
26,
523,
4177,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
4177,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
523,
1978,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
1978,
370,
1570,
14,
272,
730,
26,
769,
272,
1415,
26,
9456,
523,
376,
80,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
1261,
48,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
523,
325,
4198,
26,
272,
1369,
26,
272,
446,
710,
536,
402,
314,
662,
11115,
370,
9635,
14,
272,
730,
26,
620,
272,
1415,
26,
9456,
523,
3384,
26,
272,
1369,
26,
272,
446,
710,
3531,
1425,
315,
29215,
15843,
14,
272,
730,
26,
620,
272,
1415,
26,
2549,
523,
1369,
26,
272,
1369,
26,
272,
446,
710,
1369,
402,
642,
6303,
14,
272,
730,
26,
620,
523,
4194,
26,
272,
1369,
26,
272,
446,
710,
4194,
402,
314,
6303,
14,
272,
730,
26,
620,
272,
3415,
26,
359,
5726,
12,
4575,
1622,
523,
5709,
26,
272,
1369,
26,
272,
446,
7480,
642,
6303,
365,
5709,
3382,
812,
11778,
83,
14,
272,
730,
26,
2155,
523,
949,
63,
885,
63,
7019,
26,
272,
1369,
26,
272,
446,
7480,
642,
6303,
965,
282,
849,
10391,
14,
272,
730,
26,
2155,
523,
1174,
26,
272,
1369,
26,
272,
446,
3645,
445,
8,
1881,
9,
503,
445,
8,
5575,
9,
367,
7791,
503,
12881,
14,
272,
446,
3645,
445,
8,
1131,
9,
367,
13778,
376,
909,
503,
3663,
2251,
14,
272,
730,
26,
620,
272,
3415,
26,
359,
9552,
12,
3451,
12,
1827,
1622,
272,
849,
26,
3451,
199,
5983,
26,
199,
13,
25855,
370,
24488,
402,
314,
603,
4118,
14880,
3261,
23002,
23070,
370,
662,
11115,
18709,
883,
506,
366,
21480,
436,
29221,
666,
14,
199,
11036,
63,
9970,
63,
7677,
26,
333,
1152,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
2654,
282,
892,
6303,
370,
376,
662,
11115,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
5327,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
325,
4198,
26,
662,
11115,
413,
272,
3384,
26,
1616,
14,
16,
14,
16,
14,
16,
15,
1194,
272,
1174,
26,
3451,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
5852,
376,
662,
11115,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
325,
4198,
26,
662,
11115,
413,
272,
3384,
26,
1616,
14,
16,
14,
16,
14,
16,
15,
1194,
272,
1174,
26,
9552,
523,
13080,
63,
475,
26,
11667,
199,
199,
13,
536,
26,
8133,
282,
2488,
662,
11115,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
325,
4198,
26,
662,
11115,
413,
272,
3384,
26,
1616,
14,
16,
14,
16,
14,
16,
15,
1194,
272,
1174,
26,
1827,
523,
13080,
63,
475,
26,
11667,
523,
2274,
26,
1827,
63,
1099,
199,
199,
13,
536,
26,
8133,
1006,
662,
11115,
83,
523,
333,
1152,
63,
3629,
63,
1160,
63,
290,
80,
63,
22967,
26,
272,
1591,
26,
333,
1152,
63,
1102,
272,
3434,
26,
4628,
272,
2505,
26,
6601,
13790,
6139,
272,
4177,
26,
13268,
413,
272,
1978,
26,
5458,
413,
272,
376,
80,
26,
1261,
48,
413,
272,
1174,
26,
1827,
523,
13080,
63,
475,
26,
11667,
523,
2274,
26,
1827,
63,
1099,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
2344,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
1200,
14,
22832,
14,
706,
79,
492,
603,
4118,
2377,
12,
333,
1152,
63,
2094,
63,
1650,
12,
333,
1152,
63,
4443,
63,
1650,
12,
333,
1152,
63,
5327,
63,
1650,
421,
199,
318,
2446,
837,
272,
1423,
63,
1650,
275,
333,
1152,
63,
2094,
63,
1650,
342,
272,
1423,
63,
1650,
14,
873,
8,
267,
4177,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
1978,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
376,
80,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
325,
4198,
29,
807,
8,
466,
534,
495,
297,
1415,
29,
549,
395,
267,
1174,
29,
807,
8,
466,
534,
495,
297,
849,
534,
1881,
297,
3415,
2968,
5575,
297,
283,
1881,
297,
283,
1131,
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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