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
KellyChan/Python
javascript/backbone/backbone-templates/backbone-fileupload/venvs/lib/python2.7/site-packages/django/utils/html.py
78
9474
"""HTML utilities suitable for global use.""" import re import string import urllib import urlparse from django.utils.safestring import SafeData, mark_safe from django.utils.encoding import smart_str, force_unicode from django.utils.functional import allow_lazy from django.utils.text import normalize_newlines # Configuration for urlize() function. TRAILING_PUNCTUATION = ['.', ',', ':', ';'] WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('&lt;', '&gt;')] # List of possible strings used for bullets in bulleted lists. DOTS = [u'&middot;', u'*', u'\u2022', u'&#149;', u'&bull;', u'&#8226;'] unencoded_ampersands_re = re.compile(r'&(?!(\w+|#\d+);)') unquoted_percents_re = re.compile(r'%(?![0-9A-Fa-f]{2})') word_split_re = re.compile(r'(\s+)') simple_url_re = re.compile(r'^https?://\w') simple_url_2_re = re.compile(r'^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)$') simple_email_re = re.compile(r'^\S+@\S+\.\S+$') link_target_attribute_re = re.compile(r'(<a [^>]*?)target=[^\s>]+') html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL) trailing_empty_content_re = re.compile(r'(?:<p>(?:&nbsp;|\s|<br \/>)*?</p>\s*)+\Z') del x # Temporary variable def escape(html): """ Returns the given HTML with ampersands, quotes and angle brackets encoded. """ return mark_safe(force_unicode(html).replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;')) escape = allow_lazy(escape, unicode) _base_js_escapes = ( ('\\', r'\u005C'), ('\'', r'\u0027'), ('"', r'\u0022'), ('>', r'\u003E'), ('<', r'\u003C'), ('&', r'\u0026'), ('=', r'\u003D'), ('-', r'\u002D'), (';', r'\u003B'), (u'\u2028', r'\u2028'), (u'\u2029', r'\u2029') ) # Escape every ASCII character with a value less than 32. _js_escapes = (_base_js_escapes + tuple([('%c' % z, '\\u%04X' % z) for z in range(32)])) def escapejs(value): """Hex encodes characters for use in JavaScript strings.""" for bad, good in _js_escapes: value = mark_safe(force_unicode(value).replace(bad, good)) return value escapejs = allow_lazy(escapejs, unicode) def conditional_escape(html): """ Similar to escape(), except that it doesn't operate on pre-escaped strings. """ if isinstance(html, SafeData): return html else: return escape(html) def linebreaks(value, autoescape=False): """Converts newlines into <p> and <br />s.""" value = normalize_newlines(value) paras = re.split('\n{2,}', value) if autoescape: paras = [u'<p>%s</p>' % escape(p).replace('\n', '<br />') for p in paras] else: paras = [u'<p>%s</p>' % p.replace('\n', '<br />') for p in paras] return u'\n\n'.join(paras) linebreaks = allow_lazy(linebreaks, unicode) def strip_tags(value): """Returns the given HTML with all tags stripped.""" return re.sub(r'<[^>]*?>', '', force_unicode(value)) strip_tags = allow_lazy(strip_tags) def strip_spaces_between_tags(value): """Returns the given HTML with spaces between tags removed.""" return re.sub(r'>\s+<', '><', force_unicode(value)) strip_spaces_between_tags = allow_lazy(strip_spaces_between_tags, unicode) def strip_entities(value): """Returns the given HTML with all entities (&something;) stripped.""" return re.sub(r'&(?:\w+|#\d+);', '', force_unicode(value)) strip_entities = allow_lazy(strip_entities, unicode) def fix_ampersands(value): """Returns the given HTML with all unencoded ampersands encoded correctly.""" return unencoded_ampersands_re.sub('&amp;', force_unicode(value)) fix_ampersands = allow_lazy(fix_ampersands, unicode) def smart_urlquote(url): "Quotes a URL if it isn't already quoted." # Handle IDN before quoting. scheme, netloc, path, query, fragment = urlparse.urlsplit(url) try: netloc = netloc.encode('idna') # IDN -> ACE except UnicodeError: # invalid domain part pass else: url = urlparse.urlunsplit((scheme, netloc, path, query, fragment)) # An URL is considered unquoted if it contains no % characters or # contains a % not followed by two hexadecimal digits. See #9655. if '%' not in url or unquoted_percents_re.search(url): # See http://bugs.python.org/issue2637 url = urllib.quote(smart_str(url), safe='!*\'();:@&=+$,/?#[]~') return force_unicode(url) def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): """ Converts any URLs in text into clickable links. Works on http://, https://, www. links, and also on links ending in one of the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org). Links can have trailing punctuation (periods, commas, close-parens) and leading punctuation (opening parens) and it'll still do the right thing. If trim_url_limit is not None, the URLs in link text longer than this limit will truncated to trim_url_limit-3 characters and appended with an elipsis. If nofollow is True, the URLs in link text will get a rel="nofollow" attribute. If autoescape is True, the link text and URLs will get autoescaped. """ trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x safe_input = isinstance(text, SafeData) words = word_split_re.split(force_unicode(text)) for i, word in enumerate(words): match = None if '.' in word or '@' in word or ':' in word: # Deal with punctuation. lead, middle, trail = '', word, '' for punctuation in TRAILING_PUNCTUATION: if middle.endswith(punctuation): middle = middle[:-len(punctuation)] trail = punctuation + trail for opening, closing in WRAPPING_PUNCTUATION: if middle.startswith(opening): middle = middle[len(opening):] lead = lead + opening # Keep parentheses at the end only if they're balanced. if (middle.endswith(closing) and middle.count(closing) == middle.count(opening) + 1): middle = middle[:-len(closing)] trail = closing + trail # Make URL we want to point to. url = None nofollow_attr = ' rel="nofollow"' if nofollow else '' if simple_url_re.match(middle): url = smart_urlquote(middle) elif simple_url_2_re.match(middle): url = smart_urlquote('http://%s' % middle) elif not ':' in middle and simple_email_re.match(middle): local, domain = middle.rsplit('@', 1) try: domain = domain.encode('idna') except UnicodeError: continue url = 'mailto:%s@%s' % (local, domain) nofollow_attr = '' # Make link. if url: trimmed = trim_url(middle) if autoescape and not safe_input: lead, trail = escape(lead), escape(trail) url, trimmed = escape(url), escape(trimmed) middle = '<a href="%s"%s>%s</a>' % (url, nofollow_attr, trimmed) words[i] = mark_safe('%s%s%s' % (lead, middle, trail)) else: if safe_input: words[i] = mark_safe(word) elif autoescape: words[i] = escape(word) elif safe_input: words[i] = mark_safe(word) elif autoescape: words[i] = escape(word) return u''.join(words) urlize = allow_lazy(urlize, unicode) def clean_html(text): """ Clean the given HTML. Specifically, do the following: * Convert <b> and <i> to <strong> and <em>. * Encode all ampersands correctly. * Remove all "target" attributes from <a> tags. * Remove extraneous HTML, such as presentational tags that open and immediately close and <br clear="all">. * Convert hard-coded bullets into HTML unordered lists. * Remove stuff like "<p>&nbsp;&nbsp;</p>", but only if it's at the bottom of the text. """ from django.utils.text import normalize_newlines text = normalize_newlines(force_unicode(text)) text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text) text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text) text = fix_ampersands(text) # Remove all target="" attributes from <a> tags. text = link_target_attribute_re.sub('\\1', text) # Trim stupid HTML such as <br clear="all">. text = html_gunk_re.sub('', text) # Convert hard-coded bullets into HTML unordered lists. def replace_p_tags(match): s = match.group().replace(u'</p>', u'</li>') for d in DOTS: s = s.replace(u'<p>%s' % d, u'<li>') return u'<ul>\n%s\n</ul>' % s text = hard_coded_bullets_re.sub(replace_p_tags, text) # Remove stuff like "<p>&nbsp;&nbsp;</p>", but only if it's at the bottom # of the text. text = trailing_empty_content_re.sub(u'', text) return text clean_html = allow_lazy(clean_html, unicode)
mit
[ 624, 4943, 15841, 11233, 367, 2288, 675, 1041, 199, 199, 646, 295, 199, 646, 1059, 199, 646, 4011, 199, 646, 7097, 199, 199, 504, 1639, 14, 1208, 14, 28389, 492, 14969, 1451, 12, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 12, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 15481, 492, 2040, 63, 6395, 199, 504, 1639, 14, 1208, 14, 505, 492, 7666, 63, 13839, 199, 199, 3, 11595, 367, 7629, 13559, 342, 805, 14, 199, 1766, 6593, 1206, 63, 48, 1734, 1028, 53, 2594, 275, 788, 3130, 30048, 25475, 14289, 418, 199, 6524, 7121, 1206, 63, 48, 1734, 1028, 53, 2594, 275, 4274, 5102, 5320, 659, 19990, 297, 12696, 659, 661, 6, 4116, 10805, 7673, 3308, 27, 5440, 199, 199, 3, 3820, 402, 3962, 3326, 1202, 367, 330, 348, 16537, 315, 330, 348, 3496, 5548, 14, 199, 13203, 51, 275, 359, 85, 21840, 8523, 3287, 10805, 399, 7, 7693, 399, 1154, 85, 13859, 297, 399, 7, 7997, 10721, 10805, 399, 21840, 66, 979, 10805, 399, 7, 7997, 10228, 22, 27, 418, 199, 199, 324, 8167, 63, 5282, 1192, 5915, 63, 264, 275, 295, 14, 2014, 8, 82, 21840, 26313, 2961, 87, 21449, 20262, 68, 11, 2736, 5942, 199, 324, 9888, 63, 7045, 83, 63, 264, 275, 295, 14, 2014, 8, 82, 5956, 2229, 21282, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 18, 1552, 358, 199, 1027, 63, 1294, 63, 264, 275, 295, 14, 2014, 8, 82, 13445, 83, 11, 5942, 199, 4129, 63, 633, 63, 264, 275, 295, 14, 2014, 8, 82, 4289, 2859, 14144, 60, 87, 358, 199, 4129, 63, 633, 63, 18, 63, 264, 275, 295, 14, 2014, 8, 82, 4289, 1544, 32327, 62, 26313, 1014, 2862, 87, 4735, 32, 2807, 4537, 8, 957, 92, 8654, 92, 16294, 92, 442, 92, 77, 382, 92, 846, 92, 1308, 9, 9988, 199, 4129, 63, 2123, 63, 264, 275, 295, 14, 2014, 8, 82, 15542, 51, 11, 32, 60, 51, 23294, 51, 11, 9988, 199, 1073, 63, 1375, 63, 3215, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 28, 65, 359, 62, 30, 3672, 17076, 1375, 1524, 12773, 83, 30, 2807, 358, 199, 1360, 63, 71, 1778, 63, 264, 275, 295, 14, 2014, 8, 82, 20459, 28, 3289, 5436, 628, 452, 1743, 92, 28, 73, 2535, 19814, 73, 21521, 28, 66, 2535, 19814, 66, 21521, 28, 5633, 2535, 19814, 5633, 21521, 28, 9370, 2535, 19814, 9370, 21521, 31873, 10197, 7241, 12029, 21521, 31873, 10197, 26831, 30, 3196, 295, 14, 15434, 9, 199, 8726, 63, 15282, 63, 25792, 16537, 63, 264, 275, 295, 14, 2014, 8, 82, 7, 17304, 16875, 80, 30, 2229, 2689, 83, 680, 15279, 59, 65, 13, 6353, 13, 58, 1055, 15279, 1108, 80, 3072, 83, 10, 6393, 3171, 450, 21590, 904, 779, 264, 14, 3765, 8, 88, 9, 367, 671, 315, 15854, 51, 2522, 295, 14, 16504, 9, 199, 15910, 63, 1667, 63, 1317, 63, 264, 275, 295, 14, 2014, 8, 82, 20459, 28, 80, 30, 5169, 6, 10758, 27, 6113, 83, 92, 28, 3289, 971, 3133, 3342, 31, 1108, 80, 3072, 83, 10, 6393, 60, 58, 358, 199, 2264, 671, 327, 21791, 1750, 199, 199, 318, 4772, 8, 1360, 304, 272, 408, 272, 1803, 314, 1627, 4163, 543, 15204, 1192, 5915, 12, 9344, 436, 9324, 21873, 5737, 14, 272, 408, 272, 372, 2216, 63, 3489, 8, 3990, 63, 2975, 8, 1360, 680, 1814, 360, 16749, 7673, 5282, 27, 1959, 1814, 4827, 297, 7673, 4116, 27, 1959, 1814, 360, 4206, 7673, 3308, 27, 1959, 1814, 20630, 7673, 5184, 27, 1959, 1814, 27769, 7673, 3, 1355, 27, 1333, 199, 3765, 275, 2040, 63, 6395, 8, 3765, 12, 2649, 9, 199, 199, 63, 1095, 63, 3596, 63, 3765, 83, 275, 334, 272, 661, 1103, 297, 519, 1154, 85, 7972, 35, 659, 272, 661, 3985, 297, 519, 1154, 85, 28355, 659, 272, 661, 6949, 519, 1154, 85, 27846, 659, 272, 661, 4206, 519, 1154, 85, 8262, 37, 659, 272, 19990, 297, 519, 1154, 85, 8262, 35, 659, 272, 661, 16749, 519, 1154, 85, 28193, 659, 272, 661, 4009, 519, 1154, 85, 8262, 36, 659, 272, 12291, 297, 519, 1154, 85, 7432, 36, 659, 272, 661, 10805, 519, 1154, 85, 8262, 34, 659, 272, 334, 85, 1154, 85, 25247, 297, 519, 1154, 85, 25247, 659, 272, 334, 85, 1154, 85, 25078, 297, 519, 1154, 85, 25078, 358, 199, 9, 199, 199, 3, 21067, 4036, 10485, 4528, 543, 282, 574, 6656, 2419, 4337, 14, 199, 63, 3596, 63, 3765, 83, 275, 6110, 1095, 63, 3596, 63, 3765, 83, 435, 2049, 2008, 779, 3508, 67, 7, 450, 1315, 12, 6468, 85, 5, 966, 56, 7, 450, 1315, 9, 367, 1315, 315, 1425, 8, 708, 19563, 199, 199, 318, 4772, 3596, 8, 585, 304, 272, 408, 10373, 3752, 83, 4110, 367, 675, 315, 15250, 3326, 1041, 272, 367, 4875, 12, 6954, 315, 485, 3596, 63, 3765, 83, 26, 267, 574, 275, 2216, 63, 3489, 8, 3990, 63, 2975, 8, 585, 680, 1814, 8, 4087, 12, 6954, 430, 272, 372, 574, 199, 3765, 3596, 275, 2040, 63, 6395, 8, 3765, 3596, 12, 2649, 9, 199, 199, 318, 12303, 63, 3765, 8, 1360, 304, 272, 408, 272, 20046, 370, 4772, 1062, 871, 626, 652, 3181, 1133, 19218, 641, 876, 13, 13572, 3326, 14, 272, 408, 272, 340, 1228, 8, 1360, 12, 14969, 1451, 304, 267, 372, 3517, 272, 587, 26, 267, 372, 4772, 8, 1360, 9, 199, 199, 318, 1004, 18566, 8, 585, 12, 19102, 29, 797, 304, 272, 408, 17729, 14930, 1901, 665, 80, 30, 436, 665, 3289, 7082, 83, 1041, 272, 574, 275, 7666, 63, 13839, 8, 585, 9, 272, 623, 305, 275, 295, 14, 1294, 2258, 78, 91, 18, 12, 7293, 574, 9, 272, 340, 19102, 26, 267, 623, 305, 275, 359, 85, 7601, 80, 6598, 83, 1108, 80, 3524, 450, 4772, 8, 80, 680, 1814, 2258, 78, 297, 2650, 3289, 23266, 367, 299, 315, 623, 305, 61, 272, 587, 26, 267, 623, 305, 275, 359, 85, 7601, 80, 6598, 83, 1108, 80, 3524, 450, 299, 14, 1814, 2258, 78, 297, 2650, 3289, 23266, 367, 299, 315, 623, 305, 61, 272, 372, 399, 1154, 78, 60 ]
[ 4943, 15841, 11233, 367, 2288, 675, 1041, 199, 199, 646, 295, 199, 646, 1059, 199, 646, 4011, 199, 646, 7097, 199, 199, 504, 1639, 14, 1208, 14, 28389, 492, 14969, 1451, 12, 2216, 63, 3489, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 12, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 15481, 492, 2040, 63, 6395, 199, 504, 1639, 14, 1208, 14, 505, 492, 7666, 63, 13839, 199, 199, 3, 11595, 367, 7629, 13559, 342, 805, 14, 199, 1766, 6593, 1206, 63, 48, 1734, 1028, 53, 2594, 275, 788, 3130, 30048, 25475, 14289, 418, 199, 6524, 7121, 1206, 63, 48, 1734, 1028, 53, 2594, 275, 4274, 5102, 5320, 659, 19990, 297, 12696, 659, 661, 6, 4116, 10805, 7673, 3308, 27, 5440, 199, 199, 3, 3820, 402, 3962, 3326, 1202, 367, 330, 348, 16537, 315, 330, 348, 3496, 5548, 14, 199, 13203, 51, 275, 359, 85, 21840, 8523, 3287, 10805, 399, 7, 7693, 399, 1154, 85, 13859, 297, 399, 7, 7997, 10721, 10805, 399, 21840, 66, 979, 10805, 399, 7, 7997, 10228, 22, 27, 418, 199, 199, 324, 8167, 63, 5282, 1192, 5915, 63, 264, 275, 295, 14, 2014, 8, 82, 21840, 26313, 2961, 87, 21449, 20262, 68, 11, 2736, 5942, 199, 324, 9888, 63, 7045, 83, 63, 264, 275, 295, 14, 2014, 8, 82, 5956, 2229, 21282, 16, 13, 25, 33, 13, 1906, 13, 70, 8194, 18, 1552, 358, 199, 1027, 63, 1294, 63, 264, 275, 295, 14, 2014, 8, 82, 13445, 83, 11, 5942, 199, 4129, 63, 633, 63, 264, 275, 295, 14, 2014, 8, 82, 4289, 2859, 14144, 60, 87, 358, 199, 4129, 63, 633, 63, 18, 63, 264, 275, 295, 14, 2014, 8, 82, 4289, 1544, 32327, 62, 26313, 1014, 2862, 87, 4735, 32, 2807, 4537, 8, 957, 92, 8654, 92, 16294, 92, 442, 92, 77, 382, 92, 846, 92, 1308, 9, 9988, 199, 4129, 63, 2123, 63, 264, 275, 295, 14, 2014, 8, 82, 15542, 51, 11, 32, 60, 51, 23294, 51, 11, 9988, 199, 1073, 63, 1375, 63, 3215, 63, 264, 275, 295, 14, 2014, 8, 82, 6774, 28, 65, 359, 62, 30, 3672, 17076, 1375, 1524, 12773, 83, 30, 2807, 358, 199, 1360, 63, 71, 1778, 63, 264, 275, 295, 14, 2014, 8, 82, 20459, 28, 3289, 5436, 628, 452, 1743, 92, 28, 73, 2535, 19814, 73, 21521, 28, 66, 2535, 19814, 66, 21521, 28, 5633, 2535, 19814, 5633, 21521, 28, 9370, 2535, 19814, 9370, 21521, 31873, 10197, 7241, 12029, 21521, 31873, 10197, 26831, 30, 3196, 295, 14, 15434, 9, 199, 8726, 63, 15282, 63, 25792, 16537, 63, 264, 275, 295, 14, 2014, 8, 82, 7, 17304, 16875, 80, 30, 2229, 2689, 83, 680, 15279, 59, 65, 13, 6353, 13, 58, 1055, 15279, 1108, 80, 3072, 83, 10, 6393, 3171, 450, 21590, 904, 779, 264, 14, 3765, 8, 88, 9, 367, 671, 315, 15854, 51, 2522, 295, 14, 16504, 9, 199, 15910, 63, 1667, 63, 1317, 63, 264, 275, 295, 14, 2014, 8, 82, 20459, 28, 80, 30, 5169, 6, 10758, 27, 6113, 83, 92, 28, 3289, 971, 3133, 3342, 31, 1108, 80, 3072, 83, 10, 6393, 60, 58, 358, 199, 2264, 671, 327, 21791, 1750, 199, 199, 318, 4772, 8, 1360, 304, 272, 408, 272, 1803, 314, 1627, 4163, 543, 15204, 1192, 5915, 12, 9344, 436, 9324, 21873, 5737, 14, 272, 408, 272, 372, 2216, 63, 3489, 8, 3990, 63, 2975, 8, 1360, 680, 1814, 360, 16749, 7673, 5282, 27, 1959, 1814, 4827, 297, 7673, 4116, 27, 1959, 1814, 360, 4206, 7673, 3308, 27, 1959, 1814, 20630, 7673, 5184, 27, 1959, 1814, 27769, 7673, 3, 1355, 27, 1333, 199, 3765, 275, 2040, 63, 6395, 8, 3765, 12, 2649, 9, 199, 199, 63, 1095, 63, 3596, 63, 3765, 83, 275, 334, 272, 661, 1103, 297, 519, 1154, 85, 7972, 35, 659, 272, 661, 3985, 297, 519, 1154, 85, 28355, 659, 272, 661, 6949, 519, 1154, 85, 27846, 659, 272, 661, 4206, 519, 1154, 85, 8262, 37, 659, 272, 19990, 297, 519, 1154, 85, 8262, 35, 659, 272, 661, 16749, 519, 1154, 85, 28193, 659, 272, 661, 4009, 519, 1154, 85, 8262, 36, 659, 272, 12291, 297, 519, 1154, 85, 7432, 36, 659, 272, 661, 10805, 519, 1154, 85, 8262, 34, 659, 272, 334, 85, 1154, 85, 25247, 297, 519, 1154, 85, 25247, 659, 272, 334, 85, 1154, 85, 25078, 297, 519, 1154, 85, 25078, 358, 199, 9, 199, 199, 3, 21067, 4036, 10485, 4528, 543, 282, 574, 6656, 2419, 4337, 14, 199, 63, 3596, 63, 3765, 83, 275, 6110, 1095, 63, 3596, 63, 3765, 83, 435, 2049, 2008, 779, 3508, 67, 7, 450, 1315, 12, 6468, 85, 5, 966, 56, 7, 450, 1315, 9, 367, 1315, 315, 1425, 8, 708, 19563, 199, 199, 318, 4772, 3596, 8, 585, 304, 272, 408, 10373, 3752, 83, 4110, 367, 675, 315, 15250, 3326, 1041, 272, 367, 4875, 12, 6954, 315, 485, 3596, 63, 3765, 83, 26, 267, 574, 275, 2216, 63, 3489, 8, 3990, 63, 2975, 8, 585, 680, 1814, 8, 4087, 12, 6954, 430, 272, 372, 574, 199, 3765, 3596, 275, 2040, 63, 6395, 8, 3765, 3596, 12, 2649, 9, 199, 199, 318, 12303, 63, 3765, 8, 1360, 304, 272, 408, 272, 20046, 370, 4772, 1062, 871, 626, 652, 3181, 1133, 19218, 641, 876, 13, 13572, 3326, 14, 272, 408, 272, 340, 1228, 8, 1360, 12, 14969, 1451, 304, 267, 372, 3517, 272, 587, 26, 267, 372, 4772, 8, 1360, 9, 199, 199, 318, 1004, 18566, 8, 585, 12, 19102, 29, 797, 304, 272, 408, 17729, 14930, 1901, 665, 80, 30, 436, 665, 3289, 7082, 83, 1041, 272, 574, 275, 7666, 63, 13839, 8, 585, 9, 272, 623, 305, 275, 295, 14, 1294, 2258, 78, 91, 18, 12, 7293, 574, 9, 272, 340, 19102, 26, 267, 623, 305, 275, 359, 85, 7601, 80, 6598, 83, 1108, 80, 3524, 450, 4772, 8, 80, 680, 1814, 2258, 78, 297, 2650, 3289, 23266, 367, 299, 315, 623, 305, 61, 272, 587, 26, 267, 623, 305, 275, 359, 85, 7601, 80, 6598, 83, 1108, 80, 3524, 450, 299, 14, 1814, 2258, 78, 297, 2650, 3289, 23266, 367, 299, 315, 623, 305, 61, 272, 372, 399, 1154, 78, 60, 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,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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 ]
bottompawn/kbengine
kbe/src/lib/python/Tools/scripts/fixcid.py
47
9989
#! /usr/bin/env python3 # Perform massive identifier substitution on C source files. # This actually tokenizes the files (to some extent) so it can # avoid making substitutions inside strings or comments. # Inside strings, substitutions are never made; inside comments, # it is a user option (off by default). # # The substitutions are read from one or more files whose lines, # when not empty, after stripping comments starting with #, # must contain exactly two words separated by whitespace: the # old identifier and its replacement. # # The option -r reverses the sense of the substitutions (this may be # useful to undo a particular substitution). # # If the old identifier is prefixed with a '*' (with no intervening # whitespace), then it will not be substituted inside comments. # # Command line arguments are files or directories to be processed. # Directories are searched recursively for files whose name looks # like a C file (ends in .h or .c). The special filename '-' means # operate in filter mode: read stdin, write stdout. # # Symbolic links are always ignored (except as explicit directory # arguments). # # The original files are kept as back-up with a "~" suffix. # # Changes made are reported to stdout in a diff-like format. # # NB: by changing only the function fixline() you can turn this # into a program for different changes to C source files; by # changing the function wanted() you can make a different selection of # files. import sys import re import os from stat import * import getopt err = sys.stderr.write dbg = err rep = sys.stdout.write def usage(): progname = sys.argv[0] err('Usage: ' + progname + ' [-c] [-r] [-s file] ... file-or-directory ...\n') err('\n') err('-c : substitute inside comments\n') err('-r : reverse direction for following -s options\n') err('-s substfile : add a file of substitutions\n') err('\n') err('Each non-empty non-comment line in a substitution file must\n') err('contain exactly two words: an identifier and its replacement.\n') err('Comments start with a # character and end at end of line.\n') err('If an identifier is preceded with a *, it is not substituted\n') err('inside a comment even when -c is specified.\n') def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'crs:') except getopt.error as msg: err('Options error: ' + str(msg) + '\n') usage() sys.exit(2) bad = 0 if not args: # No arguments usage() sys.exit(2) for opt, arg in opts: if opt == '-c': setdocomments() if opt == '-r': setreverse() if opt == '-s': addsubst(arg) for arg in args: if os.path.isdir(arg): if recursedown(arg): bad = 1 elif os.path.islink(arg): err(arg + ': will not process symbolic links\n') bad = 1 else: if fix(arg): bad = 1 sys.exit(bad) # Change this regular expression to select a different set of files Wanted = '^[a-zA-Z0-9_]+\.[ch]$' def wanted(name): return re.match(Wanted, name) >= 0 def recursedown(dirname): dbg('recursedown(%r)\n' % (dirname,)) bad = 0 try: names = os.listdir(dirname) except OSError as msg: err(dirname + ': cannot list directory: ' + str(msg) + '\n') return 1 names.sort() subdirs = [] for name in names: if name in (os.curdir, os.pardir): continue fullname = os.path.join(dirname, name) if os.path.islink(fullname): pass elif os.path.isdir(fullname): subdirs.append(fullname) elif wanted(name): if fix(fullname): bad = 1 for fullname in subdirs: if recursedown(fullname): bad = 1 return bad def fix(filename): ## dbg('fix(%r)\n' % (filename,)) if filename == '-': # Filter mode f = sys.stdin g = sys.stdout else: # File replacement mode try: f = open(filename, 'r') except IOError as msg: err(filename + ': cannot open: ' + str(msg) + '\n') return 1 head, tail = os.path.split(filename) tempname = os.path.join(head, '@' + tail) g = None # If we find a match, we rewind the file and start over but # now copy everything to a temp file. lineno = 0 initfixline() while 1: line = f.readline() if not line: break lineno = lineno + 1 while line[-2:] == '\\\n': nextline = f.readline() if not nextline: break line = line + nextline lineno = lineno + 1 newline = fixline(line) if newline != line: if g is None: try: g = open(tempname, 'w') except IOError as msg: f.close() err(tempname+': cannot create: '+ str(msg)+'\n') return 1 f.seek(0) lineno = 0 initfixline() rep(filename + ':\n') continue # restart from the beginning rep(repr(lineno) + '\n') rep('< ' + line) rep('> ' + newline) if g is not None: g.write(newline) # End of file if filename == '-': return 0 # Done in filter mode f.close() if not g: return 0 # No changes # Finishing touch -- move files # First copy the file's mode to the temp file try: statbuf = os.stat(filename) os.chmod(tempname, statbuf[ST_MODE] & 0o7777) except OSError as msg: err(tempname + ': warning: chmod failed (' + str(msg) + ')\n') # Then make a backup of the original file as filename~ try: os.rename(filename, filename + '~') except OSError as msg: err(filename + ': warning: backup failed (' + str(msg) + ')\n') # Now move the temp file to the original file try: os.rename(tempname, filename) except OSError as msg: err(filename + ': rename failed (' + str(msg) + ')\n') return 1 # Return success return 0 # Tokenizing ANSI C (partly) Identifier = '\(struct \)?[a-zA-Z_][a-zA-Z0-9_]+' String = '"\([^\n\\"]\|\\\\.\)*"' Char = '\'\([^\n\\\']\|\\\\.\)*\'' CommentStart = '/\*' CommentEnd = '\*/' Hexnumber = '0[xX][0-9a-fA-F]*[uUlL]*' Octnumber = '0[0-7]*[uUlL]*' Decnumber = '[1-9][0-9]*[uUlL]*' Intnumber = Hexnumber + '\|' + Octnumber + '\|' + Decnumber Exponent = '[eE][-+]?[0-9]+' Pointfloat = '\([0-9]+\.[0-9]*\|\.[0-9]+\)\(' + Exponent + '\)?' Expfloat = '[0-9]+' + Exponent Floatnumber = Pointfloat + '\|' + Expfloat Number = Floatnumber + '\|' + Intnumber # Anything else is an operator -- don't list this explicitly because of '/*' OutsideComment = (Identifier, Number, String, Char, CommentStart) OutsideCommentPattern = '(' + '|'.join(OutsideComment) + ')' OutsideCommentProgram = re.compile(OutsideCommentPattern) InsideComment = (Identifier, Number, CommentEnd) InsideCommentPattern = '(' + '|'.join(InsideComment) + ')' InsideCommentProgram = re.compile(InsideCommentPattern) def initfixline(): global Program Program = OutsideCommentProgram def fixline(line): global Program ## print '-->', repr(line) i = 0 while i < len(line): i = Program.search(line, i) if i < 0: break found = Program.group(0) ## if Program is InsideCommentProgram: print '...', ## else: print ' ', ## print found if len(found) == 2: if found == '/*': Program = InsideCommentProgram elif found == '*/': Program = OutsideCommentProgram n = len(found) if found in Dict: subst = Dict[found] if Program is InsideCommentProgram: if not Docomments: print('Found in comment:', found) i = i + n continue if NotInComment.has_key(found): ## print 'Ignored in comment:', ## print found, '-->', subst ## print 'Line:', line, subst = found ## else: ## print 'Substituting in comment:', ## print found, '-->', subst ## print 'Line:', line, line = line[:i] + subst + line[i+n:] n = len(subst) i = i + n return line Docomments = 0 def setdocomments(): global Docomments Docomments = 1 Reverse = 0 def setreverse(): global Reverse Reverse = (not Reverse) Dict = {} NotInComment = {} def addsubst(substfile): try: fp = open(substfile, 'r') except IOError as msg: err(substfile + ': cannot read substfile: ' + str(msg) + '\n') sys.exit(1) lineno = 0 while 1: line = fp.readline() if not line: break lineno = lineno + 1 try: i = line.index('#') except ValueError: i = -1 # Happens to delete trailing \n words = line[:i].split() if not words: continue if len(words) == 3 and words[0] == 'struct': words[:2] = [words[0] + ' ' + words[1]] elif len(words) != 2: err(substfile + '%s:%r: warning: bad line: %r' % (substfile, lineno, line)) continue if Reverse: [value, key] = words else: [key, value] = words if value[0] == '*': value = value[1:] if key[0] == '*': key = key[1:] NotInComment[key] = value if key in Dict: err('%s:%r: warning: overriding: %r %r\n' % (substfile, lineno, key, value)) err('%s:%r: warning: previous: %r\n' % (substfile, lineno, Dict[key])) Dict[key] = value fp.close() if __name__ == '__main__': main()
lgpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 14795, 333, 13202, 5148, 20584, 641, 445, 1350, 1584, 14, 199, 3, 961, 5965, 1526, 6491, 314, 1584, 334, 475, 2005, 13675, 9, 880, 652, 883, 199, 3, 5126, 10663, 20873, 6272, 3326, 503, 6786, 14, 199, 3, 1010, 2441, 3326, 12, 20873, 787, 7078, 6326, 27, 6272, 6786, 12, 199, 3, 652, 365, 282, 922, 945, 334, 1997, 701, 849, 680, 199, 3, 199, 3, 710, 20873, 787, 1586, 687, 1373, 503, 1655, 1584, 7447, 2385, 12, 199, 3, 1380, 440, 2701, 12, 2410, 4024, 3637, 6786, 6617, 543, 327, 12, 199, 3, 1471, 1395, 8840, 2877, 5932, 11673, 701, 8139, 26, 314, 199, 3, 2269, 5148, 436, 2399, 8343, 14, 199, 3, 199, 3, 710, 945, 446, 82, 29465, 874, 314, 12249, 402, 314, 20873, 334, 3749, 1443, 506, 199, 3, 2997, 370, 18172, 282, 6770, 20584, 680, 199, 3, 199, 3, 982, 314, 2269, 5148, 365, 18239, 543, 282, 13626, 334, 1045, 949, 1640, 1856, 316, 199, 3, 8139, 395, 2066, 652, 911, 440, 506, 10004, 4241, 6272, 6786, 14, 199, 3, 199, 3, 5817, 1004, 2368, 787, 1584, 503, 6602, 370, 506, 7686, 14, 199, 3, 25596, 4253, 787, 17543, 15035, 367, 1584, 7447, 536, 10734, 199, 3, 2839, 282, 445, 570, 334, 3198, 315, 1275, 72, 503, 1275, 67, 680, 221, 710, 4539, 1788, 10791, 4910, 199, 3, 19218, 315, 2457, 818, 26, 1586, 9009, 12, 2218, 3839, 14, 199, 3, 199, 3, 21478, 9670, 6220, 787, 3544, 5525, 334, 2590, 465, 5027, 2082, 199, 3, 2368, 680, 199, 3, 199, 3, 710, 3379, 1584, 787, 16204, 465, 1771, 13, 384, 543, 282, 26810, 2, 4739, 14, 199, 3, 199, 3, 18784, 6326, 787, 14581, 370, 3839, 315, 282, 3915, 13, 2930, 1475, 14, 199, 3, 199, 3, 25377, 26, 701, 13729, 1454, 314, 805, 5325, 604, 342, 1265, 883, 7485, 642, 199, 3, 1901, 282, 2240, 367, 3365, 4493, 370, 445, 1350, 1584, 27, 701, 199, 3, 13729, 314, 805, 13632, 342, 1265, 883, 1852, 282, 3365, 7267, 402, 199, 3, 1584, 14, 199, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 504, 5672, 492, 627, 199, 646, 12733, 199, 199, 1508, 275, 984, 14, 3083, 14, 952, 199, 16310, 275, 2329, 199, 1155, 275, 984, 14, 2703, 14, 952, 199, 199, 318, 4503, 837, 272, 13205, 354, 275, 984, 14, 3020, 59, 16, 61, 272, 2329, 360, 7692, 26, 283, 435, 13205, 354, 435, 1598, 283, 5243, 67, 61, 5243, 82, 61, 5243, 83, 570, 61, 2263, 570, 13, 269, 13, 3619, 2263, 60, 78, 358, 272, 2329, 2258, 78, 358, 272, 2329, 3654, 67, 3698, 520, 23080, 6272, 6786, 60, 78, 358, 272, 2329, 3654, 82, 3698, 520, 3837, 7581, 367, 2569, 446, 83, 1511, 60, 78, 358, 272, 2329, 3654, 83, 27321, 493, 520, 1050, 282, 570, 402, 20873, 60, 78, 358, 272, 2329, 2258, 78, 358, 272, 2329, 360, 22321, 2222, 13, 1667, 2222, 13, 3349, 1004, 315, 282, 20584, 570, 1471, 60, 78, 358, 272, 2329, 360, 7747, 8840, 2877, 5932, 26, 376, 5148, 436, 2399, 8343, 3134, 78, 358, 272, 2329, 360, 18929, 1343, 543, 282, 327, 4528, 436, 1284, 737, 1284, 402, 1004, 3134, 78, 358, 272, 2329, 360, 3917, 376, 5148, 365, 9222, 770, 543, 282, 9889, 652, 365, 440, 10004, 4241, 60, 78, 358, 272, 2329, 360, 17183, 282, 3721, 2755, 1380, 446, 67, 365, 2013, 3134, 78, 358, 199, 199, 318, 2446, 837, 272, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 19034, 10993, 272, 871, 12733, 14, 705, 465, 1499, 26, 267, 2329, 360, 4558, 1125, 26, 283, 435, 620, 8, 1328, 9, 435, 1557, 78, 358, 267, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 272, 4875, 275, 378, 272, 340, 440, 1249, 26, 327, 3091, 2368, 267, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 272, 367, 2450, 12, 1680, 315, 3999, 26, 267, 340, 2450, 508, 2475, 67, 356, 288, 663, 1117, 6223, 342, 267, 340, 2450, 508, 2475, 82, 356, 288, 663, 4471, 342, 267, 340, 2450, 508, 2475, 83, 356, 288, 1050, 16747, 8, 1273, 9, 272, 367, 1680, 315, 1249, 26, 267, 340, 747, 14, 515, 14, 6027, 8, 1273, 304, 288, 340, 5344, 939, 944, 8, 1273, 304, 4875, 275, 413, 267, 916, 747, 14, 515, 14, 20719, 8, 1273, 304, 288, 2329, 8, 1273, 435, 7596, 911, 440, 2112, 13673, 6220, 60, 78, 358, 288, 4875, 275, 413, 267, 587, 26, 288, 340, 5325, 8, 1273, 304, 4875, 275, 413, 272, 984, 14, 2224, 8, 4087, 9, 199, 199, 3, 7743, 642, 5578, 3965, 370, 3504, 282, 3365, 663, 402, 1584, 199, 55, 10221, 275, 14452, 59, 65, 13, 6353, 13, 58, 16, 13, 25, 22155, 27658, 335, 61, 12913, 199, 318, 13632, 8, 354, 304, 272, 372, 295, 14, 1431, 8, 55, 10221, 12, 536, 9, 2356, 378, 199, 199, 318, 5344, 939, 944, 8, 3475, 304, 272, 24465, 360, 6794, 939, 944, 4042, 82, 2862, 78, 7, 450, 334, 3475, 4641, 272, 4875, 275, 378, 272, 862, 26, 267, 1561, 275, 747, 14, 7374, 8, 3475, 9, 272, 871, 6440, 465, 1499, 26, 267, 2329, 8, 3475, 435, 7596, 3913, 769, 2082, 26, 283, 435, 620, 8, 1328, 9, 435, 1557, 78, 358, 267, 372, 413, 272, 1561, 14, 3191, 342, 272, 31396, 275, 942, 272, 367, 536, 315, 1561, 26, 267, 340, 536, 315, 334, 736, 14, 15594, 12, 747, 14, 21386, 304, 1980, 267, 11064, 275, 747, 14, 515, 14, 904, 8, 3475, 12, 536, 9, 267, 340, 747, 14, 515, 14, 20719, 8, 9930, 304, 986, 267, 916, 747, 14, 515, 14, 6027, 8, 9930, 304, 288, 31396, 14, 740, 8, 9930, 9, 267, 916, 13632, 8, 354, 304, 288, 340, 5325, 8, 9930, 304, 4875, 275, 413, 272, 367, 11064, 315, 31396, 26, 267, 340, 5344, 939, 944, 8, 9930, 304, 4875, 275, 413, 272, 372, 4875, 199, 199, 318, 5325, 8, 1501, 304, 199, 309, 221, 24465, 360, 970, 4042, 82, 2862, 78, 7, 450, 334 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 14795, 333, 13202, 5148, 20584, 641, 445, 1350, 1584, 14, 199, 3, 961, 5965, 1526, 6491, 314, 1584, 334, 475, 2005, 13675, 9, 880, 652, 883, 199, 3, 5126, 10663, 20873, 6272, 3326, 503, 6786, 14, 199, 3, 1010, 2441, 3326, 12, 20873, 787, 7078, 6326, 27, 6272, 6786, 12, 199, 3, 652, 365, 282, 922, 945, 334, 1997, 701, 849, 680, 199, 3, 199, 3, 710, 20873, 787, 1586, 687, 1373, 503, 1655, 1584, 7447, 2385, 12, 199, 3, 1380, 440, 2701, 12, 2410, 4024, 3637, 6786, 6617, 543, 327, 12, 199, 3, 1471, 1395, 8840, 2877, 5932, 11673, 701, 8139, 26, 314, 199, 3, 2269, 5148, 436, 2399, 8343, 14, 199, 3, 199, 3, 710, 945, 446, 82, 29465, 874, 314, 12249, 402, 314, 20873, 334, 3749, 1443, 506, 199, 3, 2997, 370, 18172, 282, 6770, 20584, 680, 199, 3, 199, 3, 982, 314, 2269, 5148, 365, 18239, 543, 282, 13626, 334, 1045, 949, 1640, 1856, 316, 199, 3, 8139, 395, 2066, 652, 911, 440, 506, 10004, 4241, 6272, 6786, 14, 199, 3, 199, 3, 5817, 1004, 2368, 787, 1584, 503, 6602, 370, 506, 7686, 14, 199, 3, 25596, 4253, 787, 17543, 15035, 367, 1584, 7447, 536, 10734, 199, 3, 2839, 282, 445, 570, 334, 3198, 315, 1275, 72, 503, 1275, 67, 680, 221, 710, 4539, 1788, 10791, 4910, 199, 3, 19218, 315, 2457, 818, 26, 1586, 9009, 12, 2218, 3839, 14, 199, 3, 199, 3, 21478, 9670, 6220, 787, 3544, 5525, 334, 2590, 465, 5027, 2082, 199, 3, 2368, 680, 199, 3, 199, 3, 710, 3379, 1584, 787, 16204, 465, 1771, 13, 384, 543, 282, 26810, 2, 4739, 14, 199, 3, 199, 3, 18784, 6326, 787, 14581, 370, 3839, 315, 282, 3915, 13, 2930, 1475, 14, 199, 3, 199, 3, 25377, 26, 701, 13729, 1454, 314, 805, 5325, 604, 342, 1265, 883, 7485, 642, 199, 3, 1901, 282, 2240, 367, 3365, 4493, 370, 445, 1350, 1584, 27, 701, 199, 3, 13729, 314, 805, 13632, 342, 1265, 883, 1852, 282, 3365, 7267, 402, 199, 3, 1584, 14, 199, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 504, 5672, 492, 627, 199, 646, 12733, 199, 199, 1508, 275, 984, 14, 3083, 14, 952, 199, 16310, 275, 2329, 199, 1155, 275, 984, 14, 2703, 14, 952, 199, 199, 318, 4503, 837, 272, 13205, 354, 275, 984, 14, 3020, 59, 16, 61, 272, 2329, 360, 7692, 26, 283, 435, 13205, 354, 435, 1598, 283, 5243, 67, 61, 5243, 82, 61, 5243, 83, 570, 61, 2263, 570, 13, 269, 13, 3619, 2263, 60, 78, 358, 272, 2329, 2258, 78, 358, 272, 2329, 3654, 67, 3698, 520, 23080, 6272, 6786, 60, 78, 358, 272, 2329, 3654, 82, 3698, 520, 3837, 7581, 367, 2569, 446, 83, 1511, 60, 78, 358, 272, 2329, 3654, 83, 27321, 493, 520, 1050, 282, 570, 402, 20873, 60, 78, 358, 272, 2329, 2258, 78, 358, 272, 2329, 360, 22321, 2222, 13, 1667, 2222, 13, 3349, 1004, 315, 282, 20584, 570, 1471, 60, 78, 358, 272, 2329, 360, 7747, 8840, 2877, 5932, 26, 376, 5148, 436, 2399, 8343, 3134, 78, 358, 272, 2329, 360, 18929, 1343, 543, 282, 327, 4528, 436, 1284, 737, 1284, 402, 1004, 3134, 78, 358, 272, 2329, 360, 3917, 376, 5148, 365, 9222, 770, 543, 282, 9889, 652, 365, 440, 10004, 4241, 60, 78, 358, 272, 2329, 360, 17183, 282, 3721, 2755, 1380, 446, 67, 365, 2013, 3134, 78, 358, 199, 199, 318, 2446, 837, 272, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 19034, 10993, 272, 871, 12733, 14, 705, 465, 1499, 26, 267, 2329, 360, 4558, 1125, 26, 283, 435, 620, 8, 1328, 9, 435, 1557, 78, 358, 267, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 272, 4875, 275, 378, 272, 340, 440, 1249, 26, 327, 3091, 2368, 267, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 272, 367, 2450, 12, 1680, 315, 3999, 26, 267, 340, 2450, 508, 2475, 67, 356, 288, 663, 1117, 6223, 342, 267, 340, 2450, 508, 2475, 82, 356, 288, 663, 4471, 342, 267, 340, 2450, 508, 2475, 83, 356, 288, 1050, 16747, 8, 1273, 9, 272, 367, 1680, 315, 1249, 26, 267, 340, 747, 14, 515, 14, 6027, 8, 1273, 304, 288, 340, 5344, 939, 944, 8, 1273, 304, 4875, 275, 413, 267, 916, 747, 14, 515, 14, 20719, 8, 1273, 304, 288, 2329, 8, 1273, 435, 7596, 911, 440, 2112, 13673, 6220, 60, 78, 358, 288, 4875, 275, 413, 267, 587, 26, 288, 340, 5325, 8, 1273, 304, 4875, 275, 413, 272, 984, 14, 2224, 8, 4087, 9, 199, 199, 3, 7743, 642, 5578, 3965, 370, 3504, 282, 3365, 663, 402, 1584, 199, 55, 10221, 275, 14452, 59, 65, 13, 6353, 13, 58, 16, 13, 25, 22155, 27658, 335, 61, 12913, 199, 318, 13632, 8, 354, 304, 272, 372, 295, 14, 1431, 8, 55, 10221, 12, 536, 9, 2356, 378, 199, 199, 318, 5344, 939, 944, 8, 3475, 304, 272, 24465, 360, 6794, 939, 944, 4042, 82, 2862, 78, 7, 450, 334, 3475, 4641, 272, 4875, 275, 378, 272, 862, 26, 267, 1561, 275, 747, 14, 7374, 8, 3475, 9, 272, 871, 6440, 465, 1499, 26, 267, 2329, 8, 3475, 435, 7596, 3913, 769, 2082, 26, 283, 435, 620, 8, 1328, 9, 435, 1557, 78, 358, 267, 372, 413, 272, 1561, 14, 3191, 342, 272, 31396, 275, 942, 272, 367, 536, 315, 1561, 26, 267, 340, 536, 315, 334, 736, 14, 15594, 12, 747, 14, 21386, 304, 1980, 267, 11064, 275, 747, 14, 515, 14, 904, 8, 3475, 12, 536, 9, 267, 340, 747, 14, 515, 14, 20719, 8, 9930, 304, 986, 267, 916, 747, 14, 515, 14, 6027, 8, 9930, 304, 288, 31396, 14, 740, 8, 9930, 9, 267, 916, 13632, 8, 354, 304, 288, 340, 5325, 8, 9930, 304, 4875, 275, 413, 272, 367, 11064, 315, 31396, 26, 267, 340, 5344, 939, 944, 8, 9930, 304, 4875, 275, 413, 272, 372, 4875, 199, 199, 318, 5325, 8, 1501, 304, 199, 309, 221, 24465, 360, 970, 4042, 82, 2862, 78, 7, 450, 334, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
odoo-turkiye/odoo
openerp/service/report.py
324
5148
# -*- coding: utf-8 -*- import base64 import logging import sys import threading import openerp import openerp.report from openerp import tools import security _logger = logging.getLogger(__name__) # TODO: set a maximum report number per user to avoid DOS attacks # # Report state: # False -> True self_reports = {} self_id = 0 self_id_protect = threading.Semaphore() def dispatch(method, params): (db, uid, passwd ) = params[0:3] threading.current_thread().uid = uid params = params[3:] if method not in ['report', 'report_get', 'render_report']: raise KeyError("Method not supported %s" % method) security.check(db,uid,passwd) openerp.modules.registry.RegistryManager.check_registry_signaling(db) fn = globals()['exp_' + method] res = fn(db, uid, *params) openerp.modules.registry.RegistryManager.signal_caches_change(db) return res def exp_render_report(db, uid, object, ids, datas=None, context=None): if not datas: datas={} if not context: context={} self_id_protect.acquire() global self_id self_id += 1 id = self_id self_id_protect.release() self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None} cr = openerp.registry(db).cursor() try: result, format = openerp.report.render_report(cr, uid, ids, object, datas, context) if not result: tb = sys.exc_info() self_reports[id]['exception'] = openerp.exceptions.DeferredException('RML is not available at specified location or not enough data to print!', tb) self_reports[id]['result'] = result self_reports[id]['format'] = format self_reports[id]['state'] = True except Exception, exception: _logger.exception('Exception: %s\n', exception) if hasattr(exception, 'name') and hasattr(exception, 'value'): self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value)) else: tb = sys.exc_info() self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.exception_to_unicode(exception), tb) self_reports[id]['state'] = True cr.commit() cr.close() return _check_report(id) def exp_report(db, uid, object, ids, datas=None, context=None): if not datas: datas={} if not context: context={} self_id_protect.acquire() global self_id self_id += 1 id = self_id self_id_protect.release() self_reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None} def go(id, uid, ids, datas, context): with openerp.api.Environment.manage(): cr = openerp.registry(db).cursor() try: result, format = openerp.report.render_report(cr, uid, ids, object, datas, context) if not result: tb = sys.exc_info() self_reports[id]['exception'] = openerp.exceptions.DeferredException('RML is not available at specified location or not enough data to print!', tb) self_reports[id]['result'] = result self_reports[id]['format'] = format self_reports[id]['state'] = True except Exception, exception: _logger.exception('Exception: %s\n', exception) if hasattr(exception, 'name') and hasattr(exception, 'value'): self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value)) else: tb = sys.exc_info() self_reports[id]['exception'] = openerp.exceptions.DeferredException(tools.exception_to_unicode(exception), tb) self_reports[id]['state'] = True cr.commit() cr.close() return True threading.Thread(target=go, args=(id, uid, ids, datas, context)).start() return id def _check_report(report_id): result = self_reports[report_id] exc = result['exception'] if exc: raise openerp.osv.orm.except_orm(exc.message, exc.traceback) res = {'state': result['state']} if res['state']: if tools.config['reportgz']: import zlib res2 = zlib.compress(result['result']) res['code'] = 'zlib' else: #CHECKME: why is this needed??? if isinstance(result['result'], unicode): res2 = result['result'].encode('latin1', 'replace') else: res2 = result['result'] if res2: res['result'] = base64.encodestring(res2) res['format'] = result['format'] del self_reports[report_id] return res def exp_report_get(db, uid, report_id): if report_id in self_reports: if self_reports[report_id]['uid'] == uid: return _check_report(report_id) else: raise Exception, 'AccessDenied' else: raise Exception, 'ReportNotFound' # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 1300, 772, 199, 646, 2050, 199, 646, 984, 199, 646, 5796, 199, 199, 646, 5166, 199, 646, 5166, 14, 3070, 199, 504, 5166, 492, 7249, 199, 199, 646, 6391, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3, 3254, 26, 663, 282, 5696, 3622, 1329, 1126, 922, 370, 5126, 577, 3100, 28140, 199, 3, 199, 3, 11774, 1174, 26, 199, 3, 258, 756, 1035, 715, 199, 199, 277, 63, 15629, 275, 1052, 199, 277, 63, 344, 275, 378, 199, 277, 63, 344, 63, 18292, 275, 5796, 14, 26574, 342, 199, 199, 318, 7634, 8, 765, 12, 1862, 304, 272, 334, 697, 12, 1747, 12, 15081, 776, 275, 1862, 59, 16, 26, 19, 61, 272, 5796, 14, 1818, 63, 2671, 1252, 1535, 275, 1747, 272, 1862, 275, 1862, 59, 19, 2938, 272, 340, 1083, 440, 315, 788, 3070, 297, 283, 3070, 63, 362, 297, 283, 3352, 63, 3070, 2565, 267, 746, 4067, 480, 3767, 440, 3748, 450, 83, 2, 450, 1083, 9, 272, 6391, 14, 1074, 8, 697, 12, 1535, 12, 12671, 9, 272, 5166, 14, 3112, 14, 5189, 14, 10899, 2988, 14, 1074, 63, 5189, 63, 4653, 316, 8, 697, 9, 272, 4325, 275, 7992, 12047, 1474, 8650, 435, 1083, 61, 272, 522, 275, 4325, 8, 697, 12, 1747, 12, 627, 1162, 9, 272, 5166, 14, 3112, 14, 5189, 14, 10899, 2988, 14, 4653, 63, 17595, 63, 1461, 8, 697, 9, 272, 372, 522, 199, 199, 318, 1437, 63, 3352, 63, 3070, 8, 697, 12, 1747, 12, 909, 12, 2762, 12, 15012, 29, 403, 12, 1067, 29, 403, 304, 272, 340, 440, 15012, 26, 267, 15012, 7622, 272, 340, 440, 1067, 26, 267, 1067, 7622, 339, 291, 63, 344, 63, 18292, 14, 8174, 342, 272, 2288, 291, 63, 344, 272, 291, 63, 344, 847, 413, 272, 1305, 275, 291, 63, 344, 272, 291, 63, 344, 63, 18292, 14, 3221, 342, 339, 291, 63, 15629, 59, 344, 61, 275, 791, 1535, 356, 1747, 12, 283, 1099, 356, 756, 12, 283, 929, 356, 756, 12, 283, 1971, 356, 488, 93, 339, 2467, 275, 5166, 14, 5189, 8, 697, 680, 3937, 342, 272, 862, 26, 267, 754, 12, 1475, 275, 5166, 14, 3070, 14, 3352, 63, 3070, 8, 1556, 12, 1747, 12, 2762, 12, 909, 12, 15012, 12, 1067, 9, 267, 340, 440, 754, 26, 288, 7070, 275, 984, 14, 2804, 63, 815, 342, 288, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 360, 50, 1698, 365, 440, 2808, 737, 2013, 2909, 503, 440, 8321, 666, 370, 870, 12389, 7070, 9, 267, 291, 63, 15629, 59, 344, 2733, 1099, 418, 275, 754, 267, 291, 63, 15629, 59, 344, 2733, 908, 418, 275, 1475, 267, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 272, 871, 2186, 12, 1919, 26, 398, 485, 2921, 14, 1971, 360, 1726, 26, 450, 83, 60, 78, 297, 1919, 9, 267, 340, 2688, 8, 1971, 12, 283, 354, 358, 436, 2688, 8, 1971, 12, 283, 585, 735, 288, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 11409, 8, 1971, 14, 354, 395, 7249, 14, 11409, 8, 1971, 14, 585, 430, 267, 587, 26, 288, 7070, 275, 984, 14, 2804, 63, 815, 342, 288, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 1971, 63, 475, 63, 2975, 8, 1971, 395, 7070, 9, 267, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 272, 2467, 14, 3543, 342, 272, 2467, 14, 1600, 342, 339, 372, 485, 1074, 63, 3070, 8, 344, 9, 199, 199, 318, 1437, 63, 3070, 8, 697, 12, 1747, 12, 909, 12, 2762, 12, 15012, 29, 403, 12, 1067, 29, 403, 304, 272, 340, 440, 15012, 26, 267, 15012, 7622, 272, 340, 440, 1067, 26, 267, 1067, 7622, 339, 291, 63, 344, 63, 18292, 14, 8174, 342, 272, 2288, 291, 63, 344, 272, 291, 63, 344, 847, 413, 272, 1305, 275, 291, 63, 344, 272, 291, 63, 344, 63, 18292, 14, 3221, 342, 339, 291, 63, 15629, 59, 344, 61, 275, 791, 1535, 356, 1747, 12, 283, 1099, 356, 756, 12, 283, 929, 356, 756, 12, 283, 1971, 356, 488, 93, 339, 347, 2621, 8, 344, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 304, 267, 543, 5166, 14, 1246, 14, 8263, 14, 9053, 837, 288, 2467, 275, 5166, 14, 5189, 8, 697, 680, 3937, 342, 288, 862, 26, 355, 754, 12, 1475, 275, 5166, 14, 3070, 14, 3352, 63, 3070, 8, 1556, 12, 1747, 12, 2762, 12, 909, 12, 15012, 12, 1067, 9, 355, 340, 440, 754, 26, 490, 7070, 275, 984, 14, 2804, 63, 815, 342, 490, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 360, 50, 1698, 365, 440, 2808, 737, 2013, 2909, 503, 440, 8321, 666, 370, 870, 12389, 7070, 9, 355, 291, 63, 15629, 59, 344, 2733, 1099, 418, 275, 754, 355, 291, 63, 15629, 59, 344, 2733, 908, 418, 275, 1475, 355, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 288, 871, 2186, 12, 1919, 26, 355, 485, 2921, 14, 1971, 360, 1726, 26, 450, 83, 60, 78, 297, 1919, 9, 355, 340, 2688, 8, 1971, 12, 283, 354, 358, 436, 2688, 8, 1971, 12, 283, 585, 735, 490, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 11409, 8, 1971, 14, 354, 395, 7249, 14, 11409, 8, 1971, 14, 585, 430, 355, 587, 26, 490, 7070, 275, 984, 14, 2804, 63, 815, 342, 490, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 1971, 63, 475, 63, 2975, 8, 1971, 395, 7070, 9, 355, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 288, 2467, 14, 3543, 342, 288, 2467, 14, 1600, 342, 267, 372, 715, 339, 5796, 14, 4436, 8, 1375, 29, 1939, 12, 1249, 2687, 344, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 4992, 928, 342, 272, 372, 1305 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 1300, 772, 199, 646, 2050, 199, 646, 984, 199, 646, 5796, 199, 199, 646, 5166, 199, 646, 5166, 14, 3070, 199, 504, 5166, 492, 7249, 199, 199, 646, 6391, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3, 3254, 26, 663, 282, 5696, 3622, 1329, 1126, 922, 370, 5126, 577, 3100, 28140, 199, 3, 199, 3, 11774, 1174, 26, 199, 3, 258, 756, 1035, 715, 199, 199, 277, 63, 15629, 275, 1052, 199, 277, 63, 344, 275, 378, 199, 277, 63, 344, 63, 18292, 275, 5796, 14, 26574, 342, 199, 199, 318, 7634, 8, 765, 12, 1862, 304, 272, 334, 697, 12, 1747, 12, 15081, 776, 275, 1862, 59, 16, 26, 19, 61, 272, 5796, 14, 1818, 63, 2671, 1252, 1535, 275, 1747, 272, 1862, 275, 1862, 59, 19, 2938, 272, 340, 1083, 440, 315, 788, 3070, 297, 283, 3070, 63, 362, 297, 283, 3352, 63, 3070, 2565, 267, 746, 4067, 480, 3767, 440, 3748, 450, 83, 2, 450, 1083, 9, 272, 6391, 14, 1074, 8, 697, 12, 1535, 12, 12671, 9, 272, 5166, 14, 3112, 14, 5189, 14, 10899, 2988, 14, 1074, 63, 5189, 63, 4653, 316, 8, 697, 9, 272, 4325, 275, 7992, 12047, 1474, 8650, 435, 1083, 61, 272, 522, 275, 4325, 8, 697, 12, 1747, 12, 627, 1162, 9, 272, 5166, 14, 3112, 14, 5189, 14, 10899, 2988, 14, 4653, 63, 17595, 63, 1461, 8, 697, 9, 272, 372, 522, 199, 199, 318, 1437, 63, 3352, 63, 3070, 8, 697, 12, 1747, 12, 909, 12, 2762, 12, 15012, 29, 403, 12, 1067, 29, 403, 304, 272, 340, 440, 15012, 26, 267, 15012, 7622, 272, 340, 440, 1067, 26, 267, 1067, 7622, 339, 291, 63, 344, 63, 18292, 14, 8174, 342, 272, 2288, 291, 63, 344, 272, 291, 63, 344, 847, 413, 272, 1305, 275, 291, 63, 344, 272, 291, 63, 344, 63, 18292, 14, 3221, 342, 339, 291, 63, 15629, 59, 344, 61, 275, 791, 1535, 356, 1747, 12, 283, 1099, 356, 756, 12, 283, 929, 356, 756, 12, 283, 1971, 356, 488, 93, 339, 2467, 275, 5166, 14, 5189, 8, 697, 680, 3937, 342, 272, 862, 26, 267, 754, 12, 1475, 275, 5166, 14, 3070, 14, 3352, 63, 3070, 8, 1556, 12, 1747, 12, 2762, 12, 909, 12, 15012, 12, 1067, 9, 267, 340, 440, 754, 26, 288, 7070, 275, 984, 14, 2804, 63, 815, 342, 288, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 360, 50, 1698, 365, 440, 2808, 737, 2013, 2909, 503, 440, 8321, 666, 370, 870, 12389, 7070, 9, 267, 291, 63, 15629, 59, 344, 2733, 1099, 418, 275, 754, 267, 291, 63, 15629, 59, 344, 2733, 908, 418, 275, 1475, 267, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 272, 871, 2186, 12, 1919, 26, 398, 485, 2921, 14, 1971, 360, 1726, 26, 450, 83, 60, 78, 297, 1919, 9, 267, 340, 2688, 8, 1971, 12, 283, 354, 358, 436, 2688, 8, 1971, 12, 283, 585, 735, 288, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 11409, 8, 1971, 14, 354, 395, 7249, 14, 11409, 8, 1971, 14, 585, 430, 267, 587, 26, 288, 7070, 275, 984, 14, 2804, 63, 815, 342, 288, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 1971, 63, 475, 63, 2975, 8, 1971, 395, 7070, 9, 267, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 272, 2467, 14, 3543, 342, 272, 2467, 14, 1600, 342, 339, 372, 485, 1074, 63, 3070, 8, 344, 9, 199, 199, 318, 1437, 63, 3070, 8, 697, 12, 1747, 12, 909, 12, 2762, 12, 15012, 29, 403, 12, 1067, 29, 403, 304, 272, 340, 440, 15012, 26, 267, 15012, 7622, 272, 340, 440, 1067, 26, 267, 1067, 7622, 339, 291, 63, 344, 63, 18292, 14, 8174, 342, 272, 2288, 291, 63, 344, 272, 291, 63, 344, 847, 413, 272, 1305, 275, 291, 63, 344, 272, 291, 63, 344, 63, 18292, 14, 3221, 342, 339, 291, 63, 15629, 59, 344, 61, 275, 791, 1535, 356, 1747, 12, 283, 1099, 356, 756, 12, 283, 929, 356, 756, 12, 283, 1971, 356, 488, 93, 339, 347, 2621, 8, 344, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 304, 267, 543, 5166, 14, 1246, 14, 8263, 14, 9053, 837, 288, 2467, 275, 5166, 14, 5189, 8, 697, 680, 3937, 342, 288, 862, 26, 355, 754, 12, 1475, 275, 5166, 14, 3070, 14, 3352, 63, 3070, 8, 1556, 12, 1747, 12, 2762, 12, 909, 12, 15012, 12, 1067, 9, 355, 340, 440, 754, 26, 490, 7070, 275, 984, 14, 2804, 63, 815, 342, 490, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 360, 50, 1698, 365, 440, 2808, 737, 2013, 2909, 503, 440, 8321, 666, 370, 870, 12389, 7070, 9, 355, 291, 63, 15629, 59, 344, 2733, 1099, 418, 275, 754, 355, 291, 63, 15629, 59, 344, 2733, 908, 418, 275, 1475, 355, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 288, 871, 2186, 12, 1919, 26, 355, 485, 2921, 14, 1971, 360, 1726, 26, 450, 83, 60, 78, 297, 1919, 9, 355, 340, 2688, 8, 1971, 12, 283, 354, 358, 436, 2688, 8, 1971, 12, 283, 585, 735, 490, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 11409, 8, 1971, 14, 354, 395, 7249, 14, 11409, 8, 1971, 14, 585, 430, 355, 587, 26, 490, 7070, 275, 984, 14, 2804, 63, 815, 342, 490, 291, 63, 15629, 59, 344, 2733, 1971, 418, 275, 5166, 14, 3924, 14, 9937, 1726, 8, 2537, 14, 1971, 63, 475, 63, 2975, 8, 1971, 395, 7070, 9, 355, 291, 63, 15629, 59, 344, 2733, 929, 418, 275, 715, 288, 2467, 14, 3543, 342, 288, 2467, 14, 1600, 342, 267, 372, 715, 339, 5796, 14, 4436, 8, 1375, 29, 1939, 12, 1249, 2687, 344, 12, 1747, 12, 2762, 12, 15012, 12, 1067, 4992, 928, 342, 272, 372, 1305, 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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XECUTED SERVER SIDE : # cd /home/common/shade # python3 manage.py shell import sys from apis.voca import * ################################## # Init des paths et noms de fichiers AddLog('title' , 'Début du nettoyage du fichier') work_dir = '/home/common/shade/apis/raw/017_raw/' # Nom du fichier source raw_file = 'src' ################################## # Création de la liste brute with open(work_dir + raw_file , 'r') as file: raw_list = [i for i in file.read().splitlines()] ''' ################################## # Formatage du texte # Init de la list contenant la sortie de StringFormatter AddLog('subtitle' , 'Début de la fonction StringFormatter') formatted_list = [StringFormatter(line) for line in raw_list] ################################## # going through oddities finder AddLog('subtitle' , 'Début de la fonction OdditiesFinder') list_without_oddities = OdditiesFinder( formatted_list ) ''' ref_list = raw_list ################################## # Enregistrement des fichiers sortie AddLog('subtitle' , 'Début de la fonction OutFileCreate') OutFileCreate('/home/common/shade/apis/out/','017_src',ref_list,'AssetPlace;Pays clémentin , Ravénie , Lombrie')
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 378, 1196, 63, 3118, 281, 14, 647, 202, 199, 3, 5099, 8280, 2296, 6262, 3651, 4220, 934, 1149, 23578, 428, 11259, 520, 202, 199, 3, 12829, 1182, 4219, 15, 2330, 15, 31170, 202, 199, 3, 2366, 19, 9635, 14, 647, 5218, 2999, 199, 646, 984, 202, 199, 504, 2771, 374, 14, 86, 679, 65, 492, 627, 2999, 199, 1371, 309, 202, 199, 3, 21026, 18618, 3792, 10844, 17468, 83, 477, 289, 1158, 73, 1192, 202, 199, 1123, 2445, 360, 1213, 7, 2360, 283, 36, 5741, 7911, 15776, 1851, 19126, 474, 15776, 289, 1158, 4446, 358, 202, 199, 800, 63, 694, 275, 1994, 4219, 15, 2330, 15, 31170, 15, 12662, 15, 1773, 15, 9570, 63, 1773, 4805, 202, 199, 3, 653, 676, 15776, 289, 1158, 4446, 1350, 202, 199, 1773, 63, 493, 275, 283, 2164, 7, 2999, 199, 1371, 309, 202, 199, 3, 30277, 5741, 425, 477, 1127, 1212, 1597, 11665, 938, 2999, 199, 1045, 1551, 8, 800, 63, 694, 435, 3066, 63, 493, 2360, 283, 82, 358, 465, 570, 26, 1128, 3066, 63, 513, 275, 359, 73, 367, 284, 315, 570, 14, 739, 1252, 7644, 5106, 202, 199, 2344, 202, 199, 1371, 309, 202, 199, 3, 8204, 419, 303, 15776, 14709, 266, 202, 199, 3, 21026, 477, 1127, 769, 406, 4647, 1127, 308, 269, 23958, 477, 2624, 7772, 202, 199, 1123, 2445, 360, 14348, 7, 2360, 283, 36, 5741, 7911, 477, 1127, 289, 265, 414, 2624, 7772, 358, 202, 199, 15317, 63, 513, 275, 359, 1558, 7772, 8, 604, 9, 367, 1004, 315, 3066, 63, 513, 61, 8065, 199, 1371, 309, 202, 199, 3, 9995, 4012, 14467, 328, 1417, 11569, 202, 199, 1123, 2445, 360, 14348, 7, 2360, 283, 36, 5741, 7911, 477, 1127, 289, 265, 414, 593, 68, 328, 1417, 11791, 358, 202, 199, 513, 63, 7395, 63, 364, 328, 1417, 275, 593, 68, 328, 1417, 11791, 8, 7871, 63, 513, 776, 202, 199, 2344, 202, 199, 1121, 63, 513, 275, 3066, 63, 513, 202, 199, 1371, 309, 202, 199, 3, 3447, 18724, 264, 434, 18618, 289, 1158, 73, 1192, 308, 269, 23958, 202, 199, 1123, 2445, 360, 14348, 7, 2360, 283, 36, 5741, 7911, 477, 1127, 289, 265, 414, 6219, 1173, 2499, 358, 202, 199, 2204, 1173, 2499, 2336, 4219, 15, 2330, 15, 31170, 15, 12662, 15, 548, 15, 1673, 9570, 63, 2164, 297, 1121, 63, 513, 2584, 19979, 11613, 27, 4232, 588, 824, 5741, 434, 262, 2360, 820, 1214, 5741, 78, 1873, 2360, 491, 676, 9660, 69, 358, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 202, 199, 3, 378, 1196, 63, 3118, 281, 14, 647, 202, 199, 3, 5099, 8280, 2296, 6262, 3651, 4220, 934, 1149, 23578, 428, 11259, 520, 202, 199, 3, 12829, 1182, 4219, 15, 2330, 15, 31170, 202, 199, 3, 2366, 19, 9635, 14, 647, 5218, 2999, 199, 646, 984, 202, 199, 504, 2771, 374, 14, 86, 679, 65, 492, 627, 2999, 199, 1371, 309, 202, 199, 3, 21026, 18618, 3792, 10844, 17468, 83, 477, 289, 1158, 73, 1192, 202, 199, 1123, 2445, 360, 1213, 7, 2360, 283, 36, 5741, 7911, 15776, 1851, 19126, 474, 15776, 289, 1158, 4446, 358, 202, 199, 800, 63, 694, 275, 1994, 4219, 15, 2330, 15, 31170, 15, 12662, 15, 1773, 15, 9570, 63, 1773, 4805, 202, 199, 3, 653, 676, 15776, 289, 1158, 4446, 1350, 202, 199, 1773, 63, 493, 275, 283, 2164, 7, 2999, 199, 1371, 309, 202, 199, 3, 30277, 5741, 425, 477, 1127, 1212, 1597, 11665, 938, 2999, 199, 1045, 1551, 8, 800, 63, 694, 435, 3066, 63, 493, 2360, 283, 82, 358, 465, 570, 26, 1128, 3066, 63, 513, 275, 359, 73, 367, 284, 315, 570, 14, 739, 1252, 7644, 5106, 202, 199, 2344, 202, 199, 1371, 309, 202, 199, 3, 8204, 419, 303, 15776, 14709, 266, 202, 199, 3, 21026, 477, 1127, 769, 406, 4647, 1127, 308, 269, 23958, 477, 2624, 7772, 202, 199, 1123, 2445, 360, 14348, 7, 2360, 283, 36, 5741, 7911, 477, 1127, 289, 265, 414, 2624, 7772, 358, 202, 199, 15317, 63, 513, 275, 359, 1558, 7772, 8, 604, 9, 367, 1004, 315, 3066, 63, 513, 61, 8065, 199, 1371, 309, 202, 199, 3, 9995, 4012, 14467, 328, 1417, 11569, 202, 199, 1123, 2445, 360, 14348, 7, 2360, 283, 36, 5741, 7911, 477, 1127, 289, 265, 414, 593, 68, 328, 1417, 11791, 358, 202, 199, 513, 63, 7395, 63, 364, 328, 1417, 275, 593, 68, 328, 1417, 11791, 8, 7871, 63, 513, 776, 202, 199, 2344, 202, 199, 1121, 63, 513, 275, 3066, 63, 513, 202, 199, 1371, 309, 202, 199, 3, 3447, 18724, 264, 434, 18618, 289, 1158, 73, 1192, 308, 269, 23958, 202, 199, 1123, 2445, 360, 14348, 7, 2360, 283, 36, 5741, 7911, 477, 1127, 289, 265, 414, 6219, 1173, 2499, 358, 202, 199, 2204, 1173, 2499, 2336, 4219, 15, 2330, 15, 31170, 15, 12662, 15, 548, 15, 1673, 9570, 63, 2164, 297, 1121, 63, 513, 2584, 19979, 11613, 27, 4232, 588, 824, 5741, 434, 262, 2360, 820, 1214, 5741, 78, 1873, 2360, 491, 676, 9660, 69, 358, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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, subprocess # begin loop: # - reading from stdin # - forking a child # - executing a new process in the child def main(): while True: sys.stdout.write(os.environ['PROMPT']) line = sys.stdin.readline() commands = split_on_pipes(line) placeholder_in = sys.stdin placeholder_out = sys.stdout pipe = [] pids = [] for line in commands: args = [expand(string) for string in line.split()] command = args[0] if command in BUILTINS: # run built-in instead of doing fork + exec run_builtin(command, args) else: # if command is not the last command if (commands.index(line) + 1) < len(commands): pipe = os.pipe() # file descriptors placeholder_out = pipe[1] else: placeholder_out = sys.stdout pid = fork_and_exec(command, args, placeholder_out, placeholder_in) pids.append(pid) if type(placeholder_out) is int: os.close(placeholder_out) if type(placeholder_in) is int: os.close(placeholder_in) if commands.index(line) > 0: placeholder_in = pipe[0] for id in pids: wait_for_child(id) def wait_for_child(pid): try: os.waitpid(pid, 0) except: None # returns PID of child process def fork_and_exec(command, args, placeholder_out, placeholder_in): pid = os.fork() if pid == 0: # inside child process if type(placeholder_out) is int: sys.stdout = os.fdopen(placeholder_out, 'w') os.close(placeholder_out) if type(placeholder_in) is int: sys.stdin = os.fdopen(placeholder_in, 'r') os.close(placeholder_in) try: os.execvp(command, args) # actual exec except: print "%s: command not found" % command sys.exit(1) # exit child return pid def run_builtin(command, args): try: BUILTINS[command](args[1]) except: BUILTINS[command]() # returns an array of command strings def split_on_pipes(line): matches = re.findall("([^\"'|]+)|[\"']([^\"']+)[\"']", line) commands = [] for match in matches: for string in match: if string != '': commands.append(string.strip()) return commands # support different types of expansion def expand(string): # variable expansion if re.match("\$\w+", string): return os.environ[string[1:]] # arithmetic expansion elif re.match("\$\(\(([\w\W\s]*)\)\)", string): expr = re.match("\$\(\(([\w\W\s]*)\)\)", string).group(1) return str(eval(expr)) # command expansion elif re.match("\$\(([\w\W\s]*)\)", string): expr = re.match("\$\(([\w\W\s]*)\)", string).group(1) p = subprocess.Popen([expr], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # get the output of the command out, _ = p.communicate() return out[0:-1] else: return string def set(args): key, value = args.split('=') os.environ[key] = value BUILTINS = { 'cd': lambda path: os.chdir(''.join(path)), 'exit': lambda exit_code=0: sys.exit(int(exit_code)), 'set': lambda args: set(args) # can't do variable assignment in Python lambda } os.environ['PROMPT'] = "=> " main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 12, 747, 12, 295, 12, 3873, 199, 199, 3, 5386, 4438, 26, 199, 3, 446, 7664, 687, 9009, 199, 3, 446, 14926, 316, 282, 1982, 199, 3, 446, 14043, 282, 892, 2112, 315, 314, 1982, 199, 199, 318, 2446, 837, 199, 198, 6710, 715, 26, 507, 198, 1274, 14, 2703, 14, 952, 8, 736, 14, 2314, 459, 2514, 26178, 1105, 507, 198, 604, 275, 984, 14, 6626, 14, 6407, 342, 2742, 198, 4405, 275, 3715, 63, 265, 63, 29942, 8, 604, 9, 507, 198, 6199, 63, 262, 275, 984, 14, 6626, 507, 198, 6199, 63, 548, 275, 984, 14, 2703, 507, 198, 4990, 275, 942, 507, 198, 19331, 275, 942, 2742, 198, 509, 1004, 315, 3718, 26, 686, 198, 589, 275, 359, 4441, 8, 875, 9, 367, 1059, 315, 1004, 14, 1294, 5106, 686, 198, 1531, 275, 1249, 59, 16, 61, 6319, 198, 692, 1414, 315, 16331, 1193, 52, 10789, 26, 1585, 198, 3, 1255, 6137, 13, 262, 3140, 402, 9689, 14926, 435, 2146, 1585, 198, 1065, 63, 5351, 8, 1531, 12, 1249, 9, 686, 198, 2836, 26, 1585, 198, 3, 340, 1414, 365, 440, 314, 2061, 1414, 1585, 198, 692, 334, 4405, 14, 1080, 8, 604, 9, 435, 413, 9, 665, 822, 8, 4405, 304, 1871, 198, 4990, 275, 747, 14, 4990, 342, 327, 570, 15428, 1871, 198, 6199, 63, 548, 275, 5200, 59, 17, 61, 1585, 198, 2836, 26, 1871, 198, 6199, 63, 548, 275, 984, 14, 2703, 16737, 198, 3150, 275, 14926, 63, 460, 63, 1628, 8, 1531, 12, 1249, 12, 10069, 63, 548, 12, 10069, 63, 262, 9, 1585, 198, 19331, 14, 740, 8, 3150, 9, 16737, 198, 692, 730, 8, 6199, 63, 548, 9, 365, 1109, 26, 1871, 198, 736, 14, 1600, 8, 6199, 63, 548, 9, 16737, 198, 692, 730, 8, 6199, 63, 262, 9, 365, 1109, 26, 1871, 198, 736, 14, 1600, 8, 6199, 63, 262, 9, 16737, 198, 692, 3718, 14, 1080, 8, 604, 9, 690, 378, 26, 1871, 198, 6199, 63, 262, 275, 5200, 59, 16, 61, 2742, 198, 509, 1305, 315, 25902, 26, 686, 198, 2573, 63, 509, 63, 1739, 8, 344, 9, 199, 199, 318, 3618, 63, 509, 63, 1739, 8, 3150, 304, 199, 198, 893, 26, 507, 198, 736, 14, 2573, 3150, 8, 3150, 12, 378, 9, 199, 198, 2590, 26, 507, 198, 403, 198, 199, 199, 3, 2529, 20674, 402, 1982, 2112, 199, 318, 14926, 63, 460, 63, 1628, 8, 1531, 12, 1249, 12, 10069, 63, 548, 12, 10069, 63, 262, 304, 199, 198, 3150, 275, 747, 14, 11796, 342, 199, 198, 692, 4422, 508, 378, 26, 327, 6272, 1982, 2112, 507, 198, 692, 730, 8, 6199, 63, 548, 9, 365, 1109, 26, 686, 198, 1274, 14, 2703, 275, 747, 14, 23140, 8, 6199, 63, 548, 12, 283, 87, 358, 686, 198, 736, 14, 1600, 8, 6199, 63, 548, 9, 2742, 198, 692, 730, 8, 6199, 63, 262, 9, 365, 1109, 26, 686, 198, 1274, 14, 6626, 275, 747, 14, 23140, 8, 6199, 63, 262, 12, 283, 82, 358, 686, 198, 736, 14, 1600, 8, 6199, 63, 262, 9, 2742, 198, 893, 26, 686, 198, 736, 14, 1628, 11702, 8, 1531, 12, 1249, 9, 327, 3503, 2146, 507, 198, 2590, 26, 686, 198, 1361, 2071, 83, 26, 1414, 440, 1911, 2, 450, 1414, 686, 198, 1274, 14, 2224, 8, 17, 9, 327, 4458, 1982, 199, 198, 1107, 4422, 421, 199, 318, 1255, 63, 5351, 8, 1531, 12, 1249, 304, 199, 198, 893, 26, 507, 198, 18637, 52, 10789, 59, 1531, 8738, 589, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 18637, 52, 10789, 59, 1531, 32702, 199, 199, 3, 2529, 376, 1625, 402, 1414, 3326, 199, 318, 3715, 63, 265, 63, 29942, 8, 604, 304, 199, 198, 6742, 275, 295, 14, 6452, 480, 7059, 4451, 17018, 2807, 8636, 59, 4451, 418, 7059, 4451, 21899, 2788, 4451, 6256, 1004, 9, 199, 198, 4405, 275, 942, 199, 198, 509, 1336, 315, 4450, 26, 507, 198, 509, 1059, 315, 1336, 26, 686, 198, 692, 1059, 1137, 8061, 1585, 198, 4405, 14, 740, 8, 875, 14, 1913, 1012, 199, 198, 1107, 3718, 199, 199, 3, 2291, 3365, 2943, 402, 14819, 199, 318, 6544, 8, 875, 304, 199, 198, 3, 1750, 14819, 199, 198, 692, 295, 14, 1431, 4582, 16827, 87, 22758, 1059, 304, 507, 198, 1107, 747, 14, 2314, 59, 875, 59, 17, 21316, 421, 198, 3, 24166, 14819, 199, 198, 4164, 295, 14, 1431, 4582, 16827, 2961, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 2862, 4186, 1059, 304, 507, 198, 3684, 275, 295, 14, 1431, 4582, 16827, 2961, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 2862, 4186, 1059, 680, 923, 8, 17, 9, 507, 198, 1107, 620, 8, 2579, 8, 3684, 430, 421, 198, 3, 1414, 14819, 199, 198, 4164, 295, 14, 1431, 4582, 16827, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 4186, 1059, 304, 507, 198, 3684, 275, 295, 14, 1431, 4582, 16827, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 4186, 1059, 680, 923, 8, 17, 9, 507, 198, 80, 275, 3873, 14, 7942, 779, 3684, 467, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 507, 198, 3, 664, 314, 1072, 402, 314, 1414, 507, 198, 548, 12, 485, 275, 299, 14, 10664, 342, 507, 198, 1107, 734, 59, 16, 6809, 17, 61, 421, 198, 2836, 26, 507, 198, 1107, 1059, 199, 199, 318, 663, 8, 589, 304, 523, 790, 12, 574, 275, 1249, 14, 1294, 23917, 523, 747, 14, 2314, 59, 498, 61, 275, 574, 199, 199, 18637, 52, 10789, 275, 469, 199, 198, 7, 2866, 356, 2400, 931, 26, 747, 14, 8563, 17840, 904, 8, 515, 1826, 199, 198, 7, 2224, 356, 2400, 4458, 63, 600, 29, 16, 26, 984, 14, 2224, 8, 442, 8, 2224, 63, 600, 1826, 199, 198, 1159, 386, 356, 2400, 1249, 26, 663, 8, 589, 9, 327, 883, 1133, 886, 1750, 9801, 315, 2018, 2400, 199, 93, 199, 199, 736, 14, 2314, 459, 2514, 26178, 418, 275, 298, 28266, 298, 199, 199, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 12, 747, 12, 295, 12, 3873, 199, 199, 3, 5386, 4438, 26, 199, 3, 446, 7664, 687, 9009, 199, 3, 446, 14926, 316, 282, 1982, 199, 3, 446, 14043, 282, 892, 2112, 315, 314, 1982, 199, 199, 318, 2446, 837, 199, 198, 6710, 715, 26, 507, 198, 1274, 14, 2703, 14, 952, 8, 736, 14, 2314, 459, 2514, 26178, 1105, 507, 198, 604, 275, 984, 14, 6626, 14, 6407, 342, 2742, 198, 4405, 275, 3715, 63, 265, 63, 29942, 8, 604, 9, 507, 198, 6199, 63, 262, 275, 984, 14, 6626, 507, 198, 6199, 63, 548, 275, 984, 14, 2703, 507, 198, 4990, 275, 942, 507, 198, 19331, 275, 942, 2742, 198, 509, 1004, 315, 3718, 26, 686, 198, 589, 275, 359, 4441, 8, 875, 9, 367, 1059, 315, 1004, 14, 1294, 5106, 686, 198, 1531, 275, 1249, 59, 16, 61, 6319, 198, 692, 1414, 315, 16331, 1193, 52, 10789, 26, 1585, 198, 3, 1255, 6137, 13, 262, 3140, 402, 9689, 14926, 435, 2146, 1585, 198, 1065, 63, 5351, 8, 1531, 12, 1249, 9, 686, 198, 2836, 26, 1585, 198, 3, 340, 1414, 365, 440, 314, 2061, 1414, 1585, 198, 692, 334, 4405, 14, 1080, 8, 604, 9, 435, 413, 9, 665, 822, 8, 4405, 304, 1871, 198, 4990, 275, 747, 14, 4990, 342, 327, 570, 15428, 1871, 198, 6199, 63, 548, 275, 5200, 59, 17, 61, 1585, 198, 2836, 26, 1871, 198, 6199, 63, 548, 275, 984, 14, 2703, 16737, 198, 3150, 275, 14926, 63, 460, 63, 1628, 8, 1531, 12, 1249, 12, 10069, 63, 548, 12, 10069, 63, 262, 9, 1585, 198, 19331, 14, 740, 8, 3150, 9, 16737, 198, 692, 730, 8, 6199, 63, 548, 9, 365, 1109, 26, 1871, 198, 736, 14, 1600, 8, 6199, 63, 548, 9, 16737, 198, 692, 730, 8, 6199, 63, 262, 9, 365, 1109, 26, 1871, 198, 736, 14, 1600, 8, 6199, 63, 262, 9, 16737, 198, 692, 3718, 14, 1080, 8, 604, 9, 690, 378, 26, 1871, 198, 6199, 63, 262, 275, 5200, 59, 16, 61, 2742, 198, 509, 1305, 315, 25902, 26, 686, 198, 2573, 63, 509, 63, 1739, 8, 344, 9, 199, 199, 318, 3618, 63, 509, 63, 1739, 8, 3150, 304, 199, 198, 893, 26, 507, 198, 736, 14, 2573, 3150, 8, 3150, 12, 378, 9, 199, 198, 2590, 26, 507, 198, 403, 198, 199, 199, 3, 2529, 20674, 402, 1982, 2112, 199, 318, 14926, 63, 460, 63, 1628, 8, 1531, 12, 1249, 12, 10069, 63, 548, 12, 10069, 63, 262, 304, 199, 198, 3150, 275, 747, 14, 11796, 342, 199, 198, 692, 4422, 508, 378, 26, 327, 6272, 1982, 2112, 507, 198, 692, 730, 8, 6199, 63, 548, 9, 365, 1109, 26, 686, 198, 1274, 14, 2703, 275, 747, 14, 23140, 8, 6199, 63, 548, 12, 283, 87, 358, 686, 198, 736, 14, 1600, 8, 6199, 63, 548, 9, 2742, 198, 692, 730, 8, 6199, 63, 262, 9, 365, 1109, 26, 686, 198, 1274, 14, 6626, 275, 747, 14, 23140, 8, 6199, 63, 262, 12, 283, 82, 358, 686, 198, 736, 14, 1600, 8, 6199, 63, 262, 9, 2742, 198, 893, 26, 686, 198, 736, 14, 1628, 11702, 8, 1531, 12, 1249, 9, 327, 3503, 2146, 507, 198, 2590, 26, 686, 198, 1361, 2071, 83, 26, 1414, 440, 1911, 2, 450, 1414, 686, 198, 1274, 14, 2224, 8, 17, 9, 327, 4458, 1982, 199, 198, 1107, 4422, 421, 199, 318, 1255, 63, 5351, 8, 1531, 12, 1249, 304, 199, 198, 893, 26, 507, 198, 18637, 52, 10789, 59, 1531, 8738, 589, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 18637, 52, 10789, 59, 1531, 32702, 199, 199, 3, 2529, 376, 1625, 402, 1414, 3326, 199, 318, 3715, 63, 265, 63, 29942, 8, 604, 304, 199, 198, 6742, 275, 295, 14, 6452, 480, 7059, 4451, 17018, 2807, 8636, 59, 4451, 418, 7059, 4451, 21899, 2788, 4451, 6256, 1004, 9, 199, 198, 4405, 275, 942, 199, 198, 509, 1336, 315, 4450, 26, 507, 198, 509, 1059, 315, 1336, 26, 686, 198, 692, 1059, 1137, 8061, 1585, 198, 4405, 14, 740, 8, 875, 14, 1913, 1012, 199, 198, 1107, 3718, 199, 199, 3, 2291, 3365, 2943, 402, 14819, 199, 318, 6544, 8, 875, 304, 199, 198, 3, 1750, 14819, 199, 198, 692, 295, 14, 1431, 4582, 16827, 87, 22758, 1059, 304, 507, 198, 1107, 747, 14, 2314, 59, 875, 59, 17, 21316, 421, 198, 3, 24166, 14819, 199, 198, 4164, 295, 14, 1431, 4582, 16827, 2961, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 2862, 4186, 1059, 304, 507, 198, 3684, 275, 295, 14, 1431, 4582, 16827, 2961, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 2862, 4186, 1059, 680, 923, 8, 17, 9, 507, 198, 1107, 620, 8, 2579, 8, 3684, 430, 421, 198, 3, 1414, 14819, 199, 198, 4164, 295, 14, 1431, 4582, 16827, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 4186, 1059, 304, 507, 198, 3684, 275, 295, 14, 1431, 4582, 16827, 8, 16510, 87, 60, 55, 60, 83, 3672, 2862, 4186, 1059, 680, 923, 8, 17, 9, 507, 198, 80, 275, 3873, 14, 7942, 779, 3684, 467, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 507, 198, 3, 664, 314, 1072, 402, 314, 1414, 507, 198, 548, 12, 485, 275, 299, 14, 10664, 342, 507, 198, 1107, 734, 59, 16, 6809, 17, 61, 421, 198, 2836, 26, 507, 198, 1107, 1059, 199, 199, 318, 663, 8, 589, 304, 523, 790, 12, 574, 275, 1249, 14, 1294, 23917, 523, 747, 14, 2314, 59, 498, 61, 275, 574, 199, 199, 18637, 52, 10789, 275, 469, 199, 198, 7, 2866, 356, 2400, 931, 26, 747, 14, 8563, 17840, 904, 8, 515, 1826, 199, 198, 7, 2224, 356, 2400, 4458, 63, 600, 29, 16, 26, 984, 14, 2224, 8, 442, 8, 2224, 63, 600, 1826, 199, 198, 1159, 386, 356, 2400, 1249, 26, 663, 8, 589, 9, 327, 883, 1133, 886, 1750, 9801, 315, 2018, 2400, 199, 93, 199, 199, 736, 14, 2314, 459, 2514, 26178, 418, 275, 298, 28266, 298, 199, 199, 973, 342, 199, 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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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, 0, 0, 0, 0, 0, 0, 0 ]
eamuntz/Django-Tut
env/lib/python2.7/site-packages/django/contrib/gis/geos/tests/test_geos_mutation.py
109
5305
# Copyright (c) 2008-2009 Aryeh Leib Taurog, all rights reserved. # Modified from original contribution by Aryeh Leib Taurog, which was # released under the New BSD license. from django.utils import unittest from django.utils.unittest import skipUnless from .. import HAS_GEOS if HAS_GEOS: from .. import * from ..error import GEOSIndexError def getItem(o,i): return o[i] def delItem(o,i): del o[i] def setItem(o,i,v): o[i] = v if HAS_GEOS: def api_get_distance(x): return x.distance(Point(-200,-200)) def api_get_buffer(x): return x.buffer(10) def api_get_geom_typeid(x): return x.geom_typeid def api_get_num_coords(x): return x.num_coords def api_get_centroid(x): return x.centroid def api_get_empty(x): return x.empty def api_get_valid(x): return x.valid def api_get_simple(x): return x.simple def api_get_ring(x): return x.ring def api_get_boundary(x): return x.boundary def api_get_convex_hull(x): return x.convex_hull def api_get_extent(x): return x.extent def api_get_area(x): return x.area def api_get_length(x): return x.length geos_function_tests = [ val for name, val in vars().items() if hasattr(val, '__call__') and name.startswith('api_get_') ] @skipUnless(HAS_GEOS, "Geos is required.") class GEOSMutationTest(unittest.TestCase): """ Tests Pythonic Mutability of Python GEOS geometry wrappers get/set/delitem on a slice, normal list methods """ def test00_GEOSIndexException(self): 'Testing Geometry GEOSIndexError' p = Point(1,2) for i in range(-2,2): p._checkindex(i) self.assertRaises(GEOSIndexError, p._checkindex, 2) self.assertRaises(GEOSIndexError, p._checkindex, -3) def test01_PointMutations(self): 'Testing Point mutations' for p in (Point(1,2,3), fromstr('POINT (1 2 3)')): self.assertEqual(p._get_single_external(1), 2.0, 'Point _get_single_external') # _set_single p._set_single(0,100) self.assertEqual(p.coords, (100.0,2.0,3.0), 'Point _set_single') # _set_list p._set_list(2,(50,3141)) self.assertEqual(p.coords, (50.0,3141.0), 'Point _set_list') def test02_PointExceptions(self): 'Testing Point exceptions' self.assertRaises(TypeError, Point, range(1)) self.assertRaises(TypeError, Point, range(4)) def test03_PointApi(self): 'Testing Point API' q = Point(4,5,3) for p in (Point(1,2,3), fromstr('POINT (1 2 3)')): p[0:2] = [4,5] for f in geos_function_tests: self.assertEqual(f(q), f(p), 'Point ' + f.__name__) def test04_LineStringMutations(self): 'Testing LineString mutations' for ls in (LineString((1,0),(4,1),(6,-1)), fromstr('LINESTRING (1 0,4 1,6 -1)')): self.assertEqual(ls._get_single_external(1), (4.0,1.0), 'LineString _get_single_external') # _set_single ls._set_single(0,(-50,25)) self.assertEqual(ls.coords, ((-50.0,25.0),(4.0,1.0),(6.0,-1.0)), 'LineString _set_single') # _set_list ls._set_list(2, ((-50.0,25.0),(6.0,-1.0))) self.assertEqual(ls.coords, ((-50.0,25.0),(6.0,-1.0)), 'LineString _set_list') lsa = LineString(ls.coords) for f in geos_function_tests: self.assertEqual(f(lsa), f(ls), 'LineString ' + f.__name__) def test05_Polygon(self): 'Testing Polygon mutations' for pg in (Polygon(((1,0),(4,1),(6,-1),(8,10),(1,0)), ((5,4),(6,4),(6,3),(5,4))), fromstr('POLYGON ((1 0,4 1,6 -1,8 10,1 0),(5 4,6 4,6 3,5 4))')): self.assertEqual(pg._get_single_external(0), LinearRing((1,0),(4,1),(6,-1),(8,10),(1,0)), 'Polygon _get_single_external(0)') self.assertEqual(pg._get_single_external(1), LinearRing((5,4),(6,4),(6,3),(5,4)), 'Polygon _get_single_external(1)') # _set_list pg._set_list(2, (((1,2),(10,0),(12,9),(-1,15),(1,2)), ((4,2),(5,2),(5,3),(4,2)))) self.assertEqual(pg.coords, (((1.0,2.0),(10.0,0.0),(12.0,9.0),(-1.0,15.0),(1.0,2.0)), ((4.0,2.0),(5.0,2.0),(5.0,3.0),(4.0,2.0))), 'Polygon _set_list') lsa = Polygon(*pg.coords) for f in geos_function_tests: self.assertEqual(f(lsa), f(pg), 'Polygon ' + f.__name__) def test06_Collection(self): 'Testing Collection mutations' for mp in (MultiPoint(*map(Point,((3,4),(-1,2),(5,-4),(2,8)))), fromstr('MULTIPOINT (3 4,-1 2,5 -4,2 8)')): self.assertEqual(mp._get_single_external(2), Point(5,-4), 'Collection _get_single_external') mp._set_list(3, map(Point,((5,5),(3,-2),(8,1)))) self.assertEqual(mp.coords, ((5.0,5.0),(3.0,-2.0),(8.0,1.0)), 'Collection _set_list') lsa = MultiPoint(*map(Point,((5,5),(3,-2),(8,1)))) for f in geos_function_tests: self.assertEqual(f(lsa), f(mp), 'MultiPoint ' + f.__name__)
mit
[ 3, 1898, 334, 67, 9, 9079, 13, 8664, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1006, 4481, 4644, 14, 199, 3, 22016, 687, 3379, 406, 15980, 701, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1314, 1990, 199, 3, 14286, 1334, 314, 7053, 6289, 4190, 14, 199, 199, 504, 1639, 14, 1208, 492, 2882, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 5524, 199, 199, 504, 2508, 492, 7509, 63, 14151, 199, 199, 692, 7509, 63, 14151, 26, 272, 687, 2508, 492, 627, 272, 687, 2508, 705, 492, 11920, 12129, 421, 199, 318, 664, 2081, 8, 79, 12, 73, 304, 372, 312, 59, 73, 61, 199, 318, 2150, 2081, 8, 79, 12, 73, 304, 2150, 312, 59, 73, 61, 199, 318, 663, 2081, 8, 79, 12, 73, 12, 86, 304, 312, 59, 73, 61, 275, 373, 199, 199, 692, 7509, 63, 14151, 26, 272, 347, 2986, 63, 362, 63, 5590, 8, 88, 304, 372, 671, 14, 5590, 8, 3428, 2801, 1840, 3057, 1840, 430, 199, 199, 318, 2986, 63, 362, 63, 2738, 8, 88, 304, 372, 671, 14, 2738, 8, 709, 9, 199, 318, 2986, 63, 362, 63, 6481, 63, 22749, 8, 88, 304, 372, 671, 14, 6481, 63, 22749, 199, 318, 2986, 63, 362, 63, 1507, 63, 8032, 8, 88, 304, 372, 671, 14, 1507, 63, 8032, 199, 318, 2986, 63, 362, 63, 22098, 8, 88, 304, 372, 671, 14, 22098, 199, 318, 2986, 63, 362, 63, 1667, 8, 88, 304, 372, 671, 14, 1667, 199, 318, 2986, 63, 362, 63, 1078, 8, 88, 304, 372, 671, 14, 1078, 199, 318, 2986, 63, 362, 63, 4129, 8, 88, 304, 372, 671, 14, 4129, 199, 318, 2986, 63, 362, 63, 5985, 8, 88, 304, 372, 671, 14, 5985, 199, 318, 2986, 63, 362, 63, 9891, 8, 88, 304, 372, 671, 14, 9891, 199, 318, 2986, 63, 362, 63, 388, 26221, 63, 72, 979, 8, 88, 304, 372, 671, 14, 388, 26221, 63, 72, 979, 199, 318, 2986, 63, 362, 63, 11599, 8, 88, 304, 372, 671, 14, 11599, 199, 318, 2986, 63, 362, 63, 6789, 8, 88, 304, 372, 671, 14, 6789, 199, 318, 2986, 63, 362, 63, 1267, 8, 88, 304, 372, 671, 14, 1267, 199, 199, 12151, 63, 1593, 63, 2219, 275, 221, 359, 1139, 367, 536, 12, 1139, 315, 6802, 1252, 1744, 342, 717, 340, 2688, 8, 637, 12, 2560, 1250, 13766, 717, 436, 536, 14, 2460, 360, 1246, 63, 362, 15452, 1622, 421, 199, 32, 11278, 8, 13533, 63, 14151, 12, 298, 4240, 736, 365, 1415, 2685, 199, 533, 11920, 45, 10326, 774, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 2018, 530, 26550, 3616, 402, 2018, 11920, 3400, 17995, 272, 664, 15, 409, 15, 13228, 641, 282, 6014, 12, 3293, 769, 3102, 272, 408, 339, 347, 511, 383, 63, 14151, 2681, 1726, 8, 277, 304, 267, 283, 9029, 10579, 11920, 12129, 7, 267, 299, 275, 7584, 8, 17, 12, 18, 9, 267, 367, 284, 315, 1425, 2801, 18, 12, 18, 304, 299, 423, 1074, 1080, 8, 73, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 499, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 446, 19, 9, 339, 347, 511, 614, 63, 3428, 22539, 1298, 8, 277, 304, 267, 283, 9029, 7584, 8567, 1298, 7, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 291, 14, 629, 8, 80, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 499, 14, 16, 12, 283, 3428, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 299, 423, 409, 63, 4780, 8, 16, 12, 1960, 9, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1960, 14, 16, 12, 18, 14, 16, 12, 19, 14, 16, 395, 283, 3428, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 299, 423, 409, 63, 513, 8, 18, 12803, 1400, 12, 8988, 17, 430, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1400, 14, 16, 12, 8988, 17, 14, 16, 395, 283, 3428, 485, 409, 63, 513, 358, 339, 347, 511, 996, 63, 3428, 16836, 8, 277, 304, 267, 283, 9029, 7584, 4967, 7, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 17, 430, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 20, 430, 339, 347, 511, 1644, 63, 3428, 7394, 8, 277, 304, 267, 283, 9029, 7584, 3261, 7, 267, 1894, 275, 7584, 8, 20, 12, 21, 12, 19, 9, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 299, 59, 16, 26, 18, 61, 275, 359, 20, 12, 21, 61, 288, 367, 289, 315, 30259, 63, 1593, 63, 2219, 26, 355, 291, 14, 629, 8, 70, 8, 81, 395, 289, 8, 80, 395, 283, 3428, 283, 435, 289, 855, 354, 3368, 339, 347, 511, 966, 63, 22134, 22539, 1298, 8, 277, 304, 267, 283, 9029, 30020, 8567, 1298, 7, 267, 367, 9100, 315, 334, 22134, 1332, 17, 12, 16, 11865, 20, 12, 17, 11865, 22, 3057, 17, 1826, 490, 23744, 360, 6143, 29780, 334, 17, 378, 12, 20, 413, 12, 22, 446, 17, 5942, 304, 288, 291, 14, 629, 8, 478, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 334, 20, 14, 16, 12, 17, 14, 16, 395, 283, 22134, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 9100, 423, 409, 63, 4780, 8, 16, 12, 2801, 1400, 12, 821, 430, 288, 291, 14, 629, 8, 478, 14, 8032, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 20, 14, 16, 12, 17, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1826, 283, 22134, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 9100, 423, 409, 63, 513, 8, 18, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1724, 288, 291, 14, 629, 8, 478, 14, 8032 ]
[ 1898, 334, 67, 9, 9079, 13, 8664, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1006, 4481, 4644, 14, 199, 3, 22016, 687, 3379, 406, 15980, 701, 437, 651, 24528, 7005, 1892, 377, 3844, 19029, 12, 1314, 1990, 199, 3, 14286, 1334, 314, 7053, 6289, 4190, 14, 199, 199, 504, 1639, 14, 1208, 492, 2882, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 5524, 199, 199, 504, 2508, 492, 7509, 63, 14151, 199, 199, 692, 7509, 63, 14151, 26, 272, 687, 2508, 492, 627, 272, 687, 2508, 705, 492, 11920, 12129, 421, 199, 318, 664, 2081, 8, 79, 12, 73, 304, 372, 312, 59, 73, 61, 199, 318, 2150, 2081, 8, 79, 12, 73, 304, 2150, 312, 59, 73, 61, 199, 318, 663, 2081, 8, 79, 12, 73, 12, 86, 304, 312, 59, 73, 61, 275, 373, 199, 199, 692, 7509, 63, 14151, 26, 272, 347, 2986, 63, 362, 63, 5590, 8, 88, 304, 372, 671, 14, 5590, 8, 3428, 2801, 1840, 3057, 1840, 430, 199, 199, 318, 2986, 63, 362, 63, 2738, 8, 88, 304, 372, 671, 14, 2738, 8, 709, 9, 199, 318, 2986, 63, 362, 63, 6481, 63, 22749, 8, 88, 304, 372, 671, 14, 6481, 63, 22749, 199, 318, 2986, 63, 362, 63, 1507, 63, 8032, 8, 88, 304, 372, 671, 14, 1507, 63, 8032, 199, 318, 2986, 63, 362, 63, 22098, 8, 88, 304, 372, 671, 14, 22098, 199, 318, 2986, 63, 362, 63, 1667, 8, 88, 304, 372, 671, 14, 1667, 199, 318, 2986, 63, 362, 63, 1078, 8, 88, 304, 372, 671, 14, 1078, 199, 318, 2986, 63, 362, 63, 4129, 8, 88, 304, 372, 671, 14, 4129, 199, 318, 2986, 63, 362, 63, 5985, 8, 88, 304, 372, 671, 14, 5985, 199, 318, 2986, 63, 362, 63, 9891, 8, 88, 304, 372, 671, 14, 9891, 199, 318, 2986, 63, 362, 63, 388, 26221, 63, 72, 979, 8, 88, 304, 372, 671, 14, 388, 26221, 63, 72, 979, 199, 318, 2986, 63, 362, 63, 11599, 8, 88, 304, 372, 671, 14, 11599, 199, 318, 2986, 63, 362, 63, 6789, 8, 88, 304, 372, 671, 14, 6789, 199, 318, 2986, 63, 362, 63, 1267, 8, 88, 304, 372, 671, 14, 1267, 199, 199, 12151, 63, 1593, 63, 2219, 275, 221, 359, 1139, 367, 536, 12, 1139, 315, 6802, 1252, 1744, 342, 717, 340, 2688, 8, 637, 12, 2560, 1250, 13766, 717, 436, 536, 14, 2460, 360, 1246, 63, 362, 15452, 1622, 421, 199, 32, 11278, 8, 13533, 63, 14151, 12, 298, 4240, 736, 365, 1415, 2685, 199, 533, 11920, 45, 10326, 774, 8, 2796, 14, 1746, 304, 272, 408, 272, 6496, 2018, 530, 26550, 3616, 402, 2018, 11920, 3400, 17995, 272, 664, 15, 409, 15, 13228, 641, 282, 6014, 12, 3293, 769, 3102, 272, 408, 339, 347, 511, 383, 63, 14151, 2681, 1726, 8, 277, 304, 267, 283, 9029, 10579, 11920, 12129, 7, 267, 299, 275, 7584, 8, 17, 12, 18, 9, 267, 367, 284, 315, 1425, 2801, 18, 12, 18, 304, 299, 423, 1074, 1080, 8, 73, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 499, 9, 267, 291, 14, 1855, 8, 14151, 12129, 12, 299, 423, 1074, 1080, 12, 446, 19, 9, 339, 347, 511, 614, 63, 3428, 22539, 1298, 8, 277, 304, 267, 283, 9029, 7584, 8567, 1298, 7, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 291, 14, 629, 8, 80, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 499, 14, 16, 12, 283, 3428, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 299, 423, 409, 63, 4780, 8, 16, 12, 1960, 9, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1960, 14, 16, 12, 18, 14, 16, 12, 19, 14, 16, 395, 283, 3428, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 299, 423, 409, 63, 513, 8, 18, 12803, 1400, 12, 8988, 17, 430, 288, 291, 14, 629, 8, 80, 14, 8032, 12, 334, 1400, 14, 16, 12, 8988, 17, 14, 16, 395, 283, 3428, 485, 409, 63, 513, 358, 339, 347, 511, 996, 63, 3428, 16836, 8, 277, 304, 267, 283, 9029, 7584, 4967, 7, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 17, 430, 267, 291, 14, 1855, 8, 4333, 12, 7584, 12, 1425, 8, 20, 430, 339, 347, 511, 1644, 63, 3428, 7394, 8, 277, 304, 267, 283, 9029, 7584, 3261, 7, 267, 1894, 275, 7584, 8, 20, 12, 21, 12, 19, 9, 267, 367, 299, 315, 334, 3428, 8, 17, 12, 18, 12, 19, 395, 23744, 360, 7217, 334, 17, 499, 650, 5942, 304, 288, 299, 59, 16, 26, 18, 61, 275, 359, 20, 12, 21, 61, 288, 367, 289, 315, 30259, 63, 1593, 63, 2219, 26, 355, 291, 14, 629, 8, 70, 8, 81, 395, 289, 8, 80, 395, 283, 3428, 283, 435, 289, 855, 354, 3368, 339, 347, 511, 966, 63, 22134, 22539, 1298, 8, 277, 304, 267, 283, 9029, 30020, 8567, 1298, 7, 267, 367, 9100, 315, 334, 22134, 1332, 17, 12, 16, 11865, 20, 12, 17, 11865, 22, 3057, 17, 1826, 490, 23744, 360, 6143, 29780, 334, 17, 378, 12, 20, 413, 12, 22, 446, 17, 5942, 304, 288, 291, 14, 629, 8, 478, 423, 362, 63, 4780, 63, 5159, 8, 17, 395, 334, 20, 14, 16, 12, 17, 14, 16, 395, 283, 22134, 485, 362, 63, 4780, 63, 5159, 358, 953, 327, 485, 409, 63, 4780, 288, 9100, 423, 409, 63, 4780, 8, 16, 12, 2801, 1400, 12, 821, 430, 288, 291, 14, 629, 8, 478, 14, 8032, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 20, 14, 16, 12, 17, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1826, 283, 22134, 485, 409, 63, 4780, 358, 953, 327, 485, 409, 63, 513, 288, 9100, 423, 409, 63, 513, 8, 18, 12, 334, 2801, 1400, 14, 16, 12, 821, 14, 16, 11865, 22, 14, 16, 3057, 17, 14, 16, 1724, 288, 291, 14, 629, 8, 478, 14, 8032, 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, 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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 ]
WingGao/mongo-python-driver
test/test_read_preferences.py
13
20145
# Copyright 2011-2015 MongoDB, 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. """Test the replica_set_connection module.""" import contextlib import copy import random import sys import pickle sys.path[0:0] = [""] from bson.py3compat import MAXSIZE from bson.son import SON from pymongo.errors import ConfigurationError from pymongo.message import _maybe_add_read_preference from pymongo.mongo_client import MongoClient from pymongo.read_preferences import (ReadPreference, MovingAverage, Primary, PrimaryPreferred, Secondary, SecondaryPreferred, Nearest, _ServerMode) from pymongo.server_description import ServerDescription from pymongo.server_selectors import readable_server_selector from pymongo.server_type import SERVER_TYPE from pymongo.write_concern import WriteConcern from test.test_replica_set_client import TestReplicaSetClientBase from test import (SkipTest, client_context, host, port, unittest, db_user, db_pwd) from test.utils import connected, single_client, one, wait_until, rs_client from test.version import Version class TestReadPreferenceObjects(unittest.TestCase): prefs = [Primary(), Secondary(), Nearest(tag_sets=[{'a': 1}, {'b': 2}])] def test_pickle(self): for pref in self.prefs: self.assertEqual(pref, pickle.loads(pickle.dumps(pref))) def test_copy(self): for pref in self.prefs: self.assertEqual(pref, copy.copy(pref)) class TestReadPreferencesBase(TestReplicaSetClientBase): def setUp(self): super(TestReadPreferencesBase, self).setUp() # Insert some data so we can use cursors in read_from_which_host self.client.pymongo_test.test.drop() self.client.get_database( "pymongo_test", write_concern=WriteConcern(w=self.w)).test.insert_many( [{'_id': i} for i in range(10)]) self.addCleanup(self.client.pymongo_test.test.drop) def read_from_which_host(self, client): """Do a find() on the client and return which host was used """ cursor = client.pymongo_test.test.find() next(cursor) return cursor.address def read_from_which_kind(self, client): """Do a find() on the client and return 'primary' or 'secondary' depending on which the client used. """ address = self.read_from_which_host(client) if address == client.primary: return 'primary' elif address in client.secondaries: return 'secondary' else: self.fail( 'Cursor used address %s, expected either primary ' '%s or secondaries %s' % ( address, client.primary, client.secondaries)) def assertReadsFrom(self, expected, **kwargs): c = rs_client(**kwargs) wait_until( lambda: len(c.nodes - c.arbiters) == self.w, "discovered all nodes") used = self.read_from_which_kind(c) self.assertEqual(expected, used, 'Cursor used %s, expected %s' % ( used, expected)) class TestSingleSlaveOk(TestReadPreferencesBase): def test_reads_from_secondary(self): host, port = next(iter(self.client.secondaries)) # Direct connection to a secondary. client = single_client(host, port) self.assertFalse(client.is_primary) # Regardless of read preference, we should be able to do # "reads" with a direct connection to a secondary. # See server-selection.rst#topology-type-single. self.assertEqual(client.read_preference, ReadPreference.PRIMARY) db = client.pymongo_test coll = db.test # Test find and find_one. self.assertIsNotNone(coll.find_one()) self.assertEqual(10, len(list(coll.find()))) # Test some database helpers. self.assertIsNotNone(db.collection_names()) self.assertIsNotNone(db.validate_collection("test")) self.assertIsNotNone(db.command("count", "test")) # Test some collection helpers. self.assertEqual(10, coll.count()) self.assertEqual(10, len(coll.distinct("_id"))) self.assertIsNotNone(coll.aggregate([])) self.assertIsNotNone(coll.index_information()) # Test some "magic" namespace helpers. self.assertIsNotNone(db.current_op()) client.unlock() # No error. class TestReadPreferences(TestReadPreferencesBase): def test_mode_validation(self): for mode in (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST): self.assertEqual( mode, rs_client(read_preference=mode).read_preference) self.assertRaises( TypeError, rs_client, read_preference='foo') def test_tag_sets_validation(self): # Can't use tags with PRIMARY self.assertRaises(ConfigurationError, _ServerMode, 0, tag_sets=[{'k': 'v'}]) # ... but empty tag sets are ok with PRIMARY self.assertRaises(ConfigurationError, _ServerMode, 0, tag_sets=[{}]) S = Secondary(tag_sets=[{}]) self.assertEqual( [{}], rs_client(read_preference=S).read_preference.tag_sets) S = Secondary(tag_sets=[{'k': 'v'}]) self.assertEqual( [{'k': 'v'}], rs_client(read_preference=S).read_preference.tag_sets) S = Secondary(tag_sets=[{'k': 'v'}, {}]) self.assertEqual( [{'k': 'v'}, {}], rs_client(read_preference=S).read_preference.tag_sets) self.assertRaises(ValueError, Secondary, tag_sets=[]) # One dict not ok, must be a list of dicts self.assertRaises(TypeError, Secondary, tag_sets={'k': 'v'}) self.assertRaises(TypeError, Secondary, tag_sets='foo') self.assertRaises(TypeError, Secondary, tag_sets=['foo']) def test_threshold_validation(self): self.assertEqual(17, rs_client( localThresholdMS=17 ).local_threshold_ms) self.assertEqual(42, rs_client( localThresholdMS=42 ).local_threshold_ms) self.assertEqual(666, rs_client( localthresholdms=666 ).local_threshold_ms) self.assertEqual(0, rs_client( localthresholdms=0 ).local_threshold_ms) self.assertRaises(ValueError, rs_client, localthresholdms=-1) def test_zero_latency(self): ping_times = set() # Generate unique ping times. while len(ping_times) < len(self.client.nodes): ping_times.add(random.random()) for ping_time, host in zip(ping_times, self.client.nodes): ServerDescription._host_to_round_trip_time[host] = ping_time try: client = connected( rs_client(readPreference='nearest', localThresholdMS=0)) wait_until( lambda: client.nodes == self.client.nodes, "discovered all nodes") host = self.read_from_which_host(client) for _ in range(5): self.assertEqual(host, self.read_from_which_host(client)) finally: ServerDescription._host_to_round_trip_time.clear() def test_primary(self): self.assertReadsFrom( 'primary', read_preference=ReadPreference.PRIMARY) def test_primary_with_tags(self): # Tags not allowed with PRIMARY self.assertRaises( ConfigurationError, rs_client, tag_sets=[{'dc': 'ny'}]) def test_primary_preferred(self): self.assertReadsFrom( 'primary', read_preference=ReadPreference.PRIMARY_PREFERRED) def test_secondary(self): self.assertReadsFrom( 'secondary', read_preference=ReadPreference.SECONDARY) def test_secondary_preferred(self): self.assertReadsFrom( 'secondary', read_preference=ReadPreference.SECONDARY_PREFERRED) def test_nearest(self): # With high localThresholdMS, expect to read from any # member c = rs_client( read_preference=ReadPreference.NEAREST, localThresholdMS=10000) # 10 seconds data_members = set(self.hosts).difference(set(self.arbiters)) # This is a probabilistic test; track which members we've read from so # far, and keep reading until we've used all the members or give up. # Chance of using only 2 of 3 members 10k times if there's no bug = # 3 * (2/3)**10000, very low. used = set() i = 0 while data_members.difference(used) and i < 10000: address = self.read_from_which_host(c) used.add(address) i += 1 not_used = data_members.difference(used) latencies = ', '.join( '%s: %dms' % (server.description.address, server.description.round_trip_time) for server in c._get_topology().select_servers( readable_server_selector)) self.assertFalse( not_used, "Expected to use primary and all secondaries for mode NEAREST," " but didn't use %s\nlatencies: %s" % (not_used, latencies)) class ReadPrefTester(MongoClient): def __init__(self, *args, **kwargs): self.has_read_from = set() super(ReadPrefTester, self).__init__(*args, **kwargs) @contextlib.contextmanager def _socket_for_reads(self, read_preference): context = super(ReadPrefTester, self)._socket_for_reads(read_preference) with context as (sock_info, slave_ok): self.record_a_read(sock_info.address) yield sock_info, slave_ok def record_a_read(self, address): server = self._get_topology().select_server_by_address(address, 0) self.has_read_from.add(server) _PREF_MAP = [ (Primary, SERVER_TYPE.RSPrimary), (PrimaryPreferred, SERVER_TYPE.RSPrimary), (Secondary, SERVER_TYPE.RSSecondary), (SecondaryPreferred, SERVER_TYPE.RSSecondary), (Nearest, 'any') ] class TestCommandAndReadPreference(TestReplicaSetClientBase): def setUp(self): super(TestCommandAndReadPreference, self).setUp() self.c = ReadPrefTester( '%s:%s' % (host, port), replicaSet=self.name, # Ignore round trip times, to test ReadPreference modes only. localThresholdMS=1000*1000) if client_context.auth_enabled: self.c.admin.authenticate(db_user, db_pwd) self.client_version = Version.from_client(self.c) self.addCleanup(self.c.drop_database, 'pymongo_test') def executed_on_which_server(self, client, fn, *args, **kwargs): """Execute fn(*args, **kwargs) and return the Server instance used.""" client.has_read_from.clear() fn(*args, **kwargs) self.assertEqual(1, len(client.has_read_from)) return one(client.has_read_from) def assertExecutedOn(self, server_type, client, fn, *args, **kwargs): server = self.executed_on_which_server(client, fn, *args, **kwargs) self.assertEqual(SERVER_TYPE._fields[server_type], SERVER_TYPE._fields[server.description.server_type]) def _test_fn(self, server_type, fn): for _ in range(10): if server_type == 'any': used = set() for _ in range(1000): server = self.executed_on_which_server(self.c, fn) used.add(server.description.address) if len(used) == len(self.c.secondaries) + 1: # Success break unused = self.c.secondaries.union( set([self.c.primary]) ).difference(used) if unused: self.fail( "Some members not used for NEAREST: %s" % ( unused)) else: self.assertExecutedOn(server_type, self.c, fn) def _test_primary_helper(self, func): # Helpers that ignore read preference. self._test_fn(SERVER_TYPE.RSPrimary, func) def _test_coll_helper(self, secondary_ok, coll, meth, *args, **kwargs): for mode, server_type in _PREF_MAP: new_coll = coll.with_options(read_preference=mode()) func = lambda: getattr(new_coll, meth)(*args, **kwargs) if secondary_ok: self._test_fn(server_type, func) else: self._test_fn(SERVER_TYPE.RSPrimary, func) def test_command(self): # Test that the generic command helper obeys the read preference # passed to it. for mode, server_type in _PREF_MAP: func = lambda: self.c.pymongo_test.command('dbStats', read_preference=mode()) self._test_fn(server_type, func) def test_create_collection(self): # Collections should be created on primary, obviously self._test_primary_helper( lambda: self.c.pymongo_test.create_collection( 'some_collection%s' % random.randint(0, MAXSIZE))) def test_drop_collection(self): self._test_primary_helper( lambda: self.c.pymongo_test.drop_collection('some_collection')) self._test_primary_helper( lambda: self.c.pymongo_test.some_collection.drop()) def test_group(self): self._test_coll_helper(True, self.c.pymongo_test.test, 'group', {'a': 1}, {}, {}, 'function() { }') def test_map_reduce(self): # mapreduce fails if no collection coll = self.c.pymongo_test.test.with_options( write_concern=WriteConcern(w=self.w)) coll.insert_one({}) self._test_coll_helper(False, self.c.pymongo_test.test, 'map_reduce', 'function() { }', 'function() { }', 'mr_out') self._test_coll_helper(False, self.c.pymongo_test.test, 'map_reduce', 'function() { }', 'function() { }', {'inline': 1}) def test_inline_map_reduce(self): # mapreduce fails if no collection coll = self.c.pymongo_test.test.with_options( write_concern=WriteConcern(w=self.w)) coll.insert_one({}) self._test_coll_helper(True, self.c.pymongo_test.test, 'inline_map_reduce', 'function() { }', 'function() { }') def test_count(self): self._test_coll_helper(True, self.c.pymongo_test.test, 'count') def test_distinct(self): self._test_coll_helper(True, self.c.pymongo_test.test, 'distinct', 'a') def test_aggregate(self): if self.client_version.at_least(2, 1, 0): self._test_coll_helper(True, self.c.pymongo_test.test, 'aggregate', [{'$project': {'_id': 1}}]) class TestMovingAverage(unittest.TestCase): def test_moving_average(self): avg = MovingAverage() self.assertIsNone(avg.get()) avg.add_sample(10) self.assertAlmostEqual(10, avg.get()) avg.add_sample(20) self.assertAlmostEqual(12, avg.get()) avg.add_sample(30) self.assertAlmostEqual(15.6, avg.get()) class TestMongosAndReadPreference(unittest.TestCase): def test_maybe_add_read_preference(self): # Primary doesn't add $readPreference out = _maybe_add_read_preference({}, Primary()) self.assertEqual(out, {}) pref = PrimaryPreferred() out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) pref = PrimaryPreferred(tag_sets=[{'dc': 'nyc'}]) out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) pref = Secondary() out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) pref = Secondary(tag_sets=[{'dc': 'nyc'}]) out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) # SecondaryPreferred without tag_sets doesn't add $readPreference pref = SecondaryPreferred() out = _maybe_add_read_preference({}, pref) self.assertEqual(out, {}) pref = SecondaryPreferred(tag_sets=[{'dc': 'nyc'}]) out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) pref = Nearest() out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) pref = Nearest(tag_sets=[{'dc': 'nyc'}]) out = _maybe_add_read_preference({}, pref) self.assertEqual( out, SON([("$query", {}), ("$readPreference", pref.document)])) criteria = SON([("$query", {}), ("$orderby", SON([("_id", 1)]))]) pref = Nearest() out = _maybe_add_read_preference(criteria, pref) self.assertEqual( out, SON([("$query", {}), ("$orderby", SON([("_id", 1)])), ("$readPreference", pref.document)])) pref = Nearest(tag_sets=[{'dc': 'nyc'}]) out = _maybe_add_read_preference(criteria, pref) self.assertEqual( out, SON([("$query", {}), ("$orderby", SON([("_id", 1)])), ("$readPreference", pref.document)])) @client_context.require_mongos def test_mongos(self): shard = client_context.client.config.shards.find_one()['host'] num_members = shard.count(',') + 1 if num_members == 1: raise SkipTest("Need a replica set shard to test.") coll = client_context.client.pymongo_test.get_collection( "test", write_concern=WriteConcern(w=num_members)) coll.drop() res = coll.insert_many([{} for _ in range(5)]) first_id = res.inserted_ids[0] last_id = res.inserted_ids[-1] # Note - this isn't a perfect test since there's no way to # tell what shard member a query ran on. for pref in (Primary(), PrimaryPreferred(), Secondary(), SecondaryPreferred(), Nearest()): qcoll = coll.with_options(read_preference=pref) results = list(qcoll.find().sort([("_id", 1)])) self.assertEqual(first_id, results[0]["_id"]) self.assertEqual(last_id, results[-1]["_id"]) results = list(qcoll.find().sort([("_id", -1)])) self.assertEqual(first_id, results[-1]["_id"]) self.assertEqual(last_id, results[0]["_id"]) if __name__ == "__main__": unittest.main()
apache-2.0
[ 3, 1898, 7760, 13, 7806, 28458, 12, 3277, 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, 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, 624, 774, 314, 16234, 63, 409, 63, 2105, 859, 1041, 199, 199, 646, 15502, 199, 646, 1331, 199, 646, 2196, 199, 646, 984, 199, 646, 5927, 199, 199, 1274, 14, 515, 59, 16, 26, 16, 61, 275, 359, 341, 61, 199, 199, 504, 330, 834, 14, 647, 19, 5819, 492, 9141, 4305, 199, 504, 330, 834, 14, 834, 492, 428, 615, 199, 504, 21878, 14, 2550, 492, 11595, 547, 199, 504, 21878, 14, 1188, 492, 485, 11853, 63, 525, 63, 739, 63, 14994, 199, 504, 21878, 14, 9217, 63, 1258, 492, 13503, 3041, 199, 504, 21878, 14, 739, 63, 18063, 492, 334, 3284, 25258, 12, 3930, 4007, 17400, 12, 4228, 26710, 12, 26710, 29373, 12, 4228, 16707, 695, 12, 16707, 695, 29373, 12, 4228, 5612, 9540, 12, 485, 3120, 1385, 9, 199, 504, 21878, 14, 1000, 63, 1802, 492, 7146, 5831, 199, 504, 21878, 14, 1000, 63, 6662, 83, 492, 12701, 63, 1000, 63, 6662, 199, 504, 21878, 14, 1000, 63, 466, 492, 23578, 63, 2711, 199, 504, 21878, 14, 952, 63, 388, 22082, 492, 6990, 714, 22082, 199, 199, 504, 511, 14, 396, 63, 12317, 63, 409, 63, 1258, 492, 1379, 29581, 1084, 3041, 1563, 199, 504, 511, 492, 334, 25755, 12, 2116, 1890, 63, 1100, 12, 2116, 1591, 12, 2116, 1844, 12, 2116, 2882, 12, 2116, 1592, 63, 751, 12, 2116, 1592, 63, 14258, 9, 199, 504, 511, 14, 1208, 492, 8539, 12, 2849, 63, 1258, 12, 1373, 12, 3618, 63, 8111, 12, 10717, 63, 1258, 199, 504, 511, 14, 1023, 492, 3394, 421, 199, 533, 1379, 3284, 25258, 11188, 8, 2796, 14, 1746, 304, 272, 28516, 275, 359, 14908, 1062, 16707, 695, 1062, 5612, 9540, 8, 1450, 63, 2193, 1524, 1445, 65, 356, 413, 1386, 791, 66, 356, 499, 93, 12457, 339, 347, 511, 63, 8092, 8, 277, 304, 267, 367, 20491, 315, 291, 14, 17253, 26, 288, 291, 14, 629, 8, 13829, 12, 5927, 14, 3640, 8, 8092, 14, 4180, 8, 13829, 1724, 339, 347, 511, 63, 1574, 8, 277, 304, 267, 367, 20491, 315, 291, 14, 17253, 26, 288, 291, 14, 629, 8, 13829, 12, 1331, 14, 1574, 8, 13829, 430, 421, 199, 533, 1379, 3284, 30772, 1563, 8, 774, 29581, 1084, 3041, 1563, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 3284, 30772, 1563, 12, 291, 680, 5996, 342, 267, 327, 15496, 2005, 666, 880, 781, 883, 675, 18809, 1384, 315, 1586, 63, 504, 63, 6777, 63, 1102, 267, 291, 14, 1258, 14, 29380, 63, 396, 14, 396, 14, 4824, 342, 267, 291, 14, 1258, 14, 362, 63, 4659, 8, 288, 298, 29380, 63, 396, 401, 288, 2218, 63, 388, 22082, 29, 3534, 714, 22082, 8, 87, 29, 277, 14, 87, 4992, 396, 14, 3176, 63, 3479, 8, 355, 9016, 63, 344, 356, 284, 93, 367, 284, 315, 1425, 8, 709, 3948, 398, 291, 14, 12808, 8, 277, 14, 1258, 14, 29380, 63, 396, 14, 396, 14, 4824, 9, 339, 347, 1586, 63, 504, 63, 6777, 63, 1102, 8, 277, 12, 1890, 304, 267, 408, 2585, 282, 2342, 342, 641, 314, 1890, 436, 372, 1314, 1591, 1990, 1202, 267, 408, 267, 3920, 275, 1890, 14, 29380, 63, 396, 14, 396, 14, 1623, 342, 267, 2163, 8, 3937, 9, 267, 372, 3920, 14, 1562, 339, 347, 1586, 63, 504, 63, 6777, 63, 5091, 8, 277, 12, 1890, 304, 267, 408, 2585, 282, 2342, 342, 641, 314, 1890, 436, 372, 283, 3327, 7, 503, 283, 12371, 7, 1779, 10298, 641, 1314, 314, 1890, 1202, 14, 267, 408, 267, 2287, 275, 291, 14, 739, 63, 504, 63, 6777, 63, 1102, 8, 1258, 9, 267, 340, 2287, 508, 1890, 14, 3327, 26, 288, 372, 283, 3327, 7, 267, 916, 2287, 315, 1890, 14, 4375, 3433, 26, 288, 372, 283, 12371, 7, 267, 587, 26, 288, 291, 14, 1633, 8, 355, 283, 8993, 1202, 2287, 450, 83, 12, 1420, 1902, 5062, 283, 355, 1543, 83, 503, 3499, 3433, 450, 83, 7, 450, 334, 490, 2287, 12, 1890, 14, 3327, 12, 1890, 14, 4375, 3433, 430, 339, 347, 702, 23614, 2532, 8, 277, 12, 1420, 12, 1011, 958, 304, 267, 286, 275, 10717, 63, 1258, 3682, 958, 9, 267, 3618, 63, 8111, 8, 288, 2400, 26, 822, 8, 67, 14, 2415, 446, 286, 14, 285, 4492, 878, 9, 508, 291, 14, 87, 12, 288, 298, 2297, 13560, 1006, 3380, 531, 398, 1202, 275, 291, 14, 739, 63, 504, 63, 6777, 63, 5091, 8, 67, 9, 267, 291, 14, 629, 8, 2062, 12, 1202, 12, 283, 8993, 1202, 450, 83, 12, 1420, 450, 83, 7, 450, 334, 288, 1202, 12, 1420, 430, 421, 199, 533, 1379, 7200, 28950, 11622, 8, 774, 3284, 30772, 1563, 304, 339, 347, 511, 63, 15656, 63, 504, 63, 12371, 8, 277, 304, 398, 1591, 12, 1844, 275, 2163, 8, 1661, 8, 277, 14, 1258, 14, 4375, 3433, 430, 267, 327, 21128, 1950, 370, 282, 13851, 14, 267, 1890, 275, 2849, 63, 1258, 8, 1102, 12, 1844, 9, 267, 291, 14, 3334, 8, 1258, 14, 374, 63, 3327, 9, 398, 327, 5044, 1005, 2003, 402, 1586, 16705, 12, 781, 1077, 506, 7688, 370, 886, 267, 327, 298, 15656, 2, 543, 282, 4125, 1950, 370, 282, 13851, 14, 267, 327, 1666, 1654, 13, 5592, 14, 8332, 3, 10775, 13, 466, 13, 4780, 14, 267, 291, 14, 629, 8 ]
[ 1898, 7760, 13, 7806, 28458, 12, 3277, 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, 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, 624, 774, 314, 16234, 63, 409, 63, 2105, 859, 1041, 199, 199, 646, 15502, 199, 646, 1331, 199, 646, 2196, 199, 646, 984, 199, 646, 5927, 199, 199, 1274, 14, 515, 59, 16, 26, 16, 61, 275, 359, 341, 61, 199, 199, 504, 330, 834, 14, 647, 19, 5819, 492, 9141, 4305, 199, 504, 330, 834, 14, 834, 492, 428, 615, 199, 504, 21878, 14, 2550, 492, 11595, 547, 199, 504, 21878, 14, 1188, 492, 485, 11853, 63, 525, 63, 739, 63, 14994, 199, 504, 21878, 14, 9217, 63, 1258, 492, 13503, 3041, 199, 504, 21878, 14, 739, 63, 18063, 492, 334, 3284, 25258, 12, 3930, 4007, 17400, 12, 4228, 26710, 12, 26710, 29373, 12, 4228, 16707, 695, 12, 16707, 695, 29373, 12, 4228, 5612, 9540, 12, 485, 3120, 1385, 9, 199, 504, 21878, 14, 1000, 63, 1802, 492, 7146, 5831, 199, 504, 21878, 14, 1000, 63, 6662, 83, 492, 12701, 63, 1000, 63, 6662, 199, 504, 21878, 14, 1000, 63, 466, 492, 23578, 63, 2711, 199, 504, 21878, 14, 952, 63, 388, 22082, 492, 6990, 714, 22082, 199, 199, 504, 511, 14, 396, 63, 12317, 63, 409, 63, 1258, 492, 1379, 29581, 1084, 3041, 1563, 199, 504, 511, 492, 334, 25755, 12, 2116, 1890, 63, 1100, 12, 2116, 1591, 12, 2116, 1844, 12, 2116, 2882, 12, 2116, 1592, 63, 751, 12, 2116, 1592, 63, 14258, 9, 199, 504, 511, 14, 1208, 492, 8539, 12, 2849, 63, 1258, 12, 1373, 12, 3618, 63, 8111, 12, 10717, 63, 1258, 199, 504, 511, 14, 1023, 492, 3394, 421, 199, 533, 1379, 3284, 25258, 11188, 8, 2796, 14, 1746, 304, 272, 28516, 275, 359, 14908, 1062, 16707, 695, 1062, 5612, 9540, 8, 1450, 63, 2193, 1524, 1445, 65, 356, 413, 1386, 791, 66, 356, 499, 93, 12457, 339, 347, 511, 63, 8092, 8, 277, 304, 267, 367, 20491, 315, 291, 14, 17253, 26, 288, 291, 14, 629, 8, 13829, 12, 5927, 14, 3640, 8, 8092, 14, 4180, 8, 13829, 1724, 339, 347, 511, 63, 1574, 8, 277, 304, 267, 367, 20491, 315, 291, 14, 17253, 26, 288, 291, 14, 629, 8, 13829, 12, 1331, 14, 1574, 8, 13829, 430, 421, 199, 533, 1379, 3284, 30772, 1563, 8, 774, 29581, 1084, 3041, 1563, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 3284, 30772, 1563, 12, 291, 680, 5996, 342, 267, 327, 15496, 2005, 666, 880, 781, 883, 675, 18809, 1384, 315, 1586, 63, 504, 63, 6777, 63, 1102, 267, 291, 14, 1258, 14, 29380, 63, 396, 14, 396, 14, 4824, 342, 267, 291, 14, 1258, 14, 362, 63, 4659, 8, 288, 298, 29380, 63, 396, 401, 288, 2218, 63, 388, 22082, 29, 3534, 714, 22082, 8, 87, 29, 277, 14, 87, 4992, 396, 14, 3176, 63, 3479, 8, 355, 9016, 63, 344, 356, 284, 93, 367, 284, 315, 1425, 8, 709, 3948, 398, 291, 14, 12808, 8, 277, 14, 1258, 14, 29380, 63, 396, 14, 396, 14, 4824, 9, 339, 347, 1586, 63, 504, 63, 6777, 63, 1102, 8, 277, 12, 1890, 304, 267, 408, 2585, 282, 2342, 342, 641, 314, 1890, 436, 372, 1314, 1591, 1990, 1202, 267, 408, 267, 3920, 275, 1890, 14, 29380, 63, 396, 14, 396, 14, 1623, 342, 267, 2163, 8, 3937, 9, 267, 372, 3920, 14, 1562, 339, 347, 1586, 63, 504, 63, 6777, 63, 5091, 8, 277, 12, 1890, 304, 267, 408, 2585, 282, 2342, 342, 641, 314, 1890, 436, 372, 283, 3327, 7, 503, 283, 12371, 7, 1779, 10298, 641, 1314, 314, 1890, 1202, 14, 267, 408, 267, 2287, 275, 291, 14, 739, 63, 504, 63, 6777, 63, 1102, 8, 1258, 9, 267, 340, 2287, 508, 1890, 14, 3327, 26, 288, 372, 283, 3327, 7, 267, 916, 2287, 315, 1890, 14, 4375, 3433, 26, 288, 372, 283, 12371, 7, 267, 587, 26, 288, 291, 14, 1633, 8, 355, 283, 8993, 1202, 2287, 450, 83, 12, 1420, 1902, 5062, 283, 355, 1543, 83, 503, 3499, 3433, 450, 83, 7, 450, 334, 490, 2287, 12, 1890, 14, 3327, 12, 1890, 14, 4375, 3433, 430, 339, 347, 702, 23614, 2532, 8, 277, 12, 1420, 12, 1011, 958, 304, 267, 286, 275, 10717, 63, 1258, 3682, 958, 9, 267, 3618, 63, 8111, 8, 288, 2400, 26, 822, 8, 67, 14, 2415, 446, 286, 14, 285, 4492, 878, 9, 508, 291, 14, 87, 12, 288, 298, 2297, 13560, 1006, 3380, 531, 398, 1202, 275, 291, 14, 739, 63, 504, 63, 6777, 63, 5091, 8, 67, 9, 267, 291, 14, 629, 8, 2062, 12, 1202, 12, 283, 8993, 1202, 450, 83, 12, 1420, 450, 83, 7, 450, 334, 288, 1202, 12, 1420, 430, 421, 199, 533, 1379, 7200, 28950, 11622, 8, 774, 3284, 30772, 1563, 304, 339, 347, 511, 63, 15656, 63, 504, 63, 12371, 8, 277, 304, 398, 1591, 12, 1844, 275, 2163, 8, 1661, 8, 277, 14, 1258, 14, 4375, 3433, 430, 267, 327, 21128, 1950, 370, 282, 13851, 14, 267, 1890, 275, 2849, 63, 1258, 8, 1102, 12, 1844, 9, 267, 291, 14, 3334, 8, 1258, 14, 374, 63, 3327, 9, 398, 327, 5044, 1005, 2003, 402, 1586, 16705, 12, 781, 1077, 506, 7688, 370, 886, 267, 327, 298, 15656, 2, 543, 282, 4125, 1950, 370, 282, 13851, 14, 267, 327, 1666, 1654, 13, 5592, 14, 8332, 3, 10775, 13, 466, 13, 4780, 14, 267, 291, 14, 629, 8, 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, 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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 ]
0x7678/youtube-dl
youtube_dl/extractor/muzu.py
147
2224
from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urllib_parse, ) class MuzuTVIE(InfoExtractor): _VALID_URL = r'https?://www\.muzu\.tv/(.+?)/(.+?)/(?P<id>\d+)' IE_NAME = 'muzu.tv' _TEST = { 'url': 'http://www.muzu.tv/defected/marcashken-featuring-sos-cat-walk-original-mix-music-video/1981454/', 'md5': '98f8b2c7bc50578d6a0364fff2bfb000', 'info_dict': { 'id': '1981454', 'ext': 'mp4', 'title': 'Cat Walk (Original Mix)', 'description': 'md5:90e868994de201b2570e4e5854e19420', 'uploader': 'MarcAshken featuring SOS', }, } def _real_extract(self, url): video_id = self._match_id(url) info_data = compat_urllib_parse.urlencode({ 'format': 'json', 'url': url, }) info = self._download_json( 'http://www.muzu.tv/api/oembed/?%s' % info_data, video_id, 'Downloading video info') player_info = self._download_json( 'http://player.muzu.tv/player/playerInit?ai=%s' % video_id, video_id, 'Downloading player info') video_info = player_info['videos'][0] for quality in ['1080', '720', '480', '360']: if video_info.get('v%s' % quality): break data = compat_urllib_parse.urlencode({ 'ai': video_id, # Even if each time you watch a video the hash changes, # it seems to work for different videos, and it will work # even if you use any non empty string as a hash 'viewhash': 'VBNff6djeV4HV5TRPW5kOHub2k', 'device': 'web', 'qv': quality, }) video_url_info = self._download_json( 'http://player.muzu.tv/player/requestVideo?%s' % data, video_id, 'Downloading video url') video_url = video_url_info['url'] return { 'id': video_id, 'title': info['title'], 'url': video_url, 'thumbnail': info['thumbnail_url'], 'description': info['description'], 'uploader': info['author_name'], }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 12, 199, 9, 421, 199, 533, 603, 9494, 85, 12764, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 1544, 4537, 6553, 90, 85, 4537, 6993, 7985, 11198, 15136, 11198, 2447, 2229, 48, 28, 344, 3072, 68, 29600, 272, 15292, 63, 2339, 275, 283, 6553, 90, 85, 14, 6993, 7, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 6553, 90, 85, 14, 6993, 15, 318, 6201, 15, 4584, 20084, 917, 13, 11873, 4039, 13, 83, 736, 13, 3385, 13, 7757, 13, 5043, 13, 13979, 13, 20544, 13, 3722, 15, 10905, 1079, 1477, 3678, 267, 283, 1064, 21, 356, 283, 2905, 70, 24, 66, 18, 67, 23, 3776, 1400, 14992, 68, 22, 65, 1644, 772, 18190, 18, 4361, 66, 1493, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 10905, 1079, 1477, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 21548, 644, 4878, 334, 17286, 603, 1148, 3196, 288, 283, 1802, 356, 283, 1064, 21, 26, 2710, 69, 15430, 14966, 271, 1797, 66, 821, 2760, 69, 20, 69, 2010, 1477, 69, 10860, 1165, 297, 288, 283, 13671, 356, 283, 45, 9912, 33, 609, 917, 13953, 4039, 428, 3100, 297, 267, 1660, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 2256, 63, 576, 275, 8434, 63, 4078, 63, 1122, 14, 10738, 2561, 288, 283, 908, 356, 283, 1001, 297, 288, 283, 633, 356, 1166, 12, 267, 3828, 267, 2256, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 1544, 14, 6553, 90, 85, 14, 6993, 15, 1246, 15, 79, 6427, 10197, 5, 83, 7, 450, 2256, 63, 576, 12, 288, 3991, 63, 344, 12, 283, 18085, 3991, 2256, 358, 398, 7748, 63, 815, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 6147, 14, 6553, 90, 85, 14, 6993, 15, 6147, 15, 6147, 9346, 31, 5789, 2458, 83, 7, 450, 3991, 63, 344, 12, 288, 3991, 63, 344, 12, 283, 18085, 7748, 2256, 358, 267, 3991, 63, 815, 275, 7748, 63, 815, 459, 11418, 3488, 16, 61, 267, 367, 11030, 315, 788, 23514, 297, 283, 18386, 297, 283, 21853, 297, 283, 11197, 2565, 288, 340, 3991, 63, 815, 14, 362, 360, 86, 5, 83, 7, 450, 11030, 304, 355, 2059, 398, 666, 275, 8434, 63, 4078, 63, 1122, 14, 10738, 2561, 288, 283, 5789, 356, 3991, 63, 344, 12, 288, 327, 22207, 340, 1924, 900, 1265, 9626, 282, 3991, 314, 2631, 4493, 12, 288, 327, 652, 12237, 370, 1736, 367, 3365, 22010, 12, 436, 652, 911, 1736, 288, 327, 2755, 340, 1265, 675, 1263, 2222, 2701, 1059, 465, 282, 2631, 288, 283, 1345, 2227, 356, 283, 54, 18273, 556, 22, 68, 6532, 54, 20, 16566, 21, 1766, 10780, 21, 75, 47, 15338, 18, 75, 297, 288, 283, 1782, 356, 283, 2520, 297, 288, 283, 81, 86, 356, 11030, 12, 267, 3828, 267, 3991, 63, 633, 63, 815, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 6147, 14, 6553, 90, 85, 14, 6993, 15, 6147, 15, 1069, 9166, 25790, 83, 7, 450, 666, 12, 288, 3991, 63, 344, 12, 283, 18085, 3991, 1166, 358, 267, 3991, 63, 633, 275, 3991, 63, 633, 63, 815, 459, 633, 418, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2256, 459, 1213, 995, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 2256, 459, 8311, 63, 633, 995, 288, 283, 1802, 356, 2256, 459, 1802, 995, 288, 283, 13671, 356, 2256, 459, 2502, 63, 354, 995, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 12, 199, 9, 421, 199, 533, 603, 9494, 85, 12764, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 1544, 4537, 6553, 90, 85, 4537, 6993, 7985, 11198, 15136, 11198, 2447, 2229, 48, 28, 344, 3072, 68, 29600, 272, 15292, 63, 2339, 275, 283, 6553, 90, 85, 14, 6993, 7, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 6553, 90, 85, 14, 6993, 15, 318, 6201, 15, 4584, 20084, 917, 13, 11873, 4039, 13, 83, 736, 13, 3385, 13, 7757, 13, 5043, 13, 13979, 13, 20544, 13, 3722, 15, 10905, 1079, 1477, 3678, 267, 283, 1064, 21, 356, 283, 2905, 70, 24, 66, 18, 67, 23, 3776, 1400, 14992, 68, 22, 65, 1644, 772, 18190, 18, 4361, 66, 1493, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 10905, 1079, 1477, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 21548, 644, 4878, 334, 17286, 603, 1148, 3196, 288, 283, 1802, 356, 283, 1064, 21, 26, 2710, 69, 15430, 14966, 271, 1797, 66, 821, 2760, 69, 20, 69, 2010, 1477, 69, 10860, 1165, 297, 288, 283, 13671, 356, 283, 45, 9912, 33, 609, 917, 13953, 4039, 428, 3100, 297, 267, 1660, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 2256, 63, 576, 275, 8434, 63, 4078, 63, 1122, 14, 10738, 2561, 288, 283, 908, 356, 283, 1001, 297, 288, 283, 633, 356, 1166, 12, 267, 3828, 267, 2256, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 1544, 14, 6553, 90, 85, 14, 6993, 15, 1246, 15, 79, 6427, 10197, 5, 83, 7, 450, 2256, 63, 576, 12, 288, 3991, 63, 344, 12, 283, 18085, 3991, 2256, 358, 398, 7748, 63, 815, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 6147, 14, 6553, 90, 85, 14, 6993, 15, 6147, 15, 6147, 9346, 31, 5789, 2458, 83, 7, 450, 3991, 63, 344, 12, 288, 3991, 63, 344, 12, 283, 18085, 7748, 2256, 358, 267, 3991, 63, 815, 275, 7748, 63, 815, 459, 11418, 3488, 16, 61, 267, 367, 11030, 315, 788, 23514, 297, 283, 18386, 297, 283, 21853, 297, 283, 11197, 2565, 288, 340, 3991, 63, 815, 14, 362, 360, 86, 5, 83, 7, 450, 11030, 304, 355, 2059, 398, 666, 275, 8434, 63, 4078, 63, 1122, 14, 10738, 2561, 288, 283, 5789, 356, 3991, 63, 344, 12, 288, 327, 22207, 340, 1924, 900, 1265, 9626, 282, 3991, 314, 2631, 4493, 12, 288, 327, 652, 12237, 370, 1736, 367, 3365, 22010, 12, 436, 652, 911, 1736, 288, 327, 2755, 340, 1265, 675, 1263, 2222, 2701, 1059, 465, 282, 2631, 288, 283, 1345, 2227, 356, 283, 54, 18273, 556, 22, 68, 6532, 54, 20, 16566, 21, 1766, 10780, 21, 75, 47, 15338, 18, 75, 297, 288, 283, 1782, 356, 283, 2520, 297, 288, 283, 81, 86, 356, 11030, 12, 267, 3828, 267, 3991, 63, 633, 63, 815, 275, 291, 423, 4249, 63, 1001, 8, 288, 283, 1014, 921, 6147, 14, 6553, 90, 85, 14, 6993, 15, 6147, 15, 1069, 9166, 25790, 83, 7, 450, 666, 12, 288, 3991, 63, 344, 12, 283, 18085, 3991, 1166, 358, 267, 3991, 63, 633, 275, 3991, 63, 633, 63, 815, 459, 633, 418, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2256, 459, 1213, 995, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 2256, 459, 8311, 63, 633, 995, 288, 283, 1802, 356, 2256, 459, 1802, 995, 288, 283, 13671, 356, 2256, 459, 2502, 63, 354, 995, 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, 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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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 ]
mdanielwork/intellij-community
python/testData/highlighting/awaitInGenerator.py
23
1205
async def f11(x): y = (await<error descr="expression expected"> </error>for await<error descr="expression expected"> </error>in []) # fail await x def f12(x): y = (await for await in []) return x async def f21(x): y = (mapper(await<error descr="expression expected">)</error> for await<error descr="expression expected"> </error>in []) # fail await x def f22(x): y = (mapper(await) for await in []) return x async def f31(x): await<error descr="expression expected"> </error>= [] # fail y = (i for i in await<error descr="expression expected">)</error> # fail await x def f32(x): await = [] y = (i for i in await) return x async def f41(x): y = (<error descr="Python version 3.5 does not support 'await' inside comprehensions">await</error> z for z in []) # fail await x async def f42(x): y = (mapper(<error descr="Python version 3.5 does not support 'await' inside comprehensions">await</error> z) for z in []) # fail await x async def f43(x): y = (z for <error descr="can't assign to await expression">await z</error> in []) # fail await x async def f44(x): y = (z for z in await x) await x
apache-2.0
[ 4146, 347, 289, 845, 8, 88, 304, 272, 612, 275, 334, 32365, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 30, 509, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 30, 262, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 318, 289, 713, 8, 88, 304, 272, 612, 275, 334, 32365, 367, 5517, 315, 3073, 272, 372, 671, 421, 199, 4146, 347, 289, 2025, 8, 88, 304, 272, 612, 275, 334, 7153, 8, 32365, 28, 705, 16193, 628, 5599, 1420, 1743, 15939, 705, 30, 367, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 30, 262, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 318, 289, 1081, 8, 88, 304, 272, 612, 275, 334, 7153, 8, 32365, 9, 367, 5517, 315, 3073, 272, 372, 671, 421, 199, 4146, 347, 289, 2192, 8, 88, 304, 272, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 8119, 942, 221, 327, 2449, 272, 612, 275, 334, 73, 367, 284, 315, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 15939, 705, 30, 221, 327, 2449, 272, 5517, 671, 421, 199, 318, 289, 708, 8, 88, 304, 272, 5517, 275, 942, 272, 612, 275, 334, 73, 367, 284, 315, 5517, 9, 272, 372, 671, 421, 199, 4146, 347, 289, 2953, 8, 88, 304, 272, 612, 275, 8642, 705, 16193, 628, 4718, 1015, 650, 14, 21, 1630, 440, 2291, 283, 32365, 7, 6272, 1013, 22868, 1356, 1743, 32365, 1108, 705, 30, 1315, 367, 1315, 315, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 4146, 347, 289, 2260, 8, 88, 304, 272, 612, 275, 334, 7153, 27530, 705, 16193, 628, 4718, 1015, 650, 14, 21, 1630, 440, 2291, 283, 32365, 7, 6272, 1013, 22868, 1356, 1743, 32365, 1108, 705, 30, 1315, 9, 367, 1315, 315, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 4146, 347, 289, 2824, 8, 88, 304, 272, 612, 275, 334, 90, 367, 665, 705, 16193, 628, 2425, 1133, 5090, 370, 5517, 3965, 1743, 32365, 1315, 1108, 705, 30, 315, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 4146, 347, 289, 1602, 8, 88, 304, 272, 612, 275, 334, 90, 367, 1315, 315, 5517, 671, 9, 272, 5517, 671, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 347, 289, 845, 8, 88, 304, 272, 612, 275, 334, 32365, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 30, 509, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 30, 262, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 318, 289, 713, 8, 88, 304, 272, 612, 275, 334, 32365, 367, 5517, 315, 3073, 272, 372, 671, 421, 199, 4146, 347, 289, 2025, 8, 88, 304, 272, 612, 275, 334, 7153, 8, 32365, 28, 705, 16193, 628, 5599, 1420, 1743, 15939, 705, 30, 367, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 30, 262, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 318, 289, 1081, 8, 88, 304, 272, 612, 275, 334, 7153, 8, 32365, 9, 367, 5517, 315, 3073, 272, 372, 671, 421, 199, 4146, 347, 289, 2192, 8, 88, 304, 272, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 3068, 705, 8119, 942, 221, 327, 2449, 272, 612, 275, 334, 73, 367, 284, 315, 5517, 28, 705, 16193, 628, 5599, 1420, 1743, 15939, 705, 30, 221, 327, 2449, 272, 5517, 671, 421, 199, 318, 289, 708, 8, 88, 304, 272, 5517, 275, 942, 272, 612, 275, 334, 73, 367, 284, 315, 5517, 9, 272, 372, 671, 421, 199, 4146, 347, 289, 2953, 8, 88, 304, 272, 612, 275, 8642, 705, 16193, 628, 4718, 1015, 650, 14, 21, 1630, 440, 2291, 283, 32365, 7, 6272, 1013, 22868, 1356, 1743, 32365, 1108, 705, 30, 1315, 367, 1315, 315, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 4146, 347, 289, 2260, 8, 88, 304, 272, 612, 275, 334, 7153, 27530, 705, 16193, 628, 4718, 1015, 650, 14, 21, 1630, 440, 2291, 283, 32365, 7, 6272, 1013, 22868, 1356, 1743, 32365, 1108, 705, 30, 1315, 9, 367, 1315, 315, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 4146, 347, 289, 2824, 8, 88, 304, 272, 612, 275, 334, 90, 367, 665, 705, 16193, 628, 2425, 1133, 5090, 370, 5517, 3965, 1743, 32365, 1315, 1108, 705, 30, 315, 3073, 221, 327, 2449, 272, 5517, 671, 421, 199, 4146, 347, 289, 1602, 8, 88, 304, 272, 612, 275, 334, 90, 367, 1315, 315, 5517, 671, 9, 272, 5517, 671, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
JeyZeta/Dangerous
Dangerous/sqlmap/thirdparty/chardet/euctwfreq.py
3133
34872
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client 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 ######################### # EUCTW frequency table # Converted from big5 work # by Taiwan's Mandarin Promotion Council # <http:#www.edu.tw:81/mandr/> # 128 --> 0.42261 # 256 --> 0.57851 # 512 --> 0.74851 # 1024 --> 0.89384 # 2048 --> 0.97583 # # Idea Distribution Ratio = 0.74851/(1-0.74851) =2.98 # Random Distribution Ration = 512/(5401-512)=0.105 # # Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR EUCTW_TYPICAL_DISTRIBUTION_RATIO = 0.75 # Char to FreqOrder table , EUCTW_TABLE_SIZE = 8102 EUCTWCharToFreqOrder = ( 1,1800,1506, 255,1431, 198, 9, 82, 6,7310, 177, 202,3615,1256,2808, 110, # 2742 3735, 33,3241, 261, 76, 44,2113, 16,2931,2184,1176, 659,3868, 26,3404,2643, # 2758 1198,3869,3313,4060, 410,2211, 302, 590, 361,1963, 8, 204, 58,4296,7311,1931, # 2774 63,7312,7313, 317,1614, 75, 222, 159,4061,2412,1480,7314,3500,3068, 224,2809, # 2790 3616, 3, 10,3870,1471, 29,2774,1135,2852,1939, 873, 130,3242,1123, 312,7315, # 2806 4297,2051, 507, 252, 682,7316, 142,1914, 124, 206,2932, 34,3501,3173, 64, 604, # 2822 7317,2494,1976,1977, 155,1990, 645, 641,1606,7318,3405, 337, 72, 406,7319, 80, # 2838 630, 238,3174,1509, 263, 939,1092,2644, 756,1440,1094,3406, 449, 69,2969, 591, # 2854 179,2095, 471, 115,2034,1843, 60, 50,2970, 134, 806,1868, 734,2035,3407, 180, # 2870 995,1607, 156, 537,2893, 688,7320, 319,1305, 779,2144, 514,2374, 298,4298, 359, # 2886 2495, 90,2707,1338, 663, 11, 906,1099,2545, 20,2436, 182, 532,1716,7321, 732, # 2902 1376,4062,1311,1420,3175, 25,2312,1056, 113, 399, 382,1949, 242,3408,2467, 529, # 2918 3243, 475,1447,3617,7322, 117, 21, 656, 810,1297,2295,2329,3502,7323, 126,4063, # 2934 706, 456, 150, 613,4299, 71,1118,2036,4064, 145,3069, 85, 835, 486,2114,1246, # 2950 1426, 428, 727,1285,1015, 800, 106, 623, 303,1281,7324,2127,2354, 347,3736, 221, # 2966 3503,3110,7325,1955,1153,4065, 83, 296,1199,3070, 192, 624, 93,7326, 822,1897, # 2982 2810,3111, 795,2064, 991,1554,1542,1592, 27, 43,2853, 859, 139,1456, 860,4300, # 2998 437, 712,3871, 164,2392,3112, 695, 211,3017,2096, 195,3872,1608,3504,3505,3618, # 3014 3873, 234, 811,2971,2097,3874,2229,1441,3506,1615,2375, 668,2076,1638, 305, 228, # 3030 1664,4301, 467, 415,7327, 262,2098,1593, 239, 108, 300, 200,1033, 512,1247,2077, # 3046 7328,7329,2173,3176,3619,2673, 593, 845,1062,3244, 88,1723,2037,3875,1950, 212, # 3062 266, 152, 149, 468,1898,4066,4302, 77, 187,7330,3018, 37, 5,2972,7331,3876, # 3078 7332,7333, 39,2517,4303,2894,3177,2078, 55, 148, 74,4304, 545, 483,1474,1029, # 3094 1665, 217,1869,1531,3113,1104,2645,4067, 24, 172,3507, 900,3877,3508,3509,4305, # 3110 32,1408,2811,1312, 329, 487,2355,2247,2708, 784,2674, 4,3019,3314,1427,1788, # 3126 188, 109, 499,7334,3620,1717,1789, 888,1217,3020,4306,7335,3510,7336,3315,1520, # 3142 3621,3878, 196,1034, 775,7337,7338, 929,1815, 249, 439, 38,7339,1063,7340, 794, # 3158 3879,1435,2296, 46, 178,3245,2065,7341,2376,7342, 214,1709,4307, 804, 35, 707, # 3174 324,3622,1601,2546, 140, 459,4068,7343,7344,1365, 839, 272, 978,2257,2572,3409, # 3190 2128,1363,3623,1423, 697, 100,3071, 48, 70,1231, 495,3114,2193,7345,1294,7346, # 3206 2079, 462, 586,1042,3246, 853, 256, 988, 185,2377,3410,1698, 434,1084,7347,3411, # 3222 314,2615,2775,4308,2330,2331, 569,2280, 637,1816,2518, 757,1162,1878,1616,3412, # 3238 287,1577,2115, 768,4309,1671,2854,3511,2519,1321,3737, 909,2413,7348,4069, 933, # 3254 3738,7349,2052,2356,1222,4310, 765,2414,1322, 786,4311,7350,1919,1462,1677,2895, # 3270 1699,7351,4312,1424,2437,3115,3624,2590,3316,1774,1940,3413,3880,4070, 309,1369, # 3286 1130,2812, 364,2230,1653,1299,3881,3512,3882,3883,2646, 525,1085,3021, 902,2000, # 3302 1475, 964,4313, 421,1844,1415,1057,2281, 940,1364,3116, 376,4314,4315,1381, 7, # 3318 2520, 983,2378, 336,1710,2675,1845, 321,3414, 559,1131,3022,2742,1808,1132,1313, # 3334 265,1481,1857,7352, 352,1203,2813,3247, 167,1089, 420,2814, 776, 792,1724,3513, # 3350 4071,2438,3248,7353,4072,7354, 446, 229, 333,2743, 901,3739,1200,1557,4316,2647, # 3366 1920, 395,2744,2676,3740,4073,1835, 125, 916,3178,2616,4317,7355,7356,3741,7357, # 3382 7358,7359,4318,3117,3625,1133,2547,1757,3415,1510,2313,1409,3514,7360,2145, 438, # 3398 2591,2896,2379,3317,1068, 958,3023, 461, 311,2855,2677,4074,1915,3179,4075,1978, # 3414 383, 750,2745,2617,4076, 274, 539, 385,1278,1442,7361,1154,1964, 384, 561, 210, # 3430 98,1295,2548,3515,7362,1711,2415,1482,3416,3884,2897,1257, 129,7363,3742, 642, # 3446 523,2776,2777,2648,7364, 141,2231,1333, 68, 176, 441, 876, 907,4077, 603,2592, # 3462 710, 171,3417, 404, 549, 18,3118,2393,1410,3626,1666,7365,3516,4319,2898,4320, # 3478 7366,2973, 368,7367, 146, 366, 99, 871,3627,1543, 748, 807,1586,1185, 22,2258, # 3494 379,3743,3180,7368,3181, 505,1941,2618,1991,1382,2314,7369, 380,2357, 218, 702, # 3510 1817,1248,3418,3024,3517,3318,3249,7370,2974,3628, 930,3250,3744,7371, 59,7372, # 3526 585, 601,4078, 497,3419,1112,1314,4321,1801,7373,1223,1472,2174,7374, 749,1836, # 3542 690,1899,3745,1772,3885,1476, 429,1043,1790,2232,2116, 917,4079, 447,1086,1629, # 3558 7375, 556,7376,7377,2020,1654, 844,1090, 105, 550, 966,1758,2815,1008,1782, 686, # 3574 1095,7378,2282, 793,1602,7379,3518,2593,4322,4080,2933,2297,4323,3746, 980,2496, # 3590 544, 353, 527,4324, 908,2678,2899,7380, 381,2619,1942,1348,7381,1341,1252, 560, # 3606 3072,7382,3420,2856,7383,2053, 973, 886,2080, 143,4325,7384,7385, 157,3886, 496, # 3622 4081, 57, 840, 540,2038,4326,4327,3421,2117,1445, 970,2259,1748,1965,2081,4082, # 3638 3119,1234,1775,3251,2816,3629, 773,1206,2129,1066,2039,1326,3887,1738,1725,4083, # 3654 279,3120, 51,1544,2594, 423,1578,2130,2066, 173,4328,1879,7386,7387,1583, 264, # 3670 610,3630,4329,2439, 280, 154,7388,7389,7390,1739, 338,1282,3073, 693,2857,1411, # 3686 1074,3747,2440,7391,4330,7392,7393,1240, 952,2394,7394,2900,1538,2679, 685,1483, # 3702 4084,2468,1436, 953,4085,2054,4331, 671,2395, 79,4086,2441,3252, 608, 567,2680, # 3718 3422,4087,4088,1691, 393,1261,1791,2396,7395,4332,7396,7397,7398,7399,1383,1672, # 3734 3748,3182,1464, 522,1119, 661,1150, 216, 675,4333,3888,1432,3519, 609,4334,2681, # 3750 2397,7400,7401,7402,4089,3025, 0,7403,2469, 315, 231,2442, 301,3319,4335,2380, # 3766 7404, 233,4090,3631,1818,4336,4337,7405, 96,1776,1315,2082,7406, 257,7407,1809, # 3782 3632,2709,1139,1819,4091,2021,1124,2163,2778,1777,2649,7408,3074, 363,1655,3183, # 3798 7409,2975,7410,7411,7412,3889,1567,3890, 718, 103,3184, 849,1443, 341,3320,2934, # 3814 1484,7413,1712, 127, 67, 339,4092,2398, 679,1412, 821,7414,7415, 834, 738, 351, # 3830 2976,2146, 846, 235,1497,1880, 418,1992,3749,2710, 186,1100,2147,2746,3520,1545, # 3846 1355,2935,2858,1377, 583,3891,4093,2573,2977,7416,1298,3633,1078,2549,3634,2358, # 3862 78,3750,3751, 267,1289,2099,2001,1594,4094, 348, 369,1274,2194,2175,1837,4338, # 3878 1820,2817,3635,2747,2283,2002,4339,2936,2748, 144,3321, 882,4340,3892,2749,3423, # 3894 4341,2901,7417,4095,1726, 320,7418,3893,3026, 788,2978,7419,2818,1773,1327,2859, # 3910 3894,2819,7420,1306,4342,2003,1700,3752,3521,2359,2650, 787,2022, 506, 824,3636, # 3926 534, 323,4343,1044,3322,2023,1900, 946,3424,7421,1778,1500,1678,7422,1881,4344, # 3942 165, 243,4345,3637,2521, 123, 683,4096, 764,4346, 36,3895,1792, 589,2902, 816, # 3958 626,1667,3027,2233,1639,1555,1622,3753,3896,7423,3897,2860,1370,1228,1932, 891, # 3974 2083,2903, 304,4097,7424, 292,2979,2711,3522, 691,2100,4098,1115,4347, 118, 662, # 3990 7425, 611,1156, 854,2381,1316,2861, 2, 386, 515,2904,7426,7427,3253, 868,2234, # 4006 1486, 855,2651, 785,2212,3028,7428,1040,3185,3523,7429,3121, 448,7430,1525,7431, # 4022 2164,4348,7432,3754,7433,4099,2820,3524,3122, 503, 818,3898,3123,1568, 814, 676, # 4038 1444, 306,1749,7434,3755,1416,1030, 197,1428, 805,2821,1501,4349,7435,7436,7437, # 4054 1993,7438,4350,7439,7440,2195, 13,2779,3638,2980,3124,1229,1916,7441,3756,2131, # 4070 7442,4100,4351,2399,3525,7443,2213,1511,1727,1120,7444,7445, 646,3757,2443, 307, # 4086 7446,7447,1595,3186,7448,7449,7450,3639,1113,1356,3899,1465,2522,2523,7451, 519, # 4102 7452, 128,2132, 92,2284,1979,7453,3900,1512, 342,3125,2196,7454,2780,2214,1980, # 4118 3323,7455, 290,1656,1317, 789, 827,2360,7456,3758,4352, 562, 581,3901,7457, 401, # 4134 4353,2248, 94,4354,1399,2781,7458,1463,2024,4355,3187,1943,7459, 828,1105,4101, # 4150 1262,1394,7460,4102, 605,4356,7461,1783,2862,7462,2822, 819,2101, 578,2197,2937, # 4166 7463,1502, 436,3254,4103,3255,2823,3902,2905,3425,3426,7464,2712,2315,7465,7466, # 4182 2332,2067, 23,4357, 193, 826,3759,2102, 699,1630,4104,3075, 390,1793,1064,3526, # 4198 7467,1579,3076,3077,1400,7468,4105,1838,1640,2863,7469,4358,4359, 137,4106, 598, # 4214 3078,1966, 780, 104, 974,2938,7470, 278, 899, 253, 402, 572, 504, 493,1339,7471, # 4230 3903,1275,4360,2574,2550,7472,3640,3029,3079,2249, 565,1334,2713, 863, 41,7473, # 4246 7474,4361,7475,1657,2333, 19, 463,2750,4107, 606,7476,2981,3256,1087,2084,1323, # 4262 2652,2982,7477,1631,1623,1750,4108,2682,7478,2864, 791,2714,2653,2334, 232,2416, # 4278 7479,2983,1498,7480,2654,2620, 755,1366,3641,3257,3126,2025,1609, 119,1917,3427, # 4294 862,1026,4109,7481,3904,3760,4362,3905,4363,2260,1951,2470,7482,1125, 817,4110, # 4310 4111,3906,1513,1766,2040,1487,4112,3030,3258,2824,3761,3127,7483,7484,1507,7485, # 4326 2683, 733, 40,1632,1106,2865, 345,4113, 841,2524, 230,4364,2984,1846,3259,3428, # 4342 7486,1263, 986,3429,7487, 735, 879, 254,1137, 857, 622,1300,1180,1388,1562,3907, # 4358 3908,2939, 967,2751,2655,1349, 592,2133,1692,3324,2985,1994,4114,1679,3909,1901, # 4374 2185,7488, 739,3642,2715,1296,1290,7489,4115,2198,2199,1921,1563,2595,2551,1870, # 4390 2752,2986,7490, 435,7491, 343,1108, 596, 17,1751,4365,2235,3430,3643,7492,4366, # 4406 294,3527,2940,1693, 477, 979, 281,2041,3528, 643,2042,3644,2621,2782,2261,1031, # 4422 2335,2134,2298,3529,4367, 367,1249,2552,7493,3530,7494,4368,1283,3325,2004, 240, # 4438 1762,3326,4369,4370, 836,1069,3128, 474,7495,2148,2525, 268,3531,7496,3188,1521, # 4454 1284,7497,1658,1546,4116,7498,3532,3533,7499,4117,3327,2684,1685,4118, 961,1673, # 4470 2622, 190,2005,2200,3762,4371,4372,7500, 570,2497,3645,1490,7501,4373,2623,3260, # 4486 1956,4374, 584,1514, 396,1045,1944,7502,4375,1967,2444,7503,7504,4376,3910, 619, # 4502 7505,3129,3261, 215,2006,2783,2553,3189,4377,3190,4378, 763,4119,3763,4379,7506, # 4518 7507,1957,1767,2941,3328,3646,1174, 452,1477,4380,3329,3130,7508,2825,1253,2382, # 4534 2186,1091,2285,4120, 492,7509, 638,1169,1824,2135,1752,3911, 648, 926,1021,1324, # 4550 4381, 520,4382, 997, 847,1007, 892,4383,3764,2262,1871,3647,7510,2400,1784,4384, # 4566 1952,2942,3080,3191,1728,4121,2043,3648,4385,2007,1701,3131,1551, 30,2263,4122, # 4582 7511,2026,4386,3534,7512, 501,7513,4123, 594,3431,2165,1821,3535,3432,3536,3192, # 4598 829,2826,4124,7514,1680,3132,1225,4125,7515,3262,4387,4126,3133,2336,7516,4388, # 4614 4127,7517,3912,3913,7518,1847,2383,2596,3330,7519,4389, 374,3914, 652,4128,4129, # 4630 375,1140, 798,7520,7521,7522,2361,4390,2264, 546,1659, 138,3031,2445,4391,7523, # 4646 2250, 612,1848, 910, 796,3765,1740,1371, 825,3766,3767,7524,2906,2554,7525, 692, # 4662 444,3032,2624, 801,4392,4130,7526,1491, 244,1053,3033,4131,4132, 340,7527,3915, # 4678 1041,2987, 293,1168, 87,1357,7528,1539, 959,7529,2236, 721, 694,4133,3768, 219, # 4694 1478, 644,1417,3331,2656,1413,1401,1335,1389,3916,7530,7531,2988,2362,3134,1825, # 4710 730,1515, 184,2827, 66,4393,7532,1660,2943, 246,3332, 378,1457, 226,3433, 975, # 4726 3917,2944,1264,3537, 674, 696,7533, 163,7534,1141,2417,2166, 713,3538,3333,4394, # 4742 3918,7535,7536,1186, 15,7537,1079,1070,7538,1522,3193,3539, 276,1050,2716, 758, # 4758 1126, 653,2945,3263,7539,2337, 889,3540,3919,3081,2989, 903,1250,4395,3920,3434, # 4774 3541,1342,1681,1718, 766,3264, 286, 89,2946,3649,7540,1713,7541,2597,3334,2990, # 4790 7542,2947,2215,3194,2866,7543,4396,2498,2526, 181, 387,1075,3921, 731,2187,3335, # 4806 7544,3265, 310, 313,3435,2299, 770,4134, 54,3034, 189,4397,3082,3769,3922,7545, # 4822 1230,1617,1849, 355,3542,4135,4398,3336, 111,4136,3650,1350,3135,3436,3035,4137, # 4838 2149,3266,3543,7546,2784,3923,3924,2991, 722,2008,7547,1071, 247,1207,2338,2471, # 4854 1378,4399,2009, 864,1437,1214,4400, 373,3770,1142,2216, 667,4401, 442,2753,2555, # 4870 3771,3925,1968,4138,3267,1839, 837, 170,1107, 934,1336,1882,7548,7549,2118,4139, # 4886 2828, 743,1569,7550,4402,4140, 582,2384,1418,3437,7551,1802,7552, 357,1395,1729, # 4902 3651,3268,2418,1564,2237,7553,3083,3772,1633,4403,1114,2085,4141,1532,7554, 482, # 4918 2446,4404,7555,7556,1492, 833,1466,7557,2717,3544,1641,2829,7558,1526,1272,3652, # 4934 4142,1686,1794, 416,2556,1902,1953,1803,7559,3773,2785,3774,1159,2316,7560,2867, # 4950 4405,1610,1584,3036,2419,2754, 443,3269,1163,3136,7561,7562,3926,7563,4143,2499, # 4966 3037,4406,3927,3137,2103,1647,3545,2010,1872,4144,7564,4145, 431,3438,7565, 250, # 4982 97, 81,4146,7566,1648,1850,1558, 160, 848,7567, 866, 740,1694,7568,2201,2830, # 4998 3195,4147,4407,3653,1687, 950,2472, 426, 469,3196,3654,3655,3928,7569,7570,1188, # 5014 424,1995, 861,3546,4148,3775,2202,2685, 168,1235,3547,4149,7571,2086,1674,4408, # 5030 3337,3270, 220,2557,1009,7572,3776, 670,2992, 332,1208, 717,7573,7574,3548,2447, # 5046 3929,3338,7575, 513,7576,1209,2868,3339,3138,4409,1080,7577,7578,7579,7580,2527, # 5062 3656,3549, 815,1587,3930,3931,7581,3550,3439,3777,1254,4410,1328,3038,1390,3932, # 5078 1741,3933,3778,3934,7582, 236,3779,2448,3271,7583,7584,3657,3780,1273,3781,4411, # 5094 7585, 308,7586,4412, 245,4413,1851,2473,1307,2575, 430, 715,2136,2449,7587, 270, # 5110 199,2869,3935,7588,3551,2718,1753, 761,1754, 725,1661,1840,4414,3440,3658,7589, # 5126 7590, 587, 14,3272, 227,2598, 326, 480,2265, 943,2755,3552, 291, 650,1883,7591, # 5142 1702,1226, 102,1547, 62,3441, 904,4415,3442,1164,4150,7592,7593,1224,1548,2756, # 5158 391, 498,1493,7594,1386,1419,7595,2055,1177,4416, 813, 880,1081,2363, 566,1145, # 5174 4417,2286,1001,1035,2558,2599,2238, 394,1286,7596,7597,2068,7598, 86,1494,1730, # 5190 3936, 491,1588, 745, 897,2948, 843,3340,3937,2757,2870,3273,1768, 998,2217,2069, # 5206 397,1826,1195,1969,3659,2993,3341, 284,7599,3782,2500,2137,2119,1903,7600,3938, # 5222 2150,3939,4151,1036,3443,1904, 114,2559,4152, 209,1527,7601,7602,2949,2831,2625, # 5238 2385,2719,3139, 812,2560,7603,3274,7604,1559, 737,1884,3660,1210, 885, 28,2686, # 5254 3553,3783,7605,4153,1004,1779,4418,7606, 346,1981,2218,2687,4419,3784,1742, 797, # 5270 1642,3940,1933,1072,1384,2151, 896,3941,3275,3661,3197,2871,3554,7607,2561,1958, # 5286 4420,2450,1785,7608,7609,7610,3942,4154,1005,1308,3662,4155,2720,4421,4422,1528, # 5302 2600, 161,1178,4156,1982, 987,4423,1101,4157, 631,3943,1157,3198,2420,1343,1241, # 5318 1016,2239,2562, 372, 877,2339,2501,1160, 555,1934, 911,3944,7611, 466,1170, 169, # 5334 1051,2907,2688,3663,2474,2994,1182,2011,2563,1251,2626,7612, 992,2340,3444,1540, # 5350 2721,1201,2070,2401,1996,2475,7613,4424, 528,1922,2188,1503,1873,1570,2364,3342, # 5366 3276,7614, 557,1073,7615,1827,3445,2087,2266,3140,3039,3084, 767,3085,2786,4425, # 5382 1006,4158,4426,2341,1267,2176,3664,3199, 778,3945,3200,2722,1597,2657,7616,4427, # 5398 7617,3446,7618,7619,7620,3277,2689,1433,3278, 131, 95,1504,3946, 723,4159,3141, # 5414 1841,3555,2758,2189,3947,2027,2104,3665,7621,2995,3948,1218,7622,3343,3201,3949, # 5430 4160,2576, 248,1634,3785, 912,7623,2832,3666,3040,3786, 654, 53,7624,2996,7625, # 5446 1688,4428, 777,3447,1032,3950,1425,7626, 191, 820,2120,2833, 971,4429, 931,3202, # 5462 135, 664, 783,3787,1997, 772,2908,1935,3951,3788,4430,2909,3203, 282,2723, 640, # 5478 1372,3448,1127, 922, 325,3344,7627,7628, 711,2044,7629,7630,3952,2219,2787,1936, # 5494 3953,3345,2220,2251,3789,2300,7631,4431,3790,1258,3279,3954,3204,2138,2950,3955, # 5510 3956,7632,2221, 258,3205,4432, 101,1227,7633,3280,1755,7634,1391,3281,7635,2910, # 5526 2056, 893,7636,7637,7638,1402,4161,2342,7639,7640,3206,3556,7641,7642, 878,1325, # 5542 1780,2788,4433, 259,1385,2577, 744,1183,2267,4434,7643,3957,2502,7644, 684,1024, # 5558 4162,7645, 472,3557,3449,1165,3282,3958,3959, 322,2152, 881, 455,1695,1152,1340, # 5574 660, 554,2153,4435,1058,4436,4163, 830,1065,3346,3960,4437,1923,7646,1703,1918, # 5590 7647, 932,2268, 122,7648,4438, 947, 677,7649,3791,2627, 297,1905,1924,2269,4439, # 5606 2317,3283,7650,7651,4164,7652,4165, 84,4166, 112, 989,7653, 547,1059,3961, 701, # 5622 3558,1019,7654,4167,7655,3450, 942, 639, 457,2301,2451, 993,2951, 407, 851, 494, # 5638 4440,3347, 927,7656,1237,7657,2421,3348, 573,4168, 680, 921,2911,1279,1874, 285, # 5654 790,1448,1983, 719,2167,7658,7659,4441,3962,3963,1649,7660,1541, 563,7661,1077, # 5670 7662,3349,3041,3451, 511,2997,3964,3965,3667,3966,1268,2564,3350,3207,4442,4443, # 5686 7663, 535,1048,1276,1189,2912,2028,3142,1438,1373,2834,2952,1134,2012,7664,4169, # 5702 1238,2578,3086,1259,7665, 700,7666,2953,3143,3668,4170,7667,4171,1146,1875,1906, # 5718 4444,2601,3967, 781,2422, 132,1589, 203, 147, 273,2789,2402, 898,1786,2154,3968, # 5734 3969,7668,3792,2790,7669,7670,4445,4446,7671,3208,7672,1635,3793, 965,7673,1804, # 5750 2690,1516,3559,1121,1082,1329,3284,3970,1449,3794, 65,1128,2835,2913,2759,1590, # 5766 3795,7674,7675, 12,2658, 45, 976,2579,3144,4447, 517,2528,1013,1037,3209,7676, # 5782 3796,2836,7677,3797,7678,3452,7679,2602, 614,1998,2318,3798,3087,2724,2628,7680, # 5798 2580,4172, 599,1269,7681,1810,3669,7682,2691,3088, 759,1060, 489,1805,3351,3285, # 5814 1358,7683,7684,2386,1387,1215,2629,2252, 490,7685,7686,4173,1759,2387,2343,7687, # 5830 4448,3799,1907,3971,2630,1806,3210,4449,3453,3286,2760,2344, 874,7688,7689,3454, # 5846 3670,1858, 91,2914,3671,3042,3800,4450,7690,3145,3972,2659,7691,3455,1202,1403, # 5862 3801,2954,2529,1517,2503,4451,3456,2504,7692,4452,7693,2692,1885,1495,1731,3973, # 5878 2365,4453,7694,2029,7695,7696,3974,2693,1216, 237,2581,4174,2319,3975,3802,4454, # 5894 4455,2694,3560,3457, 445,4456,7697,7698,7699,7700,2761, 61,3976,3672,1822,3977, # 5910 7701, 687,2045, 935, 925, 405,2660, 703,1096,1859,2725,4457,3978,1876,1367,2695, # 5926 3352, 918,2105,1781,2476, 334,3287,1611,1093,4458, 564,3146,3458,3673,3353, 945, # 5942 2631,2057,4459,7702,1925, 872,4175,7703,3459,2696,3089, 349,4176,3674,3979,4460, # 5958 3803,4177,3675,2155,3980,4461,4462,4178,4463,2403,2046, 782,3981, 400, 251,4179, # 5974 1624,7704,7705, 277,3676, 299,1265, 476,1191,3804,2121,4180,4181,1109, 205,7706, # 5990 2582,1000,2156,3561,1860,7707,7708,7709,4464,7710,4465,2565, 107,2477,2157,3982, # 6006 3460,3147,7711,1533, 541,1301, 158, 753,4182,2872,3562,7712,1696, 370,1088,4183, # 6022 4466,3563, 579, 327, 440, 162,2240, 269,1937,1374,3461, 968,3043, 56,1396,3090, # 6038 2106,3288,3354,7713,1926,2158,4467,2998,7714,3564,7715,7716,3677,4468,2478,7717, # 6054 2791,7718,1650,4469,7719,2603,7720,7721,3983,2661,3355,1149,3356,3984,3805,3985, # 6070 7722,1076, 49,7723, 951,3211,3289,3290, 450,2837, 920,7724,1811,2792,2366,4184, # 6086 1908,1138,2367,3806,3462,7725,3212,4470,1909,1147,1518,2423,4471,3807,7726,4472, # 6102 2388,2604, 260,1795,3213,7727,7728,3808,3291, 708,7729,3565,1704,7730,3566,1351, # 6118 1618,3357,2999,1886, 944,4185,3358,4186,3044,3359,4187,7731,3678, 422, 413,1714, # 6134 3292, 500,2058,2345,4188,2479,7732,1344,1910, 954,7733,1668,7734,7735,3986,2404, # 6150 4189,3567,3809,4190,7736,2302,1318,2505,3091, 133,3092,2873,4473, 629, 31,2838, # 6166 2697,3810,4474, 850, 949,4475,3987,2955,1732,2088,4191,1496,1852,7737,3988, 620, # 6182 3214, 981,1242,3679,3360,1619,3680,1643,3293,2139,2452,1970,1719,3463,2168,7738, # 6198 3215,7739,7740,3361,1828,7741,1277,4476,1565,2047,7742,1636,3568,3093,7743, 869, # 6214 2839, 655,3811,3812,3094,3989,3000,3813,1310,3569,4477,7744,7745,7746,1733, 558, # 6230 4478,3681, 335,1549,3045,1756,4192,3682,1945,3464,1829,1291,1192, 470,2726,2107, # 6246 2793, 913,1054,3990,7747,1027,7748,3046,3991,4479, 982,2662,3362,3148,3465,3216, # 6262 3217,1946,2794,7749, 571,4480,7750,1830,7751,3570,2583,1523,2424,7752,2089, 984, # 6278 4481,3683,1959,7753,3684, 852, 923,2795,3466,3685, 969,1519, 999,2048,2320,1705, # 6294 7754,3095, 615,1662, 151, 597,3992,2405,2321,1049, 275,4482,3686,4193, 568,3687, # 6310 3571,2480,4194,3688,7755,2425,2270, 409,3218,7756,1566,2874,3467,1002, 769,2840, # 6326 194,2090,3149,3689,2222,3294,4195, 628,1505,7757,7758,1763,2177,3001,3993, 521, # 6342 1161,2584,1787,2203,2406,4483,3994,1625,4196,4197, 412, 42,3096, 464,7759,2632, # 6358 4484,3363,1760,1571,2875,3468,2530,1219,2204,3814,2633,2140,2368,4485,4486,3295, # 6374 1651,3364,3572,7760,7761,3573,2481,3469,7762,3690,7763,7764,2271,2091, 460,7765, # 6390 4487,7766,3002, 962, 588,3574, 289,3219,2634,1116, 52,7767,3047,1796,7768,7769, # 6406 7770,1467,7771,1598,1143,3691,4198,1984,1734,1067,4488,1280,3365, 465,4489,1572, # 6422 510,7772,1927,2241,1812,1644,3575,7773,4490,3692,7774,7775,2663,1573,1534,7776, # 6438 7777,4199, 536,1807,1761,3470,3815,3150,2635,7778,7779,7780,4491,3471,2915,1911, # 6454 2796,7781,3296,1122, 377,3220,7782, 360,7783,7784,4200,1529, 551,7785,2059,3693, # 6470 1769,2426,7786,2916,4201,3297,3097,2322,2108,2030,4492,1404, 136,1468,1479, 672, # 6486 1171,3221,2303, 271,3151,7787,2762,7788,2049, 678,2727, 865,1947,4493,7789,2013, # 6502 3995,2956,7790,2728,2223,1397,3048,3694,4494,4495,1735,2917,3366,3576,7791,3816, # 6518 509,2841,2453,2876,3817,7792,7793,3152,3153,4496,4202,2531,4497,2304,1166,1010, # 6534 552, 681,1887,7794,7795,2957,2958,3996,1287,1596,1861,3154, 358, 453, 736, 175, # 6550 478,1117, 905,1167,1097,7796,1853,1530,7797,1706,7798,2178,3472,2287,3695,3473, # 6566 3577,4203,2092,4204,7799,3367,1193,2482,4205,1458,2190,2205,1862,1888,1421,3298, # 6582 2918,3049,2179,3474, 595,2122,7800,3997,7801,7802,4206,1707,2636, 223,3696,1359, # 6598 751,3098, 183,3475,7803,2797,3003, 419,2369, 633, 704,3818,2389, 241,7804,7805, # 6614 7806, 838,3004,3697,2272,2763,2454,3819,1938,2050,3998,1309,3099,2242,1181,7807, # 6630 1136,2206,3820,2370,1446,4207,2305,4498,7808,7809,4208,1055,2605, 484,3698,7810, # 6646 3999, 625,4209,2273,3368,1499,4210,4000,7811,4001,4211,3222,2274,2275,3476,7812, # 6662 7813,2764, 808,2606,3699,3369,4002,4212,3100,2532, 526,3370,3821,4213, 955,7814, # 6678 1620,4214,2637,2427,7815,1429,3700,1669,1831, 994, 928,7816,3578,1260,7817,7818, # 6694 7819,1948,2288, 741,2919,1626,4215,2729,2455, 867,1184, 362,3371,1392,7820,7821, # 6710 4003,4216,1770,1736,3223,2920,4499,4500,1928,2698,1459,1158,7822,3050,3372,2877, # 6726 1292,1929,2506,2842,3701,1985,1187,2071,2014,2607,4217,7823,2566,2507,2169,3702, # 6742 2483,3299,7824,3703,4501,7825,7826, 666,1003,3005,1022,3579,4218,7827,4502,1813, # 6758 2253, 574,3822,1603, 295,1535, 705,3823,4219, 283, 858, 417,7828,7829,3224,4503, # 6774 4504,3051,1220,1889,1046,2276,2456,4004,1393,1599, 689,2567, 388,4220,7830,2484, # 6790 802,7831,2798,3824,2060,1405,2254,7832,4505,3825,2109,1052,1345,3225,1585,7833, # 6806 809,7834,7835,7836, 575,2730,3477, 956,1552,1469,1144,2323,7837,2324,1560,2457, # 6822 3580,3226,4005, 616,2207,3155,2180,2289,7838,1832,7839,3478,4506,7840,1319,3704, # 6838 3705,1211,3581,1023,3227,1293,2799,7841,7842,7843,3826, 607,2306,3827, 762,2878, # 6854 1439,4221,1360,7844,1485,3052,7845,4507,1038,4222,1450,2061,2638,4223,1379,4508, # 6870 2585,7846,7847,4224,1352,1414,2325,2921,1172,7848,7849,3828,3829,7850,1797,1451, # 6886 7851,7852,7853,7854,2922,4006,4007,2485,2346, 411,4008,4009,3582,3300,3101,4509, # 6902 1561,2664,1452,4010,1375,7855,7856, 47,2959, 316,7857,1406,1591,2923,3156,7858, # 6918 1025,2141,3102,3157, 354,2731, 884,2224,4225,2407, 508,3706, 726,3583, 996,2428, # 6934 3584, 729,7859, 392,2191,1453,4011,4510,3707,7860,7861,2458,3585,2608,1675,2800, # 6950 919,2347,2960,2348,1270,4511,4012, 73,7862,7863, 647,7864,3228,2843,2255,1550, # 6966 1346,3006,7865,1332, 883,3479,7866,7867,7868,7869,3301,2765,7870,1212, 831,1347, # 6982 4226,4512,2326,3830,1863,3053, 720,3831,4513,4514,3832,7871,4227,7872,7873,4515, # 6998 7874,7875,1798,4516,3708,2609,4517,3586,1645,2371,7876,7877,2924, 669,2208,2665, # 7014 2429,7878,2879,7879,7880,1028,3229,7881,4228,2408,7882,2256,1353,7883,7884,4518, # 7030 3158, 518,7885,4013,7886,4229,1960,7887,2142,4230,7888,7889,3007,2349,2350,3833, # 7046 516,1833,1454,4014,2699,4231,4519,2225,2610,1971,1129,3587,7890,2766,7891,2961, # 7062 1422, 577,1470,3008,1524,3373,7892,7893, 432,4232,3054,3480,7894,2586,1455,2508, # 7078 2226,1972,1175,7895,1020,2732,4015,3481,4520,7896,2733,7897,1743,1361,3055,3482, # 7094 2639,4016,4233,4521,2290, 895, 924,4234,2170, 331,2243,3056, 166,1627,3057,1098, # 7110 7898,1232,2880,2227,3374,4522, 657, 403,1196,2372, 542,3709,3375,1600,4235,3483, # 7126 7899,4523,2767,3230, 576, 530,1362,7900,4524,2533,2666,3710,4017,7901, 842,3834, # 7142 7902,2801,2031,1014,4018, 213,2700,3376, 665, 621,4236,7903,3711,2925,2430,7904, # 7158 2431,3302,3588,3377,7905,4237,2534,4238,4525,3589,1682,4239,3484,1380,7906, 724, # 7174 2277, 600,1670,7907,1337,1233,4526,3103,2244,7908,1621,4527,7909, 651,4240,7910, # 7190 1612,4241,2611,7911,2844,7912,2734,2307,3058,7913, 716,2459,3059, 174,1255,2701, # 7206 4019,3590, 548,1320,1398, 728,4020,1574,7914,1890,1197,3060,4021,7915,3061,3062, # 7222 3712,3591,3713, 747,7916, 635,4242,4528,7917,7918,7919,4243,7920,7921,4529,7922, # 7238 3378,4530,2432, 451,7923,3714,2535,2072,4244,2735,4245,4022,7924,1764,4531,7925, # 7254 4246, 350,7926,2278,2390,2486,7927,4247,4023,2245,1434,4024, 488,4532, 458,4248, # 7270 4025,3715, 771,1330,2391,3835,2568,3159,2159,2409,1553,2667,3160,4249,7928,2487, # 7286 2881,2612,1720,2702,4250,3379,4533,7929,2536,4251,7930,3231,4252,2768,7931,2015, # 7302 2736,7932,1155,1017,3716,3836,7933,3303,2308, 201,1864,4253,1430,7934,4026,7935, # 7318 7936,7937,7938,7939,4254,1604,7940, 414,1865, 371,2587,4534,4535,3485,2016,3104, # 7334 4536,1708, 960,4255, 887, 389,2171,1536,1663,1721,7941,2228,4027,2351,2926,1580, # 7350 7942,7943,7944,1744,7945,2537,4537,4538,7946,4539,7947,2073,7948,7949,3592,3380, # 7366 2882,4256,7950,4257,2640,3381,2802, 673,2703,2460, 709,3486,4028,3593,4258,7951, # 7382 1148, 502, 634,7952,7953,1204,4540,3594,1575,4541,2613,3717,7954,3718,3105, 948, # 7398 3232, 121,1745,3837,1110,7955,4259,3063,2509,3009,4029,3719,1151,1771,3838,1488, # 7414 4030,1986,7956,2433,3487,7957,7958,2093,7959,4260,3839,1213,1407,2803, 531,2737, # 7430 2538,3233,1011,1537,7960,2769,4261,3106,1061,7961,3720,3721,1866,2883,7962,2017, # 7446 120,4262,4263,2062,3595,3234,2309,3840,2668,3382,1954,4542,7963,7964,3488,1047, # 7462 2704,1266,7965,1368,4543,2845, 649,3383,3841,2539,2738,1102,2846,2669,7966,7967, # 7478 1999,7968,1111,3596,2962,7969,2488,3842,3597,2804,1854,3384,3722,7970,7971,3385, # 7494 2410,2884,3304,3235,3598,7972,2569,7973,3599,2805,4031,1460, 856,7974,3600,7975, # 7510 2885,2963,7976,2886,3843,7977,4264, 632,2510, 875,3844,1697,3845,2291,7978,7979, # 7526 4544,3010,1239, 580,4545,4265,7980, 914, 936,2074,1190,4032,1039,2123,7981,7982, # 7542 7983,3386,1473,7984,1354,4266,3846,7985,2172,3064,4033, 915,3305,4267,4268,3306, # 7558 1605,1834,7986,2739, 398,3601,4269,3847,4034, 328,1912,2847,4035,3848,1331,4270, # 7574 3011, 937,4271,7987,3602,4036,4037,3387,2160,4546,3388, 524, 742, 538,3065,1012, # 7590 7988,7989,3849,2461,7990, 658,1103, 225,3850,7991,7992,4547,7993,4548,7994,3236, # 7606 1243,7995,4038, 963,2246,4549,7996,2705,3603,3161,7997,7998,2588,2327,7999,4550, # 7622 8000,8001,8002,3489,3307, 957,3389,2540,2032,1930,2927,2462, 870,2018,3604,1746, # 7638 2770,2771,2434,2463,8003,3851,8004,3723,3107,3724,3490,3390,3725,8005,1179,3066, # 7654 8006,3162,2373,4272,3726,2541,3163,3108,2740,4039,8007,3391,1556,2542,2292, 977, # 7670 2887,2033,4040,1205,3392,8008,1765,3393,3164,2124,1271,1689, 714,4551,3491,8009, # 7686 2328,3852, 533,4273,3605,2181, 617,8010,2464,3308,3492,2310,8011,8012,3165,8013, # 7702 8014,3853,1987, 618, 427,2641,3493,3394,8015,8016,1244,1690,8017,2806,4274,4552, # 7718 8018,3494,8019,8020,2279,1576, 473,3606,4275,3395, 972,8021,3607,8022,3067,8023, # 7734 8024,4553,4554,8025,3727,4041,4042,8026, 153,4555, 356,8027,1891,2888,4276,2143, # 7750 408, 803,2352,8028,3854,8029,4277,1646,2570,2511,4556,4557,3855,8030,3856,4278, # 7766 8031,2411,3396, 752,8032,8033,1961,2964,8034, 746,3012,2465,8035,4279,3728, 698, # 7782 4558,1892,4280,3608,2543,4559,3609,3857,8036,3166,3397,8037,1823,1302,4043,2706, # 7798 3858,1973,4281,8038,4282,3167, 823,1303,1288,1236,2848,3495,4044,3398, 774,3859, # 7814 8039,1581,4560,1304,2849,3860,4561,8040,2435,2161,1083,3237,4283,4045,4284, 344, # 7830 1173, 288,2311, 454,1683,8041,8042,1461,4562,4046,2589,8043,8044,4563, 985, 894, # 7846 8045,3399,3168,8046,1913,2928,3729,1988,8047,2110,1974,8048,4047,8049,2571,1194, # 7862 425,8050,4564,3169,1245,3730,4285,8051,8052,2850,8053, 636,4565,1855,3861, 760, # 7878 1799,8054,4286,2209,1508,4566,4048,1893,1684,2293,8055,8056,8057,4287,4288,2210, # 7894 479,8058,8059, 832,8060,4049,2489,8061,2965,2490,3731, 990,3109, 627,1814,2642, # 7910 4289,1582,4290,2125,2111,3496,4567,8062, 799,4291,3170,8063,4568,2112,1737,3013, # 7926 1018, 543, 754,4292,3309,1676,4569,4570,4050,8064,1489,8065,3497,8066,2614,2889, # 7942 4051,8067,8068,2966,8069,8070,8071,8072,3171,4571,4572,2182,1722,8073,3238,3239, # 7958 1842,3610,1715, 481, 365,1975,1856,8074,8075,1962,2491,4573,8076,2126,3611,3240, # 7974 433,1894,2063,2075,8077, 602,2741,8078,8079,8080,8081,8082,3014,1628,3400,8083, # 7990 3172,4574,4052,2890,4575,2512,8084,2544,2772,8085,8086,8087,3310,4576,2891,8088, # 8006 4577,8089,2851,4578,4579,1221,2967,4053,2513,8090,8091,8092,1867,1989,8093,8094, # 8022 8095,1895,8096,8097,4580,1896,4054, 318,8098,2094,4055,4293,8099,8100, 485,8101, # 8038 938,3862, 553,2670, 116,8102,3863,3612,8103,3498,2671,2773,3401,3311,2807,8104, # 8054 3613,2929,4056,1747,2930,2968,8105,8106, 207,8107,8108,2672,4581,2514,8109,3015, # 8070 890,3614,3864,8110,1877,3732,3402,8111,2183,2353,3403,1652,8112,8113,8114, 941, # 8086 2294, 208,3499,4057,2019, 330,4294,3865,2892,2492,3733,4295,8115,8116,8117,8118, # 8102 #Everything below is of no interest for detection purpose 2515,1613,4582,8119,3312,3866,2516,8120,4058,8121,1637,4059,2466,4583,3867,8122, # 8118 2493,3016,3734,8123,8124,2192,8125,8126,2162,8127,8128,8129,8130,8131,8132,8133, # 8134 8134,8135,8136,8137,8138,8139,8140,8141,8142,8143,8144,8145,8146,8147,8148,8149, # 8150 8150,8151,8152,8153,8154,8155,8156,8157,8158,8159,8160,8161,8162,8163,8164,8165, # 8166 8166,8167,8168,8169,8170,8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181, # 8182 8182,8183,8184,8185,8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197, # 8198 8198,8199,8200,8201,8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,8213, # 8214 8214,8215,8216,8217,8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,8228,8229, # 8230 8230,8231,8232,8233,8234,8235,8236,8237,8238,8239,8240,8241,8242,8243,8244,8245, # 8246 8246,8247,8248,8249,8250,8251,8252,8253,8254,8255,8256,8257,8258,8259,8260,8261, # 8262 8262,8263,8264,8265,8266,8267,8268,8269,8270,8271,8272,8273,8274,8275,8276,8277, # 8278 8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,8288,8289,8290,8291,8292,8293, # 8294 8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,8304,8305,8306,8307,8308,8309, # 8310 8310,8311,8312,8313,8314,8315,8316,8317,8318,8319,8320,8321,8322,8323,8324,8325, # 8326 8326,8327,8328,8329,8330,8331,8332,8333,8334,8335,8336,8337,8338,8339,8340,8341, # 8342 8342,8343,8344,8345,8346,8347,8348,8349,8350,8351,8352,8353,8354,8355,8356,8357, # 8358 8358,8359,8360,8361,8362,8363,8364,8365,8366,8367,8368,8369,8370,8371,8372,8373, # 8374 8374,8375,8376,8377,8378,8379,8380,8381,8382,8383,8384,8385,8386,8387,8388,8389, # 8390 8390,8391,8392,8393,8394,8395,8396,8397,8398,8399,8400,8401,8402,8403,8404,8405, # 8406 8406,8407,8408,8409,8410,8411,8412,8413,8414,8415,8416,8417,8418,8419,8420,8421, # 8422 8422,8423,8424,8425,8426,8427,8428,8429,8430,8431,8432,8433,8434,8435,8436,8437, # 8438 8438,8439,8440,8441,8442,8443,8444,8445,8446,8447,8448,8449,8450,8451,8452,8453, # 8454 8454,8455,8456,8457,8458,8459,8460,8461,8462,8463,8464,8465,8466,8467,8468,8469, # 8470 8470,8471,8472,8473,8474,8475,8476,8477,8478,8479,8480,8481,8482,8483,8484,8485, # 8486 8486,8487,8488,8489,8490,8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501, # 8502 8502,8503,8504,8505,8506,8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517, # 8518 8518,8519,8520,8521,8522,8523,8524,8525,8526,8527,8528,8529,8530,8531,8532,8533, # 8534 8534,8535,8536,8537,8538,8539,8540,8541,8542,8543,8544,8545,8546,8547,8548,8549, # 8550 8550,8551,8552,8553,8554,8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,8565, # 8566 8566,8567,8568,8569,8570,8571,8572,8573,8574,8575,8576,8577,8578,8579,8580,8581, # 8582 8582,8583,8584,8585,8586,8587,8588,8589,8590,8591,8592,8593,8594,8595,8596,8597, # 8598 8598,8599,8600,8601,8602,8603,8604,8605,8606,8607,8608,8609,8610,8611,8612,8613, # 8614 8614,8615,8616,8617,8618,8619,8620,8621,8622,8623,8624,8625,8626,8627,8628,8629, # 8630 8630,8631,8632,8633,8634,8635,8636,8637,8638,8639,8640,8641,8642,8643,8644,8645, # 8646 8646,8647,8648,8649,8650,8651,8652,8653,8654,8655,8656,8657,8658,8659,8660,8661, # 8662 8662,8663,8664,8665,8666,8667,8668,8669,8670,8671,8672,8673,8674,8675,8676,8677, # 8678 8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693, # 8694 8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709, # 8710 8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725, # 8726 8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741) # 8742 # flake8: noqa
mit
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 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, 3, 662, 27120, 9857, 1817, 199, 3, 11801, 471, 687, 7282, 21, 1736, 199, 3, 701, 377, 5789, 20444, 1159, 603, 460, 285, 262, 27724, 23193, 1849, 1097, 382, 199, 3, 665, 1014, 15596, 1544, 14, 8654, 14, 8122, 26, 2835, 15, 10333, 82, 3133, 199, 199, 3, 7960, 221, 10541, 378, 14, 23814, 2976, 199, 3, 7633, 221, 10541, 378, 14, 1641, 22740, 199, 3, 10574, 221, 10541, 378, 14, 1342, 22740, 199, 3, 6619, 10541, 378, 14, 1407, 8188, 199, 3, 18427, 10541, 378, 14, 2576, 16793, 199, 3, 199, 3, 473, 25395, 11839, 820, 32736, 275, 378, 14, 1342, 22740, 7985, 17, 13, 16, 14, 1342, 22740, 9, 275, 18, 14, 2905, 199, 3, 9571, 11839, 820, 425, 275, 10574, 7985, 1477, 614, 13, 7736, 23397, 16, 14, 7320, 199, 3, 199, 3, 29267, 11839, 820, 32736, 3595, 5661, 5, 402, 473, 21245, 1373, 12, 5139, 8298, 10948, 2419, 820, 4564, 199, 199, 37, 27120, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 378, 14, 2194, 199, 199, 3, 6659, 370, 481, 2103, 4738, 1817, 2360, 199, 37, 27120, 63, 8723, 63, 4305, 275, 1695, 7759, 199, 199, 37, 27120, 18139, 13875, 4738, 275, 334, 2043, 413, 12, 1085, 383, 12, 1046, 1690, 12, 5450, 12, 1079, 2192, 12, 413, 2905, 12, 257, 1749, 12, 221, 18051, 12, 257, 1227, 12, 2898, 709, 12, 413, 1138, 12, 19328, 12, 1344, 1046, 12, 713, 1367, 12, 18, 11292, 12, 16814, 12, 327, 499, 16498, 199, 1401, 1276, 12, 221, 9404, 12, 708, 2953, 12, 499, 2976, 12, 221, 14646, 12, 221, 10868, 12, 18, 9225, 12, 221, 3193, 12, 1398, 2192, 12, 9252, 20, 12, 31989, 12, 1227, 1427, 12, 8040, 24, 12, 221, 7875, 12, 1082, 966, 12, 9408, 19, 12, 327, 8087, 2010, 199, 845, 2905, 12, 8040, 25, 12, 1153, 969, 12, 13344, 16, 12, 32321, 12, 1081, 845, 12, 11485, 12, 959, 2710, 12, 650, 2976, 12, 1167, 2766, 12, 257, 1695, 12, 14785, 12, 221, 13713, 12, 20, 11700, 12, 2898, 845, 12, 1167, 2192, 12, 327, 499, 15464, 523, 13668, 12, 2898, 713, 12, 2898, 969, 12, 650, 1196, 12, 975, 1079, 12, 221, 13098, 12, 26485, 12, 413, 1427, 12, 13344, 17, 12, 1194, 713, 12, 1079, 1257, 12, 2898, 1079, 12, 1276, 383, 12, 1216, 2333, 12, 18565, 12, 18, 11782, 12, 327, 499, 22252, 199, 1344, 975, 12, 257, 650, 12, 221, 1616, 12, 12399, 16, 12, 1079, 3172, 12, 221, 7349, 12, 9963, 20, 12, 845, 1276, 12, 1651, 2528, 12, 1167, 1355, 12, 10513, 19, 12, 21334, 12, 708, 2260, 12, 17, 4288, 12, 650, 713, 12, 2898, 1046, 12, 327, 499, 11901, 199, 20, 12615, 12, 1165, 2869, 12, 959, 1780, 12, 27210, 12, 1227, 2564, 12, 2898, 975, 12, 31308, 12, 1167, 1079, 12, 25442, 12, 26761, 12, 1398, 708, 12, 221, 8177, 12, 1276, 614, 12, 19, 12478, 12, 221, 5049, 12, 1227, 966, 12, 327, 7294, 1081, 199, 2898, 1196, 12, 1194, 2635, 12, 1167, 2114, 12, 1167, 1138, 12, 29710, 12, 7155, 16, 12, 5049, 21, 12, 5049, 17, 12, 975, 1690, 12, 2898, 1085, 12, 1082, 1717, 12, 650, 1401, 12, 221, 15323, 12, 841, 1690, 12, 2898, 1167, 12, 221, 5939, 12, 327, 7294, 1703, 199, 1227, 1216, 12, 27077, 12, 19, 9892, 12, 1046, 1643, 12, 499, 2766, 12, 1749, 1355, 12, 709, 2942, 12, 9408, 20, 12, 1520, 1367, 12, 1079, 2167, 12, 709, 2635, 12, 1082, 1690, 12, 841, 1887, 12, 221, 14610, 12, 1398, 1876, 12, 959, 3328, 12, 327, 7294, 1477, 199, 31420, 12, 1165, 2720, 12, 841, 3172, 12, 22560, 12, 1165, 1082, 12, 1085, 2824, 12, 221, 5212, 12, 221, 5238, 12, 1398, 2760, 12, 25956, 12, 5939, 22, 12, 1085, 2333, 12, 1520, 1082, 12, 1165, 1276, 12, 1082, 1780, 12, 13576, 12, 327, 499, 15790, 199, 8806, 21, 12, 975, 1780, 12, 32609, 12, 959, 1401, 12, 18, 14590, 12, 1227, 1299, 12, 23, 12122, 12, 650, 1167, 12, 969, 1717, 12, 8375, 25, 12, 6886, 20, 12, 959, 1079, 12, 1789, 1342, 12, 499, 2905, 12, 20, 12877, 12, 650, 1427, 12, 327, 7294, 1184, 199, 1194, 2720, 12, 221, 9137, 12, 1465, 1780, 12, 969, 1703, 12, 1227, 2766, 12, 221, 4119, 12, 1749, 1690, 12, 709, 1020, 12, 821, 2322, 12, 221, 3388, 12, 1194, 1344, 12, 413, 2564, 12, 959, 708, 12, 1196, 975, 12, 23, 12638, 12, 1520, 708, 12, 327, 7349, 996, 199, 969, 2114, 12, 13344, 18, 12, 969, 845, 12, 1079, 1165, 12, 19, 10848, 12, 221, 5661, 12, 16909, 12 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 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, 3, 662, 27120, 9857, 1817, 199, 3, 11801, 471, 687, 7282, 21, 1736, 199, 3, 701, 377, 5789, 20444, 1159, 603, 460, 285, 262, 27724, 23193, 1849, 1097, 382, 199, 3, 665, 1014, 15596, 1544, 14, 8654, 14, 8122, 26, 2835, 15, 10333, 82, 3133, 199, 199, 3, 7960, 221, 10541, 378, 14, 23814, 2976, 199, 3, 7633, 221, 10541, 378, 14, 1641, 22740, 199, 3, 10574, 221, 10541, 378, 14, 1342, 22740, 199, 3, 6619, 10541, 378, 14, 1407, 8188, 199, 3, 18427, 10541, 378, 14, 2576, 16793, 199, 3, 199, 3, 473, 25395, 11839, 820, 32736, 275, 378, 14, 1342, 22740, 7985, 17, 13, 16, 14, 1342, 22740, 9, 275, 18, 14, 2905, 199, 3, 9571, 11839, 820, 425, 275, 10574, 7985, 1477, 614, 13, 7736, 23397, 16, 14, 7320, 199, 3, 199, 3, 29267, 11839, 820, 32736, 3595, 5661, 5, 402, 473, 21245, 1373, 12, 5139, 8298, 10948, 2419, 820, 4564, 199, 199, 37, 27120, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 275, 378, 14, 2194, 199, 199, 3, 6659, 370, 481, 2103, 4738, 1817, 2360, 199, 37, 27120, 63, 8723, 63, 4305, 275, 1695, 7759, 199, 199, 37, 27120, 18139, 13875, 4738, 275, 334, 2043, 413, 12, 1085, 383, 12, 1046, 1690, 12, 5450, 12, 1079, 2192, 12, 413, 2905, 12, 257, 1749, 12, 221, 18051, 12, 257, 1227, 12, 2898, 709, 12, 413, 1138, 12, 19328, 12, 1344, 1046, 12, 713, 1367, 12, 18, 11292, 12, 16814, 12, 327, 499, 16498, 199, 1401, 1276, 12, 221, 9404, 12, 708, 2953, 12, 499, 2976, 12, 221, 14646, 12, 221, 10868, 12, 18, 9225, 12, 221, 3193, 12, 1398, 2192, 12, 9252, 20, 12, 31989, 12, 1227, 1427, 12, 8040, 24, 12, 221, 7875, 12, 1082, 966, 12, 9408, 19, 12, 327, 8087, 2010, 199, 845, 2905, 12, 8040, 25, 12, 1153, 969, 12, 13344, 16, 12, 32321, 12, 1081, 845, 12, 11485, 12, 959, 2710, 12, 650, 2976, 12, 1167, 2766, 12, 257, 1695, 12, 14785, 12, 221, 13713, 12, 20, 11700, 12, 2898, 845, 12, 1167, 2192, 12, 327, 499, 15464, 523, 13668, 12, 2898, 713, 12, 2898, 969, 12, 650, 1196, 12, 975, 1079, 12, 221, 13098, 12, 26485, 12, 413, 1427, 12, 13344, 17, 12, 1194, 713, 12, 1079, 1257, 12, 2898, 1079, 12, 1276, 383, 12, 1216, 2333, 12, 18565, 12, 18, 11782, 12, 327, 499, 22252, 199, 1344, 975, 12, 257, 650, 12, 221, 1616, 12, 12399, 16, 12, 1079, 3172, 12, 221, 7349, 12, 9963, 20, 12, 845, 1276, 12, 1651, 2528, 12, 1167, 1355, 12, 10513, 19, 12, 21334, 12, 708, 2260, 12, 17, 4288, 12, 650, 713, 12, 2898, 1046, 12, 327, 499, 11901, 199, 20, 12615, 12, 1165, 2869, 12, 959, 1780, 12, 27210, 12, 1227, 2564, 12, 2898, 975, 12, 31308, 12, 1167, 1079, 12, 25442, 12, 26761, 12, 1398, 708, 12, 221, 8177, 12, 1276, 614, 12, 19, 12478, 12, 221, 5049, 12, 1227, 966, 12, 327, 7294, 1081, 199, 2898, 1196, 12, 1194, 2635, 12, 1167, 2114, 12, 1167, 1138, 12, 29710, 12, 7155, 16, 12, 5049, 21, 12, 5049, 17, 12, 975, 1690, 12, 2898, 1085, 12, 1082, 1717, 12, 650, 1401, 12, 221, 15323, 12, 841, 1690, 12, 2898, 1167, 12, 221, 5939, 12, 327, 7294, 1703, 199, 1227, 1216, 12, 27077, 12, 19, 9892, 12, 1046, 1643, 12, 499, 2766, 12, 1749, 1355, 12, 709, 2942, 12, 9408, 20, 12, 1520, 1367, 12, 1079, 2167, 12, 709, 2635, 12, 1082, 1690, 12, 841, 1887, 12, 221, 14610, 12, 1398, 1876, 12, 959, 3328, 12, 327, 7294, 1477, 199, 31420, 12, 1165, 2720, 12, 841, 3172, 12, 22560, 12, 1165, 1082, 12, 1085, 2824, 12, 221, 5212, 12, 221, 5238, 12, 1398, 2760, 12, 25956, 12, 5939, 22, 12, 1085, 2333, 12, 1520, 1082, 12, 1165, 1276, 12, 1082, 1780, 12, 13576, 12, 327, 499, 15790, 199, 8806, 21, 12, 975, 1780, 12, 32609, 12, 959, 1401, 12, 18, 14590, 12, 1227, 1299, 12, 23, 12122, 12, 650, 1167, 12, 969, 1717, 12, 8375, 25, 12, 6886, 20, 12, 959, 1079, 12, 1789, 1342, 12, 499, 2905, 12, 20, 12877, 12, 650, 1427, 12, 327, 7294, 1184, 199, 1194, 2720, 12, 221, 9137, 12, 1465, 1780, 12, 969, 1703, 12, 1227, 2766, 12, 221, 4119, 12, 1749, 1690, 12, 709, 1020, 12, 821, 2322, 12, 221, 3388, 12, 1194, 1344, 12, 413, 2564, 12, 959, 708, 12, 1196, 975, 12, 23, 12638, 12, 1520, 708, 12, 327, 7349, 996, 199, 969, 2114, 12, 13344, 18, 12, 969, 845, 12, 1079, 1165, 12, 19, 10848, 12, 221, 5661, 12, 16909, 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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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 ]
benoitsteiner/tensorflow-opencl
tensorflow/contrib/timeseries/python/timeseries/state_space_models/structural_ensemble_test.py
92
6385
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for the structural state space ensembles.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy from tensorflow.contrib import layers from tensorflow.contrib.layers.python.layers import feature_column from tensorflow.contrib.timeseries.python.timeseries import estimators from tensorflow.contrib.timeseries.python.timeseries import input_pipeline from tensorflow.contrib.timeseries.python.timeseries.feature_keys import TrainEvalFeatures from tensorflow.contrib.timeseries.python.timeseries.state_space_models import state_space_model from tensorflow.contrib.timeseries.python.timeseries.state_space_models import structural_ensemble from tensorflow.python.estimator import estimator_lib from tensorflow.python.framework import dtypes from tensorflow.python.platform import test class StructuralEnsembleEstimatorTests(test.TestCase): def simple_data(self, sample_every, dtype, period, num_samples, num_features): time = sample_every * numpy.arange(num_samples) noise = numpy.random.normal( scale=0.01, size=[num_samples, num_features]) values = noise + numpy.sin( numpy.arange(num_features)[None, ...] + time[..., None] / float(period) * 2.0 * numpy.pi).astype( dtype.as_numpy_dtype) return {TrainEvalFeatures.TIMES: numpy.reshape(time, [1, -1]), TrainEvalFeatures.VALUES: numpy.reshape( values, [1, -1, num_features])} def dry_run_train_helper( self, sample_every, period, num_samples, model_type, model_args, num_features=1): numpy.random.seed(1) dtype = dtypes.float32 features = self.simple_data( sample_every, dtype=dtype, period=period, num_samples=num_samples, num_features=num_features) model = model_type( configuration=( state_space_model.StateSpaceModelConfiguration( num_features=num_features, dtype=dtype, covariance_prior_fn=lambda _: 0.)), **model_args) class _RunConfig(estimator_lib.RunConfig): @property def tf_random_seed(self): return 4 estimator = estimators.StateSpaceRegressor(model, config=_RunConfig()) train_input_fn = input_pipeline.RandomWindowInputFn( input_pipeline.NumpyReader(features), num_threads=1, shuffle_seed=1, batch_size=16, window_size=16) eval_input_fn = input_pipeline.WholeDatasetInputFn( input_pipeline.NumpyReader(features)) estimator.train(input_fn=train_input_fn, max_steps=1) first_evaluation = estimator.evaluate(input_fn=eval_input_fn, steps=1) estimator.train(input_fn=train_input_fn, max_steps=3) second_evaluation = estimator.evaluate(input_fn=eval_input_fn, steps=1) self.assertLess(second_evaluation["loss"], first_evaluation["loss"]) def test_structural_multivariate(self): self.dry_run_train_helper( sample_every=3, period=5, num_samples=100, num_features=3, model_type=structural_ensemble.StructuralEnsemble, model_args={ "periodicities": 2, "moving_average_order": 2, "autoregressive_order": 1 }) def test_exogenous_input(self): """Test that no errors are raised when using exogenous features.""" dtype = dtypes.float64 times = [1, 2, 3, 4, 5, 6] values = [[0.01], [5.10], [5.21], [0.30], [5.41], [0.50]] feature_a = [["off"], ["on"], ["on"], ["off"], ["on"], ["off"]] sparse_column_a = feature_column.sparse_column_with_keys( column_name="feature_a", keys=["on", "off"]) one_hot_a = layers.one_hot_column(sparse_id_column=sparse_column_a) regressor = estimators.StructuralEnsembleRegressor( periodicities=[], num_features=1, moving_average_order=0, exogenous_feature_columns=[one_hot_a], dtype=dtype) features = {TrainEvalFeatures.TIMES: times, TrainEvalFeatures.VALUES: values, "feature_a": feature_a} train_input_fn = input_pipeline.RandomWindowInputFn( input_pipeline.NumpyReader(features), window_size=6, batch_size=1) regressor.train(input_fn=train_input_fn, steps=1) eval_input_fn = input_pipeline.WholeDatasetInputFn( input_pipeline.NumpyReader(features)) evaluation = regressor.evaluate(input_fn=eval_input_fn, steps=1) predict_input_fn = input_pipeline.predict_continuation_input_fn( evaluation, times=[[7, 8, 9]], exogenous_features={"feature_a": [[["on"], ["off"], ["on"]]]}) regressor.predict(input_fn=predict_input_fn) def test_no_periodicity(self): """Test that no errors are raised when periodicites is None.""" dtype = dtypes.float64 times = [1, 2, 3, 4, 5, 6] values = [[0.01], [5.10], [5.21], [0.30], [5.41], [0.50]] regressor = estimators.StructuralEnsembleRegressor( periodicities=None, num_features=1, moving_average_order=0, dtype=dtype) features = {TrainEvalFeatures.TIMES: times, TrainEvalFeatures.VALUES: values} train_input_fn = input_pipeline.RandomWindowInputFn( input_pipeline.NumpyReader(features), window_size=6, batch_size=1) regressor.train(input_fn=train_input_fn, steps=1) eval_input_fn = input_pipeline.WholeDatasetInputFn( input_pipeline.NumpyReader(features)) evaluation = regressor.evaluate(input_fn=eval_input_fn, steps=1) predict_input_fn = input_pipeline.predict_continuation_input_fn( evaluation, times=[[7, 8, 9]]) regressor.predict(input_fn=predict_input_fn) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 2702, 4889, 1174, 4601, 19965, 83, 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, 646, 2680, 199, 199, 504, 3228, 14, 2828, 492, 9393, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 3878, 63, 2301, 199, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 23155, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 1324, 63, 7379, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 4445, 63, 1612, 492, 16732, 10006, 10807, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 929, 63, 2638, 63, 992, 492, 1174, 63, 2638, 63, 1238, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 929, 63, 2638, 63, 992, 492, 2702, 4889, 63, 15628, 199, 199, 504, 3228, 14, 1548, 14, 8627, 492, 8943, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 13039, 4889, 1327, 8834, 13183, 2925, 8, 396, 14, 1746, 304, 819, 347, 3486, 63, 576, 8, 277, 12, 2690, 63, 14287, 12, 2152, 12, 6247, 12, 1967, 63, 3356, 12, 1967, 63, 3179, 304, 272, 900, 275, 2690, 63, 14287, 627, 2680, 14, 5605, 8, 1507, 63, 3356, 9, 272, 11145, 275, 2680, 14, 2355, 14, 3302, 8, 267, 4666, 29, 16, 14, 614, 12, 1568, 1524, 1507, 63, 3356, 12, 1967, 63, 3179, 566, 272, 1338, 275, 11145, 435, 2680, 14, 5911, 8, 267, 2680, 14, 5605, 8, 1507, 63, 3179, 2788, 403, 12, 21214, 267, 435, 900, 18999, 488, 61, 1182, 2069, 8, 5191, 9, 627, 499, 14, 16, 627, 2680, 14, 1038, 680, 6041, 8, 288, 2152, 14, 305, 63, 4714, 63, 2271, 9, 272, 372, 469, 18591, 10006, 10807, 14, 11342, 654, 26, 2680, 14, 5217, 8, 521, 12, 359, 17, 12, 446, 17, 2522, 288, 16732, 10006, 10807, 14, 15514, 26, 2680, 14, 5217, 8, 355, 1338, 12, 359, 17, 12, 446, 17, 12, 1967, 63, 3179, 566, 93, 819, 347, 9951, 63, 1065, 63, 2834, 63, 3676, 8, 489, 291, 12, 2690, 63, 14287, 12, 6247, 12, 1967, 63, 3356, 12, 1402, 63, 466, 12, 1402, 63, 589, 12, 489, 1967, 63, 3179, 29, 17, 304, 272, 2680, 14, 2355, 14, 5176, 8, 17, 9, 272, 2152, 275, 6674, 14, 1609, 708, 272, 4534, 275, 291, 14, 4129, 63, 576, 8, 267, 2690, 63, 14287, 12, 2152, 29, 2271, 12, 6247, 29, 5191, 12, 1967, 63, 3356, 29, 1507, 63, 3356, 12, 267, 1967, 63, 3179, 29, 1507, 63, 3179, 9, 272, 1402, 275, 1402, 63, 466, 8, 267, 2897, 2687, 288, 1174, 63, 2638, 63, 1238, 14, 2223, 7643, 1685, 5688, 8, 355, 1967, 63, 3179, 29, 1507, 63, 3179, 12, 355, 2152, 29, 2271, 12, 355, 13263, 63, 13775, 63, 2324, 29, 2734, 24700, 378, 14, 1826, 267, 1011, 1238, 63, 589, 9, 339, 1021, 485, 2540, 2028, 8, 8627, 63, 773, 14, 2540, 2028, 304, 2541, 768, 1829, 489, 347, 2833, 63, 2355, 63, 5176, 8, 277, 304, 267, 372, 841, 339, 8943, 275, 23155, 14, 2223, 7643, 15155, 8, 1238, 12, 1101, 3699, 2540, 2028, 1012, 272, 3560, 63, 1210, 63, 2324, 275, 1324, 63, 7379, 14, 3883, 4301, 3205, 9656, 8, 267, 1324, 63, 7379, 14, 25218, 5929, 8, 3179, 395, 1967, 63, 6962, 29, 17, 12, 13031, 63, 5176, 29, 17, 12, 267, 3522, 63, 890, 29, 975, 12, 4353, 63, 890, 29, 975, 9, 272, 3468, 63, 1210, 63, 2324, 275, 1324, 63, 7379, 14, 55, 16668, 9271, 3205, 9656, 8, 267, 1324, 63, 7379, 14, 25218, 5929, 8, 3179, 430, 272, 8943, 14, 2834, 8, 1210, 63, 2324, 29, 2834, 63, 1210, 63, 2324, 12, 1390, 63, 5895, 29, 17, 9, 272, 1642, 63, 19154, 275, 8943, 14, 7383, 8, 1210, 63, 2324, 29, 2579, 63, 1210, 63, 2324, 12, 7124, 29, 17, 9, 272, 8943, 14, 2834, 8, 1210, 63, 2324, 29, 2834, 63, 1210, 63, 2324, 12, 1390, 63, 5895, 29, 19, 9, 272, 3499, 63, 19154, 275, 8943, 14, 7383, 8, 1210, 63, 2324, 29, 2579, 63, 1210, 63, 2324, 12, 7124, 29, 17, 9, 272, 291, 14, 15625, 8, 4375, 63, 19154, 905, 4358, 2255, 1642, 63, 19154, 905, 4358, 3135, 819, 347, 511, 63, 1820, 4889, 63, 3029, 13805, 8, 277, 304, 272, 291, 14, 10481, 63, 1065, 63, 2834, 63, 3676, 8, 267, 2690, 63, 14287, 29, 19, 12, 267, 6247, 29, 21, 12, 267, 1967, 63, 3356, 29, 1960, 12, 267, 1967, 63, 3179, 29, 19, 12, 267, 1402, 63, 466, 29, 1820, 4889, 63, 15628, 14, 4836, 4889, 1327, 8834, 12, 267, 1402, 63, 589, 3126, 288, 298, 529, 2308, 328, 18207, 582, 499, 12, 288, 298, 7665, 63, 8536, 63, 1648, 582, 499, 12, 288, 298, 27082, 25787, 63, 1648, 582, 413, 267, 3828, 819, 347, 511, 63, 23919, 287, 1785, 63, 1210, 8, 277, 304, 272, 408, 774, 626, 949, 2552, 787, 4915, 1380, 1808, 444, 26300, 1785, 4534, 1041, 272, 2152, 275, 6674, 14, 1609, 772, 272, 5431, 275, 359, 17, 12 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 2702, 4889, 1174, 4601, 19965, 83, 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, 646, 2680, 199, 199, 504, 3228, 14, 2828, 492, 9393, 199, 504, 3228, 14, 2828, 14, 4359, 14, 1548, 14, 4359, 492, 3878, 63, 2301, 199, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 23155, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 492, 1324, 63, 7379, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 4445, 63, 1612, 492, 16732, 10006, 10807, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 929, 63, 2638, 63, 992, 492, 1174, 63, 2638, 63, 1238, 199, 504, 3228, 14, 2828, 14, 28551, 14, 1548, 14, 28551, 14, 929, 63, 2638, 63, 992, 492, 2702, 4889, 63, 15628, 199, 199, 504, 3228, 14, 1548, 14, 8627, 492, 8943, 63, 773, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 13039, 4889, 1327, 8834, 13183, 2925, 8, 396, 14, 1746, 304, 819, 347, 3486, 63, 576, 8, 277, 12, 2690, 63, 14287, 12, 2152, 12, 6247, 12, 1967, 63, 3356, 12, 1967, 63, 3179, 304, 272, 900, 275, 2690, 63, 14287, 627, 2680, 14, 5605, 8, 1507, 63, 3356, 9, 272, 11145, 275, 2680, 14, 2355, 14, 3302, 8, 267, 4666, 29, 16, 14, 614, 12, 1568, 1524, 1507, 63, 3356, 12, 1967, 63, 3179, 566, 272, 1338, 275, 11145, 435, 2680, 14, 5911, 8, 267, 2680, 14, 5605, 8, 1507, 63, 3179, 2788, 403, 12, 21214, 267, 435, 900, 18999, 488, 61, 1182, 2069, 8, 5191, 9, 627, 499, 14, 16, 627, 2680, 14, 1038, 680, 6041, 8, 288, 2152, 14, 305, 63, 4714, 63, 2271, 9, 272, 372, 469, 18591, 10006, 10807, 14, 11342, 654, 26, 2680, 14, 5217, 8, 521, 12, 359, 17, 12, 446, 17, 2522, 288, 16732, 10006, 10807, 14, 15514, 26, 2680, 14, 5217, 8, 355, 1338, 12, 359, 17, 12, 446, 17, 12, 1967, 63, 3179, 566, 93, 819, 347, 9951, 63, 1065, 63, 2834, 63, 3676, 8, 489, 291, 12, 2690, 63, 14287, 12, 6247, 12, 1967, 63, 3356, 12, 1402, 63, 466, 12, 1402, 63, 589, 12, 489, 1967, 63, 3179, 29, 17, 304, 272, 2680, 14, 2355, 14, 5176, 8, 17, 9, 272, 2152, 275, 6674, 14, 1609, 708, 272, 4534, 275, 291, 14, 4129, 63, 576, 8, 267, 2690, 63, 14287, 12, 2152, 29, 2271, 12, 6247, 29, 5191, 12, 1967, 63, 3356, 29, 1507, 63, 3356, 12, 267, 1967, 63, 3179, 29, 1507, 63, 3179, 9, 272, 1402, 275, 1402, 63, 466, 8, 267, 2897, 2687, 288, 1174, 63, 2638, 63, 1238, 14, 2223, 7643, 1685, 5688, 8, 355, 1967, 63, 3179, 29, 1507, 63, 3179, 12, 355, 2152, 29, 2271, 12, 355, 13263, 63, 13775, 63, 2324, 29, 2734, 24700, 378, 14, 1826, 267, 1011, 1238, 63, 589, 9, 339, 1021, 485, 2540, 2028, 8, 8627, 63, 773, 14, 2540, 2028, 304, 2541, 768, 1829, 489, 347, 2833, 63, 2355, 63, 5176, 8, 277, 304, 267, 372, 841, 339, 8943, 275, 23155, 14, 2223, 7643, 15155, 8, 1238, 12, 1101, 3699, 2540, 2028, 1012, 272, 3560, 63, 1210, 63, 2324, 275, 1324, 63, 7379, 14, 3883, 4301, 3205, 9656, 8, 267, 1324, 63, 7379, 14, 25218, 5929, 8, 3179, 395, 1967, 63, 6962, 29, 17, 12, 13031, 63, 5176, 29, 17, 12, 267, 3522, 63, 890, 29, 975, 12, 4353, 63, 890, 29, 975, 9, 272, 3468, 63, 1210, 63, 2324, 275, 1324, 63, 7379, 14, 55, 16668, 9271, 3205, 9656, 8, 267, 1324, 63, 7379, 14, 25218, 5929, 8, 3179, 430, 272, 8943, 14, 2834, 8, 1210, 63, 2324, 29, 2834, 63, 1210, 63, 2324, 12, 1390, 63, 5895, 29, 17, 9, 272, 1642, 63, 19154, 275, 8943, 14, 7383, 8, 1210, 63, 2324, 29, 2579, 63, 1210, 63, 2324, 12, 7124, 29, 17, 9, 272, 8943, 14, 2834, 8, 1210, 63, 2324, 29, 2834, 63, 1210, 63, 2324, 12, 1390, 63, 5895, 29, 19, 9, 272, 3499, 63, 19154, 275, 8943, 14, 7383, 8, 1210, 63, 2324, 29, 2579, 63, 1210, 63, 2324, 12, 7124, 29, 17, 9, 272, 291, 14, 15625, 8, 4375, 63, 19154, 905, 4358, 2255, 1642, 63, 19154, 905, 4358, 3135, 819, 347, 511, 63, 1820, 4889, 63, 3029, 13805, 8, 277, 304, 272, 291, 14, 10481, 63, 1065, 63, 2834, 63, 3676, 8, 267, 2690, 63, 14287, 29, 19, 12, 267, 6247, 29, 21, 12, 267, 1967, 63, 3356, 29, 1960, 12, 267, 1967, 63, 3179, 29, 19, 12, 267, 1402, 63, 466, 29, 1820, 4889, 63, 15628, 14, 4836, 4889, 1327, 8834, 12, 267, 1402, 63, 589, 3126, 288, 298, 529, 2308, 328, 18207, 582, 499, 12, 288, 298, 7665, 63, 8536, 63, 1648, 582, 499, 12, 288, 298, 27082, 25787, 63, 1648, 582, 413, 267, 3828, 819, 347, 511, 63, 23919, 287, 1785, 63, 1210, 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 ]
chen0510566/MissionPlanner
Lib/site-packages/numpy/distutils/mingw32ccompiler.py
76
19091
""" Support code for building Python extensions on Windows. # NT stuff # 1. Make sure libpython<version>.a exists for gcc. If not, build it. # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) # 3. Force windows to use g77 """ import os import subprocess import sys import subprocess import re # Overwrite certain distutils.ccompiler functions: import numpy.distutils.ccompiler if sys.version_info[0] < 3: import log else: from numpy.distutils import log # NT stuff # 1. Make sure libpython<version>.a exists for gcc. If not, build it. # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) # --> this is done in numpy/distutils/ccompiler.py # 3. Force windows to use g77 import distutils.cygwinccompiler from distutils.version import StrictVersion from numpy.distutils.ccompiler import gen_preprocess_options, gen_lib_options from distutils.errors import DistutilsExecError, CompileError, UnknownFileError from distutils.unixccompiler import UnixCCompiler from distutils.msvccompiler import get_build_version as get_build_msvc_version from numpy.distutils.misc_util import msvc_runtime_library, get_build_architecture # Useful to generate table of symbols from a dll _START = re.compile(r'\[Ordinal/Name Pointer\] Table') _TABLE = re.compile(r'^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)') # the same as cygwin plus some additional parameters class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler): """ A modified MingW32 compiler compatible with an MSVC built Python. """ compiler_type = 'mingw32' def __init__ (self, verbose=0, dry_run=0, force=0): distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose,dry_run, force) # we need to support 3.2 which doesn't match the standard # get_versions methods regex if self.gcc_version is None: import re p = subprocess.Popen(['gcc', '-dumpversion'], shell=True, stdout=subprocess.PIPE) out_string = p.stdout.read() p.stdout.close() result = re.search('(\d+\.\d+)',out_string) if result: self.gcc_version = StrictVersion(result.group(1)) # A real mingw32 doesn't need to specify a different entry point, # but cygwin 2.91.57 in no-cygwin-mode needs it. if self.gcc_version <= "2.91.57": entry_point = '--entry _DllMain@12' else: entry_point = '' if self.linker_dll == 'dllwrap': # Commented out '--driver-name g++' part that fixes weird # g++.exe: g++: No such file or directory # error (mingw 1.0 in Enthon24 tree, gcc-3.4.5). # If the --driver-name part is required for some environment # then make the inclusion of this part specific to that environment. self.linker = 'dllwrap' # --driver-name g++' elif self.linker_dll == 'gcc': self.linker = 'g++' # **changes: eric jones 4/11/01 # 1. Check for import library on Windows. Build if it doesn't exist. build_import_library() # **changes: eric jones 4/11/01 # 2. increased optimization and turned off all warnings # 3. also added --driver-name g++ #self.set_executables(compiler='gcc -mno-cygwin -O2 -w', # compiler_so='gcc -mno-cygwin -mdll -O2 -w', # linker_exe='gcc -mno-cygwin', # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' # % (self.linker, entry_point)) # MS_WIN64 should be defined when building for amd64 on windows, but # python headers define it only for MS compilers, which has all kind of # bad consequences, like using Py_ModuleInit4 instead of # Py_ModuleInit4_64, etc... So we add it here if get_build_architecture() == 'AMD64': if self.gcc_version < "4.": self.set_executables( compiler='gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall', compiler_so='gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypes', linker_exe='gcc -g -mno-cygwin', linker_so='gcc -g -mno-cygwin -shared') else: # gcc-4 series releases do not support -mno-cygwin option self.set_executables( compiler='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall', compiler_so='gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes', linker_exe='gcc -g', linker_so='gcc -g -shared') else: if self.gcc_version <= "3.0.0": self.set_executables(compiler='gcc -mno-cygwin -O2 -w', compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes', linker_exe='g++ -mno-cygwin', linker_so='%s -mno-cygwin -mdll -static %s' % (self.linker, entry_point)) elif self.gcc_version < "4.": self.set_executables(compiler='gcc -mno-cygwin -O2 -Wall', compiler_so='gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes', linker_exe='g++ -mno-cygwin', linker_so='g++ -mno-cygwin -shared') else: # gcc-4 series releases do not support -mno-cygwin option self.set_executables(compiler='gcc -O2 -Wall', compiler_so='gcc -O2 -Wall -Wstrict-prototypes', linker_exe='g++ ', linker_so='g++ -shared') # added for python2.3 support # we can't pass it through set_executables because pre 2.2 would fail self.compiler_cxx = ['g++'] # Maybe we should also append -mthreads, but then the finished # dlls need another dll (mingwm10.dll see Mingw32 docs) # (-mthreads: Support thread-safe exception handling on `Mingw32') # no additional libraries needed #self.dll_libraries=[] return # __init__ () def link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols = None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): # Include the appropiate MSVC runtime library if Python was built # with MSVC >= 7.0 (MinGW standard is msvcrt) runtime_library = msvc_runtime_library() if runtime_library: if not libraries: libraries = [] libraries.append(runtime_library) args = (self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, None, #export_symbols, we do this in our def-file debug, extra_preargs, extra_postargs, build_temp, target_lang) if self.gcc_version < "3.0.0": func = distutils.cygwinccompiler.CygwinCCompiler.link else: func = UnixCCompiler.link if sys.version_info[0] >= 3: func(*args[:func.__code__.co_argcount]) else: func(*args[:func.im_func.func_code.co_argcount]) return def object_filenames (self, source_filenames, strip_dir=0, output_dir=''): if output_dir is None: output_dir = '' obj_names = [] for src_name in source_filenames: # use normcase to make sure '.rc' is really '.rc' and not '.RC' (base, ext) = os.path.splitext (os.path.normcase(src_name)) # added these lines to strip off windows drive letters # without it, .o files are placed next to .c files # instead of the build directory drv,base = os.path.splitdrive(base) if drv: base = base[1:] if ext not in (self.src_extensions + ['.rc','.res']): raise UnknownFileError( "unknown file type '%s' (from '%s')" % \ (ext, src_name)) if strip_dir: base = os.path.basename (base) if ext == '.res' or ext == '.rc': # these need to be compiled to object files obj_names.append (os.path.join (output_dir, base + ext + self.obj_extension)) else: obj_names.append (os.path.join (output_dir, base + self.obj_extension)) return obj_names # object_filenames () def find_python_dll(): maj, min, micro = [int(i) for i in sys.version_info[:3]] dllname = 'python%d%d.dll' % (maj, min) print ("Looking for %s" % dllname) # We can't do much here: # - find it in python main dir # - in system32, # - ortherwise (Sxs), I don't know how to get it. lib_dirs = [] lib_dirs.append(os.path.join(sys.prefix, 'lib')) try: lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'system32')) except KeyError: pass for d in lib_dirs: dll = os.path.join(d, dllname) if os.path.exists(dll): return dll raise ValueError("%s not found in %s" % (dllname, lib_dirs)) def dump_table(dll): st = subprocess.Popen(["objdump.exe", "-p", dll], stdout=subprocess.PIPE) return st.stdout.readlines() def generate_def(dll, dfile): """Given a dll file location, get all its exported symbols and dump them into the given def file. The .def file will be overwritten""" dump = dump_table(dll) for i in range(len(dump)): if _START.match(dump[i]): break if i == len(dump): raise ValueError("Symbol table not found") syms = [] for j in range(i+1, len(dump)): m = _TABLE.match(dump[j]) if m: syms.append((int(m.group(1).strip()), m.group(2))) else: break if len(syms) == 0: log.warn('No symbols found in %s' % dll) d = open(dfile, 'w') d.write('LIBRARY %s\n' % os.path.basename(dll)) d.write(';CODE PRELOAD MOVEABLE DISCARDABLE\n') d.write(';DATA PRELOAD SINGLE\n') d.write('\nEXPORTS\n') for s in syms: #d.write('@%d %s\n' % (s[0], s[1])) d.write('%s\n' % s[1]) d.close() def build_import_library(): if os.name != 'nt': return arch = get_build_architecture() if arch == 'AMD64': return _build_import_library_amd64() elif arch == 'Intel': return _build_import_library_x86() else: raise ValueError("Unhandled arch %s" % arch) def _build_import_library_amd64(): dll_file = find_python_dll() out_name = "libpython%d%d.a" % tuple(sys.version_info[:2]) out_file = os.path.join(sys.prefix, 'libs', out_name) if os.path.isfile(out_file): log.debug('Skip building import library: "%s" exists' % (out_file)) return def_name = "python%d%d.def" % tuple(sys.version_info[:2]) def_file = os.path.join(sys.prefix,'libs',def_name) log.info('Building import library (arch=AMD64): "%s" (from %s)' \ % (out_file, dll_file)) generate_def(dll_file, def_file) cmd = ['dlltool', '-d', def_file, '-l', out_file] subprocess.Popen(cmd) def _build_import_library_x86(): """ Build the import libraries for Mingw32-gcc on Windows """ lib_name = "python%d%d.lib" % tuple(sys.version_info[:2]) lib_file = os.path.join(sys.prefix,'libs',lib_name) out_name = "libpython%d%d.a" % tuple(sys.version_info[:2]) out_file = os.path.join(sys.prefix,'libs',out_name) if not os.path.isfile(lib_file): log.warn('Cannot build import library: "%s" not found' % (lib_file)) return if os.path.isfile(out_file): log.debug('Skip building import library: "%s" exists' % (out_file)) return log.info('Building import library (ARCH=x86): "%s"' % (out_file)) from numpy.distutils import lib2def def_name = "python%d%d.def" % tuple(sys.version_info[:2]) def_file = os.path.join(sys.prefix,'libs',def_name) nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file) nm_output = lib2def.getnm(nm_cmd) dlist, flist = lib2def.parse_nm(nm_output) lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w')) dll_name = "python%d%d.dll" % tuple(sys.version_info[:2]) args = (dll_name,def_file,out_file) cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args status = os.system(cmd) # for now, fail silently if status: log.warn('Failed to build import library for gcc. Linking will fail.') #if not success: # msg = "Couldn't find import library, and failed to build it." # raise DistutilsPlatformError, msg return #===================================== # Dealing with Visual Studio MANIFESTS #===================================== # Functions to deal with visual studio manifests. Manifest are a mechanism to # enforce strong DLL versioning on windows, and has nothing to do with # distutils MANIFEST. manifests are XML files with version info, and used by # the OS loader; they are necessary when linking against a DLL not in the # system path; in particular, official python 2.6 binary is built against the # MS runtime 9 (the one from VS 2008), which is not available on most windows # systems; python 2.6 installer does install it in the Win SxS (Side by side) # directory, but this requires the manifest for this to work. This is a big # mess, thanks MS for a wonderful system. # XXX: ideally, we should use exactly the same version as used by python. I # submitted a patch to get this version, but it was only included for python # 2.6.1 and above. So for versions below, we use a "best guess". _MSVCRVER_TO_FULLVER = {} if sys.platform == 'win32': try: import msvcrt if hasattr(msvcrt, "CRT_ASSEMBLY_VERSION"): _MSVCRVER_TO_FULLVER['90'] = msvcrt.CRT_ASSEMBLY_VERSION else: _MSVCRVER_TO_FULLVER['90'] = "9.0.21022.8" # I took one version in my SxS directory: no idea if it is the good # one, and we can't retrieve it from python _MSVCRVER_TO_FULLVER['80'] = "8.0.50727.42" except ImportError: # If we are here, means python was not built with MSVC. Not sure what to do # in that case: manifest building will fail, but it should not be used in # that case anyway log.warn('Cannot import msvcrt: using manifest will not be possible') def msvc_manifest_xml(maj, min): """Given a major and minor version of the MSVCR, returns the corresponding XML file.""" try: fullver = _MSVCRVER_TO_FULLVER[str(maj * 10 + min)] except KeyError: raise ValueError("Version %d,%d of MSVCRT not supported yet" \ % (maj, min)) # Don't be fooled, it looks like an XML, but it is not. In particular, it # should not have any space before starting, and its size should be # divisible by 4, most likely for alignement constraints when the xml is # embedded in the binary... # This template was copied directly from the python 2.6 binary (using # strings.exe from mingw on python.exe). template = """\ <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC%(maj)d%(min)d.CRT" version="%(fullver)s" processorArchitecture="*" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> </assembly>""" return template % {'fullver': fullver, 'maj': maj, 'min': min} def manifest_rc(name, type='dll'): """Return the rc file used to generate the res file which will be embedded as manifest for given manifest file name, of given type ('dll' or 'exe'). Parameters ---------- name: str name of the manifest file to embed type: str ('dll', 'exe') type of the binary which will embed the manifest""" if type == 'dll': rctype = 2 elif type == 'exe': rctype = 1 else: raise ValueError("Type %s not supported" % type) return """\ #include "winuser.h" %d RT_MANIFEST %s""" % (rctype, name) def check_embedded_msvcr_match_linked(msver): """msver is the ms runtime version used for the MANIFEST.""" # check msvcr major version are the same for linking and # embedding msvcv = msvc_runtime_library() if msvcv: maj = int(msvcv[5:6]) if not maj == int(msver): raise ValueError( "Discrepancy between linked msvcr " \ "(%d) and the one about to be embedded " \ "(%d)" % (int(msver), maj)) def configtest_name(config): base = os.path.basename(config._gen_temp_sourcefile("yo", [], "c")) return os.path.splitext(base)[0] def manifest_name(config): # Get configest name (including suffix) root = configtest_name(config) exext = config.compiler.exe_extension return root + exext + ".manifest" def rc_name(config): # Get configest name (including suffix) root = configtest_name(config) return root + ".rc" def generate_manifest(config): msver = get_build_msvc_version() if msver is not None: if msver >= 8: check_embedded_msvcr_match_linked(msver) ma = int(msver) mi = int((msver - ma) * 10) # Write the manifest file manxml = msvc_manifest_xml(ma, mi) man = open(manifest_name(config), "w") config.temp_files.append(manifest_name(config)) man.write(manxml) man.close() # # Write the rc file # manrc = manifest_rc(manifest_name(self), "exe") # rc = open(rc_name(self), "w") # self.temp_files.append(manrc) # rc.write(manrc) # rc.close()
gpl-3.0
[ 624, 199, 11532, 1233, 367, 10015, 2018, 5478, 641, 5417, 14, 339, 327, 23350, 8292, 272, 327, 413, 14, 4155, 3238, 1973, 1548, 28, 1023, 10827, 65, 3495, 367, 19443, 14, 221, 982, 440, 12, 1900, 652, 14, 272, 327, 499, 14, 18771, 10061, 370, 675, 19443, 334, 1129, 3984, 620, 1518, 71, 2983, 543, 11694, 35, 436, 486, 1138, 2291, 9, 272, 327, 650, 14, 18771, 10061, 370, 675, 486, 1138, 199, 199, 624, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 646, 3873, 199, 646, 295, 199, 199, 3, 7259, 952, 9842, 7065, 14, 67, 5772, 3423, 26, 199, 646, 2680, 14, 13350, 14, 67, 5772, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 492, 943, 199, 2836, 26, 272, 687, 2680, 14, 13350, 492, 943, 199, 3, 23350, 8292, 199, 3, 413, 14, 4155, 3238, 1973, 1548, 28, 1023, 10827, 65, 3495, 367, 19443, 14, 221, 982, 440, 12, 1900, 652, 14, 199, 3, 499, 14, 18771, 10061, 370, 675, 19443, 334, 1129, 3984, 620, 1518, 71, 2983, 543, 11694, 35, 436, 486, 1138, 2291, 9, 199, 3, 259, 10541, 642, 365, 4224, 315, 2680, 15, 13350, 15, 67, 5772, 14, 647, 199, 3, 650, 14, 18771, 10061, 370, 675, 486, 1138, 199, 199, 646, 7065, 14, 16680, 67, 5772, 199, 504, 7065, 14, 1023, 492, 23052, 3353, 199, 504, 2680, 14, 13350, 14, 67, 5772, 492, 3805, 63, 17677, 63, 1419, 12, 3805, 63, 773, 63, 1419, 199, 504, 7065, 14, 2550, 492, 12577, 4858, 547, 12, 24562, 547, 12, 14831, 25212, 199, 199, 504, 7065, 14, 11864, 67, 5772, 492, 13074, 30926, 199, 504, 7065, 14, 19875, 5772, 492, 664, 63, 1506, 63, 1023, 465, 664, 63, 1506, 63, 19875, 63, 1023, 199, 504, 2680, 14, 13350, 14, 9923, 63, 1974, 492, 333, 10599, 63, 7726, 63, 4342, 12, 664, 63, 1506, 63, 19134, 199, 199, 3, 18491, 370, 3550, 1817, 402, 6698, 687, 282, 17112, 199, 63, 7363, 275, 295, 14, 2014, 8, 82, 30181, 2844, 68, 1582, 15, 985, 28833, 32174, 6957, 358, 199, 63, 8723, 275, 295, 14, 2014, 8, 82, 15542, 83, 7896, 59, 16510, 83, 23033, 16, 13, 25, 3672, 2862, 61, 7287, 65, 13, 6353, 13, 58, 16, 13, 25, 15555, 5942, 199, 199, 3, 314, 2011, 465, 23941, 12254, 2005, 4722, 2633, 199, 533, 603, 316, 87, 708, 30926, 8, 13350, 14, 16680, 67, 5772, 14, 35, 18313, 30926, 304, 272, 408, 437, 6042, 603, 316, 55, 708, 6365, 9025, 543, 376, 11694, 35, 6137, 2018, 14, 339, 408, 339, 6365, 63, 466, 275, 283, 14566, 87, 708, 7, 339, 347, 636, 826, 363, 334, 277, 12, 2116, 3376, 29, 16, 12, 2116, 9951, 63, 1065, 29, 16, 12, 2116, 3542, 29, 16, 304, 398, 7065, 14, 16680, 67, 5772, 14, 35, 18313, 30926, 855, 826, 363, 334, 277, 12, 10940, 3376, 12, 10481, 63, 1065, 12, 3542, 9, 398, 327, 781, 1929, 370, 2291, 650, 14, 18, 1314, 3181, 1133, 1336, 314, 4465, 267, 327, 664, 63, 6234, 3102, 5163, 267, 340, 291, 14, 13112, 63, 1023, 365, 488, 26, 288, 492, 295, 288, 299, 275, 3873, 14, 7942, 2941, 13112, 297, 2475, 2724, 1023, 995, 5218, 29, 549, 12, 639, 3839, 29, 5781, 14, 6089, 9, 288, 734, 63, 875, 275, 299, 14, 2703, 14, 739, 342, 288, 299, 14, 2703, 14, 1600, 342, 288, 754, 275, 295, 14, 1733, 360, 2961, 68, 23294, 68, 14705, 548, 63, 875, 9, 288, 340, 754, 26, 355, 291, 14, 13112, 63, 1023, 275, 23052, 3353, 8, 1099, 14, 923, 8, 17, 430, 398, 327, 437, 3363, 333, 316, 87, 708, 3181, 1133, 1929, 370, 4165, 282, 3365, 2397, 2376, 12, 267, 327, 1325, 23941, 499, 14, 3328, 14, 1641, 315, 949, 13, 16680, 13, 632, 4839, 652, 14, 267, 340, 291, 14, 13112, 63, 1023, 2695, 298, 18, 14, 3328, 14, 1641, 582, 288, 2397, 63, 1403, 275, 2850, 2373, 485, 29479, 6756, 32, 713, 7, 267, 587, 26, 288, 2397, 63, 1403, 275, 2125, 398, 340, 291, 14, 20311, 63, 9259, 508, 283, 9259, 3823, 356, 288, 327, 5429, 2509, 734, 2850, 3090, 13, 354, 486, 4176, 7, 1777, 626, 25079, 22965, 288, 327, 257, 486, 4176, 14, 5803, 26, 486, 4176, 26, 3091, 4066, 570, 503, 2082, 288, 327, 1125, 334, 14566, 87, 413, 14, 16, 315, 3447, 898, 1194, 3123, 12, 19443, 13, 19, 14, 20, 14, 21, 680, 288, 327, 982, 314, 1553, 3090, 13, 354, 1777, 365, 1415, 367, 2005, 3734, 288, 327, 2066, 1852, 314, 20396, 402, 642, 1777, 2488, 370, 626, 3734, 14, 288, 291, 14, 20311, 275, 283, 9259, 3823, 7, 327, 221, 1553, 3090, 13, 354, 486, 4176, 7, 267, 916, 291, 14, 20311, 63, 9259, 508, 283, 13112, 356, 288, 291, 14, 20311, 275, 283, 71, 4176, 7, 398, 327, 1011, 6627, 26, 9266, 530, 1335, 4548, 841, 15, 845, 15, 614, 267, 327, 413, 14, 2670, 367, 492, 3555, 641, 5417, 14, 221, 6516, 340, 652, 3181, 1133, 2187, 14, 398, 1900, 63, 646, 63, 4342, 342, 398, 327, 1011, 6627, 26, 9266, 530, 1335, 4548, 841, 15, 845, 15, 614, 267, 327, 499, 14, 10035, 11185, 13712, 436, 19136, 2331, 1006, 3598, 267, 327, 650, 14, 2597, 3483, 1553, 3090, 13, 354, 486, 4176, 267, 327, 277, 14, 409, 63, 5904, 83, 8, 5772, 534, 13112, 446, 77, 889, 13, 16680, 446, 47, 18, 446, 87, 297, 267, 327, 9326, 6365, 63, 1152, 534, 13112, 446, 77, 889, 13, 16680, 446, 1064, 914, 446, 47, 18, 446, 87, 297, 267, 327, 9326, 17261, 63, 5803, 534, 13112, 446, 77, 889, 13, 16680, 297, 267, 327, 9326, 17261, 63, 1152, 9569, 83, 1553, 3090, 13, 354, 486, 4176, 446, 77, 889, 13, 16680, 446, 1064, 914, 446, 1986, 450, 83, 7, 267, 327, 13293, 450, 334, 277, 14, 20311, 12, 2397, 63, 1403, 430, 398, 327, 14282, 63, 7941, 772, 1077, 506, 3247, 1380, 10015, 367, 282, 1064, 772, 641, 10061, 12, 1325, 267, 327, 2366, 2323, 5627, 652, 1454, 367, 14282, 29784, 12, 1314, 965, 1006, 4928, 402, 267, 327 ]
[ 199, 11532, 1233, 367, 10015, 2018, 5478, 641, 5417, 14, 339, 327, 23350, 8292, 272, 327, 413, 14, 4155, 3238, 1973, 1548, 28, 1023, 10827, 65, 3495, 367, 19443, 14, 221, 982, 440, 12, 1900, 652, 14, 272, 327, 499, 14, 18771, 10061, 370, 675, 19443, 334, 1129, 3984, 620, 1518, 71, 2983, 543, 11694, 35, 436, 486, 1138, 2291, 9, 272, 327, 650, 14, 18771, 10061, 370, 675, 486, 1138, 199, 199, 624, 199, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 646, 3873, 199, 646, 295, 199, 199, 3, 7259, 952, 9842, 7065, 14, 67, 5772, 3423, 26, 199, 646, 2680, 14, 13350, 14, 67, 5772, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 492, 943, 199, 2836, 26, 272, 687, 2680, 14, 13350, 492, 943, 199, 3, 23350, 8292, 199, 3, 413, 14, 4155, 3238, 1973, 1548, 28, 1023, 10827, 65, 3495, 367, 19443, 14, 221, 982, 440, 12, 1900, 652, 14, 199, 3, 499, 14, 18771, 10061, 370, 675, 19443, 334, 1129, 3984, 620, 1518, 71, 2983, 543, 11694, 35, 436, 486, 1138, 2291, 9, 199, 3, 259, 10541, 642, 365, 4224, 315, 2680, 15, 13350, 15, 67, 5772, 14, 647, 199, 3, 650, 14, 18771, 10061, 370, 675, 486, 1138, 199, 199, 646, 7065, 14, 16680, 67, 5772, 199, 504, 7065, 14, 1023, 492, 23052, 3353, 199, 504, 2680, 14, 13350, 14, 67, 5772, 492, 3805, 63, 17677, 63, 1419, 12, 3805, 63, 773, 63, 1419, 199, 504, 7065, 14, 2550, 492, 12577, 4858, 547, 12, 24562, 547, 12, 14831, 25212, 199, 199, 504, 7065, 14, 11864, 67, 5772, 492, 13074, 30926, 199, 504, 7065, 14, 19875, 5772, 492, 664, 63, 1506, 63, 1023, 465, 664, 63, 1506, 63, 19875, 63, 1023, 199, 504, 2680, 14, 13350, 14, 9923, 63, 1974, 492, 333, 10599, 63, 7726, 63, 4342, 12, 664, 63, 1506, 63, 19134, 199, 199, 3, 18491, 370, 3550, 1817, 402, 6698, 687, 282, 17112, 199, 63, 7363, 275, 295, 14, 2014, 8, 82, 30181, 2844, 68, 1582, 15, 985, 28833, 32174, 6957, 358, 199, 63, 8723, 275, 295, 14, 2014, 8, 82, 15542, 83, 7896, 59, 16510, 83, 23033, 16, 13, 25, 3672, 2862, 61, 7287, 65, 13, 6353, 13, 58, 16, 13, 25, 15555, 5942, 199, 199, 3, 314, 2011, 465, 23941, 12254, 2005, 4722, 2633, 199, 533, 603, 316, 87, 708, 30926, 8, 13350, 14, 16680, 67, 5772, 14, 35, 18313, 30926, 304, 272, 408, 437, 6042, 603, 316, 55, 708, 6365, 9025, 543, 376, 11694, 35, 6137, 2018, 14, 339, 408, 339, 6365, 63, 466, 275, 283, 14566, 87, 708, 7, 339, 347, 636, 826, 363, 334, 277, 12, 2116, 3376, 29, 16, 12, 2116, 9951, 63, 1065, 29, 16, 12, 2116, 3542, 29, 16, 304, 398, 7065, 14, 16680, 67, 5772, 14, 35, 18313, 30926, 855, 826, 363, 334, 277, 12, 10940, 3376, 12, 10481, 63, 1065, 12, 3542, 9, 398, 327, 781, 1929, 370, 2291, 650, 14, 18, 1314, 3181, 1133, 1336, 314, 4465, 267, 327, 664, 63, 6234, 3102, 5163, 267, 340, 291, 14, 13112, 63, 1023, 365, 488, 26, 288, 492, 295, 288, 299, 275, 3873, 14, 7942, 2941, 13112, 297, 2475, 2724, 1023, 995, 5218, 29, 549, 12, 639, 3839, 29, 5781, 14, 6089, 9, 288, 734, 63, 875, 275, 299, 14, 2703, 14, 739, 342, 288, 299, 14, 2703, 14, 1600, 342, 288, 754, 275, 295, 14, 1733, 360, 2961, 68, 23294, 68, 14705, 548, 63, 875, 9, 288, 340, 754, 26, 355, 291, 14, 13112, 63, 1023, 275, 23052, 3353, 8, 1099, 14, 923, 8, 17, 430, 398, 327, 437, 3363, 333, 316, 87, 708, 3181, 1133, 1929, 370, 4165, 282, 3365, 2397, 2376, 12, 267, 327, 1325, 23941, 499, 14, 3328, 14, 1641, 315, 949, 13, 16680, 13, 632, 4839, 652, 14, 267, 340, 291, 14, 13112, 63, 1023, 2695, 298, 18, 14, 3328, 14, 1641, 582, 288, 2397, 63, 1403, 275, 2850, 2373, 485, 29479, 6756, 32, 713, 7, 267, 587, 26, 288, 2397, 63, 1403, 275, 2125, 398, 340, 291, 14, 20311, 63, 9259, 508, 283, 9259, 3823, 356, 288, 327, 5429, 2509, 734, 2850, 3090, 13, 354, 486, 4176, 7, 1777, 626, 25079, 22965, 288, 327, 257, 486, 4176, 14, 5803, 26, 486, 4176, 26, 3091, 4066, 570, 503, 2082, 288, 327, 1125, 334, 14566, 87, 413, 14, 16, 315, 3447, 898, 1194, 3123, 12, 19443, 13, 19, 14, 20, 14, 21, 680, 288, 327, 982, 314, 1553, 3090, 13, 354, 1777, 365, 1415, 367, 2005, 3734, 288, 327, 2066, 1852, 314, 20396, 402, 642, 1777, 2488, 370, 626, 3734, 14, 288, 291, 14, 20311, 275, 283, 9259, 3823, 7, 327, 221, 1553, 3090, 13, 354, 486, 4176, 7, 267, 916, 291, 14, 20311, 63, 9259, 508, 283, 13112, 356, 288, 291, 14, 20311, 275, 283, 71, 4176, 7, 398, 327, 1011, 6627, 26, 9266, 530, 1335, 4548, 841, 15, 845, 15, 614, 267, 327, 413, 14, 2670, 367, 492, 3555, 641, 5417, 14, 221, 6516, 340, 652, 3181, 1133, 2187, 14, 398, 1900, 63, 646, 63, 4342, 342, 398, 327, 1011, 6627, 26, 9266, 530, 1335, 4548, 841, 15, 845, 15, 614, 267, 327, 499, 14, 10035, 11185, 13712, 436, 19136, 2331, 1006, 3598, 267, 327, 650, 14, 2597, 3483, 1553, 3090, 13, 354, 486, 4176, 267, 327, 277, 14, 409, 63, 5904, 83, 8, 5772, 534, 13112, 446, 77, 889, 13, 16680, 446, 47, 18, 446, 87, 297, 267, 327, 9326, 6365, 63, 1152, 534, 13112, 446, 77, 889, 13, 16680, 446, 1064, 914, 446, 47, 18, 446, 87, 297, 267, 327, 9326, 17261, 63, 5803, 534, 13112, 446, 77, 889, 13, 16680, 297, 267, 327, 9326, 17261, 63, 1152, 9569, 83, 1553, 3090, 13, 354, 486, 4176, 446, 77, 889, 13, 16680, 446, 1064, 914, 446, 1986, 450, 83, 7, 267, 327, 13293, 450, 334, 277, 14, 20311, 12, 2397, 63, 1403, 430, 398, 327, 14282, 63, 7941, 772, 1077, 506, 3247, 1380, 10015, 367, 282, 1064, 772, 641, 10061, 12, 1325, 267, 327, 2366, 2323, 5627, 652, 1454, 367, 14282, 29784, 12, 1314, 965, 1006, 4928, 402, 267, 327, 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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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 ]
kaiix/depot_tools
third_party/logilab/common/ureports/docbook_writer.py
93
5706
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of logilab-common. # # logilab-common 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. # # logilab-common 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 logilab-common. If not, see <http://www.gnu.org/licenses/>. """HTML formatting drivers for ureports""" __docformat__ = "restructuredtext en" from six.moves import range from logilab.common.ureports import HTMLWriter class DocbookWriter(HTMLWriter): """format layouts as HTML""" def begin_format(self, layout): """begin to format a layout""" super(HTMLWriter, self).begin_format(layout) if self.snippet is None: self.writeln('<?xml version="1.0" encoding="ISO-8859-1"?>') self.writeln(""" <book xmlns:xi='http://www.w3.org/2001/XInclude' lang='fr'> """) def end_format(self, layout): """finished to format a layout""" if self.snippet is None: self.writeln('</book>') def visit_section(self, layout): """display a section (using <chapter> (level 0) or <section>)""" if self.section == 0: tag = "chapter" else: tag = "section" self.section += 1 self.writeln(self._indent('<%s%s>' % (tag, self.handle_attrs(layout)))) self.format_children(layout) self.writeln(self._indent('</%s>'% tag)) self.section -= 1 def visit_title(self, layout): """display a title using <title>""" self.write(self._indent(' <title%s>' % self.handle_attrs(layout))) self.format_children(layout) self.writeln('</title>') def visit_table(self, layout): """display a table as html""" self.writeln(self._indent(' <table%s><title>%s</title>' \ % (self.handle_attrs(layout), layout.title))) self.writeln(self._indent(' <tgroup cols="%s">'% layout.cols)) for i in range(layout.cols): self.writeln(self._indent(' <colspec colname="c%s" colwidth="1*"/>' % i)) table_content = self.get_table_content(layout) # write headers if layout.cheaders: self.writeln(self._indent(' <thead>')) self._write_row(table_content[0]) self.writeln(self._indent(' </thead>')) table_content = table_content[1:] elif layout.rcheaders: self.writeln(self._indent(' <thead>')) self._write_row(table_content[-1]) self.writeln(self._indent(' </thead>')) table_content = table_content[:-1] # write body self.writeln(self._indent(' <tbody>')) for i in range(len(table_content)): row = table_content[i] self.writeln(self._indent(' <row>')) for j in range(len(row)): cell = row[j] or '&#160;' self.writeln(self._indent(' <entry>%s</entry>' % cell)) self.writeln(self._indent(' </row>')) self.writeln(self._indent(' </tbody>')) self.writeln(self._indent(' </tgroup>')) self.writeln(self._indent(' </table>')) def _write_row(self, row): """write content of row (using <row> <entry>)""" self.writeln(' <row>') for j in range(len(row)): cell = row[j] or '&#160;' self.writeln(' <entry>%s</entry>' % cell) self.writeln(self._indent(' </row>')) def visit_list(self, layout): """display a list (using <itemizedlist>)""" self.writeln(self._indent(' <itemizedlist%s>' % self.handle_attrs(layout))) for row in list(self.compute_content(layout)): self.writeln(' <listitem><para>%s</para></listitem>' % row) self.writeln(self._indent(' </itemizedlist>')) def visit_paragraph(self, layout): """display links (using <para>)""" self.write(self._indent(' <para>')) self.format_children(layout) self.writeln('</para>') def visit_span(self, layout): """display links (using <p>)""" #TODO: translate in docbook self.write('<literal %s>' % self.handle_attrs(layout)) self.format_children(layout) self.write('</literal>') def visit_link(self, layout): """display links (using <ulink>)""" self.write('<ulink url="%s"%s>%s</ulink>' % (layout.url, self.handle_attrs(layout), layout.label)) def visit_verbatimtext(self, layout): """display verbatim text (using <programlisting>)""" self.writeln(self._indent(' <programlisting>')) self.write(layout.data.replace('&', '&amp;').replace('<', '&lt;')) self.writeln(self._indent(' </programlisting>')) def visit_text(self, layout): """add some text""" self.write(layout.data.replace('&', '&amp;').replace('<', '&lt;')) def _indent(self, string): """correctly indent string according to section""" return ' ' * 2*(self.section) + string
bsd-3-clause
[ 3, 4248, 13004, 13, 8128, 5051, 1193, 1217, 428, 14, 33, 14, 334, 1262, 374, 12, 28671, 7140, 395, 1006, 4481, 4644, 14, 199, 3, 8966, 1455, 921, 1544, 14, 793, 24142, 14, 4391, 15, 1553, 6016, 475, 26, 7811, 32, 793, 24142, 14, 4391, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 943, 24142, 13, 2330, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 943, 24142, 13, 2330, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 4943, 10803, 19016, 367, 399, 15629, 624, 199, 363, 21841, 363, 275, 298, 26854, 655, 2, 199, 199, 504, 3816, 14, 4912, 492, 1425, 199, 199, 504, 943, 24142, 14, 2330, 14, 608, 5203, 492, 4163, 6261, 199, 199, 533, 5454, 2706, 6261, 8, 4943, 6261, 304, 272, 408, 908, 7054, 83, 465, 4163, 624, 339, 347, 5386, 63, 908, 8, 277, 12, 7054, 304, 267, 408, 5037, 370, 1475, 282, 7054, 624, 267, 1613, 8, 4943, 6261, 12, 291, 680, 5037, 63, 908, 8, 4209, 9, 267, 340, 291, 14, 18547, 365, 488, 26, 288, 291, 14, 21768, 4827, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 7336, 13, 4830, 13, 17, 14863, 5971, 288, 291, 14, 21768, 4852, 199, 28, 2706, 9604, 26, 6865, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 56, 7826, 7, 489, 6339, 534, 4391, 8423, 199, 6141, 339, 347, 1284, 63, 908, 8, 277, 12, 7054, 304, 267, 408, 8669, 370, 1475, 282, 7054, 624, 267, 340, 291, 14, 18547, 365, 488, 26, 288, 291, 14, 21768, 14264, 2706, 5971, 339, 347, 5684, 63, 2792, 8, 277, 12, 7054, 304, 267, 408, 2918, 282, 3420, 334, 4941, 665, 11316, 30, 334, 1896, 378, 9, 503, 665, 2792, 30, 9471, 267, 340, 291, 14, 2792, 508, 378, 26, 288, 1947, 275, 298, 11316, 2, 267, 587, 26, 288, 1947, 275, 298, 2792, 2, 267, 291, 14, 2792, 847, 413, 267, 291, 14, 21768, 8, 277, 423, 3724, 18875, 83, 5, 83, 3524, 450, 334, 1450, 12, 291, 14, 2479, 63, 3288, 8, 4209, 7845, 267, 291, 14, 908, 63, 3223, 8, 4209, 9, 267, 291, 14, 21768, 8, 277, 423, 3724, 26576, 83, 3524, 5, 1947, 430, 267, 291, 14, 2792, 4862, 413, 339, 347, 5684, 63, 1213, 8, 277, 12, 7054, 304, 267, 408, 2918, 282, 2538, 1808, 665, 1213, 11193, 267, 291, 14, 952, 8, 277, 423, 3724, 360, 221, 665, 1213, 5, 83, 3524, 450, 291, 14, 2479, 63, 3288, 8, 4209, 1724, 267, 291, 14, 908, 63, 3223, 8, 4209, 9, 267, 291, 14, 21768, 14264, 1213, 5971, 339, 347, 5684, 63, 1224, 8, 277, 12, 7054, 304, 267, 408, 2918, 282, 1817, 465, 3517, 624, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 221, 665, 1224, 5, 83, 2535, 1213, 6598, 83, 1108, 1213, 3524, 971, 2151, 450, 334, 277, 14, 2479, 63, 3288, 8, 4209, 395, 7054, 14, 1213, 1724, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 259, 665, 84, 923, 8850, 5961, 83, 1743, 5956, 7054, 14, 4574, 430, 267, 367, 284, 315, 1425, 8, 4209, 14, 4574, 304, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 4574, 733, 1048, 354, 628, 67, 5, 83, 2, 1048, 2063, 628, 17, 10, 7897, 7, 450, 284, 430, 398, 1817, 63, 1317, 275, 291, 14, 362, 63, 1224, 63, 1317, 8, 4209, 9, 267, 327, 2218, 2323, 267, 340, 7054, 14, 595, 669, 83, 26, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 21519, 30, 1333, 288, 291, 423, 952, 63, 1143, 8, 1224, 63, 1317, 59, 16, 566, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 3068, 21519, 30, 1333, 288, 1817, 63, 1317, 275, 1817, 63, 1317, 59, 17, 2938, 267, 916, 7054, 14, 82, 595, 669, 83, 26, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 21519, 30, 1333, 288, 291, 423, 952, 63, 1143, 8, 1224, 63, 1317, 1988, 17, 566, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 3068, 21519, 30, 1333, 288, 1817, 63, 1317, 275, 1817, 63, 1317, 4439, 17, 61, 267, 327, 2218, 2396, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 17847, 30, 1333, 267, 367, 284, 315, 1425, 8, 552, 8, 1224, 63, 1317, 2298, 288, 1962, 275, 1817, 63, 1317, 59, 73, 61, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 263, 665, 1143, 30, 1333, 288, 367, 1335, 315, 1425, 8, 552, 8, 1143, 2298, 355, 4917, 275, 1962, 59, 74, 61, 503, 7673, 3, 8488, 8942, 355, 291, 14, 21768, 8, 277, 423, 3724, 360, 3515, 665, 2373, 6598, 83, 1108, 2373, 3524, 450, 4917, 430, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 263, 3068, 1143, 30, 1333, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 3068, 17847, 30, 1333, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 259, 3068, 84, 923, 30, 1333, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 221, 3068, 1224, 30, 1333, 339, 347, 485, 952, 63, 1143, 8, 277, 12, 1962, 304, 267, 408, 952, 1564, 402, 1962, 334, 4941, 665, 1143, 30, 665, 2373, 30, 9471, 267, 291, 14, 21768, 360, 263, 665, 1143, 5971, 267, 367, 1335 ]
[ 4248, 13004, 13, 8128, 5051, 1193, 1217, 428, 14, 33, 14, 334, 1262, 374, 12, 28671, 7140, 395, 1006, 4481, 4644, 14, 199, 3, 8966, 1455, 921, 1544, 14, 793, 24142, 14, 4391, 15, 1553, 6016, 475, 26, 7811, 32, 793, 24142, 14, 4391, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 943, 24142, 13, 2330, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 943, 24142, 13, 2330, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 4943, 10803, 19016, 367, 399, 15629, 624, 199, 363, 21841, 363, 275, 298, 26854, 655, 2, 199, 199, 504, 3816, 14, 4912, 492, 1425, 199, 199, 504, 943, 24142, 14, 2330, 14, 608, 5203, 492, 4163, 6261, 199, 199, 533, 5454, 2706, 6261, 8, 4943, 6261, 304, 272, 408, 908, 7054, 83, 465, 4163, 624, 339, 347, 5386, 63, 908, 8, 277, 12, 7054, 304, 267, 408, 5037, 370, 1475, 282, 7054, 624, 267, 1613, 8, 4943, 6261, 12, 291, 680, 5037, 63, 908, 8, 4209, 9, 267, 340, 291, 14, 18547, 365, 488, 26, 288, 291, 14, 21768, 4827, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 7336, 13, 4830, 13, 17, 14863, 5971, 288, 291, 14, 21768, 4852, 199, 28, 2706, 9604, 26, 6865, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 8339, 15, 56, 7826, 7, 489, 6339, 534, 4391, 8423, 199, 6141, 339, 347, 1284, 63, 908, 8, 277, 12, 7054, 304, 267, 408, 8669, 370, 1475, 282, 7054, 624, 267, 340, 291, 14, 18547, 365, 488, 26, 288, 291, 14, 21768, 14264, 2706, 5971, 339, 347, 5684, 63, 2792, 8, 277, 12, 7054, 304, 267, 408, 2918, 282, 3420, 334, 4941, 665, 11316, 30, 334, 1896, 378, 9, 503, 665, 2792, 30, 9471, 267, 340, 291, 14, 2792, 508, 378, 26, 288, 1947, 275, 298, 11316, 2, 267, 587, 26, 288, 1947, 275, 298, 2792, 2, 267, 291, 14, 2792, 847, 413, 267, 291, 14, 21768, 8, 277, 423, 3724, 18875, 83, 5, 83, 3524, 450, 334, 1450, 12, 291, 14, 2479, 63, 3288, 8, 4209, 7845, 267, 291, 14, 908, 63, 3223, 8, 4209, 9, 267, 291, 14, 21768, 8, 277, 423, 3724, 26576, 83, 3524, 5, 1947, 430, 267, 291, 14, 2792, 4862, 413, 339, 347, 5684, 63, 1213, 8, 277, 12, 7054, 304, 267, 408, 2918, 282, 2538, 1808, 665, 1213, 11193, 267, 291, 14, 952, 8, 277, 423, 3724, 360, 221, 665, 1213, 5, 83, 3524, 450, 291, 14, 2479, 63, 3288, 8, 4209, 1724, 267, 291, 14, 908, 63, 3223, 8, 4209, 9, 267, 291, 14, 21768, 14264, 1213, 5971, 339, 347, 5684, 63, 1224, 8, 277, 12, 7054, 304, 267, 408, 2918, 282, 1817, 465, 3517, 624, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 221, 665, 1224, 5, 83, 2535, 1213, 6598, 83, 1108, 1213, 3524, 971, 2151, 450, 334, 277, 14, 2479, 63, 3288, 8, 4209, 395, 7054, 14, 1213, 1724, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 259, 665, 84, 923, 8850, 5961, 83, 1743, 5956, 7054, 14, 4574, 430, 267, 367, 284, 315, 1425, 8, 4209, 14, 4574, 304, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 4574, 733, 1048, 354, 628, 67, 5, 83, 2, 1048, 2063, 628, 17, 10, 7897, 7, 450, 284, 430, 398, 1817, 63, 1317, 275, 291, 14, 362, 63, 1224, 63, 1317, 8, 4209, 9, 267, 327, 2218, 2323, 267, 340, 7054, 14, 595, 669, 83, 26, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 21519, 30, 1333, 288, 291, 423, 952, 63, 1143, 8, 1224, 63, 1317, 59, 16, 566, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 3068, 21519, 30, 1333, 288, 1817, 63, 1317, 275, 1817, 63, 1317, 59, 17, 2938, 267, 916, 7054, 14, 82, 595, 669, 83, 26, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 21519, 30, 1333, 288, 291, 423, 952, 63, 1143, 8, 1224, 63, 1317, 1988, 17, 566, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 3068, 21519, 30, 1333, 288, 1817, 63, 1317, 275, 1817, 63, 1317, 4439, 17, 61, 267, 327, 2218, 2396, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 665, 17847, 30, 1333, 267, 367, 284, 315, 1425, 8, 552, 8, 1224, 63, 1317, 2298, 288, 1962, 275, 1817, 63, 1317, 59, 73, 61, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 263, 665, 1143, 30, 1333, 288, 367, 1335, 315, 1425, 8, 552, 8, 1143, 2298, 355, 4917, 275, 1962, 59, 74, 61, 503, 7673, 3, 8488, 8942, 355, 291, 14, 21768, 8, 277, 423, 3724, 360, 3515, 665, 2373, 6598, 83, 1108, 2373, 3524, 450, 4917, 430, 288, 291, 14, 21768, 8, 277, 423, 3724, 360, 263, 3068, 1143, 30, 1333, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 420, 3068, 17847, 30, 1333, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 259, 3068, 84, 923, 30, 1333, 267, 291, 14, 21768, 8, 277, 423, 3724, 360, 221, 3068, 1224, 30, 1333, 339, 347, 485, 952, 63, 1143, 8, 277, 12, 1962, 304, 267, 408, 952, 1564, 402, 1962, 334, 4941, 665, 1143, 30, 665, 2373, 30, 9471, 267, 291, 14, 21768, 360, 263, 665, 1143, 5971, 267, 367, 1335, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Moves C++ files to a new location, updating any include paths that point to them, and re-ordering headers as needed. If multiple source files are specified, the destination must be a directory. Updates include guards in moved header files. Assumes Chromium coding style. Attempts to update paths used in .gyp(i) files, but does not reorder or restructure .gyp(i) files in any way. Updates full-path references to files in // comments in source files. Must run in a git checkout, as it relies on git grep for a fast way to find files that reference the moved file. """ import optparse import os import re import subprocess import sys import mffr if __name__ == '__main__': # Need to add the directory containing sort-headers.py to the Python # classpath. sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..'))) sort_headers = __import__('sort-headers') import sort_sources HANDLED_EXTENSIONS = ['.cc', '.mm', '.h', '.hh', '.cpp'] def IsHandledFile(path): return os.path.splitext(path)[1] in HANDLED_EXTENSIONS def MakeDestinationPath(from_path, to_path): """Given the from and to paths, return a correct destination path. The initial destination path may either a full path or a directory. Also does basic sanity checks. """ if not IsHandledFile(from_path): raise Exception('Only intended to move individual source files ' '(%s does not have a recognized extension).' % from_path) # Remove '.', '..', etc. to_path = os.path.normpath(to_path) if os.path.isdir(to_path): to_path = os.path.join(to_path, os.path.basename(from_path)) else: dest_extension = os.path.splitext(to_path)[1] if dest_extension not in HANDLED_EXTENSIONS: raise Exception('Destination must be either a full path with ' 'a recognized extension or a directory.') return to_path def UpdateIncludePathForBlink(path): """Updates |path| as it would be when used in an include statement in Blink. As Blink has its 'public' and 'Source' folders in the include search path, these prefixes of file paths are not included in include statements. For example, if |path| is 'public/foo/bar.h', the matching include statement is '#include "foo/bar.h"'. """ for prefix in ('public/', 'Source/'): if path.startswith(prefix): return path[len(prefix):] return path def MoveFile(from_path, to_path): """Performs a git mv command to move a file from |from_path| to |to_path|. """ if not os.system('git mv %s %s' % (from_path, to_path)) == 0: raise Exception('Fatal: Failed to run git mv command.') def UpdatePostMove(from_path, to_path, in_blink): """Given a file that has moved from |from_path| to |to_path|, updates the moved file's include guard to match the new path and updates all references to the file in other source files. Also tries to update references in .gyp(i) files using a heuristic. """ # Include paths always use forward slashes. from_path = from_path.replace('\\', '/') to_path = to_path.replace('\\', '/') if os.path.splitext(from_path)[1] in ['.h', '.hh']: UpdateIncludeGuard(from_path, to_path) from_include_path = from_path to_include_path = to_path if in_blink: from_include_path = UpdateIncludePathForBlink(from_include_path) to_include_path = UpdateIncludePathForBlink(to_include_path) # Update include/import references. files_with_changed_includes = mffr.MultiFileFindReplace( r'(#(include|import)\s*["<])%s([>"])' % re.escape(from_include_path), r'\1%s\3' % to_include_path, ['*.cc', '*.h', '*.m', '*.mm', '*.cpp']) # Reorder headers in files that changed. for changed_file in files_with_changed_includes: def AlwaysConfirm(a, b): return True sort_headers.FixFileWithConfirmFunction(changed_file, AlwaysConfirm, True, in_blink) # Update comments; only supports // comments, which are primarily # used in our code. # # This work takes a bit of time. If this script starts feeling too # slow, one good way to speed it up is to make the comment handling # optional under a flag. mffr.MultiFileFindReplace( r'(//.*)%s' % re.escape(from_path), r'\1%s' % to_path, ['*.cc', '*.h', '*.m', '*.mm', '*.cpp']) # Update references in GYP and BUILD.gn files. # # GYP files are mostly located under the first level directory (ex. # chrome/chrome_browser.gypi), but sometimes they are located in # directories at a deeper level (ex. extensions/shell/app_shell.gypi). On # the other hand, BUILD.gn files can be placed in any directories. # # Paths in a GYP or BUILD.gn file are relative to the directory where the # file is placed. # # For instance, "chrome/browser/chromeos/device_uma.h" is listed as # "browser/chromeos/device_uma.h" in "chrome/chrome_browser_chromeos.gypi", # but it's listed as "device_uma.h" in "chrome/browser/chromeos/BUILD.gn". # # To handle this, the code here will visit directories from the top level # src directory to the directory of |from_path| and try to update GYP and # BUILD.gn files in each directory. # # The code only handles files moved/renamed within the same build file. If # files are moved beyond the same build file, the affected build files # should be fixed manually. def SplitByFirstComponent(path): """'foo/bar/baz' -> ('foo', 'bar/baz') 'bar' -> ('bar', '') '' -> ('', '') """ parts = re.split(r"[/\\]", path, 1) if len(parts) == 2: return (parts[0], parts[1]) else: return (parts[0], '') visiting_directory = '' from_rest = from_path to_rest = to_path while True: files_with_changed_sources = mffr.MultiFileFindReplace( r'([\'"])%s([\'"])' % from_rest, r'\1%s\2' % to_rest, [os.path.join(visiting_directory, 'BUILD.gn'), os.path.join(visiting_directory, '*.gyp*')]) for changed_file in files_with_changed_sources: sort_sources.ProcessFile(changed_file, should_confirm=False) from_first, from_rest = SplitByFirstComponent(from_rest) to_first, to_rest = SplitByFirstComponent(to_rest) visiting_directory = os.path.join(visiting_directory, from_first) if not from_rest or not to_rest or from_rest == to_rest: break def MakeIncludeGuardName(path_from_root): """Returns an include guard name given a path from root.""" guard = path_from_root.replace('/', '_') guard = guard.replace('\\', '_') guard = guard.replace('.', '_') guard += '_' return guard.upper() def UpdateIncludeGuard(old_path, new_path): """Updates the include guard in a file now residing at |new_path|, previously residing at |old_path|, with an up-to-date include guard. Prints a warning if the update could not be completed successfully (e.g., because the old include guard was not formatted correctly per Chromium style). """ old_guard = MakeIncludeGuardName(old_path) new_guard = MakeIncludeGuardName(new_path) with open(new_path) as f: contents = f.read() new_contents = contents.replace(old_guard, new_guard) # The file should now have three instances of the new guard: two at the top # of the file plus one at the bottom for the comment on the #endif. if new_contents.count(new_guard) != 3: print ('WARNING: Could not successfully update include guard; perhaps ' 'old guard is not per style guide? You will have to update the ' 'include guard manually. (%s)' % new_path) with open(new_path, 'w') as f: f.write(new_contents) def main(): if not os.path.isdir('.git'): print 'Fatal: You must run from the root of a git checkout.' return 1 in_blink = os.getcwd().endswith("third_party/WebKit") parser = optparse.OptionParser(usage='%prog FROM_PATH... TO_PATH') parser.add_option('--already_moved', action='store_true', dest='already_moved', help='Causes the script to skip moving the file.') parser.add_option('--no_error_for_non_source_file', action='store_false', default='True', dest='error_for_non_source_file', help='Causes the script to simply print a warning on ' 'encountering a non-source file rather than raising an ' 'error.') opts, args = parser.parse_args() if len(args) < 2: parser.print_help() return 1 from_paths = args[:len(args)-1] orig_to_path = args[-1] if len(from_paths) > 1 and not os.path.isdir(orig_to_path): print 'Target %s is not a directory.' % orig_to_path print parser.print_help() return 1 for from_path in from_paths: if not opts.error_for_non_source_file and not IsHandledFile(from_path): print '%s does not appear to be a source file, skipping' % (from_path) continue to_path = MakeDestinationPath(from_path, orig_to_path) if not opts.already_moved: MoveFile(from_path, to_path) UpdatePostMove(from_path, to_path, in_blink) return 0 if __name__ == '__main__': sys.exit(main())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 3716, 2310, 445, 4176, 1584, 370, 282, 892, 2909, 12, 12928, 1263, 2387, 3792, 626, 2376, 199, 475, 3062, 12, 436, 295, 13, 7128, 2323, 465, 4346, 14, 221, 982, 3663, 1350, 1584, 787, 199, 10085, 12, 314, 5724, 1471, 506, 282, 2082, 14, 221, 24663, 2387, 8129, 5596, 315, 199, 3539, 1406, 1584, 14, 221, 30451, 12051, 2803, 3449, 14, 199, 199, 15322, 1086, 370, 1678, 3792, 1202, 315, 1275, 6179, 8, 73, 9, 1584, 12, 1325, 1630, 440, 32179, 199, 269, 295, 6976, 1275, 6179, 8, 73, 9, 1584, 315, 1263, 4340, 14, 199, 199, 16083, 2615, 13, 515, 6941, 370, 1584, 315, 5001, 6786, 315, 1350, 1584, 14, 199, 199, 13757, 1255, 315, 282, 6135, 15243, 12, 465, 652, 25749, 641, 6135, 20595, 367, 282, 7377, 4340, 370, 199, 1623, 1584, 626, 3659, 314, 12155, 570, 14, 199, 624, 421, 199, 646, 8691, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 199, 646, 333, 556, 82, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 14012, 370, 1050, 314, 2082, 3035, 4069, 13, 2139, 14, 647, 370, 314, 2018, 523, 327, 1021, 515, 14, 523, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 1274, 14, 515, 59, 16, 467, 11541, 7058, 199, 3191, 63, 2139, 275, 636, 646, 19734, 3191, 13, 2139, 358, 199, 646, 4069, 63, 4553, 421, 199, 10854, 5290, 63, 18451, 275, 18953, 2055, 297, 1987, 596, 297, 1987, 72, 297, 1987, 12156, 297, 1987, 5910, 418, 421, 199, 318, 6596, 5940, 68, 1173, 8, 515, 304, 523, 372, 747, 14, 515, 14, 7973, 8, 515, 2788, 17, 61, 315, 23276, 5290, 63, 18451, 421, 199, 318, 4155, 13151, 2042, 8, 504, 63, 515, 12, 370, 63, 515, 304, 523, 408, 13735, 314, 687, 436, 370, 3792, 12, 372, 282, 3211, 5724, 931, 14, 819, 710, 2536, 5724, 931, 1443, 1902, 282, 2615, 931, 503, 282, 2082, 14, 523, 6121, 1630, 5678, 16740, 5920, 14, 523, 408, 523, 340, 440, 6596, 5940, 68, 1173, 8, 504, 63, 515, 304, 272, 746, 2186, 360, 5903, 11619, 370, 4057, 8212, 1350, 1584, 283, 490, 25676, 83, 1630, 440, 1172, 282, 18054, 3329, 28823, 450, 490, 687, 63, 515, 9, 819, 327, 5852, 22608, 19155, 5423, 14, 523, 370, 63, 515, 275, 747, 14, 515, 14, 9267, 8, 475, 63, 515, 9, 819, 340, 747, 14, 515, 14, 6027, 8, 475, 63, 515, 304, 272, 370, 63, 515, 275, 747, 14, 515, 14, 904, 8, 475, 63, 515, 12, 747, 14, 515, 14, 4846, 8, 504, 63, 515, 430, 523, 587, 26, 272, 2053, 63, 3435, 275, 747, 14, 515, 14, 7973, 8, 475, 63, 515, 2788, 17, 61, 272, 340, 2053, 63, 3435, 440, 315, 23276, 5290, 63, 18451, 26, 489, 746, 2186, 360, 13151, 1471, 506, 1902, 282, 2615, 931, 543, 283, 1993, 283, 65, 18054, 3329, 503, 282, 2082, 2659, 523, 372, 370, 63, 515, 421, 199, 318, 6162, 7826, 2042, 1858, 34, 1073, 8, 515, 304, 523, 408, 16083, 1204, 515, 92, 465, 652, 3955, 506, 1380, 1202, 315, 376, 2387, 5164, 315, 699, 1073, 14, 819, 3709, 699, 1073, 965, 2399, 283, 3455, 7, 436, 283, 2980, 7, 16533, 315, 314, 2387, 2754, 931, 12, 523, 3520, 13158, 402, 570, 3792, 787, 440, 5120, 315, 2387, 9834, 14, 2104, 523, 2893, 12, 340, 1204, 515, 92, 365, 283, 3455, 15, 1421, 15, 1700, 14, 72, 297, 314, 4877, 2387, 5164, 523, 365, 3943, 2613, 298, 1421, 15, 1700, 14, 72, 2, 1370, 523, 408, 523, 367, 2403, 315, 661, 3455, 3678, 283, 2980, 26985, 272, 340, 931, 14, 2460, 8, 1861, 304, 489, 372, 931, 59, 552, 8, 1861, 15405, 819, 372, 931, 421, 199, 318, 14171, 1173, 8, 504, 63, 515, 12, 370, 63, 515, 304, 523, 408, 2623, 3351, 282, 6135, 15413, 1414, 370, 4057, 282, 570, 687, 1204, 504, 63, 515, 92, 370, 1204, 475, 63, 515, 18257, 523, 408, 523, 340, 440, 747, 14, 2253, 360, 3187, 15413, 450, 83, 450, 83, 7, 450, 334, 504, 63, 515, 12, 370, 63, 515, 430, 508, 378, 26, 272, 746, 2186, 360, 19507, 26, 16277, 370, 1255, 6135, 15413, 1414, 2659, 421, 199, 318, 6162, 6564, 10370, 8, 504, 63, 515, 12, 370, 63, 515, 12, 315, 63, 24042, 304, 523, 408, 13735, 282, 570, 626, 965, 12155, 687, 1204, 504, 63, 515, 92, 370, 1204, 475, 63, 515, 18712, 523, 7029, 314, 12155, 570, 1159, 2387, 24453, 370, 1336, 314, 892, 931, 436, 523, 7029, 1006, 6941, 370, 314, 570, 315, 1163, 1350, 1584, 14, 6121, 11275, 523, 370, 1678, 6941, 315, 1275, 6179, 8, 73, 9, 1584, 1808, 282, 25332, 14, 523, 408, 523, 327, 15783, 3792, 3544, 675, 7568, 20275, 14, 523, 687, 63, 515, 275, 687, 63, 515, 14, 1814, 20786, 15107, 523, 370, 63, 515, 275, 370, 63, 515, 14, 1814, 20786, 15107, 819, 340, 747, 14, 515, 14, 7973, 8, 504, 63, 515, 2788, 17, 61, 315, 18953, 72, 297, 1987, 12156, 2565, 272, 6162, 7826, 18183, 8, 504, 63, 515, 12, 370, 63, 515, 9, 339, 687, 63, 2613, 63, 515, 275, 687, 63, 515, 272, 370, 63, 2613, 63, 515, 275, 370, 63, 515, 272, 340, 315, 63, 24042, 26, 489, 687, 63, 2613, 63, 515, 275, 6162, 7826, 2042, 1858, 34, 1073, 8, 504, 63, 2613, 63, 515, 9, 489, 370, 63, 2613, 63, 515, 275, 6162, 7826, 2042, 1858, 34, 1073, 8, 475, 63, 2613, 63, 515, 9, 339, 327, 6162, 2387, 15, 646, 6941, 14, 272, 1584, 63, 1045, 63, 2489, 63, 9441, 275, 333, 556, 82, 14, 3947, 1173, 6591, 11328, 8, 267, 519, 6774, 3, 8, 2613, 92, 646, 2862, 83, 10, 905, 28, 566, 5, 83, 779, 30, 3135, 7, 450 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 3716, 2310, 445, 4176, 1584, 370, 282, 892, 2909, 12, 12928, 1263, 2387, 3792, 626, 2376, 199, 475, 3062, 12, 436, 295, 13, 7128, 2323, 465, 4346, 14, 221, 982, 3663, 1350, 1584, 787, 199, 10085, 12, 314, 5724, 1471, 506, 282, 2082, 14, 221, 24663, 2387, 8129, 5596, 315, 199, 3539, 1406, 1584, 14, 221, 30451, 12051, 2803, 3449, 14, 199, 199, 15322, 1086, 370, 1678, 3792, 1202, 315, 1275, 6179, 8, 73, 9, 1584, 12, 1325, 1630, 440, 32179, 199, 269, 295, 6976, 1275, 6179, 8, 73, 9, 1584, 315, 1263, 4340, 14, 199, 199, 16083, 2615, 13, 515, 6941, 370, 1584, 315, 5001, 6786, 315, 1350, 1584, 14, 199, 199, 13757, 1255, 315, 282, 6135, 15243, 12, 465, 652, 25749, 641, 6135, 20595, 367, 282, 7377, 4340, 370, 199, 1623, 1584, 626, 3659, 314, 12155, 570, 14, 199, 624, 421, 199, 646, 8691, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 199, 646, 333, 556, 82, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 14012, 370, 1050, 314, 2082, 3035, 4069, 13, 2139, 14, 647, 370, 314, 2018, 523, 327, 1021, 515, 14, 523, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 1274, 14, 515, 59, 16, 467, 11541, 7058, 199, 3191, 63, 2139, 275, 636, 646, 19734, 3191, 13, 2139, 358, 199, 646, 4069, 63, 4553, 421, 199, 10854, 5290, 63, 18451, 275, 18953, 2055, 297, 1987, 596, 297, 1987, 72, 297, 1987, 12156, 297, 1987, 5910, 418, 421, 199, 318, 6596, 5940, 68, 1173, 8, 515, 304, 523, 372, 747, 14, 515, 14, 7973, 8, 515, 2788, 17, 61, 315, 23276, 5290, 63, 18451, 421, 199, 318, 4155, 13151, 2042, 8, 504, 63, 515, 12, 370, 63, 515, 304, 523, 408, 13735, 314, 687, 436, 370, 3792, 12, 372, 282, 3211, 5724, 931, 14, 819, 710, 2536, 5724, 931, 1443, 1902, 282, 2615, 931, 503, 282, 2082, 14, 523, 6121, 1630, 5678, 16740, 5920, 14, 523, 408, 523, 340, 440, 6596, 5940, 68, 1173, 8, 504, 63, 515, 304, 272, 746, 2186, 360, 5903, 11619, 370, 4057, 8212, 1350, 1584, 283, 490, 25676, 83, 1630, 440, 1172, 282, 18054, 3329, 28823, 450, 490, 687, 63, 515, 9, 819, 327, 5852, 22608, 19155, 5423, 14, 523, 370, 63, 515, 275, 747, 14, 515, 14, 9267, 8, 475, 63, 515, 9, 819, 340, 747, 14, 515, 14, 6027, 8, 475, 63, 515, 304, 272, 370, 63, 515, 275, 747, 14, 515, 14, 904, 8, 475, 63, 515, 12, 747, 14, 515, 14, 4846, 8, 504, 63, 515, 430, 523, 587, 26, 272, 2053, 63, 3435, 275, 747, 14, 515, 14, 7973, 8, 475, 63, 515, 2788, 17, 61, 272, 340, 2053, 63, 3435, 440, 315, 23276, 5290, 63, 18451, 26, 489, 746, 2186, 360, 13151, 1471, 506, 1902, 282, 2615, 931, 543, 283, 1993, 283, 65, 18054, 3329, 503, 282, 2082, 2659, 523, 372, 370, 63, 515, 421, 199, 318, 6162, 7826, 2042, 1858, 34, 1073, 8, 515, 304, 523, 408, 16083, 1204, 515, 92, 465, 652, 3955, 506, 1380, 1202, 315, 376, 2387, 5164, 315, 699, 1073, 14, 819, 3709, 699, 1073, 965, 2399, 283, 3455, 7, 436, 283, 2980, 7, 16533, 315, 314, 2387, 2754, 931, 12, 523, 3520, 13158, 402, 570, 3792, 787, 440, 5120, 315, 2387, 9834, 14, 2104, 523, 2893, 12, 340, 1204, 515, 92, 365, 283, 3455, 15, 1421, 15, 1700, 14, 72, 297, 314, 4877, 2387, 5164, 523, 365, 3943, 2613, 298, 1421, 15, 1700, 14, 72, 2, 1370, 523, 408, 523, 367, 2403, 315, 661, 3455, 3678, 283, 2980, 26985, 272, 340, 931, 14, 2460, 8, 1861, 304, 489, 372, 931, 59, 552, 8, 1861, 15405, 819, 372, 931, 421, 199, 318, 14171, 1173, 8, 504, 63, 515, 12, 370, 63, 515, 304, 523, 408, 2623, 3351, 282, 6135, 15413, 1414, 370, 4057, 282, 570, 687, 1204, 504, 63, 515, 92, 370, 1204, 475, 63, 515, 18257, 523, 408, 523, 340, 440, 747, 14, 2253, 360, 3187, 15413, 450, 83, 450, 83, 7, 450, 334, 504, 63, 515, 12, 370, 63, 515, 430, 508, 378, 26, 272, 746, 2186, 360, 19507, 26, 16277, 370, 1255, 6135, 15413, 1414, 2659, 421, 199, 318, 6162, 6564, 10370, 8, 504, 63, 515, 12, 370, 63, 515, 12, 315, 63, 24042, 304, 523, 408, 13735, 282, 570, 626, 965, 12155, 687, 1204, 504, 63, 515, 92, 370, 1204, 475, 63, 515, 18712, 523, 7029, 314, 12155, 570, 1159, 2387, 24453, 370, 1336, 314, 892, 931, 436, 523, 7029, 1006, 6941, 370, 314, 570, 315, 1163, 1350, 1584, 14, 6121, 11275, 523, 370, 1678, 6941, 315, 1275, 6179, 8, 73, 9, 1584, 1808, 282, 25332, 14, 523, 408, 523, 327, 15783, 3792, 3544, 675, 7568, 20275, 14, 523, 687, 63, 515, 275, 687, 63, 515, 14, 1814, 20786, 15107, 523, 370, 63, 515, 275, 370, 63, 515, 14, 1814, 20786, 15107, 819, 340, 747, 14, 515, 14, 7973, 8, 504, 63, 515, 2788, 17, 61, 315, 18953, 72, 297, 1987, 12156, 2565, 272, 6162, 7826, 18183, 8, 504, 63, 515, 12, 370, 63, 515, 9, 339, 687, 63, 2613, 63, 515, 275, 687, 63, 515, 272, 370, 63, 2613, 63, 515, 275, 370, 63, 515, 272, 340, 315, 63, 24042, 26, 489, 687, 63, 2613, 63, 515, 275, 6162, 7826, 2042, 1858, 34, 1073, 8, 504, 63, 2613, 63, 515, 9, 489, 370, 63, 2613, 63, 515, 275, 6162, 7826, 2042, 1858, 34, 1073, 8, 475, 63, 2613, 63, 515, 9, 339, 327, 6162, 2387, 15, 646, 6941, 14, 272, 1584, 63, 1045, 63, 2489, 63, 9441, 275, 333, 556, 82, 14, 3947, 1173, 6591, 11328, 8, 267, 519, 6774, 3, 8, 2613, 92, 646, 2862, 83, 10, 905, 28, 566, 5, 83, 779, 30, 3135, 7, 450, 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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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 ]
venzozhang/GProject
doc/tutorial/pickle-to-xml.py
392
1500
#!/usr/bin/python # output xml format: # <pages> # <page url="xx"><prev url="yyy">zzz</prev><next url="hhh">lll</next><fragment>file.frag</fragment></page> # ... # </pages> import pickle import os import codecs def dump_pickles(out, dirname, filename, path): f = open(os.path.join(dirname, filename), 'r') data = pickle.load(f) fragment_file = codecs.open(data['current_page_name'] + '.frag', mode='w', encoding='utf-8') fragment_file.write(data['body']) fragment_file.close() out.write(' <page url="%s">\n' % path) out.write(' <fragment>%s.frag</fragment>\n' % data['current_page_name']) if data['prev'] is not None: out.write(' <prev url="%s">%s</prev>\n' % (os.path.normpath(os.path.join(path, data['prev']['link'])), data['prev']['title'])) if data['next'] is not None: out.write(' <next url="%s">%s</next>\n' % (os.path.normpath(os.path.join(path, data['next']['link'])), data['next']['title'])) out.write(' </page>\n') f.close() if data['next'] is not None: next_path = os.path.normpath(os.path.join(path, data['next']['link'])) next_filename = os.path.basename(next_path) + '.fpickle' dump_pickles(out, dirname, next_filename, next_path) return import sys sys.stdout.write('<pages>\n') dump_pickles(sys.stdout, os.path.dirname(sys.argv[1]), os.path.basename(sys.argv[1]), '/') sys.stdout.write('</pages>')
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 421, 199, 3, 1072, 2748, 1475, 26, 199, 3, 665, 5856, 30, 199, 3, 665, 1606, 1166, 628, 2154, 8186, 5701, 1166, 628, 30917, 1743, 29414, 1108, 5701, 2535, 2184, 1166, 628, 12156, 72, 1743, 914, 76, 1108, 2184, 2535, 7677, 30, 493, 14, 11255, 1108, 7677, 2957, 1606, 30, 199, 3, 2263, 199, 3, 3068, 5856, 30, 199, 199, 646, 5927, 199, 646, 747, 199, 646, 6010, 199, 199, 318, 5461, 63, 4510, 2978, 8, 548, 12, 9017, 12, 1788, 12, 931, 304, 272, 289, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 3475, 12, 1788, 395, 283, 82, 358, 272, 666, 275, 5927, 14, 912, 8, 70, 9, 272, 7956, 63, 493, 275, 6010, 14, 1490, 8, 576, 459, 1818, 63, 1606, 63, 354, 418, 435, 1987, 11255, 297, 818, 534, 87, 297, 2644, 534, 1624, 13, 24, 358, 272, 7956, 63, 493, 14, 952, 8, 576, 459, 2030, 1105, 272, 7956, 63, 493, 14, 1600, 342, 272, 734, 14, 952, 360, 221, 665, 1606, 1166, 5961, 83, 14559, 78, 7, 450, 931, 9, 272, 734, 14, 952, 360, 259, 665, 7677, 6598, 83, 14, 11255, 1108, 7677, 3072, 78, 7, 450, 666, 459, 1818, 63, 1606, 63, 354, 1105, 272, 340, 666, 459, 5701, 418, 365, 440, 488, 26, 267, 734, 14, 952, 360, 259, 665, 5701, 1166, 5961, 83, 14423, 83, 1108, 5701, 3072, 78, 7, 450, 20177, 334, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 515, 12, 666, 459, 5701, 2545, 1073, 16607, 718, 666, 459, 5701, 2545, 1213, 5156, 272, 340, 666, 459, 2184, 418, 365, 440, 488, 26, 267, 734, 14, 952, 360, 259, 665, 2184, 1166, 5961, 83, 14423, 83, 1108, 2184, 3072, 78, 7, 450, 20177, 334, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 515, 12, 666, 459, 2184, 2545, 1073, 16607, 718, 666, 459, 2184, 2545, 1213, 5156, 272, 734, 14, 952, 360, 221, 3068, 1606, 3072, 78, 358, 272, 289, 14, 1600, 342, 272, 340, 666, 459, 2184, 418, 365, 440, 488, 26, 267, 2163, 63, 515, 275, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 515, 12, 666, 459, 2184, 2545, 1073, 5156, 267, 2163, 63, 1501, 275, 747, 14, 515, 14, 4846, 8, 2184, 63, 515, 9, 435, 1987, 70, 8092, 7, 267, 5461, 63, 4510, 2978, 8, 548, 12, 9017, 12, 2163, 63, 1501, 12, 2163, 63, 515, 9, 272, 372, 199, 199, 646, 984, 199, 199, 1274, 14, 2703, 14, 952, 4827, 5856, 3072, 78, 358, 199, 2724, 63, 4510, 2978, 8, 1274, 14, 2703, 12, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 17, 2522, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 17, 2522, 15107, 199, 1274, 14, 2703, 14, 952, 14264, 5856, 5971, 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 ]
[ 2647, 15, 1393, 15, 1548, 421, 199, 3, 1072, 2748, 1475, 26, 199, 3, 665, 5856, 30, 199, 3, 665, 1606, 1166, 628, 2154, 8186, 5701, 1166, 628, 30917, 1743, 29414, 1108, 5701, 2535, 2184, 1166, 628, 12156, 72, 1743, 914, 76, 1108, 2184, 2535, 7677, 30, 493, 14, 11255, 1108, 7677, 2957, 1606, 30, 199, 3, 2263, 199, 3, 3068, 5856, 30, 199, 199, 646, 5927, 199, 646, 747, 199, 646, 6010, 199, 199, 318, 5461, 63, 4510, 2978, 8, 548, 12, 9017, 12, 1788, 12, 931, 304, 272, 289, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 3475, 12, 1788, 395, 283, 82, 358, 272, 666, 275, 5927, 14, 912, 8, 70, 9, 272, 7956, 63, 493, 275, 6010, 14, 1490, 8, 576, 459, 1818, 63, 1606, 63, 354, 418, 435, 1987, 11255, 297, 818, 534, 87, 297, 2644, 534, 1624, 13, 24, 358, 272, 7956, 63, 493, 14, 952, 8, 576, 459, 2030, 1105, 272, 7956, 63, 493, 14, 1600, 342, 272, 734, 14, 952, 360, 221, 665, 1606, 1166, 5961, 83, 14559, 78, 7, 450, 931, 9, 272, 734, 14, 952, 360, 259, 665, 7677, 6598, 83, 14, 11255, 1108, 7677, 3072, 78, 7, 450, 666, 459, 1818, 63, 1606, 63, 354, 1105, 272, 340, 666, 459, 5701, 418, 365, 440, 488, 26, 267, 734, 14, 952, 360, 259, 665, 5701, 1166, 5961, 83, 14423, 83, 1108, 5701, 3072, 78, 7, 450, 20177, 334, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 515, 12, 666, 459, 5701, 2545, 1073, 16607, 718, 666, 459, 5701, 2545, 1213, 5156, 272, 340, 666, 459, 2184, 418, 365, 440, 488, 26, 267, 734, 14, 952, 360, 259, 665, 2184, 1166, 5961, 83, 14423, 83, 1108, 2184, 3072, 78, 7, 450, 20177, 334, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 515, 12, 666, 459, 2184, 2545, 1073, 16607, 718, 666, 459, 2184, 2545, 1213, 5156, 272, 734, 14, 952, 360, 221, 3068, 1606, 3072, 78, 358, 272, 289, 14, 1600, 342, 272, 340, 666, 459, 2184, 418, 365, 440, 488, 26, 267, 2163, 63, 515, 275, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 515, 12, 666, 459, 2184, 2545, 1073, 5156, 267, 2163, 63, 1501, 275, 747, 14, 515, 14, 4846, 8, 2184, 63, 515, 9, 435, 1987, 70, 8092, 7, 267, 5461, 63, 4510, 2978, 8, 548, 12, 9017, 12, 2163, 63, 1501, 12, 2163, 63, 515, 9, 272, 372, 199, 199, 646, 984, 199, 199, 1274, 14, 2703, 14, 952, 4827, 5856, 3072, 78, 358, 199, 2724, 63, 4510, 2978, 8, 1274, 14, 2703, 12, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 17, 2522, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 17, 2522, 15107, 199, 1274, 14, 2703, 14, 952, 14264, 5856, 5971, 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, 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,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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 ]
albertjan/pypyjs
website/js/pypy.js-0.2.0/lib/modules/distutils/sysconfig_pypy.py
10
4713
"""Provide access to Python's configuration information. This is actually PyPy's minimal configuration information. The specific configuration variables available depend heavily on the platform and configuration. The values may be retrieved using get_config_var(name), and the list of variables is available via get_config_vars().keys(). Additional convenience functions are also available. """ __revision__ = "$Id: sysconfig.py 85358 2010-10-10 09:54:59Z antoine.pitrou $" import sys import os import shlex from distutils.errors import DistutilsPlatformError PREFIX = os.path.normpath(sys.prefix) EXEC_PREFIX = os.path.normpath(sys.exec_prefix) project_base = os.path.dirname(os.path.abspath(sys.executable)) python_build = False def get_python_inc(plat_specific=0, prefix=None): from os.path import join as j return j(sys.prefix, 'include') def get_python_version(): """Return a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'. """ return sys.version[:3] def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. If 'prefix' is supplied, use it instead of sys.prefix or sys.exec_prefix -- i.e., ignore 'plat_specific'. """ if prefix is None: prefix = PREFIX if standard_lib: return os.path.join(prefix, "lib-python", get_python_version()) return os.path.join(prefix, 'site-packages') _config_vars = None def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} g['EXE'] = "" g['SO'] = ".so" g['SOABI'] = g['SO'].rsplit('.')[0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check global _config_vars _config_vars = g def _init_nt(): """Initialize the module as appropriate for NT""" g = {} g['EXE'] = ".exe" g['SO'] = ".pyd" g['SOABI'] = g['SO'].rsplit('.')[0] global _config_vars _config_vars = g def get_config_vars(*args): """With no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes everything needed to build extensions and install both pure modules and extensions. On Unix, this means every variable defined in Python's installed Makefile; on Windows and Mac OS it's a much smaller set. With arguments, return a list of values that result from looking up each argument in the configuration variable dictionary. """ global _config_vars if _config_vars is None: func = globals().get("_init_" + os.name) if func: func() else: _config_vars = {} _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX if args: vals = [] for name in args: vals.append(_config_vars.get(name)) return vals else: return _config_vars def get_config_var(name): """Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) """ return get_config_vars().get(name) def customize_compiler(compiler): """Dummy method to let some easy_install packages that have optional C speedup components. """ if compiler.compiler_type == "unix": compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit']) compiler.shared_lib_extension = get_config_var('SO') if "CPPFLAGS" in os.environ: cppflags = shlex.split(os.environ["CPPFLAGS"]) compiler.compiler.extend(cppflags) compiler.compiler_so.extend(cppflags) compiler.linker_so.extend(cppflags) if "CFLAGS" in os.environ: cflags = shlex.split(os.environ["CFLAGS"]) compiler.compiler.extend(cflags) compiler.compiler_so.extend(cflags) compiler.linker_so.extend(cflags) if "LDFLAGS" in os.environ: ldflags = shlex.split(os.environ["LDFLAGS"]) compiler.linker_so.extend(ldflags) from sysconfig_cpython import ( parse_makefile, _variable_rx, expand_makefile_vars)
mit
[ 624, 25107, 2879, 370, 2018, 1159, 2897, 2556, 14, 199, 2765, 365, 5965, 1611, 2713, 1159, 13460, 2897, 2556, 14, 199, 199, 1918, 2488, 2897, 2860, 2808, 11687, 946, 1214, 3444, 641, 314, 199, 3246, 436, 2897, 14, 221, 710, 1338, 1443, 506, 12396, 1808, 199, 362, 63, 888, 63, 1391, 8, 354, 395, 436, 314, 769, 402, 2860, 365, 2808, 4799, 199, 362, 63, 888, 63, 2936, 1252, 1612, 1252, 221, 10961, 16777, 3423, 787, 2597, 199, 4561, 14, 199, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 22381, 14, 647, 1695, 7920, 24, 7129, 13, 709, 13, 709, 21798, 26, 1477, 26, 1427, 58, 27384, 79, 1132, 14, 80, 390, 7930, 2672, 2, 199, 199, 646, 984, 199, 646, 747, 199, 646, 16701, 199, 199, 504, 7065, 14, 2550, 492, 12577, 10397, 547, 421, 199, 6351, 275, 747, 14, 515, 14, 9267, 8, 1274, 14, 1861, 9, 199, 10276, 63, 6351, 275, 747, 14, 515, 14, 9267, 8, 1274, 14, 1628, 63, 1861, 9, 199, 1715, 63, 1095, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 1274, 14, 5904, 430, 199, 1548, 63, 1506, 275, 756, 421, 199, 318, 664, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 29, 16, 12, 2403, 29, 403, 304, 272, 687, 747, 14, 515, 492, 4263, 465, 1335, 272, 372, 1335, 8, 1274, 14, 1861, 12, 283, 2613, 358, 199, 199, 318, 664, 63, 1548, 63, 1023, 837, 272, 408, 1767, 282, 1059, 3035, 314, 12160, 436, 12612, 2018, 1015, 12, 272, 23188, 2331, 314, 3371, 1896, 14, 221, 15227, 372, 1338, 4293, 506, 283, 17, 14, 21, 7, 272, 503, 283, 18, 14, 18, 1370, 272, 408, 272, 372, 984, 14, 1023, 1491, 19, 61, 421, 199, 318, 664, 63, 1548, 63, 773, 8, 14156, 63, 6100, 29, 16, 12, 4465, 63, 773, 29, 16, 12, 2403, 29, 403, 304, 272, 408, 1767, 314, 2082, 3035, 314, 2018, 3555, 334, 6807, 503, 272, 4770, 32113, 680, 339, 982, 283, 14156, 63, 6100, 7, 365, 2549, 12, 372, 314, 2082, 3035, 272, 4298, 13, 6100, 4621, 12, 284, 14, 69, 14, 1263, 859, 687, 282, 2222, 13, 5115, 13, 4718, 272, 859, 4084, 27, 4257, 12, 372, 314, 4298, 13, 5555, 3555, 272, 2082, 14, 221, 982, 283, 6807, 63, 773, 7, 365, 2549, 12, 372, 314, 2082, 272, 3035, 4465, 2018, 3555, 4621, 27, 4257, 12, 372, 314, 272, 2082, 367, 4770, 13, 6100, 4621, 14, 339, 982, 283, 1861, 7, 365, 6841, 12, 675, 652, 3140, 402, 984, 14, 1861, 503, 272, 984, 14, 1628, 63, 1861, 1553, 284, 14, 69, 2020, 3686, 283, 14156, 63, 6100, 1370, 272, 408, 272, 340, 2403, 365, 488, 26, 267, 2403, 275, 27884, 272, 340, 4465, 63, 773, 26, 267, 372, 747, 14, 515, 14, 904, 8, 1861, 12, 298, 773, 13, 1548, 401, 664, 63, 1548, 63, 1023, 1012, 272, 372, 747, 14, 515, 14, 904, 8, 1861, 12, 283, 2124, 13, 5154, 358, 421, 199, 63, 888, 63, 2936, 275, 488, 199, 199, 318, 485, 826, 63, 9228, 837, 272, 408, 9345, 314, 859, 465, 5827, 367, 18169, 10460, 1041, 272, 486, 275, 1052, 272, 486, 459, 23017, 418, 275, 3087, 272, 486, 459, 4118, 418, 275, 3680, 1152, 2, 272, 486, 459, 4118, 1217, 41, 418, 275, 486, 459, 4118, 2278, 13490, 19237, 16, 61, 272, 486, 459, 5617, 3022, 418, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 1861, 12, 283, 773, 358, 272, 486, 459, 2571, 418, 275, 298, 13112, 446, 27869, 2, 327, 446, 27869, 5594, 440, 506, 1686, 641, 4403, 15, 56, 12, 1104, 339, 2288, 485, 888, 63, 2936, 272, 485, 888, 63, 2936, 275, 486, 421, 199, 318, 485, 826, 63, 343, 837, 272, 408, 9345, 314, 859, 465, 5827, 367, 23350, 624, 272, 486, 275, 1052, 272, 486, 459, 23017, 418, 275, 3680, 5803, 2, 272, 486, 459, 4118, 418, 275, 3680, 647, 68, 2, 272, 486, 459, 4118, 1217, 41, 418, 275, 486, 459, 4118, 2278, 13490, 19237, 16, 61, 339, 2288, 485, 888, 63, 2936, 272, 485, 888, 63, 2936, 275, 486, 421, 199, 318, 664, 63, 888, 63, 2936, 2031, 589, 304, 272, 408, 3007, 949, 2368, 12, 372, 282, 2600, 402, 1006, 2897, 272, 2860, 12082, 367, 314, 1453, 4298, 14, 221, 1464, 1183, 642, 6952, 272, 8137, 4346, 370, 1900, 5478, 436, 3907, 3865, 15111, 4621, 436, 272, 5478, 14, 221, 4068, 13074, 12, 642, 4910, 4036, 1750, 3247, 315, 2018, 1159, 272, 4903, 20618, 27, 641, 5417, 436, 10444, 4403, 652, 1159, 282, 8298, 12700, 663, 14, 339, 8777, 2368, 12, 372, 282, 769, 402, 1338, 626, 754, 687, 10023, 1536, 272, 1924, 1423, 315, 314, 2897, 1750, 2600, 14, 272, 408, 272, 2288, 485, 888, 63, 2936, 272, 340, 485, 888, 63, 2936, 365, 488, 26, 267, 2562, 275, 7992, 1252, 362, 11008, 826, 12172, 435, 747, 14, 354, 9, 267, 340, 2562, 26, 288, 2562, 342, 267, 587, 26, 288, 485, 888, 63, 2936, 275, 1052, 398, 485, 888, 63, 2936, 459, 1861, 418, 275, 27884, 267, 485, 888, 63, 2936, 459, 1628, 63, 1861, 418, 275, 3651, 4220, 63, 6351, 339, 340, 1249, 26, 267, 5322, 275, 942, 267, 367, 536, 315, 1249, 26, 288, 5322, 14, 740, 1547, 888, 63, 2936, 14, 362, 8, 354, 430, 267, 372, 5322, 272, 587, 26, 267, 372, 485, 888, 63, 2936, 199, 199, 318, 664, 63, 888, 63, 1391, 8, 354, 304, 272, 408, 1767, 314, 574, 402, 282, 2849, 1750, 1808, 314, 2600, 272, 2138, 701, 283, 362, 63, 888, 63, 2936, 342, 1370, 221, 24228, 370, 272, 664, 63, 888, 63, 2936, 1252, 362, 8, 354, 9, 272, 408, 272, 372, 664, 63, 888, 63, 2936, 1252, 362, 8, 354, 9, 199, 199, 318, 17551, 63, 5772, 8, 5772, 304, 272, 408, 11324, 1083, 370, 4691, 2005, 8837, 63, 3174, 6117, 626, 1172, 272, 2716, 445, 8112, 384, 7323, 14, 272, 408, 272, 340, 6365, 14, 5772, 63, 466, 508, 298, 11864, 582, 267, 6365, 14, 5772, 63, 1152, 14, 2880, 24829, 47, 18, 297, 2475, 70, 26769, 297, 2475 ]
[ 25107, 2879, 370, 2018, 1159, 2897, 2556, 14, 199, 2765, 365, 5965, 1611, 2713, 1159, 13460, 2897, 2556, 14, 199, 199, 1918, 2488, 2897, 2860, 2808, 11687, 946, 1214, 3444, 641, 314, 199, 3246, 436, 2897, 14, 221, 710, 1338, 1443, 506, 12396, 1808, 199, 362, 63, 888, 63, 1391, 8, 354, 395, 436, 314, 769, 402, 2860, 365, 2808, 4799, 199, 362, 63, 888, 63, 2936, 1252, 1612, 1252, 221, 10961, 16777, 3423, 787, 2597, 199, 4561, 14, 199, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 26, 22381, 14, 647, 1695, 7920, 24, 7129, 13, 709, 13, 709, 21798, 26, 1477, 26, 1427, 58, 27384, 79, 1132, 14, 80, 390, 7930, 2672, 2, 199, 199, 646, 984, 199, 646, 747, 199, 646, 16701, 199, 199, 504, 7065, 14, 2550, 492, 12577, 10397, 547, 421, 199, 6351, 275, 747, 14, 515, 14, 9267, 8, 1274, 14, 1861, 9, 199, 10276, 63, 6351, 275, 747, 14, 515, 14, 9267, 8, 1274, 14, 1628, 63, 1861, 9, 199, 1715, 63, 1095, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 1274, 14, 5904, 430, 199, 1548, 63, 1506, 275, 756, 421, 199, 318, 664, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 29, 16, 12, 2403, 29, 403, 304, 272, 687, 747, 14, 515, 492, 4263, 465, 1335, 272, 372, 1335, 8, 1274, 14, 1861, 12, 283, 2613, 358, 199, 199, 318, 664, 63, 1548, 63, 1023, 837, 272, 408, 1767, 282, 1059, 3035, 314, 12160, 436, 12612, 2018, 1015, 12, 272, 23188, 2331, 314, 3371, 1896, 14, 221, 15227, 372, 1338, 4293, 506, 283, 17, 14, 21, 7, 272, 503, 283, 18, 14, 18, 1370, 272, 408, 272, 372, 984, 14, 1023, 1491, 19, 61, 421, 199, 318, 664, 63, 1548, 63, 773, 8, 14156, 63, 6100, 29, 16, 12, 4465, 63, 773, 29, 16, 12, 2403, 29, 403, 304, 272, 408, 1767, 314, 2082, 3035, 314, 2018, 3555, 334, 6807, 503, 272, 4770, 32113, 680, 339, 982, 283, 14156, 63, 6100, 7, 365, 2549, 12, 372, 314, 2082, 3035, 272, 4298, 13, 6100, 4621, 12, 284, 14, 69, 14, 1263, 859, 687, 282, 2222, 13, 5115, 13, 4718, 272, 859, 4084, 27, 4257, 12, 372, 314, 4298, 13, 5555, 3555, 272, 2082, 14, 221, 982, 283, 6807, 63, 773, 7, 365, 2549, 12, 372, 314, 2082, 272, 3035, 4465, 2018, 3555, 4621, 27, 4257, 12, 372, 314, 272, 2082, 367, 4770, 13, 6100, 4621, 14, 339, 982, 283, 1861, 7, 365, 6841, 12, 675, 652, 3140, 402, 984, 14, 1861, 503, 272, 984, 14, 1628, 63, 1861, 1553, 284, 14, 69, 2020, 3686, 283, 14156, 63, 6100, 1370, 272, 408, 272, 340, 2403, 365, 488, 26, 267, 2403, 275, 27884, 272, 340, 4465, 63, 773, 26, 267, 372, 747, 14, 515, 14, 904, 8, 1861, 12, 298, 773, 13, 1548, 401, 664, 63, 1548, 63, 1023, 1012, 272, 372, 747, 14, 515, 14, 904, 8, 1861, 12, 283, 2124, 13, 5154, 358, 421, 199, 63, 888, 63, 2936, 275, 488, 199, 199, 318, 485, 826, 63, 9228, 837, 272, 408, 9345, 314, 859, 465, 5827, 367, 18169, 10460, 1041, 272, 486, 275, 1052, 272, 486, 459, 23017, 418, 275, 3087, 272, 486, 459, 4118, 418, 275, 3680, 1152, 2, 272, 486, 459, 4118, 1217, 41, 418, 275, 486, 459, 4118, 2278, 13490, 19237, 16, 61, 272, 486, 459, 5617, 3022, 418, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 1861, 12, 283, 773, 358, 272, 486, 459, 2571, 418, 275, 298, 13112, 446, 27869, 2, 327, 446, 27869, 5594, 440, 506, 1686, 641, 4403, 15, 56, 12, 1104, 339, 2288, 485, 888, 63, 2936, 272, 485, 888, 63, 2936, 275, 486, 421, 199, 318, 485, 826, 63, 343, 837, 272, 408, 9345, 314, 859, 465, 5827, 367, 23350, 624, 272, 486, 275, 1052, 272, 486, 459, 23017, 418, 275, 3680, 5803, 2, 272, 486, 459, 4118, 418, 275, 3680, 647, 68, 2, 272, 486, 459, 4118, 1217, 41, 418, 275, 486, 459, 4118, 2278, 13490, 19237, 16, 61, 339, 2288, 485, 888, 63, 2936, 272, 485, 888, 63, 2936, 275, 486, 421, 199, 318, 664, 63, 888, 63, 2936, 2031, 589, 304, 272, 408, 3007, 949, 2368, 12, 372, 282, 2600, 402, 1006, 2897, 272, 2860, 12082, 367, 314, 1453, 4298, 14, 221, 1464, 1183, 642, 6952, 272, 8137, 4346, 370, 1900, 5478, 436, 3907, 3865, 15111, 4621, 436, 272, 5478, 14, 221, 4068, 13074, 12, 642, 4910, 4036, 1750, 3247, 315, 2018, 1159, 272, 4903, 20618, 27, 641, 5417, 436, 10444, 4403, 652, 1159, 282, 8298, 12700, 663, 14, 339, 8777, 2368, 12, 372, 282, 769, 402, 1338, 626, 754, 687, 10023, 1536, 272, 1924, 1423, 315, 314, 2897, 1750, 2600, 14, 272, 408, 272, 2288, 485, 888, 63, 2936, 272, 340, 485, 888, 63, 2936, 365, 488, 26, 267, 2562, 275, 7992, 1252, 362, 11008, 826, 12172, 435, 747, 14, 354, 9, 267, 340, 2562, 26, 288, 2562, 342, 267, 587, 26, 288, 485, 888, 63, 2936, 275, 1052, 398, 485, 888, 63, 2936, 459, 1861, 418, 275, 27884, 267, 485, 888, 63, 2936, 459, 1628, 63, 1861, 418, 275, 3651, 4220, 63, 6351, 339, 340, 1249, 26, 267, 5322, 275, 942, 267, 367, 536, 315, 1249, 26, 288, 5322, 14, 740, 1547, 888, 63, 2936, 14, 362, 8, 354, 430, 267, 372, 5322, 272, 587, 26, 267, 372, 485, 888, 63, 2936, 199, 199, 318, 664, 63, 888, 63, 1391, 8, 354, 304, 272, 408, 1767, 314, 574, 402, 282, 2849, 1750, 1808, 314, 2600, 272, 2138, 701, 283, 362, 63, 888, 63, 2936, 342, 1370, 221, 24228, 370, 272, 664, 63, 888, 63, 2936, 1252, 362, 8, 354, 9, 272, 408, 272, 372, 664, 63, 888, 63, 2936, 1252, 362, 8, 354, 9, 199, 199, 318, 17551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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 ]
willingc/oh-mainline
vendor/packages/Django/django/contrib/localflavor/id/id_choices.py
439
3217
import warnings from django.utils.translation import ugettext_lazy as _ # Reference: http://id.wikipedia.org/wiki/Daftar_provinsi_Indonesia # Indonesia does not have an official Province code standard. # I decided to use unambiguous and consistent (some are common) 3-letter codes. warnings.warn( 'There have been recent changes to the ID localflavor. See the release notes for details', RuntimeWarning ) PROVINCE_CHOICES = ( ('ACE', _('Aceh')), ('BLI', _('Bali')), ('BTN', _('Banten')), ('BKL', _('Bengkulu')), ('DIY', _('Yogyakarta')), ('JKT', _('Jakarta')), ('GOR', _('Gorontalo')), ('JMB', _('Jambi')), ('JBR', _('Jawa Barat')), ('JTG', _('Jawa Tengah')), ('JTM', _('Jawa Timur')), ('KBR', _('Kalimantan Barat')), ('KSL', _('Kalimantan Selatan')), ('KTG', _('Kalimantan Tengah')), ('KTM', _('Kalimantan Timur')), ('BBL', _('Kepulauan Bangka-Belitung')), ('KRI', _('Kepulauan Riau')), ('LPG', _('Lampung')), ('MLK', _('Maluku')), ('MUT', _('Maluku Utara')), ('NTB', _('Nusa Tenggara Barat')), ('NTT', _('Nusa Tenggara Timur')), ('PPA', _('Papua')), ('PPB', _('Papua Barat')), ('RIU', _('Riau')), ('SLB', _('Sulawesi Barat')), ('SLS', _('Sulawesi Selatan')), ('SLT', _('Sulawesi Tengah')), ('SLR', _('Sulawesi Tenggara')), ('SLU', _('Sulawesi Utara')), ('SMB', _('Sumatera Barat')), ('SMS', _('Sumatera Selatan')), ('SMU', _('Sumatera Utara')), ) LICENSE_PLATE_PREFIX_CHOICES = ( ('A', _('Banten')), ('AA', _('Magelang')), ('AB', _('Yogyakarta')), ('AD', _('Surakarta - Solo')), ('AE', _('Madiun')), ('AG', _('Kediri')), ('B', _('Jakarta')), ('BA', _('Sumatera Barat')), ('BB', _('Tapanuli')), ('BD', _('Bengkulu')), ('BE', _('Lampung')), ('BG', _('Sumatera Selatan')), ('BH', _('Jambi')), ('BK', _('Sumatera Utara')), ('BL', _('Nanggroe Aceh Darussalam')), ('BM', _('Riau')), ('BN', _('Kepulauan Bangka Belitung')), ('BP', _('Kepulauan Riau')), ('CC', _('Corps Consulate')), ('CD', _('Corps Diplomatic')), ('D', _('Bandung')), ('DA', _('Kalimantan Selatan')), ('DB', _('Sulawesi Utara Daratan')), ('DC', _('Sulawesi Barat')), ('DD', _('Sulawesi Selatan')), ('DE', _('Maluku')), ('DG', _('Maluku Utara')), ('DH', _('NTT - Timor')), ('DK', _('Bali')), ('DL', _('Sulawesi Utara Kepulauan')), ('DM', _('Gorontalo')), ('DN', _('Sulawesi Tengah')), ('DR', _('NTB - Lombok')), ('DS', _('Papua dan Papua Barat')), ('DT', _('Sulawesi Tenggara')), ('E', _('Cirebon')), ('EA', _('NTB - Sumbawa')), ('EB', _('NTT - Flores')), ('ED', _('NTT - Sumba')), ('F', _('Bogor')), ('G', _('Pekalongan')), ('H', _('Semarang')), ('K', _('Pati')), ('KB', _('Kalimantan Barat')), ('KH', _('Kalimantan Tengah')), ('KT', _('Kalimantan Timur')), ('L', _('Surabaya')), ('M', _('Madura')), ('N', _('Malang')), ('P', _('Jember')), ('R', _('Banyumas')), ('RI', _('Federal Government')), ('S', _('Bojonegoro')), ('T', _('Purwakarta')), ('W', _('Sidoarjo')), ('Z', _('Garut')), )
agpl-3.0
[ 646, 3598, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 3, 10944, 26, 1455, 921, 344, 14, 13961, 14, 1308, 15, 6797, 15, 25014, 856, 285, 63, 496, 11908, 338, 63, 607, 4456, 10971, 199, 199, 3, 473, 977, 368, 10971, 1630, 440, 1172, 376, 25410, 2165, 86, 2855, 1233, 4465, 14, 199, 3, 473, 12985, 770, 370, 675, 625, 26465, 436, 12137, 334, 3972, 787, 2863, 9, 650, 13, 9269, 9479, 14, 199, 199, 5451, 14, 4050, 8, 272, 283, 10924, 1172, 2757, 8058, 4493, 370, 314, 2870, 560, 696, 276, 4271, 14, 1666, 314, 4683, 12681, 367, 2436, 297, 272, 25178, 199, 9, 199, 199, 2514, 54, 568, 2089, 63, 16236, 275, 334, 272, 661, 4121, 297, 4018, 33, 301, 72, 3855, 272, 661, 34, 2673, 297, 4018, 34, 10874, 3855, 272, 661, 19162, 46, 297, 4018, 28018, 724, 3855, 272, 661, 34, 14307, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 1914, 57, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 42, 12362, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 39, 726, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 42, 4567, 297, 4018, 42, 455, 4492, 3855, 272, 661, 42, 7184, 297, 4018, 42, 65, 758, 12377, 292, 3855, 272, 661, 42, 6332, 297, 4018, 42, 65, 758, 377, 287, 5294, 72, 3855, 272, 661, 42, 20690, 297, 4018, 42, 65, 758, 26244, 300, 3855, 272, 661, 43, 7184, 297, 4018, 43, 279, 1017, 867, 290, 12377, 292, 3855, 272, 661, 43, 4929, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 43, 6332, 297, 4018, 43, 279, 1017, 867, 290, 377, 287, 5294, 72, 3855, 272, 661, 12362, 45, 297, 4018, 43, 279, 1017, 867, 290, 26244, 300, 3855, 272, 661, 5342, 44, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 13, 3655, 1051, 10335, 3855, 272, 661, 43, 6129, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 9257, 39, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 1698, 43, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 25890, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 12460, 34, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 12377, 292, 3855, 272, 661, 46, 1481, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 26244, 300, 3855, 272, 661, 7701, 33, 297, 4018, 48, 439, 1458, 3855, 272, 661, 7701, 34, 297, 4018, 48, 439, 1458, 12377, 292, 3855, 272, 661, 6129, 53, 297, 4018, 28522, 3844, 3855, 272, 661, 4929, 34, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 4929, 51, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 4929, 52, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4929, 50, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 4929, 53, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 3855, 272, 661, 23304, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 51, 3053, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 4029, 53, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 199, 9, 199, 199, 3961, 63, 2749, 1951, 63, 6351, 63, 16236, 275, 334, 272, 661, 33, 297, 4018, 28018, 724, 3855, 272, 661, 2276, 297, 4018, 45, 474, 4159, 3855, 272, 661, 1217, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 1554, 297, 4018, 11762, 1151, 29549, 446, 2002, 320, 3855, 272, 661, 12500, 297, 4018, 11903, 328, 324, 3855, 272, 661, 1254, 297, 4018, 1136, 328, 322, 3855, 272, 661, 34, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 4134, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 5342, 297, 4018, 27746, 290, 13987, 3855, 272, 661, 11156, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 6773, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 18998, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 29931, 297, 4018, 42, 455, 4492, 3855, 272, 661, 17672, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 272, 661, 7847, 297, 4018, 46, 621, 23260, 69, 437, 301, 72, 577, 285, 27678, 279, 455, 3855, 272, 661, 15225, 297, 4018, 28522, 3844, 3855, 272, 661, 18273, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 6423, 1051, 10335, 3855, 272, 661, 24408, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 2571, 297, 4018, 8380, 1190, 1448, 83, 5434, 3855, 272, 661, 7695, 297, 4018, 8380, 1190, 577, 711, 320, 3889, 3855, 272, 661, 36, 297, 4018, 11675, 10335, 3855, 272, 661, 8980, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 2846, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 577, 285, 16080, 3855, 272, 661, 5196, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 5745, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 1093, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 29173, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 13860, 297, 4018, 46, 1481, 446, 26244, 269, 3855, 272, 661, 10892, 297, 4018, 34, 10874, 3855, 272, 661, 8045, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 25645, 80, 348, 3844, 290, 3855, 272, 661, 17751, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 10872, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4564, 297, 4018, 12460, 34, 446, 491, 676, 656, 75, 3855, 272, 661, 3177, 297, 4018, 48, 439, 1458, 366, 290, 510, 439, 1458, 12377, 292, 3855, 272, 661, 7438, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 37, 297, 4018, 35, 3621, 13520, 3855, 272, 661, 11765, 297, 4018, 12460, 34, 446, 12094, 2470, 758, 3855, 272, 661, 14138, 297, 4018, 46, 1481, 446, 481, 320, 470, 3855, 272, 661, 1149, 297, 4018, 46, 1481, 446, 12094, 2470, 3855, 272, 661, 38, 297, 4018, 34, 974, 269, 3855, 272, 661, 39, 297, 4018, 48, 5711, 21632, 290, 3855, 272 ]
[ 3598, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 3, 10944, 26, 1455, 921, 344, 14, 13961, 14, 1308, 15, 6797, 15, 25014, 856, 285, 63, 496, 11908, 338, 63, 607, 4456, 10971, 199, 199, 3, 473, 977, 368, 10971, 1630, 440, 1172, 376, 25410, 2165, 86, 2855, 1233, 4465, 14, 199, 3, 473, 12985, 770, 370, 675, 625, 26465, 436, 12137, 334, 3972, 787, 2863, 9, 650, 13, 9269, 9479, 14, 199, 199, 5451, 14, 4050, 8, 272, 283, 10924, 1172, 2757, 8058, 4493, 370, 314, 2870, 560, 696, 276, 4271, 14, 1666, 314, 4683, 12681, 367, 2436, 297, 272, 25178, 199, 9, 199, 199, 2514, 54, 568, 2089, 63, 16236, 275, 334, 272, 661, 4121, 297, 4018, 33, 301, 72, 3855, 272, 661, 34, 2673, 297, 4018, 34, 10874, 3855, 272, 661, 19162, 46, 297, 4018, 28018, 724, 3855, 272, 661, 34, 14307, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 1914, 57, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 42, 12362, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 39, 726, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 42, 4567, 297, 4018, 42, 455, 4492, 3855, 272, 661, 42, 7184, 297, 4018, 42, 65, 758, 12377, 292, 3855, 272, 661, 42, 6332, 297, 4018, 42, 65, 758, 377, 287, 5294, 72, 3855, 272, 661, 42, 20690, 297, 4018, 42, 65, 758, 26244, 300, 3855, 272, 661, 43, 7184, 297, 4018, 43, 279, 1017, 867, 290, 12377, 292, 3855, 272, 661, 43, 4929, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 43, 6332, 297, 4018, 43, 279, 1017, 867, 290, 377, 287, 5294, 72, 3855, 272, 661, 12362, 45, 297, 4018, 43, 279, 1017, 867, 290, 26244, 300, 3855, 272, 661, 5342, 44, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 13, 3655, 1051, 10335, 3855, 272, 661, 43, 6129, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 9257, 39, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 1698, 43, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 25890, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 12460, 34, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 12377, 292, 3855, 272, 661, 46, 1481, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 26244, 300, 3855, 272, 661, 7701, 33, 297, 4018, 48, 439, 1458, 3855, 272, 661, 7701, 34, 297, 4018, 48, 439, 1458, 12377, 292, 3855, 272, 661, 6129, 53, 297, 4018, 28522, 3844, 3855, 272, 661, 4929, 34, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 4929, 51, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 4929, 52, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4929, 50, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 4929, 53, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 3855, 272, 661, 23304, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 51, 3053, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 4029, 53, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 199, 9, 199, 199, 3961, 63, 2749, 1951, 63, 6351, 63, 16236, 275, 334, 272, 661, 33, 297, 4018, 28018, 724, 3855, 272, 661, 2276, 297, 4018, 45, 474, 4159, 3855, 272, 661, 1217, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 1554, 297, 4018, 11762, 1151, 29549, 446, 2002, 320, 3855, 272, 661, 12500, 297, 4018, 11903, 328, 324, 3855, 272, 661, 1254, 297, 4018, 1136, 328, 322, 3855, 272, 661, 34, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 4134, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 5342, 297, 4018, 27746, 290, 13987, 3855, 272, 661, 11156, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 6773, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 18998, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 29931, 297, 4018, 42, 455, 4492, 3855, 272, 661, 17672, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 272, 661, 7847, 297, 4018, 46, 621, 23260, 69, 437, 301, 72, 577, 285, 27678, 279, 455, 3855, 272, 661, 15225, 297, 4018, 28522, 3844, 3855, 272, 661, 18273, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 6423, 1051, 10335, 3855, 272, 661, 24408, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 2571, 297, 4018, 8380, 1190, 1448, 83, 5434, 3855, 272, 661, 7695, 297, 4018, 8380, 1190, 577, 711, 320, 3889, 3855, 272, 661, 36, 297, 4018, 11675, 10335, 3855, 272, 661, 8980, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 2846, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 577, 285, 16080, 3855, 272, 661, 5196, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 5745, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 1093, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 29173, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 13860, 297, 4018, 46, 1481, 446, 26244, 269, 3855, 272, 661, 10892, 297, 4018, 34, 10874, 3855, 272, 661, 8045, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 25645, 80, 348, 3844, 290, 3855, 272, 661, 17751, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 10872, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4564, 297, 4018, 12460, 34, 446, 491, 676, 656, 75, 3855, 272, 661, 3177, 297, 4018, 48, 439, 1458, 366, 290, 510, 439, 1458, 12377, 292, 3855, 272, 661, 7438, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 37, 297, 4018, 35, 3621, 13520, 3855, 272, 661, 11765, 297, 4018, 12460, 34, 446, 12094, 2470, 758, 3855, 272, 661, 14138, 297, 4018, 46, 1481, 446, 481, 320, 470, 3855, 272, 661, 1149, 297, 4018, 46, 1481, 446, 12094, 2470, 3855, 272, 661, 38, 297, 4018, 34, 974, 269, 3855, 272, 661, 39, 297, 4018, 48, 5711, 21632, 290, 3855, 272, 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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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 ]
gqwest-erp/server
openerp/addons/fetchmail/res_config.py
437
5234
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv class fetchmail_config_settings(osv.osv_memory): """ This wizard can be inherited in conjunction with 'res.config.settings', in order to define fields that configure a fetchmail server. It relies on the following convention on the object:: class my_config_settings(osv.osv_memory): _name = 'my.settings' _inherit = ['res.config.settings', 'fetchmail.config.settings'] _columns = { 'fetchmail_stuff': fields.boolean(..., fetchmail_model='my.stuff', fetchmail_name='Incoming Stuff'), } def configure_fetchmail_stuff(self, cr, uid, ids, context=None): return self.configure_fetchmail(cr, uid, 'fetchmail_stuff', context) and in the form view:: <field name="fetchmail_stuff"/> <button type="object" name="configure_fetchmail_stuff"/> The method ``get_default_fetchmail`` determines the value of all fields that start with 'fetchmail_'. It looks up fetchmail server configurations that match the given model name (``fetchmail_model``) and are active. The button action ``configure_fetchmail_stuff`` is caught by the object, and calls automatically the method ``configure_fetchmail``; it opens the fetchmail server configuration form for the corresponding field. """ _name = 'fetchmail.config.settings' def get_default_fetchmail(self, cr, uid, fields, context=None): """ determine the value of all fields like 'fetchmail_XXX' """ ir_model = self.pool.get('ir.model') fetchmail_server = self.pool.get('fetchmail.server') fetchmail_fields = [f for f in fields if f.startswith('fetchmail_')] res = {} for f in fetchmail_fields: model_name = self._columns[f].fetchmail_model model_id = ir_model.search(cr, uid, [('model', '=', model_name)])[0] server_ids = fetchmail_server.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'done')]) res[f] = bool(server_ids) return res def set_fetchmail(self, cr, uid, ids, context=None): """ deactivate fetchmail servers for all fields like 'fetchmail_XXX' that are False """ config = self.browse(cr, uid, ids[0], context) fetchmail_fields = [f for f in self._columns if f.startswith('fetchmail_')] # determine which models should not have active fetchmail servers, and # deactivate all active servers for those models models = [self._columns[f].fetchmail_model for f in fetchmail_fields if not config[f]] if models: fetchmail_server = self.pool.get('fetchmail.server') server_ids = fetchmail_server.search(cr, uid, [('object_id.model', 'in', models), ('state', '=', 'done')]) fetchmail_server.set_draft(cr, uid, server_ids, context) def configure_fetchmail(self, cr, uid, field, context=None): """ open the form view of the fetchmail.server to configure """ action = { 'type': 'ir.actions.act_window', 'res_model': 'fetchmail.server', 'view_mode': 'form', 'target': 'current', } model_name = self._columns[field].fetchmail_model model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', model_name)])[0] server_ids = self.pool.get('fetchmail.server').search(cr, uid, [('object_id', '=', model_id)]) if server_ids: action['res_id'] = server_ids[0] else: action['context'] = { 'default_name': self._columns[field].fetchmail_name, 'default_object_id': model_id, } return action def __getattr__(self, name): """ catch calls to 'configure_fetchmail_XXX' """ if name.startswith('configure_fetchmail_'): return (lambda cr, uid, ids, context=None: self.configure_fetchmail(cr, uid, name[10:], context)) return super(fetchmail_config_settings, self).__getattr__(name) # 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, 23813, 24636, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 428, 14, 33, 14, 8642, 1014, 921, 11267, 14, 957, 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, 9506, 199, 199, 533, 5267, 1198, 63, 888, 63, 1751, 8, 4795, 14, 4795, 63, 4844, 304, 272, 408, 961, 12262, 883, 506, 12623, 315, 22888, 543, 283, 470, 14, 888, 14, 1751, 297, 315, 1865, 370, 267, 5627, 1504, 626, 7908, 282, 5267, 1198, 1654, 14, 398, 2779, 25749, 641, 314, 2569, 16129, 641, 314, 909, 447, 953, 1021, 3002, 63, 888, 63, 1751, 8, 4795, 14, 4795, 63, 4844, 304, 355, 485, 354, 275, 283, 1662, 14, 1751, 7, 355, 485, 6486, 275, 788, 470, 14, 888, 14, 1751, 297, 283, 3535, 1198, 14, 888, 14, 1751, 418, 2234, 485, 3406, 275, 469, 490, 283, 3535, 1198, 63, 14573, 356, 1504, 14, 4871, 8, 11577, 717, 5267, 1198, 63, 1238, 534, 1662, 14, 14573, 297, 5267, 1198, 63, 354, 534, 607, 7909, 1933, 3043, 659, 355, 789, 2234, 347, 7908, 63, 3535, 1198, 63, 14573, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 490, 372, 291, 14, 6472, 63, 3535, 1198, 8, 1556, 12, 1747, 12, 283, 3535, 1198, 63, 14573, 297, 1067, 9, 398, 436, 315, 314, 1824, 2455, 447, 953, 665, 698, 536, 628, 3535, 1198, 63, 14573, 7897, 288, 665, 3887, 730, 628, 785, 2, 536, 628, 6472, 63, 3535, 1198, 63, 14573, 7897, 398, 710, 1083, 1124, 362, 63, 885, 63, 3535, 1198, 1040, 16756, 314, 574, 402, 1006, 1504, 626, 1343, 267, 543, 283, 3535, 1198, 63, 1370, 221, 2779, 10734, 1536, 5267, 1198, 1654, 13422, 626, 1336, 314, 1627, 267, 1402, 536, 15693, 3535, 1198, 63, 1238, 16580, 436, 787, 4702, 14, 398, 710, 5528, 1595, 1124, 6472, 63, 3535, 1198, 63, 14573, 1040, 365, 15604, 701, 314, 909, 12, 436, 4882, 267, 5847, 314, 1083, 1124, 6472, 63, 3535, 1198, 1040, 27, 652, 30848, 314, 5267, 1198, 1654, 267, 2897, 1824, 367, 314, 5226, 901, 14, 272, 408, 272, 485, 354, 275, 283, 3535, 1198, 14, 888, 14, 1751, 7, 339, 347, 664, 63, 885, 63, 3535, 1198, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 408, 6705, 314, 574, 402, 1006, 1504, 2839, 283, 3535, 1198, 63, 13933, 7, 408, 267, 8190, 63, 1238, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 358, 267, 5267, 1198, 63, 1000, 275, 291, 14, 2293, 14, 362, 360, 3535, 1198, 14, 1000, 358, 267, 5267, 1198, 63, 955, 275, 359, 70, 367, 289, 315, 1504, 340, 289, 14, 2460, 360, 3535, 1198, 63, 5440, 267, 522, 275, 1052, 267, 367, 289, 315, 5267, 1198, 63, 955, 26, 288, 1402, 63, 354, 275, 291, 423, 3406, 59, 70, 1055, 3535, 1198, 63, 1238, 288, 1402, 63, 344, 275, 8190, 63, 1238, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 1402, 63, 354, 3948, 59, 16, 61, 288, 1654, 63, 1580, 275, 5267, 1198, 63, 1000, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 785, 63, 344, 297, 6291, 1402, 63, 344, 395, 661, 929, 297, 6291, 283, 4456, 2023, 288, 522, 59, 70, 61, 275, 2155, 8, 1000, 63, 1580, 9, 267, 372, 522, 339, 347, 663, 63, 3535, 1198, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 25560, 5267, 1198, 8037, 367, 1006, 1504, 2839, 283, 3535, 1198, 63, 13933, 7, 626, 787, 756, 408, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 9, 267, 5267, 1198, 63, 955, 275, 359, 70, 367, 289, 315, 291, 423, 3406, 340, 289, 14, 2460, 360, 3535, 1198, 63, 5440, 267, 327, 6705, 1314, 1709, 1077, 440, 1172, 4702, 5267, 1198, 8037, 12, 436, 267, 327, 25560, 1006, 4702, 8037, 367, 5204, 1709, 267, 1709, 275, 359, 277, 423, 3406, 59, 70, 1055, 3535, 1198, 63, 1238, 367, 289, 315, 5267, 1198, 63, 955, 340, 440, 1101, 59, 70, 2677, 267, 340, 1709, 26, 288, 5267, 1198, 63, 1000, 275, 291, 14, 2293, 14, 362, 360, 3535, 1198, 14, 1000, 358, 288, 1654, 63, 1580, 275, 5267, 1198, 63, 1000, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 785, 63, 344, 14, 1238, 297, 283, 262, 297, 1709, 395, 661, 929, 297, 6291, 283, 4456, 2023, 288, 5267, 1198, 63, 1000, 14, 409, 63, 7185, 8, 1556, 12, 1747, 12, 1654, 63, 1580, 12, 1067, 9, 339, 347, 7908, 63, 3535, 1198, 8, 277, 12, 2467, 12, 1747, 12, 901, 12, 1067, 29, 403, 304, 267, 408, 1551, 314, 1824, 2455, 402, 314, 5267, 1198, 14, 1000, 370, 7908, 408, 267, 1595, 275, 469, 288, 283, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 288, 283, 470, 63, 1238, 356, 283, 3535, 1198, 14, 1000, 297, 288, 283, 1345, 63, 632, 356, 283, 964, 297, 288, 283, 1375, 356, 283, 1818, 297, 267, 789, 267, 1402 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 428, 14, 33, 14, 8642, 1014, 921, 11267, 14, 957, 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, 9506, 199, 199, 533, 5267, 1198, 63, 888, 63, 1751, 8, 4795, 14, 4795, 63, 4844, 304, 272, 408, 961, 12262, 883, 506, 12623, 315, 22888, 543, 283, 470, 14, 888, 14, 1751, 297, 315, 1865, 370, 267, 5627, 1504, 626, 7908, 282, 5267, 1198, 1654, 14, 398, 2779, 25749, 641, 314, 2569, 16129, 641, 314, 909, 447, 953, 1021, 3002, 63, 888, 63, 1751, 8, 4795, 14, 4795, 63, 4844, 304, 355, 485, 354, 275, 283, 1662, 14, 1751, 7, 355, 485, 6486, 275, 788, 470, 14, 888, 14, 1751, 297, 283, 3535, 1198, 14, 888, 14, 1751, 418, 2234, 485, 3406, 275, 469, 490, 283, 3535, 1198, 63, 14573, 356, 1504, 14, 4871, 8, 11577, 717, 5267, 1198, 63, 1238, 534, 1662, 14, 14573, 297, 5267, 1198, 63, 354, 534, 607, 7909, 1933, 3043, 659, 355, 789, 2234, 347, 7908, 63, 3535, 1198, 63, 14573, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 490, 372, 291, 14, 6472, 63, 3535, 1198, 8, 1556, 12, 1747, 12, 283, 3535, 1198, 63, 14573, 297, 1067, 9, 398, 436, 315, 314, 1824, 2455, 447, 953, 665, 698, 536, 628, 3535, 1198, 63, 14573, 7897, 288, 665, 3887, 730, 628, 785, 2, 536, 628, 6472, 63, 3535, 1198, 63, 14573, 7897, 398, 710, 1083, 1124, 362, 63, 885, 63, 3535, 1198, 1040, 16756, 314, 574, 402, 1006, 1504, 626, 1343, 267, 543, 283, 3535, 1198, 63, 1370, 221, 2779, 10734, 1536, 5267, 1198, 1654, 13422, 626, 1336, 314, 1627, 267, 1402, 536, 15693, 3535, 1198, 63, 1238, 16580, 436, 787, 4702, 14, 398, 710, 5528, 1595, 1124, 6472, 63, 3535, 1198, 63, 14573, 1040, 365, 15604, 701, 314, 909, 12, 436, 4882, 267, 5847, 314, 1083, 1124, 6472, 63, 3535, 1198, 1040, 27, 652, 30848, 314, 5267, 1198, 1654, 267, 2897, 1824, 367, 314, 5226, 901, 14, 272, 408, 272, 485, 354, 275, 283, 3535, 1198, 14, 888, 14, 1751, 7, 339, 347, 664, 63, 885, 63, 3535, 1198, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 408, 6705, 314, 574, 402, 1006, 1504, 2839, 283, 3535, 1198, 63, 13933, 7, 408, 267, 8190, 63, 1238, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 358, 267, 5267, 1198, 63, 1000, 275, 291, 14, 2293, 14, 362, 360, 3535, 1198, 14, 1000, 358, 267, 5267, 1198, 63, 955, 275, 359, 70, 367, 289, 315, 1504, 340, 289, 14, 2460, 360, 3535, 1198, 63, 5440, 267, 522, 275, 1052, 267, 367, 289, 315, 5267, 1198, 63, 955, 26, 288, 1402, 63, 354, 275, 291, 423, 3406, 59, 70, 1055, 3535, 1198, 63, 1238, 288, 1402, 63, 344, 275, 8190, 63, 1238, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 1402, 63, 354, 3948, 59, 16, 61, 288, 1654, 63, 1580, 275, 5267, 1198, 63, 1000, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 785, 63, 344, 297, 6291, 1402, 63, 344, 395, 661, 929, 297, 6291, 283, 4456, 2023, 288, 522, 59, 70, 61, 275, 2155, 8, 1000, 63, 1580, 9, 267, 372, 522, 339, 347, 663, 63, 3535, 1198, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 25560, 5267, 1198, 8037, 367, 1006, 1504, 2839, 283, 3535, 1198, 63, 13933, 7, 626, 787, 756, 408, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 9, 267, 5267, 1198, 63, 955, 275, 359, 70, 367, 289, 315, 291, 423, 3406, 340, 289, 14, 2460, 360, 3535, 1198, 63, 5440, 267, 327, 6705, 1314, 1709, 1077, 440, 1172, 4702, 5267, 1198, 8037, 12, 436, 267, 327, 25560, 1006, 4702, 8037, 367, 5204, 1709, 267, 1709, 275, 359, 277, 423, 3406, 59, 70, 1055, 3535, 1198, 63, 1238, 367, 289, 315, 5267, 1198, 63, 955, 340, 440, 1101, 59, 70, 2677, 267, 340, 1709, 26, 288, 5267, 1198, 63, 1000, 275, 291, 14, 2293, 14, 362, 360, 3535, 1198, 14, 1000, 358, 288, 1654, 63, 1580, 275, 5267, 1198, 63, 1000, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 785, 63, 344, 14, 1238, 297, 283, 262, 297, 1709, 395, 661, 929, 297, 6291, 283, 4456, 2023, 288, 5267, 1198, 63, 1000, 14, 409, 63, 7185, 8, 1556, 12, 1747, 12, 1654, 63, 1580, 12, 1067, 9, 339, 347, 7908, 63, 3535, 1198, 8, 277, 12, 2467, 12, 1747, 12, 901, 12, 1067, 29, 403, 304, 267, 408, 1551, 314, 1824, 2455, 402, 314, 5267, 1198, 14, 1000, 370, 7908, 408, 267, 1595, 275, 469, 288, 283, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 288, 283, 470, 63, 1238, 356, 283, 3535, 1198, 14, 1000, 297, 288, 283, 1345, 63, 632, 356, 283, 964, 297, 288, 283, 1375, 356, 283, 1818, 297, 267, 789, 267, 1402, 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,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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 ]
iut-ibk/DynaMind-UrbanSim
3rdparty/opus/src/psrc/household_x_gridcell/ln_retail_sector_employment_within_walking_distance_if_has_less_cars_than_workers.py
2
2357
# Opus/UrbanSim urban simulation software. # Copyright (C) 2005-2009 University of Washington # See opus_core/LICENSE from opus_core.variables.variable import Variable from urbansim.functions import attribute_label class ln_retail_sector_employment_within_walking_distance_if_has_less_cars_than_workers(Variable): """Ln Retail employment within walking distance if the household has less cars than workers. [retail_employment_within_walking_distance if hh.has_less_cars_than_workers is true else 0]""" rew = "ln_retail_sector_employment_within_walking_distance" hh_has_less_cars_than_workers = "has_less_cars_than_workers" def dependencies(self): return [attribute_label("household", self.hh_has_less_cars_than_workers), attribute_label("gridcell", self.rew)] def compute(self, dataset_pool): return self.get_dataset().interact_attribute_with_condition(self.rew, self.hh_has_less_cars_than_workers) from opus_core.tests import opus_unittest from urbansim.variable_test_toolbox import VariableTestToolbox from numpy import array from numpy import ma from psrc.opus_package_info import package class Tests(opus_unittest.OpusTestCase): variable_name = "psrc.household_x_gridcell.ln_retail_sector_employment_within_walking_distance_if_has_less_cars_than_workers" def test_my_inputs(self): ln_retail_sector_employment_within_walking_distance = array([50, 0, 15]) has_less_cars_than_workers = array([1, 0, 1, 1]) values = VariableTestToolbox().compute_variable(self.variable_name, \ {"gridcell":{ \ "ln_retail_sector_employment_within_walking_distance":ln_retail_sector_employment_within_walking_distance}, \ "household":{ \ "has_less_cars_than_workers":has_less_cars_than_workers}}, \ dataset = "household_x_gridcell") should_be = array([[50, 0, 15], [0, 0, 0], [50, 0, 15], [50, 0, 15]]) self.assertEqual(ma.allclose(values, should_be, rtol=1e-10), \ True, msg = "Error in " + self.variable_name) if __name__=='__main__': opus_unittest.main()
gpl-2.0
[ 3, 593, 8843, 15, 53, 4848, 290, 7467, 7629, 13206, 17625, 2032, 14, 202, 199, 3, 1898, 334, 35, 9, 11811, 13, 8664, 15904, 402, 644, 1119, 31673, 202, 199, 3, 1666, 1687, 527, 63, 1018, 15, 3961, 221, 2999, 199, 504, 1687, 527, 63, 1018, 14, 3669, 14, 1975, 492, 4905, 202, 199, 504, 7629, 13206, 5206, 14, 5777, 492, 2225, 63, 1302, 2999, 199, 533, 10359, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 63, 692, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 8, 2773, 304, 1128, 408, 8940, 820, 6473, 9052, 7775, 4453, 12778, 316, 6033, 340, 314, 25284, 12239, 965, 6656, 286, 4291, 2419, 14123, 14, 1128, 359, 264, 1521, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 340, 25783, 14, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 365, 2549, 587, 378, 61, 624, 258, 11787, 295, 87, 275, 298, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 2, 1128, 25783, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 275, 298, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 2, 26016, 347, 5124, 8, 277, 304, 1039, 372, 359, 3215, 63, 1302, 480, 6740, 12239, 401, 291, 14, 12156, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 395, 2628, 2225, 63, 1302, 480, 3825, 3890, 401, 291, 14, 5257, 1874, 2958, 347, 4526, 8, 277, 12, 4789, 63, 2293, 304, 1039, 372, 291, 14, 362, 63, 5214, 1252, 25850, 63, 3215, 63, 1045, 63, 5394, 8, 277, 14, 5257, 12, 20712, 25405, 291, 14, 12156, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 9, 8740, 2999, 199, 504, 1687, 527, 63, 1018, 14, 2219, 492, 1687, 527, 63, 2796, 202, 199, 504, 7629, 13206, 5206, 14, 1975, 63, 396, 63, 3557, 1977, 492, 4905, 774, 5157, 1977, 202, 199, 504, 2680, 492, 1625, 202, 199, 504, 2680, 492, 610, 202, 199, 504, 299, 2164, 14, 411, 527, 63, 2491, 63, 815, 492, 2559, 2999, 199, 533, 6496, 8, 411, 527, 63, 2796, 14, 4619, 527, 1746, 304, 1128, 1750, 63, 354, 275, 298, 1190, 1195, 14, 6740, 12239, 63, 88, 63, 3825, 3890, 14, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 63, 692, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 2, 11787, 347, 511, 63, 1662, 63, 3711, 8, 277, 304, 1039, 10359, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 275, 1625, 779, 1400, 12, 378, 12, 4114, 566, 1039, 965, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 275, 1625, 779, 17, 12, 378, 12, 413, 12, 413, 566, 1039, 1338, 275, 4905, 774, 5157, 1977, 1252, 3357, 63, 1975, 8, 277, 14, 1975, 63, 354, 12, 971, 1675, 2420, 3825, 3890, 582, 91, 971, 20085, 298, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 582, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 1386, 971, 17554, 298, 6740, 12239, 582, 91, 971, 20085, 298, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 582, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 13459, 971, 1675, 4789, 275, 298, 6740, 12239, 63, 88, 63, 3825, 3890, 531, 1039, 1077, 63, 1235, 275, 1625, 4038, 1400, 12, 378, 12, 4114, 467, 359, 16, 12, 378, 12, 378, 467, 359, 1400, 12, 378, 12, 4114, 467, 359, 1400, 12, 378, 12, 4114, 3934, 13594, 291, 14, 629, 8, 391, 14, 7520, 8, 1459, 12, 1077, 63, 1235, 12, 10561, 29, 17, 69, 13, 709, 395, 971, 202, 586, 715, 12, 1499, 275, 298, 547, 315, 298, 435, 291, 14, 1975, 63, 354, 9, 202, 586, 202, 2079, 202, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 1128, 1687, 527, 63, 2796, 14, 973, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 593, 8843, 15, 53, 4848, 290, 7467, 7629, 13206, 17625, 2032, 14, 202, 199, 3, 1898, 334, 35, 9, 11811, 13, 8664, 15904, 402, 644, 1119, 31673, 202, 199, 3, 1666, 1687, 527, 63, 1018, 15, 3961, 221, 2999, 199, 504, 1687, 527, 63, 1018, 14, 3669, 14, 1975, 492, 4905, 202, 199, 504, 7629, 13206, 5206, 14, 5777, 492, 2225, 63, 1302, 2999, 199, 533, 10359, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 63, 692, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 8, 2773, 304, 1128, 408, 8940, 820, 6473, 9052, 7775, 4453, 12778, 316, 6033, 340, 314, 25284, 12239, 965, 6656, 286, 4291, 2419, 14123, 14, 1128, 359, 264, 1521, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 340, 25783, 14, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 365, 2549, 587, 378, 61, 624, 258, 11787, 295, 87, 275, 298, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 2, 1128, 25783, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 275, 298, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 2, 26016, 347, 5124, 8, 277, 304, 1039, 372, 359, 3215, 63, 1302, 480, 6740, 12239, 401, 291, 14, 12156, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 395, 2628, 2225, 63, 1302, 480, 3825, 3890, 401, 291, 14, 5257, 1874, 2958, 347, 4526, 8, 277, 12, 4789, 63, 2293, 304, 1039, 372, 291, 14, 362, 63, 5214, 1252, 25850, 63, 3215, 63, 1045, 63, 5394, 8, 277, 14, 5257, 12, 20712, 25405, 291, 14, 12156, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 9, 8740, 2999, 199, 504, 1687, 527, 63, 1018, 14, 2219, 492, 1687, 527, 63, 2796, 202, 199, 504, 7629, 13206, 5206, 14, 1975, 63, 396, 63, 3557, 1977, 492, 4905, 774, 5157, 1977, 202, 199, 504, 2680, 492, 1625, 202, 199, 504, 2680, 492, 610, 202, 199, 504, 299, 2164, 14, 411, 527, 63, 2491, 63, 815, 492, 2559, 2999, 199, 533, 6496, 8, 411, 527, 63, 2796, 14, 4619, 527, 1746, 304, 1128, 1750, 63, 354, 275, 298, 1190, 1195, 14, 6740, 12239, 63, 88, 63, 3825, 3890, 14, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 63, 692, 63, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 2, 11787, 347, 511, 63, 1662, 63, 3711, 8, 277, 304, 1039, 10359, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 275, 1625, 779, 1400, 12, 378, 12, 4114, 566, 1039, 965, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 275, 1625, 779, 17, 12, 378, 12, 413, 12, 413, 566, 1039, 1338, 275, 4905, 774, 5157, 1977, 1252, 3357, 63, 1975, 8, 277, 14, 1975, 63, 354, 12, 971, 1675, 2420, 3825, 3890, 582, 91, 971, 20085, 298, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 582, 6066, 63, 264, 1521, 63, 22029, 63, 2109, 7775, 63, 12541, 63, 7757, 316, 63, 5590, 1386, 971, 17554, 298, 6740, 12239, 582, 91, 971, 20085, 298, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 582, 1989, 63, 2003, 63, 67, 4291, 63, 13797, 63, 11009, 13459, 971, 1675, 4789, 275, 298, 6740, 12239, 63, 88, 63, 3825, 3890, 531, 1039, 1077, 63, 1235, 275, 1625, 4038, 1400, 12, 378, 12, 4114, 467, 359, 16, 12, 378, 12, 378, 467, 359, 1400, 12, 378, 12, 4114, 467, 359, 1400, 12, 378, 12, 4114, 3934, 13594, 291, 14, 629, 8, 391, 14, 7520, 8, 1459, 12, 1077, 63, 1235, 12, 10561, 29, 17, 69, 13, 709, 395, 971, 202, 586, 715, 12, 1499, 275, 298, 547, 315, 298, 435, 291, 14, 1975, 63, 354, 9, 202, 586, 202, 2079, 202, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 1128, 1687, 527, 63, 2796, 14, 973, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
brainwane/zulip
zerver/views/storage.py
6
1723
from typing import Dict, List, Optional from django.http import HttpRequest, HttpResponse from zerver.decorator import REQ, has_request_variables from zerver.lib.bot_storage import ( StateError, get_bot_storage, get_keys_in_bot_storage, remove_bot_storage, set_bot_storage, ) from zerver.lib.response import json_error, json_success from zerver.lib.validator import check_dict, check_list, check_string from zerver.models import UserProfile @has_request_variables def update_storage( request: HttpRequest, user_profile: UserProfile, storage: Dict[str, str]=REQ(validator=check_dict([], value_validator=check_string)), ) -> HttpResponse: try: set_bot_storage(user_profile, list(storage.items())) except StateError as e: # nocoverage return json_error(str(e)) return json_success() @has_request_variables def get_storage( request: HttpRequest, user_profile: UserProfile, keys: Optional[List[str]]=REQ(validator=check_list(check_string), default=None), ) -> HttpResponse: keys = keys or get_keys_in_bot_storage(user_profile) try: storage = {key: get_bot_storage(user_profile, key) for key in keys} except StateError as e: return json_error(str(e)) return json_success({'storage': storage}) @has_request_variables def remove_storage( request: HttpRequest, user_profile: UserProfile, keys: Optional[List[str]]=REQ(validator=check_list(check_string), default=None), ) -> HttpResponse: keys = keys or get_keys_in_bot_storage(user_profile) try: remove_bot_storage(user_profile, keys) except StateError as e: return json_error(str(e)) return json_success()
apache-2.0
[ 504, 14090, 492, 7448, 12, 3820, 12, 4879, 199, 199, 504, 1639, 14, 1014, 492, 20730, 12, 6183, 199, 199, 504, 19959, 14, 11547, 492, 5363, 49, 12, 965, 63, 1069, 63, 3669, 199, 504, 19959, 14, 773, 14, 3018, 63, 3494, 492, 334, 272, 8511, 547, 12, 272, 664, 63, 3018, 63, 3494, 12, 272, 664, 63, 1612, 63, 262, 63, 3018, 63, 3494, 12, 272, 2813, 63, 3018, 63, 3494, 12, 272, 663, 63, 3018, 63, 3494, 12, 199, 9, 199, 504, 19959, 14, 773, 14, 1310, 492, 2022, 63, 705, 12, 2022, 63, 3742, 199, 504, 19959, 14, 773, 14, 11034, 492, 1104, 63, 807, 12, 1104, 63, 513, 12, 1104, 63, 875, 199, 504, 19959, 14, 992, 492, 19037, 421, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 1678, 63, 3494, 8, 272, 1056, 26, 20730, 12, 922, 63, 2913, 26, 19037, 12, 272, 4887, 26, 7448, 59, 495, 12, 620, 10404, 14583, 8, 11034, 29, 1074, 63, 807, 8798, 574, 63, 11034, 29, 1074, 63, 875, 1826, 199, 9, 1035, 6183, 26, 272, 862, 26, 267, 663, 63, 3018, 63, 3494, 8, 751, 63, 2913, 12, 769, 8, 3494, 14, 1744, 4059, 272, 871, 8511, 547, 465, 325, 26, 221, 327, 949, 10828, 267, 372, 2022, 63, 705, 8, 495, 8, 69, 430, 272, 372, 2022, 63, 3742, 342, 199, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 664, 63, 3494, 8, 267, 1056, 26, 20730, 12, 267, 922, 63, 2913, 26, 19037, 12, 267, 2883, 26, 4879, 59, 1296, 59, 495, 2677, 29, 14583, 8, 11034, 29, 1074, 63, 513, 8, 1074, 63, 875, 395, 849, 29, 403, 395, 199, 9, 1035, 6183, 26, 272, 2883, 275, 2883, 503, 664, 63, 1612, 63, 262, 63, 3018, 63, 3494, 8, 751, 63, 2913, 9, 272, 862, 26, 267, 4887, 275, 469, 498, 26, 664, 63, 3018, 63, 3494, 8, 751, 63, 2913, 12, 790, 9, 367, 790, 315, 2883, 93, 272, 871, 8511, 547, 465, 325, 26, 267, 372, 2022, 63, 705, 8, 495, 8, 69, 430, 272, 372, 2022, 63, 3742, 3252, 3494, 356, 4887, 1552, 199, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 2813, 63, 3494, 8, 267, 1056, 26, 20730, 12, 267, 922, 63, 2913, 26, 19037, 12, 267, 2883, 26, 4879, 59, 1296, 59, 495, 2677, 29, 14583, 8, 11034, 29, 1074, 63, 513, 8, 1074, 63, 875, 395, 849, 29, 403, 395, 199, 9, 1035, 6183, 26, 272, 2883, 275, 2883, 503, 664, 63, 1612, 63, 262, 63, 3018, 63, 3494, 8, 751, 63, 2913, 9, 272, 862, 26, 267, 2813, 63, 3018, 63, 3494, 8, 751, 63, 2913, 12, 2883, 9, 272, 871, 8511, 547, 465, 325, 26, 267, 372, 2022, 63, 705, 8, 495, 8, 69, 430, 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 ]
[ 14090, 492, 7448, 12, 3820, 12, 4879, 199, 199, 504, 1639, 14, 1014, 492, 20730, 12, 6183, 199, 199, 504, 19959, 14, 11547, 492, 5363, 49, 12, 965, 63, 1069, 63, 3669, 199, 504, 19959, 14, 773, 14, 3018, 63, 3494, 492, 334, 272, 8511, 547, 12, 272, 664, 63, 3018, 63, 3494, 12, 272, 664, 63, 1612, 63, 262, 63, 3018, 63, 3494, 12, 272, 2813, 63, 3018, 63, 3494, 12, 272, 663, 63, 3018, 63, 3494, 12, 199, 9, 199, 504, 19959, 14, 773, 14, 1310, 492, 2022, 63, 705, 12, 2022, 63, 3742, 199, 504, 19959, 14, 773, 14, 11034, 492, 1104, 63, 807, 12, 1104, 63, 513, 12, 1104, 63, 875, 199, 504, 19959, 14, 992, 492, 19037, 421, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 1678, 63, 3494, 8, 272, 1056, 26, 20730, 12, 922, 63, 2913, 26, 19037, 12, 272, 4887, 26, 7448, 59, 495, 12, 620, 10404, 14583, 8, 11034, 29, 1074, 63, 807, 8798, 574, 63, 11034, 29, 1074, 63, 875, 1826, 199, 9, 1035, 6183, 26, 272, 862, 26, 267, 663, 63, 3018, 63, 3494, 8, 751, 63, 2913, 12, 769, 8, 3494, 14, 1744, 4059, 272, 871, 8511, 547, 465, 325, 26, 221, 327, 949, 10828, 267, 372, 2022, 63, 705, 8, 495, 8, 69, 430, 272, 372, 2022, 63, 3742, 342, 199, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 664, 63, 3494, 8, 267, 1056, 26, 20730, 12, 267, 922, 63, 2913, 26, 19037, 12, 267, 2883, 26, 4879, 59, 1296, 59, 495, 2677, 29, 14583, 8, 11034, 29, 1074, 63, 513, 8, 1074, 63, 875, 395, 849, 29, 403, 395, 199, 9, 1035, 6183, 26, 272, 2883, 275, 2883, 503, 664, 63, 1612, 63, 262, 63, 3018, 63, 3494, 8, 751, 63, 2913, 9, 272, 862, 26, 267, 4887, 275, 469, 498, 26, 664, 63, 3018, 63, 3494, 8, 751, 63, 2913, 12, 790, 9, 367, 790, 315, 2883, 93, 272, 871, 8511, 547, 465, 325, 26, 267, 372, 2022, 63, 705, 8, 495, 8, 69, 430, 272, 372, 2022, 63, 3742, 3252, 3494, 356, 4887, 1552, 199, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 2813, 63, 3494, 8, 267, 1056, 26, 20730, 12, 267, 922, 63, 2913, 26, 19037, 12, 267, 2883, 26, 4879, 59, 1296, 59, 495, 2677, 29, 14583, 8, 11034, 29, 1074, 63, 513, 8, 1074, 63, 875, 395, 849, 29, 403, 395, 199, 9, 1035, 6183, 26, 272, 2883, 275, 2883, 503, 664, 63, 1612, 63, 262, 63, 3018, 63, 3494, 8, 751, 63, 2913, 9, 272, 862, 26, 267, 2813, 63, 3018, 63, 3494, 8, 751, 63, 2913, 12, 2883, 9, 272, 871, 8511, 547, 465, 325, 26, 267, 372, 2022, 63, 705, 8, 495, 8, 69, 430, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
RalphBariz/RalphsDotNet
Old/RalphsDotNet.Apps.OptimizationStudio/Resources/PyLib/SocketServer.py
50
24058
"""Generic socket server classes. This module tries to capture the various aspects of defining a server: For socket-based servers: - address family: - AF_INET{,6}: IP (Internet Protocol) sockets (default) - AF_UNIX: Unix domain sockets - others, e.g. AF_DECNET are conceivable (see <socket.h> - socket type: - SOCK_STREAM (reliable stream, e.g. TCP) - SOCK_DGRAM (datagrams, e.g. UDP) For request-based servers (including socket-based): - client address verification before further looking at the request (This is actually a hook for any processing that needs to look at the request before anything else, e.g. logging) - how to handle multiple requests: - synchronous (one request is handled at a time) - forking (each request is handled by a new process) - threading (each request is handled by a new thread) The classes in this module favor the server type that is simplest to write: a synchronous TCP/IP server. This is bad class design, but save some typing. (There's also the issue that a deep class hierarchy slows down method lookups.) There are five classes in an inheritance diagram, four of which represent synchronous servers of four types: +------------+ | BaseServer | +------------+ | v +-----------+ +------------------+ | TCPServer |------->| UnixStreamServer | +-----------+ +------------------+ | v +-----------+ +--------------------+ | UDPServer |------->| UnixDatagramServer | +-----------+ +--------------------+ Note that UnixDatagramServer derives from UDPServer, not from UnixStreamServer -- the only difference between an IP and a Unix stream server is the address family, which is simply repeated in both unix server classes. Forking and threading versions of each type of server can be created using the ForkingMixIn and ThreadingMixIn mix-in classes. For instance, a threading UDP server class is created as follows: class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass The Mix-in class must come first, since it overrides a method defined in UDPServer! Setting the various member variables also changes the behavior of the underlying server mechanism. To implement a service, you must derive a class from BaseRequestHandler and redefine its handle() method. You can then run various versions of the service by combining one of the server classes with your request handler class. The request handler class must be different for datagram or stream services. This can be hidden by using the request handler subclasses StreamRequestHandler or DatagramRequestHandler. Of course, you still have to use your head! For instance, it makes no sense to use a forking server if the service contains state in memory that can be modified by requests (since the modifications in the child process would never reach the initial state kept in the parent process and passed to each child). In this case, you can use a threading server, but you will probably have to use locks to avoid two requests that come in nearly simultaneous to apply conflicting changes to the server state. On the other hand, if you are building e.g. an HTTP server, where all data is stored externally (e.g. in the file system), a synchronous class will essentially render the service "deaf" while one request is being handled -- which may be for a very long time if a client is slow to reqd all the data it has requested. Here a threading or forking server is appropriate. In some cases, it may be appropriate to process part of a request synchronously, but to finish processing in a forked child depending on the request data. This can be implemented by using a synchronous server and doing an explicit fork in the request handler class handle() method. Another approach to handling multiple simultaneous requests in an environment that supports neither threads nor fork (or where these are too expensive or inappropriate for the service) is to maintain an explicit table of partially finished requests and to use select() to decide which request to work on next (or whether to handle a new incoming request). This is particularly important for stream services where each client can potentially be connected for a long time (if threads or subprocesses cannot be used). Future work: - Standard classes for Sun RPC (which uses either UDP or TCP) - Standard mix-in classes to implement various authentication and encryption schemes - Standard framework for select-based multiplexing XXX Open problems: - What to do with out-of-band data? BaseServer: - split generic "request" functionality out into BaseServer class. Copyright (C) 2000 Luke Kenneth Casson Leighton <lkcl@samba.org> example: read entries from a SQL database (requires overriding get_request() to return a table entry from the database). entry is processed by a RequestHandlerClass. """ # Author of the BaseServer patch: Luke Kenneth Casson Leighton # XXX Warning! # There is a test suite for this module, but it cannot be run by the # standard regression test. # To run it manually, run Lib/test/test_socketserver.py. __version__ = "0.4" import socket import select import sys import os try: import threading except ImportError: import dummy_threading as threading __all__ = ["TCPServer","UDPServer","ForkingUDPServer","ForkingTCPServer", "ThreadingUDPServer","ThreadingTCPServer","BaseRequestHandler", "StreamRequestHandler","DatagramRequestHandler", "ThreadingMixIn", "ForkingMixIn"] if hasattr(socket, "AF_UNIX"): __all__.extend(["UnixStreamServer","UnixDatagramServer", "ThreadingUnixStreamServer", "ThreadingUnixDatagramServer"]) class BaseServer: """Base class for server classes. Methods for the caller: - __init__(server_address, RequestHandlerClass) - serve_forever(poll_interval=0.5) - shutdown() - handle_request() # if you do not use serve_forever() - fileno() -> int # for select() Methods that may be overridden: - server_bind() - server_activate() - get_request() -> request, client_address - handle_timeout() - verify_request(request, client_address) - server_close() - process_request(request, client_address) - shutdown_request(request) - close_request(request) - handle_error() Methods for derived classes: - finish_request(request, client_address) Class variables that may be overridden by derived classes or instances: - timeout - address_family - socket_type - allow_reuse_address Instance variables: - RequestHandlerClass - socket """ timeout = None def __init__(self, server_address, RequestHandlerClass): """Constructor. May be extended, do not override.""" self.server_address = server_address self.RequestHandlerClass = RequestHandlerClass self.__is_shut_down = threading.Event() self.__shutdown_request = False def server_activate(self): """Called by constructor to activate the server. May be overridden. """ pass def serve_forever(self, poll_interval=0.5): """Handle one request at a time until shutdown. Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread. """ self.__is_shut_down.clear() try: while not self.__shutdown_request: # XXX: Consider using another file descriptor or # connecting to the socket to wake this up instead of # polling. Polling reduces our responsiveness to a # shutdown request and wastes cpu at all other times. r, w, e = select.select([self], [], [], poll_interval) if self in r: self._handle_request_noblock() finally: self.__shutdown_request = False self.__is_shut_down.set() def shutdown(self): """Stops the serve_forever loop. Blocks until the loop has finished. This must be called while serve_forever() is running in another thread, or it will deadlock. """ self.__shutdown_request = True self.__is_shut_down.wait() # The distinction between handling, getting, processing and # finishing a request is fairly arbitrary. Remember: # # - handle_request() is the top-level call. It calls # select, get_request(), verify_request() and process_request() # - get_request() is different for stream or datagram sockets # - process_request() is the place that may fork a new process # or create a new thread to finish the request # - finish_request() instantiates the request handler class; # this constructor will handle the request all by itself def handle_request(self): """Handle one request, possibly blocking. Respects self.timeout. """ # Support people who used socket.settimeout() to escape # handle_request before self.timeout was available. timeout = self.socket.gettimeout() if timeout is None: timeout = self.timeout elif self.timeout is not None: timeout = min(timeout, self.timeout) fd_sets = select.select([self], [], [], timeout) if not fd_sets[0]: self.handle_timeout() return self._handle_request_noblock() def _handle_request_noblock(self): """Handle one request, without blocking. I assume that select.select has returned that the socket is readable before this function was called, so there should be no risk of blocking in get_request(). """ try: request, client_address = self.get_request() except socket.error: return if self.verify_request(request, client_address): try: self.process_request(request, client_address) except: self.handle_error(request, client_address) self.shutdown_request(request) def handle_timeout(self): """Called if no new request arrives within self.timeout. Overridden by ForkingMixIn. """ pass def verify_request(self, request, client_address): """Verify the request. May be overridden. Return True if we should proceed with this request. """ return True def process_request(self, request, client_address): """Call finish_request. Overridden by ForkingMixIn and ThreadingMixIn. """ self.finish_request(request, client_address) self.shutdown_request(request) def server_close(self): """Called to clean-up the server. May be overridden. """ pass def finish_request(self, request, client_address): """Finish one request by instantiating RequestHandlerClass.""" self.RequestHandlerClass(request, client_address, self) def shutdown_request(self, request): """Called to shutdown and close an individual request.""" self.close_request(request) def close_request(self, request): """Called to clean up an individual request.""" pass def handle_error(self, request, client_address): """Handle an error gracefully. May be overridden. The default is to print a traceback and continue. """ print '-'*40 print 'Exception happened during processing of request from', print client_address import traceback traceback.print_exc() # XXX But this goes to stderr! print '-'*40 class TCPServer(BaseServer): """Base class for various socket-based server classes. Defaults to synchronous IP stream (i.e., TCP). Methods for the caller: - __init__(server_address, RequestHandlerClass, bind_and_activate=True) - serve_forever(poll_interval=0.5) - shutdown() - handle_request() # if you don't use serve_forever() - fileno() -> int # for select() Methods that may be overridden: - server_bind() - server_activate() - get_request() -> request, client_address - handle_timeout() - verify_request(request, client_address) - process_request(request, client_address) - shutdown_request(request) - close_request(request) - handle_error() Methods for derived classes: - finish_request(request, client_address) Class variables that may be overridden by derived classes or instances: - timeout - address_family - socket_type - request_queue_size (only for stream sockets) - allow_reuse_address Instance variables: - server_address - RequestHandlerClass - socket """ address_family = socket.AF_INET socket_type = socket.SOCK_STREAM request_queue_size = 5 allow_reuse_address = False def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True): """Constructor. May be extended, do not override.""" BaseServer.__init__(self, server_address, RequestHandlerClass) self.socket = socket.socket(self.address_family, self.socket_type) if bind_and_activate: self.server_bind() self.server_activate() def server_bind(self): """Called by constructor to bind the socket. May be overridden. """ if self.allow_reuse_address: self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.bind(self.server_address) self.server_address = self.socket.getsockname() def server_activate(self): """Called by constructor to activate the server. May be overridden. """ self.socket.listen(self.request_queue_size) def server_close(self): """Called to clean-up the server. May be overridden. """ self.socket.close() def fileno(self): """Return socket file number. Interface required by select(). """ return self.socket.fileno() def get_request(self): """Get the request and client address from the socket. May be overridden. """ return self.socket.accept() def shutdown_request(self, request): """Called to shutdown and close an individual request.""" try: #explicitly shutdown. socket.close() merely releases #the socket and waits for GC to perform the actual close. request.shutdown(socket.SHUT_WR) except socket.error: pass #some platforms may raise ENOTCONN here self.close_request(request) def close_request(self, request): """Called to clean up an individual request.""" request.close() class UDPServer(TCPServer): """UDP server class.""" allow_reuse_address = False socket_type = socket.SOCK_DGRAM max_packet_size = 8192 def get_request(self): data, client_addr = self.socket.recvfrom(self.max_packet_size) return (data, self.socket), client_addr def server_activate(self): # No need to call listen() for UDP. pass def shutdown_request(self, request): # No need to shutdown anything. self.close_request(request) def close_request(self, request): # No need to close anything. pass class ForkingMixIn: """Mix-in class to handle each request in a new process.""" timeout = 300 active_children = None max_children = 40 def collect_children(self): """Internal routine to wait for children that have exited.""" if self.active_children is None: return while len(self.active_children) >= self.max_children: # XXX: This will wait for any child process, not just ones # spawned by this library. This could confuse other # libraries that expect to be able to wait for their own # children. try: pid, status = os.waitpid(0, 0) except os.error: pid = None if pid not in self.active_children: continue self.active_children.remove(pid) # XXX: This loop runs more system calls than it ought # to. There should be a way to put the active_children into a # process group and then use os.waitpid(-pgid) to wait for any # of that set, but I couldn't find a way to allocate pgids # that couldn't collide. for child in self.active_children: try: pid, status = os.waitpid(child, os.WNOHANG) except os.error: pid = None if not pid: continue try: self.active_children.remove(pid) except ValueError, e: raise ValueError('%s. x=%d and list=%r' % (e.message, pid, self.active_children)) def handle_timeout(self): """Wait for zombies after self.timeout seconds of inactivity. May be extended, do not override. """ self.collect_children() def process_request(self, request, client_address): """Fork a new subprocess to process the request.""" self.collect_children() pid = os.fork() if pid: # Parent process if self.active_children is None: self.active_children = [] self.active_children.append(pid) self.close_request(request) #close handle in parent process return else: # Child process. # This must never return, hence os._exit()! try: self.finish_request(request, client_address) self.shutdown_request(request) os._exit(0) except: try: self.handle_error(request, client_address) self.shutdown_request(request) finally: os._exit(1) class ThreadingMixIn: """Mix-in class to handle each request in a new thread.""" # Decides how threads will act upon termination of the # main process daemon_threads = False def process_request_thread(self, request, client_address): """Same as in BaseServer but as a thread. In addition, exception handling is done here. """ try: self.finish_request(request, client_address) self.shutdown_request(request) except: self.handle_error(request, client_address) self.shutdown_request(request) def process_request(self, request, client_address): """Start a new thread to process the request.""" t = threading.Thread(target = self.process_request_thread, args = (request, client_address)) if self.daemon_threads: t.setDaemon (1) t.start() class ForkingUDPServer(ForkingMixIn, UDPServer): pass class ForkingTCPServer(ForkingMixIn, TCPServer): pass class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass if hasattr(socket, 'AF_UNIX'): class UnixStreamServer(TCPServer): address_family = socket.AF_UNIX class UnixDatagramServer(UDPServer): address_family = socket.AF_UNIX class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): pass class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): pass class BaseRequestHandler: """Base class for request handler classes. This class is instantiated for each request to be handled. The constructor sets the instance variables request, client_address and server, and then calls the handle() method. To implement a specific service, all you need to do is to derive a class which defines a handle() method. The handle() method can find the request as self.request, the client address as self.client_address, and the server (in case it needs access to per-server information) as self.server. Since a separate instance is created for each request, the handle() method can define arbitrary other instance variariables. """ def __init__(self, request, client_address, server): self.request = request self.client_address = client_address self.server = server self.setup() try: self.handle() finally: self.finish() def setup(self): pass def handle(self): pass def finish(self): pass # The following two classes make it possible to use the same service # class for stream or datagram servers. # Each class sets up these instance variables: # - rfile: a file object from which receives the request is read # - wfile: a file object to which the reply is written # When the handle() method returns, wfile is flushed properly class StreamRequestHandler(BaseRequestHandler): """Define self.rfile and self.wfile for stream sockets.""" # Default buffer sizes for rfile, wfile. # We default rfile to buffered because otherwise it could be # really slow for large data (a getc() call per byte); we make # wfile unbuffered because (a) often after a write() we want to # read and we need to flush the line; (b) big writes to unbuffered # files are typically optimized by stdio even when big reads # aren't. rbufsize = -1 wbufsize = 0 # A timeout to apply to the request socket, if not None. timeout = None # Disable nagle algorithm for this socket, if True. # Use only when wbufsize != 0, to avoid small packets. disable_nagle_algorithm = False def setup(self): self.connection = self.request if self.timeout is not None: self.connection.settimeout(self.timeout) if self.disable_nagle_algorithm: self.connection.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) self.rfile = self.connection.makefile('rb', self.rbufsize) self.wfile = self.connection.makefile('wb', self.wbufsize) def finish(self): if not self.wfile.closed: self.wfile.flush() self.wfile.close() self.rfile.close() class DatagramRequestHandler(BaseRequestHandler): # XXX Regrettably, I cannot get this working on Linux; # s.recvfrom() doesn't return a meaningful client address. """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): try: from cStringIO import StringIO except ImportError: from StringIO import StringIO self.packet, self.socket = self.request self.rfile = StringIO(self.packet) self.wfile = StringIO() def finish(self): self.socket.sendto(self.wfile.getvalue(), self.client_address)
gpl-3.0
[ 624, 9417, 2838, 1654, 3992, 14, 2999, 199, 2765, 859, 11275, 370, 12296, 314, 7750, 17435, 83, 402, 12669, 282, 1654, 26, 2999, 199, 1858, 2838, 13, 6788, 8037, 26, 2999, 199, 13, 2287, 9614, 26, 1039, 446, 20089, 63, 11367, 91, 12, 22, 9160, 3531, 334, 29820, 11557, 9, 18772, 334, 885, 9, 1039, 446, 20089, 63, 19584, 26, 13074, 2881, 18772, 1039, 446, 11789, 12, 325, 14, 71, 14, 20089, 63, 16387, 7278, 787, 406, 2375, 461, 334, 3239, 665, 3450, 14, 72, 30, 202, 199, 13, 2838, 730, 26, 1039, 446, 26327, 63, 9484, 334, 26557, 461, 2547, 12, 325, 14, 71, 14, 13488, 9, 1039, 446, 26327, 63, 25351, 334, 576, 9292, 12, 325, 14, 71, 14, 21802, 9, 2999, 199, 1858, 1056, 13, 6788, 8037, 334, 15768, 2838, 13, 6788, 304, 2999, 199, 13, 1890, 2287, 14786, 2544, 9848, 10023, 737, 314, 1056, 1039, 334, 2765, 365, 5965, 282, 5759, 367, 1263, 6661, 626, 4839, 370, 3648, 8740, 737, 314, 1056, 2544, 7003, 587, 12, 325, 14, 71, 14, 2050, 9, 202, 199, 13, 4212, 370, 2429, 3663, 4145, 26, 1039, 446, 24248, 334, 368, 1056, 365, 8860, 737, 282, 900, 9, 1039, 446, 14926, 316, 334, 10885, 1056, 365, 8860, 701, 282, 892, 2112, 9, 1039, 446, 5796, 334, 10885, 1056, 365, 8860, 701, 282, 892, 2462, 9, 2999, 199, 1918, 3992, 315, 642, 859, 17914, 314, 1654, 730, 626, 365, 3486, 270, 370, 202, 199, 952, 26, 282, 24248, 13488, 15, 1772, 1654, 14, 221, 961, 365, 4875, 1021, 12899, 12, 1325, 202, 199, 2117, 2005, 14090, 14, 221, 334, 10924, 1159, 2597, 314, 4976, 626, 282, 13217, 1021, 14446, 202, 199, 14362, 83, 3224, 1083, 16807, 4959, 2999, 199, 10924, 787, 24187, 3992, 315, 376, 15433, 8348, 5975, 12, 11648, 402, 1314, 2954, 202, 199, 83, 9865, 8037, 402, 11648, 2943, 26, 4341, 435, 4559, 11, 1039, 1204, 3523, 3120, 1204, 1039, 435, 4559, 11, 23284, 1204, 23284, 373, 1039, 435, 27592, 263, 24680, 12557, 1039, 1204, 13488, 3120, 1204, 12797, 21521, 13074, 3296, 3120, 1204, 1039, 435, 27592, 263, 24680, 12557, 23284, 1204, 23284, 373, 1039, 435, 27592, 263, 24680, 32752, 1039, 1204, 21802, 3120, 1204, 12797, 21521, 13074, 1451, 1679, 3120, 1204, 1039, 435, 27592, 263, 24680, 32752, 2999, 199, 7443, 626, 13074, 1451, 1679, 3120, 5405, 2310, 687, 21802, 3120, 12, 440, 687, 202, 199, 21607, 3296, 3120, 1553, 314, 1454, 8865, 3382, 376, 3531, 436, 282, 13074, 202, 199, 1745, 1654, 365, 314, 2287, 9614, 12, 1314, 365, 9329, 10877, 315, 3865, 202, 199, 11864, 1654, 3992, 14, 2999, 199, 1858, 17443, 436, 5796, 5459, 402, 1924, 730, 402, 1654, 883, 506, 2737, 202, 199, 4941, 314, 2104, 17443, 26527, 436, 11086, 316, 26527, 13667, 13, 262, 3992, 14, 221, 2104, 202, 199, 842, 12, 282, 5796, 21802, 1654, 1021, 365, 2737, 465, 11924, 26, 4341, 1021, 11086, 316, 17457, 3120, 8, 4436, 316, 26527, 12, 21802, 3120, 304, 986, 2999, 199, 1918, 603, 1148, 13, 262, 1021, 1471, 11492, 1642, 12, 3967, 652, 10580, 282, 1083, 3247, 202, 199, 262, 21802, 3120, 1, 13510, 314, 7750, 3653, 2860, 2597, 4493, 202, 199, 1589, 5953, 402, 314, 8793, 1654, 14729, 14, 2999, 199, 1378, 5669, 282, 2435, 12, 1265, 1471, 23519, 282, 1021, 687, 202, 199, 1563, 11149, 436, 295, 4640, 2399, 2429, 342, 1083, 14, 221, 2047, 883, 2066, 1255, 202, 199, 3808, 1785, 5459, 402, 314, 2435, 701, 29391, 1373, 402, 314, 1654, 3992, 202, 199, 1045, 2195, 1056, 3016, 1021, 14, 2999, 199, 1918, 1056, 3016, 1021, 1471, 506, 3365, 367, 666, 1679, 503, 2547, 202, 199, 5950, 14, 221, 961, 883, 506, 8752, 701, 1808, 314, 1056, 3016, 202, 199, 19094, 8271, 11149, 503, 3918, 1679, 11149, 14, 2999, 199, 3466, 2518, 12, 1265, 5139, 1172, 370, 675, 2195, 4854, 1, 2999, 199, 1858, 1256, 12, 652, 7704, 949, 12249, 370, 675, 282, 14926, 316, 1654, 340, 314, 2435, 202, 199, 6134, 1174, 315, 4402, 626, 883, 506, 6042, 701, 4145, 334, 8585, 314, 202, 199, 20945, 83, 315, 314, 1982, 2112, 3955, 7078, 12276, 314, 2536, 1174, 202, 199, 415, 541, 315, 314, 1676, 2112, 436, 3032, 370, 1924, 1982, 680, 221, 1010, 642, 1930, 12, 202, 199, 13297, 883, 675, 282, 5796, 1654, 12, 1325, 1265, 911, 8646, 1172, 370, 675, 202, 199, 20218, 370, 5126, 2877, 4145, 626, 11492, 315, 17429, 590, 27008, 370, 4838, 202, 199, 15207, 316, 4493, 370, 314, 1654, 1174, 14, 2999, 199, 3314, 314, 1163, 4926, 12, 340, 1265, 787, 10015, 325, 14, 71, 14, 376, 3101, 1654, 12, 2382, 1006, 202, 199, 576, 365, 5489, 21815, 1183, 334, 69, 14, 71, 14, 315, 314, 570, 2656, 395, 282, 24248, 202, 199, 533, 911, 28891, 3795, 314, 2435, 298, 271, 2756, 2, 1830, 1373, 1056, 365, 202, 199, 1235, 316, 8860, 1553, 1314, 1443, 506, 367, 282, 7437, 1846, 900, 340, 282, 1890, 365, 11999, 202, 199, 475, 2648, 68, 1006, 314, 666, 652, 965, 5839, 14, 221, 11842, 282, 5796, 503, 14926, 316, 202, 199, 1000, 365, 5827, 14, 2999, 199, 607, 2005, 5560, 12, 652, 1443, 506, 5827, 370, 2112, 1777, 402, 282, 1056, 202, 199, 83, 9865, 590, 12, 1325, 370, 9578, 6661, 315, 282, 14926, 379, 1982, 10298, 641, 202, 199, 1589, 1056, 666, 14, 221, 961, 883, 506, 6366, 701, 1808, 282, 24248, 202, 199, 1000, 436, 9689, 376, 5027, 14926, 315, 314, 1056, 3016, 1021, 202, 199, 2479, 342, 1083, 14, 2999, 199, 23296, 18140, 370, 7252, 3663, 27008, 4145, 315, 376, 202, 199, 5418, 626, 5171, 15564, 7183, 6590, 14926, 334, 269, 2382, 3520, 787, 202, 199, 7354, 23133, 503, 315, 11227, 5655, 367, 314, 2435, 9, 365, 370, 11075, 376, 202, 199, 10306, 1817, 402, 25172, 9158, 4145, 436, 370, 675, 3504, 342, 370, 202, 199, 22612, 271, 1314, 1056, 370, 1736, 641, 2163, 334, 269, 3775, 370, 2429, 282, 892, 202, 199, 15994, 1056, 680, 221, 961, 365, 6770, 590, 11012, 367, 2547, 8500, 202, 199, 4509, 1924, 1890, 883, 18994, 506, 8539, 367, 282, 1846, 900, 334, 692, 202, 199, 6962, 503, 1007, 11816, 3913, 506, 1202, 680, 2999, 199 ]
[ 9417, 2838, 1654, 3992, 14, 2999, 199, 2765, 859, 11275, 370, 12296, 314, 7750, 17435, 83, 402, 12669, 282, 1654, 26, 2999, 199, 1858, 2838, 13, 6788, 8037, 26, 2999, 199, 13, 2287, 9614, 26, 1039, 446, 20089, 63, 11367, 91, 12, 22, 9160, 3531, 334, 29820, 11557, 9, 18772, 334, 885, 9, 1039, 446, 20089, 63, 19584, 26, 13074, 2881, 18772, 1039, 446, 11789, 12, 325, 14, 71, 14, 20089, 63, 16387, 7278, 787, 406, 2375, 461, 334, 3239, 665, 3450, 14, 72, 30, 202, 199, 13, 2838, 730, 26, 1039, 446, 26327, 63, 9484, 334, 26557, 461, 2547, 12, 325, 14, 71, 14, 13488, 9, 1039, 446, 26327, 63, 25351, 334, 576, 9292, 12, 325, 14, 71, 14, 21802, 9, 2999, 199, 1858, 1056, 13, 6788, 8037, 334, 15768, 2838, 13, 6788, 304, 2999, 199, 13, 1890, 2287, 14786, 2544, 9848, 10023, 737, 314, 1056, 1039, 334, 2765, 365, 5965, 282, 5759, 367, 1263, 6661, 626, 4839, 370, 3648, 8740, 737, 314, 1056, 2544, 7003, 587, 12, 325, 14, 71, 14, 2050, 9, 202, 199, 13, 4212, 370, 2429, 3663, 4145, 26, 1039, 446, 24248, 334, 368, 1056, 365, 8860, 737, 282, 900, 9, 1039, 446, 14926, 316, 334, 10885, 1056, 365, 8860, 701, 282, 892, 2112, 9, 1039, 446, 5796, 334, 10885, 1056, 365, 8860, 701, 282, 892, 2462, 9, 2999, 199, 1918, 3992, 315, 642, 859, 17914, 314, 1654, 730, 626, 365, 3486, 270, 370, 202, 199, 952, 26, 282, 24248, 13488, 15, 1772, 1654, 14, 221, 961, 365, 4875, 1021, 12899, 12, 1325, 202, 199, 2117, 2005, 14090, 14, 221, 334, 10924, 1159, 2597, 314, 4976, 626, 282, 13217, 1021, 14446, 202, 199, 14362, 83, 3224, 1083, 16807, 4959, 2999, 199, 10924, 787, 24187, 3992, 315, 376, 15433, 8348, 5975, 12, 11648, 402, 1314, 2954, 202, 199, 83, 9865, 8037, 402, 11648, 2943, 26, 4341, 435, 4559, 11, 1039, 1204, 3523, 3120, 1204, 1039, 435, 4559, 11, 23284, 1204, 23284, 373, 1039, 435, 27592, 263, 24680, 12557, 1039, 1204, 13488, 3120, 1204, 12797, 21521, 13074, 3296, 3120, 1204, 1039, 435, 27592, 263, 24680, 12557, 23284, 1204, 23284, 373, 1039, 435, 27592, 263, 24680, 32752, 1039, 1204, 21802, 3120, 1204, 12797, 21521, 13074, 1451, 1679, 3120, 1204, 1039, 435, 27592, 263, 24680, 32752, 2999, 199, 7443, 626, 13074, 1451, 1679, 3120, 5405, 2310, 687, 21802, 3120, 12, 440, 687, 202, 199, 21607, 3296, 3120, 1553, 314, 1454, 8865, 3382, 376, 3531, 436, 282, 13074, 202, 199, 1745, 1654, 365, 314, 2287, 9614, 12, 1314, 365, 9329, 10877, 315, 3865, 202, 199, 11864, 1654, 3992, 14, 2999, 199, 1858, 17443, 436, 5796, 5459, 402, 1924, 730, 402, 1654, 883, 506, 2737, 202, 199, 4941, 314, 2104, 17443, 26527, 436, 11086, 316, 26527, 13667, 13, 262, 3992, 14, 221, 2104, 202, 199, 842, 12, 282, 5796, 21802, 1654, 1021, 365, 2737, 465, 11924, 26, 4341, 1021, 11086, 316, 17457, 3120, 8, 4436, 316, 26527, 12, 21802, 3120, 304, 986, 2999, 199, 1918, 603, 1148, 13, 262, 1021, 1471, 11492, 1642, 12, 3967, 652, 10580, 282, 1083, 3247, 202, 199, 262, 21802, 3120, 1, 13510, 314, 7750, 3653, 2860, 2597, 4493, 202, 199, 1589, 5953, 402, 314, 8793, 1654, 14729, 14, 2999, 199, 1378, 5669, 282, 2435, 12, 1265, 1471, 23519, 282, 1021, 687, 202, 199, 1563, 11149, 436, 295, 4640, 2399, 2429, 342, 1083, 14, 221, 2047, 883, 2066, 1255, 202, 199, 3808, 1785, 5459, 402, 314, 2435, 701, 29391, 1373, 402, 314, 1654, 3992, 202, 199, 1045, 2195, 1056, 3016, 1021, 14, 2999, 199, 1918, 1056, 3016, 1021, 1471, 506, 3365, 367, 666, 1679, 503, 2547, 202, 199, 5950, 14, 221, 961, 883, 506, 8752, 701, 1808, 314, 1056, 3016, 202, 199, 19094, 8271, 11149, 503, 3918, 1679, 11149, 14, 2999, 199, 3466, 2518, 12, 1265, 5139, 1172, 370, 675, 2195, 4854, 1, 2999, 199, 1858, 1256, 12, 652, 7704, 949, 12249, 370, 675, 282, 14926, 316, 1654, 340, 314, 2435, 202, 199, 6134, 1174, 315, 4402, 626, 883, 506, 6042, 701, 4145, 334, 8585, 314, 202, 199, 20945, 83, 315, 314, 1982, 2112, 3955, 7078, 12276, 314, 2536, 1174, 202, 199, 415, 541, 315, 314, 1676, 2112, 436, 3032, 370, 1924, 1982, 680, 221, 1010, 642, 1930, 12, 202, 199, 13297, 883, 675, 282, 5796, 1654, 12, 1325, 1265, 911, 8646, 1172, 370, 675, 202, 199, 20218, 370, 5126, 2877, 4145, 626, 11492, 315, 17429, 590, 27008, 370, 4838, 202, 199, 15207, 316, 4493, 370, 314, 1654, 1174, 14, 2999, 199, 3314, 314, 1163, 4926, 12, 340, 1265, 787, 10015, 325, 14, 71, 14, 376, 3101, 1654, 12, 2382, 1006, 202, 199, 576, 365, 5489, 21815, 1183, 334, 69, 14, 71, 14, 315, 314, 570, 2656, 395, 282, 24248, 202, 199, 533, 911, 28891, 3795, 314, 2435, 298, 271, 2756, 2, 1830, 1373, 1056, 365, 202, 199, 1235, 316, 8860, 1553, 1314, 1443, 506, 367, 282, 7437, 1846, 900, 340, 282, 1890, 365, 11999, 202, 199, 475, 2648, 68, 1006, 314, 666, 652, 965, 5839, 14, 221, 11842, 282, 5796, 503, 14926, 316, 202, 199, 1000, 365, 5827, 14, 2999, 199, 607, 2005, 5560, 12, 652, 1443, 506, 5827, 370, 2112, 1777, 402, 282, 1056, 202, 199, 83, 9865, 590, 12, 1325, 370, 9578, 6661, 315, 282, 14926, 379, 1982, 10298, 641, 202, 199, 1589, 1056, 666, 14, 221, 961, 883, 506, 6366, 701, 1808, 282, 24248, 202, 199, 1000, 436, 9689, 376, 5027, 14926, 315, 314, 1056, 3016, 1021, 202, 199, 2479, 342, 1083, 14, 2999, 199, 23296, 18140, 370, 7252, 3663, 27008, 4145, 315, 376, 202, 199, 5418, 626, 5171, 15564, 7183, 6590, 14926, 334, 269, 2382, 3520, 787, 202, 199, 7354, 23133, 503, 315, 11227, 5655, 367, 314, 2435, 9, 365, 370, 11075, 376, 202, 199, 10306, 1817, 402, 25172, 9158, 4145, 436, 370, 675, 3504, 342, 370, 202, 199, 22612, 271, 1314, 1056, 370, 1736, 641, 2163, 334, 269, 3775, 370, 2429, 282, 892, 202, 199, 15994, 1056, 680, 221, 961, 365, 6770, 590, 11012, 367, 2547, 8500, 202, 199, 4509, 1924, 1890, 883, 18994, 506, 8539, 367, 282, 1846, 900, 334, 692, 202, 199, 6962, 503, 1007, 11816, 3913, 506, 1202, 680, 2999, 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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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 ]
totolef/Sick-beard
lib/requests/packages/chardet2/chardistribution.py
62
8495
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client 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 . import constants from .euctwfreq import EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE, EUCTW_TYPICAL_DISTRIBUTION_RATIO from .euckrfreq import EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE, EUCKR_TYPICAL_DISTRIBUTION_RATIO from .gb2312freq import GB2312CharToFreqOrder, GB2312_TABLE_SIZE, GB2312_TYPICAL_DISTRIBUTION_RATIO from .big5freq import Big5CharToFreqOrder, BIG5_TABLE_SIZE, BIG5_TYPICAL_DISTRIBUTION_RATIO from .jisfreq import JISCharToFreqOrder, JIS_TABLE_SIZE, JIS_TYPICAL_DISTRIBUTION_RATIO ENOUGH_DATA_THRESHOLD = 1024 SURE_YES = 0.99 SURE_NO = 0.01 class CharDistributionAnalysis: def __init__(self): self._mCharToFreqOrder = None # Mapping table to get frequency order from char order (get from GetOrder()) self._mTableSize = None # Size of above table self._mTypicalDistributionRatio = None # This is a constant value which varies from language to language, used in calculating confidence. See http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html for further detail. self.reset() def reset(self): """reset analyser, clear any state""" self._mDone = False # If this flag is set to True, detection is done and conclusion has been made self._mTotalChars = 0 # Total characters encountered self._mFreqChars = 0 # The number of characters whose frequency order is less than 512 def feed(self, aBuf, aCharLen): """feed a character with known length""" if aCharLen == 2: # we only care about 2-bytes character in our distribution analysis order = self.get_order(aBuf) else: order = -1 if order >= 0: self._mTotalChars += 1 # order is valid if order < self._mTableSize: if 512 > self._mCharToFreqOrder[order]: self._mFreqChars += 1 def get_confidence(self): """return confidence based on existing data""" # if we didn't receive any character in our consideration range, return negative answer if self._mTotalChars <= 0: return SURE_NO if self._mTotalChars != self._mFreqChars: r = self._mFreqChars / ((self._mTotalChars - self._mFreqChars) * self._mTypicalDistributionRatio) if r < SURE_YES: return r # normalize confidence (we don't want to be 100% sure) return SURE_YES def got_enough_data(self): # It is not necessary to receive all data to draw conclusion. For charset detection, # certain amount of data is enough return self._mTotalChars > ENOUGH_DATA_THRESHOLD def get_order(self, aBuf): # We do not handle characters based on the original encoding string, but # convert this encoding string to a number, here called order. # This allows multiple encodings of a language to share one frequency table. return -1 class EUCTWDistributionAnalysis(CharDistributionAnalysis): def __init__(self): CharDistributionAnalysis.__init__(self) self._mCharToFreqOrder = EUCTWCharToFreqOrder self._mTableSize = EUCTW_TABLE_SIZE self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO def get_order(self, aBuf): # for euc-TW encoding, we are interested # first byte range: 0xc4 -- 0xfe # second byte range: 0xa1 -- 0xfe # no validation needed here. State machine has done that if aBuf[0] >= 0xC4: return 94 * (aBuf[0] - 0xC4) + aBuf[1] - 0xA1 else: return -1 class EUCKRDistributionAnalysis(CharDistributionAnalysis): def __init__(self): CharDistributionAnalysis.__init__(self) self._mCharToFreqOrder = EUCKRCharToFreqOrder self._mTableSize = EUCKR_TABLE_SIZE self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO def get_order(self, aBuf): # for euc-KR encoding, we are interested # first byte range: 0xb0 -- 0xfe # second byte range: 0xa1 -- 0xfe # no validation needed here. State machine has done that if aBuf[0] >= 0xB0: return 94 * (aBuf[0] - 0xB0) + aBuf[1] - 0xA1 else: return -1; class GB2312DistributionAnalysis(CharDistributionAnalysis): def __init__(self): CharDistributionAnalysis.__init__(self) self._mCharToFreqOrder = GB2312CharToFreqOrder self._mTableSize = GB2312_TABLE_SIZE self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO def get_order(self, aBuf): # for GB2312 encoding, we are interested # first byte range: 0xb0 -- 0xfe # second byte range: 0xa1 -- 0xfe # no validation needed here. State machine has done that if (aBuf[0] >= 0xB0) and (aBuf[1] >= 0xA1): return 94 * (aBuf[0] - 0xB0) + aBuf[1] - 0xA1 else: return -1; class Big5DistributionAnalysis(CharDistributionAnalysis): def __init__(self): CharDistributionAnalysis.__init__(self) self._mCharToFreqOrder = Big5CharToFreqOrder self._mTableSize = BIG5_TABLE_SIZE self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO def get_order(self, aBuf): # for big5 encoding, we are interested # first byte range: 0xa4 -- 0xfe # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe # no validation needed here. State machine has done that if aBuf[0] >= 0xA4: if aBuf[1] >= 0xA1: return 157 * (aBuf[0] - 0xA4) + aBuf[1] - 0xA1 + 63 else: return 157 * (aBuf[0] - 0xA4) + aBuf[1] - 0x40 else: return -1 class SJISDistributionAnalysis(CharDistributionAnalysis): def __init__(self): CharDistributionAnalysis.__init__(self) self._mCharToFreqOrder = JISCharToFreqOrder self._mTableSize = JIS_TABLE_SIZE self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO def get_order(self, aBuf): # for sjis encoding, we are interested # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe # no validation needed here. State machine has done that if (aBuf[0] >= 0x81) and (aBuf[0] <= 0x9F): order = 188 * (aBuf[0] - 0x81) elif (aBuf[0] >= 0xE0) and (aBuf[0] <= 0xEF): order = 188 * (aBuf[0] - 0xE0 + 31) else: return -1; order = order + aBuf[1] - 0x40 if aBuf[1] > 0x7F: order =- 1 return order class EUCJPDistributionAnalysis(CharDistributionAnalysis): def __init__(self): CharDistributionAnalysis.__init__(self) self._mCharToFreqOrder = JISCharToFreqOrder self._mTableSize = JIS_TABLE_SIZE self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO def get_order(self, aBuf): # for euc-JP encoding, we are interested # first byte range: 0xa0 -- 0xfe # second byte range: 0xa1 -- 0xfe # no validation needed here. State machine has done that if aBuf[0] >= 0xA0: return 94 * (aBuf[0] - 0xA1) + aBuf[1] - 0xa1 else: return -1
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 221, 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, 221, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 492, 5262, 199, 504, 1275, 69, 918, 87, 5646, 492, 662, 27120, 18139, 13875, 4738, 12, 662, 27120, 63, 8723, 63, 4305, 12, 662, 27120, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 69, 10112, 3941, 2103, 492, 26007, 27373, 18139, 13875, 4738, 12, 26007, 27373, 63, 8723, 63, 4305, 12, 26007, 27373, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 4908, 16909, 5646, 492, 18553, 16909, 18139, 13875, 4738, 12, 18553, 16909, 63, 8723, 63, 4305, 12, 18553, 16909, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 5076, 21, 5646, 492, 13123, 21, 18139, 13875, 4738, 12, 16524, 21, 63, 8723, 63, 4305, 12, 16524, 21, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 18941, 5646, 492, 1603, 1311, 18139, 13875, 4738, 12, 1603, 1311, 63, 8723, 63, 4305, 12, 1603, 1311, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 199, 15577, 10134, 40, 63, 3998, 63, 19307, 275, 6619, 199, 51, 3942, 63, 15641, 275, 378, 14, 1020, 199, 51, 3942, 63, 2826, 275, 378, 14, 614, 199, 199, 533, 6659, 24906, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 423, 77, 18139, 13875, 4738, 275, 488, 327, 12340, 1817, 370, 664, 9857, 1865, 687, 1495, 1865, 334, 362, 687, 2372, 4738, 1012, 267, 291, 423, 77, 3186, 2320, 275, 488, 327, 14579, 402, 3432, 1817, 267, 291, 423, 30376, 8580, 13971, 275, 488, 327, 961, 365, 282, 4413, 574, 1314, 373, 3433, 687, 2637, 370, 2637, 12, 1202, 315, 26079, 15197, 14, 221, 1666, 1455, 921, 1544, 14, 12102, 14, 1308, 15, 6776, 15, 442, 76, 15, 1358, 10959, 28200, 31198, 14, 1360, 367, 9848, 10093, 14, 267, 291, 14, 3958, 342, 5493, 347, 5305, 8, 277, 304, 267, 408, 3958, 5909, 332, 12, 5436, 1263, 1174, 624, 267, 291, 423, 77, 10759, 275, 756, 327, 982, 642, 3305, 365, 663, 370, 715, 12, 15212, 365, 4224, 436, 406, 10248, 965, 2757, 6326, 267, 291, 423, 77, 7316, 11229, 275, 378, 327, 19271, 4110, 14556, 267, 291, 423, 77, 13875, 11229, 275, 378, 327, 710, 1329, 402, 4110, 7447, 9857, 1865, 365, 6656, 2419, 10574, 339, 347, 4733, 8, 277, 12, 17407, 12, 282, 1610, 3166, 304, 267, 408, 3871, 282, 4528, 543, 6040, 2582, 624, 267, 340, 282, 1610, 3166, 508, 499, 26, 288, 327, 781, 1454, 10296, 3595, 499, 13, 2394, 4528, 315, 4154, 4084, 11284, 288, 1865, 275, 291, 14, 362, 63, 1648, 8, 22353, 9, 267, 587, 26, 288, 1865, 275, 446, 17, 267, 340, 1865, 2356, 378, 26, 288, 291, 423, 77, 7316, 11229, 847, 413, 288, 327, 1865, 365, 1686, 288, 340, 1865, 665, 291, 423, 77, 3186, 2320, 26, 355, 340, 10574, 690, 291, 423, 77, 18139, 13875, 4738, 59, 1648, 2189, 490, 291, 423, 77, 13875, 11229, 847, 413, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 408, 1107, 15197, 4079, 641, 3411, 666, 624, 267, 327, 340, 781, 9980, 1133, 9128, 1263, 4528, 315, 4154, 8219, 1754, 1425, 12, 372, 6946, 6385, 267, 340, 291, 423, 77, 7316, 11229, 2695, 378, 26, 288, 372, 428, 3942, 63, 2826, 398, 340, 291, 423, 77, 7316, 11229, 1137, 291, 423, 77, 13875, 11229, 26, 288, 519, 275, 291, 423, 77, 13875, 11229, 1182, 3666, 277, 423, 77, 7316, 11229, 446, 291, 423, 77, 13875, 11229, 9, 627, 291, 423, 30376, 8580, 13971, 9, 288, 340, 519, 665, 428, 3942, 63, 15641, 26, 355, 372, 519, 398, 327, 7666, 15197, 334, 1129, 2793, 1133, 2934, 370, 506, 2948, 5, 3238, 9, 267, 372, 428, 3942, 63, 15641, 339, 347, 4788, 63, 30881, 63, 576, 8, 277, 304, 267, 327, 2779, 365, 440, 5784, 370, 9128, 1006, 666, 370, 5954, 406, 10248, 14, 2104, 5960, 15212, 12, 267, 327, 9842, 5982, 402, 666, 365, 8321, 267, 372, 291, 423, 77, 7316, 11229, 690, 662, 2826, 10134, 40, 63, 3998, 63, 19307, 339, 347, 664, 63, 1648, 8, 277, 12, 17407, 304, 267, 327, 2136, 886, 440, 2429, 4110, 4079, 641, 314, 3379, 2644, 1059, 12, 1325, 4960, 327, 3957, 642, 2644, 1059, 370, 282, 1329, 12, 2348, 2797, 1865, 14, 267, 327, 961, 6127, 3663, 14134, 402, 282, 2637, 370, 8663, 1373, 9857, 1817, 14, 267, 372, 446, 17, 1362, 199, 533, 662, 27120, 24906, 8, 1610, 24906, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6659, 24906, 855, 826, 721, 277, 9, 267, 291, 423, 77, 18139, 13875, 4738, 275, 662, 27120, 18139, 13875, 4738, 267, 291, 423, 77, 3186, 2320, 275, 662, 27120, 63, 8723, 63 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 221, 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, 221, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 492, 5262, 199, 504, 1275, 69, 918, 87, 5646, 492, 662, 27120, 18139, 13875, 4738, 12, 662, 27120, 63, 8723, 63, 4305, 12, 662, 27120, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 69, 10112, 3941, 2103, 492, 26007, 27373, 18139, 13875, 4738, 12, 26007, 27373, 63, 8723, 63, 4305, 12, 26007, 27373, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 4908, 16909, 5646, 492, 18553, 16909, 18139, 13875, 4738, 12, 18553, 16909, 63, 8723, 63, 4305, 12, 18553, 16909, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 5076, 21, 5646, 492, 13123, 21, 18139, 13875, 4738, 12, 16524, 21, 63, 8723, 63, 4305, 12, 16524, 21, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 504, 1275, 18941, 5646, 492, 1603, 1311, 18139, 13875, 4738, 12, 1603, 1311, 63, 8723, 63, 4305, 12, 1603, 1311, 63, 7034, 5974, 63, 24580, 26601, 63, 26566, 199, 199, 15577, 10134, 40, 63, 3998, 63, 19307, 275, 6619, 199, 51, 3942, 63, 15641, 275, 378, 14, 1020, 199, 51, 3942, 63, 2826, 275, 378, 14, 614, 199, 199, 533, 6659, 24906, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 423, 77, 18139, 13875, 4738, 275, 488, 327, 12340, 1817, 370, 664, 9857, 1865, 687, 1495, 1865, 334, 362, 687, 2372, 4738, 1012, 267, 291, 423, 77, 3186, 2320, 275, 488, 327, 14579, 402, 3432, 1817, 267, 291, 423, 30376, 8580, 13971, 275, 488, 327, 961, 365, 282, 4413, 574, 1314, 373, 3433, 687, 2637, 370, 2637, 12, 1202, 315, 26079, 15197, 14, 221, 1666, 1455, 921, 1544, 14, 12102, 14, 1308, 15, 6776, 15, 442, 76, 15, 1358, 10959, 28200, 31198, 14, 1360, 367, 9848, 10093, 14, 267, 291, 14, 3958, 342, 5493, 347, 5305, 8, 277, 304, 267, 408, 3958, 5909, 332, 12, 5436, 1263, 1174, 624, 267, 291, 423, 77, 10759, 275, 756, 327, 982, 642, 3305, 365, 663, 370, 715, 12, 15212, 365, 4224, 436, 406, 10248, 965, 2757, 6326, 267, 291, 423, 77, 7316, 11229, 275, 378, 327, 19271, 4110, 14556, 267, 291, 423, 77, 13875, 11229, 275, 378, 327, 710, 1329, 402, 4110, 7447, 9857, 1865, 365, 6656, 2419, 10574, 339, 347, 4733, 8, 277, 12, 17407, 12, 282, 1610, 3166, 304, 267, 408, 3871, 282, 4528, 543, 6040, 2582, 624, 267, 340, 282, 1610, 3166, 508, 499, 26, 288, 327, 781, 1454, 10296, 3595, 499, 13, 2394, 4528, 315, 4154, 4084, 11284, 288, 1865, 275, 291, 14, 362, 63, 1648, 8, 22353, 9, 267, 587, 26, 288, 1865, 275, 446, 17, 267, 340, 1865, 2356, 378, 26, 288, 291, 423, 77, 7316, 11229, 847, 413, 288, 327, 1865, 365, 1686, 288, 340, 1865, 665, 291, 423, 77, 3186, 2320, 26, 355, 340, 10574, 690, 291, 423, 77, 18139, 13875, 4738, 59, 1648, 2189, 490, 291, 423, 77, 13875, 11229, 847, 413, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 408, 1107, 15197, 4079, 641, 3411, 666, 624, 267, 327, 340, 781, 9980, 1133, 9128, 1263, 4528, 315, 4154, 8219, 1754, 1425, 12, 372, 6946, 6385, 267, 340, 291, 423, 77, 7316, 11229, 2695, 378, 26, 288, 372, 428, 3942, 63, 2826, 398, 340, 291, 423, 77, 7316, 11229, 1137, 291, 423, 77, 13875, 11229, 26, 288, 519, 275, 291, 423, 77, 13875, 11229, 1182, 3666, 277, 423, 77, 7316, 11229, 446, 291, 423, 77, 13875, 11229, 9, 627, 291, 423, 30376, 8580, 13971, 9, 288, 340, 519, 665, 428, 3942, 63, 15641, 26, 355, 372, 519, 398, 327, 7666, 15197, 334, 1129, 2793, 1133, 2934, 370, 506, 2948, 5, 3238, 9, 267, 372, 428, 3942, 63, 15641, 339, 347, 4788, 63, 30881, 63, 576, 8, 277, 304, 267, 327, 2779, 365, 440, 5784, 370, 9128, 1006, 666, 370, 5954, 406, 10248, 14, 2104, 5960, 15212, 12, 267, 327, 9842, 5982, 402, 666, 365, 8321, 267, 372, 291, 423, 77, 7316, 11229, 690, 662, 2826, 10134, 40, 63, 3998, 63, 19307, 339, 347, 664, 63, 1648, 8, 277, 12, 17407, 304, 267, 327, 2136, 886, 440, 2429, 4110, 4079, 641, 314, 3379, 2644, 1059, 12, 1325, 4960, 327, 3957, 642, 2644, 1059, 370, 282, 1329, 12, 2348, 2797, 1865, 14, 267, 327, 961, 6127, 3663, 14134, 402, 282, 2637, 370, 8663, 1373, 9857, 1817, 14, 267, 372, 446, 17, 1362, 199, 533, 662, 27120, 24906, 8, 1610, 24906, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6659, 24906, 855, 826, 721, 277, 9, 267, 291, 423, 77, 18139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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 ]
laszlocsomor/tensorflow
tensorflow/python/kernel_tests/check_ops_test.py
5
48105
# Copyright 2016 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 tensorflow.ops.check_ops.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.eager import context from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import check_ops from tensorflow.python.platform import test class AssertProperIterableTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_single_tensor_raises(self): tensor = constant_op.constant(1) with self.assertRaisesRegexp(TypeError, "proper"): check_ops.assert_proper_iterable(tensor) @test_util.run_in_graph_and_eager_modes() def test_single_sparse_tensor_raises(self): ten = sparse_tensor.SparseTensor( indices=[[0, 0], [1, 2]], values=[1, 2], dense_shape=[3, 4]) with self.assertRaisesRegexp(TypeError, "proper"): check_ops.assert_proper_iterable(ten) @test_util.run_in_graph_and_eager_modes() def test_single_ndarray_raises(self): array = np.array([1, 2, 3]) with self.assertRaisesRegexp(TypeError, "proper"): check_ops.assert_proper_iterable(array) @test_util.run_in_graph_and_eager_modes() def test_single_string_raises(self): mystr = "hello" with self.assertRaisesRegexp(TypeError, "proper"): check_ops.assert_proper_iterable(mystr) @test_util.run_in_graph_and_eager_modes() def test_non_iterable_object_raises(self): non_iterable = 1234 with self.assertRaisesRegexp(TypeError, "to be iterable"): check_ops.assert_proper_iterable(non_iterable) @test_util.run_in_graph_and_eager_modes() def test_list_does_not_raise(self): list_of_stuff = [ constant_op.constant([11, 22]), constant_op.constant([1, 2]) ] check_ops.assert_proper_iterable(list_of_stuff) @test_util.run_in_graph_and_eager_modes() def test_generator_does_not_raise(self): generator_of_stuff = (constant_op.constant([11, 22]), constant_op.constant( [1, 2])) check_ops.assert_proper_iterable(generator_of_stuff) class AssertEqualTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_equal(self): small = constant_op.constant([1, 2], name="small") with ops.control_dependencies([check_ops.assert_equal(small, small)]): out = array_ops.identity(small) self.evaluate(out) def test_returns_none_with_eager(self): with context.eager_mode(): small = constant_op.constant([1, 2], name="small") x = check_ops.assert_equal(small, small) assert x is None @test_util.run_in_graph_and_eager_modes() def test_raises_when_greater(self): # Static check static_small = constant_op.constant([1, 2], name="small") static_big = constant_op.constant([3, 4], name="big") with self.assertRaisesRegexp(errors.InvalidArgumentError, "fail"): check_ops.assert_equal(static_big, static_small, message="fail") # Dynamic check if context.in_graph_mode(): with self.test_session(): small = array_ops.placeholder(dtypes.int32, name="small") big = array_ops.placeholder(dtypes.int32, name="big") with ops.control_dependencies( [check_ops.assert_equal( big, small, message="fail")]): out = array_ops.identity(small) with self.assertRaisesOpError("fail.*big.*small"): out.eval(feed_dict={small: [1, 2], big: [3, 4]}) def test_error_message_eager(self): expected_error_msg_full = r"""big does not equal small Condition x == y did not hold. Indices of first 6 different values: \[\[0 0\] \[1 1\] \[2 0\]\] Corresponding x values: \[2 3 6\] Corresponding y values: \[20 30 60\] First 6 elements of x: \[2 2 3 3 6 6\] First 6 elements of y: \[20 2 3 30 60 6\] """ expected_error_msg_short = r"""big does not equal small Condition x == y did not hold. Indices of first 2 different values: \[\[0 0\] \[1 1\]\] Corresponding x values: \[2 3\] Corresponding y values: \[20 30\] First 2 elements of x: \[2 2\] First 2 elements of y: \[20 2\] """ with context.eager_mode(): big = constant_op.constant([[2, 2], [3, 3], [6, 6]]) small = constant_op.constant([[20, 2], [3, 30], [60, 6]]) with self.assertRaisesRegexp(errors.InvalidArgumentError, expected_error_msg_full): check_ops.assert_equal(big, small, message="big does not equal small", summarize=10) with self.assertRaisesRegexp(errors.InvalidArgumentError, expected_error_msg_short): check_ops.assert_equal(big, small, message="big does not equal small", summarize=2) @test_util.run_in_graph_and_eager_modes() def test_raises_when_less(self): # Static check static_small = constant_op.constant([3, 1], name="small") static_big = constant_op.constant([4, 2], name="big") with self.assertRaisesRegexp(errors.InvalidArgumentError, "fail"): check_ops.assert_equal(static_big, static_small, message="fail") # Dynamic check if context.in_graph_mode(): with self.test_session(): small = array_ops.placeholder(dtypes.int32, name="small") big = array_ops.placeholder(dtypes.int32, name="big") with ops.control_dependencies([check_ops.assert_equal(small, big)]): out = array_ops.identity(small) with self.assertRaisesOpError("small.*big"): out.eval(feed_dict={small: [3, 1], big: [4, 2]}) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_equal_and_broadcastable_shapes(self): small = constant_op.constant([[1, 2], [1, 2]], name="small") small_2 = constant_op.constant([1, 2], name="small_2") with ops.control_dependencies([check_ops.assert_equal(small, small_2)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_equal_but_non_broadcastable_shapes(self): small = constant_op.constant([1, 1, 1], name="small") small_2 = constant_op.constant([1, 1], name="small_2") # The exception in eager and non-eager mode is different because # eager mode relies on shape check done as part of the C++ op, while # graph mode does shape checks when creating the `Operation` instance. with self.assertRaisesRegexp( (errors.InvalidArgumentError, ValueError), (r"Incompatible shapes: \[3\] vs. \[2\]|" r"Dimensions must be equal, but are 3 and 2")): with ops.control_dependencies([check_ops.assert_equal(small, small_2)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_both_empty(self): larry = constant_op.constant([]) curly = constant_op.constant([]) with ops.control_dependencies([check_ops.assert_equal(larry, curly)]): out = array_ops.identity(larry) self.evaluate(out) class AssertNoneEqualTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_not_equal(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([10, 20], name="small") with ops.control_dependencies( [check_ops.assert_none_equal(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_equal(self): small = constant_op.constant([3, 1], name="small") with self.assertRaisesOpError("x != y did not hold"): with ops.control_dependencies( [check_ops.assert_none_equal(small, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_not_equal_and_broadcastable_shapes(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3], name="big") with ops.control_dependencies( [check_ops.assert_none_equal(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_not_equal_but_non_broadcastable_shapes(self): with self.test_session(): small = constant_op.constant([1, 1, 1], name="small") big = constant_op.constant([10, 10], name="big") # The exception in eager and non-eager mode is different because # eager mode relies on shape check done as part of the C++ op, while # graph mode does shape checks when creating the `Operation` instance. with self.assertRaisesRegexp( (ValueError, errors.InvalidArgumentError), (r"Incompatible shapes: \[3\] vs. \[2\]|" r"Dimensions must be equal, but are 3 and 2")): with ops.control_dependencies( [check_ops.assert_none_equal(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_both_empty(self): with self.test_session(): larry = constant_op.constant([]) curly = constant_op.constant([]) with ops.control_dependencies( [check_ops.assert_none_equal(larry, curly)]): out = array_ops.identity(larry) self.evaluate(out) def test_returns_none_with_eager(self): with context.eager_mode(): t1 = constant_op.constant([1, 2]) t2 = constant_op.constant([3, 4]) x = check_ops.assert_none_equal(t1, t2) assert x is None class AssertLessTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_raises_when_equal(self): small = constant_op.constant([1, 2], name="small") with self.assertRaisesOpError("failure message.*\n*.* x < y did not hold"): with ops.control_dependencies( [check_ops.assert_less( small, small, message="failure message")]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_greater(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") with self.assertRaisesOpError("x < y did not hold"): with ops.control_dependencies([check_ops.assert_less(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_less(self): small = constant_op.constant([3, 1], name="small") big = constant_op.constant([4, 2], name="big") with ops.control_dependencies([check_ops.assert_less(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_less_and_broadcastable_shapes(self): small = constant_op.constant([1], name="small") big = constant_op.constant([3, 2], name="big") with ops.control_dependencies([check_ops.assert_less(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_less_but_non_broadcastable_shapes(self): small = constant_op.constant([1, 1, 1], name="small") big = constant_op.constant([3, 2], name="big") # The exception in eager and non-eager mode is different because # eager mode relies on shape check done as part of the C++ op, while # graph mode does shape checks when creating the `Operation` instance. with self.assertRaisesRegexp( (ValueError, errors.InvalidArgumentError), (r"Incompatible shapes: \[3\] vs. \[2\]|" "Dimensions must be equal, but are 3 and 2")): with ops.control_dependencies([check_ops.assert_less(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_both_empty(self): larry = constant_op.constant([]) curly = constant_op.constant([]) with ops.control_dependencies([check_ops.assert_less(larry, curly)]): out = array_ops.identity(larry) self.evaluate(out) def test_returns_none_with_eager(self): with context.eager_mode(): t1 = constant_op.constant([1, 2]) t2 = constant_op.constant([3, 4]) x = check_ops.assert_less(t1, t2) assert x is None class AssertLessEqualTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_equal(self): small = constant_op.constant([1, 2], name="small") with ops.control_dependencies( [check_ops.assert_less_equal(small, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_greater(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") with self.assertRaisesOpError("fail"): with ops.control_dependencies( [check_ops.assert_less_equal( big, small, message="fail")]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_less_equal(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 2], name="big") with ops.control_dependencies([check_ops.assert_less_equal(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_less_equal_and_broadcastable_shapes(self): small = constant_op.constant([1], name="small") big = constant_op.constant([3, 1], name="big") with ops.control_dependencies([check_ops.assert_less_equal(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_less_equal_but_non_broadcastable_shapes(self): small = constant_op.constant([3, 1], name="small") big = constant_op.constant([1, 1, 1], name="big") # The exception in eager and non-eager mode is different because # eager mode relies on shape check done as part of the C++ op, while # graph mode does shape checks when creating the `Operation` instance. with self.assertRaisesRegexp( (errors.InvalidArgumentError, ValueError), (r"Incompatible shapes: \[2\] vs. \[3\]|" r"Dimensions must be equal, but are 2 and 3")): with ops.control_dependencies( [check_ops.assert_less_equal(small, big)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_both_empty(self): larry = constant_op.constant([]) curly = constant_op.constant([]) with ops.control_dependencies( [check_ops.assert_less_equal(larry, curly)]): out = array_ops.identity(larry) self.evaluate(out) class AssertGreaterTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_raises_when_equal(self): small = constant_op.constant([1, 2], name="small") with self.assertRaisesOpError("fail"): with ops.control_dependencies( [check_ops.assert_greater( small, small, message="fail")]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_less(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") with self.assertRaisesOpError("x > y did not hold"): with ops.control_dependencies([check_ops.assert_greater(small, big)]): out = array_ops.identity(big) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_greater(self): small = constant_op.constant([3, 1], name="small") big = constant_op.constant([4, 2], name="big") with ops.control_dependencies([check_ops.assert_greater(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_greater_and_broadcastable_shapes(self): small = constant_op.constant([1], name="small") big = constant_op.constant([3, 2], name="big") with ops.control_dependencies([check_ops.assert_greater(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_greater_but_non_broadcastable_shapes(self): small = constant_op.constant([1, 1, 1], name="small") big = constant_op.constant([3, 2], name="big") # The exception in eager and non-eager mode is different because # eager mode relies on shape check done as part of the C++ op, while # graph mode does shape checks when creating the `Operation` instance. with self.assertRaisesRegexp( (errors.InvalidArgumentError, ValueError), (r"Incompatible shapes: \[2\] vs. \[3\]|" r"Dimensions must be equal, but are 2 and 3")): with ops.control_dependencies([check_ops.assert_greater(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_both_empty(self): larry = constant_op.constant([]) curly = constant_op.constant([]) with ops.control_dependencies([check_ops.assert_greater(larry, curly)]): out = array_ops.identity(larry) self.evaluate(out) class AssertGreaterEqualTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_equal(self): small = constant_op.constant([1, 2], name="small") with ops.control_dependencies( [check_ops.assert_greater_equal(small, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_less(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") with self.assertRaisesOpError("fail"): with ops.control_dependencies( [check_ops.assert_greater_equal( small, big, message="fail")]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_greater_equal(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 2], name="big") with ops.control_dependencies( [check_ops.assert_greater_equal(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_greater_equal_and_broadcastable_shapes(self): small = constant_op.constant([1], name="small") big = constant_op.constant([3, 1], name="big") with ops.control_dependencies( [check_ops.assert_greater_equal(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_less_equal_but_non_broadcastable_shapes(self): small = constant_op.constant([1, 1, 1], name="big") big = constant_op.constant([3, 1], name="small") # The exception in eager and non-eager mode is different because # eager mode relies on shape check done as part of the C++ op, while # graph mode does shape checks when creating the `Operation` instance. with self.assertRaisesRegexp( (errors.InvalidArgumentError, ValueError), (r"Incompatible shapes: \[2\] vs. \[3\]|" r"Dimensions must be equal, but are 2 and 3")): with ops.control_dependencies( [check_ops.assert_greater_equal(big, small)]): out = array_ops.identity(small) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_both_empty(self): larry = constant_op.constant([]) curly = constant_op.constant([]) with ops.control_dependencies( [check_ops.assert_greater_equal(larry, curly)]): out = array_ops.identity(larry) self.evaluate(out) class AssertNegativeTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_negative(self): frank = constant_op.constant([-1, -2], name="frank") with ops.control_dependencies([check_ops.assert_negative(frank)]): out = array_ops.identity(frank) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_positive(self): doug = constant_op.constant([1, 2], name="doug") with self.assertRaisesOpError("fail"): with ops.control_dependencies( [check_ops.assert_negative( doug, message="fail")]): out = array_ops.identity(doug) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_zero(self): claire = constant_op.constant([0], name="claire") with self.assertRaisesOpError("x < 0 did not hold"): with ops.control_dependencies([check_ops.assert_negative(claire)]): out = array_ops.identity(claire) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_empty_tensor_doesnt_raise(self): # A tensor is negative when it satisfies: # For every element x_i in x, x_i < 0 # and an empty tensor has no elements, so this is trivially satisfied. # This is standard set theory. empty = constant_op.constant([], name="empty") with ops.control_dependencies([check_ops.assert_negative(empty)]): out = array_ops.identity(empty) self.evaluate(out) class AssertPositiveTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_raises_when_negative(self): freddie = constant_op.constant([-1, -2], name="freddie") with self.assertRaisesOpError("fail"): with ops.control_dependencies( [check_ops.assert_positive( freddie, message="fail")]): out = array_ops.identity(freddie) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_positive(self): remmy = constant_op.constant([1, 2], name="remmy") with ops.control_dependencies([check_ops.assert_positive(remmy)]): out = array_ops.identity(remmy) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_zero(self): meechum = constant_op.constant([0], name="meechum") with self.assertRaisesOpError("x > 0 did not hold"): with ops.control_dependencies([check_ops.assert_positive(meechum)]): out = array_ops.identity(meechum) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_empty_tensor_doesnt_raise(self): # A tensor is positive when it satisfies: # For every element x_i in x, x_i > 0 # and an empty tensor has no elements, so this is trivially satisfied. # This is standard set theory. empty = constant_op.constant([], name="empty") with ops.control_dependencies([check_ops.assert_positive(empty)]): out = array_ops.identity(empty) self.evaluate(out) class AssertRankTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_rank_zero_tensor_raises_if_rank_too_small_static_rank(self): tensor = constant_op.constant(1, name="my_tensor") desired_rank = 1 with self.assertRaisesRegexp(ValueError, "fail.*must have rank 1"): with ops.control_dependencies( [check_ops.assert_rank( tensor, desired_rank, message="fail")]): self.evaluate(array_ops.identity(tensor)) def test_rank_zero_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 1 with ops.control_dependencies( [check_ops.assert_rank( tensor, desired_rank, message="fail")]): with self.assertRaisesOpError("fail.*my_tensor.*rank"): array_ops.identity(tensor).eval(feed_dict={tensor: 0}) @test_util.run_in_graph_and_eager_modes() def test_rank_zero_tensor_doesnt_raise_if_rank_just_right_static_rank(self): tensor = constant_op.constant(1, name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_zero_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): array_ops.identity(tensor).eval(feed_dict={tensor: 0}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_raises_if_rank_too_large_static_rank(self): tensor = constant_op.constant([1, 2], name="my_tensor") desired_rank = 0 with self.assertRaisesRegexp(ValueError, "rank"): with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_one_tensor_raises_if_rank_too_large_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): with self.assertRaisesOpError("my_tensor.*rank"): array_ops.identity(tensor).eval(feed_dict={tensor: [1, 2]}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_doesnt_raise_if_rank_just_right_static_rank(self): tensor = constant_op.constant([1, 2], name="my_tensor") desired_rank = 1 with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_one_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 1 with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): array_ops.identity(tensor).eval(feed_dict={tensor: [1, 2]}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_raises_if_rank_too_small_static_rank(self): tensor = constant_op.constant([1, 2], name="my_tensor") desired_rank = 2 with self.assertRaisesRegexp(ValueError, "rank"): with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_one_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 2 with ops.control_dependencies( [check_ops.assert_rank(tensor, desired_rank)]): with self.assertRaisesOpError("my_tensor.*rank"): array_ops.identity(tensor).eval(feed_dict={tensor: [1, 2]}) @test_util.run_in_graph_and_eager_modes() def test_raises_if_rank_is_not_scalar_static(self): tensor = constant_op.constant([1, 2], name="my_tensor") with self.assertRaisesRegexp(ValueError, "Rank must be a scalar"): check_ops.assert_rank(tensor, np.array([], dtype=np.int32)) def test_raises_if_rank_is_not_scalar_dynamic(self): with self.test_session(): tensor = constant_op.constant( [1, 2], dtype=dtypes.float32, name="my_tensor") rank_tensor = array_ops.placeholder(dtypes.int32, name="rank_tensor") with self.assertRaisesOpError("Rank must be a scalar"): with ops.control_dependencies( [check_ops.assert_rank(tensor, rank_tensor)]): array_ops.identity(tensor).eval(feed_dict={rank_tensor: [1, 2]}) @test_util.run_in_graph_and_eager_modes() def test_raises_if_rank_is_not_integer_static(self): tensor = constant_op.constant([1, 2], name="my_tensor") with self.assertRaisesRegexp(TypeError, "must be of type <dtype: 'int32'>"): check_ops.assert_rank(tensor, .5) def test_raises_if_rank_is_not_integer_dynamic(self): with self.test_session(): tensor = constant_op.constant( [1, 2], dtype=dtypes.float32, name="my_tensor") rank_tensor = array_ops.placeholder(dtypes.float32, name="rank_tensor") with self.assertRaisesRegexp(TypeError, "must be of type <dtype: 'int32'>"): with ops.control_dependencies( [check_ops.assert_rank(tensor, rank_tensor)]): array_ops.identity(tensor).eval(feed_dict={rank_tensor: .5}) class AssertRankInTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_rank_zero_tensor_raises_if_rank_mismatch_static_rank(self): tensor_rank0 = constant_op.constant(42, name="my_tensor") with self.assertRaisesRegexp( ValueError, "fail.*must have rank.*in.*1.*2"): with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank0, (1, 2), message="fail")]): self.evaluate(array_ops.identity(tensor_rank0)) def test_rank_zero_tensor_raises_if_rank_mismatch_dynamic_rank(self): with self.test_session(): tensor_rank0 = array_ops.placeholder(dtypes.float32, name="my_tensor") with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank0, (1, 2), message="fail")]): with self.assertRaisesOpError("fail.*my_tensor.*rank"): array_ops.identity(tensor_rank0).eval(feed_dict={tensor_rank0: 42.0}) @test_util.run_in_graph_and_eager_modes() def test_rank_zero_tensor_doesnt_raise_if_rank_matches_static_rank(self): tensor_rank0 = constant_op.constant(42, name="my_tensor") for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)): with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank0, desired_ranks)]): self.evaluate(array_ops.identity(tensor_rank0)) def test_rank_zero_tensor_doesnt_raise_if_rank_matches_dynamic_rank(self): with self.test_session(): tensor_rank0 = array_ops.placeholder(dtypes.float32, name="my_tensor") for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)): with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank0, desired_ranks)]): array_ops.identity(tensor_rank0).eval(feed_dict={tensor_rank0: 42.0}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_doesnt_raise_if_rank_matches_static_rank(self): tensor_rank1 = constant_op.constant([42, 43], name="my_tensor") for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)): with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank1, desired_ranks)]): self.evaluate(array_ops.identity(tensor_rank1)) def test_rank_one_tensor_doesnt_raise_if_rank_matches_dynamic_rank(self): with self.test_session(): tensor_rank1 = array_ops.placeholder(dtypes.float32, name="my_tensor") for desired_ranks in ((0, 1, 2), (1, 0, 2), (1, 2, 0)): with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank1, desired_ranks)]): array_ops.identity(tensor_rank1).eval(feed_dict={ tensor_rank1: (42.0, 43.0) }) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_raises_if_rank_mismatches_static_rank(self): tensor_rank1 = constant_op.constant((42, 43), name="my_tensor") with self.assertRaisesRegexp(ValueError, "rank"): with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank1, (0, 2))]): self.evaluate(array_ops.identity(tensor_rank1)) def test_rank_one_tensor_raises_if_rank_mismatches_dynamic_rank(self): with self.test_session(): tensor_rank1 = array_ops.placeholder(dtypes.float32, name="my_tensor") with ops.control_dependencies([ check_ops.assert_rank_in(tensor_rank1, (0, 2))]): with self.assertRaisesOpError("my_tensor.*rank"): array_ops.identity(tensor_rank1).eval(feed_dict={ tensor_rank1: (42.0, 43.0) }) @test_util.run_in_graph_and_eager_modes() def test_raises_if_rank_is_not_scalar_static(self): tensor = constant_op.constant((42, 43), name="my_tensor") desired_ranks = ( np.array(1, dtype=np.int32), np.array((2, 1), dtype=np.int32)) with self.assertRaisesRegexp(ValueError, "Rank must be a scalar"): check_ops.assert_rank_in(tensor, desired_ranks) def test_raises_if_rank_is_not_scalar_dynamic(self): with self.test_session(): tensor = constant_op.constant( (42, 43), dtype=dtypes.float32, name="my_tensor") desired_ranks = ( array_ops.placeholder(dtypes.int32, name="rank0_tensor"), array_ops.placeholder(dtypes.int32, name="rank1_tensor")) with self.assertRaisesOpError("Rank must be a scalar"): with ops.control_dependencies( (check_ops.assert_rank_in(tensor, desired_ranks),)): array_ops.identity(tensor).eval(feed_dict={ desired_ranks[0]: 1, desired_ranks[1]: [2, 1], }) @test_util.run_in_graph_and_eager_modes() def test_raises_if_rank_is_not_integer_static(self): tensor = constant_op.constant((42, 43), name="my_tensor") with self.assertRaisesRegexp(TypeError, "must be of type <dtype: 'int32'>"): check_ops.assert_rank_in(tensor, (1, .5,)) def test_raises_if_rank_is_not_integer_dynamic(self): with self.test_session(): tensor = constant_op.constant( (42, 43), dtype=dtypes.float32, name="my_tensor") rank_tensor = array_ops.placeholder(dtypes.float32, name="rank_tensor") with self.assertRaisesRegexp(TypeError, "must be of type <dtype: 'int32'>"): with ops.control_dependencies( [check_ops.assert_rank_in(tensor, (1, rank_tensor))]): array_ops.identity(tensor).eval(feed_dict={rank_tensor: .5}) class AssertRankAtLeastTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_rank_zero_tensor_raises_if_rank_too_small_static_rank(self): tensor = constant_op.constant(1, name="my_tensor") desired_rank = 1 with self.assertRaisesRegexp(ValueError, "rank at least 1"): with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_zero_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 1 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): with self.assertRaisesOpError("my_tensor.*rank"): array_ops.identity(tensor).eval(feed_dict={tensor: 0}) @test_util.run_in_graph_and_eager_modes() def test_rank_zero_tensor_doesnt_raise_if_rank_just_right_static_rank(self): tensor = constant_op.constant(1, name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_zero_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): array_ops.identity(tensor).eval(feed_dict={tensor: 0}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_ten_doesnt_raise_raise_if_rank_too_large_static_rank(self): tensor = constant_op.constant([1, 2], name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_one_ten_doesnt_raise_if_rank_too_large_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 0 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): array_ops.identity(tensor).eval(feed_dict={tensor: [1, 2]}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_doesnt_raise_if_rank_just_right_static_rank(self): tensor = constant_op.constant([1, 2], name="my_tensor") desired_rank = 1 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_one_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 1 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): array_ops.identity(tensor).eval(feed_dict={tensor: [1, 2]}) @test_util.run_in_graph_and_eager_modes() def test_rank_one_tensor_raises_if_rank_too_small_static_rank(self): tensor = constant_op.constant([1, 2], name="my_tensor") desired_rank = 2 with self.assertRaisesRegexp(ValueError, "rank at least 2"): with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) def test_rank_one_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.test_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") desired_rank = 2 with ops.control_dependencies( [check_ops.assert_rank_at_least(tensor, desired_rank)]): with self.assertRaisesOpError("my_tensor.*rank"): array_ops.identity(tensor).eval(feed_dict={tensor: [1, 2]}) class AssertNonNegativeTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_raises_when_negative(self): zoe = constant_op.constant([-1, -2], name="zoe") with self.assertRaisesOpError("x >= 0 did not hold"): with ops.control_dependencies([check_ops.assert_non_negative(zoe)]): out = array_ops.identity(zoe) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_zero_and_positive(self): lucas = constant_op.constant([0, 2], name="lucas") with ops.control_dependencies([check_ops.assert_non_negative(lucas)]): out = array_ops.identity(lucas) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_empty_tensor_doesnt_raise(self): # A tensor is non-negative when it satisfies: # For every element x_i in x, x_i >= 0 # and an empty tensor has no elements, so this is trivially satisfied. # This is standard set theory. empty = constant_op.constant([], name="empty") with ops.control_dependencies([check_ops.assert_non_negative(empty)]): out = array_ops.identity(empty) self.evaluate(out) class AssertNonPositiveTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_zero_and_negative(self): tom = constant_op.constant([0, -2], name="tom") with ops.control_dependencies([check_ops.assert_non_positive(tom)]): out = array_ops.identity(tom) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_positive(self): rachel = constant_op.constant([0, 2], name="rachel") with self.assertRaisesOpError("x <= 0 did not hold"): with ops.control_dependencies([check_ops.assert_non_positive(rachel)]): out = array_ops.identity(rachel) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_empty_tensor_doesnt_raise(self): # A tensor is non-positive when it satisfies: # For every element x_i in x, x_i <= 0 # and an empty tensor has no elements, so this is trivially satisfied. # This is standard set theory. empty = constant_op.constant([], name="empty") with ops.control_dependencies([check_ops.assert_non_positive(empty)]): out = array_ops.identity(empty) self.evaluate(out) class AssertIntegerTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_integer(self): integers = constant_op.constant([1, 2], name="integers") with ops.control_dependencies([check_ops.assert_integer(integers)]): out = array_ops.identity(integers) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_float(self): floats = constant_op.constant([1.0, 2.0], name="floats") with self.assertRaisesRegexp(TypeError, "Expected.*integer"): check_ops.assert_integer(floats) class AssertTypeTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_doesnt_raise_when_correct_type(self): integers = constant_op.constant([1, 2], dtype=dtypes.int64) with ops.control_dependencies([ check_ops.assert_type(integers, dtypes.int64)]): out = array_ops.identity(integers) self.evaluate(out) @test_util.run_in_graph_and_eager_modes() def test_raises_when_wrong_type(self): floats = constant_op.constant([1.0, 2.0], dtype=dtypes.float16) with self.assertRaisesRegexp(TypeError, "must be of type.*float32"): check_ops.assert_type(floats, dtypes.float32) class IsStrictlyIncreasingTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_constant_tensor_is_not_strictly_increasing(self): self.assertFalse(self.evaluate(check_ops.is_strictly_increasing([1, 1, 1]))) @test_util.run_in_graph_and_eager_modes() def test_decreasing_tensor_is_not_strictly_increasing(self): self.assertFalse(self.evaluate( check_ops.is_strictly_increasing([1, 0, -1]))) @test_util.run_in_graph_and_eager_modes() def test_2d_decreasing_tensor_is_not_strictly_increasing(self): self.assertFalse( self.evaluate(check_ops.is_strictly_increasing([[1, 3], [2, 4]]))) @test_util.run_in_graph_and_eager_modes() def test_increasing_tensor_is_increasing(self): self.assertTrue(self.evaluate(check_ops.is_strictly_increasing([1, 2, 3]))) @test_util.run_in_graph_and_eager_modes() def test_increasing_rank_two_tensor(self): self.assertTrue( self.evaluate(check_ops.is_strictly_increasing([[-1, 2], [3, 4]]))) @test_util.run_in_graph_and_eager_modes() def test_tensor_with_one_element_is_strictly_increasing(self): self.assertTrue(self.evaluate(check_ops.is_strictly_increasing([1]))) @test_util.run_in_graph_and_eager_modes() def test_empty_tensor_is_strictly_increasing(self): self.assertTrue(self.evaluate(check_ops.is_strictly_increasing([]))) class IsNonDecreasingTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_constant_tensor_is_non_decreasing(self): self.assertTrue(self.evaluate(check_ops.is_non_decreasing([1, 1, 1]))) @test_util.run_in_graph_and_eager_modes() def test_decreasing_tensor_is_not_non_decreasing(self): self.assertFalse(self.evaluate(check_ops.is_non_decreasing([3, 2, 1]))) @test_util.run_in_graph_and_eager_modes() def test_2d_decreasing_tensor_is_not_non_decreasing(self): self.assertFalse(self.evaluate( check_ops.is_non_decreasing([[1, 3], [2, 4]]))) @test_util.run_in_graph_and_eager_modes() def test_increasing_rank_one_tensor_is_non_decreasing(self): self.assertTrue(self.evaluate(check_ops.is_non_decreasing([1, 2, 3]))) @test_util.run_in_graph_and_eager_modes() def test_increasing_rank_two_tensor(self): self.assertTrue(self.evaluate( check_ops.is_non_decreasing([[-1, 2], [3, 3]]))) @test_util.run_in_graph_and_eager_modes() def test_tensor_with_one_element_is_non_decreasing(self): self.assertTrue(self.evaluate(check_ops.is_non_decreasing([1]))) @test_util.run_in_graph_and_eager_modes() def test_empty_tensor_is_non_decreasing(self): self.assertTrue(self.evaluate(check_ops.is_non_decreasing([]))) class FloatDTypeTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_assert_same_float_dtype(self): self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype(None, None)) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype([], None)) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype([], dtypes.float32)) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype(None, dtypes.float32)) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype([None, None], None)) self.assertIs( dtypes.float32, check_ops.assert_same_float_dtype([None, None], dtypes.float32)) const_float = constant_op.constant(3.0, dtype=dtypes.float32) self.assertIs( dtypes.float32, check_ops.assert_same_float_dtype([const_float], dtypes.float32)) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [const_float], dtypes.int32) sparse_float = sparse_tensor.SparseTensor( constant_op.constant([[111], [232]], dtypes.int64), constant_op.constant([23.4, -43.2], dtypes.float32), constant_op.constant([500], dtypes.int64)) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype([sparse_float], dtypes.float32)) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [sparse_float], dtypes.int32) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [const_float, None, sparse_float], dtypes.float64) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype( [const_float, sparse_float])) self.assertIs(dtypes.float32, check_ops.assert_same_float_dtype( [const_float, sparse_float], dtypes.float32)) const_int = constant_op.constant(3, dtype=dtypes.int32) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [sparse_float, const_int]) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [sparse_float, const_int], dtypes.int32) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [sparse_float, const_int], dtypes.float32) self.assertRaises(ValueError, check_ops.assert_same_float_dtype, [const_int]) class AssertScalarTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def test_assert_scalar(self): check_ops.assert_scalar(constant_op.constant(3)) check_ops.assert_scalar(constant_op.constant("foo")) check_ops.assert_scalar(3) check_ops.assert_scalar("foo") with self.assertRaisesRegexp(ValueError, "Expected scalar"): check_ops.assert_scalar(constant_op.constant([3, 4])) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 7800, 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, 3228, 14, 1483, 14, 1074, 63, 1483, 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, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 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, 2552, 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, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1104, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 10716, 919, 529, 20852, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 3128, 63, 3536, 8, 277, 304, 272, 2345, 275, 4413, 63, 411, 14, 4083, 8, 17, 9, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 3128, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 4421, 63, 3128, 63, 3536, 8, 277, 304, 272, 16685, 275, 5178, 63, 3128, 14, 12079, 8, 267, 4918, 16025, 16, 12, 378, 467, 359, 17, 12, 499, 2365, 1338, 1524, 17, 12, 499, 467, 9363, 63, 1392, 1524, 19, 12, 841, 566, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 724, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 8237, 63, 3536, 8, 277, 304, 272, 1625, 275, 980, 14, 1144, 779, 17, 12, 499, 12, 650, 566, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 1144, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 875, 63, 3536, 8, 277, 304, 272, 3002, 495, 275, 298, 5006, 2, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 1662, 495, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 2865, 63, 8147, 63, 785, 63, 3536, 8, 277, 304, 272, 2222, 63, 8147, 275, 14763, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 475, 506, 6076, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 2865, 63, 8147, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 513, 63, 9105, 63, 1397, 63, 3730, 8, 277, 304, 272, 769, 63, 1618, 63, 14573, 275, 359, 267, 4413, 63, 411, 14, 4083, 779, 845, 12, 6928, 2522, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 566, 272, 1622, 272, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 513, 63, 1618, 63, 14573, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4679, 63, 9105, 63, 1397, 63, 3730, 8, 277, 304, 272, 4306, 63, 1618, 63, 14573, 275, 334, 4083, 63, 411, 14, 4083, 779, 845, 12, 6928, 2522, 4413, 63, 411, 14, 4083, 8, 267, 359, 17, 12, 499, 2459, 272, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 4679, 63, 1618, 63, 14573, 9, 421, 199, 533, 10716, 591, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 26664, 63, 3730, 63, 6526, 63, 1452, 8, 277, 304, 272, 7425, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 467, 536, 628, 7241, 531, 272, 543, 4156, 14, 2785, 63, 5714, 779, 1074, 63, 1483, 14, 479, 63, 1452, 8, 7241, 12, 7425, 31540, 489, 734, 275, 1625, 63, 1483, 14, 5582, 8, 7241, 9, 272, 291, 14, 7383, 8, 548, 9, 819, 347, 511, 63, 5808, 63, 3592, 63, 1045, 63, 10283, 8, 277, 304, 272, 543, 1067, 14, 10283, 63, 632, 837, 489, 7425, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 467, 536, 628, 7241, 531, 489, 671, 275, 1104, 63, 1483, 14, 479, 63, 1452, 8, 7241, 12, 7425, 9, 489, 702, 671, 365, 488, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 3536, 63, 6526, 63, 13154, 8, 277, 304, 272, 327, 13599, 1104, 272, 2955, 63, 7241, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 467, 536, 628, 7241, 531, 272 ]
[ 1898, 7800, 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, 3228, 14, 1483, 14, 1074, 63, 1483, 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, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 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, 2552, 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, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1104, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 10716, 919, 529, 20852, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 3128, 63, 3536, 8, 277, 304, 272, 2345, 275, 4413, 63, 411, 14, 4083, 8, 17, 9, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 3128, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 4421, 63, 3128, 63, 3536, 8, 277, 304, 272, 16685, 275, 5178, 63, 3128, 14, 12079, 8, 267, 4918, 16025, 16, 12, 378, 467, 359, 17, 12, 499, 2365, 1338, 1524, 17, 12, 499, 467, 9363, 63, 1392, 1524, 19, 12, 841, 566, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 724, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 8237, 63, 3536, 8, 277, 304, 272, 1625, 275, 980, 14, 1144, 779, 17, 12, 499, 12, 650, 566, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 1144, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4780, 63, 875, 63, 3536, 8, 277, 304, 272, 3002, 495, 275, 298, 5006, 2, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 28314, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 1662, 495, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 2865, 63, 8147, 63, 785, 63, 3536, 8, 277, 304, 272, 2222, 63, 8147, 275, 14763, 272, 543, 291, 14, 10835, 8, 4333, 12, 298, 475, 506, 6076, 2349, 489, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 2865, 63, 8147, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 513, 63, 9105, 63, 1397, 63, 3730, 8, 277, 304, 272, 769, 63, 1618, 63, 14573, 275, 359, 267, 4413, 63, 411, 14, 4083, 779, 845, 12, 6928, 2522, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 566, 272, 1622, 272, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 513, 63, 1618, 63, 14573, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 4679, 63, 9105, 63, 1397, 63, 3730, 8, 277, 304, 272, 4306, 63, 1618, 63, 14573, 275, 334, 4083, 63, 411, 14, 4083, 779, 845, 12, 6928, 2522, 4413, 63, 411, 14, 4083, 8, 267, 359, 17, 12, 499, 2459, 272, 1104, 63, 1483, 14, 479, 63, 28314, 63, 8147, 8, 4679, 63, 1618, 63, 14573, 9, 421, 199, 533, 10716, 591, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 262, 63, 2180, 63, 460, 63, 10283, 63, 10433, 342, 523, 347, 511, 63, 26664, 63, 3730, 63, 6526, 63, 1452, 8, 277, 304, 272, 7425, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 467, 536, 628, 7241, 531, 272, 543, 4156, 14, 2785, 63, 5714, 779, 1074, 63, 1483, 14, 479, 63, 1452, 8, 7241, 12, 7425, 31540, 489, 734, 275, 1625, 63, 1483, 14, 5582, 8, 7241, 9, 272, 291, 14, 7383, 8, 548, 9, 819, 347, 511, 63, 5808, 63, 3592, 63, 1045, 63, 10283, 8, 277, 304, 272, 543, 1067, 14, 10283, 63, 632, 837, 489, 7425, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 499, 467, 536, 628, 7241, 531, 489, 671, 275, 1104, 63, 1483, 14, 479, 63, 1452, 8, 7241, 12, 7425, 9, 489, 702, 671, 365, 488, 819, 768, 396, 63, 1974, 14, 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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 ]
csiro-rds/casda-samples
cutouts_by_proj.py
1
7634
############################################################################################# # # Python script to demonstrate interacting with CASDA's SODA implementation to # retrieve cutout images around a list of sources. # # This script creates a job to produce and download cutouts from the specified image at # the positions provided in an input file (each line has an RA and DEC). # # Author: James Dempsey on 16 Apr 2016 # # Written for python 2.7 # Note: astropy is available on galaxy via 'module load astropy' # On other machines, try Anaconda https://www.continuum.io/downloads # # Modified: MH on 18th Dec 2020 # Take in proj name in TAP query of images. Proj argument should be text snippet of the project name in obscore. e.g. EMU for EMU, Rapid for RACS. # Also now does RA and Dec search in the TAP query of images (not just in the SODA cutout command). # # Modified:MH on 12th Apr # Use s_region for image region. This may contain NaN pixel borders, but better representation of whether a point is within an image. (Previously used fixed radius from image centre). # # Example usage: # python cutouts_by_proj.py OPAL-username Rapid mysources.txt racs_output 0.1 # For RACS cutouts, with list of positions in a file mysources,txt, and cutout radius 0.1 degrees. # ############################################################################################# from __future__ import print_function, division, unicode_literals import argparse import os from astropy.io import votable from astropy.coordinates import SkyCoord from astropy import units import casda def parseargs(): """ Parse the command line arguments :return: An args map with the parsed arguments """ parser = argparse.ArgumentParser(description="Download cutouts of specific locations from the specified image") parser.add_argument("opal_username", help="Your user name on the ATNF's online proposal system (normally an email address)") parser.add_argument("-p", "--opal_password", help="Your password on the ATNF's online proposal system") parser.add_argument("--password_file", help="The file holding your password for the ATNF's online proposal system") parser.add_argument("proj", help="The text in project name, e.g. EMU, or Rapid ") parser.add_argument("source_list_file", help="The file holding the list of positions, with one RA and Dec pair per line.") parser.add_argument("destination_directory", help="The directory where the resulting files will be stored") parser.add_argument("radius", help="Radius, in degrees, of the cutouts") args = parser.parse_args() return args def parse_sources_file(filename): """ Read in a file of sources, with one source each line. Each source is specified as a right ascension and declination pair separated by space. e.g. 1:34:56 -45:12:30 320.20 -43.5 :param filename: The name of the file contining the list of sources :return: A list of SkyCoord objects representing the parsed sources. """ sourcelist = [] with open(filename, 'r') as f: for line in f: if line and line[0] != '#': parts = line.split() if len(parts) > 1: if parts[0].find(':') > -1 or parts[0].find('h') > -1: sky_loc = SkyCoord(parts[0], parts[1], frame='icrs', unit=(units.hourangle, units.deg)) else: sky_loc = SkyCoord(parts[0], parts[1], frame='icrs', unit=(units.deg, units.deg)) sourcelist.append(sky_loc) return sourcelist def produce_cutouts(source_list, proj, username, password, destination_dir, cutout_radius_degrees): # Use CASDA VO (secure) to query for the images associated with the given scheduling_block_id print ("\n\n** Retreiving image details for %s ... \n\n" % proj) filename = destination_dir + str(proj) + ".xml" #Do initial filter of images, allow for 3 deg cone around position (get ASKAP image which is ~30 sq deg). src_num = 0 for sky_loc in source_list: src_num = src_num + 1 ra = sky_loc.ra.degree dec = sky_loc.dec.degree data_product_id_query = "select * from ivoa.obscore where obs_collection LIKE '%" + proj + \ "%' and dataproduct_subtype = 'cont.restored.t0' and pol_states = '/I/' and 1 = CONTAINS(POINT('ICRS',"+ str(ra) + ","+ str(dec) + "),s_region)" casda.sync_tap_query(data_product_id_query, filename, username=username, password=password) image_cube_votable = votable.parse(filename, pedantic=False) results_array = image_cube_votable.get_table_by_id('results').array # For each of the image cubes, query datalink to get the secure datalink details print ("\n\n** Retrieving datalink for each image containing source number " + str(src_num) + " ...\n\n") authenticated_id_tokens = [] for image_cube_result in results_array: image_cube_id = image_cube_result['obs_publisher_did'].decode('utf-8') async_url, authenticated_id_token = casda.get_service_link_and_id(image_cube_id, username, password, service='cutout_service', destination_dir=destination_dir) if authenticated_id_token is not None: authenticated_id_tokens.append(authenticated_id_token) if len(authenticated_id_tokens) == 0: print ("No image cubes found") return 1 # Create the async job job_location = casda.create_async_soda_job(authenticated_id_tokens) # For each entry in the results of the catalogue query, add the position filter as a parameter to the async job cutout_filters = [] circle = "CIRCLE " + str(ra) + " " + str(dec) + " " + str(cutout_radius_degrees) cutout_filters.append(circle) casda.add_params_to_async_job(job_location, 'pos', cutout_filters) # Run the job status = casda.run_async_job(job_location) # Download all of the files, or alert if it didn't complete if status == 'COMPLETED': print ("\n\n** Downloading results...\n\n") casda.download_all(job_location, destination_dir) returnflag = 0 else: print ("Job did not complete: Status was %s." % status) returnflag = 1 if returnflag == 0: return 0 else: return 1 def main(): args = parseargs() password = casda.get_opal_password(args.opal_password, args.password_file) # Change this to choose which environment to use, prod is the default # casda.use_dev() destination_dir = args.destination_directory + "/" + str(args.proj) + "/" # directory where files will be saved # 1) Read in the list of sources print ("\n\n** Parsing the source list ...\n") source_list = parse_sources_file(args.source_list_file) print ("\n** Read %d sources...\n\n" % (len(source_list))) # 2) Create the destination directory if not os.path.exists(destination_dir): os.makedirs(destination_dir) # Do the work return produce_cutouts(source_list, args.proj, args.opal_username, password, destination_dir, args.radius) if __name__ == '__main__': exit(main())
apache-2.0
[ 3060, 6565, 8776, 199, 3, 199, 3, 2018, 2884, 370, 23789, 18161, 17232, 316, 543, 27751, 8980, 1159, 3562, 8980, 4514, 370, 199, 3, 8044, 10415, 548, 5935, 6818, 282, 769, 402, 5274, 14, 199, 3, 221, 199, 3, 961, 2884, 8491, 282, 3906, 370, 7389, 436, 5235, 10415, 16816, 687, 314, 2013, 1834, 737, 199, 3, 314, 12266, 2741, 315, 376, 1324, 570, 334, 10885, 1004, 965, 376, 31632, 436, 31371, 680, 199, 3, 199, 3, 6529, 26, 1603, 14015, 1487, 311, 261, 89, 641, 3193, 437, 2700, 7800, 199, 3, 199, 3, 27694, 367, 2366, 499, 14, 23, 199, 3, 3390, 26, 28753, 365, 2808, 641, 486, 15914, 4799, 283, 578, 2248, 28753, 7, 199, 3, 4068, 1163, 20601, 12, 862, 1626, 16928, 983, 4178, 921, 1544, 14, 12875, 19805, 14, 2308, 15, 20373, 199, 3, 199, 3, 22016, 26, 603, 40, 641, 6155, 273, 13966, 25455, 199, 3, 18146, 315, 13523, 536, 315, 377, 1282, 1827, 402, 5935, 14, 2165, 74, 1423, 1077, 506, 1318, 17440, 402, 314, 2199, 536, 315, 16087, 1018, 14, 325, 14, 71, 14, 26512, 53, 367, 26512, 53, 12, 820, 27703, 367, 820, 1348, 51, 14, 221, 199, 3, 6121, 3063, 1630, 31632, 436, 13966, 2754, 315, 314, 377, 1282, 1827, 402, 5935, 334, 1397, 2951, 315, 314, 3562, 8980, 10415, 548, 1414, 680, 199, 3, 199, 3, 22016, 26, 30668, 641, 3144, 273, 437, 2700, 199, 3, 3645, 308, 63, 4551, 367, 1834, 4897, 14, 961, 1443, 1395, 16046, 7148, 9162, 83, 12, 1325, 8034, 6025, 402, 3775, 282, 2376, 365, 4453, 376, 1834, 14, 334, 18021, 590, 1202, 6317, 9362, 687, 1834, 13345, 264, 680, 221, 199, 3, 199, 3, 5679, 4503, 26, 199, 3, 2366, 10415, 16816, 63, 991, 63, 5468, 14, 647, 9827, 748, 13, 2473, 820, 27703, 333, 588, 616, 83, 14, 2424, 660, 1259, 63, 1199, 378, 14, 17, 199, 3, 2104, 820, 1348, 51, 10415, 16816, 12, 543, 769, 402, 12266, 315, 282, 570, 333, 588, 616, 83, 12, 2424, 12, 436, 10415, 548, 9362, 378, 14, 17, 14358, 14, 199, 3, 199, 3060, 6565, 8776, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 12, 2649, 63, 5955, 199, 199, 646, 7534, 199, 646, 747, 199, 199, 504, 28753, 14, 2308, 492, 373, 357, 461, 199, 504, 28753, 14, 12924, 492, 428, 10562, 14957, 199, 504, 28753, 492, 6204, 199, 199, 646, 14984, 983, 421, 199, 318, 2198, 589, 837, 272, 408, 272, 6077, 314, 1414, 1004, 2368, 272, 520, 1107, 26, 1626, 1249, 2341, 543, 314, 4565, 2368, 272, 408, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 11950, 10415, 16816, 402, 2488, 9918, 687, 314, 2013, 1834, 531, 272, 1798, 14, 525, 63, 2094, 480, 411, 279, 63, 2473, 401, 717, 1720, 628, 14398, 922, 536, 641, 314, 15059, 19749, 1159, 18470, 28315, 2656, 334, 4791, 1183, 376, 3031, 2287, 6320, 272, 1798, 14, 525, 63, 2094, 6096, 80, 401, 4320, 411, 279, 63, 2060, 401, 1720, 628, 14398, 2505, 641, 314, 15059, 19749, 1159, 18470, 28315, 2656, 531, 272, 1798, 14, 525, 63, 2094, 6739, 2060, 63, 493, 401, 1720, 628, 1918, 570, 17573, 2195, 2505, 367, 314, 15059, 19749, 1159, 18470, 28315, 2656, 531, 272, 1798, 14, 525, 63, 2094, 480, 5468, 401, 1720, 628, 1918, 1318, 315, 2199, 536, 12, 325, 14, 71, 14, 26512, 53, 12, 503, 820, 27703, 6099, 272, 1798, 14, 525, 63, 2094, 480, 1365, 63, 513, 63, 493, 401, 717, 1720, 628, 1918, 570, 17573, 314, 769, 402, 12266, 12, 543, 1373, 31632, 436, 13966, 4092, 1126, 1004, 2685, 272, 1798, 14, 525, 63, 2094, 480, 6881, 63, 3619, 401, 1720, 628, 1918, 2082, 2382, 314, 9183, 1584, 911, 506, 5489, 531, 272, 1798, 14, 525, 63, 2094, 480, 8017, 401, 1720, 628, 19800, 12, 315, 14358, 12, 402, 314, 10415, 16816, 531, 2286, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 372, 1249, 421, 199, 318, 2198, 63, 4553, 63, 493, 8, 1501, 304, 272, 408, 272, 5574, 315, 282, 570, 402, 5274, 12, 543, 1373, 1350, 1924, 1004, 14, 7048, 1350, 365, 2013, 465, 282, 272, 2451, 465, 2497, 438, 436, 15021, 3155, 4092, 11673, 701, 4601, 14, 272, 325, 14, 71, 14, 272, 413, 26, 1082, 26, 1367, 446, 2322, 26, 713, 26, 1216, 272, 25611, 14, 1165, 446, 2824, 14, 21, 272, 520, 635, 1788, 26, 710, 536, 402, 314, 570, 9832, 316, 314, 769, 402, 5274, 272, 520, 1107, 26, 437, 769, 402, 428, 10562, 14957, 2251, 6144, 314, 4565, 5274, 14, 272, 408, 272, 1350, 513, 275, 942, 272, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 267, 367, 1004, 315, 289, 26, 288, 340, 1004, 436, 1004, 59, 16, 61, 1137, 32326, 355, 4184, 275, 1004, 14, 1294, 342, 355, 340, 822, 8, 4181, 9, 690, 413, 26, 490, 340, 4184, 59, 16, 1055, 1623, 11633, 690, 446, 17, 503, 4184, 59, 16, 1055, 1623, 360, 72, 358, 690, 446, 17, 26, 717, 2386, 89, 63, 2102, 275, 428, 10562, 14957, 8, 4181, 59, 16, 467, 4184, 59, 17, 467, 2787, 534, 530, 2393, 297, 5644, 4137, 2687, 5260, 14, 5180, 4593, 12, 6204, 14, 6458, 430, 490, 587, 26, 717, 2386, 89, 63, 2102, 275, 428, 10562, 14957, 8, 4181, 59, 16, 467, 4184, 59, 17, 467, 2787, 534, 530, 2393, 297, 5644, 4137, 2687, 5260, 14, 6458, 12, 6204, 14, 6458, 430, 490, 1350, 513, 14, 740, 8, 12267, 63, 2102, 9, 272, 372, 1350, 513, 421, 199, 318, 7389, 63, 5919, 16816, 8, 1365, 63, 513, 12, 13523, 12, 3434, 12, 2505, 12, 5724, 63, 694, 12, 10415, 548, 63, 8017, 63, 20251, 304, 272, 327, 3645, 27751, 8980, 812, 47, 334, 7817, 9, 370, 1827, 367, 314, 5935, 4568, 543, 314, 1627, 23800, 63, 1457, 63, 344, 272, 870, 25381, 78, 60, 78, 538, 8747, 264, 12616, 1834, 2436, 367, 450, 83, 2263, 971, 78, 60, 78, 2, 450, 13523, 9, 272, 1788, 275, 5724, 63, 694, 435, 620, 8, 5468, 9, 435, 3680, 1652, 2, 272, 327, 2585, 2536, 2457, 402, 5935, 12, 2040, 367, 650, 7926, 286 ]
[ 6565, 8776, 199, 3, 199, 3, 2018, 2884, 370, 23789, 18161, 17232, 316, 543, 27751, 8980, 1159, 3562, 8980, 4514, 370, 199, 3, 8044, 10415, 548, 5935, 6818, 282, 769, 402, 5274, 14, 199, 3, 221, 199, 3, 961, 2884, 8491, 282, 3906, 370, 7389, 436, 5235, 10415, 16816, 687, 314, 2013, 1834, 737, 199, 3, 314, 12266, 2741, 315, 376, 1324, 570, 334, 10885, 1004, 965, 376, 31632, 436, 31371, 680, 199, 3, 199, 3, 6529, 26, 1603, 14015, 1487, 311, 261, 89, 641, 3193, 437, 2700, 7800, 199, 3, 199, 3, 27694, 367, 2366, 499, 14, 23, 199, 3, 3390, 26, 28753, 365, 2808, 641, 486, 15914, 4799, 283, 578, 2248, 28753, 7, 199, 3, 4068, 1163, 20601, 12, 862, 1626, 16928, 983, 4178, 921, 1544, 14, 12875, 19805, 14, 2308, 15, 20373, 199, 3, 199, 3, 22016, 26, 603, 40, 641, 6155, 273, 13966, 25455, 199, 3, 18146, 315, 13523, 536, 315, 377, 1282, 1827, 402, 5935, 14, 2165, 74, 1423, 1077, 506, 1318, 17440, 402, 314, 2199, 536, 315, 16087, 1018, 14, 325, 14, 71, 14, 26512, 53, 367, 26512, 53, 12, 820, 27703, 367, 820, 1348, 51, 14, 221, 199, 3, 6121, 3063, 1630, 31632, 436, 13966, 2754, 315, 314, 377, 1282, 1827, 402, 5935, 334, 1397, 2951, 315, 314, 3562, 8980, 10415, 548, 1414, 680, 199, 3, 199, 3, 22016, 26, 30668, 641, 3144, 273, 437, 2700, 199, 3, 3645, 308, 63, 4551, 367, 1834, 4897, 14, 961, 1443, 1395, 16046, 7148, 9162, 83, 12, 1325, 8034, 6025, 402, 3775, 282, 2376, 365, 4453, 376, 1834, 14, 334, 18021, 590, 1202, 6317, 9362, 687, 1834, 13345, 264, 680, 221, 199, 3, 199, 3, 5679, 4503, 26, 199, 3, 2366, 10415, 16816, 63, 991, 63, 5468, 14, 647, 9827, 748, 13, 2473, 820, 27703, 333, 588, 616, 83, 14, 2424, 660, 1259, 63, 1199, 378, 14, 17, 199, 3, 2104, 820, 1348, 51, 10415, 16816, 12, 543, 769, 402, 12266, 315, 282, 570, 333, 588, 616, 83, 12, 2424, 12, 436, 10415, 548, 9362, 378, 14, 17, 14358, 14, 199, 3, 199, 3060, 6565, 8776, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 12, 2649, 63, 5955, 199, 199, 646, 7534, 199, 646, 747, 199, 199, 504, 28753, 14, 2308, 492, 373, 357, 461, 199, 504, 28753, 14, 12924, 492, 428, 10562, 14957, 199, 504, 28753, 492, 6204, 199, 199, 646, 14984, 983, 421, 199, 318, 2198, 589, 837, 272, 408, 272, 6077, 314, 1414, 1004, 2368, 272, 520, 1107, 26, 1626, 1249, 2341, 543, 314, 4565, 2368, 272, 408, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 11950, 10415, 16816, 402, 2488, 9918, 687, 314, 2013, 1834, 531, 272, 1798, 14, 525, 63, 2094, 480, 411, 279, 63, 2473, 401, 717, 1720, 628, 14398, 922, 536, 641, 314, 15059, 19749, 1159, 18470, 28315, 2656, 334, 4791, 1183, 376, 3031, 2287, 6320, 272, 1798, 14, 525, 63, 2094, 6096, 80, 401, 4320, 411, 279, 63, 2060, 401, 1720, 628, 14398, 2505, 641, 314, 15059, 19749, 1159, 18470, 28315, 2656, 531, 272, 1798, 14, 525, 63, 2094, 6739, 2060, 63, 493, 401, 1720, 628, 1918, 570, 17573, 2195, 2505, 367, 314, 15059, 19749, 1159, 18470, 28315, 2656, 531, 272, 1798, 14, 525, 63, 2094, 480, 5468, 401, 1720, 628, 1918, 1318, 315, 2199, 536, 12, 325, 14, 71, 14, 26512, 53, 12, 503, 820, 27703, 6099, 272, 1798, 14, 525, 63, 2094, 480, 1365, 63, 513, 63, 493, 401, 717, 1720, 628, 1918, 570, 17573, 314, 769, 402, 12266, 12, 543, 1373, 31632, 436, 13966, 4092, 1126, 1004, 2685, 272, 1798, 14, 525, 63, 2094, 480, 6881, 63, 3619, 401, 1720, 628, 1918, 2082, 2382, 314, 9183, 1584, 911, 506, 5489, 531, 272, 1798, 14, 525, 63, 2094, 480, 8017, 401, 1720, 628, 19800, 12, 315, 14358, 12, 402, 314, 10415, 16816, 531, 2286, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 372, 1249, 421, 199, 318, 2198, 63, 4553, 63, 493, 8, 1501, 304, 272, 408, 272, 5574, 315, 282, 570, 402, 5274, 12, 543, 1373, 1350, 1924, 1004, 14, 7048, 1350, 365, 2013, 465, 282, 272, 2451, 465, 2497, 438, 436, 15021, 3155, 4092, 11673, 701, 4601, 14, 272, 325, 14, 71, 14, 272, 413, 26, 1082, 26, 1367, 446, 2322, 26, 713, 26, 1216, 272, 25611, 14, 1165, 446, 2824, 14, 21, 272, 520, 635, 1788, 26, 710, 536, 402, 314, 570, 9832, 316, 314, 769, 402, 5274, 272, 520, 1107, 26, 437, 769, 402, 428, 10562, 14957, 2251, 6144, 314, 4565, 5274, 14, 272, 408, 272, 1350, 513, 275, 942, 272, 543, 1551, 8, 1501, 12, 283, 82, 358, 465, 289, 26, 267, 367, 1004, 315, 289, 26, 288, 340, 1004, 436, 1004, 59, 16, 61, 1137, 32326, 355, 4184, 275, 1004, 14, 1294, 342, 355, 340, 822, 8, 4181, 9, 690, 413, 26, 490, 340, 4184, 59, 16, 1055, 1623, 11633, 690, 446, 17, 503, 4184, 59, 16, 1055, 1623, 360, 72, 358, 690, 446, 17, 26, 717, 2386, 89, 63, 2102, 275, 428, 10562, 14957, 8, 4181, 59, 16, 467, 4184, 59, 17, 467, 2787, 534, 530, 2393, 297, 5644, 4137, 2687, 5260, 14, 5180, 4593, 12, 6204, 14, 6458, 430, 490, 587, 26, 717, 2386, 89, 63, 2102, 275, 428, 10562, 14957, 8, 4181, 59, 16, 467, 4184, 59, 17, 467, 2787, 534, 530, 2393, 297, 5644, 4137, 2687, 5260, 14, 6458, 12, 6204, 14, 6458, 430, 490, 1350, 513, 14, 740, 8, 12267, 63, 2102, 9, 272, 372, 1350, 513, 421, 199, 318, 7389, 63, 5919, 16816, 8, 1365, 63, 513, 12, 13523, 12, 3434, 12, 2505, 12, 5724, 63, 694, 12, 10415, 548, 63, 8017, 63, 20251, 304, 272, 327, 3645, 27751, 8980, 812, 47, 334, 7817, 9, 370, 1827, 367, 314, 5935, 4568, 543, 314, 1627, 23800, 63, 1457, 63, 344, 272, 870, 25381, 78, 60, 78, 538, 8747, 264, 12616, 1834, 2436, 367, 450, 83, 2263, 971, 78, 60, 78, 2, 450, 13523, 9, 272, 1788, 275, 5724, 63, 694, 435, 620, 8, 5468, 9, 435, 3680, 1652, 2, 272, 327, 2585, 2536, 2457, 402, 5935, 12, 2040, 367, 650, 7926, 286, 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 ]
tjhunter/phd-thesis-tjhunter
python/kdd/plot_network.py
1
1065
__author__ = 'tjhunter' import build import json import pylab as pl from matplotlib.collections import LineCollection # Draws the network as a pdf and SVG file. def draw_network(ax, fd, link_style): def decode_line(l): #print l dct = json.loads(l) lats = dct['lats'] lons = dct['lons'] return zip(lons, lats) lines = [decode_line(l) for l in fd] #print lines xmin = min([x for l in lines for x,y in l]) xmax = max([x for l in lines for x,y in l]) ymin = min([y for l in lines for x,y in l]) ymax = max([y for l in lines for x,y in l]) lc = LineCollection(lines, **link_style) ax.add_collection(lc, autolim=True) return ((xmin,xmax),(ymin,ymax)) fname = build.data_name('kdd/net_export_6.json') fig = pl.figure("fig1",figsize=(10,10)) ax = fig.gca() ax.set_axis_off() style = {'colors':'k','linewidths':0.5} with open(fname) as f: (xlims, ylims) = draw_network(ax, f, style) ax.set_xlim(*xlims) ax.set_ylim(*ylims) # Saving in pdf is a bit slow build.save_figure(fig, 'figures-kdd/network_export_6',save_svg=True)
apache-2.0
[ 199, 363, 2502, 363, 275, 283, 84, 31623, 7867, 7, 199, 199, 646, 1900, 199, 646, 2022, 199, 646, 19199, 465, 1620, 199, 504, 8027, 14, 7882, 492, 7030, 7768, 199, 3, 17813, 83, 314, 2784, 465, 282, 11249, 436, 32062, 570, 14, 199, 199, 318, 5954, 63, 1200, 8, 1219, 12, 6111, 12, 2142, 63, 2487, 304, 523, 347, 4849, 63, 604, 8, 76, 304, 272, 327, 1361, 634, 272, 16354, 275, 2022, 14, 3640, 8, 76, 9, 272, 634, 1956, 275, 16354, 459, 76, 1956, 418, 272, 634, 4654, 275, 16354, 459, 76, 4654, 418, 272, 372, 3482, 8, 76, 4654, 12, 634, 1956, 9, 523, 2385, 275, 359, 2708, 63, 604, 8, 76, 9, 367, 634, 315, 6111, 61, 523, 327, 1361, 2385, 523, 22036, 275, 1748, 779, 88, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 19906, 275, 1390, 779, 88, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 22506, 275, 1748, 779, 89, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 21023, 275, 1390, 779, 89, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 16093, 275, 7030, 7768, 8, 1278, 12, 1011, 1073, 63, 2487, 9, 523, 2185, 14, 525, 63, 3627, 8, 10181, 12, 2599, 4175, 29, 549, 9, 523, 372, 3666, 21601, 12, 28961, 11865, 27429, 12, 30036, 430, 421, 199, 5252, 275, 1900, 14, 576, 63, 354, 360, 75, 617, 15, 846, 63, 3790, 63, 22, 14, 1001, 358, 199, 592, 275, 1620, 14, 8941, 480, 592, 17, 401, 23899, 2687, 709, 12, 709, 430, 199, 1219, 275, 6085, 14, 71, 696, 342, 199, 1219, 14, 409, 63, 3127, 63, 1997, 342, 199, 2487, 275, 791, 7120, 5242, 75, 1673, 24643, 83, 356, 16, 14, 21, 93, 199, 1045, 1551, 8, 5252, 9, 465, 289, 26, 523, 334, 88, 31689, 12, 612, 31689, 9, 275, 5954, 63, 1200, 8, 1219, 12, 289, 12, 3449, 9, 523, 2185, 14, 409, 63, 18512, 2031, 88, 31689, 9, 523, 2185, 14, 409, 63, 18123, 2031, 89, 31689, 9, 199, 3, 428, 5519, 315, 11249, 365, 282, 4546, 11999, 199, 1506, 14, 2117, 63, 8941, 8, 592, 12, 283, 592, 1482, 13, 75, 617, 15, 1200, 63, 3790, 63, 22, 297, 2117, 63, 10273, 29, 549, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 363, 2502, 363, 275, 283, 84, 31623, 7867, 7, 199, 199, 646, 1900, 199, 646, 2022, 199, 646, 19199, 465, 1620, 199, 504, 8027, 14, 7882, 492, 7030, 7768, 199, 3, 17813, 83, 314, 2784, 465, 282, 11249, 436, 32062, 570, 14, 199, 199, 318, 5954, 63, 1200, 8, 1219, 12, 6111, 12, 2142, 63, 2487, 304, 523, 347, 4849, 63, 604, 8, 76, 304, 272, 327, 1361, 634, 272, 16354, 275, 2022, 14, 3640, 8, 76, 9, 272, 634, 1956, 275, 16354, 459, 76, 1956, 418, 272, 634, 4654, 275, 16354, 459, 76, 4654, 418, 272, 372, 3482, 8, 76, 4654, 12, 634, 1956, 9, 523, 2385, 275, 359, 2708, 63, 604, 8, 76, 9, 367, 634, 315, 6111, 61, 523, 327, 1361, 2385, 523, 22036, 275, 1748, 779, 88, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 19906, 275, 1390, 779, 88, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 22506, 275, 1748, 779, 89, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 21023, 275, 1390, 779, 89, 367, 634, 315, 2385, 367, 671, 12, 89, 315, 634, 566, 523, 16093, 275, 7030, 7768, 8, 1278, 12, 1011, 1073, 63, 2487, 9, 523, 2185, 14, 525, 63, 3627, 8, 10181, 12, 2599, 4175, 29, 549, 9, 523, 372, 3666, 21601, 12, 28961, 11865, 27429, 12, 30036, 430, 421, 199, 5252, 275, 1900, 14, 576, 63, 354, 360, 75, 617, 15, 846, 63, 3790, 63, 22, 14, 1001, 358, 199, 592, 275, 1620, 14, 8941, 480, 592, 17, 401, 23899, 2687, 709, 12, 709, 430, 199, 1219, 275, 6085, 14, 71, 696, 342, 199, 1219, 14, 409, 63, 3127, 63, 1997, 342, 199, 2487, 275, 791, 7120, 5242, 75, 1673, 24643, 83, 356, 16, 14, 21, 93, 199, 1045, 1551, 8, 5252, 9, 465, 289, 26, 523, 334, 88, 31689, 12, 612, 31689, 9, 275, 5954, 63, 1200, 8, 1219, 12, 289, 12, 3449, 9, 523, 2185, 14, 409, 63, 18512, 2031, 88, 31689, 9, 523, 2185, 14, 409, 63, 18123, 2031, 89, 31689, 9, 199, 3, 428, 5519, 315, 11249, 365, 282, 4546, 11999, 199, 1506, 14, 2117, 63, 8941, 8, 592, 12, 283, 592, 1482, 13, 75, 617, 15, 1200, 63, 3790, 63, 22, 297, 2117, 63, 10273, 29, 549, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
interalia/cmsplugin_availablejobs
availablejob/views.py
1
3330
from django.views.generic.simple import direct_to_template from django.views.generic.list_detail import object_detail from django.contrib.sites.models import Site from django.shortcuts import get_object_or_404 from django.contrib import messages from models import EnableOpening, Opening, Candidate from forms import ApplyForm import datetime import hashlib from django.views.decorators.csrf import csrf_exempt from django.conf import settings def __create_candidate(form,op,file): name = form.cleaned_data["name"] email = form.cleaned_data["email"] phone = form.cleaned_data["phone"] cv = form.cleaned_data["cv"] uploaded_file(file) candidate, created = Candidate.objects.get_or_create(name = name, email = email) if op: candidate.opening = op candidate.phone = phone candidate.cv = cv candidate.save() return candidate def index(request): eopen = EnableOpening.objects.all() for i in eopen: print i form = ApplyForm() post=False ios=mobile(request) d = {"opens": eopen,'form': form,'post':post,'mobile':ios} if request.method == "POST": form= ApplyForm(request.POST,request.FILES) if form.is_valid(): post=True d.update({"form":form,"post":post}) name = form.cleaned_data.get("opening") opening = EnableOpening.objects.filter(opening__title = name) ''' for i in opening: __create_candidate(form,i,request.FILES['cv']) ''' else: d.update({"form":form,"post":post}) return direct_to_template(request, template="vacancy/index.html",extra_context=d) def detail(request, id): qs = EnableOpening.objects.all() d = {"queryset": qs, 'object_id': int(id), 'template_name': "vacancy/opening_detail.html" } return object_detail(request,**d) def _process_cv(request,opening): applyform = ApplyForm() if request.method == "POST": form= ApplyForm(request.POST) if form.is_valid(): vacante=form.save(commit=False) vacante.save() return direct_to_template(request, template = "vacancy/job_submit_success.html") else: return direct_to_template(request, template = "vacancy/job_form.html") def show_form(request, id): opening = get_object_or_404(EnableOpening, id = id) return _process_cv(request, opening) def send_cv(request): opening = None return _process_cv(request,opening) def facebook(request): ops = EnableOpening.objects.all() today = hashlib.md5(str(datetime.datetime.now())) SITE = Site.objects.get_current() d = {"enable_openings": ops, "today": today.hexdigest(), 'SITE': SITE} return direct_to_template(request, "vacancy/facebook.html", extra_context = d) def mobile(request): device = {} mobile=False ua=request.META.get('HTTP_USER_AGENT','').lower() if ua.find("iphone") > 0: mobile= True if ua.find("ipad") > 0: mobile= True if mobile: return True else: return False def uploaded_file(filename): fd=open(settings.MEDIA_CV+str(filename),'wb+') for chunk in filename.chunks(): fd.write(chunk) fd.close()
bsd-3-clause
[ 504, 1639, 14, 4196, 14, 6767, 14, 4129, 492, 4125, 63, 475, 63, 1160, 199, 504, 1639, 14, 4196, 14, 6767, 14, 513, 63, 5506, 492, 909, 63, 5506, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 221, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1709, 492, 12030, 4299, 316, 12, 3232, 316, 12, 6855, 5168, 199, 504, 4513, 492, 14618, 2821, 199, 646, 2197, 199, 646, 8337, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 25254, 199, 504, 1639, 14, 2190, 492, 2202, 4388, 199, 318, 636, 981, 63, 9007, 8, 964, 12, 411, 12, 493, 304, 267, 536, 275, 1824, 14, 8275, 63, 576, 905, 354, 937, 267, 3031, 275, 1824, 14, 8275, 63, 576, 905, 2123, 937, 267, 14617, 275, 1824, 14, 8275, 63, 576, 905, 9339, 937, 267, 6277, 275, 1824, 14, 8275, 63, 576, 905, 5107, 937, 267, 14238, 63, 493, 8, 493, 9, 267, 7627, 12, 2737, 275, 6855, 5168, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 354, 275, 536, 12, 3031, 275, 3031, 9, 267, 340, 1687, 26, 288, 7627, 14, 21849, 275, 1687, 267, 7627, 14, 9339, 275, 14617, 267, 7627, 14, 5107, 275, 6277, 267, 7627, 14, 2117, 342, 267, 372, 7627, 421, 199, 318, 1478, 8, 1069, 304, 272, 325, 1490, 275, 12030, 4299, 316, 14, 1462, 14, 452, 342, 272, 367, 284, 315, 325, 1490, 26, 267, 870, 284, 272, 1824, 275, 14618, 2821, 342, 272, 2963, 29, 797, 272, 29516, 29, 11375, 8, 1069, 9, 272, 366, 275, 2420, 1490, 83, 582, 325, 1490, 2584, 964, 356, 1824, 2584, 1932, 356, 1932, 2584, 11375, 356, 9207, 93, 272, 340, 1056, 14, 765, 508, 298, 4030, 582, 755, 267, 1824, 29, 14618, 2821, 8, 1069, 14, 4030, 12, 1069, 14, 9472, 9, 267, 340, 1824, 14, 374, 63, 1078, 837, 259, 288, 2963, 29, 549, 259, 288, 366, 14, 873, 6333, 964, 582, 964, 4589, 1932, 582, 1932, 1552, 259, 288, 536, 275, 1824, 14, 8275, 63, 576, 14, 362, 480, 21849, 531, 755, 288, 13618, 275, 12030, 4299, 316, 14, 1462, 14, 1541, 8, 21849, 363, 1213, 275, 536, 9, 288, 1449, 3515, 288, 367, 284, 315, 13618, 26, 355, 636, 981, 63, 9007, 8, 964, 12, 73, 12, 1069, 14, 9472, 459, 5107, 1105, 288, 1449, 267, 587, 26, 6722, 366, 14, 873, 6333, 964, 582, 964, 4589, 1932, 582, 1932, 1552, 272, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 1978, 628, 15367, 9844, 15, 1080, 14, 1360, 401, 2911, 63, 1100, 29, 68, 9, 421, 199, 318, 10093, 8, 1069, 12, 1305, 304, 272, 6377, 275, 12030, 4299, 316, 14, 1462, 14, 452, 342, 272, 366, 275, 2420, 7924, 582, 6377, 12, 283, 785, 63, 344, 356, 1109, 8, 344, 395, 283, 1160, 63, 354, 356, 298, 15367, 9844, 15, 21849, 63, 5506, 14, 1360, 2, 789, 272, 372, 909, 63, 5506, 8, 1069, 12663, 68, 9, 199, 199, 318, 485, 1412, 63, 5107, 8, 1069, 12, 21849, 304, 272, 4838, 964, 275, 14618, 2821, 342, 272, 340, 1056, 14, 765, 508, 298, 4030, 582, 267, 1824, 29, 14618, 2821, 8, 1069, 14, 4030, 9, 267, 340, 1824, 14, 374, 63, 1078, 837, 288, 28898, 8949, 29, 964, 14, 2117, 8, 3543, 29, 797, 9, 257, 288, 28898, 8949, 14, 2117, 342, 288, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 1978, 275, 298, 15367, 9844, 15, 2423, 63, 7275, 63, 3742, 14, 1360, 531, 272, 587, 26, 267, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 1978, 275, 298, 15367, 9844, 15, 2423, 63, 964, 14, 1360, 531, 421, 199, 318, 2498, 63, 964, 8, 1069, 12, 1305, 304, 272, 13618, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 6476, 4299, 316, 12, 1305, 275, 1305, 9, 272, 372, 485, 1412, 63, 5107, 8, 1069, 12, 13618, 9, 199, 199, 318, 3222, 63, 5107, 8, 1069, 304, 272, 13618, 275, 488, 272, 372, 485, 1412, 63, 5107, 8, 1069, 12, 21849, 9, 199, 199, 318, 8870, 2706, 8, 1069, 304, 272, 4156, 275, 12030, 4299, 316, 14, 1462, 14, 452, 342, 272, 11168, 275, 8337, 14, 1064, 21, 8, 495, 8, 2083, 14, 2083, 14, 2131, 4059, 272, 428, 4427, 275, 11666, 14, 1462, 14, 362, 63, 1818, 342, 272, 366, 275, 2420, 4296, 63, 1490, 780, 582, 4156, 12, 298, 8136, 582, 11168, 14, 11453, 1062, 283, 7917, 356, 428, 4427, 93, 272, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 298, 15367, 9844, 15, 16652, 14, 1360, 401, 2402, 63, 1100, 275, 366, 9, 421, 199, 318, 21305, 8, 1069, 304, 272, 2243, 275, 1052, 272, 21305, 29, 797, 272, 18500, 29, 1069, 14, 10614, 14, 362, 360, 2856, 63, 3791, 63, 14565, 26516, 2325, 342, 272, 340, 18500, 14, 1623, 480, 28303, 531, 690, 378, 26, 267, 21305, 29, 715, 272, 340, 18500, 14, 1623, 480, 711, 350, 531, 690, 378, 26, 267, 21305, 29, 715, 272, 340, 21305, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 199, 199, 318, 14238, 63, 493, 8, 1501, 304, 272, 6111, 29, 1490, 8, 1751, 14, 13669, 63, 12847, 11, 495, 8, 1501, 26582, 6603, 13854, 272, 367, 3728, 315, 1788, 14, 10660, 837, 267, 6111, 14, 952, 8, 4604, 9, 272, 6111, 14, 1600, 342, 398, 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 ]
[ 1639, 14, 4196, 14, 6767, 14, 4129, 492, 4125, 63, 475, 63, 1160, 199, 504, 1639, 14, 4196, 14, 6767, 14, 513, 63, 5506, 492, 909, 63, 5506, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 221, 199, 504, 1639, 14, 2828, 492, 3788, 199, 504, 1709, 492, 12030, 4299, 316, 12, 3232, 316, 12, 6855, 5168, 199, 504, 4513, 492, 14618, 2821, 199, 646, 2197, 199, 646, 8337, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 25254, 199, 504, 1639, 14, 2190, 492, 2202, 4388, 199, 318, 636, 981, 63, 9007, 8, 964, 12, 411, 12, 493, 304, 267, 536, 275, 1824, 14, 8275, 63, 576, 905, 354, 937, 267, 3031, 275, 1824, 14, 8275, 63, 576, 905, 2123, 937, 267, 14617, 275, 1824, 14, 8275, 63, 576, 905, 9339, 937, 267, 6277, 275, 1824, 14, 8275, 63, 576, 905, 5107, 937, 267, 14238, 63, 493, 8, 493, 9, 267, 7627, 12, 2737, 275, 6855, 5168, 14, 1462, 14, 362, 63, 269, 63, 981, 8, 354, 275, 536, 12, 3031, 275, 3031, 9, 267, 340, 1687, 26, 288, 7627, 14, 21849, 275, 1687, 267, 7627, 14, 9339, 275, 14617, 267, 7627, 14, 5107, 275, 6277, 267, 7627, 14, 2117, 342, 267, 372, 7627, 421, 199, 318, 1478, 8, 1069, 304, 272, 325, 1490, 275, 12030, 4299, 316, 14, 1462, 14, 452, 342, 272, 367, 284, 315, 325, 1490, 26, 267, 870, 284, 272, 1824, 275, 14618, 2821, 342, 272, 2963, 29, 797, 272, 29516, 29, 11375, 8, 1069, 9, 272, 366, 275, 2420, 1490, 83, 582, 325, 1490, 2584, 964, 356, 1824, 2584, 1932, 356, 1932, 2584, 11375, 356, 9207, 93, 272, 340, 1056, 14, 765, 508, 298, 4030, 582, 755, 267, 1824, 29, 14618, 2821, 8, 1069, 14, 4030, 12, 1069, 14, 9472, 9, 267, 340, 1824, 14, 374, 63, 1078, 837, 259, 288, 2963, 29, 549, 259, 288, 366, 14, 873, 6333, 964, 582, 964, 4589, 1932, 582, 1932, 1552, 259, 288, 536, 275, 1824, 14, 8275, 63, 576, 14, 362, 480, 21849, 531, 755, 288, 13618, 275, 12030, 4299, 316, 14, 1462, 14, 1541, 8, 21849, 363, 1213, 275, 536, 9, 288, 1449, 3515, 288, 367, 284, 315, 13618, 26, 355, 636, 981, 63, 9007, 8, 964, 12, 73, 12, 1069, 14, 9472, 459, 5107, 1105, 288, 1449, 267, 587, 26, 6722, 366, 14, 873, 6333, 964, 582, 964, 4589, 1932, 582, 1932, 1552, 272, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 1978, 628, 15367, 9844, 15, 1080, 14, 1360, 401, 2911, 63, 1100, 29, 68, 9, 421, 199, 318, 10093, 8, 1069, 12, 1305, 304, 272, 6377, 275, 12030, 4299, 316, 14, 1462, 14, 452, 342, 272, 366, 275, 2420, 7924, 582, 6377, 12, 283, 785, 63, 344, 356, 1109, 8, 344, 395, 283, 1160, 63, 354, 356, 298, 15367, 9844, 15, 21849, 63, 5506, 14, 1360, 2, 789, 272, 372, 909, 63, 5506, 8, 1069, 12663, 68, 9, 199, 199, 318, 485, 1412, 63, 5107, 8, 1069, 12, 21849, 304, 272, 4838, 964, 275, 14618, 2821, 342, 272, 340, 1056, 14, 765, 508, 298, 4030, 582, 267, 1824, 29, 14618, 2821, 8, 1069, 14, 4030, 9, 267, 340, 1824, 14, 374, 63, 1078, 837, 288, 28898, 8949, 29, 964, 14, 2117, 8, 3543, 29, 797, 9, 257, 288, 28898, 8949, 14, 2117, 342, 288, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 1978, 275, 298, 15367, 9844, 15, 2423, 63, 7275, 63, 3742, 14, 1360, 531, 272, 587, 26, 267, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 1978, 275, 298, 15367, 9844, 15, 2423, 63, 964, 14, 1360, 531, 421, 199, 318, 2498, 63, 964, 8, 1069, 12, 1305, 304, 272, 13618, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 6476, 4299, 316, 12, 1305, 275, 1305, 9, 272, 372, 485, 1412, 63, 5107, 8, 1069, 12, 13618, 9, 199, 199, 318, 3222, 63, 5107, 8, 1069, 304, 272, 13618, 275, 488, 272, 372, 485, 1412, 63, 5107, 8, 1069, 12, 21849, 9, 199, 199, 318, 8870, 2706, 8, 1069, 304, 272, 4156, 275, 12030, 4299, 316, 14, 1462, 14, 452, 342, 272, 11168, 275, 8337, 14, 1064, 21, 8, 495, 8, 2083, 14, 2083, 14, 2131, 4059, 272, 428, 4427, 275, 11666, 14, 1462, 14, 362, 63, 1818, 342, 272, 366, 275, 2420, 4296, 63, 1490, 780, 582, 4156, 12, 298, 8136, 582, 11168, 14, 11453, 1062, 283, 7917, 356, 428, 4427, 93, 272, 372, 4125, 63, 475, 63, 1160, 8, 1069, 12, 298, 15367, 9844, 15, 16652, 14, 1360, 401, 2402, 63, 1100, 275, 366, 9, 421, 199, 318, 21305, 8, 1069, 304, 272, 2243, 275, 1052, 272, 21305, 29, 797, 272, 18500, 29, 1069, 14, 10614, 14, 362, 360, 2856, 63, 3791, 63, 14565, 26516, 2325, 342, 272, 340, 18500, 14, 1623, 480, 28303, 531, 690, 378, 26, 267, 21305, 29, 715, 272, 340, 18500, 14, 1623, 480, 711, 350, 531, 690, 378, 26, 267, 21305, 29, 715, 272, 340, 21305, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 199, 199, 318, 14238, 63, 493, 8, 1501, 304, 272, 6111, 29, 1490, 8, 1751, 14, 13669, 63, 12847, 11, 495, 8, 1501, 26582, 6603, 13854, 272, 367, 3728, 315, 1788, 14, 10660, 837, 267, 6111, 14, 952, 8, 4604, 9, 272, 6111, 14, 1600, 342, 398, 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, 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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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 ]
wolfram74/numerical_methods_iserles_notes
venv/lib/python2.7/site-packages/IPython/parallel/apps/ipengineapp.py
5
13554
#!/usr/bin/env python # encoding: utf-8 """ The IPython engine application Authors: * Brian Granger * MinRK """ #----------------------------------------------------------------------------- # 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 json import os import sys import time import zmq from zmq.eventloop import ioloop from IPython.core.profiledir import ProfileDir from IPython.parallel.apps.baseapp import ( BaseParallelApplication, base_aliases, base_flags, catch_config_error, ) from IPython.kernel.zmq.log import EnginePUBHandler from IPython.kernel.zmq.ipkernel import IPythonKernel as Kernel from IPython.kernel.zmq.kernelapp import IPKernelApp from IPython.kernel.zmq.session import ( Session, session_aliases, session_flags ) from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell from IPython.config.configurable import Configurable from IPython.parallel.engine.engine import EngineFactory from IPython.parallel.util import disambiguate_ip_address from IPython.utils.importstring import import_item from IPython.utils.py3compat import cast_bytes from IPython.utils.traitlets import Bool, Unicode, Dict, List, Float, Instance #----------------------------------------------------------------------------- # Module level variables #----------------------------------------------------------------------------- _description = """Start an IPython engine for parallel computing. IPython engines run in parallel and perform computations on behalf of a client and controller. A controller needs to be started before the engines. The engine can be configured using command line options or using a cluster directory. Cluster directories contain config, log and security files and are usually located in your ipython directory and named as "profile_name". See the `profile` and `profile-dir` options for details. """ _examples = """ ipengine --ip=192.168.0.1 --port=1000 # connect to hub at ip and port ipengine --log-to-file --log-level=DEBUG # log to a file with DEBUG verbosity """ #----------------------------------------------------------------------------- # MPI configuration #----------------------------------------------------------------------------- mpi4py_init = """from mpi4py import MPI as mpi mpi.size = mpi.COMM_WORLD.Get_size() mpi.rank = mpi.COMM_WORLD.Get_rank() """ pytrilinos_init = """from PyTrilinos import Epetra class SimpleStruct: pass mpi = SimpleStruct() mpi.rank = 0 mpi.size = 0 """ class MPI(Configurable): """Configurable for MPI initialization""" use = Unicode('', config=True, help='How to enable MPI (mpi4py, pytrilinos, or empty string to disable).' ) def _use_changed(self, name, old, new): # load default init script if it's not set if not self.init_script: self.init_script = self.default_inits.get(new, '') init_script = Unicode('', config=True, help="Initialization code for MPI") default_inits = Dict({'mpi4py' : mpi4py_init, 'pytrilinos':pytrilinos_init}, config=True) #----------------------------------------------------------------------------- # Main application #----------------------------------------------------------------------------- aliases = dict( file = 'IPEngineApp.url_file', c = 'IPEngineApp.startup_command', s = 'IPEngineApp.startup_script', url = 'EngineFactory.url', ssh = 'EngineFactory.sshserver', sshkey = 'EngineFactory.sshkey', ip = 'EngineFactory.ip', transport = 'EngineFactory.transport', port = 'EngineFactory.regport', location = 'EngineFactory.location', timeout = 'EngineFactory.timeout', mpi = 'MPI.use', ) aliases.update(base_aliases) aliases.update(session_aliases) flags = {} flags.update(base_flags) flags.update(session_flags) class IPEngineApp(BaseParallelApplication): name = 'ipengine' description = _description examples = _examples classes = List([ZMQInteractiveShell, ProfileDir, Session, EngineFactory, Kernel, MPI]) startup_script = Unicode(u'', config=True, help='specify a script to be run at startup') startup_command = Unicode('', config=True, help='specify a command to be run at startup') url_file = Unicode(u'', config=True, help="""The full location of the file containing the connection information for the controller. If this is not given, the file must be in the security directory of the cluster directory. This location is resolved using the `profile` or `profile_dir` options.""", ) wait_for_url_file = Float(5, config=True, help="""The maximum number of seconds to wait for url_file to exist. This is useful for batch-systems and shared-filesystems where the controller and engine are started at the same time and it may take a moment for the controller to write the connector files.""") url_file_name = Unicode(u'ipcontroller-engine.json', config=True) def _cluster_id_changed(self, name, old, new): if new: base = 'ipcontroller-%s' % new else: base = 'ipcontroller' self.url_file_name = "%s-engine.json" % base log_url = Unicode('', config=True, help="""The URL for the iploggerapp instance, for forwarding logging to a central location.""") # an IPKernelApp instance, used to setup listening for shell frontends kernel_app = Instance(IPKernelApp) aliases = Dict(aliases) flags = Dict(flags) @property def kernel(self): """allow access to the Kernel object, so I look like IPKernelApp""" return self.engine.kernel def find_url_file(self): """Set the url file. Here we don't try to actually see if it exists for is valid as that is hadled by the connection logic. """ config = self.config # Find the actual controller key file if not self.url_file: self.url_file = os.path.join( self.profile_dir.security_dir, self.url_file_name ) def load_connector_file(self): """load config from a JSON connector file, at a *lower* priority than command-line/config files. """ self.log.info("Loading url_file %r", self.url_file) config = self.config with open(self.url_file) as f: num_tries = 0 max_tries = 5 d = "" while not d: try: d = json.loads(f.read()) except ValueError: if num_tries > max_tries: raise num_tries += 1 time.sleep(0.5) # allow hand-override of location for disambiguation # and ssh-server if 'EngineFactory.location' not in config: config.EngineFactory.location = d['location'] if 'EngineFactory.sshserver' not in config: config.EngineFactory.sshserver = d.get('ssh') location = config.EngineFactory.location proto, ip = d['interface'].split('://') ip = disambiguate_ip_address(ip, location) d['interface'] = '%s://%s' % (proto, ip) # DO NOT allow override of basic URLs, serialization, or key # JSON file takes top priority there config.Session.key = cast_bytes(d['key']) config.Session.signature_scheme = d['signature_scheme'] config.EngineFactory.url = d['interface'] + ':%i' % d['registration'] config.Session.packer = d['pack'] config.Session.unpacker = d['unpack'] self.log.debug("Config changed:") self.log.debug("%r", config) self.connection_info = d def bind_kernel(self, **kwargs): """Promote engine to listening kernel, accessible to frontends.""" if self.kernel_app is not None: return self.log.info("Opening ports for direct connections as an IPython kernel") kernel = self.kernel kwargs.setdefault('config', self.config) kwargs.setdefault('log', self.log) kwargs.setdefault('profile_dir', self.profile_dir) kwargs.setdefault('session', self.engine.session) app = self.kernel_app = IPKernelApp(**kwargs) # allow IPKernelApp.instance(): IPKernelApp._instance = app app.init_connection_file() # relevant contents of init_sockets: app.shell_port = app._bind_socket(kernel.shell_streams[0], app.shell_port) app.log.debug("shell ROUTER Channel on port: %i", app.shell_port) app.iopub_port = app._bind_socket(kernel.iopub_socket, app.iopub_port) app.log.debug("iopub PUB Channel on port: %i", app.iopub_port) kernel.stdin_socket = self.engine.context.socket(zmq.ROUTER) app.stdin_port = app._bind_socket(kernel.stdin_socket, app.stdin_port) app.log.debug("stdin ROUTER Channel on port: %i", app.stdin_port) # start the heartbeat, and log connection info: app.init_heartbeat() app.log_connection_info() app.write_connection_file() def init_engine(self): # This is the working dir by now. sys.path.insert(0, '') config = self.config # print config self.find_url_file() # was the url manually specified? keys = set(self.config.EngineFactory.keys()) keys = keys.union(set(self.config.RegistrationFactory.keys())) if keys.intersection(set(['ip', 'url', 'port'])): # Connection info was specified, don't wait for the file url_specified = True self.wait_for_url_file = 0 else: url_specified = False if self.wait_for_url_file and not os.path.exists(self.url_file): self.log.warn("url_file %r not found", self.url_file) self.log.warn("Waiting up to %.1f seconds for it to arrive.", self.wait_for_url_file) tic = time.time() while not os.path.exists(self.url_file) and (time.time()-tic < self.wait_for_url_file): # wait for url_file to exist, or until time limit time.sleep(0.1) if os.path.exists(self.url_file): self.load_connector_file() elif not url_specified: self.log.fatal("Fatal: url file never arrived: %s", self.url_file) self.exit(1) exec_lines = [] for app in ('IPKernelApp', 'InteractiveShellApp'): if '%s.exec_lines' % app in config: exec_lines = config[app].exec_lines break exec_files = [] for app in ('IPKernelApp', 'InteractiveShellApp'): if '%s.exec_files' % app in config: exec_files = config[app].exec_files break config.IPKernelApp.exec_lines = exec_lines config.IPKernelApp.exec_files = exec_files if self.startup_script: exec_files.append(self.startup_script) if self.startup_command: exec_lines.append(self.startup_command) # Create the underlying shell class and Engine # shell_class = import_item(self.master_config.Global.shell_class) # print self.config try: self.engine = EngineFactory(config=config, log=self.log, connection_info=self.connection_info, ) except: self.log.error("Couldn't start the Engine", exc_info=True) self.exit(1) def forward_logging(self): if self.log_url: self.log.info("Forwarding logging to %s", self.log_url) context = self.engine.context lsock = context.socket(zmq.PUB) lsock.connect(self.log_url) handler = EnginePUBHandler(self.engine, lsock) handler.setLevel(self.log_level) self.log.addHandler(handler) def init_mpi(self): global mpi self.mpi = MPI(parent=self) mpi_import_statement = self.mpi.init_script if mpi_import_statement: try: self.log.info("Initializing MPI:") self.log.info(mpi_import_statement) exec(mpi_import_statement, globals()) except: mpi = None else: mpi = None @catch_config_error def initialize(self, argv=None): super(IPEngineApp, self).initialize(argv) self.init_mpi() self.init_engine() self.forward_logging() def start(self): self.engine.start() try: self.engine.loop.start() except KeyboardInterrupt: self.log.critical("Engine Interrupted, shutting down...\n") launch_new_instance = IPEngineApp.launch_instance if __name__ == '__main__': launch_new_instance()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 624, 199, 1918, 16243, 6869, 4223, 199, 199, 2817, 1384, 26, 199, 199, 10, 699, 18429, 598, 82, 12974, 199, 10, 10195, 50, 43, 199, 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, 2022, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 199, 646, 26633, 199, 504, 26633, 14, 1430, 3813, 492, 5890, 3813, 199, 199, 504, 16243, 14, 1018, 14, 2913, 694, 492, 14386, 3567, 199, 504, 16243, 14, 11887, 14, 5181, 14, 1095, 571, 492, 334, 272, 3523, 25721, 5039, 12, 272, 1300, 63, 8602, 12, 272, 1300, 63, 2469, 12, 272, 8579, 63, 888, 63, 705, 12, 199, 9, 199, 504, 16243, 14, 4989, 14, 21290, 14, 793, 492, 12580, 13047, 2461, 199, 504, 16243, 14, 4989, 14, 21290, 14, 711, 4989, 492, 16243, 14127, 465, 24901, 199, 504, 16243, 14, 4989, 14, 21290, 14, 4989, 571, 492, 3531, 14127, 2640, 199, 504, 16243, 14, 4989, 14, 21290, 14, 1730, 492, 334, 272, 8596, 12, 2351, 63, 8602, 12, 2351, 63, 2469, 199, 9, 199, 504, 16243, 14, 4989, 14, 21290, 14, 21290, 5641, 492, 3107, 14449, 23879, 8529, 199, 199, 504, 16243, 14, 888, 14, 888, 15684, 492, 4094, 15684, 199, 199, 504, 16243, 14, 11887, 14, 3908, 14, 3908, 492, 12580, 2927, 199, 504, 16243, 14, 11887, 14, 1974, 492, 2153, 16902, 4767, 63, 711, 63, 1562, 199, 199, 504, 16243, 14, 1208, 14, 646, 875, 492, 492, 63, 1053, 199, 504, 16243, 14, 1208, 14, 647, 19, 5819, 492, 9106, 63, 2394, 199, 504, 16243, 14, 1208, 14, 1239, 5776, 1086, 492, 19287, 12, 6140, 12, 7448, 12, 3820, 12, 11140, 12, 10066, 421, 199, 18045, 199, 3, 5673, 2166, 2860, 199, 18045, 199, 199, 63, 1802, 275, 408, 3162, 376, 16243, 6869, 367, 9861, 17226, 14, 199, 199, 1772, 11361, 28156, 1255, 315, 9861, 436, 5147, 28319, 1298, 641, 506, 10220, 402, 282, 1890, 199, 460, 7614, 14, 437, 7614, 4839, 370, 506, 8239, 2544, 314, 28156, 14, 710, 199, 3908, 883, 506, 7526, 1808, 1414, 1004, 1511, 503, 1808, 282, 4350, 199, 3619, 14, 16454, 6602, 1395, 1101, 12, 943, 436, 6391, 1584, 436, 787, 199, 25118, 16180, 315, 2195, 284, 1548, 2082, 436, 4310, 465, 298, 2913, 63, 354, 1674, 199, 9295, 314, 658, 2913, 64, 436, 658, 2913, 13, 694, 64, 1511, 367, 2436, 14, 199, 624, 199, 199, 63, 8589, 275, 408, 199, 711, 3908, 1553, 711, 29, 5756, 14, 6568, 14, 16, 14, 17, 1553, 719, 29, 5279, 258, 327, 4907, 370, 26726, 737, 3384, 436, 1844, 199, 711, 3908, 1553, 793, 13, 475, 13, 493, 1553, 793, 13, 1896, 29, 5287, 221, 327, 943, 370, 282, 570, 543, 10990, 8661, 199, 624, 199, 199, 18045, 199, 3, 26024, 2897, 199, 18045, 199, 199, 13213, 20, 647, 63, 826, 275, 408, 504, 26806, 20, 647, 492, 26024, 465, 26806, 199, 13213, 14, 890, 275, 26806, 14, 5378, 63, 22125, 14, 1002, 63, 890, 342, 199, 13213, 14, 4648, 275, 26806, 14, 5378, 63, 22125, 14, 1002, 63, 4648, 342, 199, 624, 421, 199, 647, 599, 472, 736, 63, 826, 275, 408, 504, 1611, 6948, 472, 736, 492, 662, 321, 1239, 199, 533, 5870, 4836, 26, 199, 1529, 199, 13213, 275, 5870, 4836, 342, 199, 13213, 14, 4648, 275, 378, 199, 13213, 14, 890, 275, 378, 199, 624, 199, 199, 533, 26024, 8, 2028, 15684, 304, 272, 408, 2028, 15684, 367, 26024, 11097, 624, 272, 675, 275, 6140, 8594, 1101, 29, 549, 12, 267, 1720, 534, 18335, 370, 4756, 26024, 334, 13213, 20, 647, 12, 1134, 599, 472, 736, 12, 503, 2701, 1059, 370, 3507, 28823, 267, 776, 339, 347, 485, 1180, 63, 2489, 8, 277, 12, 536, 12, 2269, 12, 892, 304, 267, 327, 2248, 849, 4205, 2884, 340, 652, 1159, 440, 663, 267, 340, 440, 291, 14, 826, 63, 1579, 26, 288, 291, 14, 826, 63, 1579, 275, 291, 14, 885, 63, 826, 83, 14, 362, 8, 1222, 12, 4074, 339, 4205, 63, 1579, 275, 6140, 8594, 1101, 29, 549, 12, 267, 1720, 628, 5733, 2072, 1233, 367, 26024, 531, 339, 849, 63, 826, 83, 275, 7448, 3252, 13213, 20, 647, 7, 520, 26806, 20, 647, 63, 826, 12, 283, 647, 599, 472, 736, 356, 647, 599, 472, 736, 63, 826, 1386, 267, 1101, 29, 549, 9, 421, 199, 18045, 199, 3, 11298, 4223, 199, 18045, 199, 8602, 275, 1211, 8, 272, 570, 275, 283, 1772, 8524, 2640, 14, 633, 63, 493, 297, 272, 286, 275, 283, 1772, 8524, 2640, 14, 16480, 63, 1531, 297, 272, 308, 275, 283, 1772, 8524, 2640, 14, 16480, 63, 1579, 297, 339, 1166, 275, 283, 8524, 2927, 14, 633, 297, 272, 8635, 275, 283, 8524, 2927, 14, 5510, 1000, 297, 272, 8635, 498, 275, 283, 8524, 2927, 14, 5510, 498, 297, 272, 3384, 275, 283, 8524, 2927, 14, 711, 297, 272, 7773, 275, 283, 8524, 2927, 14, 5545, 297, 272, 1844, 275, 283, 8524, 2927, 14, 1135, 719, 297, 272, 2909, 275, 283, 8524, 2927, 14, 1985, 297, 339, 2653, 275, 283, 8524, 2927, 14, 2593, 297, 339, 26806, 275, 283, 28983, 14, 1180, 297, 199, 199, 9, 199, 8602, 14, 873, 8, 1095, 63, 8602, 9, 199, 8602, 14, 873, 8, 1730, 63, 8602, 9, 199, 2469, 275, 1052, 199, 2469, 14, 873, 8, 1095, 63, 2469, 9, 199, 2469, 14, 873, 8, 1730, 63, 2469, 9, 199, 199, 533, 3531, 8524, 2640, 8, 1563, 25721, 5039, 304, 339, 536, 275, 283, 711, 3908, 7, 272, 1369, 275, 485, 1802, 272, 7251, 275, 485, 8589, 272, 3992, 275, 3820, 779, 58, 14449, 23879, 8529, 12, 14386, 3567, 12, 8596, 12, 12580, 2927, 12, 24901, 12, 26024, 566, 339, 14210, 63, 1579, 275, 6140, 8, 85, 6448, 1101, 29 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 624, 199, 1918, 16243, 6869, 4223, 199, 199, 2817, 1384, 26, 199, 199, 10, 699, 18429, 598, 82, 12974, 199, 10, 10195, 50, 43, 199, 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, 2022, 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 199, 646, 26633, 199, 504, 26633, 14, 1430, 3813, 492, 5890, 3813, 199, 199, 504, 16243, 14, 1018, 14, 2913, 694, 492, 14386, 3567, 199, 504, 16243, 14, 11887, 14, 5181, 14, 1095, 571, 492, 334, 272, 3523, 25721, 5039, 12, 272, 1300, 63, 8602, 12, 272, 1300, 63, 2469, 12, 272, 8579, 63, 888, 63, 705, 12, 199, 9, 199, 504, 16243, 14, 4989, 14, 21290, 14, 793, 492, 12580, 13047, 2461, 199, 504, 16243, 14, 4989, 14, 21290, 14, 711, 4989, 492, 16243, 14127, 465, 24901, 199, 504, 16243, 14, 4989, 14, 21290, 14, 4989, 571, 492, 3531, 14127, 2640, 199, 504, 16243, 14, 4989, 14, 21290, 14, 1730, 492, 334, 272, 8596, 12, 2351, 63, 8602, 12, 2351, 63, 2469, 199, 9, 199, 504, 16243, 14, 4989, 14, 21290, 14, 21290, 5641, 492, 3107, 14449, 23879, 8529, 199, 199, 504, 16243, 14, 888, 14, 888, 15684, 492, 4094, 15684, 199, 199, 504, 16243, 14, 11887, 14, 3908, 14, 3908, 492, 12580, 2927, 199, 504, 16243, 14, 11887, 14, 1974, 492, 2153, 16902, 4767, 63, 711, 63, 1562, 199, 199, 504, 16243, 14, 1208, 14, 646, 875, 492, 492, 63, 1053, 199, 504, 16243, 14, 1208, 14, 647, 19, 5819, 492, 9106, 63, 2394, 199, 504, 16243, 14, 1208, 14, 1239, 5776, 1086, 492, 19287, 12, 6140, 12, 7448, 12, 3820, 12, 11140, 12, 10066, 421, 199, 18045, 199, 3, 5673, 2166, 2860, 199, 18045, 199, 199, 63, 1802, 275, 408, 3162, 376, 16243, 6869, 367, 9861, 17226, 14, 199, 199, 1772, 11361, 28156, 1255, 315, 9861, 436, 5147, 28319, 1298, 641, 506, 10220, 402, 282, 1890, 199, 460, 7614, 14, 437, 7614, 4839, 370, 506, 8239, 2544, 314, 28156, 14, 710, 199, 3908, 883, 506, 7526, 1808, 1414, 1004, 1511, 503, 1808, 282, 4350, 199, 3619, 14, 16454, 6602, 1395, 1101, 12, 943, 436, 6391, 1584, 436, 787, 199, 25118, 16180, 315, 2195, 284, 1548, 2082, 436, 4310, 465, 298, 2913, 63, 354, 1674, 199, 9295, 314, 658, 2913, 64, 436, 658, 2913, 13, 694, 64, 1511, 367, 2436, 14, 199, 624, 199, 199, 63, 8589, 275, 408, 199, 711, 3908, 1553, 711, 29, 5756, 14, 6568, 14, 16, 14, 17, 1553, 719, 29, 5279, 258, 327, 4907, 370, 26726, 737, 3384, 436, 1844, 199, 711, 3908, 1553, 793, 13, 475, 13, 493, 1553, 793, 13, 1896, 29, 5287, 221, 327, 943, 370, 282, 570, 543, 10990, 8661, 199, 624, 199, 199, 18045, 199, 3, 26024, 2897, 199, 18045, 199, 199, 13213, 20, 647, 63, 826, 275, 408, 504, 26806, 20, 647, 492, 26024, 465, 26806, 199, 13213, 14, 890, 275, 26806, 14, 5378, 63, 22125, 14, 1002, 63, 890, 342, 199, 13213, 14, 4648, 275, 26806, 14, 5378, 63, 22125, 14, 1002, 63, 4648, 342, 199, 624, 421, 199, 647, 599, 472, 736, 63, 826, 275, 408, 504, 1611, 6948, 472, 736, 492, 662, 321, 1239, 199, 533, 5870, 4836, 26, 199, 1529, 199, 13213, 275, 5870, 4836, 342, 199, 13213, 14, 4648, 275, 378, 199, 13213, 14, 890, 275, 378, 199, 624, 199, 199, 533, 26024, 8, 2028, 15684, 304, 272, 408, 2028, 15684, 367, 26024, 11097, 624, 272, 675, 275, 6140, 8594, 1101, 29, 549, 12, 267, 1720, 534, 18335, 370, 4756, 26024, 334, 13213, 20, 647, 12, 1134, 599, 472, 736, 12, 503, 2701, 1059, 370, 3507, 28823, 267, 776, 339, 347, 485, 1180, 63, 2489, 8, 277, 12, 536, 12, 2269, 12, 892, 304, 267, 327, 2248, 849, 4205, 2884, 340, 652, 1159, 440, 663, 267, 340, 440, 291, 14, 826, 63, 1579, 26, 288, 291, 14, 826, 63, 1579, 275, 291, 14, 885, 63, 826, 83, 14, 362, 8, 1222, 12, 4074, 339, 4205, 63, 1579, 275, 6140, 8594, 1101, 29, 549, 12, 267, 1720, 628, 5733, 2072, 1233, 367, 26024, 531, 339, 849, 63, 826, 83, 275, 7448, 3252, 13213, 20, 647, 7, 520, 26806, 20, 647, 63, 826, 12, 283, 647, 599, 472, 736, 356, 647, 599, 472, 736, 63, 826, 1386, 267, 1101, 29, 549, 9, 421, 199, 18045, 199, 3, 11298, 4223, 199, 18045, 199, 8602, 275, 1211, 8, 272, 570, 275, 283, 1772, 8524, 2640, 14, 633, 63, 493, 297, 272, 286, 275, 283, 1772, 8524, 2640, 14, 16480, 63, 1531, 297, 272, 308, 275, 283, 1772, 8524, 2640, 14, 16480, 63, 1579, 297, 339, 1166, 275, 283, 8524, 2927, 14, 633, 297, 272, 8635, 275, 283, 8524, 2927, 14, 5510, 1000, 297, 272, 8635, 498, 275, 283, 8524, 2927, 14, 5510, 498, 297, 272, 3384, 275, 283, 8524, 2927, 14, 711, 297, 272, 7773, 275, 283, 8524, 2927, 14, 5545, 297, 272, 1844, 275, 283, 8524, 2927, 14, 1135, 719, 297, 272, 2909, 275, 283, 8524, 2927, 14, 1985, 297, 339, 2653, 275, 283, 8524, 2927, 14, 2593, 297, 339, 26806, 275, 283, 28983, 14, 1180, 297, 199, 199, 9, 199, 8602, 14, 873, 8, 1095, 63, 8602, 9, 199, 8602, 14, 873, 8, 1730, 63, 8602, 9, 199, 2469, 275, 1052, 199, 2469, 14, 873, 8, 1095, 63, 2469, 9, 199, 2469, 14, 873, 8, 1730, 63, 2469, 9, 199, 199, 533, 3531, 8524, 2640, 8, 1563, 25721, 5039, 304, 339, 536, 275, 283, 711, 3908, 7, 272, 1369, 275, 485, 1802, 272, 7251, 275, 485, 8589, 272, 3992, 275, 3820, 779, 58, 14449, 23879, 8529, 12, 14386, 3567, 12, 8596, 12, 12580, 2927, 12, 24901, 12, 26024, 566, 339, 14210, 63, 1579, 275, 6140, 8, 85, 6448, 1101, 29, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
calio/cflow2dot
cflow2dot.py
1
9602
#!/usr/bin/env python import os.path import sys import subprocess import re import argparse import json from sys import exit from os import system cflow_path = "/usr/local/bin/cflow" dot_path = "/usr/local/bin/dot" color = ["#eecc80", "#ccee80", "#80ccee", "#eecc80", "#80eecc"]; shape =["box", "ellipse", "octagon", "hexagon", "diamond"]; shape_len = len(shape) pref = "cflow" exts = ["svg", "png"] index = {} count = {} stdlib = [ "assert", "isalnum", "isalpha", "iscntrl", "isdigit", "isgraph", "islower", "isprint", "ispunct", "isspace", "isupper", "isxdigit", "toupper", "tolower", "errno", "setlocale", "acos", "asin", "atan", "atan2", "ceil", "cos", "cosh", "exp", "fabs", "floor", "fmod", "frexp", "ldexp", "log", "log10", "modf", "pow", "sin", "sinh", "sqrt", "tan", "tanh", "stdlib.h", "setjmp", "longjmp", "signal", "raise", "clearerr", "fclose", "feof", "fflush", "fgetc", "fgetpos", "fgets", "fopen", "fprintf", "fputc", "fputs", "fread", "freopen", "fscanf", "fseek", "fsetpos", "ftell", "fwrite", "getc", "getchar", "gets", "perror", "printf", "putchar", "puts", "remove", "rewind", "scanf", "setbuf", "setvbuf", "sprintf", "sscanf", "tmpfile", "tmpnam", "ungetc", "vfprintf", "vprintf", "vsprintf", "abort", "abs", "atexit", "atof", "atoi", "atol", "bsearch", "calloc", "div", "exit", "getenv", "free", "labs", "ldiv", "malloc", "mblen", "mbstowcs", "mbtowc", "qsort", "rand", "realloc", "strtod", "strtol", "strtoul", "srand", "system", "wctomb", "wcstombs", "memchr", "memcmp", "memcpy", "memmove", "memset", "strcat", "strchr", "strcmp", "strcoll", "strcpy", "strcspn", "strerror", "strlen", "strncat", "strncmp", "strncpy", "strpbrk", "strrchr", "strspn", "strstr", "strtok", "strxfrm", "asctime", "clock", "ctime", "difftime", "gmtime", "localtime", "mktime", "strftime", "time","vsnprintf"] pthreadlib = [ "pthread_atfork", "pthread_attr_destroy", "pthread_attr_getdetachstate", "pthread_attr_getguardsize", "pthread_attr_getinheritsched", "pthread_attr_getschedparam", "pthread_attr_getschedpolicy", "pthread_attr_getscope", "pthread_attr_getstack", "pthread_attr_getstackaddr", "pthread_attr_getstacksize", "pthread_attr_init", "pthread_attr_setdetachstate", "pthread_attr_setguardsize", "pthread_attr_setinheritsched", "pthread_attr_setschedparam", "pthread_attr_setschedpolicy", "pthread_attr_setscope", "pthread_attr_setstack", "pthread_attr_setstackaddr", "pthread_attr_setstacksize", "pthread_barrier_destroy", "pthread_barrier_init", "pthread_barrier_wait", "pthread_barrierattr_destroy", "pthread_barrierattr_getpshared", "pthread_barrierattr_init", "pthread_barrierattr_setpshared", "pthread_cancel", "pthread_cleanup_pop", "pthread_cleanup_push", "pthread_cond_broadcast", "pthread_cond_destroy", "pthread_cond_init", "pthread_cond_signal", "pthread_cond_timedwait", "pthread_cond_wait", "pthread_condattr_destroy", "pthread_condattr_getclock", "pthread_condattr_getpshared", "pthread_condattr_init", "pthread_condattr_setclock", "pthread_condattr_setpshared", "pthread_create", "pthread_detach", "pthread_equal", "pthread_exit", "pthread_getconcurrency", "pthread_getcpuclockid", "pthread_getschedparam", "pthread_getspecific", "pthread_join", "pthread_key_create", "pthread_key_delete", "pthread_kill", "pthread_mutex_destroy", "pthread_mutex_getprioceiling", "pthread_mutex_init", "pthread_mutex_lock", "pthread_mutex_setprioceiling", "pthread_mutex_timedlock", "pthread_mutex_trylock", "pthread_mutex_unlock", "pthread_mutexattr_destroy", "pthread_mutexattr_getprioceiling", "pthread_mutexattr_getprotocol", "pthread_mutexattr_getpshared", "pthread_mutexattr_gettype", "pthread_mutexattr_init", "pthread_mutexattr_setprioceiling", "pthread_mutexattr_setprotocol", "pthread_mutexattr_setpshared", "pthread_mutexattr_settype", "pthread_once", "pthread_rwlock_destroy", "pthread_rwlock_init", "pthread_rwlock_rdlock", "pthread_rwlock_timedrdlock", "pthread_rwlock_timedwrlock", "pthread_rwlock_tryrdlock", "pthread_rwlock_trywrlock", "pthread_rwlock_unlock", "pthread_rwlock_wrlock", "pthread_rwlockattr_destroy", "pthread_rwlockattr_getpshared", "pthread_rwlockattr_init", "pthread_rwlockattr_setpshared", "pthread_self", "pthread_setcancelstate", "pthread_setcanceltype", "pthread_setconcurrency", "pthread_setschedparam", "pthread_setschedprio", "pthread_setspecific", "pthread_sigmask", "pthread_spin_destroy", "pthread_spin_init", "pthread_spin_lock", "pthread_spin_trylock", "pthread_spin_unlock", "pthread_testcancel", "pthread_setaffinity_np" ] def get_parser(): ap = argparse.ArgumentParser(description="cflow2dot: generate call graph from C source code") ap.add_argument("-e", "--exclude", metavar="symbols", help="exclude these symbols (comma separated values) from output") ap.add_argument("-m", "--main", metavar="NAME", help="Assume main function to be called NAME") ap.add_argument("-r", "--rank", default="LR", choices=["LR", "same"], help="if rank is \"LR\", graph is left to right. If rank is \"same\", graph is top to bottom. Default value is \"LR\".") ap.add_argument("-v", "--verbose", action="store_true", help="increase verbosity level") ap.add_argument("--no", metavar="NAME", action="append", help="exclude NAME symbol set (configured in ~/.cflowdotrc) from output") ap.add_argument("--no-pthreadlib", action="store_true", help="exclude pthread lib symbols from output") ap.add_argument("--no-stdlib", action="store_true", help="exclude C stdlib symbols from output") ap.add_argument("cflow_args", nargs=argparse.REMAINDER, help="arguments that are passed to cflow") return ap def call_cflow(opts): args = opts.cflow_args args.insert(0, cflow_path) args.insert(1, "-l") if opts.main: args.insert(1, "-m") args.insert(2, opts.main) if opts.verbose: print "calling cflow with args: ", args p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() if stderr and not stdout: exit(stderr) return stdout def build_excludes(opts): res = {} if opts.exclude: exclude_symbols = opts.exclude.split(",") for v in exclude_symbols: res[v] = True if opts.no_stdlib: for v in stdlib: res[v] = True if opts.no_pthreadlib: for v in pthreadlib: res[v] = True if opts.no: rcfile = os.path.expanduser("~") + "/.cflow2dotrc" print(rcfile) if not os.path.isfile(rcfile): print("no ~/.cflow2dotrc file found, --no argument is skipped") return res else: fp = open(rcfile) rcdata = json.load(fp) for exclude_set in opts.no: if rcdata.get(exclude_set): for func_name in rcdata[exclude_set]: res[func_name] = True else: print("no key \"" + exclude_set + "\" specified in " + rcfile) fp.close() return res def get_output(opts, res): output = [] skip = False exclude_index = -1 lines = res.split('\n') verbose = opts.verbose exclude = build_excludes(opts) for line in lines: if line == '': continue line = re.sub("\(.*$", "", line) line = re.sub("^\{\s*", "", line) line = re.sub("\}\s*", "\t", line) parts = line.split("\t") # indent level n = parts[0] # function name of callee f = parts[1] index[n] = f # test if callee is in exclude list if skip: # exclude all sub function calls from the excluded function. If we # get another callee at the same indent level, then stop skipping if int(n) > int(exclude_index): if verbose: print("exclude sub function: " + f) continue else: skip = False exclude_index = -1 if f in exclude: skip = True exclude_index = n if verbose: print("exclude function: " + f) continue if n != '0': s = "%s->%s" % (index[str(int(n) - 1)], f) if s not in count: output.append("node [color=\"{0}\" shape={1}];edge [color=\"{2}\"];\n{3}\n".format(color[int(n) % shape_len], shape[int(n) % shape_len], color[int(n) % shape_len], s)) count[s] = True else: output.append("%s [shape=box];\n" % f) output.insert(0, "digraph G {\nnode [peripheries=2 style=\"filled,rounded\" fontname=\"Vera Sans YuanTi Mono\" color=\"%s\"];\nrankdir=%s;\nlabel=\"%s\"\n" % (color[0], opts.rank, opts.cflow_args[2])) output.append("}\n") return output def write_output(output): f = open(pref + ".dot", "w") f.write(''.join(output)) f.close() print("dot output to %s.dot" % pref) if os.path.isfile(dot_path): for ext in exts: system("dot -T%s %s.dot -o %s.%s" % (ext, pref, pref, ext)) print("%s output to %s.%s" % (ext, pref, ext)) else: print("'dot(GraphViz)' not installed.") if __name__ == '__main__': ap = get_parser() opts = ap.parse_args() if not os.path.isfile(cflow_path): exit('cflow not found on: %s' % cflow_path) res = call_cflow(opts) output = get_output(opts, res) write_output(output)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 14, 515, 199, 646, 984, 199, 646, 3873, 199, 646, 295, 199, 646, 7534, 199, 646, 2022, 199, 199, 504, 984, 492, 4458, 199, 504, 747, 492, 2656, 199, 199, 67, 1659, 63, 515, 275, 3286, 2647, 15, 1832, 15, 1393, 15, 67, 1659, 2, 199, 3287, 63, 515, 275, 3286, 2647, 15, 1832, 15, 1393, 15, 3287, 2, 199, 2326, 275, 2097, 3, 69, 825, 67, 1257, 401, 5426, 67, 29377, 1257, 401, 5426, 1257, 67, 29377, 401, 5426, 69, 825, 67, 1257, 401, 5426, 1257, 69, 825, 67, 937, 27, 199, 1392, 275, 905, 1977, 401, 298, 16514, 261, 401, 298, 15560, 643, 265, 401, 298, 4097, 643, 265, 401, 298, 328, 24940, 937, 27, 199, 1392, 63, 552, 275, 822, 8, 1392, 9, 199, 13829, 275, 298, 67, 1659, 2, 199, 25752, 275, 2097, 10273, 401, 298, 4524, 937, 199, 1080, 275, 1052, 199, 835, 275, 1052, 199, 199, 28683, 275, 359, 199, 2, 479, 401, 298, 28235, 1507, 401, 298, 374, 4468, 401, 298, 374, 6507, 4308, 401, 298, 13896, 401, 298, 374, 2180, 401, 298, 374, 2325, 401, 199, 2, 374, 1361, 401, 298, 374, 27003, 401, 298, 23360, 401, 298, 374, 4142, 401, 298, 374, 88, 8573, 401, 298, 475, 4142, 401, 298, 475, 2325, 401, 199, 2, 7931, 401, 298, 409, 5508, 401, 298, 65, 5197, 401, 298, 24202, 401, 298, 16080, 401, 298, 16080, 18, 401, 298, 14085, 401, 298, 5197, 401, 298, 15106, 401, 199, 2, 1474, 401, 298, 70, 2101, 401, 298, 11289, 401, 298, 70, 1494, 401, 298, 20153, 9290, 401, 298, 76, 31450, 401, 298, 793, 401, 298, 793, 709, 401, 298, 1494, 70, 401, 199, 2, 8278, 401, 298, 5911, 401, 298, 15831, 401, 298, 5079, 401, 298, 12990, 401, 298, 21468, 401, 298, 28683, 14, 72, 401, 298, 409, 74, 311, 401, 298, 2809, 74, 311, 401, 199, 2, 4653, 401, 298, 3730, 401, 298, 2265, 1530, 9734, 401, 298, 70, 1600, 401, 298, 771, 1618, 401, 298, 556, 76, 2084, 401, 298, 27823, 67, 401, 298, 27823, 1712, 401, 199, 2, 70, 24894, 401, 298, 70, 1490, 401, 298, 70, 19139, 401, 298, 70, 524, 67, 401, 298, 70, 524, 83, 401, 298, 70, 739, 401, 298, 20153, 1490, 401, 298, 70, 6282, 70, 401, 199, 2, 70, 5507, 401, 298, 70, 409, 1712, 401, 298, 70, 9974, 401, 298, 70, 952, 401, 298, 362, 67, 401, 298, 362, 1560, 401, 298, 24894, 401, 298, 529, 451, 401, 199, 2, 19139, 401, 298, 524, 1560, 401, 298, 524, 83, 401, 298, 2168, 401, 298, 5257, 688, 401, 298, 6282, 70, 401, 298, 409, 1436, 401, 298, 409, 86, 1436, 401, 199, 2, 681, 672, 70, 401, 298, 385, 2425, 70, 401, 298, 21930, 401, 298, 2791, 17811, 401, 298, 21912, 67, 401, 298, 19963, 19139, 401, 298, 86, 19139, 401, 199, 2, 86, 681, 672, 70, 401, 298, 13845, 401, 298, 2101, 401, 298, 24026, 390, 401, 298, 292, 1618, 401, 298, 11318, 73, 401, 298, 24504, 401, 298, 66, 1733, 401, 199, 2, 915, 2102, 401, 298, 3015, 401, 298, 2224, 401, 298, 12959, 401, 298, 4624, 401, 298, 76, 2101, 401, 298, 76, 3015, 401, 298, 23981, 401, 298, 887, 552, 401, 199, 2, 887, 270, 583, 1259, 401, 298, 887, 475, 13683, 401, 298, 81, 3191, 401, 298, 3759, 401, 298, 3093, 2102, 401, 298, 495, 5766, 401, 298, 495, 6896, 401, 199, 2, 495, 475, 348, 401, 298, 83, 3759, 401, 298, 2253, 401, 298, 87, 319, 24370, 401, 298, 13683, 270, 676, 1533, 401, 298, 5286, 10194, 401, 298, 5286, 5730, 401, 199, 2, 5286, 25644, 401, 298, 5286, 1185, 401, 298, 5286, 409, 401, 298, 495, 3385, 401, 298, 495, 10194, 401, 298, 495, 5730, 401, 298, 495, 15772, 401, 199, 2, 495, 25644, 401, 298, 495, 30608, 78, 401, 298, 20395, 401, 298, 495, 552, 401, 298, 495, 78, 3385, 401, 298, 495, 78, 5730, 401, 298, 495, 7966, 647, 401, 199, 2, 495, 80, 3289, 75, 401, 298, 495, 82, 10194, 401, 298, 495, 681, 78, 401, 298, 495, 495, 401, 298, 495, 9305, 401, 298, 495, 1949, 5682, 401, 298, 18331, 401, 199, 2, 9597, 401, 298, 20691, 401, 298, 3028, 521, 401, 298, 22227, 401, 298, 15198, 401, 298, 23456, 401, 298, 6205, 401, 199, 2, 521, 2266, 3122, 78, 19139, 937, 199, 199, 27869, 773, 275, 359, 199, 2, 27869, 63, 292, 11796, 401, 298, 27869, 63, 962, 63, 7237, 401, 298, 27869, 63, 962, 63, 362, 14481, 929, 401, 199, 2, 27869, 63, 962, 63, 362, 15606, 890, 401, 298, 27869, 63, 962, 63, 362, 20882, 1809, 401, 199, 2, 27869, 63, 962, 63, 362, 10487, 635, 401, 298, 27869, 63, 962, 63, 362, 10487, 3185, 401, 199, 2, 27869, 63, 962, 63, 362, 2645, 401, 298, 27869, 63, 962, 63, 362, 2340, 401, 298, 27869, 63, 962, 63, 362, 2340, 2697, 401, 199, 2, 27869, 63, 962, 63, 362, 2340, 890, 401, 298, 27869, 63, 962, 63, 826, 401, 199, 2, 27869, 63, 962, 63, 409, 14481, 929, 401, 298, 27869, 63, 962, 63, 409, 15606, 890, 401, 199, 2, 27869, 63, 962, 63, 409, 20882, 1809, 401, 298, 27869, 63, 962, 63, 2193, 1809, 635, 401, 199, 2, 27869, 63, 962, 63, 2193, 1809, 3185, 401, 298, 27869, 63, 962, 63, 2193, 1859, 401, 199, 2, 27869, 63, 962, 63, 409, 2340, 401, 298, 27869, 63, 962, 63, 409, 2340, 2697, 401, 199, 2, 27869, 63, 962, 63, 409, 2340, 890, 401, 298, 27869, 63, 1700, 10742, 63, 7237, 401, 298, 27869, 63, 1700, 10742, 63, 826, 401, 199, 2, 27869, 63, 1700, 10742, 63, 2573, 401, 298, 27869, 63, 1700, 10742, 962, 63, 7237, 401, 199, 2, 27869, 63, 1700, 10742, 962, 63, 362, 80, 5555, 401, 298, 27869, 63, 1700, 10742, 962, 63, 826, 401, 199, 2, 27869, 63, 1700, 10742, 962, 63, 409, 80, 5555, 401, 298, 27869, 63, 6406, 401, 298, 27869, 63, 7661, 63, 1935, 401, 199, 2, 27869, 63, 7661, 63, 5335, 401, 298, 27869, 63, 2067, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 14, 515, 199, 646, 984, 199, 646, 3873, 199, 646, 295, 199, 646, 7534, 199, 646, 2022, 199, 199, 504, 984, 492, 4458, 199, 504, 747, 492, 2656, 199, 199, 67, 1659, 63, 515, 275, 3286, 2647, 15, 1832, 15, 1393, 15, 67, 1659, 2, 199, 3287, 63, 515, 275, 3286, 2647, 15, 1832, 15, 1393, 15, 3287, 2, 199, 2326, 275, 2097, 3, 69, 825, 67, 1257, 401, 5426, 67, 29377, 1257, 401, 5426, 1257, 67, 29377, 401, 5426, 69, 825, 67, 1257, 401, 5426, 1257, 69, 825, 67, 937, 27, 199, 1392, 275, 905, 1977, 401, 298, 16514, 261, 401, 298, 15560, 643, 265, 401, 298, 4097, 643, 265, 401, 298, 328, 24940, 937, 27, 199, 1392, 63, 552, 275, 822, 8, 1392, 9, 199, 13829, 275, 298, 67, 1659, 2, 199, 25752, 275, 2097, 10273, 401, 298, 4524, 937, 199, 1080, 275, 1052, 199, 835, 275, 1052, 199, 199, 28683, 275, 359, 199, 2, 479, 401, 298, 28235, 1507, 401, 298, 374, 4468, 401, 298, 374, 6507, 4308, 401, 298, 13896, 401, 298, 374, 2180, 401, 298, 374, 2325, 401, 199, 2, 374, 1361, 401, 298, 374, 27003, 401, 298, 23360, 401, 298, 374, 4142, 401, 298, 374, 88, 8573, 401, 298, 475, 4142, 401, 298, 475, 2325, 401, 199, 2, 7931, 401, 298, 409, 5508, 401, 298, 65, 5197, 401, 298, 24202, 401, 298, 16080, 401, 298, 16080, 18, 401, 298, 14085, 401, 298, 5197, 401, 298, 15106, 401, 199, 2, 1474, 401, 298, 70, 2101, 401, 298, 11289, 401, 298, 70, 1494, 401, 298, 20153, 9290, 401, 298, 76, 31450, 401, 298, 793, 401, 298, 793, 709, 401, 298, 1494, 70, 401, 199, 2, 8278, 401, 298, 5911, 401, 298, 15831, 401, 298, 5079, 401, 298, 12990, 401, 298, 21468, 401, 298, 28683, 14, 72, 401, 298, 409, 74, 311, 401, 298, 2809, 74, 311, 401, 199, 2, 4653, 401, 298, 3730, 401, 298, 2265, 1530, 9734, 401, 298, 70, 1600, 401, 298, 771, 1618, 401, 298, 556, 76, 2084, 401, 298, 27823, 67, 401, 298, 27823, 1712, 401, 199, 2, 70, 24894, 401, 298, 70, 1490, 401, 298, 70, 19139, 401, 298, 70, 524, 67, 401, 298, 70, 524, 83, 401, 298, 70, 739, 401, 298, 20153, 1490, 401, 298, 70, 6282, 70, 401, 199, 2, 70, 5507, 401, 298, 70, 409, 1712, 401, 298, 70, 9974, 401, 298, 70, 952, 401, 298, 362, 67, 401, 298, 362, 1560, 401, 298, 24894, 401, 298, 529, 451, 401, 199, 2, 19139, 401, 298, 524, 1560, 401, 298, 524, 83, 401, 298, 2168, 401, 298, 5257, 688, 401, 298, 6282, 70, 401, 298, 409, 1436, 401, 298, 409, 86, 1436, 401, 199, 2, 681, 672, 70, 401, 298, 385, 2425, 70, 401, 298, 21930, 401, 298, 2791, 17811, 401, 298, 21912, 67, 401, 298, 19963, 19139, 401, 298, 86, 19139, 401, 199, 2, 86, 681, 672, 70, 401, 298, 13845, 401, 298, 2101, 401, 298, 24026, 390, 401, 298, 292, 1618, 401, 298, 11318, 73, 401, 298, 24504, 401, 298, 66, 1733, 401, 199, 2, 915, 2102, 401, 298, 3015, 401, 298, 2224, 401, 298, 12959, 401, 298, 4624, 401, 298, 76, 2101, 401, 298, 76, 3015, 401, 298, 23981, 401, 298, 887, 552, 401, 199, 2, 887, 270, 583, 1259, 401, 298, 887, 475, 13683, 401, 298, 81, 3191, 401, 298, 3759, 401, 298, 3093, 2102, 401, 298, 495, 5766, 401, 298, 495, 6896, 401, 199, 2, 495, 475, 348, 401, 298, 83, 3759, 401, 298, 2253, 401, 298, 87, 319, 24370, 401, 298, 13683, 270, 676, 1533, 401, 298, 5286, 10194, 401, 298, 5286, 5730, 401, 199, 2, 5286, 25644, 401, 298, 5286, 1185, 401, 298, 5286, 409, 401, 298, 495, 3385, 401, 298, 495, 10194, 401, 298, 495, 5730, 401, 298, 495, 15772, 401, 199, 2, 495, 25644, 401, 298, 495, 30608, 78, 401, 298, 20395, 401, 298, 495, 552, 401, 298, 495, 78, 3385, 401, 298, 495, 78, 5730, 401, 298, 495, 7966, 647, 401, 199, 2, 495, 80, 3289, 75, 401, 298, 495, 82, 10194, 401, 298, 495, 681, 78, 401, 298, 495, 495, 401, 298, 495, 9305, 401, 298, 495, 1949, 5682, 401, 298, 18331, 401, 199, 2, 9597, 401, 298, 20691, 401, 298, 3028, 521, 401, 298, 22227, 401, 298, 15198, 401, 298, 23456, 401, 298, 6205, 401, 199, 2, 521, 2266, 3122, 78, 19139, 937, 199, 199, 27869, 773, 275, 359, 199, 2, 27869, 63, 292, 11796, 401, 298, 27869, 63, 962, 63, 7237, 401, 298, 27869, 63, 962, 63, 362, 14481, 929, 401, 199, 2, 27869, 63, 962, 63, 362, 15606, 890, 401, 298, 27869, 63, 962, 63, 362, 20882, 1809, 401, 199, 2, 27869, 63, 962, 63, 362, 10487, 635, 401, 298, 27869, 63, 962, 63, 362, 10487, 3185, 401, 199, 2, 27869, 63, 962, 63, 362, 2645, 401, 298, 27869, 63, 962, 63, 362, 2340, 401, 298, 27869, 63, 962, 63, 362, 2340, 2697, 401, 199, 2, 27869, 63, 962, 63, 362, 2340, 890, 401, 298, 27869, 63, 962, 63, 826, 401, 199, 2, 27869, 63, 962, 63, 409, 14481, 929, 401, 298, 27869, 63, 962, 63, 409, 15606, 890, 401, 199, 2, 27869, 63, 962, 63, 409, 20882, 1809, 401, 298, 27869, 63, 962, 63, 2193, 1809, 635, 401, 199, 2, 27869, 63, 962, 63, 2193, 1809, 3185, 401, 298, 27869, 63, 962, 63, 2193, 1859, 401, 199, 2, 27869, 63, 962, 63, 409, 2340, 401, 298, 27869, 63, 962, 63, 409, 2340, 2697, 401, 199, 2, 27869, 63, 962, 63, 409, 2340, 890, 401, 298, 27869, 63, 1700, 10742, 63, 7237, 401, 298, 27869, 63, 1700, 10742, 63, 826, 401, 199, 2, 27869, 63, 1700, 10742, 63, 2573, 401, 298, 27869, 63, 1700, 10742, 962, 63, 7237, 401, 199, 2, 27869, 63, 1700, 10742, 962, 63, 362, 80, 5555, 401, 298, 27869, 63, 1700, 10742, 962, 63, 826, 401, 199, 2, 27869, 63, 1700, 10742, 962, 63, 409, 80, 5555, 401, 298, 27869, 63, 6406, 401, 298, 27869, 63, 7661, 63, 1935, 401, 199, 2, 27869, 63, 7661, 63, 5335, 401, 298, 27869, 63, 2067, 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,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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 ]
kokosowy/vuadek
vuadek.py
1
1180
#!/usr/bin/python3.4 import sys import os import subprocess zm_home = os.path.expanduser("~") zm_pth_workdir = zm_home+"/.vuadek/" if not os.path.exists(zm_pth_workdir): os.makedirs(zm_pth_workdir) zm_fl_remains = zm_pth_workdir+"remains" pathname = os.path.dirname(sys.argv[1]) if not os.path.isfile(zm_fl_remains): print('nie istnieje') scan_result = subprocess.Popen(["uade123", "--scan", os.path.abspath(pathname)],stdout=subprocess.PIPE) with open(zm_fl_remains, 'w') as f: for line in scan_result.stdout: f.write(line.decode('utf-8')) f.closed print('istnieje') with open(zm_fl_remains, 'r') as f: zm_input = [line.rstrip('\n') for line in f] for item in zm_input: head, tail = os.path.split(item) subprocess.call(["uade123", "--detect-format-by-content", "-f",zm_pth_workdir+tail+'.wav', "--filter=A1200", "--normalise", "--speed-hack", "-v", "--headphones", item]) subprocess.call(["lame", "--verbose", "--preset", "standard", zm_pth_workdir+tail+'.wav', head+'/'+tail+'.mp3']) subprocess.call(["rm", zm_pth_workdir+tail+'.wav']) f.closed #call(["lame", "--verbose", "--preset", "standard", zm_output, zm_mp3]) #call(["rm", zm_output])
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 14, 20, 199, 199, 646, 984, 199, 646, 747, 199, 646, 3873, 199, 199, 90, 77, 63, 4219, 275, 747, 14, 515, 14, 12131, 20793, 531, 199, 90, 77, 63, 13316, 63, 19132, 275, 1315, 77, 63, 4219, 5207, 8083, 86, 1458, 271, 75, 6687, 199, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 90, 77, 63, 13316, 63, 19132, 304, 272, 747, 14, 8347, 8, 90, 77, 63, 13316, 63, 19132, 9, 199, 90, 77, 63, 2327, 63, 8902, 83, 275, 1315, 77, 63, 13316, 63, 19132, 5207, 8902, 83, 2, 199, 199, 12445, 275, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 17, 566, 199, 199, 692, 440, 747, 14, 515, 14, 6292, 8, 90, 77, 63, 2327, 63, 8902, 83, 304, 199, 198, 1361, 360, 78, 1873, 284, 270, 78, 1873, 6532, 358, 199, 198, 6282, 63, 1099, 275, 3873, 14, 7942, 5234, 1458, 271, 4288, 401, 4320, 6282, 401, 747, 14, 515, 14, 4832, 8, 12445, 4360, 2703, 29, 5781, 14, 6089, 9, 199, 198, 1045, 1551, 8, 90, 77, 63, 2327, 63, 8902, 83, 12, 283, 87, 358, 465, 289, 26, 507, 198, 509, 1004, 315, 8000, 63, 1099, 14, 2703, 26, 686, 198, 70, 14, 952, 8, 604, 14, 2708, 360, 1624, 13, 24, 1333, 1057, 199, 198, 70, 14, 5938, 199, 199, 1361, 360, 631, 78, 1873, 6532, 358, 199, 1045, 1551, 8, 90, 77, 63, 2327, 63, 8902, 83, 12, 283, 82, 358, 465, 289, 26, 199, 198, 90, 77, 63, 1210, 275, 359, 604, 14, 6735, 2258, 78, 358, 367, 1004, 315, 289, 61, 199, 198, 509, 1242, 315, 1315, 77, 63, 1210, 26, 507, 198, 2993, 12, 9483, 275, 747, 14, 515, 14, 1294, 8, 1053, 9, 507, 198, 5781, 14, 1250, 5234, 1458, 271, 4288, 401, 4320, 13552, 13, 908, 13, 991, 13, 1317, 401, 3905, 70, 401, 90, 77, 63, 13316, 63, 19132, 11, 1521, 18098, 19118, 297, 4320, 1541, 29, 33, 23781, 401, 4320, 3302, 572, 401, 4320, 7625, 13, 20875, 401, 3905, 86, 401, 4320, 2993, 838, 4548, 401, 1242, 566, 507, 198, 5781, 14, 1250, 5234, 76, 313, 401, 4320, 3832, 401, 4320, 25701, 401, 298, 6807, 401, 1315, 77, 63, 13316, 63, 19132, 11, 1521, 18098, 19118, 297, 4854, 4786, 19047, 1521, 18098, 311, 19, 1105, 507, 198, 5781, 14, 1250, 5234, 5682, 401, 1315, 77, 63, 13316, 63, 19132, 11, 1521, 18098, 19118, 1105, 199, 70, 14, 5938, 6905, 199, 3, 1250, 5234, 76, 313, 401, 4320, 3832, 401, 4320, 25701, 401, 298, 6807, 401, 1315, 77, 63, 1199, 12, 1315, 77, 63, 311, 19, 566, 199, 3, 1250, 5234, 5682, 401, 1315, 77, 63, 1199, 566, 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 ]
[ 2647, 15, 1393, 15, 1548, 19, 14, 20, 199, 199, 646, 984, 199, 646, 747, 199, 646, 3873, 199, 199, 90, 77, 63, 4219, 275, 747, 14, 515, 14, 12131, 20793, 531, 199, 90, 77, 63, 13316, 63, 19132, 275, 1315, 77, 63, 4219, 5207, 8083, 86, 1458, 271, 75, 6687, 199, 199, 692, 440, 747, 14, 515, 14, 2444, 8, 90, 77, 63, 13316, 63, 19132, 304, 272, 747, 14, 8347, 8, 90, 77, 63, 13316, 63, 19132, 9, 199, 90, 77, 63, 2327, 63, 8902, 83, 275, 1315, 77, 63, 13316, 63, 19132, 5207, 8902, 83, 2, 199, 199, 12445, 275, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 17, 566, 199, 199, 692, 440, 747, 14, 515, 14, 6292, 8, 90, 77, 63, 2327, 63, 8902, 83, 304, 199, 198, 1361, 360, 78, 1873, 284, 270, 78, 1873, 6532, 358, 199, 198, 6282, 63, 1099, 275, 3873, 14, 7942, 5234, 1458, 271, 4288, 401, 4320, 6282, 401, 747, 14, 515, 14, 4832, 8, 12445, 4360, 2703, 29, 5781, 14, 6089, 9, 199, 198, 1045, 1551, 8, 90, 77, 63, 2327, 63, 8902, 83, 12, 283, 87, 358, 465, 289, 26, 507, 198, 509, 1004, 315, 8000, 63, 1099, 14, 2703, 26, 686, 198, 70, 14, 952, 8, 604, 14, 2708, 360, 1624, 13, 24, 1333, 1057, 199, 198, 70, 14, 5938, 199, 199, 1361, 360, 631, 78, 1873, 6532, 358, 199, 1045, 1551, 8, 90, 77, 63, 2327, 63, 8902, 83, 12, 283, 82, 358, 465, 289, 26, 199, 198, 90, 77, 63, 1210, 275, 359, 604, 14, 6735, 2258, 78, 358, 367, 1004, 315, 289, 61, 199, 198, 509, 1242, 315, 1315, 77, 63, 1210, 26, 507, 198, 2993, 12, 9483, 275, 747, 14, 515, 14, 1294, 8, 1053, 9, 507, 198, 5781, 14, 1250, 5234, 1458, 271, 4288, 401, 4320, 13552, 13, 908, 13, 991, 13, 1317, 401, 3905, 70, 401, 90, 77, 63, 13316, 63, 19132, 11, 1521, 18098, 19118, 297, 4320, 1541, 29, 33, 23781, 401, 4320, 3302, 572, 401, 4320, 7625, 13, 20875, 401, 3905, 86, 401, 4320, 2993, 838, 4548, 401, 1242, 566, 507, 198, 5781, 14, 1250, 5234, 76, 313, 401, 4320, 3832, 401, 4320, 25701, 401, 298, 6807, 401, 1315, 77, 63, 13316, 63, 19132, 11, 1521, 18098, 19118, 297, 4854, 4786, 19047, 1521, 18098, 311, 19, 1105, 507, 198, 5781, 14, 1250, 5234, 5682, 401, 1315, 77, 63, 13316, 63, 19132, 11, 1521, 18098, 19118, 1105, 199, 70, 14, 5938, 6905, 199, 3, 1250, 5234, 76, 313, 401, 4320, 3832, 401, 4320, 25701, 401, 298, 6807, 401, 1315, 77, 63, 1199, 12, 1315, 77, 63, 311, 19, 566, 199, 3, 1250, 5234, 5682, 401, 1315, 77, 63, 1199, 566, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
danieljaouen/ansible
lib/ansible/modules/cloud/ovirt/ovirt_mac_pool.py
75
5267
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (c) 2016 Red Hat, Inc. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: ovirt_mac_pool short_description: Module to manage MAC pools in oVirt/RHV version_added: "2.3" author: "Ondra Machacek (@machacekondra)" description: - "This module manage MAC pools in oVirt/RHV." options: id: description: - "ID of the mac pool to manage." version_added: "2.8" name: description: - "Name of the MAC pool to manage." required: true description: description: - "Description of the MAC pool." state: description: - "Should the mac pool be present or absent." choices: ['present', 'absent'] default: present allow_duplicates: description: - "If I(true) allow a MAC address to be used multiple times in a pool." - "Default value is set by oVirt/RHV engine to I(false)." type: bool ranges: description: - "List of MAC ranges. The from and to should be split by comma." - "For example: 00:1a:4a:16:01:51,00:1a:4a:16:01:61" extends_documentation_fragment: ovirt ''' EXAMPLES = ''' # Examples don't contain auth parameter for simplicity, # look at ovirt_auth module to see how to reuse authentication: # Create MAC pool: - ovirt_mac_pool: name: mymacpool allow_duplicates: false ranges: - 00:1a:4a:16:01:51,00:1a:4a:16:01:61 - 00:1a:4a:16:02:51,00:1a:4a:16:02:61 # Remove MAC pool: - ovirt_mac_pool: state: absent name: mymacpool # Change MAC pool Name - ovirt_nic: id: 00000000-0000-0000-0000-000000000000 name: "new_mac_pool_name" ''' RETURN = ''' id: description: ID of the MAC pool which is managed returned: On success if MAC pool is found. type: str sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c template: description: "Dictionary of all the MAC pool attributes. MAC pool attributes can be found on your oVirt/RHV instance at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/mac_pool." returned: On success if MAC pool is found. type: dict ''' import traceback try: import ovirtsdk4.types as otypes except ImportError: pass from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ovirt import ( BaseModule, check_sdk, equal, create_connection, ovirt_full_argument_spec, ) class MACPoolModule(BaseModule): def build_entity(self): return otypes.MacPool( name=self._module.params['name'], id=self._module.params['id'], allow_duplicates=self._module.params['allow_duplicates'], description=self._module.params['description'], ranges=[ otypes.Range( from_=mac_range.split(',')[0], to=mac_range.split(',')[1], ) for mac_range in self._module.params['ranges'] ] if self._module.params['ranges'] else None, ) def _compare_ranges(self, entity): if self._module.params['ranges'] is not None: ranges = sorted([ '%s,%s' % (mac_range.from_, mac_range.to) for mac_range in entity.ranges ]) return equal(sorted(self._module.params['ranges']), ranges) return True def update_check(self, entity): return ( self._compare_ranges(entity) and equal(self._module.params['allow_duplicates'], entity.allow_duplicates) and equal(self._module.params['description'], entity.description) and equal(self._module.params['name'], entity.name) ) def main(): argument_spec = ovirt_full_argument_spec( state=dict( choices=['present', 'absent'], default='present', ), name=dict(required=True), id=dict(default=None), allow_duplicates=dict(default=None, type='bool'), description=dict(default=None), ranges=dict(default=None, type='list'), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) check_sdk(module) try: auth = module.params.pop('auth') connection = create_connection(auth) mac_pools_service = connection.system_service().mac_pools_service() mac_pools_module = MACPoolModule( connection=connection, module=module, service=mac_pools_service, ) state = module.params['state'] if state == 'present': ret = mac_pools_module.create() elif state == 'absent': ret = mac_pools_module.remove() module.exit_json(**ret) except Exception as e: module.fail_json(msg=str(e), exception=traceback.format_exc()) finally: connection.close(logout=auth.get('token') is None) if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 9572, 13002, 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, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21353, 63, 3088, 63, 2293, 199, 3612, 63, 1802, 26, 5673, 370, 9635, 13347, 20092, 315, 312, 17146, 15, 50, 16566, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 47, 977, 345, 30611, 7984, 75, 8593, 14121, 7984, 75, 7835, 345, 2924, 199, 1802, 26, 272, 446, 298, 2765, 859, 9635, 13347, 20092, 315, 312, 17146, 15, 50, 16566, 2122, 199, 1419, 26, 272, 1305, 26, 267, 1369, 26, 288, 446, 298, 998, 402, 314, 4497, 4203, 370, 9635, 2122, 267, 1015, 63, 3270, 26, 298, 18, 14, 24, 2, 272, 536, 26, 267, 1369, 26, 288, 446, 298, 985, 402, 314, 13347, 4203, 370, 9635, 2122, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 298, 5831, 402, 314, 13347, 4203, 2122, 272, 1174, 26, 267, 1369, 26, 288, 446, 298, 11408, 314, 4497, 4203, 506, 3451, 503, 9552, 2122, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 3451, 272, 2040, 63, 18563, 26, 267, 1369, 26, 288, 446, 298, 3917, 473, 8, 2052, 9, 2040, 282, 13347, 2287, 370, 506, 1202, 3663, 5431, 315, 282, 4203, 2122, 288, 446, 298, 2698, 574, 365, 663, 701, 312, 17146, 15, 50, 16566, 6869, 370, 473, 8, 3910, 17617, 267, 730, 26, 2155, 272, 12271, 26, 267, 1369, 26, 288, 446, 298, 1296, 402, 13347, 12271, 14, 710, 687, 436, 370, 1077, 506, 3715, 701, 10029, 2122, 288, 446, 298, 1858, 2893, 26, 8733, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2869, 12, 383, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2976, 2, 199, 11036, 63, 9970, 63, 7677, 26, 21353, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 6058, 2793, 1133, 1395, 1790, 2725, 367, 17553, 3690, 12, 199, 3, 3648, 737, 21353, 63, 1178, 859, 370, 1937, 4212, 370, 12598, 6299, 26, 199, 199, 3, 2790, 13347, 4203, 26, 199, 13, 21353, 63, 3088, 63, 2293, 26, 272, 536, 26, 3002, 3088, 2293, 272, 2040, 63, 18563, 26, 3055, 272, 12271, 26, 489, 446, 8733, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2869, 12, 383, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2976, 489, 446, 8733, 26, 17, 65, 26, 20, 65, 26, 975, 26, 996, 26, 2869, 12, 383, 26, 17, 65, 26, 20, 65, 26, 975, 26, 996, 26, 2976, 199, 199, 3, 5852, 13347, 4203, 26, 199, 13, 21353, 63, 3088, 63, 2293, 26, 272, 1174, 26, 9552, 272, 536, 26, 3002, 3088, 2293, 199, 199, 3, 7743, 13347, 4203, 2812, 199, 13, 21353, 63, 12165, 26, 272, 1305, 26, 378, 9084, 13, 993, 13, 993, 13, 993, 13, 15672, 272, 536, 26, 298, 1222, 63, 3088, 63, 2293, 63, 354, 2, 199, 2344, 199, 199, 9677, 275, 1449, 199, 344, 26, 272, 1369, 26, 2870, 402, 314, 13347, 4203, 1314, 365, 12883, 272, 2138, 26, 4068, 3182, 340, 13347, 4203, 365, 1911, 14, 272, 730, 26, 620, 272, 2690, 26, 1520, 271, 2710, 70, 2192, 13, 9485, 67, 13, 26319, 67, 13, 65, 17, 696, 13, 23, 69, 10027, 3691, 21, 66, 2259, 67, 199, 1160, 26, 272, 1369, 26, 298, 11728, 402, 1006, 314, 13347, 4203, 3004, 14, 13347, 4203, 3004, 883, 506, 1911, 641, 2195, 312, 17146, 15, 50, 16566, 1256, 2116, 737, 2569, 1166, 26, 1455, 921, 23334, 14, 5031, 14, 2308, 15, 23334, 13, 3908, 13, 1246, 13, 1238, 15, 4133, 12645, 1313, 15, 3088, 63, 2293, 2122, 272, 2138, 26, 4068, 3182, 340, 13347, 4203, 365, 1911, 14, 272, 730, 26, 1211, 199, 2344, 199, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 312, 1042, 1086, 6341, 20, 14, 1313, 465, 312, 1313, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 23334, 492, 334, 272, 3523, 2377, 12, 272, 1104, 63, 9277, 12, 272, 4472, 12, 272, 1218, 63, 2105, 12, 272, 21353, 63, 2861, 63, 2094, 63, 1650, 12, 199, 9, 421, 199, 533, 13347, 5453, 2377, 8, 1563, 2377, 304, 339, 347, 1900, 63, 4502, 8, 277, 304, 267, 372, 312, 1313, 14, 3399, 5453, 8, 288, 536, 29, 277, 423, 578, 14, 1162, 459, 354, 995, 288, 1305, 29, 277, 423, 578, 14, 1162, 459, 344, 995, 288, 2040, 63, 18563, 29, 277, 423, 578, 14, 1162, 459, 3306, 63, 18563, 995, 288, 1369, 29, 277, 423, 578, 14, 1162, 459, 1802, 995, 288, 12271, 1524, 355, 312, 1313, 14, 4709, 8, 490, 687, 10683, 3088, 63, 1842, 14, 1294, 5102, 5832, 16, 467, 490, 370, 29, 3088, 63, 1842, 14, 1294, 5102, 5832, 17, 467, 355, 776, 355, 367, 4497, 63, 1842, 315, 291, 423, 578, 14, 1162, 459, 8404, 418, 288, 1622, 340, 291, 423, 578, 14, 1162, 459, 8404, 418, 587, 488, 12, 267, 776, 339, 347, 485, 5785, 63, 8404, 8, 277, 12, 4642, 304, 267, 340, 291, 423, 578, 14, 1162, 459, 8404, 418, 365, 440, 488, 26, 288, 12271, 275, 3355, 779, 355, 1543, 83, 8719, 83, 7, 450, 334, 3088, 63, 1842, 14, 504, 3131, 4497, 63, 1842, 14, 475, 9, 355, 367, 4497, 63, 1842, 315, 4642, 14, 8404, 288, 4794, 288, 372, 4472, 8, 5917, 8, 277, 423, 578, 14, 1162, 459, 8404, 3815, 12271, 9, 398, 372, 715, 339, 347, 1678, 63, 1074, 8, 277, 12, 4642, 304, 267, 372, 334, 288, 291, 423, 5785, 63, 8404, 8 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 9572, 13002, 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, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21353, 63, 3088, 63, 2293, 199, 3612, 63, 1802, 26, 5673, 370, 9635, 13347, 20092, 315, 312, 17146, 15, 50, 16566, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 47, 977, 345, 30611, 7984, 75, 8593, 14121, 7984, 75, 7835, 345, 2924, 199, 1802, 26, 272, 446, 298, 2765, 859, 9635, 13347, 20092, 315, 312, 17146, 15, 50, 16566, 2122, 199, 1419, 26, 272, 1305, 26, 267, 1369, 26, 288, 446, 298, 998, 402, 314, 4497, 4203, 370, 9635, 2122, 267, 1015, 63, 3270, 26, 298, 18, 14, 24, 2, 272, 536, 26, 267, 1369, 26, 288, 446, 298, 985, 402, 314, 13347, 4203, 370, 9635, 2122, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 298, 5831, 402, 314, 13347, 4203, 2122, 272, 1174, 26, 267, 1369, 26, 288, 446, 298, 11408, 314, 4497, 4203, 506, 3451, 503, 9552, 2122, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 3451, 272, 2040, 63, 18563, 26, 267, 1369, 26, 288, 446, 298, 3917, 473, 8, 2052, 9, 2040, 282, 13347, 2287, 370, 506, 1202, 3663, 5431, 315, 282, 4203, 2122, 288, 446, 298, 2698, 574, 365, 663, 701, 312, 17146, 15, 50, 16566, 6869, 370, 473, 8, 3910, 17617, 267, 730, 26, 2155, 272, 12271, 26, 267, 1369, 26, 288, 446, 298, 1296, 402, 13347, 12271, 14, 710, 687, 436, 370, 1077, 506, 3715, 701, 10029, 2122, 288, 446, 298, 1858, 2893, 26, 8733, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2869, 12, 383, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2976, 2, 199, 11036, 63, 9970, 63, 7677, 26, 21353, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 6058, 2793, 1133, 1395, 1790, 2725, 367, 17553, 3690, 12, 199, 3, 3648, 737, 21353, 63, 1178, 859, 370, 1937, 4212, 370, 12598, 6299, 26, 199, 199, 3, 2790, 13347, 4203, 26, 199, 13, 21353, 63, 3088, 63, 2293, 26, 272, 536, 26, 3002, 3088, 2293, 272, 2040, 63, 18563, 26, 3055, 272, 12271, 26, 489, 446, 8733, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2869, 12, 383, 26, 17, 65, 26, 20, 65, 26, 975, 26, 614, 26, 2976, 489, 446, 8733, 26, 17, 65, 26, 20, 65, 26, 975, 26, 996, 26, 2869, 12, 383, 26, 17, 65, 26, 20, 65, 26, 975, 26, 996, 26, 2976, 199, 199, 3, 5852, 13347, 4203, 26, 199, 13, 21353, 63, 3088, 63, 2293, 26, 272, 1174, 26, 9552, 272, 536, 26, 3002, 3088, 2293, 199, 199, 3, 7743, 13347, 4203, 2812, 199, 13, 21353, 63, 12165, 26, 272, 1305, 26, 378, 9084, 13, 993, 13, 993, 13, 993, 13, 15672, 272, 536, 26, 298, 1222, 63, 3088, 63, 2293, 63, 354, 2, 199, 2344, 199, 199, 9677, 275, 1449, 199, 344, 26, 272, 1369, 26, 2870, 402, 314, 13347, 4203, 1314, 365, 12883, 272, 2138, 26, 4068, 3182, 340, 13347, 4203, 365, 1911, 14, 272, 730, 26, 620, 272, 2690, 26, 1520, 271, 2710, 70, 2192, 13, 9485, 67, 13, 26319, 67, 13, 65, 17, 696, 13, 23, 69, 10027, 3691, 21, 66, 2259, 67, 199, 1160, 26, 272, 1369, 26, 298, 11728, 402, 1006, 314, 13347, 4203, 3004, 14, 13347, 4203, 3004, 883, 506, 1911, 641, 2195, 312, 17146, 15, 50, 16566, 1256, 2116, 737, 2569, 1166, 26, 1455, 921, 23334, 14, 5031, 14, 2308, 15, 23334, 13, 3908, 13, 1246, 13, 1238, 15, 4133, 12645, 1313, 15, 3088, 63, 2293, 2122, 272, 2138, 26, 4068, 3182, 340, 13347, 4203, 365, 1911, 14, 272, 730, 26, 1211, 199, 2344, 199, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 312, 1042, 1086, 6341, 20, 14, 1313, 465, 312, 1313, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 23334, 492, 334, 272, 3523, 2377, 12, 272, 1104, 63, 9277, 12, 272, 4472, 12, 272, 1218, 63, 2105, 12, 272, 21353, 63, 2861, 63, 2094, 63, 1650, 12, 199, 9, 421, 199, 533, 13347, 5453, 2377, 8, 1563, 2377, 304, 339, 347, 1900, 63, 4502, 8, 277, 304, 267, 372, 312, 1313, 14, 3399, 5453, 8, 288, 536, 29, 277, 423, 578, 14, 1162, 459, 354, 995, 288, 1305, 29, 277, 423, 578, 14, 1162, 459, 344, 995, 288, 2040, 63, 18563, 29, 277, 423, 578, 14, 1162, 459, 3306, 63, 18563, 995, 288, 1369, 29, 277, 423, 578, 14, 1162, 459, 1802, 995, 288, 12271, 1524, 355, 312, 1313, 14, 4709, 8, 490, 687, 10683, 3088, 63, 1842, 14, 1294, 5102, 5832, 16, 467, 490, 370, 29, 3088, 63, 1842, 14, 1294, 5102, 5832, 17, 467, 355, 776, 355, 367, 4497, 63, 1842, 315, 291, 423, 578, 14, 1162, 459, 8404, 418, 288, 1622, 340, 291, 423, 578, 14, 1162, 459, 8404, 418, 587, 488, 12, 267, 776, 339, 347, 485, 5785, 63, 8404, 8, 277, 12, 4642, 304, 267, 340, 291, 423, 578, 14, 1162, 459, 8404, 418, 365, 440, 488, 26, 288, 12271, 275, 3355, 779, 355, 1543, 83, 8719, 83, 7, 450, 334, 3088, 63, 1842, 14, 504, 3131, 4497, 63, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gavioto/rethinkdb
test/rql_test/connections/http_support/flask/sessions.py
428
13107
# -*- coding: utf-8 -*- """ flask.sessions ~~~~~~~~~~~~~~ Implements cookie based sessions based on itsdangerous. :copyright: (c) 2012 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ import uuid import hashlib from base64 import b64encode, b64decode from datetime import datetime from werkzeug.http import http_date, parse_date from werkzeug.datastructures import CallbackDict from . import Markup, json from ._compat import iteritems, text_type from itsdangerous import URLSafeTimedSerializer, BadSignature def total_seconds(td): return td.days * 60 * 60 * 24 + td.seconds class SessionMixin(object): """Expands a basic dictionary with an accessors that are expected by Flask extensions and users for the session. """ def _get_permanent(self): return self.get('_permanent', False) def _set_permanent(self, value): self['_permanent'] = bool(value) #: this reflects the ``'_permanent'`` key in the dict. permanent = property(_get_permanent, _set_permanent) del _get_permanent, _set_permanent #: some session backends can tell you if a session is new, but that is #: not necessarily guaranteed. Use with caution. The default mixin #: implementation just hardcodes `False` in. new = False #: for some backends this will always be `True`, but some backends will #: default this to false and detect changes in the dictionary for as #: long as changes do not happen on mutable structures in the session. #: The default mixin implementation just hardcodes `True` in. modified = True class TaggedJSONSerializer(object): """A customized JSON serializer that supports a few extra types that we take for granted when serializing (tuples, markup objects, datetime). """ def dumps(self, value): def _tag(value): if isinstance(value, tuple): return {' t': [_tag(x) for x in value]} elif isinstance(value, uuid.UUID): return {' u': value.hex} elif isinstance(value, bytes): return {' b': b64encode(value).decode('ascii')} elif callable(getattr(value, '__html__', None)): return {' m': text_type(value.__html__())} elif isinstance(value, list): return [_tag(x) for x in value] elif isinstance(value, datetime): return {' d': http_date(value)} elif isinstance(value, dict): return dict((k, _tag(v)) for k, v in iteritems(value)) elif isinstance(value, str): try: return text_type(value) except UnicodeError: raise UnexpectedUnicodeError(u'A byte string with ' u'non-ASCII data was passed to the session system ' u'which can only store unicode strings. Consider ' u'base64 encoding your string (String was %r)' % value) return value return json.dumps(_tag(value), separators=(',', ':')) def loads(self, value): def object_hook(obj): if len(obj) != 1: return obj the_key, the_value = next(iteritems(obj)) if the_key == ' t': return tuple(the_value) elif the_key == ' u': return uuid.UUID(the_value) elif the_key == ' b': return b64decode(the_value) elif the_key == ' m': return Markup(the_value) elif the_key == ' d': return parse_date(the_value) return obj return json.loads(value, object_hook=object_hook) session_json_serializer = TaggedJSONSerializer() class SecureCookieSession(CallbackDict, SessionMixin): """Baseclass for sessions based on signed cookies.""" def __init__(self, initial=None): def on_update(self): self.modified = True CallbackDict.__init__(self, initial, on_update) self.modified = False class NullSession(SecureCookieSession): """Class used to generate nicer error messages if sessions are not available. Will still allow read-only access to the empty session but fail on setting. """ def _fail(self, *args, **kwargs): raise RuntimeError('the session is unavailable because no secret ' 'key was set. Set the secret_key on the ' 'application to something unique and secret.') __setitem__ = __delitem__ = clear = pop = popitem = \ update = setdefault = _fail del _fail class SessionInterface(object): """The basic interface you have to implement in order to replace the default session interface which uses werkzeug's securecookie implementation. The only methods you have to implement are :meth:`open_session` and :meth:`save_session`, the others have useful defaults which you don't need to change. The session object returned by the :meth:`open_session` method has to provide a dictionary like interface plus the properties and methods from the :class:`SessionMixin`. We recommend just subclassing a dict and adding that mixin:: class Session(dict, SessionMixin): pass If :meth:`open_session` returns `None` Flask will call into :meth:`make_null_session` to create a session that acts as replacement if the session support cannot work because some requirement is not fulfilled. The default :class:`NullSession` class that is created will complain that the secret key was not set. To replace the session interface on an application all you have to do is to assign :attr:`flask.Flask.session_interface`:: app = Flask(__name__) app.session_interface = MySessionInterface() .. versionadded:: 0.8 """ #: :meth:`make_null_session` will look here for the class that should #: be created when a null session is requested. Likewise the #: :meth:`is_null_session` method will perform a typecheck against #: this type. null_session_class = NullSession #: A flag that indicates if the session interface is pickle based. #: This can be used by flask extensions to make a decision in regards #: to how to deal with the session object. #: #: .. versionadded:: 0.10 pickle_based = False def make_null_session(self, app): """Creates a null session which acts as a replacement object if the real session support could not be loaded due to a configuration error. This mainly aids the user experience because the job of the null session is to still support lookup without complaining but modifications are answered with a helpful error message of what failed. This creates an instance of :attr:`null_session_class` by default. """ return self.null_session_class() def is_null_session(self, obj): """Checks if a given object is a null session. Null sessions are not asked to be saved. This checks if the object is an instance of :attr:`null_session_class` by default. """ return isinstance(obj, self.null_session_class) def get_cookie_domain(self, app): """Helpful helper method that returns the cookie domain that should be used for the session cookie if session cookies are used. """ if app.config['SESSION_COOKIE_DOMAIN'] is not None: return app.config['SESSION_COOKIE_DOMAIN'] if app.config['SERVER_NAME'] is not None: # chop of the port which is usually not supported by browsers rv = '.' + app.config['SERVER_NAME'].rsplit(':', 1)[0] # Google chrome does not like cookies set to .localhost, so # we just go with no domain then. Flask documents anyways that # cross domain cookies need a fully qualified domain name if rv == '.localhost': rv = None # If we infer the cookie domain from the server name we need # to check if we are in a subpath. In that case we can't # set a cross domain cookie. if rv is not None: path = self.get_cookie_path(app) if path != '/': rv = rv.lstrip('.') return rv def get_cookie_path(self, app): """Returns the path for which the cookie should be valid. The default implementation uses the value from the SESSION_COOKIE_PATH`` config var if it's set, and falls back to ``APPLICATION_ROOT`` or uses ``/`` if it's `None`. """ return app.config['SESSION_COOKIE_PATH'] or \ app.config['APPLICATION_ROOT'] or '/' def get_cookie_httponly(self, app): """Returns True if the session cookie should be httponly. This currently just returns the value of the ``SESSION_COOKIE_HTTPONLY`` config var. """ return app.config['SESSION_COOKIE_HTTPONLY'] def get_cookie_secure(self, app): """Returns True if the cookie should be secure. This currently just returns the value of the ``SESSION_COOKIE_SECURE`` setting. """ return app.config['SESSION_COOKIE_SECURE'] def get_expiration_time(self, app, session): """A helper method that returns an expiration date for the session or `None` if the session is linked to the browser session. The default implementation returns now + the permanent session lifetime configured on the application. """ if session.permanent: return datetime.utcnow() + app.permanent_session_lifetime def open_session(self, app, request): """This method has to be implemented and must either return `None` in case the loading failed because of a configuration error or an instance of a session object which implements a dictionary like interface + the methods and attributes on :class:`SessionMixin`. """ raise NotImplementedError() def save_session(self, app, session, response): """This is called for actual sessions returned by :meth:`open_session` at the end of the request. This is still called during a request context so if you absolutely need access to the request you can do that. """ raise NotImplementedError() class SecureCookieSessionInterface(SessionInterface): """The default session interface that stores sessions in signed cookies through the :mod:`itsdangerous` module. """ #: the salt that should be applied on top of the secret key for the #: signing of cookie based sessions. salt = 'cookie-session' #: the hash function to use for the signature. The default is sha1 digest_method = staticmethod(hashlib.sha1) #: the name of the itsdangerous supported key derivation. The default #: is hmac. key_derivation = 'hmac' #: A python serializer for the payload. The default is a compact #: JSON derived serializer with support for some extra Python types #: such as datetime objects or tuples. serializer = session_json_serializer session_class = SecureCookieSession def get_signing_serializer(self, app): if not app.secret_key: return None signer_kwargs = dict( key_derivation=self.key_derivation, digest_method=self.digest_method ) return URLSafeTimedSerializer(app.secret_key, salt=self.salt, serializer=self.serializer, signer_kwargs=signer_kwargs) def open_session(self, app, request): s = self.get_signing_serializer(app) if s is None: return None val = request.cookies.get(app.session_cookie_name) if not val: return self.session_class() max_age = total_seconds(app.permanent_session_lifetime) try: data = s.loads(val, max_age=max_age) return self.session_class(data) except BadSignature: return self.session_class() def save_session(self, app, session, response): domain = self.get_cookie_domain(app) path = self.get_cookie_path(app) if not session: if session.modified: response.delete_cookie(app.session_cookie_name, domain=domain, path=path) return httponly = self.get_cookie_httponly(app) secure = self.get_cookie_secure(app) expires = self.get_expiration_time(app, session) val = self.get_signing_serializer(app).dumps(dict(session)) response.set_cookie(app.session_cookie_name, val, expires=expires, httponly=httponly, domain=domain, path=path, secure=secure) from flask.debughelpers import UnexpectedUnicodeError
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 11676, 272, 32202, 1714, 339, 24664, 5494, 4079, 12184, 4079, 641, 2399, 31444, 14, 339, 520, 7307, 26, 334, 67, 9, 6029, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 5377, 199, 646, 8337, 199, 504, 1300, 772, 492, 330, 772, 2143, 12, 330, 772, 2708, 199, 504, 2197, 492, 2197, 199, 504, 10380, 14, 1014, 492, 1455, 63, 602, 12, 2198, 63, 602, 199, 504, 10380, 14, 23004, 492, 17555, 2141, 199, 504, 1275, 492, 17504, 12, 2022, 199, 504, 13653, 5819, 492, 10849, 12, 1318, 63, 466, 199, 199, 504, 2399, 31444, 492, 2851, 11090, 28682, 7299, 12, 8857, 10014, 421, 199, 318, 3141, 63, 4515, 8, 2076, 304, 272, 372, 12749, 14, 4899, 627, 5212, 627, 5212, 627, 5504, 435, 12749, 14, 4515, 421, 199, 533, 8596, 4256, 8, 785, 304, 272, 408, 4527, 5915, 282, 5678, 2600, 543, 376, 31908, 626, 787, 1420, 272, 701, 16704, 5478, 436, 4390, 367, 314, 2351, 14, 272, 408, 339, 347, 485, 362, 63, 19904, 8, 277, 304, 267, 372, 291, 14, 362, 6412, 19904, 297, 756, 9, 339, 347, 485, 409, 63, 19904, 8, 277, 12, 574, 304, 267, 291, 8680, 19904, 418, 275, 2155, 8, 585, 9, 339, 6079, 642, 16806, 83, 314, 12692, 63, 19904, 14700, 790, 315, 314, 1211, 14, 272, 19860, 275, 3324, 1547, 362, 63, 19904, 12, 485, 409, 63, 19904, 9, 272, 2150, 485, 362, 63, 19904, 12, 485, 409, 63, 19904, 339, 6079, 2005, 2351, 14745, 883, 11480, 1265, 340, 282, 2351, 365, 892, 12, 1325, 626, 365, 272, 6079, 440, 20513, 17334, 14, 221, 3645, 543, 1704, 2206, 14, 221, 710, 849, 20048, 272, 6079, 4514, 2951, 7508, 6021, 658, 797, 64, 315, 14, 272, 892, 275, 756, 339, 6079, 367, 2005, 14745, 642, 911, 3544, 506, 658, 549, 3559, 1325, 2005, 14745, 911, 272, 6079, 849, 642, 370, 3055, 436, 9696, 4493, 315, 314, 2600, 367, 465, 272, 6079, 1846, 465, 4493, 886, 440, 5992, 641, 17194, 13955, 315, 314, 2351, 14, 272, 6079, 710, 849, 20048, 4514, 2951, 7508, 6021, 658, 549, 64, 315, 14, 272, 6042, 275, 715, 421, 199, 533, 32121, 6243, 7299, 8, 785, 304, 272, 408, 33, 26707, 4840, 9146, 626, 5171, 282, 9284, 2402, 2943, 626, 272, 781, 5452, 367, 10009, 1380, 3012, 9147, 334, 11760, 12, 9189, 2251, 12, 2197, 680, 272, 408, 339, 347, 16864, 8, 277, 12, 574, 304, 267, 347, 485, 1450, 8, 585, 304, 288, 340, 1228, 8, 585, 12, 2008, 304, 355, 372, 791, 307, 356, 15500, 1450, 8, 88, 9, 367, 671, 315, 574, 9420, 288, 916, 1228, 8, 585, 12, 5377, 14, 8757, 304, 355, 372, 791, 399, 356, 574, 14, 4097, 93, 288, 916, 1228, 8, 585, 12, 2783, 304, 355, 372, 791, 330, 356, 330, 772, 2143, 8, 585, 680, 2708, 360, 4371, 21004, 288, 916, 4550, 8, 5675, 8, 585, 12, 2560, 1360, 7500, 488, 2298, 355, 372, 791, 333, 356, 1318, 63, 466, 8, 585, 855, 1360, 29133, 93, 288, 916, 1228, 8, 585, 12, 769, 304, 355, 372, 15500, 1450, 8, 88, 9, 367, 671, 315, 574, 61, 288, 916, 1228, 8, 585, 12, 2197, 304, 355, 372, 791, 366, 356, 1455, 63, 602, 8, 585, 6769, 288, 916, 1228, 8, 585, 12, 1211, 304, 355, 372, 1211, 1332, 75, 12, 485, 1450, 8, 86, 430, 367, 1022, 12, 373, 315, 10849, 8, 585, 430, 288, 916, 1228, 8, 585, 12, 620, 304, 355, 862, 26, 490, 372, 1318, 63, 466, 8, 585, 9, 355, 871, 20872, 26, 490, 746, 25345, 7087, 547, 8, 85, 7, 33, 3696, 1059, 543, 283, 717, 399, 7, 2865, 13, 12292, 666, 1990, 3032, 370, 314, 2351, 2656, 283, 717, 399, 7, 6777, 883, 1454, 3877, 2649, 3326, 14, 221, 24413, 283, 717, 399, 7, 1095, 772, 2644, 2195, 1059, 334, 1558, 1990, 450, 82, 3171, 450, 574, 9, 288, 372, 574, 267, 372, 2022, 14, 4180, 1547, 1450, 8, 585, 395, 17658, 2687, 23324, 7596, 1333, 339, 347, 14404, 8, 277, 12, 574, 304, 267, 347, 909, 63, 3664, 8, 1113, 304, 288, 340, 822, 8, 1113, 9, 1137, 413, 26, 355, 372, 1559, 288, 314, 63, 498, 12, 314, 63, 585, 275, 2163, 8, 4611, 8, 1113, 430, 288, 340, 314, 63, 498, 508, 283, 307, 356, 355, 372, 2008, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 399, 356, 355, 372, 5377, 14, 8757, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 330, 356, 355, 372, 330, 772, 2708, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 333, 356, 355, 372, 17504, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 366, 356, 355, 372, 2198, 63, 602, 8, 1589, 63, 585, 9, 288, 372, 1559, 267, 372, 2022, 14, 3640, 8, 585, 12, 909, 63, 3664, 29, 785, 63, 3664, 9, 421, 199, 1730, 63, 1001, 63, 8349, 275, 32121, 6243, 7299, 342, 421, 199, 533, 30894, 7810, 4434, 8, 2806, 2141, 12, 8596, 4256, 304, 272, 408, 1563, 533, 367, 12184, 4079, 641, 10514, 10049, 1041, 339, 347, 636, 826, 721, 277, 12, 2536, 29, 403, 304, 267, 347, 641, 63, 873, 8, 277, 304, 288, 291, 14, 5540, 275, 715, 267, 17555, 2141, 855, 826, 721, 277, 12, 2536, 12, 641, 63, 873, 9, 267, 291, 14, 5540, 275, 756, 421, 199, 533, 12119, 4434, 8, 24117, 7810, 4434, 304, 272, 408, 2543, 1202, 370, 3550, 30023, 1125, 3788, 340, 12184, 787, 440, 272, 2808, 14, 221, 12823, 5139, 2040, 1586, 13, 2118, 2879, 370, 314, 2701, 2351, 272, 1325, 2449, 641, 4260, 14, 272, 408, 339, 347, 485, 1633, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 746, 6064, 360, 1589, 2351, 365, 18735, 2952, 949, 7565, 283, 2574, 283, 498, 1990, 663, 14, 221, 2494, 314, 7565, 63, 498, 641, 314, 283, 2574, 283, 3578, 370, 6020, 3747, 436, 7565, 2659, 272, 636, 8617, 363, 275 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 11676, 272, 32202, 1714, 339, 24664, 5494, 4079, 12184, 4079, 641, 2399, 31444, 14, 339, 520, 7307, 26, 334, 67, 9, 6029, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 5377, 199, 646, 8337, 199, 504, 1300, 772, 492, 330, 772, 2143, 12, 330, 772, 2708, 199, 504, 2197, 492, 2197, 199, 504, 10380, 14, 1014, 492, 1455, 63, 602, 12, 2198, 63, 602, 199, 504, 10380, 14, 23004, 492, 17555, 2141, 199, 504, 1275, 492, 17504, 12, 2022, 199, 504, 13653, 5819, 492, 10849, 12, 1318, 63, 466, 199, 199, 504, 2399, 31444, 492, 2851, 11090, 28682, 7299, 12, 8857, 10014, 421, 199, 318, 3141, 63, 4515, 8, 2076, 304, 272, 372, 12749, 14, 4899, 627, 5212, 627, 5212, 627, 5504, 435, 12749, 14, 4515, 421, 199, 533, 8596, 4256, 8, 785, 304, 272, 408, 4527, 5915, 282, 5678, 2600, 543, 376, 31908, 626, 787, 1420, 272, 701, 16704, 5478, 436, 4390, 367, 314, 2351, 14, 272, 408, 339, 347, 485, 362, 63, 19904, 8, 277, 304, 267, 372, 291, 14, 362, 6412, 19904, 297, 756, 9, 339, 347, 485, 409, 63, 19904, 8, 277, 12, 574, 304, 267, 291, 8680, 19904, 418, 275, 2155, 8, 585, 9, 339, 6079, 642, 16806, 83, 314, 12692, 63, 19904, 14700, 790, 315, 314, 1211, 14, 272, 19860, 275, 3324, 1547, 362, 63, 19904, 12, 485, 409, 63, 19904, 9, 272, 2150, 485, 362, 63, 19904, 12, 485, 409, 63, 19904, 339, 6079, 2005, 2351, 14745, 883, 11480, 1265, 340, 282, 2351, 365, 892, 12, 1325, 626, 365, 272, 6079, 440, 20513, 17334, 14, 221, 3645, 543, 1704, 2206, 14, 221, 710, 849, 20048, 272, 6079, 4514, 2951, 7508, 6021, 658, 797, 64, 315, 14, 272, 892, 275, 756, 339, 6079, 367, 2005, 14745, 642, 911, 3544, 506, 658, 549, 3559, 1325, 2005, 14745, 911, 272, 6079, 849, 642, 370, 3055, 436, 9696, 4493, 315, 314, 2600, 367, 465, 272, 6079, 1846, 465, 4493, 886, 440, 5992, 641, 17194, 13955, 315, 314, 2351, 14, 272, 6079, 710, 849, 20048, 4514, 2951, 7508, 6021, 658, 549, 64, 315, 14, 272, 6042, 275, 715, 421, 199, 533, 32121, 6243, 7299, 8, 785, 304, 272, 408, 33, 26707, 4840, 9146, 626, 5171, 282, 9284, 2402, 2943, 626, 272, 781, 5452, 367, 10009, 1380, 3012, 9147, 334, 11760, 12, 9189, 2251, 12, 2197, 680, 272, 408, 339, 347, 16864, 8, 277, 12, 574, 304, 267, 347, 485, 1450, 8, 585, 304, 288, 340, 1228, 8, 585, 12, 2008, 304, 355, 372, 791, 307, 356, 15500, 1450, 8, 88, 9, 367, 671, 315, 574, 9420, 288, 916, 1228, 8, 585, 12, 5377, 14, 8757, 304, 355, 372, 791, 399, 356, 574, 14, 4097, 93, 288, 916, 1228, 8, 585, 12, 2783, 304, 355, 372, 791, 330, 356, 330, 772, 2143, 8, 585, 680, 2708, 360, 4371, 21004, 288, 916, 4550, 8, 5675, 8, 585, 12, 2560, 1360, 7500, 488, 2298, 355, 372, 791, 333, 356, 1318, 63, 466, 8, 585, 855, 1360, 29133, 93, 288, 916, 1228, 8, 585, 12, 769, 304, 355, 372, 15500, 1450, 8, 88, 9, 367, 671, 315, 574, 61, 288, 916, 1228, 8, 585, 12, 2197, 304, 355, 372, 791, 366, 356, 1455, 63, 602, 8, 585, 6769, 288, 916, 1228, 8, 585, 12, 1211, 304, 355, 372, 1211, 1332, 75, 12, 485, 1450, 8, 86, 430, 367, 1022, 12, 373, 315, 10849, 8, 585, 430, 288, 916, 1228, 8, 585, 12, 620, 304, 355, 862, 26, 490, 372, 1318, 63, 466, 8, 585, 9, 355, 871, 20872, 26, 490, 746, 25345, 7087, 547, 8, 85, 7, 33, 3696, 1059, 543, 283, 717, 399, 7, 2865, 13, 12292, 666, 1990, 3032, 370, 314, 2351, 2656, 283, 717, 399, 7, 6777, 883, 1454, 3877, 2649, 3326, 14, 221, 24413, 283, 717, 399, 7, 1095, 772, 2644, 2195, 1059, 334, 1558, 1990, 450, 82, 3171, 450, 574, 9, 288, 372, 574, 267, 372, 2022, 14, 4180, 1547, 1450, 8, 585, 395, 17658, 2687, 23324, 7596, 1333, 339, 347, 14404, 8, 277, 12, 574, 304, 267, 347, 909, 63, 3664, 8, 1113, 304, 288, 340, 822, 8, 1113, 9, 1137, 413, 26, 355, 372, 1559, 288, 314, 63, 498, 12, 314, 63, 585, 275, 2163, 8, 4611, 8, 1113, 430, 288, 340, 314, 63, 498, 508, 283, 307, 356, 355, 372, 2008, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 399, 356, 355, 372, 5377, 14, 8757, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 330, 356, 355, 372, 330, 772, 2708, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 333, 356, 355, 372, 17504, 8, 1589, 63, 585, 9, 288, 916, 314, 63, 498, 508, 283, 366, 356, 355, 372, 2198, 63, 602, 8, 1589, 63, 585, 9, 288, 372, 1559, 267, 372, 2022, 14, 3640, 8, 585, 12, 909, 63, 3664, 29, 785, 63, 3664, 9, 421, 199, 1730, 63, 1001, 63, 8349, 275, 32121, 6243, 7299, 342, 421, 199, 533, 30894, 7810, 4434, 8, 2806, 2141, 12, 8596, 4256, 304, 272, 408, 1563, 533, 367, 12184, 4079, 641, 10514, 10049, 1041, 339, 347, 636, 826, 721, 277, 12, 2536, 29, 403, 304, 267, 347, 641, 63, 873, 8, 277, 304, 288, 291, 14, 5540, 275, 715, 267, 17555, 2141, 855, 826, 721, 277, 12, 2536, 12, 641, 63, 873, 9, 267, 291, 14, 5540, 275, 756, 421, 199, 533, 12119, 4434, 8, 24117, 7810, 4434, 304, 272, 408, 2543, 1202, 370, 3550, 30023, 1125, 3788, 340, 12184, 787, 440, 272, 2808, 14, 221, 12823, 5139, 2040, 1586, 13, 2118, 2879, 370, 314, 2701, 2351, 272, 1325, 2449, 641, 4260, 14, 272, 408, 339, 347, 485, 1633, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 746, 6064, 360, 1589, 2351, 365, 18735, 2952, 949, 7565, 283, 2574, 283, 498, 1990, 663, 14, 221, 2494, 314, 7565, 63, 498, 641, 314, 283, 2574, 283, 3578, 370, 6020, 3747, 436, 7565, 2659, 272, 636, 8617, 363, 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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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 ]
avmarchenko/exa
exa/core/tests/test_editor.py
2
2573
# -*- coding: utf-8 -*- # Copyright (c) 2015-2018, Exa Analytics Development Team # Distributed under the terms of the Apache License 2.0 """ Tests for :mod:`~exa.core.editor` ################################# """ import os, six from unittest import TestCase from exa import Editor class TestEditor(TestCase): def setUp(self): """ Generate the file path to the exa.core.editor module (which will be used as the test for the :class:`~exa.core.editor.Editor` class that it provides). """ self.path = os.path.abspath(os.path.join(os.path.abspath(__file__), "../../editor.py")) with open(self.path) as f: self.lines = f.readlines() self.fl = Editor.from_file(self.path) def test_loaders(self): """ The editor provides there different methods for instantiation; from a file on disk, from a file stream, or from a string. """ fl = Editor.from_file(self.path) with open(self.path) as f: tm = Editor.from_stream(f) f.seek(0) tr = Editor.from_string(f.read()) self.assertTrue(len(self.lines) == len(fl) == len(tm) == len(tr)) self.assertTrue(all(fl[i] == tm[i] == tr[i] for i in range(len(self.lines)))) def test_find_regex(self): od = self.fl.find('Args:') self.assertIsInstance(od, list) self.assertIsInstance(od[0], tuple) self.assertTrue(len(od) == 16) self.assertTrue(self.fl.cursor == 0) n0, line0 = self.fl.find_next('Args:') self.assertIsInstance(n0, int) self.assertIsInstance(line0, six.string_types) self.assertIn(n0, od[0]) self.assertTrue(self.fl.cursor > 0) n1, line1 = self.fl.find_next('Args:') self.assertTrue(n1 > n0) self.assertIsInstance(line1, six.string_types) self.assertIn(n1, od[1]) od1 = self.fl.regex('Args:') self.assertTrue(od == od1) # True in this case; depends on regex used def test_insert_format_plus(self): n = len(self.fl) lines = {0: '{INSERTED}'} self.fl.insert(lines) self.assertTrue(len(self.fl) == n + 1) self.assertTrue(self.fl[0] == lines[0]) self.fl.delete_lines(range(5, len(self.fl))) self.assertTrue(len(self.fl) == 5) self.assertTrue(len(self.fl.variables) == 1) formatted = self.fl.format(INSERTED='replaced').splitlines() self.assertTrue(formatted[0] == 'replaced') del self.fl[0] self.assertTrue(len(self.fl) == 4)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6900, 13, 12682, 12, 1316, 65, 14279, 7769, 15290, 11682, 199, 3, 17484, 1334, 314, 2895, 402, 314, 3668, 844, 499, 14, 16, 199, 624, 199, 2925, 367, 520, 1494, 6054, 476, 65, 14, 1018, 14, 7515, 64, 199, 1371, 3, 199, 624, 199, 646, 747, 12, 3816, 199, 504, 2882, 492, 7640, 199, 504, 444, 65, 492, 30318, 421, 199, 533, 1379, 10423, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 408, 267, 7958, 314, 570, 931, 370, 314, 444, 65, 14, 1018, 14, 7515, 859, 334, 6777, 911, 506, 1202, 465, 267, 314, 511, 367, 314, 520, 533, 6054, 476, 65, 14, 1018, 14, 7515, 14, 10423, 64, 1021, 626, 652, 6571, 680, 267, 408, 267, 291, 14, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 3460, 493, 10139, 298, 9707, 7515, 14, 647, 2237, 267, 543, 1551, 8, 277, 14, 515, 9, 465, 289, 26, 288, 291, 14, 1278, 275, 289, 14, 9684, 342, 267, 291, 14, 2327, 275, 30318, 14, 504, 63, 493, 8, 277, 14, 515, 9, 339, 347, 511, 63, 16370, 8, 277, 304, 267, 408, 267, 710, 8823, 6571, 2337, 3365, 3102, 367, 26621, 27, 687, 282, 267, 570, 641, 4543, 12, 687, 282, 570, 2547, 12, 503, 687, 282, 1059, 14, 267, 408, 267, 2717, 275, 30318, 14, 504, 63, 493, 8, 277, 14, 515, 9, 267, 543, 1551, 8, 277, 14, 515, 9, 465, 289, 26, 288, 7352, 275, 30318, 14, 504, 63, 1745, 8, 70, 9, 288, 289, 14, 5507, 8, 16, 9, 288, 5651, 275, 30318, 14, 504, 63, 875, 8, 70, 14, 739, 1012, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 1278, 9, 508, 822, 8, 2327, 9, 508, 822, 8, 7574, 9, 508, 822, 8, 454, 430, 267, 291, 14, 1815, 8, 452, 8, 2327, 59, 73, 61, 508, 7352, 59, 73, 61, 508, 5651, 59, 73, 61, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1278, 7845, 339, 347, 511, 63, 1623, 63, 3821, 8, 277, 304, 267, 14467, 275, 291, 14, 2327, 14, 1623, 360, 6213, 10993, 267, 291, 14, 6926, 8, 364, 12, 769, 9, 267, 291, 14, 6926, 8, 364, 59, 16, 467, 2008, 9, 267, 291, 14, 1815, 8, 552, 8, 364, 9, 508, 3193, 9, 267, 291, 14, 1815, 8, 277, 14, 2327, 14, 3937, 508, 378, 9, 267, 302, 16, 12, 1004, 16, 275, 291, 14, 2327, 14, 1623, 63, 2184, 360, 6213, 10993, 267, 291, 14, 6926, 8, 78, 16, 12, 1109, 9, 267, 291, 14, 6926, 8, 604, 16, 12, 3816, 14, 875, 63, 1313, 9, 267, 291, 14, 4080, 8, 78, 16, 12, 14467, 59, 16, 566, 267, 291, 14, 1815, 8, 277, 14, 2327, 14, 3937, 690, 378, 9, 267, 302, 17, 12, 1004, 17, 275, 291, 14, 2327, 14, 1623, 63, 2184, 360, 6213, 10993, 267, 291, 14, 1815, 8, 78, 17, 690, 302, 16, 9, 267, 291, 14, 6926, 8, 604, 17, 12, 3816, 14, 875, 63, 1313, 9, 267, 291, 14, 4080, 8, 78, 17, 12, 14467, 59, 17, 566, 267, 14467, 17, 275, 291, 14, 2327, 14, 3821, 360, 6213, 10993, 267, 291, 14, 1815, 8, 364, 508, 14467, 17, 9, 259, 327, 715, 315, 642, 1930, 27, 8350, 641, 5163, 1202, 339, 347, 511, 63, 3176, 63, 908, 63, 6666, 8, 277, 304, 267, 302, 275, 822, 8, 277, 14, 2327, 9, 267, 2385, 275, 469, 16, 26, 5041, 10258, 1149, 93, 936, 267, 291, 14, 2327, 14, 3176, 8, 1278, 9, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 9, 508, 302, 435, 413, 9, 267, 291, 14, 1815, 8, 277, 14, 2327, 59, 16, 61, 508, 2385, 59, 16, 566, 267, 291, 14, 2327, 14, 1807, 63, 1278, 8, 1842, 8, 21, 12, 822, 8, 277, 14, 2327, 1724, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 9, 508, 959, 9, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 14, 3669, 9, 508, 413, 9, 267, 7871, 275, 291, 14, 2327, 14, 908, 8, 10258, 1149, 534, 31473, 1959, 7644, 342, 267, 291, 14, 1815, 8, 15317, 59, 16, 61, 508, 283, 31473, 358, 267, 2150, 291, 14, 2327, 59, 16, 61, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 9, 508, 841, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6900, 13, 12682, 12, 1316, 65, 14279, 7769, 15290, 11682, 199, 3, 17484, 1334, 314, 2895, 402, 314, 3668, 844, 499, 14, 16, 199, 624, 199, 2925, 367, 520, 1494, 6054, 476, 65, 14, 1018, 14, 7515, 64, 199, 1371, 3, 199, 624, 199, 646, 747, 12, 3816, 199, 504, 2882, 492, 7640, 199, 504, 444, 65, 492, 30318, 421, 199, 533, 1379, 10423, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 408, 267, 7958, 314, 570, 931, 370, 314, 444, 65, 14, 1018, 14, 7515, 859, 334, 6777, 911, 506, 1202, 465, 267, 314, 511, 367, 314, 520, 533, 6054, 476, 65, 14, 1018, 14, 7515, 14, 10423, 64, 1021, 626, 652, 6571, 680, 267, 408, 267, 291, 14, 515, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 3460, 493, 10139, 298, 9707, 7515, 14, 647, 2237, 267, 543, 1551, 8, 277, 14, 515, 9, 465, 289, 26, 288, 291, 14, 1278, 275, 289, 14, 9684, 342, 267, 291, 14, 2327, 275, 30318, 14, 504, 63, 493, 8, 277, 14, 515, 9, 339, 347, 511, 63, 16370, 8, 277, 304, 267, 408, 267, 710, 8823, 6571, 2337, 3365, 3102, 367, 26621, 27, 687, 282, 267, 570, 641, 4543, 12, 687, 282, 570, 2547, 12, 503, 687, 282, 1059, 14, 267, 408, 267, 2717, 275, 30318, 14, 504, 63, 493, 8, 277, 14, 515, 9, 267, 543, 1551, 8, 277, 14, 515, 9, 465, 289, 26, 288, 7352, 275, 30318, 14, 504, 63, 1745, 8, 70, 9, 288, 289, 14, 5507, 8, 16, 9, 288, 5651, 275, 30318, 14, 504, 63, 875, 8, 70, 14, 739, 1012, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 1278, 9, 508, 822, 8, 2327, 9, 508, 822, 8, 7574, 9, 508, 822, 8, 454, 430, 267, 291, 14, 1815, 8, 452, 8, 2327, 59, 73, 61, 508, 7352, 59, 73, 61, 508, 5651, 59, 73, 61, 367, 284, 315, 1425, 8, 552, 8, 277, 14, 1278, 7845, 339, 347, 511, 63, 1623, 63, 3821, 8, 277, 304, 267, 14467, 275, 291, 14, 2327, 14, 1623, 360, 6213, 10993, 267, 291, 14, 6926, 8, 364, 12, 769, 9, 267, 291, 14, 6926, 8, 364, 59, 16, 467, 2008, 9, 267, 291, 14, 1815, 8, 552, 8, 364, 9, 508, 3193, 9, 267, 291, 14, 1815, 8, 277, 14, 2327, 14, 3937, 508, 378, 9, 267, 302, 16, 12, 1004, 16, 275, 291, 14, 2327, 14, 1623, 63, 2184, 360, 6213, 10993, 267, 291, 14, 6926, 8, 78, 16, 12, 1109, 9, 267, 291, 14, 6926, 8, 604, 16, 12, 3816, 14, 875, 63, 1313, 9, 267, 291, 14, 4080, 8, 78, 16, 12, 14467, 59, 16, 566, 267, 291, 14, 1815, 8, 277, 14, 2327, 14, 3937, 690, 378, 9, 267, 302, 17, 12, 1004, 17, 275, 291, 14, 2327, 14, 1623, 63, 2184, 360, 6213, 10993, 267, 291, 14, 1815, 8, 78, 17, 690, 302, 16, 9, 267, 291, 14, 6926, 8, 604, 17, 12, 3816, 14, 875, 63, 1313, 9, 267, 291, 14, 4080, 8, 78, 17, 12, 14467, 59, 17, 566, 267, 14467, 17, 275, 291, 14, 2327, 14, 3821, 360, 6213, 10993, 267, 291, 14, 1815, 8, 364, 508, 14467, 17, 9, 259, 327, 715, 315, 642, 1930, 27, 8350, 641, 5163, 1202, 339, 347, 511, 63, 3176, 63, 908, 63, 6666, 8, 277, 304, 267, 302, 275, 822, 8, 277, 14, 2327, 9, 267, 2385, 275, 469, 16, 26, 5041, 10258, 1149, 93, 936, 267, 291, 14, 2327, 14, 3176, 8, 1278, 9, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 9, 508, 302, 435, 413, 9, 267, 291, 14, 1815, 8, 277, 14, 2327, 59, 16, 61, 508, 2385, 59, 16, 566, 267, 291, 14, 2327, 14, 1807, 63, 1278, 8, 1842, 8, 21, 12, 822, 8, 277, 14, 2327, 1724, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 9, 508, 959, 9, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 14, 3669, 9, 508, 413, 9, 267, 7871, 275, 291, 14, 2327, 14, 908, 8, 10258, 1149, 534, 31473, 1959, 7644, 342, 267, 291, 14, 1815, 8, 15317, 59, 16, 61, 508, 283, 31473, 358, 267, 2150, 291, 14, 2327, 59, 16, 61, 267, 291, 14, 1815, 8, 552, 8, 277, 14, 2327, 9, 508, 841, 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, 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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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 ]
petemounce/ansible-modules-extras
system/selinux_permissive.py
88
4067
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Michael Scherer <misc@zarb.org> # inspired by code of github.com/dandiker/ # # 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: selinux_permissive short_description: Change permissive domain in SELinux policy description: - Add and remove domain from the list of permissive domain. version_added: "2.0" options: domain: description: - "the domain that will be added or removed from the list of permissive domains" required: true permissive: description: - "indicate if the domain should or should not be set as permissive" required: true choices: [ 'True', 'False' ] no_reload: description: - "automatically reload the policy after a change" - "default is set to 'false' as that's what most people would want after changing one domain" - "Note that this doesn't work on older version of the library (example EL 6), the module will silently ignore it in this case" required: false default: False choices: [ 'True', 'False' ] store: description: - "name of the SELinux policy store to use" required: false default: null notes: - Requires a version of SELinux recent enough ( ie EL 6 or newer ) requirements: [ policycoreutils-python ] author: Michael Scherer <misc@zarb.org> ''' EXAMPLES = ''' - selinux_permissive: name=httpd_t permissive=true ''' HAVE_SEOBJECT = False try: import seobject HAVE_SEOBJECT = True except ImportError: pass def main(): module = AnsibleModule( argument_spec=dict( domain=dict(aliases=['name'], required=True), store=dict(required=False, default=''), permissive=dict(type='bool', required=True), no_reload=dict(type='bool', required=False, default=False), ), supports_check_mode=True ) # global vars changed = False store = module.params['store'] permissive = module.params['permissive'] domain = module.params['domain'] no_reload = module.params['no_reload'] if not HAVE_SEOBJECT: module.fail_json(changed=False, msg="policycoreutils-python required for this module") try: permissive_domains = seobject.permissiveRecords(store) except ValueError, e: module.fail_json(domain=domain, msg=str(e)) # not supported on EL 6 if 'set_reload' in dir(permissive_domains): permissive_domains.set_reload(not no_reload) try: all_domains = permissive_domains.get_all() except ValueError, e: module.fail_json(domain=domain, msg=str(e)) if permissive: if domain not in all_domains: if not module.check_mode: try: permissive_domains.add(domain) except ValueError, e: module.fail_json(domain=domain, msg=str(e)) changed = True else: if domain in all_domains: if not module.check_mode: try: permissive_domains.delete(domain) except ValueError, e: module.fail_json(domain=domain, msg=str(e)) changed = True module.exit_json(changed=changed, store=store, permissive=permissive, domain=domain) ################################################# # import module snippets from ansible.module_utils.basic import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 3, 315, 8721, 581, 701, 1233, 402, 12869, 14, 957, 15, 24863, 328, 2570, 15, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 542, 5135, 63, 529, 32237, 199, 3612, 63, 1802, 26, 7743, 1126, 32237, 2881, 315, 428, 2901, 7226, 4592, 199, 1802, 26, 523, 446, 2654, 436, 2813, 2881, 687, 314, 769, 402, 1126, 32237, 2881, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 523, 2881, 26, 272, 1369, 26, 267, 446, 298, 1589, 2881, 626, 911, 506, 3483, 503, 4829, 687, 314, 769, 402, 1126, 32237, 14006, 2, 272, 1415, 26, 2549, 523, 1126, 32237, 26, 272, 1369, 26, 267, 446, 298, 3558, 1411, 340, 314, 2881, 1077, 503, 1077, 440, 506, 663, 465, 1126, 32237, 2, 272, 1415, 26, 2549, 272, 3415, 26, 359, 283, 549, 297, 283, 797, 7, 1622, 523, 949, 63, 9233, 26, 272, 1369, 26, 267, 446, 298, 2495, 17174, 13101, 314, 4592, 2410, 282, 1570, 2, 267, 446, 298, 885, 365, 663, 370, 283, 3910, 7, 465, 626, 1159, 4052, 4750, 13135, 3955, 2934, 2410, 13729, 1373, 2881, 2, 267, 446, 298, 7443, 626, 642, 3181, 1133, 1736, 641, 12731, 1015, 402, 314, 3555, 334, 2694, 22325, 1227, 395, 314, 859, 911, 18030, 3686, 652, 315, 642, 1930, 2, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 3415, 26, 359, 283, 549, 297, 283, 797, 7, 1622, 523, 3877, 26, 272, 1369, 26, 489, 446, 298, 354, 402, 314, 428, 2901, 7226, 4592, 3877, 370, 675, 2, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 5983, 26, 272, 446, 15127, 282, 1015, 402, 428, 2901, 7226, 8058, 8321, 334, 13446, 22325, 1227, 503, 15666, 776, 199, 7538, 26, 359, 4592, 1018, 1208, 13, 1548, 1622, 199, 2502, 26, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 542, 5135, 63, 529, 32237, 26, 536, 29, 21594, 63, 84, 1126, 32237, 29, 2052, 199, 2344, 199, 199, 10767, 63, 899, 9868, 275, 756, 199, 893, 26, 272, 492, 542, 785, 272, 25227, 63, 899, 9868, 275, 715, 199, 2590, 3545, 26, 272, 986, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 2881, 29, 807, 8, 8602, 2968, 354, 995, 1415, 29, 549, 395, 288, 3877, 29, 807, 8, 2427, 29, 797, 12, 849, 534, 659, 288, 1126, 32237, 29, 807, 8, 466, 534, 2245, 297, 1415, 29, 549, 395, 288, 949, 63, 9233, 29, 807, 8, 466, 534, 2245, 297, 1415, 29, 797, 12, 849, 29, 797, 395, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 339, 327, 2288, 6802, 272, 2896, 275, 756, 272, 3877, 275, 859, 14, 1162, 459, 1617, 418, 272, 1126, 32237, 275, 859, 14, 1162, 459, 529, 32237, 418, 272, 2881, 275, 859, 14, 1162, 459, 2261, 418, 272, 949, 63, 9233, 275, 859, 14, 1162, 459, 889, 63, 9233, 418, 339, 340, 440, 25227, 63, 899, 9868, 26, 267, 859, 14, 1633, 63, 1001, 8, 2489, 29, 797, 12, 1499, 628, 3185, 1018, 1208, 13, 1548, 1415, 367, 642, 859, 531, 339, 862, 26, 267, 1126, 32237, 63, 9756, 275, 542, 785, 14, 529, 32237, 14941, 8, 1617, 9, 272, 871, 1722, 12, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 339, 327, 440, 3748, 641, 22325, 1227, 272, 340, 283, 409, 63, 9233, 7, 315, 2935, 8, 529, 32237, 63, 9756, 304, 267, 1126, 32237, 63, 9756, 14, 409, 63, 9233, 8, 1397, 949, 63, 9233, 9, 339, 862, 26, 267, 1006, 63, 9756, 275, 1126, 32237, 63, 9756, 14, 362, 63, 452, 342, 272, 871, 1722, 12, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 339, 340, 1126, 32237, 26, 267, 340, 2881, 440, 315, 1006, 63, 9756, 26, 288, 340, 440, 859, 14, 1074, 63, 632, 26, 355, 862, 26, 490, 1126, 32237, 63, 9756, 14, 525, 8, 2261, 9, 355, 871, 1722, 12, 325, 26, 490, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 288, 2896, 275, 715, 272, 587, 26, 267, 340, 2881, 315, 1006, 63, 9756, 26, 288, 340, 440, 859, 14, 1074, 63, 632, 26, 355, 862, 26, 490, 1126, 32237, 63, 9756, 14, 1807, 8, 2261, 9, 355, 871, 1722, 12, 325, 26, 490, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 288, 2896, 275, 715, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 3877, 29, 1617, 12, 2151, 1126, 32237, 29, 529, 32237, 12, 2881, 29, 2261, 9, 421, 199, 22529, 3, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 3, 315, 8721, 581, 701, 1233, 402, 12869, 14, 957, 15, 24863, 328, 2570, 15, 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, 8948, 275, 1449, 199, 2595, 199, 578, 26, 542, 5135, 63, 529, 32237, 199, 3612, 63, 1802, 26, 7743, 1126, 32237, 2881, 315, 428, 2901, 7226, 4592, 199, 1802, 26, 523, 446, 2654, 436, 2813, 2881, 687, 314, 769, 402, 1126, 32237, 2881, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 523, 2881, 26, 272, 1369, 26, 267, 446, 298, 1589, 2881, 626, 911, 506, 3483, 503, 4829, 687, 314, 769, 402, 1126, 32237, 14006, 2, 272, 1415, 26, 2549, 523, 1126, 32237, 26, 272, 1369, 26, 267, 446, 298, 3558, 1411, 340, 314, 2881, 1077, 503, 1077, 440, 506, 663, 465, 1126, 32237, 2, 272, 1415, 26, 2549, 272, 3415, 26, 359, 283, 549, 297, 283, 797, 7, 1622, 523, 949, 63, 9233, 26, 272, 1369, 26, 267, 446, 298, 2495, 17174, 13101, 314, 4592, 2410, 282, 1570, 2, 267, 446, 298, 885, 365, 663, 370, 283, 3910, 7, 465, 626, 1159, 4052, 4750, 13135, 3955, 2934, 2410, 13729, 1373, 2881, 2, 267, 446, 298, 7443, 626, 642, 3181, 1133, 1736, 641, 12731, 1015, 402, 314, 3555, 334, 2694, 22325, 1227, 395, 314, 859, 911, 18030, 3686, 652, 315, 642, 1930, 2, 272, 1415, 26, 3055, 272, 849, 26, 756, 272, 3415, 26, 359, 283, 549, 297, 283, 797, 7, 1622, 523, 3877, 26, 272, 1369, 26, 489, 446, 298, 354, 402, 314, 428, 2901, 7226, 4592, 3877, 370, 675, 2, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 5983, 26, 272, 446, 15127, 282, 1015, 402, 428, 2901, 7226, 8058, 8321, 334, 13446, 22325, 1227, 503, 15666, 776, 199, 7538, 26, 359, 4592, 1018, 1208, 13, 1548, 1622, 199, 2502, 26, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 542, 5135, 63, 529, 32237, 26, 536, 29, 21594, 63, 84, 1126, 32237, 29, 2052, 199, 2344, 199, 199, 10767, 63, 899, 9868, 275, 756, 199, 893, 26, 272, 492, 542, 785, 272, 25227, 63, 899, 9868, 275, 715, 199, 2590, 3545, 26, 272, 986, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 2881, 29, 807, 8, 8602, 2968, 354, 995, 1415, 29, 549, 395, 288, 3877, 29, 807, 8, 2427, 29, 797, 12, 849, 534, 659, 288, 1126, 32237, 29, 807, 8, 466, 534, 2245, 297, 1415, 29, 549, 395, 288, 949, 63, 9233, 29, 807, 8, 466, 534, 2245, 297, 1415, 29, 797, 12, 849, 29, 797, 395, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 272, 776, 339, 327, 2288, 6802, 272, 2896, 275, 756, 272, 3877, 275, 859, 14, 1162, 459, 1617, 418, 272, 1126, 32237, 275, 859, 14, 1162, 459, 529, 32237, 418, 272, 2881, 275, 859, 14, 1162, 459, 2261, 418, 272, 949, 63, 9233, 275, 859, 14, 1162, 459, 889, 63, 9233, 418, 339, 340, 440, 25227, 63, 899, 9868, 26, 267, 859, 14, 1633, 63, 1001, 8, 2489, 29, 797, 12, 1499, 628, 3185, 1018, 1208, 13, 1548, 1415, 367, 642, 859, 531, 339, 862, 26, 267, 1126, 32237, 63, 9756, 275, 542, 785, 14, 529, 32237, 14941, 8, 1617, 9, 272, 871, 1722, 12, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 339, 327, 440, 3748, 641, 22325, 1227, 272, 340, 283, 409, 63, 9233, 7, 315, 2935, 8, 529, 32237, 63, 9756, 304, 267, 1126, 32237, 63, 9756, 14, 409, 63, 9233, 8, 1397, 949, 63, 9233, 9, 339, 862, 26, 267, 1006, 63, 9756, 275, 1126, 32237, 63, 9756, 14, 362, 63, 452, 342, 272, 871, 1722, 12, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 339, 340, 1126, 32237, 26, 267, 340, 2881, 440, 315, 1006, 63, 9756, 26, 288, 340, 440, 859, 14, 1074, 63, 632, 26, 355, 862, 26, 490, 1126, 32237, 63, 9756, 14, 525, 8, 2261, 9, 355, 871, 1722, 12, 325, 26, 490, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 288, 2896, 275, 715, 272, 587, 26, 267, 340, 2881, 315, 1006, 63, 9756, 26, 288, 340, 440, 859, 14, 1074, 63, 632, 26, 355, 862, 26, 490, 1126, 32237, 63, 9756, 14, 1807, 8, 2261, 9, 355, 871, 1722, 12, 325, 26, 490, 859, 14, 1633, 63, 1001, 8, 2261, 29, 2261, 12, 1499, 29, 495, 8, 69, 430, 288, 2896, 275, 715, 339, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 3877, 29, 1617, 12, 2151, 1126, 32237, 29, 529, 32237, 12, 2881, 29, 2261, 9, 421, 199, 22529, 3, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 973, 342, 199, 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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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, 0, 0, 0, 0, 0, 0, 0 ]
denbedilov/ATTENDER
server/attender-mobile/lib/requests/packages/urllib3/util/connection.py
252
3265
import socket try: from select import poll, POLLIN except ImportError: # `poll` doesn't exist on OSX and other platforms poll = False try: from select import select except ImportError: # `select` doesn't exist on AppEngine. select = False def is_connection_dropped(conn): # Platform-specific """ Returns True if the connection is dropped and should be closed. :param conn: :class:`httplib.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycling transparently for us. """ sock = getattr(conn, 'sock', False) if sock is False: # Platform-specific: AppEngine return False if sock is None: # Connection already closed (such as by httplib). return True if not poll: if not select: # Platform-specific: AppEngine return False try: return select([sock], [], [], 0.0)[0] except socket.error: return True # This version is better on platforms that support it. p = poll() p.register(sock, POLLIN) for (fno, ev) in p.poll(0.0): if fno == sock.fileno(): # Either data is buffered (bad), or the connection is dropped. return True # This function is copied from socket.py in the Python 2.7 standard # library test suite. Added to its signature is only `socket_options`. def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, socket_options=None): """Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the optional *timeout* parameter will set the timeout on the socket instance before attempting to connect. If no *timeout* is supplied, the global default timeout setting returned by :func:`getdefaulttimeout` is used. If *source_address* is set it must be a tuple of (host, port) for the socket to bind as a source address before making the connection. An host of '' or port 0 tells the OS to use the default. """ host, port = address err = None for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res sock = None try: sock = socket.socket(af, socktype, proto) # If provided, set socket level options before connecting. # This is the only addition urllib3 makes to this function. _set_socket_options(sock, socket_options) if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT: sock.settimeout(timeout) if source_address: sock.bind(source_address) sock.connect(sa) return sock except socket.error as _: err = _ if sock is not None: sock.close() if err is not None: raise err else: raise socket.error("getaddrinfo returns an empty list") def _set_socket_options(sock, options): if options is None: return for opt in options: sock.setsockopt(*opt)
mit
[ 646, 2838, 199, 893, 26, 272, 687, 3504, 492, 11271, 12, 25480, 6143, 199, 2590, 3545, 26, 221, 327, 658, 6843, 64, 3181, 1133, 2187, 641, 32144, 436, 1163, 10677, 272, 11271, 275, 756, 272, 862, 26, 267, 687, 3504, 492, 3504, 272, 871, 3545, 26, 221, 327, 658, 2416, 64, 3181, 1133, 2187, 641, 4693, 8524, 14, 267, 3504, 275, 756, 421, 199, 318, 365, 63, 2105, 63, 27557, 8, 1631, 304, 221, 327, 16078, 13, 6100, 272, 408, 272, 1803, 715, 340, 314, 1950, 365, 17481, 436, 1077, 506, 6876, 14, 339, 520, 635, 2557, 26, 267, 520, 533, 1705, 12942, 14, 19114, 64, 909, 14, 339, 3390, 26, 2104, 10677, 2839, 4693, 8524, 12, 642, 911, 3544, 372, 1124, 797, 1040, 370, 272, 4691, 314, 4298, 2429, 1950, 295, 1480, 429, 316, 17265, 590, 367, 2739, 14, 272, 408, 272, 6771, 275, 2519, 8, 1631, 12, 283, 5096, 297, 756, 9, 272, 340, 6771, 365, 756, 26, 221, 327, 16078, 13, 6100, 26, 4693, 8524, 267, 372, 756, 272, 340, 6771, 365, 488, 26, 221, 327, 8113, 2575, 6876, 334, 10180, 465, 701, 8809, 680, 267, 372, 715, 339, 340, 440, 11271, 26, 267, 340, 440, 3504, 26, 221, 327, 16078, 13, 6100, 26, 4693, 8524, 288, 372, 756, 398, 862, 26, 288, 372, 3504, 779, 5096, 467, 990, 990, 378, 14, 16, 2788, 16, 61, 267, 871, 2838, 14, 705, 26, 288, 372, 715, 339, 327, 961, 1015, 365, 8034, 641, 10677, 626, 2291, 652, 14, 272, 299, 275, 11271, 342, 272, 299, 14, 2683, 8, 5096, 12, 25480, 6143, 9, 272, 367, 334, 70, 889, 12, 8145, 9, 315, 299, 14, 6843, 8, 16, 14, 16, 304, 267, 340, 289, 889, 508, 6771, 14, 9843, 837, 288, 327, 13083, 666, 365, 20224, 334, 4087, 395, 503, 314, 1950, 365, 17481, 14, 288, 372, 715, 421, 199, 3, 961, 805, 365, 8876, 687, 2838, 14, 647, 315, 314, 2018, 499, 14, 23, 4465, 199, 3, 3555, 511, 5241, 14, 16230, 370, 2399, 4955, 365, 1454, 658, 3450, 63, 1419, 2313, 199, 318, 1218, 63, 2105, 8, 1562, 12, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 1993, 1350, 63, 1562, 29, 403, 12, 2838, 63, 1419, 29, 403, 304, 272, 408, 8631, 370, 627, 1562, 10, 436, 372, 314, 2838, 909, 14, 339, 1448, 23329, 805, 14, 221, 15175, 370, 627, 1562, 10, 334, 65, 499, 13, 2960, 15475, 1102, 12, 272, 1844, 9719, 9, 436, 372, 314, 2838, 909, 14, 221, 31755, 314, 2716, 272, 627, 2593, 10, 2725, 911, 663, 314, 2653, 641, 314, 2838, 1256, 272, 2544, 19595, 370, 4907, 14, 221, 982, 949, 627, 2593, 10, 365, 6841, 12, 314, 272, 2288, 849, 2653, 4260, 2138, 701, 520, 1532, 1705, 362, 885, 2593, 64, 272, 365, 1202, 14, 221, 982, 627, 1365, 63, 1562, 10, 365, 663, 652, 1471, 506, 282, 2008, 402, 334, 1102, 12, 1844, 9, 272, 367, 314, 2838, 370, 5398, 465, 282, 1350, 2287, 2544, 10663, 314, 1950, 14, 272, 1626, 1591, 402, 2125, 503, 1844, 378, 26544, 314, 4403, 370, 675, 314, 849, 14, 272, 408, 339, 1591, 12, 1844, 275, 2287, 272, 2329, 275, 488, 272, 367, 522, 315, 2838, 14, 27606, 815, 8, 1102, 12, 1844, 12, 378, 12, 2838, 14, 9469, 63, 9484, 304, 267, 15871, 12, 6771, 466, 12, 4104, 12, 883, 265, 354, 12, 2937, 275, 522, 267, 6771, 275, 488, 267, 862, 26, 288, 6771, 275, 2838, 14, 3450, 8, 2756, 12, 6771, 466, 12, 4104, 9, 953, 327, 982, 2741, 12, 663, 2838, 2166, 1511, 2544, 18170, 14, 288, 327, 961, 365, 314, 1454, 10234, 4011, 19, 7704, 370, 642, 805, 14, 288, 485, 409, 63, 3450, 63, 1419, 8, 5096, 12, 2838, 63, 1419, 9, 953, 340, 2653, 365, 440, 2838, 423, 13808, 63, 3472, 63, 8899, 26, 355, 6771, 14, 24630, 8, 2593, 9, 288, 340, 1350, 63, 1562, 26, 355, 6771, 14, 3409, 8, 1365, 63, 1562, 9, 288, 6771, 14, 2242, 8, 2231, 9, 288, 372, 6771, 398, 871, 2838, 14, 705, 465, 24700, 288, 2329, 275, 485, 288, 340, 6771, 365, 440, 488, 26, 355, 6771, 14, 1600, 342, 339, 340, 2329, 365, 440, 488, 26, 267, 746, 2329, 272, 587, 26, 267, 746, 2838, 14, 705, 480, 27606, 815, 2529, 376, 2701, 769, 531, 421, 199, 318, 485, 409, 63, 3450, 63, 1419, 8, 5096, 12, 1511, 304, 272, 340, 1511, 365, 488, 26, 267, 372, 339, 367, 2450, 315, 1511, 26, 267, 6771, 14, 27689, 2031, 2992, 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 ]
[ 2838, 199, 893, 26, 272, 687, 3504, 492, 11271, 12, 25480, 6143, 199, 2590, 3545, 26, 221, 327, 658, 6843, 64, 3181, 1133, 2187, 641, 32144, 436, 1163, 10677, 272, 11271, 275, 756, 272, 862, 26, 267, 687, 3504, 492, 3504, 272, 871, 3545, 26, 221, 327, 658, 2416, 64, 3181, 1133, 2187, 641, 4693, 8524, 14, 267, 3504, 275, 756, 421, 199, 318, 365, 63, 2105, 63, 27557, 8, 1631, 304, 221, 327, 16078, 13, 6100, 272, 408, 272, 1803, 715, 340, 314, 1950, 365, 17481, 436, 1077, 506, 6876, 14, 339, 520, 635, 2557, 26, 267, 520, 533, 1705, 12942, 14, 19114, 64, 909, 14, 339, 3390, 26, 2104, 10677, 2839, 4693, 8524, 12, 642, 911, 3544, 372, 1124, 797, 1040, 370, 272, 4691, 314, 4298, 2429, 1950, 295, 1480, 429, 316, 17265, 590, 367, 2739, 14, 272, 408, 272, 6771, 275, 2519, 8, 1631, 12, 283, 5096, 297, 756, 9, 272, 340, 6771, 365, 756, 26, 221, 327, 16078, 13, 6100, 26, 4693, 8524, 267, 372, 756, 272, 340, 6771, 365, 488, 26, 221, 327, 8113, 2575, 6876, 334, 10180, 465, 701, 8809, 680, 267, 372, 715, 339, 340, 440, 11271, 26, 267, 340, 440, 3504, 26, 221, 327, 16078, 13, 6100, 26, 4693, 8524, 288, 372, 756, 398, 862, 26, 288, 372, 3504, 779, 5096, 467, 990, 990, 378, 14, 16, 2788, 16, 61, 267, 871, 2838, 14, 705, 26, 288, 372, 715, 339, 327, 961, 1015, 365, 8034, 641, 10677, 626, 2291, 652, 14, 272, 299, 275, 11271, 342, 272, 299, 14, 2683, 8, 5096, 12, 25480, 6143, 9, 272, 367, 334, 70, 889, 12, 8145, 9, 315, 299, 14, 6843, 8, 16, 14, 16, 304, 267, 340, 289, 889, 508, 6771, 14, 9843, 837, 288, 327, 13083, 666, 365, 20224, 334, 4087, 395, 503, 314, 1950, 365, 17481, 14, 288, 372, 715, 421, 199, 3, 961, 805, 365, 8876, 687, 2838, 14, 647, 315, 314, 2018, 499, 14, 23, 4465, 199, 3, 3555, 511, 5241, 14, 16230, 370, 2399, 4955, 365, 1454, 658, 3450, 63, 1419, 2313, 199, 318, 1218, 63, 2105, 8, 1562, 12, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 1993, 1350, 63, 1562, 29, 403, 12, 2838, 63, 1419, 29, 403, 304, 272, 408, 8631, 370, 627, 1562, 10, 436, 372, 314, 2838, 909, 14, 339, 1448, 23329, 805, 14, 221, 15175, 370, 627, 1562, 10, 334, 65, 499, 13, 2960, 15475, 1102, 12, 272, 1844, 9719, 9, 436, 372, 314, 2838, 909, 14, 221, 31755, 314, 2716, 272, 627, 2593, 10, 2725, 911, 663, 314, 2653, 641, 314, 2838, 1256, 272, 2544, 19595, 370, 4907, 14, 221, 982, 949, 627, 2593, 10, 365, 6841, 12, 314, 272, 2288, 849, 2653, 4260, 2138, 701, 520, 1532, 1705, 362, 885, 2593, 64, 272, 365, 1202, 14, 221, 982, 627, 1365, 63, 1562, 10, 365, 663, 652, 1471, 506, 282, 2008, 402, 334, 1102, 12, 1844, 9, 272, 367, 314, 2838, 370, 5398, 465, 282, 1350, 2287, 2544, 10663, 314, 1950, 14, 272, 1626, 1591, 402, 2125, 503, 1844, 378, 26544, 314, 4403, 370, 675, 314, 849, 14, 272, 408, 339, 1591, 12, 1844, 275, 2287, 272, 2329, 275, 488, 272, 367, 522, 315, 2838, 14, 27606, 815, 8, 1102, 12, 1844, 12, 378, 12, 2838, 14, 9469, 63, 9484, 304, 267, 15871, 12, 6771, 466, 12, 4104, 12, 883, 265, 354, 12, 2937, 275, 522, 267, 6771, 275, 488, 267, 862, 26, 288, 6771, 275, 2838, 14, 3450, 8, 2756, 12, 6771, 466, 12, 4104, 9, 953, 327, 982, 2741, 12, 663, 2838, 2166, 1511, 2544, 18170, 14, 288, 327, 961, 365, 314, 1454, 10234, 4011, 19, 7704, 370, 642, 805, 14, 288, 485, 409, 63, 3450, 63, 1419, 8, 5096, 12, 2838, 63, 1419, 9, 953, 340, 2653, 365, 440, 2838, 423, 13808, 63, 3472, 63, 8899, 26, 355, 6771, 14, 24630, 8, 2593, 9, 288, 340, 1350, 63, 1562, 26, 355, 6771, 14, 3409, 8, 1365, 63, 1562, 9, 288, 6771, 14, 2242, 8, 2231, 9, 288, 372, 6771, 398, 871, 2838, 14, 705, 465, 24700, 288, 2329, 275, 485, 288, 340, 6771, 365, 440, 488, 26, 355, 6771, 14, 1600, 342, 339, 340, 2329, 365, 440, 488, 26, 267, 746, 2329, 272, 587, 26, 267, 746, 2838, 14, 705, 480, 27606, 815, 2529, 376, 2701, 769, 531, 421, 199, 318, 485, 409, 63, 3450, 63, 1419, 8, 5096, 12, 1511, 304, 272, 340, 1511, 365, 488, 26, 267, 372, 339, 367, 2450, 315, 1511, 26, 267, 6771, 14, 27689, 2031, 2992, 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, 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 ]
inirudebwoy/AutobahnPython
examples/twisted/wamp/rpc/timeservice/frontend.py
8
2292
############################################################################### # # The MIT License (MIT) # # Copyright (c) Tavendo GmbH # # 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. # ############################################################################### from os import environ from twisted.internet import reactor from twisted.internet.defer import inlineCallbacks from autobahn.twisted.wamp import ApplicationSession, ApplicationRunner class Component(ApplicationSession): """ An application component using the time service. """ @inlineCallbacks def onJoin(self, details): print("session attached") try: now = yield self.call(u'com.timeservice.now') except Exception as e: print("Error: {}".format(e)) else: print("Current time from time service: {}".format(now)) self.leave() def onDisconnect(self): print("disconnected") reactor.stop() if __name__ == '__main__': runner = ApplicationRunner( environ.get("AUTOBAHN_DEMO_ROUTER", u"ws://127.0.0.1:8080/ws"), u"crossbardemo", debug_wamp=False, # optional; log many WAMP details debug=False, # optional; log even more details ) runner.run(Component)
mit
[ 11490, 199, 3, 199, 3, 710, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 377, 1214, 500, 79, 23428, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 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, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 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, 1621, 199, 3, 2334, 4141, 14, 199, 3, 199, 11490, 199, 199, 504, 747, 492, 6160, 199, 504, 7390, 14, 4901, 492, 9655, 199, 504, 7390, 14, 4901, 14, 11610, 492, 8308, 17958, 199, 199, 504, 2599, 2470, 6164, 14, 12145, 14, 758, 311, 492, 13515, 4434, 12, 13515, 7446, 421, 199, 533, 12727, 8, 5039, 4434, 304, 272, 408, 272, 1626, 4223, 3931, 1808, 314, 900, 2435, 14, 272, 408, 339, 768, 24813, 272, 347, 641, 13005, 8, 277, 12, 2436, 304, 267, 870, 480, 1730, 10102, 531, 267, 862, 26, 288, 3063, 275, 1995, 291, 14, 1250, 8, 85, 7, 957, 14, 521, 1364, 14, 2131, 358, 267, 871, 2186, 465, 325, 26, 288, 870, 480, 547, 26, 8352, 908, 8, 69, 430, 267, 587, 26, 288, 870, 480, 5639, 900, 687, 900, 2435, 26, 8352, 908, 8, 2131, 430, 398, 291, 14, 12422, 342, 339, 347, 641, 16761, 8, 277, 304, 267, 870, 480, 27476, 531, 267, 9655, 14, 2379, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 7876, 275, 13515, 7446, 8, 267, 6160, 14, 362, 480, 13883, 4134, 23084, 63, 1093, 2679, 63, 19281, 401, 399, 2, 3569, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 15844, 15, 3569, 1288, 267, 399, 2, 7925, 1700, 8768, 401, 267, 3105, 63, 758, 311, 29, 797, 12, 221, 327, 2716, 27, 943, 5002, 644, 7089, 2436, 267, 3105, 29, 797, 12, 221, 327, 2716, 27, 943, 2755, 1655, 2436, 272, 776, 272, 7876, 14, 1065, 8, 7004, 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 ]
[ 199, 3, 199, 3, 710, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 377, 1214, 500, 79, 23428, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 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, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 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, 1621, 199, 3, 2334, 4141, 14, 199, 3, 199, 11490, 199, 199, 504, 747, 492, 6160, 199, 504, 7390, 14, 4901, 492, 9655, 199, 504, 7390, 14, 4901, 14, 11610, 492, 8308, 17958, 199, 199, 504, 2599, 2470, 6164, 14, 12145, 14, 758, 311, 492, 13515, 4434, 12, 13515, 7446, 421, 199, 533, 12727, 8, 5039, 4434, 304, 272, 408, 272, 1626, 4223, 3931, 1808, 314, 900, 2435, 14, 272, 408, 339, 768, 24813, 272, 347, 641, 13005, 8, 277, 12, 2436, 304, 267, 870, 480, 1730, 10102, 531, 267, 862, 26, 288, 3063, 275, 1995, 291, 14, 1250, 8, 85, 7, 957, 14, 521, 1364, 14, 2131, 358, 267, 871, 2186, 465, 325, 26, 288, 870, 480, 547, 26, 8352, 908, 8, 69, 430, 267, 587, 26, 288, 870, 480, 5639, 900, 687, 900, 2435, 26, 8352, 908, 8, 2131, 430, 398, 291, 14, 12422, 342, 339, 347, 641, 16761, 8, 277, 304, 267, 870, 480, 27476, 531, 267, 9655, 14, 2379, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 7876, 275, 13515, 7446, 8, 267, 6160, 14, 362, 480, 13883, 4134, 23084, 63, 1093, 2679, 63, 19281, 401, 399, 2, 3569, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 15844, 15, 3569, 1288, 267, 399, 2, 7925, 1700, 8768, 401, 267, 3105, 63, 758, 311, 29, 797, 12, 221, 327, 2716, 27, 943, 5002, 644, 7089, 2436, 267, 3105, 29, 797, 12, 221, 327, 2716, 27, 943, 2755, 1655, 2436, 272, 776, 272, 7876, 14, 1065, 8, 7004, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rennhak/Dia
plug-ins/python/wdeps.py
2
28887
# Generates a weighted dependencies graph from DLLs # Copyright (c) 2001, 2005, 2007 Hans Breuer <hans@breuer.org> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sys, os, re, string, math, time g_maxWeight = 1 # a very limited demangling (leaves junk for some forms) #rDemangle = re.compile("\?(?:\?0)*([^@]+)(?:@@[0ABGHIKPQUVXYZ?1]+|@Z|@)*([^@]*)") # somewhat better: # 1) every mangled name starts with '?' # 2) ctor has '?1' following, dtor has '?0' and the class@namespaces@@parameters # 3) other members have '' following function@class_and_namespaces@@parameters # this is overly simplified: somehow the key appears to have more than one meaning Operators = { "2" : " new", "3" : " delete", "4" : "=", "5" : ">>", "6" : "<<", "7" : "!", "8" : "==", "9" : "!=", "C" : "->", "Z" : "-", "F" : "--", "G" : "-", "H" : "+", "D" : "*", "E" : "++", "M" : "<", "Y" : "+=", "A" : "[]", "B" : " char const *", "K" : "/" } rDemangle = re.compile ("\?(?P<tor>\?[01" + string.join(Operators.keys(), "") + "])*(?P<sym>[\w@_]+?(?=@))@@") # still NOT handling ''' d:\Projects>undname ?ReleaseAccess@?$CWriteAccess@VCDocEx@app@@@utl@@UAEXXZ Microsoft (R) C++ Name Undecorator Copyright (C) Microsoft Corporation 1981-2001. All rights reserved. Undecoration of :- "?ReleaseAccess@?$CWriteAccess@VCDocEx@app@@@utl@@UAEXXZ" is :- "public: virtual void __thiscall utl::CWriteAccess<class app::CDocEx>::ReleaseAccess(void)" Undecoration of :- "??_7CDocMgrView@app@@6B@" is :- "const app::CDocMgrView::`vftable'" Undecoration of :- "??_0CUnit@utl@@QAEAAV01@ABV01@@Z" is :- "public: class utl::CUnit & __thiscall utl::CUnit::operator/=(class utl::CUnit const &)" ''' # a list of dlls to ignore dependencies of g_DontFollow = [] class Node : def __init__ (self, name, depth) : self.name = name self.deps = {} self.depth = depth # where we found it # symbol -> use-count self.exports = {} def AddEdge (self, name, symbols, delayLoad) : self.deps[name] = Edge(name, symbols, delayLoad) def AddExports (self, symbols, used=0) : ''' remember the symbols this node exports (and their use)''' for s in symbols : if self.exports.has_key(s) : self.exports[s] += used else : self.exports[s] = used class Edge : def __init__ (self, name, symbols, delayLoad) : global g_maxWeight self.name = name # the target self.reduce = 0 # != 0 if this should better vanish self.delayLoad = delayLoad if len(symbols) > g_maxWeight : g_maxWeight = len(symbols) demangled = [] for s in symbols : m = rDemangle.match (s) if m : #print m.group("tor"), "::", m.group("sym") dm = "" names = string.split (m.group("sym"), "@") # we must not append the .reverse() in the line above otherwise names would become None. WTF? Inplace operation? names.reverse() if m.group("tor") == "?0" : # constructor dm = string.join(names, "::") + "::" + names[-1] elif m.group("tor") == "?1" : # constructor dm = string.join(names, "::") + "::~" + names[-1] elif m.group("tor") != None and m.group("tor")[0] == "?" and m.group("tor")[1] in Operators.keys() : # constructor dm = string.join(names, "::") + "::operator" + Operators[m.group("tor")[1]] else : dm = string.join(names, "::") #print " => ", dm demangled.append (dm) else : #print " <unmatched>: ", s demangled.append (s) self.symbols = demangled def Weight (self) : "As method to have let always be the number of symbols" return len(self.symbols) g_path = None # empty, default behaviour def FindInPath (sName) : "returns the complete path of the given name, looking at cwd first" sDir = os.getcwd() p = sDir + os.sep + sName if os.path.exists (p) : return p myPath = os.environ['PATH'] if g_path : myPath = g_path for sDir in string.split (myPath, os.pathsep) : p = sDir + os.sep + sName if os.path.exists (p) : return p # safety return sName def GetDepsWin32 (sFrom, dAll, nMaxDepth, nDepth=0) : "calculates the dependents of the passed in dll" if nMaxDepth <= nDepth : return sFrom = string.lower(sFrom) global g_DontFollow if sFrom in g_DontFollow : dAll[sFrom] = Node (sFrom, nDepth) # needed here so other algoritm can remove it ;) return if not dAll.has_key (sFrom) : node = Node (sFrom, nDepth) sPath = sFrom if g_path : sPath = FindInPath (sFrom) f = os.popen ('dumpbin /imports "' + sPath + '"') name = None arr = [] sDump = f.readlines () # avoids multiple instances of dumpbin running simultaneously f = None # avoids infinite recursion on circular dependencies dAll[sFrom] = None delayLoad = 0 directDeps = [] for s in sDump : r = re.match ("^ (.*\.dll)", s, re.IGNORECASE) # the delay load switch is flipped once if s.find ("delay load imports") > 0 : delayLoad = 1 if r : name = string.lower(r.group(1)) # print name else : # import by name # The system dlls seem to follow a diferent pattern (or is this for know-dlls? Delay load?) thus (?:[0123456789ABCDEF]{8}[ ]+)? r2 = re.match ("^[ ]+(?:[0123456789ABCDEF]{8}[ ]+)?[0123456789ABCDEF]{1,5}[ ]+([\w@?$]+)$", s) if not r2 : r2 = re.match ("^[ ]+(?:[0123456789ABCDEF]{8}[ ]+)?Ordinal[ ]+([1234567890]+)$", s) if r2 : arr.append (r2.group(1)) elif s[:-1] == "" and name != None and len(arr) > 0 : #print name, len(arr) node.AddEdge (name, arr, delayLoad) arr = [] directDeps.append(name) GetDepsWin32 (name, dAll, nMaxDepth-nDepth+2, nDepth+1) # add to all nodes dAll[sFrom] = node # restore original depth (independent of how the recurison works) for sd in directDeps : if sd in dAll.keys() : try : dAll[sd].depth = nDepth + 1 except AttributeError, msg : print "FIXME:", sd, msg def GetDepsPosix (sFrom, dAll, nMaxDepth, nDepth=0) : "calculates the dependents of the passed in so" # sFrom must be with absolute on Posix, still we prefer the shorter name sFromName = os.path.split(sFrom)[-1] if nMaxDepth <= nDepth : return global g_DontFollow if sFromName in g_DontFollow : dAll[sFromName] = Node (sFromName, nDepth) # needed here so other algoritm can remove it ;) return if not sFromName in dAll.keys() : #print "Creating", sFromName, nDepth node = Node (sFromName, nDepth) sPath = sFrom #TODO: work with relative pathes? Current dir? f = os.popen ('ldd "' + sPath + '"') sModules = f.readlines () # avoids multiple instances of dumpbin running simultaneously f = None # avoids infinite recursion on circular dependencies dAll[sFromName] = None # sFrom imports fImports = os.popen ('nm --extern-only --dynamic --undefined-only ' + sPath) sImports = fImports.readlines() dImports = {} for si in sImports : mi = re.match("\s+U (\S+)", si) if mi : dImports[mi.group(1)] = 1 toRecurse = [] for s in sModules : r = re.match ("\s+(?P<name>\S+) => (?P<path>\S+).*", s) if r : # print r.group("name"), r.group("path") # now find symbols between sFrom and any of the SOs usedSymbols = [] unusedSymbols = [] fExports = os.popen ('nm --extern-only --dynamic --defined-only ' + r.group("path")) sExports = fExports.readlines() for se in sExports : me = re.match ("\w+ T (\S+)", se) if me : symbol = me.group(1) # print me.group(1), r.group('name') if symbol in dImports.keys() : # direct connection usedSymbols.append (symbol) else : unusedSymbols.append(symbol) # now we have complete symbols for node r.group('name'), # should remember the node although it may not be connected yet # OTOH the recursion would become more difficult to understand, favor KISS if len(usedSymbols) > 0 : node.AddEdge(r.group("name"), usedSymbols, 0) toRecurse.append(r.group("path")) print sFromName, "(", nDepth, "):", r.group("path") # add to all nodes dAll[sFromName] = node for sd in toRecurse : print sFromName, "->", sd, "level:", nDepth+1 sdn = os.path.split(sd)[-1] GetDepsPosix (sd, dAll, nMaxDepth-nDepth+2, nDepth+1) if sdn in dAll.keys() : #print "Adjusting depth", sd, nDepth+1 dAll[sdn].depth = nDepth+1 # adjust to original depth (not how our recursion found it) def IsWin32 () : return os.name in ["nt"] def Remove (deps, list) : "From the deps tree remove the nodes matching list" for s in list : if deps.has_key (s) : del deps[s] for sn in deps.keys() : node = deps[sn] if node.deps.has_key (s) : del node.deps[s] def RemoveRegEx (deps, reg_ex) : "If a module matches reg_ex remove it" import re rr = re.compile (reg_ex) for k1 in deps.keys() : if rr.match (k1) : del deps[k1] else : node = deps[k1] for k2 in node.deps.keys () : if rr.match (k2) : del node.deps[k2] def RemoveBySymbols (deps, list) : "If a connection is conly caused by some symbol in 'list' it is removed" for k in deps.keys() : node = deps[k] for c in node.deps.keys () : edge = node.deps[c] kills = [] for s2 in edge.symbols : for s1 in list : # robustness, dont compare the empty string if s1 == "" : continue # only comparing the start of the symbol if string.find (s2, s1) == 0 : #print "removing", s2, "from", c, "->", k kills.append (s2) #NOT modifying while iterating: edge.symbols.remove (s2) break if len(edge.symbols) == len(kills) : # remove complete edge (maybe we should only mark it removed?) #print "removing", c, "from", k del node.deps[c] else : for s in kills : edge.symbols.remove (s) def Reduce (deps, f, bHintOnly = 1) : "Automatically remove connections until there is only something reasonable left" # first iteration: two components are connected in both directions # if one connection is much weaker than the other one, the weaker one is considered bad # if both have similar weight they are both treated as bad and removed keys = deps.keys() keys.sort() nReduced = 0 for k in keys : node = deps[k] for c in node.deps.keys () : edge = node.deps[c] if deps.has_key (c) : node2 = deps[c] if node2.deps.has_key(k) : edge2 = node2.deps[k] # if one already is reduced dont do it again if edge.reduce or edge2.reduce : continue n = len(edge.symbols) n2 = len(edge2.symbols) if abs(n - n2) < 3 : f.write ("Remove (" + str(n) + "," + str(n2) + ") " + edge.name + " <-> " + edge2.name + "\n\t" + string.join (edge.symbols, ", ") + "\n\t" + string.join (edge2.symbols, ", ") + "\n") # if we now remove *both* connections some components could become completely disconnected. # Instead may try some more guessing. Maybe the component with less deps should drop one more ? if bHintOnly : edge.reduce = 1 edge2.reduce = 1 else : if node.deps.has_key(c) : del node.deps[c] if node2.deps.has_key(k) : del node2.deps[k] nReduced += (n + n2) elif n > n2 : f.write ("Remove (" + str(n2) + ") " + edge.name + " -> " + edge2.name + "\n\t" + string.join (edge2.symbols, ", ") + "\n") if bHintOnly : edge2.reduce = 1 else : if node2.deps.has_key(k) : del node2.deps[k] nReduced += n2 else : f.write("Remove (" + str(n) + ") " + edge2.name + " -> " + edge.name + "\n\t" + string.join (edge.symbols, ", ") + "\n") if bHintOnly : edge.reduce = 1 else : if node.deps.has_key(c) : del node.deps[c] nReduced += n f.write("Remove total: %d\n" % (nReduced)) def CutLeafs (deps, nCuts) : "Remove components without connections. After some iterations only circulars remain (or nothing)" leafs = {} cut = [] # what we have cut in the last pass while nCuts > 0 : cut = leafs.keys() leafs = {} # first pass: find leafs for k in deps.keys() : node = deps[k] if len(node.deps.keys ()) == 0 : leafs[k] = 0 if len(leafs.keys()) == 0 : break # nothing remaining nCuts -= 1 # second pass : remove references to leafs for k in deps.keys() : node = deps[k] for c in leafs.keys() : if node.deps.has_key(c) : leafs[c] += 1 del node.deps[c] # third pass: remove the leafs for k in leafs.keys() : # we either need to reset leafs in every round or if deps.has_key(k) : del deps[k] if len(leafs.keys()) > 0 : return leafs.keys() return cut def TransitiveReduction (deps, tops, treds=[]) : """If a component A has B and C as dependency and B also depends on C reduce A->C. This algorithm is available with dot, too. But here we can adjust the respective 'inherited' symbols and 'depth' as well. """ for a in tops : bs = deps[a].deps.keys() cs = {} for b in bs : for c in deps[b].deps.keys() : if not c in cs.keys() : cs[c] = 1 # bs and cs are now complete, remove all a->b, where b in cs extra_syms = {} for c in cs.keys() : if c in bs : print "Cut", a, "->", c # we need to know which edge a->b is taking the extra symbols extra_syms[c] = deps[a].deps[c].symbols del deps[a].deps[c] # fill remaining bs having a c dependency with the extra symbols e_keys = extra_syms.keys() for e in e_keys : bs = deps[a].deps.keys() # they are reduced above for b in bs : if e in deps[b].deps.keys () : print "Adjust", a, "->", b, "+", len(extra_syms[e]), "from", e #NOT: deps[a].deps[b].symbols.extend(extra_syms[e]) # producing duplicates for s in extra_syms[e] : if not s in deps[a].deps[b].symbols : deps[a].deps[b].symbols.append(s) del extra_syms[e] break #FIXME: something we have cut before may not be visible anymore (would need a deeper search or an ordered reduction) if len(extra_syms.keys()) : print "Not adjusted:", a, "->", string.join(extra_syms.keys(), ", ") # recurse into remaining bs for a in tops : bs = deps[a].deps.keys() treds.append(a) # rember already done to avoid endless recursion TransitiveReduction (deps, bs, treds) def TopMost (deps) : "everything not used by something else" keys = deps.keys () topmost = [] used = {} for k in keys : for d in deps[k].deps.keys() : if not used.has_key (d) : used[d] = 1 for k in keys : if not used.has_key (k) : topmost.append (k) return topmost def UnGlob (comps) : import glob comp_dict = {} for p in comps : g = glob.glob (p) for d in g : if not comp_dict.has_key (d) : comp_dict[d] = 1 return comp_dict.keys() def Sorted (dict) : "given a dictionary with name to number, sort by number" ret = [] keys = dict.keys() keys.sort ( lambda a, b : cmp(dict[a], dict[b]) ) for k in keys : ret.append ((k, dict[k])) return ret # some predefined sets of DLLs, either for hiding from the dependencies or maybe to tin them dllsSysWin32 = [ "version.dll", "winmm.dll", "kernel32.dll", "user32.dll", "gdi32.dll", "comdlg32.dll", "advapi32.dll", "shell32.dll", "comctl32.dll", "ole32.dll", "oleaut32.dll", "winspool.drv", "imm32.dll", "ws2_32.dll", "ws2help.dll", "wsock32.dll", "ntdll.dll", "mpr.dll", "rpcrt4.dll", "shlwapi.dll", "netapi32.dll", "msimg32.dll", "oledlg.dll", "setupapi.dll", "secur32.dll", "avifil32.dll", "msvfw32.dll", "uxtheme.dll"] dllsCrts = [ "msvcrt.dll", "msvcrtd.dll", "msvcp60.dll", # "msvcrt20.dll", # "msvcr70.dll", "msvcp70.dll", "msvcr71.dll", "msvcr71d.dll", "msvcp71.dll", "msvcp71d.dll", "msvcr80.dll", "msvcr80d.dll", "msvcp80.dll", "msvcp80d.dll", # only one on Linux? (or am I missing th C++rt, and what about librt.so.1?) "libc.so.5", "libc.so.6" ] dllsMfc = [ "mfc71u.dll", "mfc71.dll", "mfc71ud.dll", "mfc80u.dll", "mfc80.dll", "mfc80ud.dll" ] dllsGtk = [ "libglib-2.0-0.dll", "libgmodule-2.0-0.dll", "libgobject-2.0-0.dll", "libgthread-2.0-0.dll", "libpango-1.0-0.dll", "libpangowin32-1.0-0.dll", "libpangoft2-1.0-0.dll", "libpangocairo-1.0-0.dll", "libgdk_pixbuf-2.0-0.dll", "libgdk-win32-2.0-0.dll", "libgtk-win32-2.0-0.dll", "libatk-1.0-0.dll", "libcairo.dll", "libintl-1.dll", "iconv.dll" ] # Tinting themes colorMatcher = [] tangoColors = [ "white", # noone is going to ask for it (start of graph) "#fce94f", # butter (light occer) "#fcaf3e", # orange "#e9b96e", # chocolate (light brown) "#8ae234", # chameleon (green) "#729fcf", # sky blue "#ad7fa8", # plum # leaving out red, now getting darker "#edd400", "#f57900", "#c17d11", "#73d216", "#3465a4", "#75507b", # even darker "#c4a00", "#ce5c00", "#8f590f", "#4ce9a06", "#204a87", "#5c3566", ] def ParseRegexTheme (fname) : global colorMatcher rkv = re.compile(r'^"(?P<regex>[^"]+)"\s*=\s*(?P<color>[\w#]+).*') f = open (fname, 'r') for s in f.readlines() : m = rkv.match(s) if m : try : sr = re.compile(m.group('regex')) sc = m.group('color') colorMatcher.append ((sr, sc)) except re.error, msg : print "Parser error\n", s sys.exit(2) if len(colorMatcher) == 0 : print "no colors parsed:", fname sys.exit(3) else : print len(colorMatcher), "colors parsed:", fname def LookupColor (node) : '''Used to tint the nodes by layer ''' global colorMatcher if len(colorMatcher) : for rx, color in colorMatcher : m = rx.match(node.name) if m and m.start() == 0 and m.end() == len(node.name) : #print color, node.name return color return "white" # tinting by palette try : return tangoColors[node.depth] except KeyError, msg : print msg return "#ef2929" # scarlet red except IndexError, msg : print "Dependency", node.name, 'level', node.depth return "#cc0000" # scarlet ret (a bit darker) def main () : deps = {} dllsToRemove = [] regexRemoves = [] symbolsToRemove = [] nMaxDepth = 10000 # almost unlimited components = [] bDump = 0 bByUse = 0 bReduce = 0 bTred = 0 sOutFilename = None sPickle = None nSymbols = 0 nCutLeafs = 0 if IsWin32() : # check if we are running from the right environment # HB: completely bogus, only works with vc2003? #try : # print "FrameworkSDKDir=" + os.environ["FrameworkSDKDir"] #except : # print "The script needs to be called from a 'VS command prompt'" # sys.exit (1) if FindInPath ("dumpbin.exe") == "dumpbin.exe" : print "dumpbin.exe not found" sys.exit (1) for arg in sys.argv[1:] : if string.find (arg, "--remove") == 0 : if arg == "--remove-sys" : dllsToRemove.extend (dllsSysWin32) elif arg == "--remove-crt" : dllsToRemove.extend (dllsCrts) elif arg == "--remove-mfc" : dllsToRemove.extend (dllsMfc) elif arg == "--remove-gtk" : dllsToRemove.extend (dllsGtk) elif string.find (arg, "--remove-regex=") == 0 : regexRemoves.append (arg[len("--remove-regex="):]) elif string.find (arg, "--remove-symbols=") == 0 : noSyms = string.split(arg[len("--remove-symbols="):], ",") symbolsToRemove.extend (noSyms) else : noDeps = string.split(arg[len("--remove="):], ",") dllsToRemove.extend(noDeps) elif string.find (arg, "--dont-follow") == 0 : global g_DontFollow noFollow = string.split(arg[len("--dont-follow="):], ",") g_DontFollow.extend (noFollow) elif string.find (arg, "--depth=") == 0 : nMaxDepth = int(arg[len("--depth="):]) if nMaxDepth < 1 : print "Wrong depth"; sys.exit(1) elif string.find (arg, "--symbols=") == 0 : nSymbols = int(arg[len("--symbols="):]) if nSymbols < 0 : nSymbols = 0 elif string.find (arg, "--cut-leafs") == 0 : if string.find (arg, "--cut-leafs=") == 0 : nCutLeafs = int(arg[len("--cut-leafs="):]) else : nCutLeafs = 10000 # infinite ;) elif arg == "--dump" : bDump = 1 elif arg == "--reduce" : bReduce = 1 elif arg == "--tred" : bTred = 1 elif arg == "--by-use" : bByUse = 1 elif string.find (arg, "--pickle=") == 0 : sGraph = arg[len("--pickle="):] sPickle = arg[len("--pickle="):] + ".pickle" elif string.find (arg, "--path") == 0 : global g_path if string.find (arg, "--path=") == 0 : g_path = arg[len("--path="):] else : g_path = os.environ['PATH'] elif string.find (arg, "--theme=") == 0 : theme = arg[len("--theme="):] if theme == 'regex' : ParseRegexTheme('wdeps.tinting') else : print "Unknown theme!" sys.exit(1) elif string.find (arg, "--") == 0 : print "Unknown option or missing parameter:", arg else : if len(components) == 0 : components = string.split(arg, ",") components = UnGlob (components) # don't GetDeps here cause we need to first evaluate *all* parameters if len(components) == 0 : print "No DLL input found - wrong directory?" sys.exit(1) sGraph = components[0] else : sOutFilename = arg print "arg is:", arg if len(sys.argv) < 2 : print sys.argv[0], "[parameters] <component,s> [dot-output]" print """ Given one or mores starting components like a.dll,another.dll this tool anayzes the dependencies of the DLLs and generates a depency graph in the dot format (see: www.graphviz.org). This tool requires DUMPBIN from the MSVC toolchain. With the version included in VC7.1 it is capable to also 'see' 'delay load imports'. The tool follows the depencies to DLLs in the current directory only. If a second parameter is given the depency graph is written to that file. Otherwise output is written to stdout. There is also a number of extra parameters to fine-tune the graph. First you can use --remove{-crt,-sys,-mfc} to remove the respective set of dependencies. There is also a special form of remove --remove=another.dll removes excatly that dll from the graph. Another way to get more manageable graphs is to limit the recursion depth while searching, like --depth=2 which cuts everything below the second dependency level. The most useful switch to anaylze parts of a highly coupled system is --dont-follow=random.dll (accepting a list as above). This will show random.dll in the resulting graph in gray. But it will not drag in any dependencies below. If you have a small graph it may be useful to not only show the number of symbols used but their name. Giving --symbols=n all edges with n or less symbols will have the (mostly demangled) name of the symbols printed as text. Finally there is the switch --dump for people prefering the textual representation over some graph. For more information read the source. """ sys.exit(0) # output ... if not sOutFilename : f = sys.stdout else : # ... dot f = open(sOutFilename, "w") if bDump : # remember the command line f.write ("# " + string.join (sys.argv, " ") + "\n") try : import pickle deps = pickle.load (open(sPickle)) print "Input from", sPickle except : for s in components: if IsWin32() : GetDepsWin32 (s, deps, nMaxDepth) else : GetDepsPosix (s, deps, nMaxDepth) if len(dllsToRemove) : Remove (deps, dllsToRemove) if len(symbolsToRemove) > 0 : RemoveBySymbols (deps, symbolsToRemove) for rr in regexRemoves : RemoveRegEx (deps, rr) while nCutLeafs > 0 : # not always iterating here, CutLeafs does too if bDump : nTotal = len(deps.keys()) leafs = CutLeafs (deps, 1) if len(leafs) < 1 : break f.write ("CutLeafs " + str(nTotal) + " => " + str(nTotal - len(leafs)) + "\n") leafs.sort() f.write ("\t" + string.join (leafs, ",") + "\n") nCutLeafs -= 1 else : leafs = CutLeafs (deps, nCutLeafs) break if bDump : topmost = TopMost(deps) f.write ("TopMost(%d) : %s\n" % (len(topmost), string.join(topmost, ","))) # the *automatic* reduction is intentionally after cut-leafs if bReduce : if not sOutFilename : f2 = f else : f2 = open (sOutFilename + ".reduced.txt", "w") Reduce (deps, f2) if nCutLeafs > 1000 : # magic number two, still infinite ;) for d in deps.keys() : # kind of arbitrary numbers n1 = len(deps[d].deps.keys()) # lthis ones dependencies n2 = len(deps.keys()) # total number of components left # write erros/warning like the compiler would do f2.write ("%s - %d error(s), %d warning(s)\n" % (deps[d].name, n1, n2)) if bTred : tops = TopMost (deps) if len(tops) == 0 : print "Transitive reduction without topmost!" tops = deps.keys () TransitiveReduction (deps, tops) if sPickle : import pickle pickle.dump(deps, open(sPickle,"w")) if bDump : Symbols = {} Modules = {} Imports = {} node_keys = deps.keys() node_keys.sort() for sn in node_keys : node = deps[sn] if len(node.deps.keys()) == 0 : continue f.write (sn + "\n") Imports[sn] = 0 edge_keys = node.deps.keys() edge_keys.sort() for se in edge_keys : edge = node.deps[se] if edge.reduce : f.write ("\t!" + node.name + " -> " + edge.name + "\n") continue if edge.delayLoad : f.write ("\t" + node.name + " -> " + edge.name + " (delay load)\n") else : f.write ("\t" + node.name + " -> " + edge.name + "\n") syms = edge.symbols syms.sort() for sy in syms : f.write ("\t\t" + sy + "\n") if Symbols.has_key(sy) : Symbols[sy] += 1 else : Symbols[sy] = 1 Imports[sn] += len(syms) if Modules.has_key (edge.name) : Modules[edge.name].append (node.name) else : Modules[edge.name] = [node.name] # symbols used by many modules are good candidates for refactoring f.write ( "***** Modules with users (symbols) *****\n" ) for s, i in Sorted (Imports) : if Modules.has_key (s) : f.write (s + " (" + str(i) + ") : " + string.join (Modules[s], ",") + "\n") else : f.write (s + " (0) : <no users>\n") # no diagram at all sys.exit(0) f.write ('digraph "' + sGraph + '" {\n') f.write ('graph [fontsize=8.0 label="wdeps.py ' + string.join (sys.argv[1:], " ") + '\\n' + time.ctime() + '"]\n') f.write ('ratio=0.7\nnode [fontsize=12.0 ]\nedge [fontsize=8.0]\n') if bByUse : # kind of inverted diagram not showing edependencies but 'users' users = {} for sn in deps.keys() : users[sn] = [] for sn in deps.keys() : node = deps[sn] for se in node.deps.keys() : edge = node.deps[se] users[edge.name].append(node.name) for sn in users.keys() : for s in users[sn] : f.write ('"%s" -> "%s"\n' % (sn, s)) else : # first pass mark don't follows dontFollowsDone = {} urlsDone = {} deps_keys = deps.keys() deps_keys.sort() for sn in deps_keys : node = deps[sn] edge_keys = node.deps.keys() edge_keys.sort() for se in edge_keys : cut_len = len(se) if IsWin32() : cut_len = string.find(se, ".dll") else : cut_len = string.find(se, ".so") ses = se[:cut_len] if se in g_DontFollow : if not dontFollowsDone.has_key(se) : # mark as such f.write ('"%s" [style=filled,fillcolor="lightgray"]\n' % (se,)) dontFollowsDone[se] = 1 else : if not urlsDone.has_key (se) : f.write ('"%s" [style=filled,fillcolor="%s",URL="#%s"]\n' % (se, LookupColor(deps[se]), se)) urlsDone[se] = 1 for sn in deps_keys : # write weighted edges, could also classify the nodes ... node = deps[sn] edge_keys = node.deps.keys() edge_keys.sort() for se in edge_keys : edge = node.deps[se] sPrefix = "" if edge.reduce : # remove from graph by commenting it out sPrefix = "// " + string.join(edge.symbols, ", ") + "\n// " if edge.delayLoad : # putting 'weight' and 'constraint' seems to be too much for dot sStyle = "weight=%f,style=dotted" % (math.log10(math.sqrt(edge.Weight()+.1)),) # even using constraint at all seems to often crash dot #sStyle = "style=dotted,constraint=false" else : sStyle = "weight=%f" % (math.log10(edge.Weight()+.1),) if edge.Weight() <= nSymbols : #f.write ('"%s" -> "%s" [weight=%f,label=%s]\n' % (node.name, edge.name, math.log(1)-0.5, edge.symbols[0])) f.write ('%s"%s" -> "%s" [fontsize=6,label="%s",%s]\n' % (sPrefix, node.name, edge.name, string.join(edge.symbols, "\\n"), sStyle)) else : #f.write ('"%s" -> "%s" [weight=%f]\n' % (node.name, edge.name, math.log(edge.Weight())-0.5)) f.write ('%s"%s" -> "%s" [label="(%d)",%s]\n' % (sPrefix, node.name, edge.name, edge.Weight(), sStyle)) f.write("}\n") if __name__ == '__main__': main()
gpl-2.0
[ 3, 21687, 282, 14609, 5124, 3343, 687, 577, 4464, 83, 199, 3, 1898, 334, 67, 9, 12521, 12, 11811, 12, 10219, 869, 796, 699, 264, 14262, 665, 72, 796, 32, 10205, 14262, 14, 1308, 30, 199, 199, 3, 259, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 257, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 257, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 257, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 199, 646, 984, 12, 747, 12, 295, 12, 1059, 12, 3473, 12, 900, 199, 199, 71, 63, 988, 16359, 275, 413, 199, 3, 282, 7437, 13988, 28548, 26896, 334, 16554, 24605, 367, 2005, 4513, 9, 199, 3, 82, 872, 29602, 275, 295, 14, 2014, 4582, 31, 15840, 31, 16, 3342, 7059, 32, 11896, 5169, 7492, 59, 16, 1217, 39, 11183, 24974, 2328, 54, 16694, 31, 17, 2807, 92, 32, 58, 92, 32, 3342, 7059, 32, 3672, 6320, 199, 3, 30362, 8034, 26, 199, 3, 413, 9, 4036, 333, 22183, 536, 9174, 543, 15539, 199, 3, 499, 9, 286, 8270, 965, 8720, 17, 7, 2569, 12, 4487, 269, 965, 8720, 16, 7, 221, 436, 314, 1021, 32, 9247, 7492, 3214, 199, 3, 650, 9, 1163, 7556, 1172, 2125, 2569, 805, 32, 533, 63, 460, 63, 9247, 7492, 3214, 199, 199, 3, 642, 365, 1806, 590, 26867, 26, 29437, 314, 790, 11337, 370, 1172, 1655, 2419, 1373, 11150, 199, 3632, 2750, 275, 469, 298, 18, 2, 520, 298, 892, 401, 298, 19, 2, 520, 298, 3145, 401, 28932, 221, 298, 20, 2, 520, 298, 11107, 298, 21, 2, 520, 298, 1140, 401, 298, 22, 2, 520, 3886, 28, 401, 298, 23, 2, 520, 298, 17716, 298, 24, 2, 520, 298, 389, 401, 298, 25, 2, 520, 298, 1111, 401, 28932, 221, 298, 35, 2, 520, 3905, 7166, 298, 58, 2, 520, 3905, 401, 298, 38, 2, 520, 4320, 401, 298, 39, 2, 520, 3905, 401, 298, 40, 2, 520, 7210, 401, 298, 36, 2, 520, 8969, 401, 298, 37, 2, 520, 298, 4176, 401, 28932, 221, 298, 45, 2, 520, 3886, 401, 298, 57, 2, 520, 7210, 11107, 298, 33, 2, 520, 7369, 11472, 298, 34, 2, 520, 298, 1495, 950, 627, 401, 298, 43, 2, 520, 10609, 789, 199, 82, 872, 29602, 275, 295, 14, 2014, 25381, 31, 2229, 48, 28, 8270, 3072, 26736, 614, 2, 435, 1059, 14, 904, 8, 3632, 2750, 14, 1612, 1062, 6899, 435, 298, 19100, 2229, 48, 28, 3840, 24693, 87, 17608, 2807, 31, 2229, 29, 32, 430, 7492, 531, 199, 3, 5139, 2845, 7252, 199, 2344, 199, 68, 3427, 24286, 30, 725, 354, 5805, 9625, 3946, 32, 31, 4, 35, 3534, 3946, 32, 9454, 3768, 920, 32, 571, 25673, 337, 76, 7492, 21659, 1438, 56, 58, 199, 12940, 334, 50, 9, 445, 4176, 2812, 1910, 11547, 199, 7384, 334, 35, 9, 15332, 11098, 5851, 2835, 13, 8339, 14, 2900, 4481, 4644, 14, 199, 199, 1358, 6518, 425, 402, 22901, 23665, 9625, 3946, 32, 31, 4, 35, 3534, 3946, 32, 9454, 3768, 920, 32, 571, 25673, 337, 76, 7492, 21659, 1438, 56, 58, 2, 199, 374, 22901, 298, 3455, 26, 5791, 2309, 636, 3749, 1250, 11430, 76, 447, 35, 3534, 3946, 28, 533, 1145, 447, 35, 3768, 920, 14229, 9625, 3946, 8, 1647, 2924, 199, 199, 1358, 6518, 425, 402, 22901, 298, 10674, 63, 23, 35, 3768, 20752, 2768, 32, 571, 7492, 22, 34, 32, 2, 199, 374, 22901, 298, 1297, 1145, 447, 35, 3768, 20752, 2768, 447, 64, 86, 856, 461, 4065, 199, 199, 1358, 6518, 425, 402, 22901, 298, 10674, 63, 16, 35, 5072, 32, 337, 76, 7492, 49, 12500, 2276, 54, 614, 32, 1217, 54, 614, 7492, 58, 2, 199, 374, 22901, 298, 3455, 26, 1021, 11430, 76, 447, 35, 5072, 1253, 636, 3749, 1250, 11430, 76, 447, 35, 5072, 447, 3856, 15, 2687, 533, 11430, 76, 447, 35, 5072, 950, 1253, 2924, 199, 2344, 199, 3, 282, 769, 402, 15396, 478, 370, 3686, 5124, 402, 199, 71, 63, 20028, 18696, 275, 942, 199, 199, 533, 5013, 520, 199, 198, 318, 636, 826, 363, 334, 277, 12, 536, 12, 5818, 9, 520, 507, 198, 277, 14, 354, 275, 536, 507, 198, 277, 14, 5846, 275, 1052, 507, 198, 277, 14, 4631, 275, 5818, 327, 2382, 781, 1911, 652, 507, 198, 3, 5272, 1035, 675, 13, 835, 507, 198, 277, 14, 20775, 275, 1052, 199, 198, 318, 2654, 12886, 334, 277, 12, 536, 12, 6698, 12, 7339, 6200, 9, 520, 507, 198, 277, 14, 5846, 59, 354, 61, 275, 25155, 8, 354, 12, 6698, 12, 7339, 6200, 9, 199, 198, 318, 2654, 920, 5203, 334, 277, 12, 6698, 12, 1202, 29, 16, 9, 520, 507, 198, 2344, 21027, 314, 6698, 642, 1031, 22609, 334, 460, 3932, 675, 9, 2344, 507, 198, 509, 308, 315, 6698, 520, 686, 198, 692, 291, 14, 20775, 14, 1989, 63, 498, 8, 83, 9, 520, 1585, 198, 277, 14, 20775, 59, 83, 61, 847, 1202, 686, 198, 2836, 520, 1585, 198, 277, 14, 20775, 59, 83, 61, 275, 1202, 199, 199, 533, 25155, 520, 199, 198, 318, 636, 826, 363, 334, 277, 12, 536, 12, 6698, 12, 7339, 6200, 9, 520, 507, 198, 2966, 486, 63, 988, 16359, 507, 198, 277, 14, 354, 275, 536, 327, 314, 1347, 507, 198, 277, 14, 5270, 275, 378, 327, 1137, 378, 340, 642, 1077 ]
[ 21687, 282, 14609, 5124, 3343, 687, 577, 4464, 83, 199, 3, 1898, 334, 67, 9, 12521, 12, 11811, 12, 10219, 869, 796, 699, 264, 14262, 665, 72, 796, 32, 10205, 14262, 14, 1308, 30, 199, 199, 3, 259, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 257, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 257, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 257, 2752, 12, 3277, 2020, 1227, 2194, 603, 405, 437, 432, 12, 445, 455, 9528, 12, 4828, 12497, 7491, 12, 8217, 14, 199, 199, 646, 984, 12, 747, 12, 295, 12, 1059, 12, 3473, 12, 900, 199, 199, 71, 63, 988, 16359, 275, 413, 199, 3, 282, 7437, 13988, 28548, 26896, 334, 16554, 24605, 367, 2005, 4513, 9, 199, 3, 82, 872, 29602, 275, 295, 14, 2014, 4582, 31, 15840, 31, 16, 3342, 7059, 32, 11896, 5169, 7492, 59, 16, 1217, 39, 11183, 24974, 2328, 54, 16694, 31, 17, 2807, 92, 32, 58, 92, 32, 3342, 7059, 32, 3672, 6320, 199, 3, 30362, 8034, 26, 199, 3, 413, 9, 4036, 333, 22183, 536, 9174, 543, 15539, 199, 3, 499, 9, 286, 8270, 965, 8720, 17, 7, 2569, 12, 4487, 269, 965, 8720, 16, 7, 221, 436, 314, 1021, 32, 9247, 7492, 3214, 199, 3, 650, 9, 1163, 7556, 1172, 2125, 2569, 805, 32, 533, 63, 460, 63, 9247, 7492, 3214, 199, 199, 3, 642, 365, 1806, 590, 26867, 26, 29437, 314, 790, 11337, 370, 1172, 1655, 2419, 1373, 11150, 199, 3632, 2750, 275, 469, 298, 18, 2, 520, 298, 892, 401, 298, 19, 2, 520, 298, 3145, 401, 28932, 221, 298, 20, 2, 520, 298, 11107, 298, 21, 2, 520, 298, 1140, 401, 298, 22, 2, 520, 3886, 28, 401, 298, 23, 2, 520, 298, 17716, 298, 24, 2, 520, 298, 389, 401, 298, 25, 2, 520, 298, 1111, 401, 28932, 221, 298, 35, 2, 520, 3905, 7166, 298, 58, 2, 520, 3905, 401, 298, 38, 2, 520, 4320, 401, 298, 39, 2, 520, 3905, 401, 298, 40, 2, 520, 7210, 401, 298, 36, 2, 520, 8969, 401, 298, 37, 2, 520, 298, 4176, 401, 28932, 221, 298, 45, 2, 520, 3886, 401, 298, 57, 2, 520, 7210, 11107, 298, 33, 2, 520, 7369, 11472, 298, 34, 2, 520, 298, 1495, 950, 627, 401, 298, 43, 2, 520, 10609, 789, 199, 82, 872, 29602, 275, 295, 14, 2014, 25381, 31, 2229, 48, 28, 8270, 3072, 26736, 614, 2, 435, 1059, 14, 904, 8, 3632, 2750, 14, 1612, 1062, 6899, 435, 298, 19100, 2229, 48, 28, 3840, 24693, 87, 17608, 2807, 31, 2229, 29, 32, 430, 7492, 531, 199, 3, 5139, 2845, 7252, 199, 2344, 199, 68, 3427, 24286, 30, 725, 354, 5805, 9625, 3946, 32, 31, 4, 35, 3534, 3946, 32, 9454, 3768, 920, 32, 571, 25673, 337, 76, 7492, 21659, 1438, 56, 58, 199, 12940, 334, 50, 9, 445, 4176, 2812, 1910, 11547, 199, 7384, 334, 35, 9, 15332, 11098, 5851, 2835, 13, 8339, 14, 2900, 4481, 4644, 14, 199, 199, 1358, 6518, 425, 402, 22901, 23665, 9625, 3946, 32, 31, 4, 35, 3534, 3946, 32, 9454, 3768, 920, 32, 571, 25673, 337, 76, 7492, 21659, 1438, 56, 58, 2, 199, 374, 22901, 298, 3455, 26, 5791, 2309, 636, 3749, 1250, 11430, 76, 447, 35, 3534, 3946, 28, 533, 1145, 447, 35, 3768, 920, 14229, 9625, 3946, 8, 1647, 2924, 199, 199, 1358, 6518, 425, 402, 22901, 298, 10674, 63, 23, 35, 3768, 20752, 2768, 32, 571, 7492, 22, 34, 32, 2, 199, 374, 22901, 298, 1297, 1145, 447, 35, 3768, 20752, 2768, 447, 64, 86, 856, 461, 4065, 199, 199, 1358, 6518, 425, 402, 22901, 298, 10674, 63, 16, 35, 5072, 32, 337, 76, 7492, 49, 12500, 2276, 54, 614, 32, 1217, 54, 614, 7492, 58, 2, 199, 374, 22901, 298, 3455, 26, 1021, 11430, 76, 447, 35, 5072, 1253, 636, 3749, 1250, 11430, 76, 447, 35, 5072, 447, 3856, 15, 2687, 533, 11430, 76, 447, 35, 5072, 950, 1253, 2924, 199, 2344, 199, 3, 282, 769, 402, 15396, 478, 370, 3686, 5124, 402, 199, 71, 63, 20028, 18696, 275, 942, 199, 199, 533, 5013, 520, 199, 198, 318, 636, 826, 363, 334, 277, 12, 536, 12, 5818, 9, 520, 507, 198, 277, 14, 354, 275, 536, 507, 198, 277, 14, 5846, 275, 1052, 507, 198, 277, 14, 4631, 275, 5818, 327, 2382, 781, 1911, 652, 507, 198, 3, 5272, 1035, 675, 13, 835, 507, 198, 277, 14, 20775, 275, 1052, 199, 198, 318, 2654, 12886, 334, 277, 12, 536, 12, 6698, 12, 7339, 6200, 9, 520, 507, 198, 277, 14, 5846, 59, 354, 61, 275, 25155, 8, 354, 12, 6698, 12, 7339, 6200, 9, 199, 198, 318, 2654, 920, 5203, 334, 277, 12, 6698, 12, 1202, 29, 16, 9, 520, 507, 198, 2344, 21027, 314, 6698, 642, 1031, 22609, 334, 460, 3932, 675, 9, 2344, 507, 198, 509, 308, 315, 6698, 520, 686, 198, 692, 291, 14, 20775, 14, 1989, 63, 498, 8, 83, 9, 520, 1585, 198, 277, 14, 20775, 59, 83, 61, 847, 1202, 686, 198, 2836, 520, 1585, 198, 277, 14, 20775, 59, 83, 61, 275, 1202, 199, 199, 533, 25155, 520, 199, 198, 318, 636, 826, 363, 334, 277, 12, 536, 12, 6698, 12, 7339, 6200, 9, 520, 507, 198, 2966, 486, 63, 988, 16359, 507, 198, 277, 14, 354, 275, 536, 327, 314, 1347, 507, 198, 277, 14, 5270, 275, 378, 327, 1137, 378, 340, 642, 1077, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aeph6Ee0/youtube-dl
youtube_dl/extractor/fc2.py
40
5593
# coding: utf-8 from __future__ import unicode_literals import hashlib import re from .common import InfoExtractor from ..compat import ( compat_parse_qs, compat_urllib_request, compat_urlparse, ) from ..utils import ( ExtractorError, sanitized_Request, urlencode_postdata, ) class FC2IE(InfoExtractor): _VALID_URL = r'^(?:https?://video\.fc2\.com/(?:[^/]+/)*content/|fc2:)(?P<id>[^/]+)' IE_NAME = 'fc2' _NETRC_MACHINE = 'fc2' _TESTS = [{ 'url': 'http://video.fc2.com/en/content/20121103kUan1KHs', 'md5': 'a6ebe8ebe0396518689d963774a54eb7', 'info_dict': { 'id': '20121103kUan1KHs', 'ext': 'flv', 'title': 'Boxing again with Puff', }, }, { 'url': 'http://video.fc2.com/en/content/20150125cEva0hDn/', 'info_dict': { 'id': '20150125cEva0hDn', 'ext': 'mp4', }, 'params': { 'username': 'ytdl@yt-dl.org', 'password': '(snip)', }, 'skip': 'requires actual password', }, { 'url': 'http://video.fc2.com/en/a/content/20130926eZpARwsF', 'only_matching': True, }] def _login(self): (username, password) = self._get_login_info() if username is None or password is None: return False # Log in login_form_strs = { 'email': username, 'password': password, 'done': 'video', 'Submit': ' Login ', } login_data = urlencode_postdata(login_form_strs) request = sanitized_Request( 'https://secure.id.fc2.com/index.php?mode=login&switch_language=en', login_data) login_results = self._download_webpage(request, None, note='Logging in', errnote='Unable to log in') if 'mode=redirect&login=done' not in login_results: self.report_warning('unable to log in: bad username or password') return False # this is also needed login_redir = sanitized_Request('http://id.fc2.com/?mode=redirect&login=done') self._download_webpage( login_redir, None, note='Login redirect', errnote='Login redirect failed') return True def _real_extract(self, url): video_id = self._match_id(url) self._login() webpage = None if not url.startswith('fc2:'): webpage = self._download_webpage(url, video_id) self._downloader.cookiejar.clear_session_cookies() # must clear self._login() title = 'FC2 video %s' % video_id thumbnail = None if webpage is not None: title = self._og_search_title(webpage) thumbnail = self._og_search_thumbnail(webpage) refer = url.replace('/content/', '/a/content/') if '/a/content/' not in url else url mimi = hashlib.md5((video_id + '_gGddgPfeaf_gzyr').encode('utf-8')).hexdigest() info_url = ( 'http://video.fc2.com/ginfo.php?mimi={1:s}&href={2:s}&v={0:s}&fversion=WIN%2011%2C6%2C602%2C180&from=2&otag=0&upid={0:s}&tk=null&'. format(video_id, mimi, compat_urllib_request.quote(refer, safe=b'').replace('.', '%2E'))) info_webpage = self._download_webpage( info_url, video_id, note='Downloading info page') info = compat_urlparse.parse_qs(info_webpage) if 'err_code' in info: # most of the time we can still download wideo even if err_code is 403 or 602 self.report_warning( 'Error code was: %s... but still trying' % info['err_code'][0]) if 'filepath' not in info: raise ExtractorError('Cannot download file. Are you logged in?') video_url = info['filepath'][0] + '?mid=' + info['mid'][0] title_info = info.get('title') if title_info: title = title_info[0] return { 'id': video_id, 'title': title, 'url': video_url, 'ext': 'flv', 'thumbnail': thumbnail, } class FC2EmbedIE(InfoExtractor): _VALID_URL = r'https?://video\.fc2\.com/flv2\.swf\?(?P<query>.+)' IE_NAME = 'fc2:embed' _TEST = { 'url': 'http://video.fc2.com/flv2.swf?t=201404182936758512407645&i=20130316kwishtfitaknmcgd76kjd864hso93htfjcnaogz629mcgfs6rbfk0hsycma7shkf85937cbchfygd74&i=201403223kCqB3Ez&d=2625&sj=11&lang=ja&rel=1&from=11&cmt=1&tk=TlRBM09EQTNNekU9&tl=プリズン・ブレイク%20S1-01%20マイケル%20【吹替】', 'md5': 'b8aae5334cb691bdb1193a88a6ab5d5a', 'info_dict': { 'id': '201403223kCqB3Ez', 'ext': 'flv', 'title': 'プリズン・ブレイク S1-01 マイケル 【吹替】', 'thumbnail': r're:^https?://.*\.jpg$', }, } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) query = compat_parse_qs(mobj.group('query')) video_id = query['i'][-1] title = query.get('tl', ['FC2 video %s' % video_id])[0] sj = query.get('sj', [None])[0] thumbnail = None if sj: # See thumbnailImagePath() in ServerConst.as of flv2.swf thumbnail = 'http://video%s-thumbnail.fc2.com/up/pic/%s.jpg' % ( sj, '/'.join((video_id[:6], video_id[6:8], video_id[-2], video_id[-1], video_id))) return { '_type': 'url_transparent', 'ie_key': FC2IE.ie_key(), 'url': 'fc2:%s' % video_id, 'title': title, 'thumbnail': thumbnail, }
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 8337, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 1122, 63, 6177, 12, 272, 8434, 63, 4078, 63, 1069, 12, 272, 8434, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 31734, 63, 2017, 12, 272, 16511, 63, 1932, 576, 12, 199, 9, 421, 199, 533, 20934, 18, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 4289, 5169, 2859, 14144, 3722, 4537, 3003, 18, 4537, 957, 32576, 26285, 15, 3342, 1317, 15, 92, 3003, 18, 26, 18168, 48, 28, 344, 26906, 3171, 272, 15292, 63, 2339, 275, 283, 3003, 18, 7, 272, 485, 7278, 8205, 63, 20890, 275, 283, 3003, 18, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 287, 15, 1317, 15, 1797, 2025, 8845, 75, 8206, 17, 30392, 83, 297, 267, 283, 1064, 21, 356, 283, 65, 22, 69, 1235, 24, 69, 1235, 10005, 2182, 11656, 1407, 68, 2534, 7332, 20, 65, 1477, 2871, 23, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1797, 2025, 8845, 75, 8206, 17, 30392, 83, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 3532, 316, 4020, 543, 510, 3043, 297, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 287, 15, 1317, 15, 7806, 614, 821, 67, 37, 3042, 16, 72, 36, 78, 3678, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7806, 614, 821, 67, 37, 3042, 16, 72, 36, 78, 297, 288, 283, 832, 356, 283, 311, 20, 297, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2473, 356, 283, 89, 2076, 76, 32, 24264, 13, 5030, 14, 1308, 297, 288, 283, 2060, 356, 8189, 5167, 711, 3196, 267, 1660, 267, 283, 2759, 356, 283, 6537, 3503, 2505, 297, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 287, 15, 65, 15, 1317, 15, 1797, 10556, 1479, 69, 58, 80, 689, 3569, 38, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 2886, 8, 277, 304, 267, 334, 2473, 12, 2505, 9, 275, 291, 423, 362, 63, 2886, 63, 815, 342, 267, 340, 3434, 365, 488, 503, 2505, 365, 488, 26, 288, 372, 756, 398, 327, 5297, 315, 267, 4676, 63, 964, 63, 16144, 275, 469, 288, 283, 2123, 356, 3434, 12, 288, 283, 2060, 356, 2505, 12, 288, 283, 4456, 356, 283, 3722, 297, 288, 283, 17187, 356, 283, 16430, 1656, 267, 789, 398, 4676, 63, 576, 275, 16511, 63, 1932, 576, 8, 2886, 63, 964, 63, 16144, 9, 267, 1056, 275, 31734, 63, 2017, 8, 288, 283, 2859, 921, 7817, 14, 344, 14, 3003, 18, 14, 957, 15, 1080, 14, 8624, 31, 632, 29, 2886, 6, 5656, 63, 3671, 29, 287, 297, 4676, 63, 576, 9, 398, 4676, 63, 2604, 275, 291, 423, 4249, 63, 12022, 8, 1069, 12, 488, 12, 5317, 534, 14054, 315, 297, 2329, 4610, 534, 6005, 370, 943, 315, 358, 267, 340, 283, 632, 29, 4876, 6, 2886, 29, 4456, 7, 440, 315, 4676, 63, 2604, 26, 288, 291, 14, 3070, 63, 3764, 360, 17200, 370, 943, 315, 26, 4875, 3434, 503, 2505, 358, 288, 372, 756, 398, 327, 642, 365, 2597, 4346, 267, 4676, 63, 264, 694, 275, 31734, 63, 2017, 360, 1014, 921, 344, 14, 3003, 18, 14, 957, 10197, 632, 29, 4876, 6, 2886, 29, 4456, 358, 267, 291, 423, 4249, 63, 12022, 8, 288, 4676, 63, 264, 694, 12, 488, 12, 5317, 534, 8880, 4660, 297, 2329, 4610, 534, 8880, 4660, 3405, 358, 398, 372, 715, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 291, 423, 2886, 342, 267, 9248, 275, 488, 267, 340, 440, 1166, 14, 2460, 360, 3003, 18, 23117, 288, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 288, 291, 423, 22846, 14, 30552, 14, 3584, 63, 1730, 63, 7792, 342, 221, 327, 1471, 5436, 288, 291, 423, 2886, 342, 398, 2538, 275, 283, 4161, 18, 3991, 450, 83, 7, 450, 3991, 63, 344, 267, 10062, 275, 488, 267, 340, 9248, 365, 440, 488, 26, 288, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 288, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 9, 267, 10618, 275, 1166, 14, 1814, 2336, 1317, 3678, 1994, 65, 15, 1317, 6217, 340, 1994, 65, 15, 1317, 4805, 440, 315, 1166, 587, 1166, 398, 24102, 73, 275, 8337, 14, 1064, 21, 1332, 3722, 63, 344, 435, 2513, 71, 39, 617, 71, 48, 771, 2756, 63, 71, 3605, 82, 1959, 2143, 360, 1624, 13, 24, 11103, 11453, 342, 398, 2256, 63, 633, 275, 334, 288, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 71, 815, 14, 8624, 31, 77, 1017, 73, 3126, 17, 26, 83, 93, 6, 6399, 3126, 18, 26, 83, 93, 6, 86, 3126, 16, 26, 83, 93, 6, 70, 1023, 29, 7941, 5, 8128, 5, 18, 35, 22, 5, 18, 35, 28384, 5, 18, 35, 7663, 6, 504, 29, 18, 6, 357, 643, 29, 16, 6, 31596, 3126, 16, 26, 83, 93, 6, 2663, 29, 2307, 6, 1370, 288, 1475, 8, 3722, 63, 344, 12, 24102, 73, 12, 8434, 63, 4078, 63, 1069, 14, 3513, 8, 21928, 12, 5048, 29, 66, 7, 1959, 1814, 14078, 1543, 18, 37, 7058, 398, 2256, 63, 12022, 275, 291, 423, 4249, 63, 12022, 8, 288, 2256, 63, 633, 12, 3991, 63, 344, 12, 5317, 534, 18085, 2256, 2034, 358, 267, 2256, 275, 8434, 63, 10290, 14, 1122, 63, 6177, 8, 815, 63, 12022, 9, 398, 340, 283, 1508, 63, 600, 7, 315, 2256, 26, 288, 327, 4750, 402, 314, 900, 781, 883, 5139, 5235, 26038, 2172, 2755, 340, 2329, 63, 600, 365, 13269, 503, 1227, 996, 288 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 8337, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 1122, 63, 6177, 12, 272, 8434, 63, 4078, 63, 1069, 12, 272, 8434, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 31734, 63, 2017, 12, 272, 16511, 63, 1932, 576, 12, 199, 9, 421, 199, 533, 20934, 18, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 4289, 5169, 2859, 14144, 3722, 4537, 3003, 18, 4537, 957, 32576, 26285, 15, 3342, 1317, 15, 92, 3003, 18, 26, 18168, 48, 28, 344, 26906, 3171, 272, 15292, 63, 2339, 275, 283, 3003, 18, 7, 272, 485, 7278, 8205, 63, 20890, 275, 283, 3003, 18, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 287, 15, 1317, 15, 1797, 2025, 8845, 75, 8206, 17, 30392, 83, 297, 267, 283, 1064, 21, 356, 283, 65, 22, 69, 1235, 24, 69, 1235, 10005, 2182, 11656, 1407, 68, 2534, 7332, 20, 65, 1477, 2871, 23, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1797, 2025, 8845, 75, 8206, 17, 30392, 83, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 3532, 316, 4020, 543, 510, 3043, 297, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 287, 15, 1317, 15, 7806, 614, 821, 67, 37, 3042, 16, 72, 36, 78, 3678, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7806, 614, 821, 67, 37, 3042, 16, 72, 36, 78, 297, 288, 283, 832, 356, 283, 311, 20, 297, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2473, 356, 283, 89, 2076, 76, 32, 24264, 13, 5030, 14, 1308, 297, 288, 283, 2060, 356, 8189, 5167, 711, 3196, 267, 1660, 267, 283, 2759, 356, 283, 6537, 3503, 2505, 297, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 287, 15, 65, 15, 1317, 15, 1797, 10556, 1479, 69, 58, 80, 689, 3569, 38, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 347, 485, 2886, 8, 277, 304, 267, 334, 2473, 12, 2505, 9, 275, 291, 423, 362, 63, 2886, 63, 815, 342, 267, 340, 3434, 365, 488, 503, 2505, 365, 488, 26, 288, 372, 756, 398, 327, 5297, 315, 267, 4676, 63, 964, 63, 16144, 275, 469, 288, 283, 2123, 356, 3434, 12, 288, 283, 2060, 356, 2505, 12, 288, 283, 4456, 356, 283, 3722, 297, 288, 283, 17187, 356, 283, 16430, 1656, 267, 789, 398, 4676, 63, 576, 275, 16511, 63, 1932, 576, 8, 2886, 63, 964, 63, 16144, 9, 267, 1056, 275, 31734, 63, 2017, 8, 288, 283, 2859, 921, 7817, 14, 344, 14, 3003, 18, 14, 957, 15, 1080, 14, 8624, 31, 632, 29, 2886, 6, 5656, 63, 3671, 29, 287, 297, 4676, 63, 576, 9, 398, 4676, 63, 2604, 275, 291, 423, 4249, 63, 12022, 8, 1069, 12, 488, 12, 5317, 534, 14054, 315, 297, 2329, 4610, 534, 6005, 370, 943, 315, 358, 267, 340, 283, 632, 29, 4876, 6, 2886, 29, 4456, 7, 440, 315, 4676, 63, 2604, 26, 288, 291, 14, 3070, 63, 3764, 360, 17200, 370, 943, 315, 26, 4875, 3434, 503, 2505, 358, 288, 372, 756, 398, 327, 642, 365, 2597, 4346, 267, 4676, 63, 264, 694, 275, 31734, 63, 2017, 360, 1014, 921, 344, 14, 3003, 18, 14, 957, 10197, 632, 29, 4876, 6, 2886, 29, 4456, 358, 267, 291, 423, 4249, 63, 12022, 8, 288, 4676, 63, 264, 694, 12, 488, 12, 5317, 534, 8880, 4660, 297, 2329, 4610, 534, 8880, 4660, 3405, 358, 398, 372, 715, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 291, 423, 2886, 342, 267, 9248, 275, 488, 267, 340, 440, 1166, 14, 2460, 360, 3003, 18, 23117, 288, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 288, 291, 423, 22846, 14, 30552, 14, 3584, 63, 1730, 63, 7792, 342, 221, 327, 1471, 5436, 288, 291, 423, 2886, 342, 398, 2538, 275, 283, 4161, 18, 3991, 450, 83, 7, 450, 3991, 63, 344, 267, 10062, 275, 488, 267, 340, 9248, 365, 440, 488, 26, 288, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 288, 10062, 275, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 9, 267, 10618, 275, 1166, 14, 1814, 2336, 1317, 3678, 1994, 65, 15, 1317, 6217, 340, 1994, 65, 15, 1317, 4805, 440, 315, 1166, 587, 1166, 398, 24102, 73, 275, 8337, 14, 1064, 21, 1332, 3722, 63, 344, 435, 2513, 71, 39, 617, 71, 48, 771, 2756, 63, 71, 3605, 82, 1959, 2143, 360, 1624, 13, 24, 11103, 11453, 342, 398, 2256, 63, 633, 275, 334, 288, 283, 1014, 921, 3722, 14, 3003, 18, 14, 957, 15, 71, 815, 14, 8624, 31, 77, 1017, 73, 3126, 17, 26, 83, 93, 6, 6399, 3126, 18, 26, 83, 93, 6, 86, 3126, 16, 26, 83, 93, 6, 70, 1023, 29, 7941, 5, 8128, 5, 18, 35, 22, 5, 18, 35, 28384, 5, 18, 35, 7663, 6, 504, 29, 18, 6, 357, 643, 29, 16, 6, 31596, 3126, 16, 26, 83, 93, 6, 2663, 29, 2307, 6, 1370, 288, 1475, 8, 3722, 63, 344, 12, 24102, 73, 12, 8434, 63, 4078, 63, 1069, 14, 3513, 8, 21928, 12, 5048, 29, 66, 7, 1959, 1814, 14078, 1543, 18, 37, 7058, 398, 2256, 63, 12022, 275, 291, 423, 4249, 63, 12022, 8, 288, 2256, 63, 633, 12, 3991, 63, 344, 12, 5317, 534, 18085, 2256, 2034, 358, 267, 2256, 275, 8434, 63, 10290, 14, 1122, 63, 6177, 8, 815, 63, 12022, 9, 398, 340, 283, 1508, 63, 600, 7, 315, 2256, 26, 288, 327, 4750, 402, 314, 900, 781, 883, 5139, 5235, 26038, 2172, 2755, 340, 2329, 63, 600, 365, 13269, 503, 1227, 996, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yongshengwang/builthue
desktop/core/ext-py/Mako-0.8.1/test/test_babelplugin.py
36
1647
from test import TemplateTest, template_base, skip_if try: import babel from mako.ext.babelplugin import extract except: babel = None import os class ExtractMakoTestCase(TemplateTest): @skip_if(lambda: not babel, 'babel not installed: skipping babelplugin test') def test_extract(self): mako_tmpl = open(os.path.join(template_base, 'gettext.mako')) messages = list(extract(mako_tmpl, {'_': None, 'gettext': None, 'ungettext': (1, 2)}, ['TRANSLATOR:'], {})) expected = \ [(1, '_', 'Page arg 1', []), (1, '_', 'Page arg 2', []), (10, 'gettext', 'Begin', []), (14, '_', 'Hi there!', ['TRANSLATOR: Hi there!']), (19, '_', 'Hello', []), (22, '_', 'Welcome', []), (25, '_', 'Yo', []), (36, '_', 'The', ['TRANSLATOR: Ensure so and', 'so, thanks']), (36, 'ungettext', ('bunny', 'bunnies', None), []), (41, '_', 'Goodbye', ['TRANSLATOR: Good bye']), (44, '_', 'Babel', []), (45, 'ungettext', ('hella', 'hellas', None), []), (62, '_', 'The', ['TRANSLATOR: Ensure so and', 'so, thanks']), (62, 'ungettext', ('bunny', 'bunnies', None), []), (68, '_', 'Goodbye, really!', ['TRANSLATOR: HTML comment']), (71, '_', 'P.S. byebye', []), (77, '_', 'Top', []), (83, '_', 'foo', []), (83, '_', 'baz', []), (85, '_', 'bar', []) ] self.assertEqual(expected, messages)
apache-2.0
[ 199, 504, 511, 492, 5458, 774, 12, 1978, 63, 1095, 12, 3372, 63, 692, 199, 199, 893, 26, 272, 492, 29178, 272, 687, 26834, 14, 832, 14, 66, 902, 2718, 492, 5536, 199, 2590, 26, 272, 29178, 275, 488, 523, 199, 646, 747, 421, 199, 533, 12892, 45, 23564, 1746, 8, 4231, 774, 304, 272, 768, 2759, 63, 692, 8, 2734, 26, 440, 29178, 12, 283, 66, 902, 440, 4903, 26, 16068, 29178, 2718, 511, 358, 20950, 347, 511, 63, 5005, 8, 277, 304, 267, 26834, 63, 11510, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 1160, 63, 1095, 12, 283, 5152, 14, 19491, 1333, 267, 3788, 275, 769, 8, 5005, 8, 19491, 63, 11510, 12, 32136, 356, 488, 12, 283, 5152, 356, 488, 12, 4490, 283, 324, 5152, 356, 334, 17, 12, 499, 16658, 1816, 788, 26376, 6467, 26, 995, 17003, 267, 1420, 275, 971, 288, 3842, 17, 12, 25469, 283, 3276, 1680, 413, 297, 14431, 1467, 334, 17, 12, 25469, 283, 3276, 1680, 499, 297, 14431, 1467, 334, 709, 12, 283, 5152, 297, 283, 5595, 297, 14431, 1467, 334, 1079, 12, 25469, 283, 16106, 2337, 12389, 788, 26376, 6467, 26, 869, 73, 2337, 1, 3815, 1467, 334, 1167, 12, 25469, 283, 6257, 297, 14431, 1467, 334, 1081, 12, 25469, 283, 24679, 297, 14431, 1467, 334, 821, 12, 25469, 283, 32154, 297, 14431, 1467, 334, 1344, 12, 25469, 283, 1918, 297, 788, 26376, 6467, 26, 7523, 880, 436, 297, 283, 1152, 12, 2419, 6080, 3815, 1467, 334, 1344, 12, 283, 324, 5152, 297, 661, 66, 324, 9745, 297, 283, 66, 324, 78, 1500, 297, 488, 395, 14431, 1467, 334, 2953, 12, 25469, 283, 20652, 16481, 297, 788, 26376, 6467, 26, 22311, 701, 69, 3815, 1467, 334, 1602, 12, 25469, 283, 34, 902, 297, 14431, 1467, 334, 2322, 12, 283, 324, 5152, 297, 661, 30586, 416, 297, 283, 72, 1697, 305, 297, 488, 395, 14431, 288, 334, 2789, 12, 25469, 283, 1918, 297, 788, 26376, 6467, 26, 7523, 880, 436, 297, 283, 1152, 12, 2419, 6080, 3815, 288, 334, 2789, 12, 283, 324, 5152, 297, 661, 66, 324, 9745, 297, 283, 66, 324, 78, 1500, 297, 488, 395, 14431, 288, 334, 2333, 12, 25469, 283, 20652, 16481, 12, 7710, 12389, 788, 26376, 6467, 26, 4163, 3721, 3815, 288, 334, 3172, 12, 25469, 283, 48, 14, 51, 14, 701, 69, 16481, 297, 14431, 288, 334, 1138, 12, 25469, 283, 6105, 297, 14431, 288, 334, 2658, 12, 25469, 283, 1421, 297, 14431, 288, 334, 2658, 12, 25469, 283, 6185, 297, 14431, 288, 334, 2426, 12, 25469, 283, 1700, 297, 3073, 1467, 1622, 267, 291, 14, 629, 8, 2062, 12, 3788, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 504, 511, 492, 5458, 774, 12, 1978, 63, 1095, 12, 3372, 63, 692, 199, 199, 893, 26, 272, 492, 29178, 272, 687, 26834, 14, 832, 14, 66, 902, 2718, 492, 5536, 199, 2590, 26, 272, 29178, 275, 488, 523, 199, 646, 747, 421, 199, 533, 12892, 45, 23564, 1746, 8, 4231, 774, 304, 272, 768, 2759, 63, 692, 8, 2734, 26, 440, 29178, 12, 283, 66, 902, 440, 4903, 26, 16068, 29178, 2718, 511, 358, 20950, 347, 511, 63, 5005, 8, 277, 304, 267, 26834, 63, 11510, 275, 1551, 8, 736, 14, 515, 14, 904, 8, 1160, 63, 1095, 12, 283, 5152, 14, 19491, 1333, 267, 3788, 275, 769, 8, 5005, 8, 19491, 63, 11510, 12, 32136, 356, 488, 12, 283, 5152, 356, 488, 12, 4490, 283, 324, 5152, 356, 334, 17, 12, 499, 16658, 1816, 788, 26376, 6467, 26, 995, 17003, 267, 1420, 275, 971, 288, 3842, 17, 12, 25469, 283, 3276, 1680, 413, 297, 14431, 1467, 334, 17, 12, 25469, 283, 3276, 1680, 499, 297, 14431, 1467, 334, 709, 12, 283, 5152, 297, 283, 5595, 297, 14431, 1467, 334, 1079, 12, 25469, 283, 16106, 2337, 12389, 788, 26376, 6467, 26, 869, 73, 2337, 1, 3815, 1467, 334, 1167, 12, 25469, 283, 6257, 297, 14431, 1467, 334, 1081, 12, 25469, 283, 24679, 297, 14431, 1467, 334, 821, 12, 25469, 283, 32154, 297, 14431, 1467, 334, 1344, 12, 25469, 283, 1918, 297, 788, 26376, 6467, 26, 7523, 880, 436, 297, 283, 1152, 12, 2419, 6080, 3815, 1467, 334, 1344, 12, 283, 324, 5152, 297, 661, 66, 324, 9745, 297, 283, 66, 324, 78, 1500, 297, 488, 395, 14431, 1467, 334, 2953, 12, 25469, 283, 20652, 16481, 297, 788, 26376, 6467, 26, 22311, 701, 69, 3815, 1467, 334, 1602, 12, 25469, 283, 34, 902, 297, 14431, 1467, 334, 2322, 12, 283, 324, 5152, 297, 661, 30586, 416, 297, 283, 72, 1697, 305, 297, 488, 395, 14431, 288, 334, 2789, 12, 25469, 283, 1918, 297, 788, 26376, 6467, 26, 7523, 880, 436, 297, 283, 1152, 12, 2419, 6080, 3815, 288, 334, 2789, 12, 283, 324, 5152, 297, 661, 66, 324, 9745, 297, 283, 66, 324, 78, 1500, 297, 488, 395, 14431, 288, 334, 2333, 12, 25469, 283, 20652, 16481, 12, 7710, 12389, 788, 26376, 6467, 26, 4163, 3721, 3815, 288, 334, 3172, 12, 25469, 283, 48, 14, 51, 14, 701, 69, 16481, 297, 14431, 288, 334, 1138, 12, 25469, 283, 6105, 297, 14431, 288, 334, 2658, 12, 25469, 283, 1421, 297, 14431, 288, 334, 2658, 12, 25469, 283, 6185, 297, 14431, 288, 334, 2426, 12, 25469, 283, 1700, 297, 3073, 1467, 1622, 267, 291, 14, 629, 8, 2062, 12, 3788, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
heeraj123/oh-mainline
vendor/packages/docutils/docutils/languages/zh_tw.py
148
2771
# -*- coding: utf-8 -*- # $Id: zh_tw.py 4564 2006-05-21 20:44:42Z wiemann $ # Author: Joe YS Jaw <joeysj@users.sourceforge.net> # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please # read <http://docutils.sf.net/docs/howto/i18n.html>. Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. """ Traditional Chinese language mappings for language-dependent features of Docutils. """ __docformat__ = 'reStructuredText' labels = { # fixed: language-dependent 'author': u'\u4f5c\u8005', # '作者' <-- Chinese word 'authors': u'\u4f5c\u8005\u7fa4', # '作者群', 'organization': u'\u7d44\u7e54', # '組織', 'address': u'\u5730\u5740', # '地址', 'contact': u'\u9023\u7d61', # '連絡', 'version': u'\u7248\u672c', # '版本', 'revision': u'\u4fee\u8a02', # '修訂', 'status': u'\u72c0\u614b', # '狀態', 'date': u'\u65e5\u671f', # '日期', 'copyright': u'\u7248\u6b0a', # '版權', 'dedication': u'\u984c\u737b', # '題獻', 'abstract': u'\u6458\u8981', # '摘要', 'attention': u'\u6ce8\u610f\uff01', # '注意!', 'caution': u'\u5c0f\u5fc3\uff01', # '小心!', 'danger': u'\uff01\u5371\u96aa\uff01', # '!危險!', 'error': u'\u932f\u8aa4', # '錯誤', 'hint': u'\u63d0\u793a', # '提示', 'important': u'\u91cd\u8981', # '注意!', 'note': u'\u8a3b\u91cb', # '註釋', 'tip': u'\u79d8\u8a23', # '秘訣', 'warning': u'\u8b66\u544a', # '警告', 'contents': u'\u76ee\u9304' # '目錄' } """Mapping of node class name to label text.""" bibliographic_fields = { # language-dependent: fixed 'author (translation required)': 'author', 'authors (translation required)': 'authors', 'organization (translation required)': 'organization', 'address (translation required)': 'address', 'contact (translation required)': 'contact', 'version (translation required)': 'version', 'revision (translation required)': 'revision', 'status (translation required)': 'status', 'date (translation required)': 'date', 'copyright (translation required)': 'copyright', 'dedication (translation required)': 'dedication', 'abstract (translation required)': 'abstract'} """Traditional Chinese to canonical name mapping for bibliographic fields.""" author_separators = [';', ',', u'\uff1b', # ';' u'\uff0c', # ',' u'\u3001', # '、' ] """List of separator strings for the 'Authors' bibliographic field. Tried in order."""
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2672, 1304, 26, 1315, 72, 63, 8122, 14, 647, 10416, 772, 8315, 13, 1717, 13, 2025, 3388, 26, 1602, 26, 2260, 58, 336, 1873, 20059, 2672, 199, 3, 6529, 26, 7135, 69, 1488, 51, 1603, 10084, 665, 20241, 588, 74, 32, 3707, 14, 22943, 14, 846, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 3, 7053, 2637, 13546, 787, 336, 14628, 14, 221, 21467, 9689, 282, 892, 7761, 12, 8749, 199, 3, 1586, 665, 1014, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 21232, 15, 73, 1085, 78, 14, 1360, 10827, 221, 16853, 1584, 1471, 506, 199, 3, 14598, 367, 1924, 2637, 26, 1373, 315, 18382, 15, 13209, 12, 314, 1163, 315, 199, 3, 18382, 15, 11531, 15, 8332, 15, 13209, 14, 199, 199, 624, 199, 2437, 2603, 2799, 26883, 2637, 13546, 367, 2637, 13, 7106, 4534, 402, 5454, 1208, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 199, 199, 3512, 275, 469, 489, 327, 6317, 26, 2637, 13, 7106, 489, 283, 2502, 356, 399, 1154, 85, 20, 70, 21, 67, 60, 85, 6718, 21, 297, 327, 283, 21927, 18497, 7, 665, 306, 2799, 26883, 4349, 489, 283, 8149, 356, 399, 1154, 85, 20, 70, 21, 67, 60, 85, 6718, 21, 60, 85, 23, 667, 20, 297, 327, 283, 21927, 18497, 164, 123, 98, 297, 489, 283, 9071, 356, 399, 1154, 85, 23, 68, 1602, 60, 85, 23, 69, 1477, 297, 327, 283, 23767, 227, 164, 118, 243, 297, 489, 283, 1562, 356, 399, 1154, 85, 1641, 1216, 60, 85, 10950, 16, 297, 327, 283, 27340, 30899, 223, 297, 489, 283, 7811, 356, 399, 1154, 85, 25, 16771, 60, 85, 23, 68, 2976, 297, 327, 283, 14333, 97, 23767, 95, 297, 489, 283, 1023, 356, 399, 1154, 85, 23, 11242, 60, 85, 20298, 67, 297, 327, 283, 19431, 231, 26304, 297, 489, 283, 5792, 356, 399, 1154, 85, 20, 11195, 60, 85, 24, 65, 996, 297, 327, 283, 13764, 107, 20278, 225, 297, 489, 283, 1205, 356, 399, 1154, 85, 2819, 67, 16, 60, 85, 32392, 66, 297, 327, 283, 164, 234, 223, 163, 228, 234, 297, 489, 283, 602, 356, 399, 1154, 85, 2182, 69, 21, 60, 85, 23772, 70, 297, 327, 283, 31502, 297, 489, 283, 7307, 356, 399, 1154, 85, 23, 11242, 60, 85, 22, 66, 16, 65, 297, 327, 283, 19431, 231, 23974, 233, 297, 489, 283, 271, 21171, 356, 399, 1154, 85, 29703, 67, 60, 85, 29045, 66, 297, 327, 283, 27513, 235, 164, 236, 120, 297, 489, 283, 6198, 356, 399, 1154, 85, 772, 2010, 60, 85, 1407, 2835, 297, 327, 283, 163, 240, 247, 22274, 297, 489, 283, 22393, 356, 399, 1154, 85, 22, 301, 24, 60, 85, 31504, 70, 60, 3043, 614, 297, 327, 283, 20021, 102, 163, 227, 238, 8454, 224, 297, 489, 283, 696, 2206, 356, 399, 1154, 85, 21, 67, 16, 70, 60, 85, 21, 3003, 19, 60, 3043, 614, 297, 327, 283, 15348, 238, 16989, 226, 8454, 224, 297, 489, 283, 68, 12974, 356, 399, 1154, 3043, 614, 60, 85, 21, 16124, 60, 85, 2534, 2158, 60, 3043, 614, 297, 327, 283, 8454, 224, 10450, 110, 166, 249, 104, 8454, 224, 297, 489, 283, 705, 356, 399, 1154, 85, 27251, 70, 60, 85, 24, 2158, 20, 297, 327, 283, 166, 235, 108, 165, 104, 98, 297, 489, 283, 6479, 356, 399, 1154, 85, 2766, 68, 16, 60, 85, 26153, 65, 297, 327, 283, 22843, 239, 29875, 119, 297, 489, 283, 19559, 356, 399, 1154, 85, 3328, 2866, 60, 85, 1407, 2835, 297, 327, 283, 20021, 102, 163, 227, 238, 8454, 224, 297, 489, 283, 4610, 356, 399, 1154, 85, 24, 65, 19, 66, 60, 85, 3328, 2894, 297, 327, 283, 20278, 120, 10770, 234, 297, 489, 283, 8996, 356, 399, 1154, 85, 1965, 68, 24, 60, 85, 24, 65, 1789, 297, 327, 283, 19012, 247, 20278, 97, 297, 489, 283, 3764, 356, 399, 1154, 85, 24, 66, 1272, 60, 85, 16298, 65, 297, 327, 283, 165, 256, 100, 19580, 233, 297, 489, 283, 4407, 356, 399, 1154, 85, 2114, 1024, 60, 85, 3129, 966, 7, 327, 283, 31869, 166, 235, 227, 7, 199, 93, 221, 199, 624, 7674, 402, 1031, 1021, 536, 370, 1768, 1318, 1041, 199, 199, 30892, 63, 955, 275, 469, 489, 327, 2637, 13, 7106, 26, 6317, 489, 283, 2502, 334, 6893, 1415, 11862, 283, 2502, 297, 489, 283, 8149, 334, 6893, 1415, 11862, 283, 8149, 297, 489, 283, 9071, 334, 6893, 1415, 11862, 283, 9071, 297, 489, 283, 1562, 334, 6893, 1415, 11862, 283, 1562, 297, 489, 283, 7811, 334, 6893, 1415, 11862, 283, 7811, 297, 489, 283, 1023, 334, 6893, 1415, 11862, 283, 1023, 297, 489, 283, 5792, 334, 6893, 1415, 11862, 283, 5792, 297, 489, 283, 1205, 334, 6893, 1415, 11862, 283, 1205, 297, 489, 283, 602, 334, 6893, 1415, 11862, 283, 602, 297, 489, 283, 7307, 334, 6893, 1415, 11862, 283, 7307, 297, 489, 283, 271, 21171, 334, 6893, 1415, 11862, 283, 271, 21171, 297, 489, 283, 6198, 334, 6893, 1415, 11862, 283, 6198, 936, 199, 624, 2437, 2603, 2799, 26883, 370, 11358, 536, 4412, 367, 11314, 24623, 1504, 1041, 199, 199, 2502, 63, 29862, 275, 788, 10805, 30048, 2151, 399, 1154, 3043, 17, 66, 297, 327, 283, 8454, 250, 7, 2151, 399, 1154, 3043, 16, 67, 297, 327, 283, 12356, 7, 2151, 399, 1154, 85, 19, 4587, 297, 327, 283, 23709, 7, 490, 1622, 199, 624, 1296, 402, 9432, 3326, 367, 314, 283, 2817, 1384, 7, 11314, 24623, 901, 14, 12480, 379, 315, 199, 1648, 1041, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2672, 1304, 26, 1315, 72, 63, 8122, 14, 647, 10416, 772, 8315, 13, 1717, 13, 2025, 3388, 26, 1602, 26, 2260, 58, 336, 1873, 20059, 2672, 199, 3, 6529, 26, 7135, 69, 1488, 51, 1603, 10084, 665, 20241, 588, 74, 32, 3707, 14, 22943, 14, 846, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 3, 7053, 2637, 13546, 787, 336, 14628, 14, 221, 21467, 9689, 282, 892, 7761, 12, 8749, 199, 3, 1586, 665, 1014, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 21232, 15, 73, 1085, 78, 14, 1360, 10827, 221, 16853, 1584, 1471, 506, 199, 3, 14598, 367, 1924, 2637, 26, 1373, 315, 18382, 15, 13209, 12, 314, 1163, 315, 199, 3, 18382, 15, 11531, 15, 8332, 15, 13209, 14, 199, 199, 624, 199, 2437, 2603, 2799, 26883, 2637, 13546, 367, 2637, 13, 7106, 4534, 402, 5454, 1208, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 199, 199, 3512, 275, 469, 489, 327, 6317, 26, 2637, 13, 7106, 489, 283, 2502, 356, 399, 1154, 85, 20, 70, 21, 67, 60, 85, 6718, 21, 297, 327, 283, 21927, 18497, 7, 665, 306, 2799, 26883, 4349, 489, 283, 8149, 356, 399, 1154, 85, 20, 70, 21, 67, 60, 85, 6718, 21, 60, 85, 23, 667, 20, 297, 327, 283, 21927, 18497, 164, 123, 98, 297, 489, 283, 9071, 356, 399, 1154, 85, 23, 68, 1602, 60, 85, 23, 69, 1477, 297, 327, 283, 23767, 227, 164, 118, 243, 297, 489, 283, 1562, 356, 399, 1154, 85, 1641, 1216, 60, 85, 10950, 16, 297, 327, 283, 27340, 30899, 223, 297, 489, 283, 7811, 356, 399, 1154, 85, 25, 16771, 60, 85, 23, 68, 2976, 297, 327, 283, 14333, 97, 23767, 95, 297, 489, 283, 1023, 356, 399, 1154, 85, 23, 11242, 60, 85, 20298, 67, 297, 327, 283, 19431, 231, 26304, 297, 489, 283, 5792, 356, 399, 1154, 85, 20, 11195, 60, 85, 24, 65, 996, 297, 327, 283, 13764, 107, 20278, 225, 297, 489, 283, 1205, 356, 399, 1154, 85, 2819, 67, 16, 60, 85, 32392, 66, 297, 327, 283, 164, 234, 223, 163, 228, 234, 297, 489, 283, 602, 356, 399, 1154, 85, 2182, 69, 21, 60, 85, 23772, 70, 297, 327, 283, 31502, 297, 489, 283, 7307, 356, 399, 1154, 85, 23, 11242, 60, 85, 22, 66, 16, 65, 297, 327, 283, 19431, 231, 23974, 233, 297, 489, 283, 271, 21171, 356, 399, 1154, 85, 29703, 67, 60, 85, 29045, 66, 297, 327, 283, 27513, 235, 164, 236, 120, 297, 489, 283, 6198, 356, 399, 1154, 85, 772, 2010, 60, 85, 1407, 2835, 297, 327, 283, 163, 240, 247, 22274, 297, 489, 283, 22393, 356, 399, 1154, 85, 22, 301, 24, 60, 85, 31504, 70, 60, 3043, 614, 297, 327, 283, 20021, 102, 163, 227, 238, 8454, 224, 297, 489, 283, 696, 2206, 356, 399, 1154, 85, 21, 67, 16, 70, 60, 85, 21, 3003, 19, 60, 3043, 614, 297, 327, 283, 15348, 238, 16989, 226, 8454, 224, 297, 489, 283, 68, 12974, 356, 399, 1154, 3043, 614, 60, 85, 21, 16124, 60, 85, 2534, 2158, 60, 3043, 614, 297, 327, 283, 8454, 224, 10450, 110, 166, 249, 104, 8454, 224, 297, 489, 283, 705, 356, 399, 1154, 85, 27251, 70, 60, 85, 24, 2158, 20, 297, 327, 283, 166, 235, 108, 165, 104, 98, 297, 489, 283, 6479, 356, 399, 1154, 85, 2766, 68, 16, 60, 85, 26153, 65, 297, 327, 283, 22843, 239, 29875, 119, 297, 489, 283, 19559, 356, 399, 1154, 85, 3328, 2866, 60, 85, 1407, 2835, 297, 327, 283, 20021, 102, 163, 227, 238, 8454, 224, 297, 489, 283, 4610, 356, 399, 1154, 85, 24, 65, 19, 66, 60, 85, 3328, 2894, 297, 327, 283, 20278, 120, 10770, 234, 297, 489, 283, 8996, 356, 399, 1154, 85, 1965, 68, 24, 60, 85, 24, 65, 1789, 297, 327, 283, 19012, 247, 20278, 97, 297, 489, 283, 3764, 356, 399, 1154, 85, 24, 66, 1272, 60, 85, 16298, 65, 297, 327, 283, 165, 256, 100, 19580, 233, 297, 489, 283, 4407, 356, 399, 1154, 85, 2114, 1024, 60, 85, 3129, 966, 7, 327, 283, 31869, 166, 235, 227, 7, 199, 93, 221, 199, 624, 7674, 402, 1031, 1021, 536, 370, 1768, 1318, 1041, 199, 199, 30892, 63, 955, 275, 469, 489, 327, 2637, 13, 7106, 26, 6317, 489, 283, 2502, 334, 6893, 1415, 11862, 283, 2502, 297, 489, 283, 8149, 334, 6893, 1415, 11862, 283, 8149, 297, 489, 283, 9071, 334, 6893, 1415, 11862, 283, 9071, 297, 489, 283, 1562, 334, 6893, 1415, 11862, 283, 1562, 297, 489, 283, 7811, 334, 6893, 1415, 11862, 283, 7811, 297, 489, 283, 1023, 334, 6893, 1415, 11862, 283, 1023, 297, 489, 283, 5792, 334, 6893, 1415, 11862, 283, 5792, 297, 489, 283, 1205, 334, 6893, 1415, 11862, 283, 1205, 297, 489, 283, 602, 334, 6893, 1415, 11862, 283, 602, 297, 489, 283, 7307, 334, 6893, 1415, 11862, 283, 7307, 297, 489, 283, 271, 21171, 334, 6893, 1415, 11862, 283, 271, 21171, 297, 489, 283, 6198, 334, 6893, 1415, 11862, 283, 6198, 936, 199, 624, 2437, 2603, 2799, 26883, 370, 11358, 536, 4412, 367, 11314, 24623, 1504, 1041, 199, 199, 2502, 63, 29862, 275, 788, 10805, 30048, 2151, 399, 1154, 3043, 17, 66, 297, 327, 283, 8454, 250, 7, 2151, 399, 1154, 3043, 16, 67, 297, 327, 283, 12356, 7, 2151, 399, 1154, 85, 19, 4587, 297, 327, 283, 23709, 7, 490, 1622, 199, 624, 1296, 402, 9432, 3326, 367, 314, 283, 2817, 1384, 7, 11314, 24623, 901, 14, 12480, 379, 315, 199, 1648, 1041, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
teamosceola/bitbake
lib/bb/ui/knotty.py
1
12691
# # BitBake (No)TTY UI Implementation # # Handling output to TTYs or files (no TTY) # # Copyright (C) 2006-2007 Richard Purdie # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from __future__ import division import os import sys import xmlrpclib import logging import progressbar import bb.msg from bb.ui import uihelper logger = logging.getLogger("BitBake") interactive = sys.stdout.isatty() class BBProgress(progressbar.ProgressBar): def __init__(self, msg, maxval): self.msg = msg widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.ETA()] progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets) class NonInteractiveProgress(object): fobj = sys.stdout def __init__(self, msg, maxval): self.msg = msg self.maxval = maxval def start(self): self.fobj.write("%s..." % self.msg) self.fobj.flush() return self def update(self, value): pass def finish(self): self.fobj.write("done.\n") self.fobj.flush() def new_progress(msg, maxval): if interactive: return BBProgress(msg, maxval) else: return NonInteractiveProgress(msg, maxval) def pluralise(singular, plural, qty): if(qty == 1): return singular % qty else: return plural % qty def main(server, eventHandler): # Get values of variables which control our output includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"]) loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"]) helper = uihelper.BBUIHelper() console = logging.StreamHandler(sys.stdout) format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") bb.msg.addDefaultlogFilter(console) console.setFormatter(format) logger.addHandler(console) if consolelogfile: consolelog = logging.FileHandler(consolelogfile) bb.msg.addDefaultlogFilter(consolelog) consolelog.setFormatter(format) logger.addHandler(consolelog) try: cmdline = server.runCommand(["getCmdLineAction"]) if not cmdline: print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") return 1 elif not cmdline['action']: print(cmdline['msg']) return 1 ret = server.runCommand(cmdline['action']) if ret != True: print("Couldn't get default commandline! %s" % ret) return 1 except xmlrpclib.Fault as x: print("XMLRPC Fault getting commandline:\n %s" % x) return 1 parseprogress = None cacheprogress = None shutdown = 0 interrupted = False return_value = 0 errors = 0 warnings = 0 taskfailures = [] while True: try: event = eventHandler.waitEvent(0.25) if event is None: if shutdown > 1: break continue helper.eventHandler(event) if isinstance(event, bb.runqueue.runQueueExitWait): if not shutdown: shutdown = 1 if shutdown and helper.needUpdate: activetasks, failedtasks = helper.getTasks() if activetasks: print("Waiting for %s active tasks to finish:" % len(activetasks)) for tasknum, task in enumerate(activetasks): print("%s: %s (pid %s)" % (tasknum, activetasks[task]["title"], task)) if isinstance(event, logging.LogRecord): if event.levelno >= format.ERROR: errors = errors + 1 return_value = 1 elif event.levelno == format.WARNING: warnings = warnings + 1 # For "normal" logging conditions, don't show note logs from tasks # but do show them if the user has changed the default log level to # include verbose/debug messages if event.taskpid != 0 and event.levelno <= format.NOTE: continue logger.handle(event) continue if isinstance(event, bb.build.TaskFailed): return_value = 1 logfile = event.logfile if logfile and os.path.exists(logfile): print("ERROR: Logfile of failure stored in: %s" % logfile) if includelogs and not event.errprinted: print("Log data follows:") f = open(logfile, "r") lines = [] while True: l = f.readline() if l == '': break l = l.rstrip() if loglines: lines.append(' | %s' % l) if len(lines) > int(loglines): lines.pop(0) else: print('| %s' % l) f.close() if lines: for line in lines: print(line) if isinstance(event, bb.build.TaskBase): logger.info(event._message) continue if isinstance(event, bb.event.ParseStarted): if event.total == 0: continue parseprogress = new_progress("Parsing recipes", event.total).start() continue if isinstance(event, bb.event.ParseProgress): parseprogress.update(event.current) continue if isinstance(event, bb.event.ParseCompleted): if not parseprogress: continue parseprogress.finish() print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) continue if isinstance(event, bb.event.CacheLoadStarted): cacheprogress = new_progress("Loading cache", event.total).start() continue if isinstance(event, bb.event.CacheLoadProgress): cacheprogress.update(event.current) continue if isinstance(event, bb.event.CacheLoadCompleted): cacheprogress.finish() print("Loaded %d entries from dependency cache." % event.num_entries) continue if isinstance(event, bb.command.CommandFailed): return_value = event.exitcode errors = errors + 1 logger.error("Command execution failed: %s", event.error) shutdown = 2 continue if isinstance(event, bb.command.CommandExit): if not return_value: return_value = event.exitcode continue if isinstance(event, (bb.command.CommandCompleted, bb.cooker.CookerExit)): shutdown = 2 continue if isinstance(event, bb.event.MultipleProviders): logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "", event._item, ", ".join(event._candidates)) logger.info("consider defining a PREFERRED_PROVIDER entry to match %s", event._item) continue if isinstance(event, bb.event.NoProvider): return_value = 1 errors = errors + 1 if event._runtime: r = "R" else: r = "" if event._dependees: logger.error("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)", r, event._item, ", ".join(event._dependees), r) else: logger.error("Nothing %sPROVIDES '%s'", r, event._item) if event._reasons: for reason in event._reasons: logger.error("%s", reason) continue if isinstance(event, bb.runqueue.sceneQueueTaskStarted): logger.info("Running setscene task %d of %d (%s)" % (event.stats.completed + event.stats.active + event.stats.failed + 1, event.stats.total, event.taskstring)) continue if isinstance(event, bb.runqueue.runQueueTaskStarted): if event.noexec: tasktype = 'noexec task' else: tasktype = 'task' logger.info("Running %s %s of %s (ID: %s, %s)", tasktype, event.stats.completed + event.stats.active + event.stats.failed + 1, event.stats.total, event.taskid, event.taskstring) continue if isinstance(event, bb.runqueue.runQueueTaskFailed): taskfailures.append(event.taskstring) logger.error("Task %s (%s) failed with exit code '%s'", event.taskid, event.taskstring, event.exitcode) continue if isinstance(event, bb.runqueue.sceneQueueTaskFailed): logger.warn("Setscene task %s (%s) failed with exit code '%s' - real task will be run instead", event.taskid, event.taskstring, event.exitcode) continue # ignore if isinstance(event, (bb.event.BuildBase, bb.event.StampUpdate, bb.event.ConfigParsed, bb.event.RecipeParsed, bb.event.RecipePreFinalise, bb.runqueue.runQueueEvent, bb.runqueue.runQueueExitWait, bb.event.OperationStarted, bb.event.OperationCompleted, bb.event.OperationProgress)): continue logger.error("Unknown event: %s", event) except EnvironmentError as ioerror: # ignore interrupted io if ioerror.args[0] == 4: pass except KeyboardInterrupt: if shutdown == 1: print("\nSecond Keyboard Interrupt, stopping...\n") server.runCommand(["stateStop"]) if shutdown == 0: interrupted = True print("\nKeyboard Interrupt, closing down...\n") server.runCommand(["stateShutdown"]) shutdown = shutdown + 1 pass summary = "" if taskfailures: summary += pluralise("\nSummary: %s task failed:", "\nSummary: %s tasks failed:", len(taskfailures)) for failure in taskfailures: summary += "\n %s" % failure if warnings: summary += pluralise("\nSummary: There was %s WARNING message shown.", "\nSummary: There were %s WARNING messages shown.", warnings) if return_value: summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) if summary: print(summary) if interrupted: print("Execution was interrupted, returning a non-zero exit code.") if return_value == 0: return_value = 1 return return_value
gpl-2.0
[ 3, 199, 3, 10199, 34, 1728, 334, 1944, 9, 1481, 57, 14041, 24425, 199, 3, 199, 3, 18405, 2983, 1072, 370, 377, 2099, 83, 503, 1584, 334, 889, 377, 2099, 9, 199, 3, 199, 3, 1898, 334, 35, 9, 8315, 13, 9488, 30846, 1005, 23177, 15130, 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, 1015, 499, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 747, 199, 646, 984, 199, 646, 19122, 199, 646, 2050, 199, 646, 6696, 1700, 199, 646, 14027, 14, 1328, 199, 504, 14027, 14, 1907, 492, 8574, 3676, 199, 199, 2921, 275, 2050, 14, 5572, 480, 4734, 34, 1728, 531, 199, 13543, 275, 984, 14, 2703, 14, 21122, 342, 199, 199, 533, 699, 34, 11504, 8, 5734, 1700, 14, 11504, 5281, 304, 272, 347, 636, 826, 721, 277, 12, 1499, 12, 23291, 304, 267, 291, 14, 1328, 275, 1499, 267, 11114, 275, 359, 5734, 1700, 14, 17931, 474, 1062, 283, 1656, 6696, 1700, 14, 5281, 1062, 283, 1656, 1779, 6696, 1700, 14, 15808, 5106, 398, 6696, 1700, 14, 11504, 5281, 855, 826, 721, 277, 12, 23291, 12, 359, 277, 14, 1328, 435, 7244, 32705, 435, 11114, 9, 199, 199, 533, 10172, 23879, 11504, 8, 785, 304, 272, 29962, 275, 984, 14, 2703, 339, 347, 636, 826, 721, 277, 12, 1499, 12, 23291, 304, 267, 291, 14, 1328, 275, 1499, 267, 291, 14, 30909, 275, 23291, 339, 347, 1343, 8, 277, 304, 267, 291, 14, 32755, 14, 952, 3647, 83, 11500, 450, 291, 14, 1328, 9, 267, 291, 14, 32755, 14, 4939, 342, 267, 372, 291, 339, 347, 1678, 8, 277, 12, 574, 304, 267, 986, 339, 347, 9578, 8, 277, 304, 267, 291, 14, 32755, 14, 952, 480, 4456, 3134, 78, 531, 267, 291, 14, 32755, 14, 4939, 342, 199, 199, 318, 892, 63, 5734, 8, 1328, 12, 23291, 304, 272, 340, 12777, 26, 267, 372, 699, 34, 11504, 8, 1328, 12, 23291, 9, 272, 587, 26, 267, 372, 10172, 23879, 11504, 8, 1328, 12, 23291, 9, 199, 199, 318, 11718, 572, 8, 17045, 12, 11718, 12, 13556, 304, 272, 340, 8, 5643, 508, 413, 304, 267, 372, 15823, 450, 13556, 272, 587, 26, 267, 372, 11718, 450, 13556, 199, 199, 318, 2446, 8, 1000, 12, 1566, 2461, 304, 339, 327, 2372, 1338, 402, 2860, 1314, 3304, 4154, 1072, 272, 2387, 7270, 275, 1654, 14, 1065, 3110, 5234, 362, 2773, 401, 298, 5342, 18171, 4947, 51, 3135, 272, 943, 1278, 275, 1654, 14, 1065, 3110, 5234, 362, 2773, 401, 298, 5342, 18171, 4947, 51, 63, 23023, 3135, 272, 8559, 12804, 275, 1654, 14, 1065, 3110, 5234, 362, 2773, 401, 298, 5342, 63, 31774, 4947, 3135, 339, 5922, 275, 8574, 3676, 14, 34, 2910, 41, 4433, 342, 339, 8559, 275, 2050, 14, 22482, 8, 1274, 14, 2703, 9, 272, 1475, 275, 14027, 14, 1328, 14, 5342, 2445, 7772, 480, 2840, 20056, 9, 83, 26, 2818, 1188, 9, 83, 531, 272, 14027, 14, 1328, 14, 525, 2698, 793, 4131, 8, 6614, 9, 272, 8559, 14, 26076, 8, 908, 9, 272, 2512, 14, 18826, 8, 6614, 9, 272, 340, 8559, 12804, 26, 267, 8559, 793, 275, 2050, 14, 21982, 8, 6614, 12804, 9, 267, 14027, 14, 1328, 14, 525, 2698, 793, 4131, 8, 6614, 793, 9, 267, 8559, 793, 14, 26076, 8, 908, 9, 267, 2512, 14, 18826, 8, 6614, 793, 9, 339, 862, 26, 267, 21206, 275, 1654, 14, 1065, 3110, 5234, 362, 7874, 3049, 3310, 3135, 267, 340, 440, 21206, 26, 288, 870, 480, 19627, 370, 886, 14, 221, 3645, 283, 2075, 66, 1728, 6701, 7, 370, 1900, 8137, 12, 503, 1255, 283, 2075, 66, 1728, 1553, 3437, 7, 367, 4503, 2556, 2685, 288, 372, 413, 267, 916, 440, 21206, 459, 1287, 2565, 288, 870, 8, 15612, 459, 1328, 1105, 288, 372, 413, 267, 2203, 275, 1654, 14, 1065, 3110, 8, 15612, 459, 1287, 1105, 267, 340, 2203, 1137, 715, 26, 288, 870, 480, 20485, 1133, 664, 849, 28279, 1, 450, 83, 2, 450, 2203, 9, 288, 372, 413, 272, 871, 19122, 14, 16665, 465, 671, 26, 267, 870, 480, 27026, 31422, 10232, 28279, 3427, 78, 450, 83, 2, 450, 671, 9, 267, 372, 413, 2378, 2198, 5734, 275, 488, 272, 2581, 5734, 275, 488, 272, 12842, 275, 378, 272, 31366, 275, 756, 272, 372, 63, 585, 275, 378, 272, 2552, 275, 378, 272, 3598, 275, 378, 272, 2120, 9968, 275, 942, 272, 1830, 715, 26, 267, 862, 26, 288, 1566, 275, 1566, 2461, 14, 2573, 2390, 8, 16, 14, 821, 9, 288, 340, 1566, 365, 488, 26, 355, 340, 12842, 690, 413, 26, 490, 2059, 355, 1980, 288, 5922, 14, 1430, 2461, 8, 1430, 9, 288, 340, 1228, 8, 1430, 12, 14027, 14, 1065, 1825, 14, 1065, 3737, 6699, 7536, 304, 355, 340, 440, 12842, 26, 490, 12842, 275, 413, 288, 340, 12842, 436, 5922, 14, 9321, 4152, 26, 355, 6633, 28350, 813, 83, 12, 3405, 5054, 275, 5922, 14, 362, 19295, 342, 355, 340, 6633, 28350, 813, 83, 26, 490, 870, 480, 19189, 367, 450, 83, 4702, 6527, 370, 9578, 5424, 450, 822, 8, 5416, 28350, 813, 83, 430, 490, 367, 2120, 1507, 12, 2120, 315, 3874, 8, 5416, 28350, 813, 83, 304, 717, 870, 3647, 83, 26, 450, 83, 334, 3150, 450, 83, 2924, 450, 334, 1765, 1507, 12, 6633, 28350, 813, 83, 59, 1765, 7541, 1213, 2255, 2120 ]
[ 199, 3, 10199, 34, 1728, 334, 1944, 9, 1481, 57, 14041, 24425, 199, 3, 199, 3, 18405, 2983, 1072, 370, 377, 2099, 83, 503, 1584, 334, 889, 377, 2099, 9, 199, 3, 199, 3, 1898, 334, 35, 9, 8315, 13, 9488, 30846, 1005, 23177, 15130, 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, 1015, 499, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 747, 199, 646, 984, 199, 646, 19122, 199, 646, 2050, 199, 646, 6696, 1700, 199, 646, 14027, 14, 1328, 199, 504, 14027, 14, 1907, 492, 8574, 3676, 199, 199, 2921, 275, 2050, 14, 5572, 480, 4734, 34, 1728, 531, 199, 13543, 275, 984, 14, 2703, 14, 21122, 342, 199, 199, 533, 699, 34, 11504, 8, 5734, 1700, 14, 11504, 5281, 304, 272, 347, 636, 826, 721, 277, 12, 1499, 12, 23291, 304, 267, 291, 14, 1328, 275, 1499, 267, 11114, 275, 359, 5734, 1700, 14, 17931, 474, 1062, 283, 1656, 6696, 1700, 14, 5281, 1062, 283, 1656, 1779, 6696, 1700, 14, 15808, 5106, 398, 6696, 1700, 14, 11504, 5281, 855, 826, 721, 277, 12, 23291, 12, 359, 277, 14, 1328, 435, 7244, 32705, 435, 11114, 9, 199, 199, 533, 10172, 23879, 11504, 8, 785, 304, 272, 29962, 275, 984, 14, 2703, 339, 347, 636, 826, 721, 277, 12, 1499, 12, 23291, 304, 267, 291, 14, 1328, 275, 1499, 267, 291, 14, 30909, 275, 23291, 339, 347, 1343, 8, 277, 304, 267, 291, 14, 32755, 14, 952, 3647, 83, 11500, 450, 291, 14, 1328, 9, 267, 291, 14, 32755, 14, 4939, 342, 267, 372, 291, 339, 347, 1678, 8, 277, 12, 574, 304, 267, 986, 339, 347, 9578, 8, 277, 304, 267, 291, 14, 32755, 14, 952, 480, 4456, 3134, 78, 531, 267, 291, 14, 32755, 14, 4939, 342, 199, 199, 318, 892, 63, 5734, 8, 1328, 12, 23291, 304, 272, 340, 12777, 26, 267, 372, 699, 34, 11504, 8, 1328, 12, 23291, 9, 272, 587, 26, 267, 372, 10172, 23879, 11504, 8, 1328, 12, 23291, 9, 199, 199, 318, 11718, 572, 8, 17045, 12, 11718, 12, 13556, 304, 272, 340, 8, 5643, 508, 413, 304, 267, 372, 15823, 450, 13556, 272, 587, 26, 267, 372, 11718, 450, 13556, 199, 199, 318, 2446, 8, 1000, 12, 1566, 2461, 304, 339, 327, 2372, 1338, 402, 2860, 1314, 3304, 4154, 1072, 272, 2387, 7270, 275, 1654, 14, 1065, 3110, 5234, 362, 2773, 401, 298, 5342, 18171, 4947, 51, 3135, 272, 943, 1278, 275, 1654, 14, 1065, 3110, 5234, 362, 2773, 401, 298, 5342, 18171, 4947, 51, 63, 23023, 3135, 272, 8559, 12804, 275, 1654, 14, 1065, 3110, 5234, 362, 2773, 401, 298, 5342, 63, 31774, 4947, 3135, 339, 5922, 275, 8574, 3676, 14, 34, 2910, 41, 4433, 342, 339, 8559, 275, 2050, 14, 22482, 8, 1274, 14, 2703, 9, 272, 1475, 275, 14027, 14, 1328, 14, 5342, 2445, 7772, 480, 2840, 20056, 9, 83, 26, 2818, 1188, 9, 83, 531, 272, 14027, 14, 1328, 14, 525, 2698, 793, 4131, 8, 6614, 9, 272, 8559, 14, 26076, 8, 908, 9, 272, 2512, 14, 18826, 8, 6614, 9, 272, 340, 8559, 12804, 26, 267, 8559, 793, 275, 2050, 14, 21982, 8, 6614, 12804, 9, 267, 14027, 14, 1328, 14, 525, 2698, 793, 4131, 8, 6614, 793, 9, 267, 8559, 793, 14, 26076, 8, 908, 9, 267, 2512, 14, 18826, 8, 6614, 793, 9, 339, 862, 26, 267, 21206, 275, 1654, 14, 1065, 3110, 5234, 362, 7874, 3049, 3310, 3135, 267, 340, 440, 21206, 26, 288, 870, 480, 19627, 370, 886, 14, 221, 3645, 283, 2075, 66, 1728, 6701, 7, 370, 1900, 8137, 12, 503, 1255, 283, 2075, 66, 1728, 1553, 3437, 7, 367, 4503, 2556, 2685, 288, 372, 413, 267, 916, 440, 21206, 459, 1287, 2565, 288, 870, 8, 15612, 459, 1328, 1105, 288, 372, 413, 267, 2203, 275, 1654, 14, 1065, 3110, 8, 15612, 459, 1287, 1105, 267, 340, 2203, 1137, 715, 26, 288, 870, 480, 20485, 1133, 664, 849, 28279, 1, 450, 83, 2, 450, 2203, 9, 288, 372, 413, 272, 871, 19122, 14, 16665, 465, 671, 26, 267, 870, 480, 27026, 31422, 10232, 28279, 3427, 78, 450, 83, 2, 450, 671, 9, 267, 372, 413, 2378, 2198, 5734, 275, 488, 272, 2581, 5734, 275, 488, 272, 12842, 275, 378, 272, 31366, 275, 756, 272, 372, 63, 585, 275, 378, 272, 2552, 275, 378, 272, 3598, 275, 378, 272, 2120, 9968, 275, 942, 272, 1830, 715, 26, 267, 862, 26, 288, 1566, 275, 1566, 2461, 14, 2573, 2390, 8, 16, 14, 821, 9, 288, 340, 1566, 365, 488, 26, 355, 340, 12842, 690, 413, 26, 490, 2059, 355, 1980, 288, 5922, 14, 1430, 2461, 8, 1430, 9, 288, 340, 1228, 8, 1430, 12, 14027, 14, 1065, 1825, 14, 1065, 3737, 6699, 7536, 304, 355, 340, 440, 12842, 26, 490, 12842, 275, 413, 288, 340, 12842, 436, 5922, 14, 9321, 4152, 26, 355, 6633, 28350, 813, 83, 12, 3405, 5054, 275, 5922, 14, 362, 19295, 342, 355, 340, 6633, 28350, 813, 83, 26, 490, 870, 480, 19189, 367, 450, 83, 4702, 6527, 370, 9578, 5424, 450, 822, 8, 5416, 28350, 813, 83, 430, 490, 367, 2120, 1507, 12, 2120, 315, 3874, 8, 5416, 28350, 813, 83, 304, 717, 870, 3647, 83, 26, 450, 83, 334, 3150, 450, 83, 2924, 450, 334, 1765, 1507, 12, 6633, 28350, 813, 83, 59, 1765, 7541, 1213, 2255, 2120, 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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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 ]
jonasstein/cryspy
cryspy/fromstr.py
3
10829
from cryspy import numbers as nb import quicktions as fr import uncertainties as uc from cryspy import geo as geo import re def removeletters(string): assert isinstance(string, str), \ "Argument must be of type str." string = re.sub("[a-zA-Z]", " ", string) return string def str2linearterm(string, liste_variables): assert isinstance(string, str), \ "Argument must be of type str." assert isinstance(liste_variables, list), \ "Argument must be of type list." for item in liste_variables: assert isinstance(item, str), \ "Argument must be a list of objects of type str." string = string.replace('-', '+-') string = string.replace(' ', '') words = string.split('+') liste_numbers = [0 for i in range(len(liste_variables) + 1)] for word in words: has_variable = False index = -1 for a in word: if a.isalpha(): word = word.replace(a, '') index = liste_variables.index(a) has_variable = True if word == '' or word == '-': if has_variable: word += '1' else: word += '0' liste_numbers[index] += fromstr(word) return liste_numbers def fromstr(string): assert isinstance(string, str), \ "Function fromstr must have an argument of type string." typ = typefromstr(string) if typ == nb.Mixed: try: result = mixedfromstr(string) assert isinstance(result, nb.Mixed), \ "The following string looks like a number, but I "\ "cannot convert it: %s" % (string) return result except: pass elif typ == nb.Matrix: try: return matrixfromstr(string) except ValueError: raise(Exception("The following string looks like a Matrix, " "but I cannot convert it: %s" % (string))) elif typ == geo.Symmetry: try: return symmetryfromstr(string) except ValueError: raise(Exception("The following string looks like a Symmetry, " "but I cannot convert it: %s" % (string))) elif typ == geo.Transformation: try: return transformationfromstr(string) except ValueError: raise(Exception("The following string looks like a " "Transformation, but I cannot convert it: %s" % (string))) elif typ == geo.Coset: try: return cosetfromstr(string) except ValueError: raise(Exception("The following string looks like a Coset " "but I cannot convert it: %s" % (string))) elif typ == geo.Pos: try: return posfromstr(string) except ValueError: raise(Exception("The following string looks like a Pos " "but I cannot convert it: %s" % (string))) elif typ == geo.Dif: try: return diffromstr(string) except ValueError: raise(Exception("The following string looks like a Dif " "but I cannot convert it: %s" % (string))) elif typ == geo.Rec: try: return recfromstr(string) except ValueError: raise(Exception("The following string looks like a Rec " "but I cannot convert it: %s" % (string))) def typefromstr(string): words = string.split() if ('Rec' in string): return geo.Rec elif re.findall("[abc]|then|O|->", string) != []: return geo.Transformation elif (words[0][0] == '/') and words[-1][-1] == '/': return nb.Matrix elif (words[0][0] == '<') and (words[-1][-1] == '>'): return nb.Matrix elif re.findall("[pPrR]", string) != []: return geo.Pos elif ('d' in string) or ('D' in string): return geo.Dif elif re.findall("[kKqQ]", string) != []: return geo.Rec elif ('{' in string) and ('}' in string): return geo.Coset elif ('x' in string) or ('y' in string) or ('z' in string): return geo.Symmetry elif ('\n' in string) or ('\\' in string) or (' ' in string): return nb.Matrix else: return nb.Mixed def mixedfromstr(string): try: return nb.Mixed(int(string)) except: try: return nb.Mixed(float(string)) except: try: return nb.Mixed(fr.Fraction(string)) except ValueError: try: return nb.Mixed(uc.ufloat_fromstr(string)) except ValueError: raise(Exception("The following string looks like a number, " "but I can't convert it: %s" % (string))) def matrixfromstr(string): string = string.replace('|', '\\') string = re.sub('\/ | \/|[<>]', ' ', string) # string = string.replace('/ ', ' ') # string = string.replace('<', ' ') # string = string.replace('>', ' ') # string = string.replace(' /', ' ') string = string.replace('\n', '\\') # string = re.sub('\\\\ +\\\\', '\\', string) for i in range(4): string = string.replace('\\ \\', '\\') string = string.replace('\\ \\', '\\') string = string.replace('\\ \\', '\\') rowwords = string.split('\\') rowliste = [] for rowword in rowwords: words = rowword.split() liste = [] for word in words: liste.append(mixedfromstr(word)) rowliste.append(nb.Row(liste)) return nb.Matrix(rowliste) def symmetryfromstr(string): words = string.split(',') assert len(words) == 3, \ "The following string looks like a Symmetry, but it has not "\ "three comma-separated terms: %s" % (string) liste = [] for word in words: row = nb.Row(str2linearterm(word, ['x', 'y', 'z'])) liste.append(row) liste.append(nb.Row([fromstr("0"), fromstr("0"), fromstr("0"), fromstr("1")])) return geo.Symmetry(nb.Matrix(liste)) def transformationfromstr(string): if len(string.split("then")) > 1: # The string respresents not an elementar transformation, # i.e. the string represents a transformation which is # a composition of elementar transformations. result = geo.Transformation(nb.Matrix.onematrix(4)) for word in string.split("\nthen\n"): result = transformationfromstr(word) * result return result else: # The string represents an elementar transformation, # i.e. either a pure translation of the origin or a # pure change of the axes. if ('O' in string) or ("->" in string): # The string represents a pure translation of the origin. words = string.split("->") word = words[1] word = word.replace('\n', ' ') word = word.replace('(', ' ').replace(')', ' ').replace(',', ' ') threenumbers = fromstr(word) matrix = nb.Matrix([[1, 0, 0, -threenumbers.liste[0].liste[0]], [0, 1, 0, -threenumbers.liste[0].liste[1]], [0, 0, 1, -threenumbers.liste[0].liste[2]], [0, 0, 0, 1 ]]) return geo.Transformation(matrix) elif ('a' in string) or ('b' in string) or ('c' in string): # The string represents a pure change of the axes lines = string.split('\n') assert len(lines) == 3, \ "The following string looks like a Transformation, " \ "but it has not exactly three lines: %s" % (string) liste = [] i = 0 for line in lines: if len(line.split(' ')) > 0: i += 1 words = line.split(' ') assert ( ((i == 1) and (words[0] == "a'")) or ((i == 2) and (words[0] == "b'")) or ((i == 3) and (words[0] == "c'")) )\ and (words[1] == '='), \ "The Transformation must have the following form: \n" \ "a' = ... \n" \ "b' = ... \n" \ "c' = ... \n" \ "in this Order!" words = line.split('=') row = nb.Row(str2linearterm(words[1], ['a', 'b', 'c'])) liste.append(row) liste.append(nb.Row([fromstr("0"), fromstr("0"), fromstr("0"), fromstr("1")])) m = nb.Matrix(liste) matrix = nb.Matrix( [nb.Row([m.liste[0].liste[0], m.liste[1].liste[0], m.liste[2].liste[0], 0]), nb.Row([m.liste[0].liste[1], m.liste[1].liste[1], m.liste[2].liste[1], 0]), nb.Row([m.liste[0].liste[2], m.liste[1].liste[2], m.liste[2].liste[2], 0]), nb.Row([0, 0, 0, 1])]) return geo.Transformation(matrix.inv()) def cosetfromstr(string): string = re.sub('[{}]', ' ', string) # string = string.replace('{', ' ') # string = string.replace('}', ' ') return geo.Coset(fromstr(string), geo.canonical) def posfromstr(string): string = re.sub('\\\\| \/|\/ |\|', ' ', string) string = string.replace('\n', ' ') # string = string.replace('\\', ' ') # string = string.replace('/ ', ' ') # string = string.replace(' /', ' ') # string = string.replace('|', ' ') string = removeletters(string) words = string.split() string = '\n'.join(words) string += "\n 1" return geo.Pos(matrixfromstr(string)) def diffromstr(string): string = string.replace('\n', ' ') string = re.sub("\\\\| \/|\/ |\|", " ", string) # string = string.replace('\\', ' ') # string = string.replace('/ ', ' ') # string = string.replace(' /', ' ') # string = string.replace('|', ' ') string = removeletters(string) words = string.split() string = '\n'.join(words) string += "\n 0" return geo.Dif(matrixfromstr(string)) def recfromstr(string): string = string.replace('\n', ' ') string = re.sub("\\\\| \/|\/ |[|<>]", " ", string) # string = string.replace('\\', ' ') # string = string.replace('/ ', ' ') # string = string.replace(' /', ' ') # string = string.replace('|', ' ') # string = string.replace('<', ' ') # string = string.replace('>', ' ') string = removeletters(string) words = string.split() string = ' '.join(words) string += " 0" return geo.Rec(matrixfromstr(string))
gpl-3.0
[ 504, 2467, 588, 647, 492, 5579, 465, 8526, 199, 646, 12530, 852, 465, 9513, 199, 646, 30043, 1417, 465, 399, 67, 199, 504, 2467, 588, 647, 492, 8509, 465, 8509, 199, 646, 295, 199, 199, 318, 2813, 16415, 8, 875, 304, 272, 702, 1228, 8, 875, 12, 620, 395, 971, 267, 298, 5201, 1471, 506, 402, 730, 620, 2122, 272, 1059, 275, 295, 14, 954, 10994, 65, 13, 6353, 13, 58, 11472, 298, 3872, 1059, 9, 272, 372, 1059, 199, 199, 318, 620, 18, 6676, 5125, 8, 875, 12, 1212, 1597, 63, 3669, 304, 272, 702, 1228, 8, 875, 12, 620, 395, 971, 267, 298, 5201, 1471, 506, 402, 730, 620, 2122, 272, 702, 1228, 8, 317, 1597, 63, 3669, 12, 769, 395, 971, 267, 298, 5201, 1471, 506, 402, 730, 769, 2122, 272, 367, 1242, 315, 1212, 1597, 63, 3669, 26, 267, 702, 1228, 8, 1053, 12, 620, 395, 971, 288, 298, 5201, 1471, 506, 282, 769, 402, 2251, 402, 730, 620, 2122, 272, 1059, 275, 1059, 14, 1814, 13858, 6681, 25815, 272, 1059, 275, 1059, 14, 1814, 360, 1656, 4074, 272, 5932, 275, 1059, 14, 1294, 360, 13854, 272, 1212, 1597, 63, 10548, 275, 359, 16, 367, 284, 315, 1425, 8, 552, 8, 317, 1597, 63, 3669, 9, 435, 413, 1874, 272, 367, 4349, 315, 5932, 26, 267, 965, 63, 1975, 275, 756, 267, 1478, 275, 446, 17, 267, 367, 282, 315, 4349, 26, 288, 340, 282, 14, 374, 4468, 837, 355, 4349, 275, 4349, 14, 1814, 8, 65, 12, 4074, 355, 1478, 275, 1212, 1597, 63, 3669, 14, 1080, 8, 65, 9, 355, 965, 63, 1975, 275, 715, 267, 340, 4349, 508, 2125, 503, 4349, 508, 20905, 288, 340, 965, 63, 1975, 26, 355, 4349, 847, 283, 17, 7, 288, 587, 26, 355, 4349, 847, 283, 16, 7, 267, 1212, 1597, 63, 10548, 59, 1080, 61, 847, 23744, 8, 1027, 9, 272, 372, 1212, 1597, 63, 10548, 199, 199, 318, 23744, 8, 875, 304, 272, 702, 1228, 8, 875, 12, 620, 395, 971, 267, 298, 3481, 23744, 1471, 1172, 376, 1423, 402, 730, 1059, 2122, 272, 6211, 275, 730, 504, 495, 8, 875, 9, 272, 340, 6211, 508, 8526, 14, 17899, 26, 267, 862, 26, 288, 754, 275, 13492, 504, 495, 8, 875, 9, 288, 702, 1228, 8, 1099, 12, 8526, 14, 17899, 395, 971, 355, 298, 1918, 2569, 1059, 10734, 2839, 282, 1329, 12, 1325, 473, 1867, 355, 298, 11250, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 9, 288, 372, 754, 267, 871, 26, 288, 986, 272, 916, 6211, 508, 8526, 14, 6443, 26, 267, 862, 26, 288, 372, 3634, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 8449, 12, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 16594, 10987, 26, 267, 862, 26, 288, 372, 30246, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 21478, 10987, 12, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 26283, 26, 267, 862, 26, 288, 372, 13315, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 298, 1169, 298, 26283, 12, 1325, 473, 3913, 3957, 652, 26, 450, 83, 2, 1169, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 967, 409, 26, 267, 862, 26, 288, 372, 512, 409, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 1849, 409, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 6981, 26, 267, 862, 26, 288, 372, 2086, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 25987, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 36, 692, 26, 267, 862, 26, 288, 372, 487, 70, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 577, 692, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 21561, 26, 267, 862, 26, 288, 372, 6488, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 799, 67, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 199, 199, 318, 730, 504, 495, 8, 875, 304, 272, 5932, 275, 1059, 14, 1294, 342, 339, 340, 661, 21561, 7, 315, 1059, 304, 267, 372, 8509, 14, 21561, 272, 916, 295, 14, 6452, 10994, 3175, 11752, 12726, 92, 47, 92, 5118, 401, 1059, 9, 1137, 18410, 267, 372, 8509, 14, 26283, 272, 916, 334, 3148, 59, 16, 1527, 16, 61, 508, 15107, 436, 5932, 1988, 17, 15898, 17, 61, 508, 20549, 267, 372, 8526, 14, 6443, 272, 916, 334, 3148, 59, 16, 1527, 16, 61, 508, 2650, 358, 436, 334, 3148, 1988, 17, 15898, 17, 61, 508, 12696, 735, 267, 372, 8526, 14, 6443, 272, 916, 295, 14, 6452, 10994, 80, 9779, 50, 11472, 1059, 9, 1137, 18410, 267, 372, 8509, 14, 6981, 272, 916, 661, 68, 7, 315, 1059, 9, 503, 661, 36, 7, 315, 1059, 304, 267, 372, 8509, 14, 36, 692, 272, 916, 295, 14, 6452, 10994, 75, 43, 81, 49, 11472, 1059, 9, 1137, 18410, 267, 372, 8509, 14, 21561, 272, 916, 661, 1445, 315, 1059, 9, 436, 661, 6834, 315, 1059, 304, 267, 372, 8509, 14, 967, 409, 272, 916, 661, 88, 7, 315, 1059, 9, 503, 661, 89, 7, 315, 1059, 9, 503, 661, 90, 7, 315, 1059, 304, 267, 372, 8509, 14, 16594, 10987, 272, 916, 17485, 78, 7, 315, 1059, 9, 503, 661, 1103, 7, 315, 1059, 9, 503, 661, 283, 315, 1059 ]
[ 2467, 588, 647, 492, 5579, 465, 8526, 199, 646, 12530, 852, 465, 9513, 199, 646, 30043, 1417, 465, 399, 67, 199, 504, 2467, 588, 647, 492, 8509, 465, 8509, 199, 646, 295, 199, 199, 318, 2813, 16415, 8, 875, 304, 272, 702, 1228, 8, 875, 12, 620, 395, 971, 267, 298, 5201, 1471, 506, 402, 730, 620, 2122, 272, 1059, 275, 295, 14, 954, 10994, 65, 13, 6353, 13, 58, 11472, 298, 3872, 1059, 9, 272, 372, 1059, 199, 199, 318, 620, 18, 6676, 5125, 8, 875, 12, 1212, 1597, 63, 3669, 304, 272, 702, 1228, 8, 875, 12, 620, 395, 971, 267, 298, 5201, 1471, 506, 402, 730, 620, 2122, 272, 702, 1228, 8, 317, 1597, 63, 3669, 12, 769, 395, 971, 267, 298, 5201, 1471, 506, 402, 730, 769, 2122, 272, 367, 1242, 315, 1212, 1597, 63, 3669, 26, 267, 702, 1228, 8, 1053, 12, 620, 395, 971, 288, 298, 5201, 1471, 506, 282, 769, 402, 2251, 402, 730, 620, 2122, 272, 1059, 275, 1059, 14, 1814, 13858, 6681, 25815, 272, 1059, 275, 1059, 14, 1814, 360, 1656, 4074, 272, 5932, 275, 1059, 14, 1294, 360, 13854, 272, 1212, 1597, 63, 10548, 275, 359, 16, 367, 284, 315, 1425, 8, 552, 8, 317, 1597, 63, 3669, 9, 435, 413, 1874, 272, 367, 4349, 315, 5932, 26, 267, 965, 63, 1975, 275, 756, 267, 1478, 275, 446, 17, 267, 367, 282, 315, 4349, 26, 288, 340, 282, 14, 374, 4468, 837, 355, 4349, 275, 4349, 14, 1814, 8, 65, 12, 4074, 355, 1478, 275, 1212, 1597, 63, 3669, 14, 1080, 8, 65, 9, 355, 965, 63, 1975, 275, 715, 267, 340, 4349, 508, 2125, 503, 4349, 508, 20905, 288, 340, 965, 63, 1975, 26, 355, 4349, 847, 283, 17, 7, 288, 587, 26, 355, 4349, 847, 283, 16, 7, 267, 1212, 1597, 63, 10548, 59, 1080, 61, 847, 23744, 8, 1027, 9, 272, 372, 1212, 1597, 63, 10548, 199, 199, 318, 23744, 8, 875, 304, 272, 702, 1228, 8, 875, 12, 620, 395, 971, 267, 298, 3481, 23744, 1471, 1172, 376, 1423, 402, 730, 1059, 2122, 272, 6211, 275, 730, 504, 495, 8, 875, 9, 272, 340, 6211, 508, 8526, 14, 17899, 26, 267, 862, 26, 288, 754, 275, 13492, 504, 495, 8, 875, 9, 288, 702, 1228, 8, 1099, 12, 8526, 14, 17899, 395, 971, 355, 298, 1918, 2569, 1059, 10734, 2839, 282, 1329, 12, 1325, 473, 1867, 355, 298, 11250, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 9, 288, 372, 754, 267, 871, 26, 288, 986, 272, 916, 6211, 508, 8526, 14, 6443, 26, 267, 862, 26, 288, 372, 3634, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 8449, 12, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 16594, 10987, 26, 267, 862, 26, 288, 372, 30246, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 21478, 10987, 12, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 26283, 26, 267, 862, 26, 288, 372, 13315, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 298, 1169, 298, 26283, 12, 1325, 473, 3913, 3957, 652, 26, 450, 83, 2, 1169, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 967, 409, 26, 267, 862, 26, 288, 372, 512, 409, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 1849, 409, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 6981, 26, 267, 862, 26, 288, 372, 2086, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 25987, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 36, 692, 26, 267, 862, 26, 288, 372, 487, 70, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 577, 692, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 272, 916, 6211, 508, 8509, 14, 21561, 26, 267, 862, 26, 288, 372, 6488, 504, 495, 8, 875, 9, 267, 871, 1722, 26, 288, 746, 8, 1726, 480, 1918, 2569, 1059, 10734, 2839, 282, 799, 67, 298, 1169, 298, 7911, 473, 3913, 3957, 652, 26, 450, 83, 2, 450, 334, 875, 1724, 199, 199, 318, 730, 504, 495, 8, 875, 304, 272, 5932, 275, 1059, 14, 1294, 342, 339, 340, 661, 21561, 7, 315, 1059, 304, 267, 372, 8509, 14, 21561, 272, 916, 295, 14, 6452, 10994, 3175, 11752, 12726, 92, 47, 92, 5118, 401, 1059, 9, 1137, 18410, 267, 372, 8509, 14, 26283, 272, 916, 334, 3148, 59, 16, 1527, 16, 61, 508, 15107, 436, 5932, 1988, 17, 15898, 17, 61, 508, 20549, 267, 372, 8526, 14, 6443, 272, 916, 334, 3148, 59, 16, 1527, 16, 61, 508, 2650, 358, 436, 334, 3148, 1988, 17, 15898, 17, 61, 508, 12696, 735, 267, 372, 8526, 14, 6443, 272, 916, 295, 14, 6452, 10994, 80, 9779, 50, 11472, 1059, 9, 1137, 18410, 267, 372, 8509, 14, 6981, 272, 916, 661, 68, 7, 315, 1059, 9, 503, 661, 36, 7, 315, 1059, 304, 267, 372, 8509, 14, 36, 692, 272, 916, 295, 14, 6452, 10994, 75, 43, 81, 49, 11472, 1059, 9, 1137, 18410, 267, 372, 8509, 14, 21561, 272, 916, 661, 1445, 315, 1059, 9, 436, 661, 6834, 315, 1059, 304, 267, 372, 8509, 14, 967, 409, 272, 916, 661, 88, 7, 315, 1059, 9, 503, 661, 89, 7, 315, 1059, 9, 503, 661, 90, 7, 315, 1059, 304, 267, 372, 8509, 14, 16594, 10987, 272, 916, 17485, 78, 7, 315, 1059, 9, 503, 661, 1103, 7, 315, 1059, 9, 503, 661, 283, 315, 1059, 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, 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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 ]
vikatory/kbengine
kbe/res/scripts/common/Lib/test/test_asyncio/test_transports.py
60
3435
"""Tests for transports.py.""" import unittest from unittest import mock import asyncio from asyncio import transports class TransportTests(unittest.TestCase): def test_ctor_extra_is_none(self): transport = asyncio.Transport() self.assertEqual(transport._extra, {}) def test_get_extra_info(self): transport = asyncio.Transport({'extra': 'info'}) self.assertEqual('info', transport.get_extra_info('extra')) self.assertIsNone(transport.get_extra_info('unknown')) default = object() self.assertIs(default, transport.get_extra_info('unknown', default)) def test_writelines(self): transport = asyncio.Transport() transport.write = mock.Mock() transport.writelines([b'line1', bytearray(b'line2'), memoryview(b'line3')]) self.assertEqual(1, transport.write.call_count) transport.write.assert_called_with(b'line1line2line3') def test_not_implemented(self): transport = asyncio.Transport() self.assertRaises(NotImplementedError, transport.set_write_buffer_limits) self.assertRaises(NotImplementedError, transport.get_write_buffer_size) self.assertRaises(NotImplementedError, transport.write, 'data') self.assertRaises(NotImplementedError, transport.write_eof) self.assertRaises(NotImplementedError, transport.can_write_eof) self.assertRaises(NotImplementedError, transport.pause_reading) self.assertRaises(NotImplementedError, transport.resume_reading) self.assertRaises(NotImplementedError, transport.close) self.assertRaises(NotImplementedError, transport.abort) def test_dgram_not_implemented(self): transport = asyncio.DatagramTransport() self.assertRaises(NotImplementedError, transport.sendto, 'data') self.assertRaises(NotImplementedError, transport.abort) def test_subprocess_transport_not_implemented(self): transport = asyncio.SubprocessTransport() self.assertRaises(NotImplementedError, transport.get_pid) self.assertRaises(NotImplementedError, transport.get_returncode) self.assertRaises(NotImplementedError, transport.get_pipe_transport, 1) self.assertRaises(NotImplementedError, transport.send_signal, 1) self.assertRaises(NotImplementedError, transport.terminate) self.assertRaises(NotImplementedError, transport.kill) def test_flowcontrol_mixin_set_write_limits(self): class MyTransport(transports._FlowControlMixin, transports.Transport): def get_write_buffer_size(self): return 512 transport = MyTransport() transport._protocol = mock.Mock() self.assertFalse(transport._protocol_paused) with self.assertRaisesRegex(ValueError, 'high.*must be >= low'): transport.set_write_buffer_limits(high=0, low=1) transport.set_write_buffer_limits(high=1024, low=128) self.assertFalse(transport._protocol_paused) self.assertEqual(transport.get_write_buffer_limits(), (128, 1024)) transport.set_write_buffer_limits(high=256, low=128) self.assertTrue(transport._protocol_paused) self.assertEqual(transport.get_write_buffer_limits(), (128, 256)) if __name__ == '__main__': unittest.main()
lgpl-3.0
[ 624, 2925, 367, 7773, 83, 14, 647, 1041, 199, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 646, 16195, 199, 504, 16195, 492, 7773, 83, 421, 199, 533, 27018, 2925, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 630, 63, 2911, 63, 374, 63, 3592, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 342, 267, 291, 14, 629, 8, 5545, 423, 2911, 12, 5009, 339, 347, 511, 63, 362, 63, 2911, 63, 815, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 3252, 2911, 356, 283, 815, 3071, 267, 291, 14, 629, 360, 815, 297, 7773, 14, 362, 63, 2911, 63, 815, 360, 2911, 1333, 267, 291, 14, 7702, 8, 5545, 14, 362, 63, 2911, 63, 815, 360, 5187, 1333, 398, 849, 275, 909, 342, 267, 291, 14, 3436, 8, 885, 12, 7773, 14, 362, 63, 2911, 63, 815, 360, 5187, 297, 849, 430, 339, 347, 511, 63, 23277, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 342, 267, 7773, 14, 952, 275, 1683, 14, 3346, 342, 398, 7773, 14, 23277, 779, 66, 7, 604, 17, 297, 2892, 11640, 8, 66, 7, 604, 18, 659, 2892, 20228, 8, 66, 7, 604, 19, 2023, 267, 291, 14, 629, 8, 17, 12, 7773, 14, 952, 14, 1250, 63, 835, 9, 267, 7773, 14, 952, 14, 479, 63, 3527, 63, 1045, 8, 66, 7, 604, 17, 604, 18, 604, 19, 358, 339, 347, 511, 63, 1397, 63, 13825, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 342, 398, 291, 14, 1855, 8, 18097, 12, 2079, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 952, 63, 2738, 63, 890, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 952, 12, 283, 576, 358, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 952, 63, 11670, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 2425, 63, 952, 63, 11670, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 11241, 63, 19332, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 9964, 63, 19332, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 1600, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 13845, 9, 339, 347, 511, 63, 68, 1679, 63, 1397, 63, 13825, 8, 277, 304, 267, 7773, 275, 16195, 14, 1451, 1679, 7836, 342, 398, 291, 14, 1855, 8, 18097, 12, 7773, 14, 23267, 12, 283, 576, 358, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 13845, 9, 339, 347, 511, 63, 5781, 63, 5545, 63, 1397, 63, 13825, 8, 277, 304, 267, 7773, 275, 16195, 14, 22299, 7836, 342, 398, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 3150, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 9913, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 4990, 63, 5545, 12, 413, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 2254, 63, 4653, 12, 413, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 14478, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 8997, 9, 339, 347, 511, 63, 1659, 2785, 63, 20406, 63, 409, 63, 952, 63, 9368, 8, 277, 304, 398, 1021, 4932, 7836, 8, 5545, 83, 423, 5060, 3717, 4256, 12, 2079, 7773, 83, 14, 7836, 304, 953, 347, 664, 63, 952, 63, 2738, 63, 890, 8, 277, 304, 355, 372, 10574, 398, 7773, 275, 4932, 7836, 342, 267, 7773, 423, 3922, 275, 1683, 14, 3346, 342, 398, 291, 14, 3334, 8, 5545, 423, 3922, 63, 22478, 9, 398, 543, 291, 14, 16499, 8, 3393, 12, 283, 6260, 2795, 7790, 506, 2356, 6465, 735, 288, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 8, 6260, 29, 16, 12, 6465, 29, 17, 9, 398, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 8, 6260, 29, 7727, 12, 6465, 29, 3933, 9, 267, 291, 14, 3334, 8, 5545, 423, 3922, 63, 22478, 9, 267, 291, 14, 629, 8, 5545, 14, 362, 63, 952, 63, 2738, 63, 9368, 1062, 334, 3933, 12, 6619, 430, 398, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 8, 6260, 29, 3912, 12, 6465, 29, 3933, 9, 267, 291, 14, 1815, 8, 5545, 423, 3922, 63, 22478, 9, 267, 291, 14, 629, 8, 5545, 14, 362, 63, 952, 63, 2738, 63, 9368, 1062, 334, 3933, 12, 7633, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2925, 367, 7773, 83, 14, 647, 1041, 199, 199, 646, 2882, 199, 504, 2882, 492, 1683, 199, 199, 646, 16195, 199, 504, 16195, 492, 7773, 83, 421, 199, 533, 27018, 2925, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 630, 63, 2911, 63, 374, 63, 3592, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 342, 267, 291, 14, 629, 8, 5545, 423, 2911, 12, 5009, 339, 347, 511, 63, 362, 63, 2911, 63, 815, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 3252, 2911, 356, 283, 815, 3071, 267, 291, 14, 629, 360, 815, 297, 7773, 14, 362, 63, 2911, 63, 815, 360, 2911, 1333, 267, 291, 14, 7702, 8, 5545, 14, 362, 63, 2911, 63, 815, 360, 5187, 1333, 398, 849, 275, 909, 342, 267, 291, 14, 3436, 8, 885, 12, 7773, 14, 362, 63, 2911, 63, 815, 360, 5187, 297, 849, 430, 339, 347, 511, 63, 23277, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 342, 267, 7773, 14, 952, 275, 1683, 14, 3346, 342, 398, 7773, 14, 23277, 779, 66, 7, 604, 17, 297, 2892, 11640, 8, 66, 7, 604, 18, 659, 2892, 20228, 8, 66, 7, 604, 19, 2023, 267, 291, 14, 629, 8, 17, 12, 7773, 14, 952, 14, 1250, 63, 835, 9, 267, 7773, 14, 952, 14, 479, 63, 3527, 63, 1045, 8, 66, 7, 604, 17, 604, 18, 604, 19, 358, 339, 347, 511, 63, 1397, 63, 13825, 8, 277, 304, 267, 7773, 275, 16195, 14, 7836, 342, 398, 291, 14, 1855, 8, 18097, 12, 2079, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 952, 63, 2738, 63, 890, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 952, 12, 283, 576, 358, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 952, 63, 11670, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 2425, 63, 952, 63, 11670, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 11241, 63, 19332, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 9964, 63, 19332, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 1600, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 13845, 9, 339, 347, 511, 63, 68, 1679, 63, 1397, 63, 13825, 8, 277, 304, 267, 7773, 275, 16195, 14, 1451, 1679, 7836, 342, 398, 291, 14, 1855, 8, 18097, 12, 7773, 14, 23267, 12, 283, 576, 358, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 13845, 9, 339, 347, 511, 63, 5781, 63, 5545, 63, 1397, 63, 13825, 8, 277, 304, 267, 7773, 275, 16195, 14, 22299, 7836, 342, 398, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 3150, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 9913, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 362, 63, 4990, 63, 5545, 12, 413, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 2254, 63, 4653, 12, 413, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 14478, 9, 267, 291, 14, 1855, 8, 18097, 12, 7773, 14, 8997, 9, 339, 347, 511, 63, 1659, 2785, 63, 20406, 63, 409, 63, 952, 63, 9368, 8, 277, 304, 398, 1021, 4932, 7836, 8, 5545, 83, 423, 5060, 3717, 4256, 12, 2079, 7773, 83, 14, 7836, 304, 953, 347, 664, 63, 952, 63, 2738, 63, 890, 8, 277, 304, 355, 372, 10574, 398, 7773, 275, 4932, 7836, 342, 267, 7773, 423, 3922, 275, 1683, 14, 3346, 342, 398, 291, 14, 3334, 8, 5545, 423, 3922, 63, 22478, 9, 398, 543, 291, 14, 16499, 8, 3393, 12, 283, 6260, 2795, 7790, 506, 2356, 6465, 735, 288, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 8, 6260, 29, 16, 12, 6465, 29, 17, 9, 398, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 8, 6260, 29, 7727, 12, 6465, 29, 3933, 9, 267, 291, 14, 3334, 8, 5545, 423, 3922, 63, 22478, 9, 267, 291, 14, 629, 8, 5545, 14, 362, 63, 952, 63, 2738, 63, 9368, 1062, 334, 3933, 12, 6619, 430, 398, 7773, 14, 409, 63, 952, 63, 2738, 63, 9368, 8, 6260, 29, 3912, 12, 6465, 29, 3933, 9, 267, 291, 14, 1815, 8, 5545, 423, 3922, 63, 22478, 9, 267, 291, 14, 629, 8, 5545, 14, 362, 63, 952, 63, 2738, 63, 9368, 1062, 334, 3933, 12, 7633, 430, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
matiasb/django
django/db/models/fields/__init__.py
57
89296
# -*- coding: utf-8 -*- from __future__ import unicode_literals import collections import copy import datetime import decimal import math import uuid import warnings from base64 import b64decode, b64encode from functools import total_ordering from django import forms from django.apps import apps from django.conf import settings from django.core import checks, exceptions, validators # When the _meta object was formalized, this exception was moved to # django.core.exceptions. It is retained here for backwards compatibility # purposes. from django.core.exceptions import FieldDoesNotExist # NOQA from django.db import connection, connections, router from django.db.models.query_utils import QueryWrapper, RegisterLookupMixin from django.utils import six, timezone from django.utils.datastructures import DictWrapper from django.utils.dateparse import ( parse_date, parse_datetime, parse_duration, parse_time, ) from django.utils.deprecation import ( RemovedInDjango20Warning, warn_about_renamed_method, ) from django.utils.duration import duration_string from django.utils.encoding import ( force_bytes, force_text, python_2_unicode_compatible, smart_text, ) from django.utils.functional import Promise, cached_property, curry from django.utils.ipv6 import clean_ipv6_address from django.utils.itercompat import is_iterable from django.utils.text import capfirst from django.utils.translation import ugettext_lazy as _ # Avoid "TypeError: Item in ``from list'' not a string" -- unicode_literals # makes these strings unicode __all__ = [str(x) for x in ( 'AutoField', 'BLANK_CHOICE_DASH', 'BigIntegerField', 'BinaryField', 'BooleanField', 'CharField', 'CommaSeparatedIntegerField', 'DateField', 'DateTimeField', 'DecimalField', 'DurationField', 'EmailField', 'Empty', 'Field', 'FieldDoesNotExist', 'FilePathField', 'FloatField', 'GenericIPAddressField', 'IPAddressField', 'IntegerField', 'NOT_PROVIDED', 'NullBooleanField', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'SlugField', 'SmallIntegerField', 'TextField', 'TimeField', 'URLField', 'UUIDField', )] class Empty(object): pass class NOT_PROVIDED: pass # The values to use for "blank" in SelectFields. Will be appended to the start # of most "choices" lists. BLANK_CHOICE_DASH = [("", "---------")] def _load_field(app_label, model_name, field_name): return apps.get_model(app_label, model_name)._meta.get_field(field_name) # A guide to Field parameters: # # * name: The name of the field specified in the model. # * attname: The attribute to use on the model object. This is the same as # "name", except in the case of ForeignKeys, where "_id" is # appended. # * db_column: The db_column specified in the model (or None). # * column: The database column for this field. This is the same as # "attname", except if db_column is specified. # # Code that introspects values, or does other dynamic things, should use # attname. For example, this gets the primary key value of object "obj": # # getattr(obj, opts.pk.attname) def _empty(of_cls): new = Empty() new.__class__ = of_cls return new @total_ordering @python_2_unicode_compatible class Field(RegisterLookupMixin): """Base class for all field types""" # Designates whether empty strings fundamentally are allowed at the # database level. empty_strings_allowed = True empty_values = list(validators.EMPTY_VALUES) # These track each time a Field instance is created. Used to retain order. # The auto_creation_counter is used for fields that Django implicitly # creates, creation_counter is used for all user-specified fields. creation_counter = 0 auto_creation_counter = -1 default_validators = [] # Default set of validators default_error_messages = { 'invalid_choice': _('Value %(value)r is not a valid choice.'), 'null': _('This field cannot be null.'), 'blank': _('This field cannot be blank.'), 'unique': _('%(model_name)s with this %(field_label)s ' 'already exists.'), # Translators: The 'lookup_type' is one of 'date', 'year' or 'month'. # Eg: "Title must be unique for pub_date year" 'unique_for_date': _("%(field_label)s must be unique for " "%(date_field_label)s %(lookup_type)s."), } system_check_deprecated_details = None system_check_removed_details = None # Field flags hidden = False many_to_many = None many_to_one = None one_to_many = None one_to_one = None related_model = None # Generic field type description, usually overridden by subclasses def _description(self): return _('Field of type: %(field_type)s') % { 'field_type': self.__class__.__name__ } description = property(_description) def __init__(self, verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=NOT_PROVIDED, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=[], error_messages=None): self.name = name self.verbose_name = verbose_name # May be set by set_attributes_from_name self._verbose_name = verbose_name # Store original for deconstruction self.primary_key = primary_key self.max_length, self._unique = max_length, unique self.blank, self.null = blank, null self.remote_field = rel self.is_relation = self.remote_field is not None self.default = default self.editable = editable self.serialize = serialize self.unique_for_date = unique_for_date self.unique_for_month = unique_for_month self.unique_for_year = unique_for_year if isinstance(choices, collections.Iterator): choices = list(choices) self.choices = choices or [] self.help_text = help_text self.db_index = db_index self.db_column = db_column self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE self.auto_created = auto_created # Adjust the appropriate creation counter, and save our local copy. if auto_created: self.creation_counter = Field.auto_creation_counter Field.auto_creation_counter -= 1 else: self.creation_counter = Field.creation_counter Field.creation_counter += 1 self._validators = validators # Store for deconstruction later messages = {} for c in reversed(self.__class__.__mro__): messages.update(getattr(c, 'default_error_messages', {})) messages.update(error_messages or {}) self._error_messages = error_messages # Store for deconstruction later self.error_messages = messages def __str__(self): """ Return "app_label.model_label.field_name". """ model = self.model app = model._meta.app_label return '%s.%s.%s' % (app, model._meta.object_name, self.name) def __repr__(self): """ Displays the module, class and name of the field. """ path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__) name = getattr(self, 'name', None) if name is not None: return '<%s: %s>' % (path, name) return '<%s>' % path def check(self, **kwargs): errors = [] errors.extend(self._check_field_name()) errors.extend(self._check_choices()) errors.extend(self._check_default()) errors.extend(self._check_db_index()) errors.extend(self._check_null_allowed_for_primary_keys()) errors.extend(self._check_backend_specific_checks(**kwargs)) errors.extend(self._check_deprecation_details()) return errors def _check_field_name(self): """ Check if field name is valid, i.e. 1) does not end with an underscore, 2) does not contain "__" and 3) is not "pk". """ if self.name.endswith('_'): return [ checks.Error( 'Field names must not end with an underscore.', hint=None, obj=self, id='fields.E001', ) ] elif '__' in self.name: return [ checks.Error( 'Field names must not contain "__".', hint=None, obj=self, id='fields.E002', ) ] elif self.name == 'pk': return [ checks.Error( "'pk' is a reserved word that cannot be used as a field name.", hint=None, obj=self, id='fields.E003', ) ] else: return [] @property def rel(self): warnings.warn( "Usage of field.rel has been deprecated. Use field.remote_field instead.", RemovedInDjango20Warning, 2) return self.remote_field def _check_choices(self): if self.choices: if (isinstance(self.choices, six.string_types) or not is_iterable(self.choices)): return [ checks.Error( "'choices' must be an iterable (e.g., a list or tuple).", hint=None, obj=self, id='fields.E004', ) ] elif any(isinstance(choice, six.string_types) or not is_iterable(choice) or len(choice) != 2 for choice in self.choices): return [ checks.Error( ("'choices' must be an iterable containing " "(actual value, human readable name) tuples."), hint=None, obj=self, id='fields.E005', ) ] else: return [] else: return [] def _check_default(self): if self.has_default(): default = self.get_default() try: self.clean(default, None) except exceptions.ValidationError as messages: return [ checks.Error( "Invalid 'default' value: %s" % message, hint=None, obj=self, id='fields.E008', ) for message in messages ] return [] def _check_db_index(self): if self.db_index not in (None, True, False): return [ checks.Error( "'db_index' must be None, True or False.", hint=None, obj=self, id='fields.E006', ) ] else: return [] def _check_null_allowed_for_primary_keys(self): if (self.primary_key and self.null and not connection.features.interprets_empty_strings_as_nulls): # We cannot reliably check this for backends like Oracle which # consider NULL and '' to be equal (and thus set up # character-based fields a little differently). return [ checks.Error( 'Primary keys must not have null=True.', hint=('Set null=False on the field, or ' 'remove primary_key=True argument.'), obj=self, id='fields.E007', ) ] else: return [] def _check_backend_specific_checks(self, **kwargs): app_label = self.model._meta.app_label for db in connections: if router.allow_migrate(db, app_label, model=self.model): return connections[db].validation.check_field(self, **kwargs) return [] def _check_deprecation_details(self): if self.system_check_removed_details is not None: return [ checks.Error( self.system_check_removed_details.get( 'msg', '%s has been removed except for support in historical ' 'migrations.' % self.__class__.__name__ ), hint=self.system_check_removed_details.get('hint'), obj=self, id=self.system_check_removed_details.get('id', 'fields.EXXX'), ) ] elif self.system_check_deprecated_details is not None: return [ checks.Warning( self.system_check_deprecated_details.get( 'msg', '%s has been deprecated.' % self.__class__.__name__ ), hint=self.system_check_deprecated_details.get('hint'), obj=self, id=self.system_check_deprecated_details.get('id', 'fields.WXXX'), ) ] return [] def get_col(self, alias, output_field=None): if output_field is None: output_field = self if alias != self.model._meta.db_table or output_field != self: from django.db.models.expressions import Col return Col(alias, self, output_field) else: return self.cached_col @cached_property def cached_col(self): from django.db.models.expressions import Col return Col(self.model._meta.db_table, self) def select_format(self, compiler, sql, params): """ Custom format for select clauses. For example, GIS columns need to be selected as AsText(table.col) on MySQL as the table.col data can't be used by Django. """ return sql, params def deconstruct(self): """ Returns enough information to recreate the field as a 4-tuple: * The name of the field on the model, if contribute_to_class has been run * The import path of the field, including the class: django.db.models.IntegerField This should be the most portable version, so less specific may be better. * A list of positional arguments * A dict of keyword arguments Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types): * None, bool, str, unicode, int, long, float, complex, set, frozenset, list, tuple, dict * UUID * datetime.datetime (naive), datetime.date * top-level classes, top-level functions - will be referenced by their full import path * Storage instances - these have their own deconstruct() method This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined. There's no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values. """ # Short-form way of fetching all the default parameters keywords = {} possibles = { "verbose_name": None, "primary_key": False, "max_length": None, "unique": False, "blank": False, "null": False, "db_index": False, "default": NOT_PROVIDED, "editable": True, "serialize": True, "unique_for_date": None, "unique_for_month": None, "unique_for_year": None, "choices": [], "help_text": '', "db_column": None, "db_tablespace": settings.DEFAULT_INDEX_TABLESPACE, "auto_created": False, "validators": [], "error_messages": None, } attr_overrides = { "unique": "_unique", "error_messages": "_error_messages", "validators": "_validators", "verbose_name": "_verbose_name", } equals_comparison = {"choices", "validators", "db_tablespace"} for name, default in possibles.items(): value = getattr(self, attr_overrides.get(name, name)) # Unroll anything iterable for choices into a concrete list if name == "choices" and isinstance(value, collections.Iterable): value = list(value) # Do correct kind of comparison if name in equals_comparison: if value != default: keywords[name] = value else: if value is not default: keywords[name] = value # Work out path - we shorten it for known Django core fields path = "%s.%s" % (self.__class__.__module__, self.__class__.__name__) if path.startswith("django.db.models.fields.related"): path = path.replace("django.db.models.fields.related", "django.db.models") if path.startswith("django.db.models.fields.files"): path = path.replace("django.db.models.fields.files", "django.db.models") if path.startswith("django.db.models.fields.proxy"): path = path.replace("django.db.models.fields.proxy", "django.db.models") if path.startswith("django.db.models.fields"): path = path.replace("django.db.models.fields", "django.db.models") # Return basic info - other fields should override this. return ( force_text(self.name, strings_only=True), path, [], keywords, ) def clone(self): """ Uses deconstruct() to clone a new copy of this Field. Will not preserve any class attachments/attribute names. """ name, path, args, kwargs = self.deconstruct() return self.__class__(*args, **kwargs) def __eq__(self, other): # Needed for @total_ordering if isinstance(other, Field): return self.creation_counter == other.creation_counter return NotImplemented def __lt__(self, other): # This is needed because bisect does not take a comparison function. if isinstance(other, Field): return self.creation_counter < other.creation_counter return NotImplemented def __hash__(self): return hash(self.creation_counter) def __deepcopy__(self, memodict): # We don't have to deepcopy very much here, since most things are not # intended to be altered after initial creation. obj = copy.copy(self) if self.remote_field: obj.remote_field = copy.copy(self.remote_field) if hasattr(self.remote_field, 'field') and self.remote_field.field is self: obj.remote_field.field = obj memodict[id(self)] = obj return obj def __copy__(self): # We need to avoid hitting __reduce__, so define this # slightly weird copy construct. obj = Empty() obj.__class__ = self.__class__ obj.__dict__ = self.__dict__.copy() return obj def __reduce__(self): """ Pickling should return the model._meta.fields instance of the field, not a new copy of that field. So, we use the app registry to load the model and then the field back. """ if not hasattr(self, 'model'): # Fields are sometimes used without attaching them to models (for # example in aggregation). In this case give back a plain field # instance. The code below will create a new empty instance of # class self.__class__, then update its dict with self.__dict__ # values - so, this is very close to normal pickle. return _empty, (self.__class__,), self.__dict__ if self.model._deferred: # Deferred model will not be found from the app registry. This # could be fixed by reconstructing the deferred model on unpickle. raise RuntimeError("Fields of deferred models can't be reduced") return _load_field, (self.model._meta.app_label, self.model._meta.object_name, self.name) def get_pk_value_on_save(self, instance): """ Hook to generate new PK values on save. This method is called when saving instances with no primary key value set. If this method returns something else than None, then the returned value is used when saving the new instance. """ if self.default: return self.get_default() return None def to_python(self, value): """ Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can't be converted. Returns the converted value. Subclasses should override this. """ return value @cached_property def validators(self): # Some validators can't be created at field initialization time. # This method provides a way to delay their creation until required. return self.default_validators + self._validators def run_validators(self, value): if value in self.empty_values: return errors = [] for v in self.validators: try: v(value) except exceptions.ValidationError as e: if hasattr(e, 'code') and e.code in self.error_messages: e.message = self.error_messages[e.code] errors.extend(e.error_list) if errors: raise exceptions.ValidationError(errors) def validate(self, value, model_instance): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not self.editable: # Skip validation for non-editable fields. return if self.choices and value not in self.empty_values: for option_key, option_value in self.choices: if isinstance(option_value, (list, tuple)): # This is an optgroup, so look inside the group for # options. for optgroup_key, optgroup_value in option_value: if value == optgroup_key: return elif value == option_key: return raise exceptions.ValidationError( self.error_messages['invalid_choice'], code='invalid_choice', params={'value': value}, ) if value is None and not self.null: raise exceptions.ValidationError(self.error_messages['null'], code='null') if not self.blank and value in self.empty_values: raise exceptions.ValidationError(self.error_messages['blank'], code='blank') def clean(self, value, model_instance): """ Convert the value's type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised. """ value = self.to_python(value) self.validate(value, model_instance) self.run_validators(value) return value def db_type(self, connection): """ Returns the database column data type for this field, for the provided connection. """ # The default implementation of this method looks at the # backend-specific data_types dictionary, looking up the field by its # "internal type". # # A Field class can implement the get_internal_type() method to specify # which *preexisting* Django Field class it's most similar to -- i.e., # a custom field might be represented by a TEXT column type, which is # the same as the TextField Django field type, which means the custom # field's get_internal_type() returns 'TextField'. # # But the limitation of the get_internal_type() / data_types approach # is that it cannot handle database column types that aren't already # mapped to one of the built-in Django field types. In this case, you # can implement db_type() instead of get_internal_type() to specify # exactly which wacky database column type you want to use. data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_") try: return connection.data_types[self.get_internal_type()] % data except KeyError: return None def db_parameters(self, connection): """ Extension of db_type(), providing a range of different return values (type, checks). This will look at db_type(), allowing custom model fields to override it. """ data = DictWrapper(self.__dict__, connection.ops.quote_name, "qn_") type_string = self.db_type(connection) try: check_string = connection.data_type_check_constraints[self.get_internal_type()] % data except KeyError: check_string = None return { "type": type_string, "check": check_string, } def db_type_suffix(self, connection): return connection.data_types_suffix.get(self.get_internal_type()) def get_db_converters(self, connection): if hasattr(self, 'from_db_value'): return [self.from_db_value] return [] @property def unique(self): return self._unique or self.primary_key def set_attributes_from_name(self, name): if not self.name: self.name = name self.attname, self.column = self.get_attname_column() self.concrete = self.column is not None if self.verbose_name is None and self.name: self.verbose_name = self.name.replace('_', ' ') def contribute_to_class(self, cls, name, virtual_only=False): self.set_attributes_from_name(name) self.model = cls if virtual_only: cls._meta.add_field(self, virtual=True) else: cls._meta.add_field(self) if self.choices: setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self)) def get_filter_kwargs_for_object(self, obj): """ Return a dict that when passed as kwargs to self.model.filter(), would yield all instances having the same value for this field as obj has. """ return {self.name: getattr(obj, self.attname)} def get_attname(self): return self.name def get_attname_column(self): attname = self.get_attname() column = self.db_column or attname return attname, column def get_cache_name(self): return '_%s_cache' % self.name def get_internal_type(self): return self.__class__.__name__ def pre_save(self, model_instance, add): """ Returns field's value just before saving. """ return getattr(model_instance, self.attname) def get_prep_value(self, value): """ Perform preliminary non-db specific value checks and conversions. """ if isinstance(value, Promise): value = value._proxy____cast() return value def get_db_prep_value(self, value, connection, prepared=False): """Returns field's value prepared for interacting with the database backend. Used by the default implementations of ``get_db_prep_save``and `get_db_prep_lookup``` """ if not prepared: value = self.get_prep_value(value) return value def get_db_prep_save(self, value, connection): """ Returns field's value prepared for saving into a database. """ return self.get_db_prep_value(value, connection=connection, prepared=False) def get_prep_lookup(self, lookup_type, value): """ Perform preliminary non-db specific lookup checks and conversions """ if hasattr(value, '_prepare'): return value._prepare() if lookup_type in { 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith', 'isnull', 'search', 'regex', 'iregex', }: return value elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return self.get_prep_value(value) elif lookup_type in ('range', 'in'): return [self.get_prep_value(v) for v in value] return self.get_prep_value(value) def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False): """ Returns field's value prepared for database lookup. """ if not prepared: value = self.get_prep_lookup(lookup_type, value) prepared = True if hasattr(value, 'get_compiler'): value = value.get_compiler(connection=connection) if hasattr(value, 'as_sql') or hasattr(value, '_as_sql'): # If the value has a relabeled_clone method it means the # value will be handled later on. if hasattr(value, 'relabeled_clone'): return value if hasattr(value, 'as_sql'): sql, params = value.as_sql() else: sql, params = value._as_sql(connection=connection) return QueryWrapper(('(%s)' % sql), params) if lookup_type in ('search', 'regex', 'iregex', 'contains', 'icontains', 'iexact', 'startswith', 'endswith', 'istartswith', 'iendswith'): return [value] elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return [self.get_db_prep_value(value, connection=connection, prepared=prepared)] elif lookup_type in ('range', 'in'): return [self.get_db_prep_value(v, connection=connection, prepared=prepared) for v in value] elif lookup_type == 'isnull': return [] else: return [value] def has_default(self): """ Returns a boolean of whether this field has a default value. """ return self.default is not NOT_PROVIDED def get_default(self): """ Returns the default value for this field. """ if self.has_default(): if callable(self.default): return self.default() return self.default if (not self.empty_strings_allowed or (self.null and not connection.features.interprets_empty_strings_as_nulls)): return None return "" def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, limit_choices_to=None): """Returns choices with a default blank choices included, for use as SelectField choices for this field.""" blank_defined = False choices = list(self.choices) if self.choices else [] named_groups = choices and isinstance(choices[0][1], (list, tuple)) if not named_groups: for choice, __ in choices: if choice in ('', None): blank_defined = True break first_choice = (blank_choice if include_blank and not blank_defined else []) if self.choices: return first_choice + choices rel_model = self.remote_field.model limit_choices_to = limit_choices_to or self.get_limit_choices_to() if hasattr(self.remote_field, 'get_related_field'): lst = [(getattr(x, self.remote_field.get_related_field().attname), smart_text(x)) for x in rel_model._default_manager.complex_filter( limit_choices_to)] else: lst = [(x._get_pk_val(), smart_text(x)) for x in rel_model._default_manager.complex_filter( limit_choices_to)] return first_choice + lst def get_choices_default(self): return self.get_choices() @warn_about_renamed_method( 'Field', '_get_val_from_obj', 'value_from_object', RemovedInDjango20Warning ) def _get_val_from_obj(self, obj): if obj is not None: return getattr(obj, self.attname) else: return self.get_default() def value_to_string(self, obj): """ Returns a string value of this field from the passed obj. This is used by the serialization framework. """ return smart_text(self.value_from_object(obj)) def _get_flatchoices(self): """Flattened version of choices tuple.""" flat = [] for choice, value in self.choices: if isinstance(value, (list, tuple)): flat.extend(value) else: flat.append((choice, value)) return flat flatchoices = property(_get_flatchoices) def save_form_data(self, instance, data): setattr(instance, self.name, data) def formfield(self, form_class=None, choices_form_class=None, **kwargs): """ Returns a django.forms.Field instance for this database Field. """ defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} if self.has_default(): if callable(self.default): defaults['initial'] = self.default defaults['show_hidden_initial'] = True else: defaults['initial'] = self.get_default() if self.choices: # Fields with choices get special treatment. include_blank = (self.blank or not (self.has_default() or 'initial' in kwargs)) defaults['choices'] = self.get_choices(include_blank=include_blank) defaults['coerce'] = self.to_python if self.null: defaults['empty_value'] = None if choices_form_class is not None: form_class = choices_form_class else: form_class = forms.TypedChoiceField # Many of the subclass-specific formfield arguments (min_value, # max_value) don't apply for choice fields, so be sure to only pass # the values that TypedChoiceField will understand. for k in list(kwargs): if k not in ('coerce', 'empty_value', 'choices', 'required', 'widget', 'label', 'initial', 'help_text', 'error_messages', 'show_hidden_initial'): del kwargs[k] defaults.update(kwargs) if form_class is None: form_class = forms.CharField return form_class(**defaults) def value_from_object(self, obj): """ Returns the value of this field in the given model instance. """ return getattr(obj, self.attname) class AutoField(Field): description = _("Integer") empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be an integer."), } def __init__(self, *args, **kwargs): kwargs['blank'] = True super(AutoField, self).__init__(*args, **kwargs) def check(self, **kwargs): errors = super(AutoField, self).check(**kwargs) errors.extend(self._check_primary_key()) return errors def _check_primary_key(self): if not self.primary_key: return [ checks.Error( 'AutoFields must set primary_key=True.', hint=None, obj=self, id='fields.E100', ), ] else: return [] def deconstruct(self): name, path, args, kwargs = super(AutoField, self).deconstruct() del kwargs['blank'] kwargs['primary_key'] = True return name, path, args, kwargs def get_internal_type(self): return "AutoField" def to_python(self, value): if value is None: return value try: return int(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def validate(self, value, model_instance): pass def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) value = connection.ops.validate_autopk_value(value) return value def get_prep_value(self, value): value = super(AutoField, self).get_prep_value(value) if value is None: return None return int(value) def contribute_to_class(self, cls, name, **kwargs): assert not cls._meta.has_auto_field, \ "A model can't have more than one AutoField." super(AutoField, self).contribute_to_class(cls, name, **kwargs) cls._meta.has_auto_field = True cls._meta.auto_field = self def formfield(self, **kwargs): return None class BooleanField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be either True or False."), } description = _("Boolean (Either True or False)") def __init__(self, *args, **kwargs): kwargs['blank'] = True super(BooleanField, self).__init__(*args, **kwargs) def check(self, **kwargs): errors = super(BooleanField, self).check(**kwargs) errors.extend(self._check_null(**kwargs)) return errors def _check_null(self, **kwargs): if getattr(self, 'null', False): return [ checks.Error( 'BooleanFields do not accept null values.', hint='Use a NullBooleanField instead.', obj=self, id='fields.E110', ) ] else: return [] def deconstruct(self): name, path, args, kwargs = super(BooleanField, self).deconstruct() del kwargs['blank'] return name, path, args, kwargs def get_internal_type(self): return "BooleanField" def to_python(self, value): if value in (True, False): # if value is 1 or 0 than it's equal to True or False, but we want # to return a true bool for semantic reasons. return bool(value) if value in ('t', 'True', '1'): return True if value in ('f', 'False', '0'): return False raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_prep_lookup(self, lookup_type, value): # Special-case handling for filters coming from a Web request (e.g. the # admin interface). Only works for scalar values (not lists). If you're # passing in a list, you might as well make things the right type when # constructing the list. if value in ('1', '0'): value = bool(int(value)) return super(BooleanField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): value = super(BooleanField, self).get_prep_value(value) if value is None: return None return bool(value) def formfield(self, **kwargs): # Unlike most fields, BooleanField figures out include_blank from # self.null instead of self.blank. if self.choices: include_blank = not (self.has_default() or 'initial' in kwargs) defaults = {'choices': self.get_choices(include_blank=include_blank)} else: defaults = {'form_class': forms.BooleanField} defaults.update(kwargs) return super(BooleanField, self).formfield(**defaults) class CharField(Field): description = _("String (up to %(max_length)s)") def __init__(self, *args, **kwargs): super(CharField, self).__init__(*args, **kwargs) self.validators.append(validators.MaxLengthValidator(self.max_length)) def check(self, **kwargs): errors = super(CharField, self).check(**kwargs) errors.extend(self._check_max_length_attribute(**kwargs)) return errors def _check_max_length_attribute(self, **kwargs): if self.max_length is None: return [ checks.Error( "CharFields must define a 'max_length' attribute.", hint=None, obj=self, id='fields.E120', ) ] elif not isinstance(self.max_length, six.integer_types) or self.max_length <= 0: return [ checks.Error( "'max_length' must be a positive integer.", hint=None, obj=self, id='fields.E121', ) ] else: return [] def get_internal_type(self): return "CharField" def to_python(self, value): if isinstance(value, six.string_types) or value is None: return value return smart_text(value) def get_prep_value(self, value): value = super(CharField, self).get_prep_value(value) return self.to_python(value) def formfield(self, **kwargs): # Passing max_length to forms.CharField means that the value's length # will be validated twice. This is considered acceptable since we want # the value in the form field (to pass into widget for example). defaults = {'max_length': self.max_length} defaults.update(kwargs) return super(CharField, self).formfield(**defaults) class CommaSeparatedIntegerField(CharField): default_validators = [validators.validate_comma_separated_integer_list] description = _("Comma-separated integers") def formfield(self, **kwargs): defaults = { 'error_messages': { 'invalid': _('Enter only digits separated by commas.'), } } defaults.update(kwargs) return super(CommaSeparatedIntegerField, self).formfield(**defaults) class DateTimeCheckMixin(object): def check(self, **kwargs): errors = super(DateTimeCheckMixin, self).check(**kwargs) errors.extend(self._check_mutually_exclusive_options()) errors.extend(self._check_fix_default_value()) return errors def _check_mutually_exclusive_options(self): # auto_now, auto_now_add, and default are mutually exclusive # options. The use of more than one of these options together # will trigger an Error mutually_exclusive_options = [self.auto_now_add, self.auto_now, self.has_default()] enabled_options = [option not in (None, False) for option in mutually_exclusive_options].count(True) if enabled_options > 1: return [ checks.Error( "The options auto_now, auto_now_add, and default " "are mutually exclusive. Only one of these options " "may be present.", hint=None, obj=self, id='fields.E160', ) ] else: return [] def _check_fix_default_value(self): return [] class DateField(DateTimeCheckMixin, Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid date format. It must be " "in YYYY-MM-DD format."), 'invalid_date': _("'%(value)s' value has the correct format (YYYY-MM-DD) " "but it is an invalid date."), } description = _("Date (without time)") def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True super(DateField, self).__init__(verbose_name, name, **kwargs) def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): now = timezone.make_naive(now, timezone.utc) value = self.default if isinstance(value, datetime.datetime): if not timezone.is_naive(value): value = timezone.make_naive(value, timezone.utc) value = value.date() elif isinstance(value, datetime.date): # Nothing to do, as dates don't have tz information pass else: # No explicit date / datetime value -- no checks necessary return [] offset = datetime.timedelta(days=1) lower = (now - offset).date() upper = (now + offset).date() if lower <= value <= upper: return [ checks.Warning( 'Fixed default value provided.', hint='It seems you set a fixed date / time / datetime ' 'value as default for this field. This may not be ' 'what you want. If you want to have the current date ' 'as default, use `django.utils.timezone.now`', obj=self, id='fields.W161', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(DateField, self).deconstruct() if self.auto_now: kwargs['auto_now'] = True if self.auto_now_add: kwargs['auto_now_add'] = True if self.auto_now or self.auto_now_add: del kwargs['editable'] del kwargs['blank'] return name, path, args, kwargs def get_internal_type(self): return "DateField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): if settings.USE_TZ and timezone.is_aware(value): # Convert aware datetimes to the default time zone # before casting them to dates (#17742). default_timezone = timezone.get_default_timezone() value = timezone.make_naive(value, default_timezone) return value.date() if isinstance(value, datetime.date): return value try: parsed = parse_date(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_date'], code='invalid_date', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.date.today() setattr(model_instance, self.attname, value) return value else: return super(DateField, self).pre_save(model_instance, add) def contribute_to_class(self, cls, name, **kwargs): super(DateField, self).contribute_to_class(cls, name, **kwargs) if not self.null: setattr(cls, 'get_next_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=True)) setattr(cls, 'get_previous_by_%s' % self.name, curry(cls._get_next_or_previous_by_FIELD, field=self, is_next=False)) def get_prep_value(self, value): value = super(DateField, self).get_prep_value(value) return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts dates into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.adapt_datefield_value(value) def value_to_string(self, obj): val = self.value_from_object(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.DateField} defaults.update(kwargs) return super(DateField, self).formfield(**defaults) class DateTimeField(DateField): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format."), 'invalid_date': _("'%(value)s' value has the correct format " "(YYYY-MM-DD) but it is an invalid date."), 'invalid_datetime': _("'%(value)s' value has the correct format " "(YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) " "but it is an invalid date/time."), } description = _("Date (with time)") # __init__ is inherited from DateField def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual date or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): now = timezone.make_naive(now, timezone.utc) value = self.default if isinstance(value, datetime.datetime): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset upper = now + second_offset if timezone.is_aware(value): value = timezone.make_naive(value, timezone.utc) elif isinstance(value, datetime.date): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset lower = datetime.datetime(lower.year, lower.month, lower.day) upper = now + second_offset upper = datetime.datetime(upper.year, upper.month, upper.day) value = datetime.datetime(value.year, value.month, value.day) else: # No explicit date / datetime value -- no checks necessary return [] if lower <= value <= upper: return [ checks.Warning( 'Fixed default value provided.', hint='It seems you set a fixed date / time / datetime ' 'value as default for this field. This may not be ' 'what you want. If you want to have the current date ' 'as default, use `django.utils.timezone.now`', obj=self, id='fields.W161', ) ] return [] def get_internal_type(self): return "DateTimeField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.datetime): return value if isinstance(value, datetime.date): value = datetime.datetime(value.year, value.month, value.day) if settings.USE_TZ: # For backwards compatibility, interpret naive datetimes in # local time. This won't work during DST change, but we can't # do much about it, so we let the exceptions percolate up the # call stack. warnings.warn("DateTimeField %s.%s received a naive datetime " "(%s) while time zone support is active." % (self.model.__name__, self.name, value), RuntimeWarning) default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) return value try: parsed = parse_datetime(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_datetime'], code='invalid_datetime', params={'value': value}, ) try: parsed = parse_date(value) if parsed is not None: return datetime.datetime(parsed.year, parsed.month, parsed.day) except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_date'], code='invalid_date', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = timezone.now() setattr(model_instance, self.attname, value) return value else: return super(DateTimeField, self).pre_save(model_instance, add) # contribute_to_class is inherited from DateField, it registers # get_next_by_FOO and get_prev_by_FOO # get_prep_lookup is inherited from DateField def get_prep_value(self, value): value = super(DateTimeField, self).get_prep_value(value) value = self.to_python(value) if value is not None and settings.USE_TZ and timezone.is_naive(value): # For backwards compatibility, interpret naive datetimes in local # time. This won't work during DST change, but we can't do much # about it, so we let the exceptions percolate up the call stack. try: name = '%s.%s' % (self.model.__name__, self.name) except AttributeError: name = '(unbound)' warnings.warn("DateTimeField %s received a naive datetime (%s)" " while time zone support is active." % (name, value), RuntimeWarning) default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) return value def get_db_prep_value(self, value, connection, prepared=False): # Casts datetimes into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.adapt_datetimefield_value(value) def value_to_string(self, obj): val = self.value_from_object(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.DateTimeField} defaults.update(kwargs) return super(DateTimeField, self).formfield(**defaults) class DecimalField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be a decimal number."), } description = _("Decimal number") def __init__(self, verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs): self.max_digits, self.decimal_places = max_digits, decimal_places super(DecimalField, self).__init__(verbose_name, name, **kwargs) def check(self, **kwargs): errors = super(DecimalField, self).check(**kwargs) digits_errors = self._check_decimal_places() digits_errors.extend(self._check_max_digits()) if not digits_errors: errors.extend(self._check_decimal_places_and_max_digits(**kwargs)) else: errors.extend(digits_errors) return errors def _check_decimal_places(self): try: decimal_places = int(self.decimal_places) if decimal_places < 0: raise ValueError() except TypeError: return [ checks.Error( "DecimalFields must define a 'decimal_places' attribute.", hint=None, obj=self, id='fields.E130', ) ] except ValueError: return [ checks.Error( "'decimal_places' must be a non-negative integer.", hint=None, obj=self, id='fields.E131', ) ] else: return [] def _check_max_digits(self): try: max_digits = int(self.max_digits) if max_digits <= 0: raise ValueError() except TypeError: return [ checks.Error( "DecimalFields must define a 'max_digits' attribute.", hint=None, obj=self, id='fields.E132', ) ] except ValueError: return [ checks.Error( "'max_digits' must be a positive integer.", hint=None, obj=self, id='fields.E133', ) ] else: return [] def _check_decimal_places_and_max_digits(self, **kwargs): if int(self.decimal_places) > int(self.max_digits): return [ checks.Error( "'max_digits' must be greater or equal to 'decimal_places'.", hint=None, obj=self, id='fields.E134', ) ] return [] @cached_property def validators(self): return super(DecimalField, self).validators + [ validators.DecimalValidator(self.max_digits, self.decimal_places) ] def deconstruct(self): name, path, args, kwargs = super(DecimalField, self).deconstruct() if self.max_digits is not None: kwargs['max_digits'] = self.max_digits if self.decimal_places is not None: kwargs['decimal_places'] = self.decimal_places return name, path, args, kwargs def get_internal_type(self): return "DecimalField" def to_python(self, value): if value is None: return value try: return decimal.Decimal(value) except decimal.InvalidOperation: raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def _format(self, value): if isinstance(value, six.string_types): return value else: return self.format_number(value) def format_number(self, value): """ Formats a number into a string with the requisite number of digits and decimal places. """ # Method moved to django.db.backends.utils. # # It is preserved because it is used by the oracle backend # (django.db.backends.oracle.query), and also for # backwards-compatibility with any external code which may have used # this method. from django.db.backends import utils return utils.format_number(value, self.max_digits, self.decimal_places) def get_db_prep_save(self, value, connection): return connection.ops.adapt_decimalfield_value(self.to_python(value), self.max_digits, self.decimal_places) def get_prep_value(self, value): value = super(DecimalField, self).get_prep_value(value) return self.to_python(value) def formfield(self, **kwargs): defaults = { 'max_digits': self.max_digits, 'decimal_places': self.decimal_places, 'form_class': forms.DecimalField, } defaults.update(kwargs) return super(DecimalField, self).formfield(**defaults) class DurationField(Field): """Stores timedelta objects. Uses interval on postgres, INVERAL DAY TO SECOND on Oracle, and bigint of microseconds on other databases. """ empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "[DD] [HH:[MM:]]ss[.uuuuuu] format.") } description = _("Duration") def get_internal_type(self): return "DurationField" def to_python(self, value): if value is None: return value if isinstance(value, datetime.timedelta): return value try: parsed = parse_duration(value) except ValueError: pass else: if parsed is not None: return parsed raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_db_prep_value(self, value, connection, prepared=False): if connection.features.has_native_duration_field: return value if value is None: return None return value.total_seconds() * 1000000 def get_db_converters(self, connection): converters = [] if not connection.features.has_native_duration_field: converters.append(connection.ops.convert_durationfield_value) return converters + super(DurationField, self).get_db_converters(connection) def value_to_string(self, obj): val = self.value_from_object(obj) return '' if val is None else duration_string(val) def formfield(self, **kwargs): defaults = { 'form_class': forms.DurationField, } defaults.update(kwargs) return super(DurationField, self).formfield(**defaults) class EmailField(CharField): default_validators = [validators.validate_email] description = _("Email address") def __init__(self, *args, **kwargs): # max_length=254 to be compliant with RFCs 3696 and 5321 kwargs['max_length'] = kwargs.get('max_length', 254) super(EmailField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(EmailField, self).deconstruct() # We do not exclude max_length if it matches default as we want to change # the default in future. return name, path, args, kwargs def formfield(self, **kwargs): # As with CharField, this will cause email validation to be performed # twice. defaults = { 'form_class': forms.EmailField, } defaults.update(kwargs) return super(EmailField, self).formfield(**defaults) class FilePathField(Field): description = _("File path") def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, allow_files=True, allow_folders=False, **kwargs): self.path, self.match, self.recursive = path, match, recursive self.allow_files, self.allow_folders = allow_files, allow_folders kwargs['max_length'] = kwargs.get('max_length', 100) super(FilePathField, self).__init__(verbose_name, name, **kwargs) def check(self, **kwargs): errors = super(FilePathField, self).check(**kwargs) errors.extend(self._check_allowing_files_or_folders(**kwargs)) return errors def _check_allowing_files_or_folders(self, **kwargs): if not self.allow_files and not self.allow_folders: return [ checks.Error( "FilePathFields must have either 'allow_files' or 'allow_folders' set to True.", hint=None, obj=self, id='fields.E140', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(FilePathField, self).deconstruct() if self.path != '': kwargs['path'] = self.path if self.match is not None: kwargs['match'] = self.match if self.recursive is not False: kwargs['recursive'] = self.recursive if self.allow_files is not True: kwargs['allow_files'] = self.allow_files if self.allow_folders is not False: kwargs['allow_folders'] = self.allow_folders if kwargs.get("max_length") == 100: del kwargs["max_length"] return name, path, args, kwargs def get_prep_value(self, value): value = super(FilePathField, self).get_prep_value(value) if value is None: return None return six.text_type(value) def formfield(self, **kwargs): defaults = { 'path': self.path, 'match': self.match, 'recursive': self.recursive, 'form_class': forms.FilePathField, 'allow_files': self.allow_files, 'allow_folders': self.allow_folders, } defaults.update(kwargs) return super(FilePathField, self).formfield(**defaults) def get_internal_type(self): return "FilePathField" class FloatField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be a float."), } description = _("Floating point number") def get_prep_value(self, value): value = super(FloatField, self).get_prep_value(value) if value is None: return None return float(value) def get_internal_type(self): return "FloatField" def to_python(self, value): if value is None: return value try: return float(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def formfield(self, **kwargs): defaults = {'form_class': forms.FloatField} defaults.update(kwargs) return super(FloatField, self).formfield(**defaults) class IntegerField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be an integer."), } description = _("Integer") def check(self, **kwargs): errors = super(IntegerField, self).check(**kwargs) errors.extend(self._check_max_length_warning()) return errors def _check_max_length_warning(self): if self.max_length is not None: return [ checks.Warning( "'max_length' is ignored when used with IntegerField", hint="Remove 'max_length' from field", obj=self, id='fields.W122', ) ] return [] @cached_property def validators(self): # These validators can't be added at field initialization time since # they're based on values retrieved from `connection`. range_validators = [] internal_type = self.get_internal_type() min_value, max_value = connection.ops.integer_field_range(internal_type) if min_value is not None: range_validators.append(validators.MinValueValidator(min_value)) if max_value is not None: range_validators.append(validators.MaxValueValidator(max_value)) return super(IntegerField, self).validators + range_validators def get_prep_value(self, value): value = super(IntegerField, self).get_prep_value(value) if value is None: return None return int(value) def get_prep_lookup(self, lookup_type, value): if ((lookup_type == 'gte' or lookup_type == 'lt') and isinstance(value, float)): value = math.ceil(value) return super(IntegerField, self).get_prep_lookup(lookup_type, value) def get_internal_type(self): return "IntegerField" def to_python(self, value): if value is None: return value try: return int(value) except (TypeError, ValueError): raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def formfield(self, **kwargs): defaults = {'form_class': forms.IntegerField} defaults.update(kwargs) return super(IntegerField, self).formfield(**defaults) class BigIntegerField(IntegerField): empty_strings_allowed = False description = _("Big (8 byte) integer") MAX_BIGINT = 9223372036854775807 def get_internal_type(self): return "BigIntegerField" def formfield(self, **kwargs): defaults = {'min_value': -BigIntegerField.MAX_BIGINT - 1, 'max_value': BigIntegerField.MAX_BIGINT} defaults.update(kwargs) return super(BigIntegerField, self).formfield(**defaults) class IPAddressField(Field): empty_strings_allowed = False description = _("IPv4 address") system_check_removed_details = { 'msg': ( 'IPAddressField has been removed except for support in ' 'historical migrations.' ), 'hint': 'Use GenericIPAddressField instead.', 'id': 'fields.E900', } def __init__(self, *args, **kwargs): kwargs['max_length'] = 15 super(IPAddressField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(IPAddressField, self).deconstruct() del kwargs['max_length'] return name, path, args, kwargs def get_prep_value(self, value): value = super(IPAddressField, self).get_prep_value(value) if value is None: return None return six.text_type(value) def get_internal_type(self): return "IPAddressField" class GenericIPAddressField(Field): empty_strings_allowed = False description = _("IP address") default_error_messages = {} def __init__(self, verbose_name=None, name=None, protocol='both', unpack_ipv4=False, *args, **kwargs): self.unpack_ipv4 = unpack_ipv4 self.protocol = protocol self.default_validators, invalid_error_message = \ validators.ip_address_validators(protocol, unpack_ipv4) self.default_error_messages['invalid'] = invalid_error_message kwargs['max_length'] = 39 super(GenericIPAddressField, self).__init__(verbose_name, name, *args, **kwargs) def check(self, **kwargs): errors = super(GenericIPAddressField, self).check(**kwargs) errors.extend(self._check_blank_and_null_values(**kwargs)) return errors def _check_blank_and_null_values(self, **kwargs): if not getattr(self, 'null', False) and getattr(self, 'blank', False): return [ checks.Error( ('GenericIPAddressFields cannot have blank=True if null=False, ' 'as blank values are stored as nulls.'), hint=None, obj=self, id='fields.E150', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(GenericIPAddressField, self).deconstruct() if self.unpack_ipv4 is not False: kwargs['unpack_ipv4'] = self.unpack_ipv4 if self.protocol != "both": kwargs['protocol'] = self.protocol if kwargs.get("max_length") == 39: del kwargs['max_length'] return name, path, args, kwargs def get_internal_type(self): return "GenericIPAddressField" def to_python(self, value): if value is None: return None if not isinstance(value, six.string_types): value = force_text(value) value = value.strip() if ':' in value: return clean_ipv6_address(value, self.unpack_ipv4, self.error_messages['invalid']) return value def get_db_prep_value(self, value, connection, prepared=False): if not prepared: value = self.get_prep_value(value) return connection.ops.adapt_ipaddressfield_value(value) def get_prep_value(self, value): value = super(GenericIPAddressField, self).get_prep_value(value) if value is None: return None if value and ':' in value: try: return clean_ipv6_address(value, self.unpack_ipv4) except exceptions.ValidationError: pass return six.text_type(value) def formfield(self, **kwargs): defaults = { 'protocol': self.protocol, 'form_class': forms.GenericIPAddressField, } defaults.update(kwargs) return super(GenericIPAddressField, self).formfield(**defaults) class NullBooleanField(Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value must be either None, True or False."), } description = _("Boolean (Either True, False or None)") def __init__(self, *args, **kwargs): kwargs['null'] = True kwargs['blank'] = True super(NullBooleanField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(NullBooleanField, self).deconstruct() del kwargs['null'] del kwargs['blank'] return name, path, args, kwargs def get_internal_type(self): return "NullBooleanField" def to_python(self, value): if value is None: return None if value in (True, False): return bool(value) if value in ('None',): return None if value in ('t', 'True', '1'): return True if value in ('f', 'False', '0'): return False raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def get_prep_lookup(self, lookup_type, value): # Special-case handling for filters coming from a Web request (e.g. the # admin interface). Only works for scalar values (not lists). If you're # passing in a list, you might as well make things the right type when # constructing the list. if value in ('1', '0'): value = bool(int(value)) return super(NullBooleanField, self).get_prep_lookup(lookup_type, value) def get_prep_value(self, value): value = super(NullBooleanField, self).get_prep_value(value) if value is None: return None return bool(value) def formfield(self, **kwargs): defaults = { 'form_class': forms.NullBooleanField, 'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} defaults.update(kwargs) return super(NullBooleanField, self).formfield(**defaults) class PositiveIntegerField(IntegerField): description = _("Positive integer") def get_internal_type(self): return "PositiveIntegerField" def formfield(self, **kwargs): defaults = {'min_value': 0} defaults.update(kwargs) return super(PositiveIntegerField, self).formfield(**defaults) class PositiveSmallIntegerField(IntegerField): description = _("Positive small integer") def get_internal_type(self): return "PositiveSmallIntegerField" def formfield(self, **kwargs): defaults = {'min_value': 0} defaults.update(kwargs) return super(PositiveSmallIntegerField, self).formfield(**defaults) class SlugField(CharField): default_validators = [validators.validate_slug] description = _("Slug (up to %(max_length)s)") def __init__(self, *args, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 50) # Set db_index=True unless it's been set manually. if 'db_index' not in kwargs: kwargs['db_index'] = True self.allow_unicode = kwargs.pop('allow_unicode', False) if self.allow_unicode: self.default_validators = [validators.validate_unicode_slug] super(SlugField, self).__init__(*args, **kwargs) def deconstruct(self): name, path, args, kwargs = super(SlugField, self).deconstruct() if kwargs.get("max_length") == 50: del kwargs['max_length'] if self.db_index is False: kwargs['db_index'] = False else: del kwargs['db_index'] if self.allow_unicode is not False: kwargs['allow_unicode'] = self.allow_unicode return name, path, args, kwargs def get_internal_type(self): return "SlugField" def formfield(self, **kwargs): defaults = {'form_class': forms.SlugField, 'allow_unicode': self.allow_unicode} defaults.update(kwargs) return super(SlugField, self).formfield(**defaults) class SmallIntegerField(IntegerField): description = _("Small integer") def get_internal_type(self): return "SmallIntegerField" class TextField(Field): description = _("Text") def get_internal_type(self): return "TextField" def to_python(self, value): if isinstance(value, six.string_types) or value is None: return value return smart_text(value) def get_prep_value(self, value): value = super(TextField, self).get_prep_value(value) return self.to_python(value) def formfield(self, **kwargs): # Passing max_length to forms.CharField means that the value's length # will be validated twice. This is considered acceptable since we want # the value in the form field (to pass into widget for example). defaults = {'max_length': self.max_length, 'widget': forms.Textarea} defaults.update(kwargs) return super(TextField, self).formfield(**defaults) class TimeField(DateTimeCheckMixin, Field): empty_strings_allowed = False default_error_messages = { 'invalid': _("'%(value)s' value has an invalid format. It must be in " "HH:MM[:ss[.uuuuuu]] format."), 'invalid_time': _("'%(value)s' value has the correct format " "(HH:MM[:ss[.uuuuuu]]) but it is an invalid time."), } description = _("Time") def __init__(self, verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs): self.auto_now, self.auto_now_add = auto_now, auto_now_add if auto_now or auto_now_add: kwargs['editable'] = False kwargs['blank'] = True super(TimeField, self).__init__(verbose_name, name, **kwargs) def _check_fix_default_value(self): """ Adds a warning to the checks framework stating, that using an actual time or datetime value is probably wrong; it's only being evaluated on server start-up. For details see ticket #21905 """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): now = timezone.make_naive(now, timezone.utc) value = self.default if isinstance(value, datetime.datetime): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset upper = now + second_offset if timezone.is_aware(value): value = timezone.make_naive(value, timezone.utc) elif isinstance(value, datetime.time): second_offset = datetime.timedelta(seconds=10) lower = now - second_offset upper = now + second_offset value = datetime.datetime.combine(now.date(), value) if timezone.is_aware(value): value = timezone.make_naive(value, timezone.utc).time() else: # No explicit time / datetime value -- no checks necessary return [] if lower <= value <= upper: return [ checks.Warning( 'Fixed default value provided.', hint='It seems you set a fixed date / time / datetime ' 'value as default for this field. This may not be ' 'what you want. If you want to have the current date ' 'as default, use `django.utils.timezone.now`', obj=self, id='fields.W161', ) ] return [] def deconstruct(self): name, path, args, kwargs = super(TimeField, self).deconstruct() if self.auto_now is not False: kwargs["auto_now"] = self.auto_now if self.auto_now_add is not False: kwargs["auto_now_add"] = self.auto_now_add if self.auto_now or self.auto_now_add: del kwargs['blank'] del kwargs['editable'] return name, path, args, kwargs def get_internal_type(self): return "TimeField" def to_python(self, value): if value is None: return None if isinstance(value, datetime.time): return value if isinstance(value, datetime.datetime): # Not usually a good idea to pass in a datetime here (it loses # information), but this can be a side-effect of interacting with a # database backend (e.g. Oracle), so we'll be accommodating. return value.time() try: parsed = parse_time(value) if parsed is not None: return parsed except ValueError: raise exceptions.ValidationError( self.error_messages['invalid_time'], code='invalid_time', params={'value': value}, ) raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) def pre_save(self, model_instance, add): if self.auto_now or (self.auto_now_add and add): value = datetime.datetime.now().time() setattr(model_instance, self.attname, value) return value else: return super(TimeField, self).pre_save(model_instance, add) def get_prep_value(self, value): value = super(TimeField, self).get_prep_value(value) return self.to_python(value) def get_db_prep_value(self, value, connection, prepared=False): # Casts times into the format expected by the backend if not prepared: value = self.get_prep_value(value) return connection.ops.adapt_timefield_value(value) def value_to_string(self, obj): val = self.value_from_object(obj) return '' if val is None else val.isoformat() def formfield(self, **kwargs): defaults = {'form_class': forms.TimeField} defaults.update(kwargs) return super(TimeField, self).formfield(**defaults) class URLField(CharField): default_validators = [validators.URLValidator()] description = _("URL") def __init__(self, verbose_name=None, name=None, **kwargs): kwargs['max_length'] = kwargs.get('max_length', 200) super(URLField, self).__init__(verbose_name, name, **kwargs) def deconstruct(self): name, path, args, kwargs = super(URLField, self).deconstruct() if kwargs.get("max_length") == 200: del kwargs['max_length'] return name, path, args, kwargs def formfield(self, **kwargs): # As with CharField, this will cause URL validation to be performed # twice. defaults = { 'form_class': forms.URLField, } defaults.update(kwargs) return super(URLField, self).formfield(**defaults) class BinaryField(Field): description = _("Raw binary data") empty_values = [None, b''] def __init__(self, *args, **kwargs): kwargs['editable'] = False super(BinaryField, self).__init__(*args, **kwargs) if self.max_length is not None: self.validators.append(validators.MaxLengthValidator(self.max_length)) def deconstruct(self): name, path, args, kwargs = super(BinaryField, self).deconstruct() del kwargs['editable'] return name, path, args, kwargs def get_internal_type(self): return "BinaryField" def get_default(self): if self.has_default() and not callable(self.default): return self.default default = super(BinaryField, self).get_default() if default == '': return b'' return default def get_db_prep_value(self, value, connection, prepared=False): value = super(BinaryField, self).get_db_prep_value(value, connection, prepared) if value is not None: return connection.Database.Binary(value) return value def value_to_string(self, obj): """Binary data is serialized as base64""" return b64encode(force_bytes(self.value_from_object(obj))).decode('ascii') def to_python(self, value): # If it's a string, it should be base64-encoded data if isinstance(value, six.text_type): return six.memoryview(b64decode(force_bytes(value))) return value class UUIDField(Field): default_error_messages = { 'invalid': _("'%(value)s' is not a valid UUID."), } description = 'Universally unique identifier' empty_strings_allowed = False def __init__(self, verbose_name=None, **kwargs): kwargs['max_length'] = 32 super(UUIDField, self).__init__(verbose_name, **kwargs) def deconstruct(self): name, path, args, kwargs = super(UUIDField, self).deconstruct() del kwargs['max_length'] return name, path, args, kwargs def get_internal_type(self): return "UUIDField" def get_db_prep_value(self, value, connection, prepared=False): if value is None: return None if not isinstance(value, uuid.UUID): try: value = uuid.UUID(value) except AttributeError: raise TypeError(self.error_messages['invalid'] % {'value': value}) if connection.features.has_native_uuid_field: return value return value.hex def to_python(self, value): if value and not isinstance(value, uuid.UUID): try: return uuid.UUID(value) except ValueError: raise exceptions.ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value}, ) return value def formfield(self, **kwargs): defaults = { 'form_class': forms.UUIDField, } defaults.update(kwargs) return super(UUIDField, self).formfield(**defaults)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 2197, 199, 646, 6107, 199, 646, 3473, 199, 646, 5377, 199, 646, 3598, 199, 504, 1300, 772, 492, 330, 772, 2708, 12, 330, 772, 2143, 199, 504, 9143, 492, 3141, 63, 7128, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 5920, 12, 4967, 12, 14370, 199, 3, 3979, 314, 485, 2024, 909, 1990, 1824, 279, 1759, 12, 642, 1919, 1990, 12155, 370, 199, 3, 1639, 14, 1018, 14, 3924, 14, 2779, 365, 30403, 2348, 367, 8552, 7163, 199, 3, 12901, 14, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 221, 327, 20432, 199, 504, 1639, 14, 697, 492, 1950, 12, 6947, 12, 6197, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 12, 11828, 7521, 4256, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7137, 199, 504, 1639, 14, 1208, 14, 23004, 492, 7448, 4590, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 334, 272, 2198, 63, 602, 12, 2198, 63, 2083, 12, 2198, 63, 5553, 12, 2198, 63, 521, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 15383, 492, 334, 272, 23687, 1165, 3849, 12, 7987, 63, 10254, 63, 29401, 63, 765, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 199, 504, 1639, 14, 1208, 14, 2991, 492, 334, 272, 3542, 63, 2394, 12, 3542, 63, 505, 12, 2366, 63, 18, 63, 2975, 63, 6490, 12, 11179, 63, 505, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 15481, 492, 27724, 572, 12, 6328, 63, 1829, 12, 1094, 651, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 3633, 63, 4774, 22, 63, 1562, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 3, 19503, 298, 4333, 26, 7020, 315, 1124, 504, 769, 891, 440, 282, 1059, 2, 1553, 2649, 63, 5955, 199, 3, 7704, 3520, 3326, 2649, 199, 363, 452, 363, 275, 359, 495, 8, 88, 9, 367, 671, 315, 334, 272, 283, 4378, 297, 283, 20438, 63, 22544, 63, 29019, 297, 283, 25175, 297, 283, 6636, 792, 297, 272, 283, 5036, 297, 283, 2183, 297, 283, 25732, 20727, 3901, 297, 283, 14071, 297, 272, 283, 4626, 297, 283, 15975, 297, 283, 13283, 792, 297, 283, 16577, 297, 283, 4699, 297, 272, 283, 792, 297, 283, 792, 7400, 297, 283, 14225, 792, 297, 283, 13019, 297, 272, 283, 9417, 26969, 297, 283, 26969, 297, 283, 3901, 297, 283, 4609, 63, 21403, 1149, 297, 272, 283, 29068, 297, 283, 8591, 297, 283, 25197, 297, 272, 283, 17315, 297, 283, 14640, 297, 283, 6254, 297, 283, 27115, 297, 283, 17363, 297, 272, 283, 8757, 792, 297, 199, 1874, 421, 199, 533, 9630, 8, 785, 304, 272, 986, 421, 199, 533, 2845, 63, 21403, 1149, 26, 272, 986, 199, 199, 3, 710, 1338, 370, 675, 367, 298, 2500, 2, 315, 9496, 7304, 14, 12823, 506, 11544, 370, 314, 1343, 199, 3, 402, 4750, 298, 4577, 2, 5548, 14, 199, 20438, 63, 22544, 63, 29019, 275, 3842, 5151, 298, 9960, 11323, 421, 199, 318, 485, 912, 63, 698, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 901, 63, 354, 304, 272, 372, 8686, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 10445, 2024, 14, 362, 63, 698, 8, 698, 63, 354, 9, 421, 199, 3, 437, 22885, 370, 5024, 2633, 26, 199, 3, 199, 3, 257, 627, 536, 26, 420, 710, 536, 402, 314, 901, 2013, 315, 314, 1402, 14, 199, 3, 257, 627, 15115, 354, 26, 257, 710, 2225, 370, 675, 641, 314, 1402, 909, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 354, 401, 871, 315, 314, 1930, 402, 481, 2692, 6340, 12, 2382, 2668, 344, 2, 365, 199, 3, 4483, 11544, 14, 199, 3, 257, 627, 1592, 63, 2301, 26, 710, 1592, 63, 2301, 2013, 315, 314, 1402, 334, 269, 488, 680, 199, 3, 257, 627, 2763, 26, 259, 710, 3050, 2763, 367, 642, 901, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 13651, 401, 871, 340, 1592, 63, 2301, 365, 2013, 14, 199, 3, 199, 3, 5495, 626, 1109, 21302, 83, 1338, 12, 503, 1630, 1163, 8336, 7645, 12, 1077, 675, 199, 3, 15115, 354, 14, 2104, 2893, 12, 642, 7545, 314, 5062, 790, 574, 402, 909, 298, 1113, 582, 199, 3, 199, 3, 258, 2519, 8, 1113, 12, 3999, 14, 2051, 14, 13651, 9, 199, 199, 318, 485, 1667, 8, 1618, 63, 1886, 304, 272, 892, 275, 9630, 342, 272, 892, 855, 533, 363, 275, 402, 63, 1886, 272, 372, 892, 421, 199, 32, 2923, 63, 7128, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 5024, 8, 7099, 7521, 4256, 304, 272, 408, 1563, 1021, 367, 1006, 901, 2943, 624, 339, 327, 29410, 2335, 3775, 2701, 3326, 27440, 14040, 1183, 787, 4370, 737, 314, 272, 327, 3050, 2166, 14, 272, 2701, 63, 5465, 63, 6541, 275, 715, 272, 2701, 63, 1459, 275, 769, 8, 11346, 14, 13993, 63, 15514, 9, 339, 327, 5723, 4426, 1924, 900, 282, 5024, 1256, 365, 2737, 14, 8051, 370, 8074, 1865, 14, 272, 327, 710, 2599, 63, 8782, 63, 5337, 365, 1202, 367, 1504, 626, 5634, 19796, 272, 327, 8491, 12, 7143, 63, 5337, 365, 1202, 367, 1006, 922, 13, 10085, 1504, 14, 272, 7143, 63, 5337, 275, 378, 272, 2599, 63, 8782, 63, 5337, 275, 446, 17, 272, 849, 63, 11346, 275, 942, 221, 327, 3758, 663, 402, 14370, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 63, 5095, 356, 4018, 1110, 2818, 585, 9, 82, 365, 440, 282, 1686, 7141, 8038, 267, 283, 2307, 356, 4018, 2765, 901, 3913, 506, 2973, 8038, 267, 283, 2500, 356, 4018, 2765, 901, 3913, 506, 4596, 8038, 267, 283, 3235, 356, 4018, 2840, 1238, 63, 354, 9 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 2197, 199, 646, 6107, 199, 646, 3473, 199, 646, 5377, 199, 646, 3598, 199, 504, 1300, 772, 492, 330, 772, 2708, 12, 330, 772, 2143, 199, 504, 9143, 492, 3141, 63, 7128, 199, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 5181, 492, 8686, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 5920, 12, 4967, 12, 14370, 199, 3, 3979, 314, 485, 2024, 909, 1990, 1824, 279, 1759, 12, 642, 1919, 1990, 12155, 370, 199, 3, 1639, 14, 1018, 14, 3924, 14, 2779, 365, 30403, 2348, 367, 8552, 7163, 199, 3, 12901, 14, 199, 504, 1639, 14, 1018, 14, 3924, 492, 29994, 221, 327, 20432, 199, 504, 1639, 14, 697, 492, 1950, 12, 6947, 12, 6197, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 12, 11828, 7521, 4256, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7137, 199, 504, 1639, 14, 1208, 14, 23004, 492, 7448, 4590, 199, 504, 1639, 14, 1208, 14, 602, 1122, 492, 334, 272, 2198, 63, 602, 12, 2198, 63, 2083, 12, 2198, 63, 5553, 12, 2198, 63, 521, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 15383, 492, 334, 272, 23687, 1165, 3849, 12, 7987, 63, 10254, 63, 29401, 63, 765, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 5553, 492, 7373, 63, 875, 199, 504, 1639, 14, 1208, 14, 2991, 492, 334, 272, 3542, 63, 2394, 12, 3542, 63, 505, 12, 2366, 63, 18, 63, 2975, 63, 6490, 12, 11179, 63, 505, 12, 199, 9, 199, 504, 1639, 14, 1208, 14, 15481, 492, 27724, 572, 12, 6328, 63, 1829, 12, 1094, 651, 199, 504, 1639, 14, 1208, 14, 4774, 22, 492, 3633, 63, 4774, 22, 63, 1562, 199, 504, 1639, 14, 1208, 14, 1661, 5819, 492, 365, 63, 8147, 199, 504, 1639, 14, 1208, 14, 505, 492, 4021, 2246, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 3, 19503, 298, 4333, 26, 7020, 315, 1124, 504, 769, 891, 440, 282, 1059, 2, 1553, 2649, 63, 5955, 199, 3, 7704, 3520, 3326, 2649, 199, 363, 452, 363, 275, 359, 495, 8, 88, 9, 367, 671, 315, 334, 272, 283, 4378, 297, 283, 20438, 63, 22544, 63, 29019, 297, 283, 25175, 297, 283, 6636, 792, 297, 272, 283, 5036, 297, 283, 2183, 297, 283, 25732, 20727, 3901, 297, 283, 14071, 297, 272, 283, 4626, 297, 283, 15975, 297, 283, 13283, 792, 297, 283, 16577, 297, 283, 4699, 297, 272, 283, 792, 297, 283, 792, 7400, 297, 283, 14225, 792, 297, 283, 13019, 297, 272, 283, 9417, 26969, 297, 283, 26969, 297, 283, 3901, 297, 283, 4609, 63, 21403, 1149, 297, 272, 283, 29068, 297, 283, 8591, 297, 283, 25197, 297, 272, 283, 17315, 297, 283, 14640, 297, 283, 6254, 297, 283, 27115, 297, 283, 17363, 297, 272, 283, 8757, 792, 297, 199, 1874, 421, 199, 533, 9630, 8, 785, 304, 272, 986, 421, 199, 533, 2845, 63, 21403, 1149, 26, 272, 986, 199, 199, 3, 710, 1338, 370, 675, 367, 298, 2500, 2, 315, 9496, 7304, 14, 12823, 506, 11544, 370, 314, 1343, 199, 3, 402, 4750, 298, 4577, 2, 5548, 14, 199, 20438, 63, 22544, 63, 29019, 275, 3842, 5151, 298, 9960, 11323, 421, 199, 318, 485, 912, 63, 698, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 901, 63, 354, 304, 272, 372, 8686, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 10445, 2024, 14, 362, 63, 698, 8, 698, 63, 354, 9, 421, 199, 3, 437, 22885, 370, 5024, 2633, 26, 199, 3, 199, 3, 257, 627, 536, 26, 420, 710, 536, 402, 314, 901, 2013, 315, 314, 1402, 14, 199, 3, 257, 627, 15115, 354, 26, 257, 710, 2225, 370, 675, 641, 314, 1402, 909, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 354, 401, 871, 315, 314, 1930, 402, 481, 2692, 6340, 12, 2382, 2668, 344, 2, 365, 199, 3, 4483, 11544, 14, 199, 3, 257, 627, 1592, 63, 2301, 26, 710, 1592, 63, 2301, 2013, 315, 314, 1402, 334, 269, 488, 680, 199, 3, 257, 627, 2763, 26, 259, 710, 3050, 2763, 367, 642, 901, 14, 961, 365, 314, 2011, 465, 199, 3, 4483, 298, 13651, 401, 871, 340, 1592, 63, 2301, 365, 2013, 14, 199, 3, 199, 3, 5495, 626, 1109, 21302, 83, 1338, 12, 503, 1630, 1163, 8336, 7645, 12, 1077, 675, 199, 3, 15115, 354, 14, 2104, 2893, 12, 642, 7545, 314, 5062, 790, 574, 402, 909, 298, 1113, 582, 199, 3, 199, 3, 258, 2519, 8, 1113, 12, 3999, 14, 2051, 14, 13651, 9, 199, 199, 318, 485, 1667, 8, 1618, 63, 1886, 304, 272, 892, 275, 9630, 342, 272, 892, 855, 533, 363, 275, 402, 63, 1886, 272, 372, 892, 421, 199, 32, 2923, 63, 7128, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 5024, 8, 7099, 7521, 4256, 304, 272, 408, 1563, 1021, 367, 1006, 901, 2943, 624, 339, 327, 29410, 2335, 3775, 2701, 3326, 27440, 14040, 1183, 787, 4370, 737, 314, 272, 327, 3050, 2166, 14, 272, 2701, 63, 5465, 63, 6541, 275, 715, 272, 2701, 63, 1459, 275, 769, 8, 11346, 14, 13993, 63, 15514, 9, 339, 327, 5723, 4426, 1924, 900, 282, 5024, 1256, 365, 2737, 14, 8051, 370, 8074, 1865, 14, 272, 327, 710, 2599, 63, 8782, 63, 5337, 365, 1202, 367, 1504, 626, 5634, 19796, 272, 327, 8491, 12, 7143, 63, 5337, 365, 1202, 367, 1006, 922, 13, 10085, 1504, 14, 272, 7143, 63, 5337, 275, 378, 272, 2599, 63, 8782, 63, 5337, 275, 446, 17, 272, 849, 63, 11346, 275, 942, 221, 327, 3758, 663, 402, 14370, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 63, 5095, 356, 4018, 1110, 2818, 585, 9, 82, 365, 440, 282, 1686, 7141, 8038, 267, 283, 2307, 356, 4018, 2765, 901, 3913, 506, 2973, 8038, 267, 283, 2500, 356, 4018, 2765, 901, 3913, 506, 4596, 8038, 267, 283, 3235, 356, 4018, 2840, 1238, 63, 354, 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,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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 ]
hoangt/ScaffCC
scaffold/flatten-qasm.py
2
7835
import argparse import re def process_qasm(fname): qgates = ['H','X','CNOT','Y','Z','S','T','Tdag','Sdag','Rz','PrepX','PrepZ','MeasX','MeasZ','Toffoli','Fredkin'] qgates_1 = ['H','X','Y','Z','S','T','Tdag'] qgates_1a = ['Sdag'] qgates_2 = ['CNOT'] qgates_3 = ['Toffoli','Fredkin'] qgates_4 = ['PrepX','PrepZ'] qgates_5 = ['MeasX','MeasZ'] qgates_6 = ['Rz'] gateNames = { 'H':'H', 'X':'X', 'Y':'Y', 'Z':'Z', 'S':'S', 'T':'T', 'Sdag':'Sdag', 'Tdag':'Tdag', 'PrepX':'PrepX', #'Px', 'PrepZ':'PrepZ', #'Pz', 'MeasZ':'MeasZ', #'Mz', 'MeasX':'MeasX', #'Mx', 'Rz':'Rz', 'CNOT':'CNOT', #'CX', 'Toffoli':'Tof', 'Fredkin':'Fredkin' } pattern_qbit_decl = re.compile(r"\s*\bqbit\b\s+(?P<qbit_var>\w+)\s*\[\s*(?P<array_size>\d+)\s*\]\s*;") pattern_cbit_decl = re.compile(r"\s*\bcbit\b\s+(?P<qbit_var>\w+)\s*\[\s*(?P<array_size>\d+)\s*\]\s*;") pattern_qg = re.compile(r"\s*((\w+|\w+\[(.*?)\])\s*\=)*\s*(?P<func_name>\w+)\s*\(\s*(?P<array_size>(.*?))\s*\)\s*;") pattern_qbit_arg = re.compile(r"(.*?)\((.*?)\bqbit\b\s*(.*?)\)(.*?)") pattern_meas = re.compile(r"\s*(?P<func_ret>(\w+|\w+\[(.*?)\])\s*\=)*\s*(\bqg_MeasX|qg_MeasZ\b)\s*\(\s*(?P<array_size>(.*?))\s*\)\s*;") pattern_main = re.compile(r"\s*(\bvoid|module\b)\s+(\bmain\b)\s*\((.*?)\)\s*(\{)*\s*") pattern_comment = re.compile(r"\s*//--//--(.*?)--//--//\s*") fout_name = re.sub('\.qhf$','_qasm.scaffold',fname) fout = open(fout_name,'w') fout.write('#include<stdio.h>\n') #add instrumentation functions for q in qgates_1: instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a){ printf("' +gateNames[q] +' %s\\n",a); }\n' fout.write(fstr) fout.write('\n') for q in qgates_1a: #Sdag = S^3 instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a){ printf("S %s\\n",a); printf("S %s\\n",a); printf("S %s\\n",a); }\n' fout.write(fstr) fout.write('\n') for q in qgates_2: #CNOT => CX (target,control) instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a, char* b){ printf("'+gateNames[q]+' %s,%s\\n",a,b); }\n' fout.write(fstr) fout.write('\n') for q in qgates_3: instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a, char* b, char* c){ printf("' +gateNames[q] +' %s,%s,%s\\n",a,b,c); }\n' fout.write(fstr) fout.write('\n') for q in qgates_4: #PrepZ, PrepX instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a, int i){ printf("' +gateNames[q] +' %s\\n",a); ' fout.write(fstr) fstr = 'if(i==1){ printf("X %s\\n",a); } }\n' fout.write(fstr) fout.write('\n') for q in qgates_5: #MeasX, MeasZ instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a){ printf("' +gateNames[q] +' %s\\n",a); }\n' fout.write(fstr) fout.write('\n') for q in qgates_6: instFnName = 'qg_'+q fstr = 'void '+instFnName+'(char* a, double b){ printf("' +gateNames[q] +' %s,%f\\n",a,b); }\n' fout.write(fstr) fout.write('\n') #ignore contents until QASM Generation Pass f = open(fname,'r') b = 'Dummy Line' while(b!=''): if(b.find('QASM Generation Pass:')!=-1): break b = f.readline() b = f.readline() inMainFunc = False setQbitDecl = [] setCbitDecl = [] while(b!=''): if(b.find('End of QASM generation')!=-1): break #check for qbit declarations m = re.match(pattern_main,b) if(m): inMainFunc = True b = re.sub(r"\bvoid|module\b","int ",b) m = re.match(pattern_qbit_decl,b) if(m): #Matched qbit declaration numElem = int(m.group('array_size')) var = m.group('qbit_var') addAlphabet='' if(not inMainFunc): addAlphabet='a' #add 'a' at end of ancilla declaration subStr = "char* "+m.group('qbit_var')+'['+m.group('array_size')+'] = {' fout.write(subStr) for i in range(numElem-1): varName = var+str(i)+addAlphabet tmp = '"'+varName+'",' if varName not in setQbitDecl: setQbitDecl.append(varName) fout.write(tmp) varName = var+str(numElem-1)+addAlphabet tmp = '"'+varName+'"' if varName not in setQbitDecl: setQbitDecl.append(varName) fout.write(tmp) fout.write('};\n') else: m = re.match(pattern_qg,b) if(m): #Matched qauntum gate call qstr = m.group('func_name') if qstr in qgates: rstr = 'qg_'+qstr mystr = b.replace(qstr,rstr) #check for Meas gates m1 = re.match(pattern_meas,mystr) if(m1): retStr = m1.group('func_ret') if(retStr): mystr = mystr.replace(retStr,'') fout.write(mystr) else: fout.write(b) else: #substitute qbit as char* in module definitions m = re.match(pattern_qbit_arg,b) if(m): mystr = b mystr = re.sub(r"\bqbit\b","char* ",mystr) fout.write(mystr) else: m = re.match(pattern_cbit_decl,b) if(m): numElem = int(m.group('array_size')) var = m.group('qbit_var') subStr = "char* "+m.group('qbit_var')+'['+m.group('array_size')+'] = {' fout.write(subStr) for i in range(numElem-1): tmp = '"'+var+str(i)+'",' setCbitDecl.append(var+str(i)) fout.write(tmp) tmp = '"'+var+str(numElem-1)+'"' setCbitDecl.append(var+str(numElem-1)) fout.write(tmp) fout.write('};\n') else: m = re.match(pattern_comment,b) if(m): subStr = 'printf("'+b.rstrip('\n')+'\\n");' fout.write(subStr) else: #print 'Did not match any pattern:',b fout.write(b) b = f.readline() print 'Output written to ',fout_name f.close() fout.close() print 'Qbits:',setQbitDecl print 'Cbits:',setCbitDecl #write qbit and cbit declarations to file fdecl = open("fdecl.out",'w') for q in setQbitDecl: myStr = 'qubit '+q+'\n' fdecl.write(myStr) for q in setCbitDecl: myStr = 'cbit '+q+'\n' fdecl.write(myStr) fdecl.close() parser = argparse.ArgumentParser(description='Convert QASM code into flattened QASM code') parser.add_argument("input") args = parser.parse_args() process_qasm(args.input)
bsd-2-clause
[ 646, 7534, 199, 646, 295, 199, 199, 318, 2112, 63, 81, 11374, 8, 5252, 304, 339, 1894, 71, 2335, 275, 788, 40, 1673, 56, 1673, 35, 4609, 1673, 57, 1673, 58, 1673, 51, 1673, 52, 1673, 52, 7406, 1673, 51, 7406, 1673, 50, 90, 1673, 24001, 56, 1673, 24001, 58, 1673, 1352, 305, 56, 1673, 1352, 305, 58, 1673, 1378, 70, 545, 317, 1673, 38, 581, 19269, 418, 258, 339, 1894, 71, 2335, 63, 17, 275, 788, 40, 1673, 56, 1673, 57, 1673, 58, 1673, 51, 1673, 52, 1673, 52, 7406, 418, 272, 1894, 71, 2335, 63, 17, 65, 275, 788, 51, 7406, 418, 272, 1894, 71, 2335, 63, 18, 275, 788, 35, 4609, 418, 272, 1894, 71, 2335, 63, 19, 275, 788, 1378, 70, 545, 317, 1673, 38, 581, 19269, 418, 14821, 1894, 71, 2335, 63, 20, 275, 788, 24001, 56, 1673, 24001, 58, 418, 272, 1894, 71, 2335, 63, 21, 275, 788, 1352, 305, 56, 1673, 1352, 305, 58, 418, 272, 1894, 71, 2335, 63, 22, 275, 788, 50, 90, 418, 1362, 339, 17036, 5866, 275, 469, 267, 283, 40, 5242, 40, 297, 267, 283, 56, 5242, 56, 297, 267, 283, 57, 5242, 57, 297, 267, 283, 58, 5242, 58, 297, 267, 283, 51, 5242, 51, 297, 267, 283, 52, 5242, 52, 297, 267, 283, 51, 7406, 5242, 51, 7406, 297, 267, 283, 52, 7406, 5242, 52, 7406, 297, 267, 283, 24001, 56, 5242, 24001, 56, 297, 17384, 48, 88, 297, 267, 283, 24001, 58, 5242, 24001, 58, 297, 17384, 48, 90, 297, 267, 283, 1352, 305, 58, 5242, 1352, 305, 58, 297, 17384, 23332, 297, 267, 283, 1352, 305, 56, 5242, 1352, 305, 56, 297, 17384, 45, 88, 297, 267, 283, 50, 90, 5242, 50, 90, 297, 267, 283, 35, 4609, 5242, 35, 4609, 297, 17384, 26001, 297, 267, 283, 1378, 70, 545, 317, 5242, 1378, 70, 297, 267, 283, 38, 581, 19269, 5242, 38, 581, 19269, 7, 267, 789, 2286, 3851, 63, 81, 2075, 63, 9427, 275, 295, 14, 2014, 8, 82, 3212, 83, 7590, 23907, 2075, 60, 66, 60, 83, 11, 2229, 48, 28, 81, 2075, 63, 1391, 3072, 87, 13439, 83, 7590, 7023, 83, 30957, 48, 28, 1144, 63, 890, 3072, 68, 13439, 83, 7590, 7272, 83, 10, 15027, 272, 3851, 63, 67, 2075, 63, 9427, 275, 295, 14, 2014, 8, 82, 3212, 83, 7590, 3776, 2075, 60, 66, 60, 83, 11, 2229, 48, 28, 81, 2075, 63, 1391, 3072, 87, 13439, 83, 7590, 7023, 83, 30957, 48, 28, 1144, 63, 890, 3072, 68, 13439, 83, 7590, 7272, 83, 10, 15027, 339, 3851, 63, 81, 71, 275, 295, 14, 2014, 8, 82, 3212, 83, 10, 1332, 60, 87, 11, 6113, 87, 7896, 7528, 6697, 2862, 27147, 83, 7590, 29, 3342, 60, 83, 30957, 48, 28, 1532, 63, 354, 3072, 87, 13439, 83, 7590, 2961, 83, 30957, 48, 28, 1144, 63, 890, 13661, 6697, 25105, 83, 7590, 2862, 83, 10, 15027, 272, 3851, 63, 81, 2075, 63, 1273, 275, 295, 14, 2014, 8, 82, 2, 17140, 2862, 1332, 6697, 2862, 23907, 2075, 60, 66, 60, 83, 5830, 6697, 2862, 5130, 6697, 6320, 272, 3851, 63, 19116, 275, 295, 14, 2014, 8, 82, 3212, 83, 30957, 48, 28, 1532, 63, 3292, 30, 2961, 87, 11, 6113, 87, 7896, 7528, 6697, 2862, 27147, 83, 7590, 29, 3342, 60, 83, 22588, 23907, 71, 63, 1352, 305, 56, 92, 81, 71, 63, 1352, 305, 58, 60, 66, 2862, 83, 7590, 2961, 83, 30957, 48, 28, 1144, 63, 890, 13661, 6697, 25105, 83, 7590, 2862, 83, 10, 15027, 272, 3851, 63, 973, 275, 295, 14, 2014, 8, 82, 3212, 83, 22588, 66, 1647, 92, 578, 60, 66, 2862, 83, 20900, 66, 973, 60, 66, 2862, 83, 7590, 1332, 6697, 2862, 2862, 83, 22588, 91, 3342, 60, 83, 10, 531, 272, 3851, 63, 3349, 275, 295, 14, 2014, 8, 82, 3212, 83, 10, 501, 306, 501, 306, 17140, 9, 306, 501, 306, 501, 60, 83, 10, 531, 339, 17863, 63, 354, 275, 295, 14, 954, 2258, 14, 81, 9188, 4, 1673, 63, 81, 11374, 14, 27927, 297, 5252, 9, 272, 17863, 275, 1551, 8, 30762, 63, 354, 2584, 87, 358, 339, 17863, 14, 952, 7863, 2613, 28, 32011, 14, 72, 3072, 78, 358, 339, 327, 525, 14498, 425, 3423, 272, 367, 1894, 315, 1894, 71, 2335, 63, 17, 26, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 11224, 870, 70, 15587, 435, 3237, 5866, 59, 81, 61, 435, 7, 450, 83, 1103, 78, 401, 65, 2736, 27958, 78, 7, 267, 17863, 14, 952, 8, 70, 495, 9, 339, 17863, 14, 952, 2258, 78, 358, 339, 367, 1894, 315, 1894, 71, 2335, 63, 17, 65, 26, 327, 51, 7406, 275, 428, 62, 19, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 11224, 870, 70, 480, 51, 450, 83, 1103, 78, 401, 65, 2736, 870, 70, 480, 51, 450, 83, 1103, 78, 401, 65, 2736, 870, 70, 480, 51, 450, 83, 1103, 78, 401, 65, 2736, 27958, 78, 7, 267, 17863, 14, 952, 8, 70, 495, 9, 339, 17863, 14, 952, 2258, 78, 358, 2378, 367, 1894, 315, 1894, 71, 2335, 63, 18, 26, 327, 35, 4609, 9265, 445, 56, 334, 1375, 12, 2785, 9, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 12, 1495, 10, 330, 11224, 870, 70, 480, 6828, 3237, 5866, 59, 81, 28012, 450, 83, 8719, 83, 1103, 78, 401, 65, 12, 66, 2736, 27958, 78, 7, 267, 17863, 14, 952, 8, 70, 495, 9, 339, 17863, 14, 952, 2258, 78, 358, 339, 367, 1894, 315, 1894, 71, 2335, 63, 19, 26, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 12, 1495, 10, 330, 12, 1495, 10, 286, 11224, 870, 70, 15587, 435, 3237, 5866, 59, 81, 61, 435, 7, 450, 83, 8719, 83, 8719 ]
[ 7534, 199, 646, 295, 199, 199, 318, 2112, 63, 81, 11374, 8, 5252, 304, 339, 1894, 71, 2335, 275, 788, 40, 1673, 56, 1673, 35, 4609, 1673, 57, 1673, 58, 1673, 51, 1673, 52, 1673, 52, 7406, 1673, 51, 7406, 1673, 50, 90, 1673, 24001, 56, 1673, 24001, 58, 1673, 1352, 305, 56, 1673, 1352, 305, 58, 1673, 1378, 70, 545, 317, 1673, 38, 581, 19269, 418, 258, 339, 1894, 71, 2335, 63, 17, 275, 788, 40, 1673, 56, 1673, 57, 1673, 58, 1673, 51, 1673, 52, 1673, 52, 7406, 418, 272, 1894, 71, 2335, 63, 17, 65, 275, 788, 51, 7406, 418, 272, 1894, 71, 2335, 63, 18, 275, 788, 35, 4609, 418, 272, 1894, 71, 2335, 63, 19, 275, 788, 1378, 70, 545, 317, 1673, 38, 581, 19269, 418, 14821, 1894, 71, 2335, 63, 20, 275, 788, 24001, 56, 1673, 24001, 58, 418, 272, 1894, 71, 2335, 63, 21, 275, 788, 1352, 305, 56, 1673, 1352, 305, 58, 418, 272, 1894, 71, 2335, 63, 22, 275, 788, 50, 90, 418, 1362, 339, 17036, 5866, 275, 469, 267, 283, 40, 5242, 40, 297, 267, 283, 56, 5242, 56, 297, 267, 283, 57, 5242, 57, 297, 267, 283, 58, 5242, 58, 297, 267, 283, 51, 5242, 51, 297, 267, 283, 52, 5242, 52, 297, 267, 283, 51, 7406, 5242, 51, 7406, 297, 267, 283, 52, 7406, 5242, 52, 7406, 297, 267, 283, 24001, 56, 5242, 24001, 56, 297, 17384, 48, 88, 297, 267, 283, 24001, 58, 5242, 24001, 58, 297, 17384, 48, 90, 297, 267, 283, 1352, 305, 58, 5242, 1352, 305, 58, 297, 17384, 23332, 297, 267, 283, 1352, 305, 56, 5242, 1352, 305, 56, 297, 17384, 45, 88, 297, 267, 283, 50, 90, 5242, 50, 90, 297, 267, 283, 35, 4609, 5242, 35, 4609, 297, 17384, 26001, 297, 267, 283, 1378, 70, 545, 317, 5242, 1378, 70, 297, 267, 283, 38, 581, 19269, 5242, 38, 581, 19269, 7, 267, 789, 2286, 3851, 63, 81, 2075, 63, 9427, 275, 295, 14, 2014, 8, 82, 3212, 83, 7590, 23907, 2075, 60, 66, 60, 83, 11, 2229, 48, 28, 81, 2075, 63, 1391, 3072, 87, 13439, 83, 7590, 7023, 83, 30957, 48, 28, 1144, 63, 890, 3072, 68, 13439, 83, 7590, 7272, 83, 10, 15027, 272, 3851, 63, 67, 2075, 63, 9427, 275, 295, 14, 2014, 8, 82, 3212, 83, 7590, 3776, 2075, 60, 66, 60, 83, 11, 2229, 48, 28, 81, 2075, 63, 1391, 3072, 87, 13439, 83, 7590, 7023, 83, 30957, 48, 28, 1144, 63, 890, 3072, 68, 13439, 83, 7590, 7272, 83, 10, 15027, 339, 3851, 63, 81, 71, 275, 295, 14, 2014, 8, 82, 3212, 83, 10, 1332, 60, 87, 11, 6113, 87, 7896, 7528, 6697, 2862, 27147, 83, 7590, 29, 3342, 60, 83, 30957, 48, 28, 1532, 63, 354, 3072, 87, 13439, 83, 7590, 2961, 83, 30957, 48, 28, 1144, 63, 890, 13661, 6697, 25105, 83, 7590, 2862, 83, 10, 15027, 272, 3851, 63, 81, 2075, 63, 1273, 275, 295, 14, 2014, 8, 82, 2, 17140, 2862, 1332, 6697, 2862, 23907, 2075, 60, 66, 60, 83, 5830, 6697, 2862, 5130, 6697, 6320, 272, 3851, 63, 19116, 275, 295, 14, 2014, 8, 82, 3212, 83, 30957, 48, 28, 1532, 63, 3292, 30, 2961, 87, 11, 6113, 87, 7896, 7528, 6697, 2862, 27147, 83, 7590, 29, 3342, 60, 83, 22588, 23907, 71, 63, 1352, 305, 56, 92, 81, 71, 63, 1352, 305, 58, 60, 66, 2862, 83, 7590, 2961, 83, 30957, 48, 28, 1144, 63, 890, 13661, 6697, 25105, 83, 7590, 2862, 83, 10, 15027, 272, 3851, 63, 973, 275, 295, 14, 2014, 8, 82, 3212, 83, 22588, 66, 1647, 92, 578, 60, 66, 2862, 83, 20900, 66, 973, 60, 66, 2862, 83, 7590, 1332, 6697, 2862, 2862, 83, 22588, 91, 3342, 60, 83, 10, 531, 272, 3851, 63, 3349, 275, 295, 14, 2014, 8, 82, 3212, 83, 10, 501, 306, 501, 306, 17140, 9, 306, 501, 306, 501, 60, 83, 10, 531, 339, 17863, 63, 354, 275, 295, 14, 954, 2258, 14, 81, 9188, 4, 1673, 63, 81, 11374, 14, 27927, 297, 5252, 9, 272, 17863, 275, 1551, 8, 30762, 63, 354, 2584, 87, 358, 339, 17863, 14, 952, 7863, 2613, 28, 32011, 14, 72, 3072, 78, 358, 339, 327, 525, 14498, 425, 3423, 272, 367, 1894, 315, 1894, 71, 2335, 63, 17, 26, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 11224, 870, 70, 15587, 435, 3237, 5866, 59, 81, 61, 435, 7, 450, 83, 1103, 78, 401, 65, 2736, 27958, 78, 7, 267, 17863, 14, 952, 8, 70, 495, 9, 339, 17863, 14, 952, 2258, 78, 358, 339, 367, 1894, 315, 1894, 71, 2335, 63, 17, 65, 26, 327, 51, 7406, 275, 428, 62, 19, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 11224, 870, 70, 480, 51, 450, 83, 1103, 78, 401, 65, 2736, 870, 70, 480, 51, 450, 83, 1103, 78, 401, 65, 2736, 870, 70, 480, 51, 450, 83, 1103, 78, 401, 65, 2736, 27958, 78, 7, 267, 17863, 14, 952, 8, 70, 495, 9, 339, 17863, 14, 952, 2258, 78, 358, 2378, 367, 1894, 315, 1894, 71, 2335, 63, 18, 26, 327, 35, 4609, 9265, 445, 56, 334, 1375, 12, 2785, 9, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 282, 12, 1495, 10, 330, 11224, 870, 70, 480, 6828, 3237, 5866, 59, 81, 28012, 450, 83, 8719, 83, 1103, 78, 401, 65, 12, 66, 2736, 27958, 78, 7, 267, 17863, 14, 952, 8, 70, 495, 9, 339, 17863, 14, 952, 2258, 78, 358, 339, 367, 1894, 315, 1894, 71, 2335, 63, 19, 26, 267, 2727, 9656, 985, 275, 283, 81, 71, 20013, 81, 267, 289, 495, 275, 283, 1647, 6681, 3615, 9656, 985, 4786, 8, 1560, 10, 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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 ]
JonatanAntoni/CMSIS_5
CMSIS/DSP/PythonWrapper/setup.py
2
5357
from distutils.core import setup, Extension import glob import numpy import config import sys import os from config import ROOT import re includes = [os.path.join(ROOT,"Include"),os.path.join(ROOT,"PrivateInclude"),os.path.join("cmsisdsp_pkg","src")] if sys.platform == 'win32': cflags = ["-DWIN",config.cflags,"-DUNALIGNED_SUPPORT_DISABLE"] else: cflags = ["-Wno-attributes","-Wno-unused-function","-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags,"-D__GNUC_PYTHON__"] transform = glob.glob(os.path.join(ROOT,"Source","TransformFunctions","*.c")) #transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_dct4_init_q15.c")) #transform.remove(os.path.join(ROOT,"Source","TransformFunctions","arm_rfft_init_q15.c")) transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctions.c")) transform.remove(os.path.join(ROOT,"Source","TransformFunctions","TransformFunctionsF16.c")) support = glob.glob(os.path.join(ROOT,"Source","SupportFunctions","*.c")) support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctions.c")) support.remove(os.path.join(ROOT,"Source","SupportFunctions","SupportFunctionsF16.c")) fastmath = glob.glob(os.path.join(ROOT,"Source","FastMathFunctions","*.c")) fastmath.remove(os.path.join(ROOT,"Source","FastMathFunctions","FastMathFunctions.c")) filtering = glob.glob(os.path.join(ROOT,"Source","FilteringFunctions","*.c")) filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctions.c")) filtering.remove(os.path.join(ROOT,"Source","FilteringFunctions","FilteringFunctionsF16.c")) matrix = glob.glob(os.path.join(ROOT,"Source","MatrixFunctions","*.c")) matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctions.c")) matrix.remove(os.path.join(ROOT,"Source","MatrixFunctions","MatrixFunctionsF16.c")) statistics = glob.glob(os.path.join(ROOT,"Source","StatisticsFunctions","*.c")) statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctions.c")) statistics.remove(os.path.join(ROOT,"Source","StatisticsFunctions","StatisticsFunctionsF16.c")) complexf = glob.glob(os.path.join(ROOT,"Source","ComplexMathFunctions","*.c")) complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctions.c")) complexf.remove(os.path.join(ROOT,"Source","ComplexMathFunctions","ComplexMathFunctionsF16.c")) basic = glob.glob(os.path.join(ROOT,"Source","BasicMathFunctions","*.c")) basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctions.c")) basic.remove(os.path.join(ROOT,"Source","BasicMathFunctions","BasicMathFunctionsF16.c")) controller = glob.glob(os.path.join(ROOT,"Source","ControllerFunctions","*.c")) controller.remove(os.path.join(ROOT,"Source","ControllerFunctions","ControllerFunctions.c")) common = glob.glob(os.path.join(ROOT,"Source","CommonTables","*.c")) common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTables.c")) common.remove(os.path.join(ROOT,"Source","CommonTables","CommonTablesF16.c")) interpolation = glob.glob(os.path.join(ROOT,"Source","InterpolationFunctions","*.c")) interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctions.c")) interpolation.remove(os.path.join(ROOT,"Source","InterpolationFunctions","InterpolationFunctionsF16.c")) quaternion = glob.glob(os.path.join(ROOT,"Source","QuaternionMathFunctions","*.c")) quaternion.remove(os.path.join(ROOT,"Source","QuaternionMathFunctions","QuaternionMathFunctions.c")) #distance = glob.glob(os.path.join(ROOT,"Source","DistanceFunctions","*.c")) #distance.remove(os.path.join(ROOT,"Source","DistanceFunctions","DistanceFunctions.c")) #modulesrc = glob.glob(os.path.join("cmsisdsp_pkg","src","*.c")) modulesrc = [] modulesrc.append(os.path.join("cmsisdsp_pkg","src","cmsismodule.c")) allsrcs = support + fastmath + filtering + matrix + statistics + complexf + basic allsrcs = allsrcs + controller + transform + modulesrc + common+ interpolation allsrcs = allsrcs + quaternion def notf16(number): if re.search(r'f16',number): return(False) if re.search(r'F16',number): return(False) return(True) # If there are too many files, the linker command is failing on Windows. # So f16 functions are removed since they are not currently available in the wrapper. # A next version will have to structure this wrapper more cleanly so that the # build can work even with more functions srcs = list(filter(notf16, allsrcs)) module1 = Extension(config.extensionName, sources = (srcs ) , include_dirs = includes + [numpy.get_include()], #extra_compile_args = ["-Wno-unused-variable","-Wno-implicit-function-declaration",config.cflags] extra_compile_args = cflags ) setup (name = config.setupName, version = '1.0.0', description = config.setupDescription, ext_modules = [module1], author = 'Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.', url="https://github.com/ARM-software/CMSIS_5", classifiers=[ "Programming Language :: Python", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ])
apache-2.0
[ 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 646, 5739, 199, 646, 2680, 199, 646, 1101, 199, 646, 984, 199, 646, 747, 199, 504, 1101, 492, 16547, 199, 646, 295, 199, 199, 9441, 275, 359, 736, 14, 515, 14, 904, 8, 5441, 4589, 7826, 1288, 736, 14, 515, 14, 904, 8, 5441, 4589, 12185, 7826, 1288, 736, 14, 515, 14, 904, 480, 4400, 2316, 68, 681, 63, 4600, 2266, 2164, 11323, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 523, 13426, 275, 16984, 36, 7941, 401, 888, 14, 14002, 4589, 13, 36, 1734, 15255, 1149, 63, 10640, 63, 13052, 937, 221, 199, 2836, 26, 523, 13426, 275, 16984, 55, 889, 13, 2987, 2266, 13, 55, 889, 13, 8618, 13, 1593, 2266, 13, 55, 889, 13, 8618, 13, 1975, 2266, 13, 55, 889, 13, 11886, 13, 1593, 13, 15477, 401, 888, 14, 14002, 4589, 13, 36, 363, 17732, 35, 63, 11720, 363, 937, 199, 199, 4711, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 4856, 67, 2237, 199, 3, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 5362, 63, 20660, 20, 63, 826, 63, 81, 1046, 14, 67, 2237, 199, 3, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 5362, 63, 82, 9996, 63, 826, 63, 81, 1046, 14, 67, 2237, 199, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 6939, 13967, 14, 67, 2237, 199, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 6939, 13967, 38, 975, 14, 67, 2237, 199, 199, 4058, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 11532, 13967, 2266, 4856, 67, 2237, 199, 4058, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 11532, 13967, 2266, 11532, 13967, 14, 67, 2237, 199, 4058, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 11532, 13967, 2266, 11532, 13967, 38, 975, 14, 67, 2237, 199, 199, 7015, 3442, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 16976, 18568, 13967, 2266, 4856, 67, 2237, 199, 7015, 3442, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 16976, 18568, 13967, 2266, 16976, 18568, 13967, 14, 67, 2237, 199, 199, 24133, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 4131, 316, 13967, 2266, 4856, 67, 2237, 199, 24133, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 4131, 316, 13967, 2266, 4131, 316, 13967, 14, 67, 2237, 199, 24133, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 4131, 316, 13967, 2266, 4131, 316, 13967, 38, 975, 14, 67, 2237, 199, 199, 3642, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6443, 13967, 2266, 4856, 67, 2237, 199, 3642, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6443, 13967, 2266, 6443, 13967, 14, 67, 2237, 199, 3642, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6443, 13967, 2266, 6443, 13967, 38, 975, 14, 67, 2237, 199, 199, 13724, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 20750, 13967, 2266, 4856, 67, 2237, 199, 13724, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 20750, 13967, 2266, 20750, 13967, 14, 67, 2237, 199, 13724, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 20750, 13967, 2266, 20750, 13967, 38, 975, 14, 67, 2237, 199, 199, 2731, 1949, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 14500, 18568, 13967, 2266, 4856, 67, 2237, 199, 2731, 1949, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 14500, 18568, 13967, 2266, 14500, 18568, 13967, 14, 67, 2237, 199, 2731, 1949, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 14500, 18568, 13967, 2266, 14500, 18568, 13967, 38, 975, 14, 67, 2237, 199, 199, 4316, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6845, 18568, 13967, 2266, 4856, 67, 2237, 199, 4316, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6845, 18568, 13967, 2266, 6845, 18568, 13967, 14, 67, 2237, 199, 4316, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6845, 18568, 13967, 2266, 6845, 18568, 13967, 38, 975, 14, 67, 2237, 199, 199, 5538, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7506, 13967, 2266, 4856, 67, 2237, 199, 5538, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7506, 13967, 2266, 7506, 13967, 14, 67, 2237, 199, 199, 2330, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7844, 18845, 2266, 4856, 67, 2237, 199, 2330, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7844, 18845, 2266, 7844, 18845, 14, 67, 2237, 199, 2330, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7844, 18845, 2266, 7844, 18845, 38, 975, 14, 67, 2237, 199, 199, 21080, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 32653, 13967, 2266, 4856, 67, 2237, 199, 21080, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 32653, 13967, 2266, 32653, 13967, 14, 67, 2237, 199, 21080, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 32653, 13967, 2266, 32653, 13967, 38, 975, 14, 67, 2237, 199, 199, 392, 28945, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 2371, 28945, 18568, 13967, 2266, 4856, 67, 2237, 199, 392, 28945, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589 ]
[ 7065, 14, 1018, 492, 3272, 12, 13282, 199, 646, 5739, 199, 646, 2680, 199, 646, 1101, 199, 646, 984, 199, 646, 747, 199, 504, 1101, 492, 16547, 199, 646, 295, 199, 199, 9441, 275, 359, 736, 14, 515, 14, 904, 8, 5441, 4589, 7826, 1288, 736, 14, 515, 14, 904, 8, 5441, 4589, 12185, 7826, 1288, 736, 14, 515, 14, 904, 480, 4400, 2316, 68, 681, 63, 4600, 2266, 2164, 11323, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 523, 13426, 275, 16984, 36, 7941, 401, 888, 14, 14002, 4589, 13, 36, 1734, 15255, 1149, 63, 10640, 63, 13052, 937, 221, 199, 2836, 26, 523, 13426, 275, 16984, 55, 889, 13, 2987, 2266, 13, 55, 889, 13, 8618, 13, 1593, 2266, 13, 55, 889, 13, 8618, 13, 1975, 2266, 13, 55, 889, 13, 11886, 13, 1593, 13, 15477, 401, 888, 14, 14002, 4589, 13, 36, 363, 17732, 35, 63, 11720, 363, 937, 199, 199, 4711, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 4856, 67, 2237, 199, 3, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 5362, 63, 20660, 20, 63, 826, 63, 81, 1046, 14, 67, 2237, 199, 3, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 5362, 63, 82, 9996, 63, 826, 63, 81, 1046, 14, 67, 2237, 199, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 6939, 13967, 14, 67, 2237, 199, 4711, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6939, 13967, 2266, 6939, 13967, 38, 975, 14, 67, 2237, 199, 199, 4058, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 11532, 13967, 2266, 4856, 67, 2237, 199, 4058, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 11532, 13967, 2266, 11532, 13967, 14, 67, 2237, 199, 4058, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 11532, 13967, 2266, 11532, 13967, 38, 975, 14, 67, 2237, 199, 199, 7015, 3442, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 16976, 18568, 13967, 2266, 4856, 67, 2237, 199, 7015, 3442, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 16976, 18568, 13967, 2266, 16976, 18568, 13967, 14, 67, 2237, 199, 199, 24133, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 4131, 316, 13967, 2266, 4856, 67, 2237, 199, 24133, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 4131, 316, 13967, 2266, 4131, 316, 13967, 14, 67, 2237, 199, 24133, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 4131, 316, 13967, 2266, 4131, 316, 13967, 38, 975, 14, 67, 2237, 199, 199, 3642, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6443, 13967, 2266, 4856, 67, 2237, 199, 3642, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6443, 13967, 2266, 6443, 13967, 14, 67, 2237, 199, 3642, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6443, 13967, 2266, 6443, 13967, 38, 975, 14, 67, 2237, 199, 199, 13724, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 20750, 13967, 2266, 4856, 67, 2237, 199, 13724, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 20750, 13967, 2266, 20750, 13967, 14, 67, 2237, 199, 13724, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 20750, 13967, 2266, 20750, 13967, 38, 975, 14, 67, 2237, 199, 199, 2731, 1949, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 14500, 18568, 13967, 2266, 4856, 67, 2237, 199, 2731, 1949, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 14500, 18568, 13967, 2266, 14500, 18568, 13967, 14, 67, 2237, 199, 2731, 1949, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 14500, 18568, 13967, 2266, 14500, 18568, 13967, 38, 975, 14, 67, 2237, 199, 199, 4316, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6845, 18568, 13967, 2266, 4856, 67, 2237, 199, 4316, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6845, 18568, 13967, 2266, 6845, 18568, 13967, 14, 67, 2237, 199, 4316, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 6845, 18568, 13967, 2266, 6845, 18568, 13967, 38, 975, 14, 67, 2237, 199, 199, 5538, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7506, 13967, 2266, 4856, 67, 2237, 199, 5538, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7506, 13967, 2266, 7506, 13967, 14, 67, 2237, 199, 199, 2330, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7844, 18845, 2266, 4856, 67, 2237, 199, 2330, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7844, 18845, 2266, 7844, 18845, 14, 67, 2237, 199, 2330, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 7844, 18845, 2266, 7844, 18845, 38, 975, 14, 67, 2237, 199, 199, 21080, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 32653, 13967, 2266, 4856, 67, 2237, 199, 21080, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 32653, 13967, 2266, 32653, 13967, 14, 67, 2237, 199, 21080, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 32653, 13967, 2266, 32653, 13967, 38, 975, 14, 67, 2237, 199, 199, 392, 28945, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 2980, 2266, 2371, 28945, 18568, 13967, 2266, 4856, 67, 2237, 199, 392, 28945, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 5441, 4589, 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,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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 ]
dol-sen/portage
pym/portage/emaint/modules/sync/__init__.py
8
1496
# Copyright 2014-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from ....sync import _SUBMODULE_PATH_MAP doc = """Check repos.conf settings and sync repositories.""" __doc__ = doc[:] module_spec = { 'name': 'sync', 'description': doc, 'provides':{ 'sync-module': { 'name': "sync", 'sourcefile': "sync", 'class': "SyncRepos", 'description': doc, 'functions': ['allrepos', 'auto', 'repo'], 'func_desc': { 'repo': { "short": "-r", "long": "--repo", "help": "(sync module only): -r, --repo Sync the specified repo", 'status': "Syncing %s", 'action': 'store', 'func': 'repo', }, 'allrepos': { "short": "-A", "long": "--allrepos", "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined", 'status': "Syncing %s", 'action': 'store_true', 'dest': 'allrepos', 'func': 'all_repos', }, 'auto': { "short": "-a", "long": "--auto", "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only", 'status': "Syncing %s", 'action': 'store_true', 'dest': 'auto', 'func': 'auto_sync', }, }, 'opt_desc': { 'sync-submodule': { "long": "--sync-submodule", "help": ("(sync module only): Restrict sync " "to the specified submodule(s)"), "choices": tuple(_SUBMODULE_PATH_MAP), "action": "append", "dest": "sync_submodule", }, } } } }
gpl-2.0
[ 3, 1898, 6927, 13, 7806, 18870, 7354, 2752, 199, 3, 17484, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 373, 18, 199, 199, 504, 29222, 5186, 492, 485, 6348, 10001, 63, 3243, 63, 5443, 199, 199, 1301, 275, 408, 1799, 20416, 14, 2190, 2202, 436, 7604, 23737, 1041, 199, 363, 1301, 363, 275, 1382, 5873, 199, 199, 578, 63, 1650, 275, 469, 199, 198, 7, 354, 356, 283, 5186, 297, 199, 198, 5121, 397, 4802, 356, 1382, 12, 199, 198, 7, 20121, 356, 91, 507, 198, 1159, 1870, 13, 578, 356, 469, 686, 198, 7, 354, 356, 298, 5186, 401, 686, 198, 1159, 616, 493, 356, 298, 5186, 401, 686, 198, 7, 533, 356, 298, 10878, 497, 1712, 401, 686, 198, 5121, 397, 4802, 356, 1382, 12, 686, 198, 7, 5777, 356, 788, 452, 11857, 297, 283, 2495, 297, 283, 3417, 995, 686, 198, 7, 1532, 63, 3257, 356, 469, 1585, 198, 3984, 555, 356, 469, 1871, 198, 2, 3612, 582, 3905, 82, 401, 298, 2809, 582, 4320, 3417, 401, 1871, 198, 2, 3437, 582, 7340, 5186, 859, 1454, 304, 446, 82, 12, 1553, 3417, 221, 22407, 314, 2013, 3831, 401, 1871, 198, 1159, 84, 896, 356, 298, 10878, 316, 450, 83, 401, 1871, 198, 7, 1287, 356, 283, 1617, 297, 1871, 198, 7, 1532, 356, 283, 3417, 297, 1871, 198, 1386, 1585, 198, 7, 452, 11857, 356, 469, 1871, 198, 2, 3612, 582, 3905, 33, 401, 298, 2809, 582, 4320, 452, 11857, 401, 1871, 198, 2, 3437, 582, 7340, 5186, 859, 1454, 304, 446, 33, 12, 1553, 452, 11857, 221, 22407, 1006, 20416, 626, 1172, 282, 7604, 13, 633, 3247, 401, 1871, 198, 1159, 84, 896, 356, 298, 10878, 316, 450, 83, 401, 1871, 198, 7, 1287, 356, 283, 1617, 63, 2052, 297, 1871, 198, 5121, 597, 356, 283, 452, 11857, 297, 1871, 198, 7, 1532, 356, 283, 452, 63, 11857, 297, 1871, 198, 1386, 1585, 198, 7, 2495, 356, 469, 1871, 198, 2, 3612, 582, 3905, 65, 401, 298, 2809, 582, 4320, 2495, 401, 1871, 198, 2, 3437, 582, 7340, 5186, 859, 1454, 304, 446, 65, 12, 1553, 2495, 221, 22407, 2599, 13, 5186, 5223, 20416, 1454, 401, 1871, 198, 1159, 84, 896, 356, 298, 10878, 316, 450, 83, 401, 1871, 198, 7, 1287, 356, 283, 1617, 63, 2052, 297, 1871, 198, 5121, 597, 356, 283, 2495, 297, 1871, 198, 7, 1532, 356, 283, 2495, 63, 5186, 297, 1871, 198, 1386, 1585, 198, 1386, 686, 198, 7, 2992, 63, 3257, 356, 469, 1585, 198, 1159, 1870, 13, 16229, 356, 469, 1871, 198, 2, 2809, 582, 4320, 5186, 13, 16229, 401, 1871, 198, 2, 3437, 582, 1689, 8, 5186, 859, 1454, 304, 799, 4768, 7604, 298, 4671, 198, 2, 475, 314, 2013, 22988, 8, 83, 13185, 1871, 198, 2, 4577, 582, 2008, 1547, 6348, 10001, 63, 3243, 63, 5443, 395, 1871, 198, 2, 1287, 582, 298, 740, 401, 1871, 198, 2, 2614, 582, 298, 5186, 63, 16229, 401, 1871, 198, 1386, 1585, 198, 93, 686, 198, 93, 507, 198, 93, 199, 198, 93, 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 ]
[ 1898, 6927, 13, 7806, 18870, 7354, 2752, 199, 3, 17484, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 373, 18, 199, 199, 504, 29222, 5186, 492, 485, 6348, 10001, 63, 3243, 63, 5443, 199, 199, 1301, 275, 408, 1799, 20416, 14, 2190, 2202, 436, 7604, 23737, 1041, 199, 363, 1301, 363, 275, 1382, 5873, 199, 199, 578, 63, 1650, 275, 469, 199, 198, 7, 354, 356, 283, 5186, 297, 199, 198, 5121, 397, 4802, 356, 1382, 12, 199, 198, 7, 20121, 356, 91, 507, 198, 1159, 1870, 13, 578, 356, 469, 686, 198, 7, 354, 356, 298, 5186, 401, 686, 198, 1159, 616, 493, 356, 298, 5186, 401, 686, 198, 7, 533, 356, 298, 10878, 497, 1712, 401, 686, 198, 5121, 397, 4802, 356, 1382, 12, 686, 198, 7, 5777, 356, 788, 452, 11857, 297, 283, 2495, 297, 283, 3417, 995, 686, 198, 7, 1532, 63, 3257, 356, 469, 1585, 198, 3984, 555, 356, 469, 1871, 198, 2, 3612, 582, 3905, 82, 401, 298, 2809, 582, 4320, 3417, 401, 1871, 198, 2, 3437, 582, 7340, 5186, 859, 1454, 304, 446, 82, 12, 1553, 3417, 221, 22407, 314, 2013, 3831, 401, 1871, 198, 1159, 84, 896, 356, 298, 10878, 316, 450, 83, 401, 1871, 198, 7, 1287, 356, 283, 1617, 297, 1871, 198, 7, 1532, 356, 283, 3417, 297, 1871, 198, 1386, 1585, 198, 7, 452, 11857, 356, 469, 1871, 198, 2, 3612, 582, 3905, 33, 401, 298, 2809, 582, 4320, 452, 11857, 401, 1871, 198, 2, 3437, 582, 7340, 5186, 859, 1454, 304, 446, 33, 12, 1553, 452, 11857, 221, 22407, 1006, 20416, 626, 1172, 282, 7604, 13, 633, 3247, 401, 1871, 198, 1159, 84, 896, 356, 298, 10878, 316, 450, 83, 401, 1871, 198, 7, 1287, 356, 283, 1617, 63, 2052, 297, 1871, 198, 5121, 597, 356, 283, 452, 11857, 297, 1871, 198, 7, 1532, 356, 283, 452, 63, 11857, 297, 1871, 198, 1386, 1585, 198, 7, 2495, 356, 469, 1871, 198, 2, 3612, 582, 3905, 65, 401, 298, 2809, 582, 4320, 2495, 401, 1871, 198, 2, 3437, 582, 7340, 5186, 859, 1454, 304, 446, 65, 12, 1553, 2495, 221, 22407, 2599, 13, 5186, 5223, 20416, 1454, 401, 1871, 198, 1159, 84, 896, 356, 298, 10878, 316, 450, 83, 401, 1871, 198, 7, 1287, 356, 283, 1617, 63, 2052, 297, 1871, 198, 5121, 597, 356, 283, 2495, 297, 1871, 198, 7, 1532, 356, 283, 2495, 63, 5186, 297, 1871, 198, 1386, 1585, 198, 1386, 686, 198, 7, 2992, 63, 3257, 356, 469, 1585, 198, 1159, 1870, 13, 16229, 356, 469, 1871, 198, 2, 2809, 582, 4320, 5186, 13, 16229, 401, 1871, 198, 2, 3437, 582, 1689, 8, 5186, 859, 1454, 304, 799, 4768, 7604, 298, 4671, 198, 2, 475, 314, 2013, 22988, 8, 83, 13185, 1871, 198, 2, 4577, 582, 2008, 1547, 6348, 10001, 63, 3243, 63, 5443, 395, 1871, 198, 2, 1287, 582, 298, 740, 401, 1871, 198, 2, 2614, 582, 298, 5186, 63, 16229, 401, 1871, 198, 1386, 1585, 198, 93, 686, 198, 93, 507, 198, 93, 199, 198, 93, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
redq81/redq81.github.io
test/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py
1355
44604
# 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. """cmake output module This module is under development and should be considered experimental. This module produces cmake (2.8.8+) input as its output. One CMakeLists.txt is created for each configuration. This module's original purpose was to support editing in IDEs like KDevelop which use CMake for project management. It is also possible to use CMake to generate projects for other IDEs such as eclipse cdt and code::blocks. QtCreator will convert the CMakeLists.txt to a code::blocks cbp for the editor to read, but build using CMake. As a result QtCreator editor is unaware of compiler defines. The generated CMakeLists.txt can also be used to build on Linux. There is currently no support for building on platforms other than Linux. The generated CMakeLists.txt should properly compile all projects. However, there is a mismatch between gyp and cmake with regard to linking. All attempts are made to work around this, but CMake sometimes sees -Wl,--start-group as a library and incorrectly repeats it. As a result the output of this generator should not be relied on for building. When using with kdevelop, use version 4.4+. Previous versions of kdevelop will not be able to find the header file directories described in the generated CMakeLists.txt file. """ import multiprocessing import os import signal import string import subprocess import gyp.common generator_default_variables = { 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'SHARED_LIB_PREFIX': 'lib', 'SHARED_LIB_SUFFIX': '.so', 'SHARED_LIB_DIR': '${builddir}/lib.${TOOLSET}', 'LIB_DIR': '${obj}.${TOOLSET}', 'INTERMEDIATE_DIR': '${obj}.${TOOLSET}/${TARGET}/geni', 'SHARED_INTERMEDIATE_DIR': '${obj}/gen', 'PRODUCT_DIR': '${builddir}', 'RULE_INPUT_PATH': '${RULE_INPUT_PATH}', 'RULE_INPUT_DIRNAME': '${RULE_INPUT_DIRNAME}', 'RULE_INPUT_NAME': '${RULE_INPUT_NAME}', 'RULE_INPUT_ROOT': '${RULE_INPUT_ROOT}', 'RULE_INPUT_EXT': '${RULE_INPUT_EXT}', 'CONFIGURATION_NAME': '${configuration}', } FULL_PATH_VARS = ('${CMAKE_CURRENT_LIST_DIR}', '${builddir}', '${obj}') generator_supports_multiple_toolsets = True generator_wants_static_library_dependencies_adjusted = True COMPILABLE_EXTENSIONS = { '.c': 'cc', '.cc': 'cxx', '.cpp': 'cxx', '.cxx': 'cxx', '.s': 's', # cc '.S': 's', # cc } def RemovePrefix(a, prefix): """Returns 'a' without 'prefix' if it starts with 'prefix'.""" return a[len(prefix):] if a.startswith(prefix) else a def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" default_variables.setdefault('OS', gyp.common.GetFlavor(params)) def Compilable(filename): """Return true if the file is compilable (should be in OBJS).""" return any(filename.endswith(e) for e in COMPILABLE_EXTENSIONS) def Linkable(filename): """Return true if the file is linkable (should be on the link line).""" return filename.endswith('.o') def NormjoinPathForceCMakeSource(base_path, rel_path): """Resolves rel_path against base_path and returns the result. If rel_path is an absolute path it is returned unchanged. Otherwise it is resolved against base_path and normalized. If the result is a relative path, it is forced to be relative to the CMakeLists.txt. """ if os.path.isabs(rel_path): return rel_path if any([rel_path.startswith(var) for var in FULL_PATH_VARS]): return rel_path # TODO: do we need to check base_path for absolute variables as well? return os.path.join('${CMAKE_CURRENT_LIST_DIR}', os.path.normpath(os.path.join(base_path, rel_path))) def NormjoinPath(base_path, rel_path): """Resolves rel_path against base_path and returns the result. TODO: what is this really used for? If rel_path begins with '$' it is returned unchanged. Otherwise it is resolved against base_path if relative, then normalized. """ if rel_path.startswith('$') and not rel_path.startswith('${configuration}'): return rel_path return os.path.normpath(os.path.join(base_path, rel_path)) def CMakeStringEscape(a): """Escapes the string 'a' for use inside a CMake string. This means escaping '\' otherwise it may be seen as modifying the next character '"' otherwise it will end the string ';' otherwise the string becomes a list The following do not need to be escaped '#' when the lexer is in string state, this does not start a comment The following are yet unknown '$' generator variables (like ${obj}) must not be escaped, but text $ should be escaped what is wanted is to know which $ come from generator variables """ return a.replace('\\', '\\\\').replace(';', '\\;').replace('"', '\\"') def SetFileProperty(output, source_name, property_name, values, sep): """Given a set of source file, sets the given property on them.""" output.write('set_source_files_properties(') output.write(source_name) output.write(' PROPERTIES ') output.write(property_name) output.write(' "') for value in values: output.write(CMakeStringEscape(value)) output.write(sep) output.write('")\n') def SetFilesProperty(output, variable, property_name, values, sep): """Given a set of source files, sets the given property on them.""" output.write('set_source_files_properties(') WriteVariable(output, variable) output.write(' PROPERTIES ') output.write(property_name) output.write(' "') for value in values: output.write(CMakeStringEscape(value)) output.write(sep) output.write('")\n') def SetTargetProperty(output, target_name, property_name, values, sep=''): """Given a target, sets the given property.""" output.write('set_target_properties(') output.write(target_name) output.write(' PROPERTIES ') output.write(property_name) output.write(' "') for value in values: output.write(CMakeStringEscape(value)) output.write(sep) output.write('")\n') def SetVariable(output, variable_name, value): """Sets a CMake variable.""" output.write('set(') output.write(variable_name) output.write(' "') output.write(CMakeStringEscape(value)) output.write('")\n') def SetVariableList(output, variable_name, values): """Sets a CMake variable to a list.""" if not values: return SetVariable(output, variable_name, "") if len(values) == 1: return SetVariable(output, variable_name, values[0]) output.write('list(APPEND ') output.write(variable_name) output.write('\n "') output.write('"\n "'.join([CMakeStringEscape(value) for value in values])) output.write('")\n') def UnsetVariable(output, variable_name): """Unsets a CMake variable.""" output.write('unset(') output.write(variable_name) output.write(')\n') def WriteVariable(output, variable_name, prepend=None): if prepend: output.write(prepend) output.write('${') output.write(variable_name) output.write('}') class CMakeTargetType(object): def __init__(self, command, modifier, property_modifier): self.command = command self.modifier = modifier self.property_modifier = property_modifier cmake_target_type_from_gyp_target_type = { 'executable': CMakeTargetType('add_executable', None, 'RUNTIME'), 'static_library': CMakeTargetType('add_library', 'STATIC', 'ARCHIVE'), 'shared_library': CMakeTargetType('add_library', 'SHARED', 'LIBRARY'), 'loadable_module': CMakeTargetType('add_library', 'MODULE', 'LIBRARY'), 'none': CMakeTargetType('add_custom_target', 'SOURCES', None), } def StringToCMakeTargetName(a): """Converts the given string 'a' to a valid CMake target name. All invalid characters are replaced by '_'. Invalid for cmake: ' ', '/', '(', ')', '"' Invalid for make: ':' Invalid for unknown reasons but cause failures: '.' """ return a.translate(string.maketrans(' /():."', '_______')) def WriteActions(target_name, actions, extra_sources, extra_deps, path_to_gyp, output): """Write CMake for the 'actions' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with generated source files. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp file in which the target being generated is defined. """ for action in actions: action_name = StringToCMakeTargetName(action['action_name']) action_target_name = '%s__%s' % (target_name, action_name) inputs = action['inputs'] inputs_name = action_target_name + '__input' SetVariableList(output, inputs_name, [NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs]) outputs = action['outputs'] cmake_outputs = [NormjoinPathForceCMakeSource(path_to_gyp, out) for out in outputs] outputs_name = action_target_name + '__output' SetVariableList(output, outputs_name, cmake_outputs) # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir) if int(action.get('process_outputs_as_sources', False)): extra_sources.extend(zip(cmake_outputs, outputs)) # add_custom_command output.write('add_custom_command(OUTPUT ') WriteVariable(output, outputs_name) output.write('\n') if len(dirs) > 0: for directory in dirs: output.write(' COMMAND ${CMAKE_COMMAND} -E make_directory ') output.write(directory) output.write('\n') output.write(' COMMAND ') output.write(gyp.common.EncodePOSIXShellList(action['action'])) output.write('\n') output.write(' DEPENDS ') WriteVariable(output, inputs_name) output.write('\n') output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') output.write(path_to_gyp) output.write('\n') output.write(' COMMENT ') if 'message' in action: output.write(action['message']) else: output.write(action_target_name) output.write('\n') output.write(' VERBATIM\n') output.write(')\n') # add_custom_target output.write('add_custom_target(') output.write(action_target_name) output.write('\n DEPENDS ') WriteVariable(output, outputs_name) output.write('\n SOURCES ') WriteVariable(output, inputs_name) output.write('\n)\n') extra_deps.append(action_target_name) def NormjoinRulePathForceCMakeSource(base_path, rel_path, rule_source): if rel_path.startswith(("${RULE_INPUT_PATH}","${RULE_INPUT_DIRNAME}")): if any([rule_source.startswith(var) for var in FULL_PATH_VARS]): return rel_path return NormjoinPathForceCMakeSource(base_path, rel_path) def WriteRules(target_name, rules, extra_sources, extra_deps, path_to_gyp, output): """Write CMake for the 'rules' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with generated source files. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp file in which the target being generated is defined. """ for rule in rules: rule_name = StringToCMakeTargetName(target_name + '__' + rule['rule_name']) inputs = rule.get('inputs', []) inputs_name = rule_name + '__input' SetVariableList(output, inputs_name, [NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs]) outputs = rule['outputs'] var_outputs = [] for count, rule_source in enumerate(rule.get('rule_sources', [])): action_name = rule_name + '_' + str(count) rule_source_dirname, rule_source_basename = os.path.split(rule_source) rule_source_root, rule_source_ext = os.path.splitext(rule_source_basename) SetVariable(output, 'RULE_INPUT_PATH', rule_source) SetVariable(output, 'RULE_INPUT_DIRNAME', rule_source_dirname) SetVariable(output, 'RULE_INPUT_NAME', rule_source_basename) SetVariable(output, 'RULE_INPUT_ROOT', rule_source_root) SetVariable(output, 'RULE_INPUT_EXT', rule_source_ext) # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir) # Create variables for the output, as 'local' variable will be unset. these_outputs = [] for output_index, out in enumerate(outputs): output_name = action_name + '_' + str(output_index) SetVariable(output, output_name, NormjoinRulePathForceCMakeSource(path_to_gyp, out, rule_source)) if int(rule.get('process_outputs_as_sources', False)): extra_sources.append(('${' + output_name + '}', out)) these_outputs.append('${' + output_name + '}') var_outputs.append('${' + output_name + '}') # add_custom_command output.write('add_custom_command(OUTPUT\n') for out in these_outputs: output.write(' ') output.write(out) output.write('\n') for directory in dirs: output.write(' COMMAND ${CMAKE_COMMAND} -E make_directory ') output.write(directory) output.write('\n') output.write(' COMMAND ') output.write(gyp.common.EncodePOSIXShellList(rule['action'])) output.write('\n') output.write(' DEPENDS ') WriteVariable(output, inputs_name) output.write(' ') output.write(NormjoinPath(path_to_gyp, rule_source)) output.write('\n') # CMAKE_CURRENT_LIST_DIR is where the CMakeLists.txt lives. # The cwd is the current build directory. output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') output.write(path_to_gyp) output.write('\n') output.write(' COMMENT ') if 'message' in rule: output.write(rule['message']) else: output.write(action_name) output.write('\n') output.write(' VERBATIM\n') output.write(')\n') UnsetVariable(output, 'RULE_INPUT_PATH') UnsetVariable(output, 'RULE_INPUT_DIRNAME') UnsetVariable(output, 'RULE_INPUT_NAME') UnsetVariable(output, 'RULE_INPUT_ROOT') UnsetVariable(output, 'RULE_INPUT_EXT') # add_custom_target output.write('add_custom_target(') output.write(rule_name) output.write(' DEPENDS\n') for out in var_outputs: output.write(' ') output.write(out) output.write('\n') output.write('SOURCES ') WriteVariable(output, inputs_name) output.write('\n') for rule_source in rule.get('rule_sources', []): output.write(' ') output.write(NormjoinPath(path_to_gyp, rule_source)) output.write('\n') output.write(')\n') extra_deps.append(rule_name) def WriteCopies(target_name, copies, extra_deps, path_to_gyp, output): """Write CMake for the 'copies' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp file in which the target being generated is defined. """ copy_name = target_name + '__copies' # CMake gets upset with custom targets with OUTPUT which specify no output. have_copies = any(copy['files'] for copy in copies) if not have_copies: output.write('add_custom_target(') output.write(copy_name) output.write(')\n') extra_deps.append(copy_name) return class Copy(object): def __init__(self, ext, command): self.cmake_inputs = [] self.cmake_outputs = [] self.gyp_inputs = [] self.gyp_outputs = [] self.ext = ext self.inputs_name = None self.outputs_name = None self.command = command file_copy = Copy('', 'copy') dir_copy = Copy('_dirs', 'copy_directory') for copy in copies: files = copy['files'] destination = copy['destination'] for src in files: path = os.path.normpath(src) basename = os.path.split(path)[1] dst = os.path.join(destination, basename) copy = file_copy if os.path.basename(src) else dir_copy copy.cmake_inputs.append(NormjoinPathForceCMakeSource(path_to_gyp, src)) copy.cmake_outputs.append(NormjoinPathForceCMakeSource(path_to_gyp, dst)) copy.gyp_inputs.append(src) copy.gyp_outputs.append(dst) for copy in (file_copy, dir_copy): if copy.cmake_inputs: copy.inputs_name = copy_name + '__input' + copy.ext SetVariableList(output, copy.inputs_name, copy.cmake_inputs) copy.outputs_name = copy_name + '__output' + copy.ext SetVariableList(output, copy.outputs_name, copy.cmake_outputs) # add_custom_command output.write('add_custom_command(\n') output.write('OUTPUT') for copy in (file_copy, dir_copy): if copy.outputs_name: WriteVariable(output, copy.outputs_name, ' ') output.write('\n') for copy in (file_copy, dir_copy): for src, dst in zip(copy.gyp_inputs, copy.gyp_outputs): # 'cmake -E copy src dst' will create the 'dst' directory if needed. output.write('COMMAND ${CMAKE_COMMAND} -E %s ' % copy.command) output.write(src) output.write(' ') output.write(dst) output.write("\n") output.write('DEPENDS') for copy in (file_copy, dir_copy): if copy.inputs_name: WriteVariable(output, copy.inputs_name, ' ') output.write('\n') output.write('WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') output.write(path_to_gyp) output.write('\n') output.write('COMMENT Copying for ') output.write(target_name) output.write('\n') output.write('VERBATIM\n') output.write(')\n') # add_custom_target output.write('add_custom_target(') output.write(copy_name) output.write('\n DEPENDS') for copy in (file_copy, dir_copy): if copy.outputs_name: WriteVariable(output, copy.outputs_name, ' ') output.write('\n SOURCES') if file_copy.inputs_name: WriteVariable(output, file_copy.inputs_name, ' ') output.write('\n)\n') extra_deps.append(copy_name) def CreateCMakeTargetBaseName(qualified_target): """This is the name we would like the target to have.""" _, gyp_target_name, gyp_target_toolset = ( gyp.common.ParseQualifiedTarget(qualified_target)) cmake_target_base_name = gyp_target_name if gyp_target_toolset and gyp_target_toolset != 'target': cmake_target_base_name += '_' + gyp_target_toolset return StringToCMakeTargetName(cmake_target_base_name) def CreateCMakeTargetFullName(qualified_target): """An unambiguous name for the target.""" gyp_file, gyp_target_name, gyp_target_toolset = ( gyp.common.ParseQualifiedTarget(qualified_target)) cmake_target_full_name = gyp_file + ':' + gyp_target_name if gyp_target_toolset and gyp_target_toolset != 'target': cmake_target_full_name += '_' + gyp_target_toolset return StringToCMakeTargetName(cmake_target_full_name) class CMakeNamer(object): """Converts Gyp target names into CMake target names. CMake requires that target names be globally unique. One way to ensure this is to fully qualify the names of the targets. Unfortunatly, this ends up with all targets looking like "chrome_chrome_gyp_chrome" instead of just "chrome". If this generator were only interested in building, it would be possible to fully qualify all target names, then create unqualified target names which depend on all qualified targets which should have had that name. This is more or less what the 'make' generator does with aliases. However, one goal of this generator is to create CMake files for use with IDEs, and fully qualified names are not as user friendly. Since target name collision is rare, we do the above only when required. Toolset variants are always qualified from the base, as this is required for building. However, it also makes sense for an IDE, as it is possible for defines to be different. """ def __init__(self, target_list): self.cmake_target_base_names_conficting = set() cmake_target_base_names_seen = set() for qualified_target in target_list: cmake_target_base_name = CreateCMakeTargetBaseName(qualified_target) if cmake_target_base_name not in cmake_target_base_names_seen: cmake_target_base_names_seen.add(cmake_target_base_name) else: self.cmake_target_base_names_conficting.add(cmake_target_base_name) def CreateCMakeTargetName(self, qualified_target): base_name = CreateCMakeTargetBaseName(qualified_target) if base_name in self.cmake_target_base_names_conficting: return CreateCMakeTargetFullName(qualified_target) return base_name def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use, options, generator_flags, all_qualified_targets, output): # The make generator does this always. # TODO: It would be nice to be able to tell CMake all dependencies. circular_libs = generator_flags.get('circular', True) if not generator_flags.get('standalone', False): output.write('\n#') output.write(qualified_target) output.write('\n') gyp_file, _, _ = gyp.common.ParseQualifiedTarget(qualified_target) rel_gyp_file = gyp.common.RelativePath(gyp_file, options.toplevel_dir) rel_gyp_dir = os.path.dirname(rel_gyp_file) # Relative path from build dir to top dir. build_to_top = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir) # Relative path from build dir to gyp dir. build_to_gyp = os.path.join(build_to_top, rel_gyp_dir) path_from_cmakelists_to_gyp = build_to_gyp spec = target_dicts.get(qualified_target, {}) config = spec.get('configurations', {}).get(config_to_use, {}) target_name = spec.get('target_name', '<missing target name>') target_type = spec.get('type', '<missing target type>') target_toolset = spec.get('toolset') cmake_target_type = cmake_target_type_from_gyp_target_type.get(target_type) if cmake_target_type is None: print ('Target %s has unknown target type %s, skipping.' % ( target_name, target_type ) ) return SetVariable(output, 'TARGET', target_name) SetVariable(output, 'TOOLSET', target_toolset) cmake_target_name = namer.CreateCMakeTargetName(qualified_target) extra_sources = [] extra_deps = [] # Actions must come first, since they can generate more OBJs for use below. if 'actions' in spec: WriteActions(cmake_target_name, spec['actions'], extra_sources, extra_deps, path_from_cmakelists_to_gyp, output) # Rules must be early like actions. if 'rules' in spec: WriteRules(cmake_target_name, spec['rules'], extra_sources, extra_deps, path_from_cmakelists_to_gyp, output) # Copies if 'copies' in spec: WriteCopies(cmake_target_name, spec['copies'], extra_deps, path_from_cmakelists_to_gyp, output) # Target and sources srcs = spec.get('sources', []) # Gyp separates the sheep from the goats based on file extensions. # A full separation is done here because of flag handing (see below). s_sources = [] c_sources = [] cxx_sources = [] linkable_sources = [] other_sources = [] for src in srcs: _, ext = os.path.splitext(src) src_type = COMPILABLE_EXTENSIONS.get(ext, None) src_norm_path = NormjoinPath(path_from_cmakelists_to_gyp, src); if src_type == 's': s_sources.append(src_norm_path) elif src_type == 'cc': c_sources.append(src_norm_path) elif src_type == 'cxx': cxx_sources.append(src_norm_path) elif Linkable(ext): linkable_sources.append(src_norm_path) else: other_sources.append(src_norm_path) for extra_source in extra_sources: src, real_source = extra_source _, ext = os.path.splitext(real_source) src_type = COMPILABLE_EXTENSIONS.get(ext, None) if src_type == 's': s_sources.append(src) elif src_type == 'cc': c_sources.append(src) elif src_type == 'cxx': cxx_sources.append(src) elif Linkable(ext): linkable_sources.append(src) else: other_sources.append(src) s_sources_name = None if s_sources: s_sources_name = cmake_target_name + '__asm_srcs' SetVariableList(output, s_sources_name, s_sources) c_sources_name = None if c_sources: c_sources_name = cmake_target_name + '__c_srcs' SetVariableList(output, c_sources_name, c_sources) cxx_sources_name = None if cxx_sources: cxx_sources_name = cmake_target_name + '__cxx_srcs' SetVariableList(output, cxx_sources_name, cxx_sources) linkable_sources_name = None if linkable_sources: linkable_sources_name = cmake_target_name + '__linkable_srcs' SetVariableList(output, linkable_sources_name, linkable_sources) other_sources_name = None if other_sources: other_sources_name = cmake_target_name + '__other_srcs' SetVariableList(output, other_sources_name, other_sources) # CMake gets upset when executable targets provide no sources. # http://www.cmake.org/pipermail/cmake/2010-July/038461.html dummy_sources_name = None has_sources = (s_sources_name or c_sources_name or cxx_sources_name or linkable_sources_name or other_sources_name) if target_type == 'executable' and not has_sources: dummy_sources_name = cmake_target_name + '__dummy_srcs' SetVariable(output, dummy_sources_name, "${obj}.${TOOLSET}/${TARGET}/genc/dummy.c") output.write('if(NOT EXISTS "') WriteVariable(output, dummy_sources_name) output.write('")\n') output.write(' file(WRITE "') WriteVariable(output, dummy_sources_name) output.write('" "")\n') output.write("endif()\n") # CMake is opposed to setting linker directories and considers the practice # of setting linker directories dangerous. Instead, it favors the use of # find_library and passing absolute paths to target_link_libraries. # However, CMake does provide the command link_directories, which adds # link directories to targets defined after it is called. # As a result, link_directories must come before the target definition. # CMake unfortunately has no means of removing entries from LINK_DIRECTORIES. library_dirs = config.get('library_dirs') if library_dirs is not None: output.write('link_directories(') for library_dir in library_dirs: output.write(' ') output.write(NormjoinPath(path_from_cmakelists_to_gyp, library_dir)) output.write('\n') output.write(')\n') output.write(cmake_target_type.command) output.write('(') output.write(cmake_target_name) if cmake_target_type.modifier is not None: output.write(' ') output.write(cmake_target_type.modifier) if s_sources_name: WriteVariable(output, s_sources_name, ' ') if c_sources_name: WriteVariable(output, c_sources_name, ' ') if cxx_sources_name: WriteVariable(output, cxx_sources_name, ' ') if linkable_sources_name: WriteVariable(output, linkable_sources_name, ' ') if other_sources_name: WriteVariable(output, other_sources_name, ' ') if dummy_sources_name: WriteVariable(output, dummy_sources_name, ' ') output.write(')\n') # Let CMake know if the 'all' target should depend on this target. exclude_from_all = ('TRUE' if qualified_target not in all_qualified_targets else 'FALSE') SetTargetProperty(output, cmake_target_name, 'EXCLUDE_FROM_ALL', exclude_from_all) for extra_target_name in extra_deps: SetTargetProperty(output, extra_target_name, 'EXCLUDE_FROM_ALL', exclude_from_all) # Output name and location. if target_type != 'none': # Link as 'C' if there are no other files if not c_sources and not cxx_sources: SetTargetProperty(output, cmake_target_name, 'LINKER_LANGUAGE', ['C']) # Mark uncompiled sources as uncompiled. if other_sources_name: output.write('set_source_files_properties(') WriteVariable(output, other_sources_name, '') output.write(' PROPERTIES HEADER_FILE_ONLY "TRUE")\n') # Mark object sources as linkable. if linkable_sources_name: output.write('set_source_files_properties(') WriteVariable(output, other_sources_name, '') output.write(' PROPERTIES EXTERNAL_OBJECT "TRUE")\n') # Output directory target_output_directory = spec.get('product_dir') if target_output_directory is None: if target_type in ('executable', 'loadable_module'): target_output_directory = generator_default_variables['PRODUCT_DIR'] elif target_type == 'shared_library': target_output_directory = '${builddir}/lib.${TOOLSET}' elif spec.get('standalone_static_library', False): target_output_directory = generator_default_variables['PRODUCT_DIR'] else: base_path = gyp.common.RelativePath(os.path.dirname(gyp_file), options.toplevel_dir) target_output_directory = '${obj}.${TOOLSET}' target_output_directory = ( os.path.join(target_output_directory, base_path)) cmake_target_output_directory = NormjoinPathForceCMakeSource( path_from_cmakelists_to_gyp, target_output_directory) SetTargetProperty(output, cmake_target_name, cmake_target_type.property_modifier + '_OUTPUT_DIRECTORY', cmake_target_output_directory) # Output name default_product_prefix = '' default_product_name = target_name default_product_ext = '' if target_type == 'static_library': static_library_prefix = generator_default_variables['STATIC_LIB_PREFIX'] default_product_name = RemovePrefix(default_product_name, static_library_prefix) default_product_prefix = static_library_prefix default_product_ext = generator_default_variables['STATIC_LIB_SUFFIX'] elif target_type in ('loadable_module', 'shared_library'): shared_library_prefix = generator_default_variables['SHARED_LIB_PREFIX'] default_product_name = RemovePrefix(default_product_name, shared_library_prefix) default_product_prefix = shared_library_prefix default_product_ext = generator_default_variables['SHARED_LIB_SUFFIX'] elif target_type != 'executable': print ('ERROR: What output file should be generated?', 'type', target_type, 'target', target_name) product_prefix = spec.get('product_prefix', default_product_prefix) product_name = spec.get('product_name', default_product_name) product_ext = spec.get('product_extension') if product_ext: product_ext = '.' + product_ext else: product_ext = default_product_ext SetTargetProperty(output, cmake_target_name, 'PREFIX', product_prefix) SetTargetProperty(output, cmake_target_name, cmake_target_type.property_modifier + '_OUTPUT_NAME', product_name) SetTargetProperty(output, cmake_target_name, 'SUFFIX', product_ext) # Make the output of this target referenceable as a source. cmake_target_output_basename = product_prefix + product_name + product_ext cmake_target_output = os.path.join(cmake_target_output_directory, cmake_target_output_basename) SetFileProperty(output, cmake_target_output, 'GENERATED', ['TRUE'], '') # Includes includes = config.get('include_dirs') if includes: # This (target include directories) is what requires CMake 2.8.8 includes_name = cmake_target_name + '__include_dirs' SetVariableList(output, includes_name, [NormjoinPathForceCMakeSource(path_from_cmakelists_to_gyp, include) for include in includes]) output.write('set_property(TARGET ') output.write(cmake_target_name) output.write(' APPEND PROPERTY INCLUDE_DIRECTORIES ') WriteVariable(output, includes_name, '') output.write(')\n') # Defines defines = config.get('defines') if defines is not None: SetTargetProperty(output, cmake_target_name, 'COMPILE_DEFINITIONS', defines, ';') # Compile Flags - http://www.cmake.org/Bug/view.php?id=6493 # CMake currently does not have target C and CXX flags. # So, instead of doing... # cflags_c = config.get('cflags_c') # if cflags_c is not None: # SetTargetProperty(output, cmake_target_name, # 'C_COMPILE_FLAGS', cflags_c, ' ') # cflags_cc = config.get('cflags_cc') # if cflags_cc is not None: # SetTargetProperty(output, cmake_target_name, # 'CXX_COMPILE_FLAGS', cflags_cc, ' ') # Instead we must... cflags = config.get('cflags', []) cflags_c = config.get('cflags_c', []) cflags_cxx = config.get('cflags_cc', []) if (not cflags_c or not c_sources) and (not cflags_cxx or not cxx_sources): SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', cflags, ' ') elif c_sources and not (s_sources or cxx_sources): flags = [] flags.extend(cflags) flags.extend(cflags_c) SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', flags, ' ') elif cxx_sources and not (s_sources or c_sources): flags = [] flags.extend(cflags) flags.extend(cflags_cxx) SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', flags, ' ') else: # TODO: This is broken, one cannot generally set properties on files, # as other targets may require different properties on the same files. if s_sources and cflags: SetFilesProperty(output, s_sources_name, 'COMPILE_FLAGS', cflags, ' ') if c_sources and (cflags or cflags_c): flags = [] flags.extend(cflags) flags.extend(cflags_c) SetFilesProperty(output, c_sources_name, 'COMPILE_FLAGS', flags, ' ') if cxx_sources and (cflags or cflags_cxx): flags = [] flags.extend(cflags) flags.extend(cflags_cxx) SetFilesProperty(output, cxx_sources_name, 'COMPILE_FLAGS', flags, ' ') # Linker flags ldflags = config.get('ldflags') if ldflags is not None: SetTargetProperty(output, cmake_target_name, 'LINK_FLAGS', ldflags, ' ') # Note on Dependencies and Libraries: # CMake wants to handle link order, resolving the link line up front. # Gyp does not retain or enforce specifying enough information to do so. # So do as other gyp generators and use --start-group and --end-group. # Give CMake as little information as possible so that it doesn't mess it up. # Dependencies rawDeps = spec.get('dependencies', []) static_deps = [] shared_deps = [] other_deps = [] for rawDep in rawDeps: dep_cmake_name = namer.CreateCMakeTargetName(rawDep) dep_spec = target_dicts.get(rawDep, {}) dep_target_type = dep_spec.get('type', None) if dep_target_type == 'static_library': static_deps.append(dep_cmake_name) elif dep_target_type == 'shared_library': shared_deps.append(dep_cmake_name) else: other_deps.append(dep_cmake_name) # ensure all external dependencies are complete before internal dependencies # extra_deps currently only depend on their own deps, so otherwise run early if static_deps or shared_deps or other_deps: for extra_dep in extra_deps: output.write('add_dependencies(') output.write(extra_dep) output.write('\n') for deps in (static_deps, shared_deps, other_deps): for dep in gyp.common.uniquer(deps): output.write(' ') output.write(dep) output.write('\n') output.write(')\n') linkable = target_type in ('executable', 'loadable_module', 'shared_library') other_deps.extend(extra_deps) if other_deps or (not linkable and (static_deps or shared_deps)): output.write('add_dependencies(') output.write(cmake_target_name) output.write('\n') for dep in gyp.common.uniquer(other_deps): output.write(' ') output.write(dep) output.write('\n') if not linkable: for deps in (static_deps, shared_deps): for lib_dep in gyp.common.uniquer(deps): output.write(' ') output.write(lib_dep) output.write('\n') output.write(')\n') # Libraries if linkable: external_libs = [lib for lib in spec.get('libraries', []) if len(lib) > 0] if external_libs or static_deps or shared_deps: output.write('target_link_libraries(') output.write(cmake_target_name) output.write('\n') if static_deps: write_group = circular_libs and len(static_deps) > 1 if write_group: output.write('-Wl,--start-group\n') for dep in gyp.common.uniquer(static_deps): output.write(' ') output.write(dep) output.write('\n') if write_group: output.write('-Wl,--end-group\n') if shared_deps: for dep in gyp.common.uniquer(shared_deps): output.write(' ') output.write(dep) output.write('\n') if external_libs: for lib in gyp.common.uniquer(external_libs): output.write(' ') output.write(lib) output.write('\n') output.write(')\n') UnsetVariable(output, 'TOOLSET') UnsetVariable(output, 'TARGET') def GenerateOutputForConfig(target_list, target_dicts, data, params, config_to_use): options = params['options'] generator_flags = params['generator_flags'] # generator_dir: relative path from pwd to where make puts build files. # Makes migrating from make to cmake easier, cmake doesn't put anything here. # Each Gyp configuration creates a different CMakeLists.txt file # to avoid incompatibilities between Gyp and CMake configurations. generator_dir = os.path.relpath(options.generator_output or '.') # output_dir: relative path from generator_dir to the build directory. output_dir = generator_flags.get('output_dir', 'out') # build_dir: relative path from source root to our output files. # e.g. "out/Debug" build_dir = os.path.normpath(os.path.join(generator_dir, output_dir, config_to_use)) toplevel_build = os.path.join(options.toplevel_dir, build_dir) output_file = os.path.join(toplevel_build, 'CMakeLists.txt') gyp.common.EnsureDirExists(output_file) output = open(output_file, 'w') output.write('cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n') output.write('cmake_policy(VERSION 2.8.8)\n') gyp_file, project_target, _ = gyp.common.ParseQualifiedTarget(target_list[-1]) output.write('project(') output.write(project_target) output.write(')\n') SetVariable(output, 'configuration', config_to_use) ar = None cc = None cxx = None make_global_settings = data[gyp_file].get('make_global_settings', []) build_to_top = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir) for key, value in make_global_settings: if key == 'AR': ar = os.path.join(build_to_top, value) if key == 'CC': cc = os.path.join(build_to_top, value) if key == 'CXX': cxx = os.path.join(build_to_top, value) ar = gyp.common.GetEnvironFallback(['AR_target', 'AR'], ar) cc = gyp.common.GetEnvironFallback(['CC_target', 'CC'], cc) cxx = gyp.common.GetEnvironFallback(['CXX_target', 'CXX'], cxx) if ar: SetVariable(output, 'CMAKE_AR', ar) if cc: SetVariable(output, 'CMAKE_C_COMPILER', cc) if cxx: SetVariable(output, 'CMAKE_CXX_COMPILER', cxx) # The following appears to be as-yet undocumented. # http://public.kitware.com/Bug/view.php?id=8392 output.write('enable_language(ASM)\n') # ASM-ATT does not support .S files. # output.write('enable_language(ASM-ATT)\n') if cc: SetVariable(output, 'CMAKE_ASM_COMPILER', cc) SetVariable(output, 'builddir', '${CMAKE_CURRENT_BINARY_DIR}') SetVariable(output, 'obj', '${builddir}/obj') output.write('\n') # TODO: Undocumented/unsupported (the CMake Java generator depends on it). # CMake by default names the object resulting from foo.c to be foo.c.o. # Gyp traditionally names the object resulting from foo.c foo.o. # This should be irrelevant, but some targets extract .o files from .a # and depend on the name of the extracted .o files. output.write('set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)\n') output.write('set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)\n') output.write('\n') # Force ninja to use rsp files. Otherwise link and ar lines can get too long, # resulting in 'Argument list too long' errors. output.write('set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)\n') output.write('\n') namer = CMakeNamer(target_list) # The list of targets upon which the 'all' target should depend. # CMake has it's own implicit 'all' target, one is not created explicitly. all_qualified_targets = set() for build_file in params['build_files']: for qualified_target in gyp.common.AllTargets(target_list, target_dicts, os.path.normpath(build_file)): all_qualified_targets.add(qualified_target) for qualified_target in target_list: WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use, options, generator_flags, all_qualified_targets, output) output.close() def PerformBuild(data, configurations, params): options = params['options'] generator_flags = params['generator_flags'] # generator_dir: relative path from pwd to where make puts build files. # Makes migrating from make to cmake easier, cmake doesn't put anything here. generator_dir = os.path.relpath(options.generator_output or '.') # output_dir: relative path from generator_dir to the build directory. output_dir = generator_flags.get('output_dir', 'out') for config_name in configurations: # build_dir: relative path from source root to our output files. # e.g. "out/Debug" build_dir = os.path.normpath(os.path.join(generator_dir, output_dir, config_name)) arguments = ['cmake', '-G', 'Ninja'] print 'Generating [%s]: %s' % (config_name, arguments) subprocess.check_call(arguments, cwd=build_dir) arguments = ['ninja', '-C', build_dir] print 'Building [%s]: %s' % (config_name, arguments) subprocess.check_call(arguments) def CallGenerateOutputForConfig(arglist): # Ignore the interrupt signal so that the parent process catches it and # kills all multiprocessing children. signal.signal(signal.SIGINT, signal.SIG_IGN) target_list, target_dicts, data, params, config_name = arglist GenerateOutputForConfig(target_list, target_dicts, data, params, config_name) def GenerateOutput(target_list, target_dicts, data, params): user_config = params.get('generator_flags', {}).get('config', None) if user_config: GenerateOutputForConfig(target_list, target_dicts, data, params, user_config) else: config_names = target_dicts[target_list[0]]['configurations'].keys() if params['parallel']: try: pool = multiprocessing.Pool(len(config_names)) arglists = [] for config_name in config_names: arglists.append((target_list, target_dicts, data, params, config_name)) pool.map(CallGenerateOutputForConfig, arglists) except KeyboardInterrupt, e: pool.terminate() raise e else: for config_name in config_names: GenerateOutputForConfig(target_list, target_dicts, data, params, config_name)
mit
[ 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, 16472, 1072, 859, 199, 199, 2765, 859, 365, 1334, 16367, 436, 1077, 506, 8652, 22820, 14, 199, 199, 2765, 859, 16904, 19773, 334, 18, 14, 24, 14, 24, 8771, 1324, 465, 2399, 1072, 14, 7309, 21355, 15116, 14, 2424, 365, 199, 3966, 367, 1924, 2897, 14, 199, 199, 2765, 859, 1159, 3379, 12016, 1990, 370, 2291, 20401, 315, 473, 1093, 83, 2839, 1804, 872, 7549, 199, 6777, 675, 21355, 367, 2199, 10041, 14, 2779, 365, 2597, 3962, 370, 675, 21355, 370, 199, 4208, 11336, 367, 1163, 473, 1093, 83, 4066, 465, 325, 7548, 261, 286, 3583, 436, 1233, 447, 4166, 14, 3959, 17523, 199, 14117, 3957, 314, 21355, 15116, 14, 2424, 370, 282, 1233, 447, 4166, 7434, 80, 367, 314, 8823, 370, 1586, 12, 199, 7911, 1900, 1808, 21355, 14, 3709, 282, 754, 3959, 17523, 8823, 365, 625, 14600, 402, 6365, 199, 14334, 14, 710, 4046, 21355, 15116, 14, 2424, 883, 2597, 506, 1202, 370, 1900, 641, 10130, 14, 6006, 199, 374, 5544, 949, 2291, 367, 10015, 641, 10677, 1163, 2419, 10130, 14, 199, 199, 1918, 4046, 21355, 15116, 14, 2424, 1077, 7684, 6555, 1006, 11336, 14, 9738, 12, 199, 16990, 365, 282, 15015, 3382, 4902, 436, 19773, 543, 8794, 370, 25833, 14, 2900, 12454, 199, 1530, 6326, 370, 1736, 6818, 642, 12, 1325, 21355, 15026, 542, 397, 446, 16239, 28925, 928, 13, 923, 465, 282, 199, 4342, 436, 22743, 28908, 652, 14, 3709, 282, 754, 314, 1072, 402, 642, 4306, 199, 5626, 440, 506, 295, 1857, 641, 367, 10015, 14, 199, 199, 11423, 1808, 543, 1022, 32176, 12, 675, 1015, 841, 14, 20, 26240, 26902, 5459, 402, 1022, 32176, 911, 199, 1397, 506, 7688, 370, 2342, 314, 1406, 570, 6602, 11736, 315, 314, 4046, 199, 27984, 15116, 14, 2424, 570, 14, 199, 624, 199, 199, 646, 12866, 199, 646, 747, 199, 646, 4673, 199, 646, 1059, 199, 646, 3873, 199, 646, 4902, 14, 2330, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 12273, 356, 1987, 1152, 297, 523, 283, 13772, 63, 5617, 63, 3022, 356, 20044, 21728, 5995, 773, 14, 10545, 16892, 7293, 523, 283, 5617, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 7293, 523, 283, 23227, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 5995, 10545, 9268, 5995, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 20044, 1113, 5995, 2268, 297, 523, 283, 14853, 63, 3022, 356, 20044, 21728, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 13578, 63, 7321, 63, 3243, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 13578, 63, 7321, 63, 3022, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 13578, 63, 7321, 63, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 13578, 63, 7321, 63, 5441, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 13578, 63, 7321, 63, 2472, 7293, 523, 283, 22212, 63, 2339, 356, 20044, 4758, 7293, 199, 93, 199, 199, 14742, 63, 3243, 63, 21367, 275, 661, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 20044, 21728, 7293, 20044, 1113, 12216, 199, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 4679, 63, 28789, 63, 1986, 63, 4342, 63, 5714, 63, 23395, 275, 715, 199, 199, 6790, 1193, 2617, 63, 18451, 275, 469, 523, 1987, 67, 356, 283, 2055, 297, 523, 1987, 2055, 356, 283, 9634, 297, 523, 1987, 5910, 356, 283, 9634, 297, 523, 1987, 9634, 356, 283, 9634, 297, 523, 1987, 83, 356, 283, 83, 297, 327, 7429, 523, 1987, 51, 356, 283, 83, 297, 327, 7429, 199, 93, 421, 199, 318, 5852, 4793, 8, 65, 12, 2403, 304, 523, 408, 3407, 283, 65, 7, 1928, 283, 1861, 7, 340, 652, 9174, 543, 283, 1861, 23690, 523, 372, 282, 59, 552, 8, 1861, 15405, 340, 282, 14, 2460, 8, 1861, 9, 587, 282, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 849, 63, 3669, 14, 5486, 360, 3100, 297, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 430, 421, 199, 318, 3599, 382, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 1013, 382, 461, 334, 5626, 506, 315, 28652, 11378, 10477, 523, 372, 1263, 8, 1501, 14, 4130, 8, 69, 9, 367, 325, 315, 16503, 1193, 2617, 63, 18451, 9, 421, 199, 318, 10967, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 30258, 334, 5626, 506, 641, 314, 2142, 1004, 10477, 523, 372, 1788, 14, 4130, 5175, 79, 358, 421, 199, 318, 20800, 904, 2042, 13606, 27984, 2980, 8, 1095, 63, 515, 12, 4668, 63, 515, 304, 523, 408, 1322, 393, 2310, 4668, 63, 515, 6169, 1300, 63, 515, 436, 2529, 314, 754, 14, 819, 982, 4668, 63, 515, 365, 376, 3679, 931, 652, 365, 2138, 14874, 14, 523, 6630, 652, 365, 12152, 6169, 1300, 63, 515, 436, 9657, 14, 523, 982, 314, 754, 365, 282, 3847, 931, 12, 652, 365, 19565, 370, 506, 3847, 370, 314, 523, 21355, 15116, 14, 2424, 14, 523, 408, 523, 340, 747, 14, 515, 14, 17896, 8, 3369, 63, 515, 304, 272, 372, 4668, 63, 515, 523, 340, 1263, 779, 3369, 63, 515, 14, 2460, 8, 1391, 9, 367, 2729, 315, 18530, 63, 3243, 63, 21367, 4682, 272, 372, 4668, 63, 515, 523, 327, 3254, 26, 886, 781, 1929, 370, 1104, 1300, 63, 515, 367, 3679, 2860, 465, 5521, 31, 523, 372, 747, 14, 515, 14, 904, 360, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 1993, 747, 14, 515, 14, 9267 ]
[ 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, 16472, 1072, 859, 199, 199, 2765, 859, 365, 1334, 16367, 436, 1077, 506, 8652, 22820, 14, 199, 199, 2765, 859, 16904, 19773, 334, 18, 14, 24, 14, 24, 8771, 1324, 465, 2399, 1072, 14, 7309, 21355, 15116, 14, 2424, 365, 199, 3966, 367, 1924, 2897, 14, 199, 199, 2765, 859, 1159, 3379, 12016, 1990, 370, 2291, 20401, 315, 473, 1093, 83, 2839, 1804, 872, 7549, 199, 6777, 675, 21355, 367, 2199, 10041, 14, 2779, 365, 2597, 3962, 370, 675, 21355, 370, 199, 4208, 11336, 367, 1163, 473, 1093, 83, 4066, 465, 325, 7548, 261, 286, 3583, 436, 1233, 447, 4166, 14, 3959, 17523, 199, 14117, 3957, 314, 21355, 15116, 14, 2424, 370, 282, 1233, 447, 4166, 7434, 80, 367, 314, 8823, 370, 1586, 12, 199, 7911, 1900, 1808, 21355, 14, 3709, 282, 754, 3959, 17523, 8823, 365, 625, 14600, 402, 6365, 199, 14334, 14, 710, 4046, 21355, 15116, 14, 2424, 883, 2597, 506, 1202, 370, 1900, 641, 10130, 14, 6006, 199, 374, 5544, 949, 2291, 367, 10015, 641, 10677, 1163, 2419, 10130, 14, 199, 199, 1918, 4046, 21355, 15116, 14, 2424, 1077, 7684, 6555, 1006, 11336, 14, 9738, 12, 199, 16990, 365, 282, 15015, 3382, 4902, 436, 19773, 543, 8794, 370, 25833, 14, 2900, 12454, 199, 1530, 6326, 370, 1736, 6818, 642, 12, 1325, 21355, 15026, 542, 397, 446, 16239, 28925, 928, 13, 923, 465, 282, 199, 4342, 436, 22743, 28908, 652, 14, 3709, 282, 754, 314, 1072, 402, 642, 4306, 199, 5626, 440, 506, 295, 1857, 641, 367, 10015, 14, 199, 199, 11423, 1808, 543, 1022, 32176, 12, 675, 1015, 841, 14, 20, 26240, 26902, 5459, 402, 1022, 32176, 911, 199, 1397, 506, 7688, 370, 2342, 314, 1406, 570, 6602, 11736, 315, 314, 4046, 199, 27984, 15116, 14, 2424, 570, 14, 199, 624, 199, 199, 646, 12866, 199, 646, 747, 199, 646, 4673, 199, 646, 1059, 199, 646, 3873, 199, 646, 4902, 14, 2330, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 12273, 356, 1987, 1152, 297, 523, 283, 13772, 63, 5617, 63, 3022, 356, 20044, 21728, 5995, 773, 14, 10545, 16892, 7293, 523, 283, 5617, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 7293, 523, 283, 23227, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 5995, 10545, 9268, 5995, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 20044, 1113, 5995, 2268, 297, 523, 283, 14853, 63, 3022, 356, 20044, 21728, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 13578, 63, 7321, 63, 3243, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 13578, 63, 7321, 63, 3022, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 13578, 63, 7321, 63, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 13578, 63, 7321, 63, 5441, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 13578, 63, 7321, 63, 2472, 7293, 523, 283, 22212, 63, 2339, 356, 20044, 4758, 7293, 199, 93, 199, 199, 14742, 63, 3243, 63, 21367, 275, 661, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 20044, 21728, 7293, 20044, 1113, 12216, 199, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 4679, 63, 28789, 63, 1986, 63, 4342, 63, 5714, 63, 23395, 275, 715, 199, 199, 6790, 1193, 2617, 63, 18451, 275, 469, 523, 1987, 67, 356, 283, 2055, 297, 523, 1987, 2055, 356, 283, 9634, 297, 523, 1987, 5910, 356, 283, 9634, 297, 523, 1987, 9634, 356, 283, 9634, 297, 523, 1987, 83, 356, 283, 83, 297, 327, 7429, 523, 1987, 51, 356, 283, 83, 297, 327, 7429, 199, 93, 421, 199, 318, 5852, 4793, 8, 65, 12, 2403, 304, 523, 408, 3407, 283, 65, 7, 1928, 283, 1861, 7, 340, 652, 9174, 543, 283, 1861, 23690, 523, 372, 282, 59, 552, 8, 1861, 15405, 340, 282, 14, 2460, 8, 1861, 9, 587, 282, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 849, 63, 3669, 14, 5486, 360, 3100, 297, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 430, 421, 199, 318, 3599, 382, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 1013, 382, 461, 334, 5626, 506, 315, 28652, 11378, 10477, 523, 372, 1263, 8, 1501, 14, 4130, 8, 69, 9, 367, 325, 315, 16503, 1193, 2617, 63, 18451, 9, 421, 199, 318, 10967, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 30258, 334, 5626, 506, 641, 314, 2142, 1004, 10477, 523, 372, 1788, 14, 4130, 5175, 79, 358, 421, 199, 318, 20800, 904, 2042, 13606, 27984, 2980, 8, 1095, 63, 515, 12, 4668, 63, 515, 304, 523, 408, 1322, 393, 2310, 4668, 63, 515, 6169, 1300, 63, 515, 436, 2529, 314, 754, 14, 819, 982, 4668, 63, 515, 365, 376, 3679, 931, 652, 365, 2138, 14874, 14, 523, 6630, 652, 365, 12152, 6169, 1300, 63, 515, 436, 9657, 14, 523, 982, 314, 754, 365, 282, 3847, 931, 12, 652, 365, 19565, 370, 506, 3847, 370, 314, 523, 21355, 15116, 14, 2424, 14, 523, 408, 523, 340, 747, 14, 515, 14, 17896, 8, 3369, 63, 515, 304, 272, 372, 4668, 63, 515, 523, 340, 1263, 779, 3369, 63, 515, 14, 2460, 8, 1391, 9, 367, 2729, 315, 18530, 63, 3243, 63, 21367, 4682, 272, 372, 4668, 63, 515, 523, 327, 3254, 26, 886, 781, 1929, 370, 1104, 1300, 63, 515, 367, 3679, 2860, 465, 5521, 31, 523, 372, 747, 14, 515, 14, 904, 360, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 1993, 747, 14, 515, 14, 9267, 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 ]
kenorb/BitTorrent
python_bt_codebase_library/BTL/log.py
5
14279
# 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 logging import * import time, sys import socket import datetime import logging import logging.handlers from BTL.reactor_magic import reactor from BTL.defer import Deferred from BTL.btl_string import printable from BTL import twisted_logger # convenience re-export so that they can be used without import logging. DEBUG = DEBUG INFO = INFO WARNING = WARNING ERROR = ERROR CRITICAL = CRITICAL getLogger = getLogger # Not used at the moment but can be changed later SYSLOG_HOST = 'localhost' SYSLOG_PORT = 514 class BTLFormatter(logging.Formatter): def __init__(self, *a, **k): self.use_localtime = False if k.has_key('use_localtime'): self.use_localtime = k['use_localtime'] del k['use_localtime'] logging.Formatter.__init__(self, *a, **k) def formatTime(self, record, datefmt=None): ct = self.converter(record.created) try: if self.use_localtime: dt = datetime.datetime.fromtimestamp(record.created) else: dt = datetime.datetime.utcfromtimestamp(record.created) if datefmt: s = dt.strftime(datefmt) else: s = dt.isoformat() except: s = "Interpretter Shutdown" return s class RateLimitedLogger: """Logger that tosses log entries whenever the logged entries per second exceeds the specified rate limit by max_burst log entries.""" def __init__(self, logger, rate_limit, max_burst, log_all_level = CRITICAL ): """@param logger: logging.Logger object that this class wraps. @param rate_limit: maximum number of log entries per second. @param max_burst: maximum number of log entries that can be printed in a burst. max_burst is the sigma in a (sigma,rho) token bucket. @param log_all_level: log all entries with level >= log_all_level. Such entries are still counted against the rate limit. """ self.logger = logger self.rate_limit = rate_limit self.max_burst = max_burst self.logged_discard = False # logged that we are dropping entries? self.tokens = self.max_burst self.log_all_above_level = log_all_level reactor.callLater(1,self._increment_tokens) reactor.callLater(5,self._log_clear) def _increment_tokens(self): self.tokens += self.rate_limit if self.tokens >= self.max_burst: self.tokens = self.max_burst reactor.callLater(1, self._increment_tokens) def _log_clear(self): self.logged_discard = False def setLevel(self, level): return self.logger.setLevel(level) def _discarded(self, level): self.tokens -= 1 if self.tokens < 0: self.tokens = 0 if level >= self.log_all_above_level: return False elif not self.logged_discard: self.logger.error( "Discarding '%s' logger entries because they are arriving " "too fast. Will not log this error again for 5 " "seconds." % self.logger.name ) self.logged_discard = True return True # true = discarded return False # false = not discarded def debug(self, msg, *args, **kwargs): if not self._discarded(level = DEBUG): self.logger.debug(msg,*args, **kwargs) def info(self, msg, *args, **kwargs): if not self._discarded(level = INFO): self.logger.info(msg, *args, **kwargs) def warning(self, msg, *args, **kwargs): if not self._discarded(level = WARNING): self.logger.warning(msg, *args, **kwargs) def error(self, msg, *args, **kwargs): if not self._discarded(level = ERROR): self.logger.error(msg, *args, **kwargs) def exception(self, msg, *args): if not self._discarded(level = EXCEPTION): self.logger.exception(msg, *args) def critical(self, msg, *args, **kwargs): if not self._discarded(level = CRITICAL): self.logger.critical(msg, *args, **kwargs) def log(self, level, msg, *args, **kwargs): if not self._discarded(): self.logger.log(level, msg, *args, **kwargs) def findCaller(self): return self.logger.findCaller() def makeRecord(self, name, level, fn, lno, msg, args, exc_info): self.logger.makeRecord(name, level, fn, lno, msg, args, exc_info) def addHandler(self, hdlr): self.logger.addHandler(hdlr) def removeHandler(self, hdlr): self.logger.removeHandler(hdlr) def callHandlers(self, record): self.logger.callHandlers(record) def getEffectiveLevel(self): return self.logger.getEffectiveLevel() class StdioPretender: """Pretends to be stdout or stderr.""" # modified from twisted.python.log.StdioOnnaStick closed = 0 softspace = 0 mode = 'wb' name = '<stdio (log)>' def __init__(self, capture_name, level ): self.level = level self.logger = logging.getLogger( capture_name ) self.buf = '' def close(self): pass def flush(self): pass def fileno(self): return -1 def read(self): raise IOError("can't read from the log!") readline = read readlines = read seek = read tell = read def write(self, data): d = (self.buf + data).split('\n') self.buf = d[-1] messages = d[0:-1] for message in messages: self.logger.log( self.level, message ) def writelines(self, lines): for line in lines: self.logger.log( self.level, message ) class SysLogHandler(logging.handlers.SysLogHandler): # This is a hack to get around log entry size limits imposed by syslog. def __init__(self, address=('localhost', logging.handlers.SYSLOG_UDP_PORT), facility=logging.handlers.SysLogHandler.LOG_USER, max_msg_len = 4096, fragment_len = 900, make_printable = True ): """@param max_msg_len: maximum message length before truncation. @param fragment_len: when message length exceeds 900 it is truncated and broken into multiple consecutive log entries. @param make_printable: runs each message through BTL.btl_string.printable in emit. For example, this is useful if the messages are being sent through a UNIX socket to syslogd and the message might contain non-ascii characters. """ logging.handlers.SysLogHandler.__init__( self, address, facility ) self.max_msg_len = max_msg_len self.fragment_len = fragment_len self.make_printable = make_printable def emit(self, record): """Differs from the override emit in that it fragments the message to allow for much longer syslog messages.""" msg = self.format(record) if self.make_printable: msg = printable(msg) msg = msg[:self.max_msg_len] i = 0 while msg: remaining = msg[self.fragment_len:] if i > 0: msg = "(cont.) " + msg[:self.fragment_len] else: msg = msg[:self.fragment_len] msg = self.log_format_string % (self.encodePriority(self.facility, string.lower(record.levelname)),msg) try: if self.unixsocket: try: self.socket.send(msg) except socket.error: self._connect_unixsocket(self.address) self.socket.send(msg) else: self.socket.sendto(msg, self.address) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) msg = remaining i += 1 def injectLogger(use_syslog = True, log_file = None, verbose = False, capture_output = True, twisted_error_log_level = ERROR, twisted_info_log_level = INFO, capture_stderr_log_level = ERROR, capture_stdout_log_level = INFO, capture_stderr_name = 'stderr', capture_stdout_name = 'stdout', log_level = DEBUG, log_twisted = True, use_localtime = False ): """ Installs logging. @param use_syslog: log to syslog. use_syslog, log_file, and verbose are not mutually exclusive. @param log_file: log to a file. @param verbose: output logs to stdout. Setting verbose and capture_output to this function does NOT result in an infinite loop. @param capture_output: redirects stdout and stderr to the logger. Be careful. This can create infinite loops with loggers that output to stdout or stderr. @param twisted_error_log_level: log level for errors reported by twisted. @param twisted_info_log_level: log level for non-errors reported by twisted. If capture_output is set then this is also the log level for anything output to stdout or stderr. @param log_level: only log events that have level >= passed level are logged. This is achieved by setting the log level in each of the installed handlers. @param capture_stderr_log_level: log level for output captured from stdout. @param capture_stdout_log_level: log level for output captured from stderr. @param capture_stderr_name: log name used for stderr. 'name' refers to the name arg passed to logging.getLogger(name). @param capture_stdout_name: log name used for stdout. Analogous to capture_stderr_name. """ logger = logging.getLogger('') logger.setLevel(DEBUG) # we use log handler levels to control output level. formatter = BTLFormatter("%(asctime)s - %(name)s - %(process)d - " "%(levelname)s - %(message)s", use_localtime=use_localtime) if log_file is not None: lf_handler = logging.handlers.RotatingFileHandler(filename=log_file, mode='a', maxBytes=2**27, backupCount=10) lf_handler.setFormatter(formatter) lf_handler.setLevel(log_level) logger.addHandler(lf_handler) if use_syslog: sl_handler = SysLogHandler('/dev/log', facility=SysLogHandler.LOG_LOCAL0) #address = (SYSLOG_HOST, SYSLOG_PORT)) # namespace - pid - level - message sl_handler.setFormatter(BTLFormatter("%(name)s - %(process)d - " "%(levelname)s - %(message)s")) sl_handler.setLevel(log_level) logger.addHandler(sl_handler) if verbose: # StreamHandler does not capture stdout, it directs output from # loggers to stdout. so_handler = logging.StreamHandler(sys.stdout) so_handler.setFormatter(formatter) so_handler.setLevel(log_level) logger.addHandler(so_handler) if capture_output: sys.stdout = StdioPretender( capture_stdout_name, capture_stdout_log_level ) sys.stderr = StdioPretender( capture_stderr_name, capture_stderr_log_level ) if log_twisted: twisted_logger.start(error_log_level = twisted_error_log_level, info_log_level = twisted_info_log_level) if __name__ == '__main__': from BTL.greenlet_yielddefer import coroutine, like_yield @coroutine def test_rate_limited_logger(): injectLogger(verbose = True) log = RateLimitedLogger(logging.getLogger("myapp"), 1,1) log.info( "should be printed." ) log.info( "should not be printed" ) # but should log "discard" message. log.info( "also should not be printed" ) # should not logging of discard message. df = Deferred() reactor.callLater(3, df.callback, True) like_yield(df) log.info( "should also be printed" ) reactor.stop() def test_injectLogger(): injectLogger(log_file = "your.log", use_syslog=False, verbose=True) logger = logging.getLogger("myapp") logger.warning("You are awesome") print 'stdout!' print >>sys.stderr, 'stderr!' from twisted.internet import reactor from twisted.python import failure def foo(): reactor.stop() zuul = dana reactor.callLater(0, foo) def test_injectLogger2(): injectLogger(log_file = "your.log", verbose=False, capture_output=True) print "hello world" def foo(): reactor.stop() zuul = dana reactor.callLater(0, foo) #test_injectLogger() test_injectLogger2() #reactor.callLater(0, test_rate_limited_logger) reactor.run()
gpl-3.0
[ 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, 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, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 2050, 492, 627, 199, 199, 646, 900, 12, 984, 199, 646, 2838, 199, 646, 2197, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 504, 699, 7308, 14, 13544, 63, 11523, 492, 9655, 199, 504, 699, 7308, 14, 11610, 492, 17448, 199, 504, 699, 7308, 14, 66, 5019, 63, 875, 492, 21834, 199, 199, 504, 699, 7308, 492, 7390, 63, 2921, 199, 199, 3, 16777, 295, 13, 3790, 880, 626, 2985, 883, 506, 1202, 1928, 492, 2050, 14, 199, 5287, 275, 10990, 199, 4531, 275, 24008, 199, 9171, 275, 14750, 199, 3170, 275, 12539, 199, 21539, 275, 17101, 19223, 199, 5572, 275, 28138, 199, 199, 3, 2832, 1202, 737, 314, 12427, 1325, 883, 506, 2896, 2945, 199, 13326, 4947, 63, 5449, 463, 275, 283, 5967, 7, 199, 13326, 4947, 63, 3657, 463, 275, 959, 1079, 199, 199, 533, 699, 7308, 7772, 8, 4806, 14, 7772, 304, 339, 347, 636, 826, 721, 277, 12, 627, 65, 12, 1011, 75, 304, 267, 291, 14, 1180, 63, 15198, 275, 756, 267, 340, 1022, 14, 1989, 63, 498, 360, 1180, 63, 15198, 735, 288, 291, 14, 1180, 63, 15198, 275, 1022, 459, 1180, 63, 15198, 418, 288, 2150, 1022, 459, 1180, 63, 15198, 418, 267, 2050, 14, 7772, 855, 826, 721, 277, 12, 627, 65, 12, 1011, 75, 9, 2378, 347, 1475, 1366, 8, 277, 12, 2777, 12, 1434, 5045, 29, 403, 304, 267, 9428, 275, 291, 14, 11256, 8, 3059, 14, 3966, 9, 267, 862, 26, 288, 340, 291, 14, 1180, 63, 15198, 26, 355, 4487, 275, 2197, 14, 2083, 14, 18531, 8, 3059, 14, 3966, 9, 288, 587, 26, 355, 4487, 275, 2197, 14, 2083, 14, 5834, 18531, 8, 3059, 14, 3966, 9, 288, 340, 1434, 5045, 26, 355, 308, 275, 4487, 14, 6205, 8, 602, 5045, 9, 288, 587, 26, 355, 308, 275, 4487, 14, 17070, 342, 267, 871, 26, 288, 308, 275, 298, 2620, 25133, 351, 5244, 6159, 2, 267, 372, 308, 199, 199, 533, 26311, 7219, 5703, 4455, 26, 272, 408, 4455, 626, 370, 83, 874, 943, 4811, 18119, 314, 10367, 2126, 4811, 1126, 3499, 22338, 314, 2013, 6634, 2304, 701, 2126, 1390, 63, 26420, 943, 4811, 1041, 272, 347, 636, 826, 721, 277, 12, 2512, 12, 6634, 63, 3097, 12, 1390, 63, 26420, 12, 943, 63, 452, 63, 1896, 275, 17101, 19223, 3461, 267, 408, 32, 635, 2512, 26, 2050, 14, 4455, 909, 626, 642, 1021, 14018, 14, 1779, 768, 635, 6634, 63, 3097, 26, 5696, 1329, 402, 943, 4811, 1126, 3499, 14, 1779, 768, 635, 1390, 63, 26420, 26, 5696, 1329, 402, 943, 4811, 626, 883, 506, 12487, 1598, 315, 282, 330, 13305, 14, 1390, 63, 26420, 365, 314, 10819, 315, 282, 334, 9412, 12, 10412, 9, 1526, 5315, 14, 1779, 768, 635, 943, 63, 452, 63, 1896, 26, 943, 1006, 4811, 543, 2166, 2356, 943, 63, 452, 63, 1896, 14, 1598, 32753, 4811, 787, 5139, 31662, 6169, 314, 6634, 2304, 14, 1598, 408, 267, 291, 14, 2921, 275, 2512, 267, 291, 14, 1866, 63, 3097, 275, 6634, 63, 3097, 267, 291, 14, 988, 63, 26420, 275, 1390, 63, 26420, 267, 291, 14, 12419, 63, 14394, 275, 756, 257, 327, 10367, 626, 781, 787, 366, 20148, 4811, 31, 267, 291, 14, 4504, 275, 291, 14, 988, 63, 26420, 267, 291, 14, 793, 63, 452, 63, 16181, 63, 1896, 275, 943, 63, 452, 63, 1896, 267, 9655, 14, 1250, 22028, 8, 17, 12, 277, 423, 9728, 63, 4504, 9, 267, 9655, 14, 1250, 22028, 8, 21, 12, 277, 423, 793, 63, 3584, 9, 339, 347, 485, 9728, 63, 4504, 8, 277, 304, 267, 291, 14, 4504, 847, 291, 14, 1866, 63, 3097, 267, 340, 291, 14, 4504, 2356, 291, 14, 988, 63, 26420, 26, 288, 291, 14, 4504, 275, 291, 14, 988, 63, 26420, 267, 9655, 14, 1250, 22028, 8, 17, 12, 291, 423, 9728, 63, 4504, 9, 339, 347, 485, 793, 63, 3584, 8, 277, 304, 267, 291, 14, 12419, 63, 14394, 275, 756, 339, 347, 663, 4670, 8, 277, 12, 2166, 304, 267, 372, 291, 14, 2921, 14, 13548, 8, 1896, 9, 339, 347, 485, 6409, 12910, 8, 277, 12, 2166, 304, 267, 291, 14, 4504, 4862, 413, 267, 340, 291, 14, 4504, 665, 378, 26, 288, 291, 14, 4504, 275, 378, 288, 340, 2166, 2356, 291, 14, 793, 63, 452, 63, 16181, 63, 1896, 26, 355, 372, 756, 288, 916, 440, 291, 14, 12419, 63, 14394, 26, 355, 291, 14, 2921, 14, 705, 8, 298, 2825, 5841, 316, 1543, 83, 7, 2512, 4811, 2952, 2985, 787, 601, 322, 4007, 298, 3521, 298, 7354, 7377, 14, 221, 12823, 440, 943, 642, 1125, 4020, 367, 959, 298, 3521, 298, 4515, 2122, 450, 291, 14, 2921, 14, 354, 776, 355, 291, 14, 12419, 63, 14394, 275, 715, 288, 372, 715, 257, 327, 2549, 275, 22002, 267, 372, 756, 420, 327, 3055, 275, 440, 22002, 339, 347, 3105, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 423, 6409, 12910, 8, 1896, 275, 10990, 304, 288, 291, 14, 2921, 14, 1757, 8, 1328, 19166, 589, 12, 1011, 958, 9, 339, 347, 2256, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 423, 6409, 12910, 8, 1896, 275, 24008, 304, 288 ]
[ 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, 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, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 2050, 492, 627, 199, 199, 646, 900, 12, 984, 199, 646, 2838, 199, 646, 2197, 199, 646, 2050, 199, 646, 2050, 14, 5586, 199, 504, 699, 7308, 14, 13544, 63, 11523, 492, 9655, 199, 504, 699, 7308, 14, 11610, 492, 17448, 199, 504, 699, 7308, 14, 66, 5019, 63, 875, 492, 21834, 199, 199, 504, 699, 7308, 492, 7390, 63, 2921, 199, 199, 3, 16777, 295, 13, 3790, 880, 626, 2985, 883, 506, 1202, 1928, 492, 2050, 14, 199, 5287, 275, 10990, 199, 4531, 275, 24008, 199, 9171, 275, 14750, 199, 3170, 275, 12539, 199, 21539, 275, 17101, 19223, 199, 5572, 275, 28138, 199, 199, 3, 2832, 1202, 737, 314, 12427, 1325, 883, 506, 2896, 2945, 199, 13326, 4947, 63, 5449, 463, 275, 283, 5967, 7, 199, 13326, 4947, 63, 3657, 463, 275, 959, 1079, 199, 199, 533, 699, 7308, 7772, 8, 4806, 14, 7772, 304, 339, 347, 636, 826, 721, 277, 12, 627, 65, 12, 1011, 75, 304, 267, 291, 14, 1180, 63, 15198, 275, 756, 267, 340, 1022, 14, 1989, 63, 498, 360, 1180, 63, 15198, 735, 288, 291, 14, 1180, 63, 15198, 275, 1022, 459, 1180, 63, 15198, 418, 288, 2150, 1022, 459, 1180, 63, 15198, 418, 267, 2050, 14, 7772, 855, 826, 721, 277, 12, 627, 65, 12, 1011, 75, 9, 2378, 347, 1475, 1366, 8, 277, 12, 2777, 12, 1434, 5045, 29, 403, 304, 267, 9428, 275, 291, 14, 11256, 8, 3059, 14, 3966, 9, 267, 862, 26, 288, 340, 291, 14, 1180, 63, 15198, 26, 355, 4487, 275, 2197, 14, 2083, 14, 18531, 8, 3059, 14, 3966, 9, 288, 587, 26, 355, 4487, 275, 2197, 14, 2083, 14, 5834, 18531, 8, 3059, 14, 3966, 9, 288, 340, 1434, 5045, 26, 355, 308, 275, 4487, 14, 6205, 8, 602, 5045, 9, 288, 587, 26, 355, 308, 275, 4487, 14, 17070, 342, 267, 871, 26, 288, 308, 275, 298, 2620, 25133, 351, 5244, 6159, 2, 267, 372, 308, 199, 199, 533, 26311, 7219, 5703, 4455, 26, 272, 408, 4455, 626, 370, 83, 874, 943, 4811, 18119, 314, 10367, 2126, 4811, 1126, 3499, 22338, 314, 2013, 6634, 2304, 701, 2126, 1390, 63, 26420, 943, 4811, 1041, 272, 347, 636, 826, 721, 277, 12, 2512, 12, 6634, 63, 3097, 12, 1390, 63, 26420, 12, 943, 63, 452, 63, 1896, 275, 17101, 19223, 3461, 267, 408, 32, 635, 2512, 26, 2050, 14, 4455, 909, 626, 642, 1021, 14018, 14, 1779, 768, 635, 6634, 63, 3097, 26, 5696, 1329, 402, 943, 4811, 1126, 3499, 14, 1779, 768, 635, 1390, 63, 26420, 26, 5696, 1329, 402, 943, 4811, 626, 883, 506, 12487, 1598, 315, 282, 330, 13305, 14, 1390, 63, 26420, 365, 314, 10819, 315, 282, 334, 9412, 12, 10412, 9, 1526, 5315, 14, 1779, 768, 635, 943, 63, 452, 63, 1896, 26, 943, 1006, 4811, 543, 2166, 2356, 943, 63, 452, 63, 1896, 14, 1598, 32753, 4811, 787, 5139, 31662, 6169, 314, 6634, 2304, 14, 1598, 408, 267, 291, 14, 2921, 275, 2512, 267, 291, 14, 1866, 63, 3097, 275, 6634, 63, 3097, 267, 291, 14, 988, 63, 26420, 275, 1390, 63, 26420, 267, 291, 14, 12419, 63, 14394, 275, 756, 257, 327, 10367, 626, 781, 787, 366, 20148, 4811, 31, 267, 291, 14, 4504, 275, 291, 14, 988, 63, 26420, 267, 291, 14, 793, 63, 452, 63, 16181, 63, 1896, 275, 943, 63, 452, 63, 1896, 267, 9655, 14, 1250, 22028, 8, 17, 12, 277, 423, 9728, 63, 4504, 9, 267, 9655, 14, 1250, 22028, 8, 21, 12, 277, 423, 793, 63, 3584, 9, 339, 347, 485, 9728, 63, 4504, 8, 277, 304, 267, 291, 14, 4504, 847, 291, 14, 1866, 63, 3097, 267, 340, 291, 14, 4504, 2356, 291, 14, 988, 63, 26420, 26, 288, 291, 14, 4504, 275, 291, 14, 988, 63, 26420, 267, 9655, 14, 1250, 22028, 8, 17, 12, 291, 423, 9728, 63, 4504, 9, 339, 347, 485, 793, 63, 3584, 8, 277, 304, 267, 291, 14, 12419, 63, 14394, 275, 756, 339, 347, 663, 4670, 8, 277, 12, 2166, 304, 267, 372, 291, 14, 2921, 14, 13548, 8, 1896, 9, 339, 347, 485, 6409, 12910, 8, 277, 12, 2166, 304, 267, 291, 14, 4504, 4862, 413, 267, 340, 291, 14, 4504, 665, 378, 26, 288, 291, 14, 4504, 275, 378, 288, 340, 2166, 2356, 291, 14, 793, 63, 452, 63, 16181, 63, 1896, 26, 355, 372, 756, 288, 916, 440, 291, 14, 12419, 63, 14394, 26, 355, 291, 14, 2921, 14, 705, 8, 298, 2825, 5841, 316, 1543, 83, 7, 2512, 4811, 2952, 2985, 787, 601, 322, 4007, 298, 3521, 298, 7354, 7377, 14, 221, 12823, 440, 943, 642, 1125, 4020, 367, 959, 298, 3521, 298, 4515, 2122, 450, 291, 14, 2921, 14, 354, 776, 355, 291, 14, 12419, 63, 14394, 275, 715, 288, 372, 715, 257, 327, 2549, 275, 22002, 267, 372, 756, 420, 327, 3055, 275, 440, 22002, 339, 347, 3105, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 423, 6409, 12910, 8, 1896, 275, 10990, 304, 288, 291, 14, 2921, 14, 1757, 8, 1328, 19166, 589, 12, 1011, 958, 9, 339, 347, 2256, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 440, 291, 423, 6409, 12910, 8, 1896, 275, 24008, 304, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
marctc/django
tests/gis_tests/relatedapp/tests.py
199
15937
from __future__ import unicode_literals from django.contrib.gis.db.models import F, Collect, Count, Extent, Union from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.geos import GEOSGeometry, MultiPoint, Point from django.db import connection from django.test import TestCase, ignore_warnings, skipUnlessDBFeature from django.test.utils import override_settings from django.utils import timezone from django.utils.deprecation import RemovedInDjango110Warning from ..utils import no_oracle from .models import ( Article, Author, Book, City, DirectoryEntry, Event, Location, Parcel, ) @skipUnlessDBFeature("gis_enabled") class RelatedGeoModelTest(TestCase): fixtures = ['initial'] def test02_select_related(self): "Testing `select_related` on geographic models (see #7126)." qs1 = City.objects.order_by('id') qs2 = City.objects.order_by('id').select_related() qs3 = City.objects.order_by('id').select_related('location') # Reference data for what's in the fixtures. cities = ( ('Aurora', 'TX', -97.516111, 33.058333), ('Roswell', 'NM', -104.528056, 33.387222), ('Kecksburg', 'PA', -79.460734, 40.18476), ) for qs in (qs1, qs2, qs3): for ref, c in zip(cities, qs): nm, st, lon, lat = ref self.assertEqual(nm, c.name) self.assertEqual(st, c.state) self.assertEqual(Point(lon, lat), c.location.point) @skipUnlessDBFeature("has_transform_method") def test03_transform_related(self): "Testing the `transform` GeoQuerySet method on related geographic models." # All the transformations are to state plane coordinate systems using # US Survey Feet (thus a tolerance of 0 implies error w/in 1 survey foot). tol = 0 def check_pnt(ref, pnt): self.assertAlmostEqual(ref.x, pnt.x, tol) self.assertAlmostEqual(ref.y, pnt.y, tol) self.assertEqual(ref.srid, pnt.srid) # Each city transformed to the SRID of their state plane coordinate system. transformed = (('Kecksburg', 2272, 'POINT(1490553.98959621 314792.131023984)'), ('Roswell', 2257, 'POINT(481902.189077221 868477.766629735)'), ('Aurora', 2276, 'POINT(2269923.2484839 7069381.28722222)'), ) for name, srid, wkt in transformed: # Doing this implicitly sets `select_related` select the location. # TODO: Fix why this breaks on Oracle. qs = list(City.objects.filter(name=name).transform(srid, field_name='location__point')) check_pnt(GEOSGeometry(wkt, srid), qs[0].location.point) @skipUnlessDBFeature("supports_extent_aggr") @ignore_warnings(category=RemovedInDjango110Warning) def test_related_extent_aggregate(self): "Testing the `extent` GeoQuerySet aggregates on related geographic models." # This combines the Extent and Union aggregates into one query aggs = City.objects.aggregate(Extent('location__point')) # One for all locations, one that excludes New Mexico (Roswell). all_extent = (-104.528056, 29.763374, -79.460734, 40.18476) txpa_extent = (-97.516111, 29.763374, -79.460734, 40.18476) e1 = City.objects.extent(field_name='location__point') e2 = City.objects.exclude(state='NM').extent(field_name='location__point') e3 = aggs['location__point__extent'] # The tolerance value is to four decimal places because of differences # between the Oracle and PostGIS spatial backends on the extent calculation. tol = 4 for ref, e in [(all_extent, e1), (txpa_extent, e2), (all_extent, e3)]: for ref_val, e_val in zip(ref, e): self.assertAlmostEqual(ref_val, e_val, tol) @skipUnlessDBFeature("supports_extent_aggr") def test_related_extent_annotate(self): """ Test annotation with Extent GeoAggregate. """ cities = City.objects.annotate(points_extent=Extent('location__point')).order_by('name') tol = 4 self.assertAlmostEqual( cities[0].points_extent, (-97.516111, 33.058333, -97.516111, 33.058333), tol ) @skipUnlessDBFeature("has_unionagg_method") @ignore_warnings(category=RemovedInDjango110Warning) def test_related_union_aggregate(self): "Testing the `unionagg` GeoQuerySet aggregates on related geographic models." # This combines the Extent and Union aggregates into one query aggs = City.objects.aggregate(Union('location__point')) # These are the points that are components of the aggregate geographic # union that is returned. Each point # corresponds to City PK. p1 = Point(-104.528056, 33.387222) p2 = Point(-97.516111, 33.058333) p3 = Point(-79.460734, 40.18476) p4 = Point(-96.801611, 32.782057) p5 = Point(-95.363151, 29.763374) # The second union aggregate is for a union # query that includes limiting information in the WHERE clause (in other # words a `.filter()` precedes the call to `.unionagg()`). ref_u1 = MultiPoint(p1, p2, p4, p5, p3, srid=4326) ref_u2 = MultiPoint(p2, p3, srid=4326) u1 = City.objects.unionagg(field_name='location__point') u2 = City.objects.exclude( name__in=('Roswell', 'Houston', 'Dallas', 'Fort Worth'), ).unionagg(field_name='location__point') u3 = aggs['location__point__union'] self.assertEqual(type(u1), MultiPoint) self.assertEqual(type(u3), MultiPoint) # Ordering of points in the result of the union is not defined and # implementation-dependent (DB backend, GEOS version) self.assertSetEqual({p.ewkt for p in ref_u1}, {p.ewkt for p in u1}) self.assertSetEqual({p.ewkt for p in ref_u2}, {p.ewkt for p in u2}) self.assertSetEqual({p.ewkt for p in ref_u1}, {p.ewkt for p in u3}) def test05_select_related_fk_to_subclass(self): "Testing that calling select_related on a query over a model with an FK to a model subclass works" # Regression test for #9752. list(DirectoryEntry.objects.all().select_related()) def test06_f_expressions(self): "Testing F() expressions on GeometryFields." # Constructing a dummy parcel border and getting the City instance for # assigning the FK. b1 = GEOSGeometry( 'POLYGON((-97.501205 33.052520,-97.501205 33.052576,' '-97.501150 33.052576,-97.501150 33.052520,-97.501205 33.052520))', srid=4326 ) pcity = City.objects.get(name='Aurora') # First parcel has incorrect center point that is equal to the City; # it also has a second border that is different from the first as a # 100ft buffer around the City. c1 = pcity.location.point c2 = c1.transform(2276, clone=True) b2 = c2.buffer(100) Parcel.objects.create(name='P1', city=pcity, center1=c1, center2=c2, border1=b1, border2=b2) # Now creating a second Parcel where the borders are the same, just # in different coordinate systems. The center points are also the # same (but in different coordinate systems), and this time they # actually correspond to the centroid of the border. c1 = b1.centroid c2 = c1.transform(2276, clone=True) Parcel.objects.create(name='P2', city=pcity, center1=c1, center2=c2, border1=b1, border2=b1) # Should return the second Parcel, which has the center within the # border. qs = Parcel.objects.filter(center1__within=F('border1')) self.assertEqual(1, len(qs)) self.assertEqual('P2', qs[0].name) if connection.features.supports_transform: # This time center2 is in a different coordinate system and needs # to be wrapped in transformation SQL. qs = Parcel.objects.filter(center2__within=F('border1')) self.assertEqual(1, len(qs)) self.assertEqual('P2', qs[0].name) # Should return the first Parcel, which has the center point equal # to the point in the City ForeignKey. qs = Parcel.objects.filter(center1=F('city__location__point')) self.assertEqual(1, len(qs)) self.assertEqual('P1', qs[0].name) if connection.features.supports_transform: # This time the city column should be wrapped in transformation SQL. qs = Parcel.objects.filter(border2__contains=F('city__location__point')) self.assertEqual(1, len(qs)) self.assertEqual('P1', qs[0].name) def test07_values(self): "Testing values() and values_list() and GeoQuerySets." gqs = Location.objects.all() gvqs = Location.objects.values() gvlqs = Location.objects.values_list() # Incrementing through each of the models, dictionaries, and tuples # returned by the different types of GeoQuerySets. for m, d, t in zip(gqs, gvqs, gvlqs): # The values should be Geometry objects and not raw strings returned # by the spatial database. self.assertIsInstance(d['point'], Geometry) self.assertIsInstance(t[1], Geometry) self.assertEqual(m.point, d['point']) self.assertEqual(m.point, t[1]) @override_settings(USE_TZ=True) def test_07b_values(self): "Testing values() and values_list() with aware datetime. See #21565." Event.objects.create(name="foo", when=timezone.now()) list(Event.objects.values_list('when')) def test08_defer_only(self): "Testing defer() and only() on Geographic models." qs = Location.objects.all() def_qs = Location.objects.defer('point') for loc, def_loc in zip(qs, def_qs): self.assertEqual(loc.point, def_loc.point) def test09_pk_relations(self): "Ensuring correct primary key column is selected across relations. See #10757." # The expected ID values -- notice the last two location IDs # are out of order. Dallas and Houston have location IDs that differ # from their PKs -- this is done to ensure that the related location # ID column is selected instead of ID column for the city. city_ids = (1, 2, 3, 4, 5) loc_ids = (1, 2, 3, 5, 4) ids_qs = City.objects.order_by('id').values('id', 'location__id') for val_dict, c_id, l_id in zip(ids_qs, city_ids, loc_ids): self.assertEqual(val_dict['id'], c_id) self.assertEqual(val_dict['location__id'], l_id) # TODO: fix on Oracle -- qs2 returns an empty result for an unknown reason @no_oracle def test10_combine(self): "Testing the combination of two GeoQuerySets. See #10807." buf1 = City.objects.get(name='Aurora').location.point.buffer(0.1) buf2 = City.objects.get(name='Kecksburg').location.point.buffer(0.1) qs1 = City.objects.filter(location__point__within=buf1) qs2 = City.objects.filter(location__point__within=buf2) combined = qs1 | qs2 names = [c.name for c in combined] self.assertEqual(2, len(names)) self.assertIn('Aurora', names) self.assertIn('Kecksburg', names) # TODO: fix on Oracle -- get the following error because the SQL is ordered # by a geometry object, which Oracle apparently doesn't like: # ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type @no_oracle def test12a_count(self): "Testing `Count` aggregate use with the `GeoManager` on geo-fields." # The City, 'Fort Worth' uses the same location as Dallas. dallas = City.objects.get(name='Dallas') # Count annotation should be 2 for the Dallas location now. loc = Location.objects.annotate(num_cities=Count('city')).get(id=dallas.location.id) self.assertEqual(2, loc.num_cities) def test12b_count(self): "Testing `Count` aggregate use with the `GeoManager` on non geo-fields. See #11087." # Should only be one author (Trevor Paglen) returned by this query, and # the annotation should have 3 for the number of books, see #11087. # Also testing with a values(), see #11489. qs = Author.objects.annotate(num_books=Count('books')).filter(num_books__gt=1) vqs = Author.objects.values('name').annotate(num_books=Count('books')).filter(num_books__gt=1) self.assertEqual(1, len(qs)) self.assertEqual(3, qs[0].num_books) self.assertEqual(1, len(vqs)) self.assertEqual(3, vqs[0]['num_books']) # TODO: fix on Oracle -- get the following error because the SQL is ordered # by a geometry object, which Oracle apparently doesn't like: # ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type @no_oracle def test13c_count(self): "Testing `Count` aggregate with `.values()`. See #15305." qs = Location.objects.filter(id=5).annotate(num_cities=Count('city')).values('id', 'point', 'num_cities') self.assertEqual(1, len(qs)) self.assertEqual(2, qs[0]['num_cities']) self.assertIsInstance(qs[0]['point'], GEOSGeometry) # TODO: The phantom model does appear on Oracle. @no_oracle def test13_select_related_null_fk(self): "Testing `select_related` on a nullable ForeignKey via `GeoManager`. See #11381." Book.objects.create(title='Without Author') b = Book.objects.select_related('author').get(title='Without Author') # Should be `None`, and not a 'dummy' model. self.assertIsNone(b.author) @skipUnlessDBFeature("supports_collect_aggr") @ignore_warnings(category=RemovedInDjango110Warning) def test_collect(self): """ Testing the (deprecated) `collect` GeoQuerySet method and `Collect` aggregate. """ # Reference query: # SELECT AsText(ST_Collect("relatedapp_location"."point")) FROM "relatedapp_city" LEFT OUTER JOIN # "relatedapp_location" ON ("relatedapp_city"."location_id" = "relatedapp_location"."id") # WHERE "relatedapp_city"."state" = 'TX'; ref_geom = GEOSGeometry( 'MULTIPOINT(-97.516111 33.058333,-96.801611 32.782057,' '-95.363151 29.763374,-96.801611 32.782057)' ) c1 = City.objects.filter(state='TX').collect(field_name='location__point') c2 = City.objects.filter(state='TX').aggregate(Collect('location__point'))['location__point__collect'] for coll in (c1, c2): # Even though Dallas and Ft. Worth share same point, Collect doesn't # consolidate -- that's why 4 points in MultiPoint. self.assertEqual(4, len(coll)) self.assertTrue(ref_geom.equals(coll)) def test15_invalid_select_related(self): "Testing doing select_related on the related name manager of a unique FK. See #13934." qs = Article.objects.select_related('author__article') # This triggers TypeError when `get_default_columns` has no `local_only` # keyword. The TypeError is swallowed if QuerySet is actually # evaluated as list generation swallows TypeError in CPython. str(qs.query) def test16_annotated_date_queryset(self): "Ensure annotated date querysets work if spatial backend is used. See #14648." birth_years = [dt.year for dt in list(Author.objects.annotate(num_books=Count('books')).dates('dob', 'year'))] birth_years.sort() self.assertEqual([1950, 1974], birth_years) # TODO: Related tests for KML, GML, and distance lookups.
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 492, 481, 12, 19649, 12, 14826, 12, 1316, 767, 12, 15961, 199, 504, 1639, 14, 2828, 14, 5668, 14, 7660, 14, 4620, 492, 10579, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21479, 12, 6879, 3428, 12, 7584, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 7640, 12, 3686, 63, 5451, 12, 3372, 5524, 18093, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 6019, 3849, 199, 199, 504, 2508, 1208, 492, 949, 63, 16404, 199, 504, 1275, 992, 492, 334, 272, 8281, 12, 6529, 12, 8944, 12, 14753, 12, 15191, 3900, 12, 6763, 12, 12625, 12, 2235, 6067, 12, 199, 9, 421, 199, 32, 22424, 480, 5668, 63, 3827, 531, 199, 533, 20116, 10748, 1685, 774, 8, 1746, 304, 272, 15188, 275, 788, 2747, 418, 339, 347, 511, 996, 63, 2416, 63, 2407, 8, 277, 304, 267, 298, 9029, 658, 2416, 63, 2407, 64, 641, 25637, 1709, 334, 3239, 327, 23, 7957, 17617, 267, 6377, 17, 275, 14753, 14, 1462, 14, 1648, 63, 991, 360, 344, 358, 267, 6377, 18, 275, 14753, 14, 1462, 14, 1648, 63, 991, 360, 344, 1959, 2416, 63, 2407, 342, 267, 6377, 19, 275, 14753, 14, 1462, 14, 1648, 63, 991, 360, 344, 1959, 2416, 63, 2407, 360, 1985, 358, 398, 327, 10944, 666, 367, 4052, 1159, 315, 314, 15188, 14, 267, 286, 12107, 275, 334, 288, 661, 33, 300, 11131, 297, 283, 10051, 297, 446, 2576, 14, 23691, 6673, 12, 9404, 14, 18009, 11769, 395, 288, 661, 50, 736, 20501, 297, 283, 21942, 297, 446, 6785, 14, 2528, 1257, 1367, 12, 9404, 14, 12399, 9485, 395, 288, 661, 1136, 5618, 29291, 297, 283, 8470, 297, 446, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 395, 267, 776, 398, 367, 6377, 315, 334, 6177, 17, 12, 6377, 18, 12, 6377, 19, 304, 288, 367, 2984, 12, 286, 315, 3482, 8, 18207, 12, 6377, 304, 355, 16751, 12, 410, 12, 6132, 12, 8396, 275, 2984, 355, 291, 14, 629, 8, 10756, 12, 286, 14, 354, 9, 355, 291, 14, 629, 8, 270, 12, 286, 14, 929, 9, 355, 291, 14, 629, 8, 3428, 8, 5298, 12, 8396, 395, 286, 14, 1985, 14, 1403, 9, 339, 768, 22424, 480, 1989, 63, 4711, 63, 765, 531, 272, 347, 511, 1644, 63, 4711, 63, 2407, 8, 277, 304, 267, 298, 9029, 314, 658, 4711, 64, 25587, 1083, 641, 4048, 25637, 1709, 2122, 267, 327, 2900, 314, 25947, 787, 370, 1174, 16388, 10021, 10460, 1808, 267, 327, 19635, 29013, 7949, 386, 334, 273, 527, 282, 13464, 402, 378, 22660, 1125, 336, 15, 262, 413, 16576, 18913, 680, 267, 9561, 275, 378, 398, 347, 1104, 63, 24519, 8, 1121, 12, 19948, 304, 288, 291, 14, 7904, 8, 1121, 14, 88, 12, 19948, 14, 88, 12, 9561, 9, 288, 291, 14, 7904, 8, 1121, 14, 89, 12, 19948, 14, 89, 12, 9561, 9, 288, 291, 14, 629, 8, 1121, 14, 10498, 12, 19948, 14, 10498, 9, 398, 327, 7048, 14492, 14834, 370, 314, 22425, 402, 3932, 1174, 16388, 10021, 2656, 14, 267, 14834, 275, 13636, 1136, 5618, 29291, 297, 499, 12900, 12, 283, 7217, 8, 1079, 2710, 24412, 14, 30924, 15112, 2025, 29182, 22364, 14, 969, 7759, 1355, 1349, 11218, 2432, 661, 50, 736, 20501, 297, 499, 11551, 12, 283, 7217, 8, 2006, 1167, 996, 14, 1085, 2710, 1138, 11564, 10300, 1349, 1138, 14, 23, 11829, 12615, 1276, 11218, 2432, 661, 33, 300, 11131, 297, 499, 13319, 12, 283, 7217, 8, 11085, 1020, 1789, 14, 1194, 15186, 1355, 1520, 18264, 16706, 14, 11884, 1081, 9485, 11218, 2432, 776, 398, 367, 536, 12, 15627, 12, 21992, 315, 14834, 26, 288, 327, 4226, 316, 642, 19796, 5951, 658, 2416, 63, 2407, 64, 3504, 314, 2909, 14, 288, 327, 3254, 26, 14811, 10842, 642, 18277, 641, 15309, 14, 288, 6377, 275, 769, 8, 17024, 14, 1462, 14, 1541, 8, 354, 29, 354, 680, 4711, 8, 10498, 12, 901, 63, 354, 534, 1985, 363, 1403, 1333, 288, 1104, 63, 24519, 8, 14151, 6831, 8, 11412, 12, 15627, 395, 6377, 59, 16, 1055, 1985, 14, 1403, 9, 339, 768, 22424, 480, 9823, 63, 11599, 63, 32027, 531, 272, 768, 4247, 63, 5451, 8, 3710, 29, 497, 19797, 6019, 3849, 9, 272, 347, 511, 63, 2407, 63, 11599, 63, 7516, 8, 277, 304, 267, 298, 9029, 314, 658, 11599, 64, 25587, 27535, 641, 4048, 25637, 1709, 2122, 267, 327, 961, 5300, 3746, 314, 1316, 767, 436, 15961, 27535, 1901, 1373, 1827, 267, 1839, 458, 275, 14753, 14, 1462, 14, 7516, 8, 19808, 360, 1985, 363, 1403, 1333, 398, 327, 7309, 367, 1006, 9918, 12, 1373, 626, 23388, 7053, 603, 476, 12802, 334, 50, 736, 20501, 680, 267, 1006, 63, 11599, 275, 5868, 6785, 14, 2528, 1257, 1367, 12, 7349, 14, 2114, 1153, 1342, 12, 446, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 9, 267, 4773, 387, 63, 11599, 275, 5868, 2576, 14, 23691, 6673, 12, 7349, 14, 2114, 1153, 1342, 12, 446, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 9, 267, 325, 17, 275, 14753, 14, 1462, 14, 11599, 8, 698, 63, 354, 534, 1985, 363, 1403, 358, 267, 325, 18, 275, 14753, 14, 1462, 14, 5473, 8, 929, 534, 21942, 1959, 11599, 8, 698, 63, 354, 534, 1985, 363, 1403, 358, 267, 325, 19, 275, 1839, 458, 459, 1985, 363, 1403, 363, 11599, 418, 398, 327, 710, 13464, 574, 365, 370, 11648, 6107, 9825, 2952, 402, 15109, 267, 327, 3382, 314, 15309, 436, 20929, 11469, 14745, 641, 314, 13675, 15232, 14, 267, 9561, 275, 841, 267, 367, 2984, 12, 325, 315, 3842, 452, 63, 11599, 12, 325, 17, 395, 334, 2347, 387, 63, 11599, 12, 325, 18, 395, 334, 452, 63, 11599, 12, 325, 19, 19532, 288, 367, 2984, 63, 637, 12, 325, 63, 637, 315, 3482, 8, 1121, 12, 325, 304, 355, 291, 14, 7904, 8, 1121, 63, 637, 12, 325, 63, 637, 12, 9561, 9 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 492, 481, 12, 19649, 12, 14826, 12, 1316, 767, 12, 15961, 199, 504, 1639, 14, 2828, 14, 5668, 14, 7660, 14, 4620, 492, 10579, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21479, 12, 6879, 3428, 12, 7584, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 396, 492, 7640, 12, 3686, 63, 5451, 12, 3372, 5524, 18093, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 6019, 3849, 199, 199, 504, 2508, 1208, 492, 949, 63, 16404, 199, 504, 1275, 992, 492, 334, 272, 8281, 12, 6529, 12, 8944, 12, 14753, 12, 15191, 3900, 12, 6763, 12, 12625, 12, 2235, 6067, 12, 199, 9, 421, 199, 32, 22424, 480, 5668, 63, 3827, 531, 199, 533, 20116, 10748, 1685, 774, 8, 1746, 304, 272, 15188, 275, 788, 2747, 418, 339, 347, 511, 996, 63, 2416, 63, 2407, 8, 277, 304, 267, 298, 9029, 658, 2416, 63, 2407, 64, 641, 25637, 1709, 334, 3239, 327, 23, 7957, 17617, 267, 6377, 17, 275, 14753, 14, 1462, 14, 1648, 63, 991, 360, 344, 358, 267, 6377, 18, 275, 14753, 14, 1462, 14, 1648, 63, 991, 360, 344, 1959, 2416, 63, 2407, 342, 267, 6377, 19, 275, 14753, 14, 1462, 14, 1648, 63, 991, 360, 344, 1959, 2416, 63, 2407, 360, 1985, 358, 398, 327, 10944, 666, 367, 4052, 1159, 315, 314, 15188, 14, 267, 286, 12107, 275, 334, 288, 661, 33, 300, 11131, 297, 283, 10051, 297, 446, 2576, 14, 23691, 6673, 12, 9404, 14, 18009, 11769, 395, 288, 661, 50, 736, 20501, 297, 283, 21942, 297, 446, 6785, 14, 2528, 1257, 1367, 12, 9404, 14, 12399, 9485, 395, 288, 661, 1136, 5618, 29291, 297, 283, 8470, 297, 446, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 395, 267, 776, 398, 367, 6377, 315, 334, 6177, 17, 12, 6377, 18, 12, 6377, 19, 304, 288, 367, 2984, 12, 286, 315, 3482, 8, 18207, 12, 6377, 304, 355, 16751, 12, 410, 12, 6132, 12, 8396, 275, 2984, 355, 291, 14, 629, 8, 10756, 12, 286, 14, 354, 9, 355, 291, 14, 629, 8, 270, 12, 286, 14, 929, 9, 355, 291, 14, 629, 8, 3428, 8, 5298, 12, 8396, 395, 286, 14, 1985, 14, 1403, 9, 339, 768, 22424, 480, 1989, 63, 4711, 63, 765, 531, 272, 347, 511, 1644, 63, 4711, 63, 2407, 8, 277, 304, 267, 298, 9029, 314, 658, 4711, 64, 25587, 1083, 641, 4048, 25637, 1709, 2122, 267, 327, 2900, 314, 25947, 787, 370, 1174, 16388, 10021, 10460, 1808, 267, 327, 19635, 29013, 7949, 386, 334, 273, 527, 282, 13464, 402, 378, 22660, 1125, 336, 15, 262, 413, 16576, 18913, 680, 267, 9561, 275, 378, 398, 347, 1104, 63, 24519, 8, 1121, 12, 19948, 304, 288, 291, 14, 7904, 8, 1121, 14, 88, 12, 19948, 14, 88, 12, 9561, 9, 288, 291, 14, 7904, 8, 1121, 14, 89, 12, 19948, 14, 89, 12, 9561, 9, 288, 291, 14, 629, 8, 1121, 14, 10498, 12, 19948, 14, 10498, 9, 398, 327, 7048, 14492, 14834, 370, 314, 22425, 402, 3932, 1174, 16388, 10021, 2656, 14, 267, 14834, 275, 13636, 1136, 5618, 29291, 297, 499, 12900, 12, 283, 7217, 8, 1079, 2710, 24412, 14, 30924, 15112, 2025, 29182, 22364, 14, 969, 7759, 1355, 1349, 11218, 2432, 661, 50, 736, 20501, 297, 499, 11551, 12, 283, 7217, 8, 2006, 1167, 996, 14, 1085, 2710, 1138, 11564, 10300, 1349, 1138, 14, 23, 11829, 12615, 1276, 11218, 2432, 661, 33, 300, 11131, 297, 499, 13319, 12, 283, 7217, 8, 11085, 1020, 1789, 14, 1194, 15186, 1355, 1520, 18264, 16706, 14, 11884, 1081, 9485, 11218, 2432, 776, 398, 367, 536, 12, 15627, 12, 21992, 315, 14834, 26, 288, 327, 4226, 316, 642, 19796, 5951, 658, 2416, 63, 2407, 64, 3504, 314, 2909, 14, 288, 327, 3254, 26, 14811, 10842, 642, 18277, 641, 15309, 14, 288, 6377, 275, 769, 8, 17024, 14, 1462, 14, 1541, 8, 354, 29, 354, 680, 4711, 8, 10498, 12, 901, 63, 354, 534, 1985, 363, 1403, 1333, 288, 1104, 63, 24519, 8, 14151, 6831, 8, 11412, 12, 15627, 395, 6377, 59, 16, 1055, 1985, 14, 1403, 9, 339, 768, 22424, 480, 9823, 63, 11599, 63, 32027, 531, 272, 768, 4247, 63, 5451, 8, 3710, 29, 497, 19797, 6019, 3849, 9, 272, 347, 511, 63, 2407, 63, 11599, 63, 7516, 8, 277, 304, 267, 298, 9029, 314, 658, 11599, 64, 25587, 27535, 641, 4048, 25637, 1709, 2122, 267, 327, 961, 5300, 3746, 314, 1316, 767, 436, 15961, 27535, 1901, 1373, 1827, 267, 1839, 458, 275, 14753, 14, 1462, 14, 7516, 8, 19808, 360, 1985, 363, 1403, 1333, 398, 327, 7309, 367, 1006, 9918, 12, 1373, 626, 23388, 7053, 603, 476, 12802, 334, 50, 736, 20501, 680, 267, 1006, 63, 11599, 275, 5868, 6785, 14, 2528, 1257, 1367, 12, 7349, 14, 2114, 1153, 1342, 12, 446, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 9, 267, 4773, 387, 63, 11599, 275, 5868, 2576, 14, 23691, 6673, 12, 7349, 14, 2114, 1153, 1342, 12, 446, 1965, 14, 2466, 1780, 1082, 12, 6335, 14, 10078, 2114, 9, 267, 325, 17, 275, 14753, 14, 1462, 14, 11599, 8, 698, 63, 354, 534, 1985, 363, 1403, 358, 267, 325, 18, 275, 14753, 14, 1462, 14, 5473, 8, 929, 534, 21942, 1959, 11599, 8, 698, 63, 354, 534, 1985, 363, 1403, 358, 267, 325, 19, 275, 1839, 458, 459, 1985, 363, 1403, 363, 11599, 418, 398, 327, 710, 13464, 574, 365, 370, 11648, 6107, 9825, 2952, 402, 15109, 267, 327, 3382, 314, 15309, 436, 20929, 11469, 14745, 641, 314, 13675, 15232, 14, 267, 9561, 275, 841, 267, 367, 2984, 12, 325, 315, 3842, 452, 63, 11599, 12, 325, 17, 395, 334, 2347, 387, 63, 11599, 12, 325, 18, 395, 334, 452, 63, 11599, 12, 325, 19, 19532, 288, 367, 2984, 63, 637, 12, 325, 63, 637, 315, 3482, 8, 1121, 12, 325, 304, 355, 291, 14, 7904, 8, 1121, 63, 637, 12, 325, 63, 637, 12, 9561, 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,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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 ]
ThiagoGarciaAlves/three.js
utils/exporters/blender/addons/io_three/exporter/utilities.py
225
1229
import uuid import hashlib from .. import constants ROUND = constants.DEFAULT_PRECISION def bit_mask(flags): """Generate a bit mask. :type flags: dict :return: int """ bit = 0 true = lambda x, y: (x | (1 << y)) false = lambda x, y: (x & (~(1 << y))) for mask, position in constants.MASK.items(): func = true if flags.get(mask) else false bit = func(bit, position) return bit def hash(value): """Generate a hash from a given value :param value: :rtype: str """ hash_ = hashlib.md5() hash_.update(repr(value).encode('utf8')) return hash_.hexdigest() def id(): """Generate a random UUID :rtype: str """ return str(uuid.uuid4()).upper() def id_from_name(name): """Generate a UUID using a name as the namespace :type name: str :rtype: str """ return str(uuid.uuid3(uuid.NAMESPACE_DNS, name)).upper() def rgb2int(rgb): """Convert a given rgb value to an integer :type rgb: list|tuple :rtype: int """ is_tuple = isinstance(rgb, tuple) rgb = list(rgb) if is_tuple else rgb colour = (int(rgb[0]*255) << 16) + (int(rgb[1]*255) << 8) + int(rgb[2]*255) return colour
mit
[ 646, 5377, 199, 646, 8337, 199, 199, 504, 2508, 492, 5262, 421, 199, 16848, 275, 5262, 14, 3472, 63, 14246, 30011, 421, 199, 318, 4546, 63, 2629, 8, 2469, 304, 272, 408, 6864, 282, 4546, 3656, 14, 339, 520, 466, 3285, 26, 1211, 272, 520, 1107, 26, 1109, 339, 408, 272, 4546, 275, 378, 272, 2549, 275, 2400, 671, 12, 612, 26, 334, 88, 1204, 334, 17, 5213, 612, 430, 272, 3055, 275, 2400, 671, 12, 612, 26, 334, 88, 1253, 31742, 8, 17, 5213, 612, 1724, 339, 367, 3656, 12, 3421, 315, 5262, 14, 12880, 14, 1744, 837, 267, 2562, 275, 2549, 340, 3285, 14, 362, 8, 2629, 9, 587, 3055, 267, 4546, 275, 2562, 8, 2075, 12, 3421, 9, 339, 372, 4546, 421, 199, 318, 2631, 8, 585, 304, 272, 408, 6864, 282, 2631, 687, 282, 1627, 574, 339, 520, 635, 574, 26, 272, 520, 4500, 26, 620, 339, 408, 272, 2631, 63, 275, 8337, 14, 1064, 21, 342, 272, 2631, 3754, 873, 8, 2722, 8, 585, 680, 2143, 360, 1624, 24, 1333, 272, 372, 2631, 3754, 11453, 342, 421, 199, 318, 1305, 837, 272, 408, 6864, 282, 2196, 11134, 339, 520, 4500, 26, 620, 339, 408, 272, 372, 620, 8, 2580, 14, 2580, 20, 8801, 4142, 342, 421, 199, 318, 1305, 63, 504, 63, 354, 8, 354, 304, 272, 408, 6864, 282, 11134, 1808, 282, 536, 465, 314, 3231, 339, 520, 466, 536, 26, 620, 272, 520, 4500, 26, 620, 339, 408, 272, 372, 620, 8, 2580, 14, 2580, 19, 8, 2580, 14, 13001, 63, 12323, 12, 536, 4992, 4142, 342, 421, 199, 318, 15180, 18, 442, 8, 10090, 304, 272, 408, 7306, 282, 1627, 15180, 574, 370, 376, 3000, 339, 520, 466, 15180, 26, 769, 92, 2960, 272, 520, 4500, 26, 1109, 339, 408, 272, 365, 63, 2960, 275, 1228, 8, 10090, 12, 2008, 9, 272, 15180, 275, 769, 8, 10090, 9, 340, 365, 63, 2960, 587, 15180, 339, 15706, 275, 334, 442, 8, 10090, 59, 16, 3672, 2299, 9, 5213, 3193, 9, 435, 334, 442, 8, 10090, 59, 17, 3672, 2299, 9, 5213, 1695, 9, 435, 1109, 8, 10090, 59, 18, 3672, 2299, 9, 272, 372, 15706, 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 ]
[ 5377, 199, 646, 8337, 199, 199, 504, 2508, 492, 5262, 421, 199, 16848, 275, 5262, 14, 3472, 63, 14246, 30011, 421, 199, 318, 4546, 63, 2629, 8, 2469, 304, 272, 408, 6864, 282, 4546, 3656, 14, 339, 520, 466, 3285, 26, 1211, 272, 520, 1107, 26, 1109, 339, 408, 272, 4546, 275, 378, 272, 2549, 275, 2400, 671, 12, 612, 26, 334, 88, 1204, 334, 17, 5213, 612, 430, 272, 3055, 275, 2400, 671, 12, 612, 26, 334, 88, 1253, 31742, 8, 17, 5213, 612, 1724, 339, 367, 3656, 12, 3421, 315, 5262, 14, 12880, 14, 1744, 837, 267, 2562, 275, 2549, 340, 3285, 14, 362, 8, 2629, 9, 587, 3055, 267, 4546, 275, 2562, 8, 2075, 12, 3421, 9, 339, 372, 4546, 421, 199, 318, 2631, 8, 585, 304, 272, 408, 6864, 282, 2631, 687, 282, 1627, 574, 339, 520, 635, 574, 26, 272, 520, 4500, 26, 620, 339, 408, 272, 2631, 63, 275, 8337, 14, 1064, 21, 342, 272, 2631, 3754, 873, 8, 2722, 8, 585, 680, 2143, 360, 1624, 24, 1333, 272, 372, 2631, 3754, 11453, 342, 421, 199, 318, 1305, 837, 272, 408, 6864, 282, 2196, 11134, 339, 520, 4500, 26, 620, 339, 408, 272, 372, 620, 8, 2580, 14, 2580, 20, 8801, 4142, 342, 421, 199, 318, 1305, 63, 504, 63, 354, 8, 354, 304, 272, 408, 6864, 282, 11134, 1808, 282, 536, 465, 314, 3231, 339, 520, 466, 536, 26, 620, 272, 520, 4500, 26, 620, 339, 408, 272, 372, 620, 8, 2580, 14, 2580, 19, 8, 2580, 14, 13001, 63, 12323, 12, 536, 4992, 4142, 342, 421, 199, 318, 15180, 18, 442, 8, 10090, 304, 272, 408, 7306, 282, 1627, 15180, 574, 370, 376, 3000, 339, 520, 466, 15180, 26, 769, 92, 2960, 272, 520, 4500, 26, 1109, 339, 408, 272, 365, 63, 2960, 275, 1228, 8, 10090, 12, 2008, 9, 272, 15180, 275, 769, 8, 10090, 9, 340, 365, 63, 2960, 587, 15180, 339, 15706, 275, 334, 442, 8, 10090, 59, 16, 3672, 2299, 9, 5213, 3193, 9, 435, 334, 442, 8, 10090, 59, 17, 3672, 2299, 9, 5213, 1695, 9, 435, 1109, 8, 10090, 59, 18, 3672, 2299, 9, 272, 372, 15706, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
jzoldak/edx-platform
openedx/core/djangoapps/cors_csrf/views.py
10
2496
"""Views for enabling cross-domain requests. """ import logging import json from django.conf import settings from django.views.decorators.cache import cache_page from django.http import HttpResponseNotFound from edxmako.shortcuts import render_to_response from .models import XDomainProxyConfiguration log = logging.getLogger(__name__) XDOMAIN_PROXY_CACHE_TIMEOUT = getattr(settings, 'XDOMAIN_PROXY_CACHE_TIMEOUT', 60 * 15) @cache_page(XDOMAIN_PROXY_CACHE_TIMEOUT) def xdomain_proxy(request): # pylint: disable=unused-argument """Serve the xdomain proxy page. Internet Explorer 9 does not send cookie information with CORS, which means we can't make cross-domain POST requests that require authentication (for example, from the course details page on the marketing site to the enrollment API to auto-enroll a user in an "honor" track). The XDomain library [https://github.com/jpillora/xdomain] provides an alternative to using CORS. The library works as follows: 1) A static HTML file ("xdomain_proxy.html") is served from courses.edx.org. The file includes JavaScript and a domain whitelist. 2) The course details page (on edx.org) creates an invisible iframe that loads the proxy HTML file. 3) A JS shim library on the course details page intercepts AJAX requests and communicates with JavaScript on the iframed page. The iframed page then proxies the request to the LMS. Since the iframed page is served from courses.edx.org, this is a same-domain request, so all cookies for the domain are sent along with the request. You can enable this feature and configure the domain whitelist using Django admin. """ config = XDomainProxyConfiguration.current() if not config.enabled: return HttpResponseNotFound() allowed_domains = [] for domain in config.whitelist.split("\n"): if domain.strip(): allowed_domains.append(domain.strip()) if not allowed_domains: log.warning( u"No whitelist configured for cross-domain proxy. " u"You can configure the whitelist in Django Admin " u"using the XDomainProxyConfiguration model." ) return HttpResponseNotFound() context = { 'xdomain_masters': json.dumps({ domain: '*' for domain in allowed_domains }) } return render_to_response('cors_csrf/xdomain_proxy.html', context)
agpl-3.0
[ 624, 21180, 367, 29310, 8059, 13, 2261, 4145, 14, 408, 199, 646, 2050, 199, 646, 2022, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 2581, 63, 1606, 199, 504, 1639, 14, 1014, 492, 6183, 4667, 199, 504, 22435, 19491, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 199, 504, 1275, 992, 492, 1323, 7705, 4936, 5688, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 56, 7378, 63, 20026, 63, 8677, 63, 8899, 275, 2519, 8, 1751, 12, 283, 56, 7378, 63, 20026, 63, 8677, 63, 8899, 297, 5212, 627, 4114, 9, 421, 199, 32, 1637, 63, 1606, 8, 56, 7378, 63, 20026, 63, 8677, 63, 8899, 9, 199, 318, 671, 2261, 63, 3280, 8, 1069, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 272, 408, 1505, 432, 314, 671, 2261, 4566, 2034, 14, 339, 22026, 7910, 22732, 1749, 1630, 440, 3222, 5494, 2556, 543, 445, 4149, 12, 272, 1314, 4910, 781, 883, 1133, 1852, 8059, 13, 2261, 8761, 4145, 626, 272, 4409, 6299, 334, 509, 2893, 12, 687, 314, 2518, 2436, 272, 2034, 641, 314, 2216, 13800, 4770, 370, 314, 14869, 3261, 272, 370, 2599, 13, 14695, 282, 922, 315, 376, 298, 19923, 2, 4426, 680, 339, 710, 1323, 7705, 3555, 359, 2859, 921, 5031, 14, 957, 15, 11538, 778, 11131, 15, 88, 2261, 61, 272, 6571, 376, 13943, 370, 1808, 445, 4149, 14, 339, 710, 3555, 5419, 465, 11924, 26, 339, 413, 9, 437, 2955, 4163, 570, 1689, 88, 2261, 63, 3280, 14, 1360, 531, 365, 19733, 687, 13588, 14, 8268, 14, 1308, 14, 2126, 710, 570, 6952, 15250, 436, 282, 2881, 22671, 14, 339, 499, 9, 710, 2518, 2436, 2034, 334, 265, 22435, 14, 1308, 9, 8491, 376, 315, 6604, 340, 1186, 2126, 626, 14404, 314, 4566, 4163, 570, 14, 339, 650, 9, 437, 18001, 25905, 3555, 641, 314, 2518, 2436, 2034, 13926, 83, 2126, 437, 42, 9839, 4145, 436, 13882, 2335, 543, 15250, 641, 314, 340, 1186, 68, 2034, 14, 2126, 710, 340, 1186, 68, 2034, 2066, 14942, 314, 1056, 370, 314, 27540, 14, 2126, 9336, 314, 340, 1186, 68, 2034, 365, 19733, 687, 13588, 14, 8268, 14, 1308, 12, 2126, 642, 365, 282, 2011, 13, 2261, 1056, 12, 880, 1006, 10049, 367, 314, 2881, 2126, 787, 4847, 3180, 543, 314, 1056, 14, 339, 2047, 883, 4756, 642, 3878, 436, 7908, 314, 2881, 22671, 272, 1808, 5634, 4628, 14, 339, 408, 272, 1101, 275, 1323, 7705, 4936, 5688, 14, 1818, 342, 272, 340, 440, 1101, 14, 3827, 26, 267, 372, 6183, 4667, 342, 339, 4370, 63, 9756, 275, 942, 272, 367, 2881, 315, 1101, 14, 14189, 14, 1294, 4582, 78, 2349, 267, 340, 2881, 14, 1913, 837, 288, 4370, 63, 9756, 14, 740, 8, 2261, 14, 1913, 1012, 339, 340, 440, 4370, 63, 9756, 26, 267, 943, 14, 3764, 8, 288, 399, 2, 1944, 22671, 7526, 367, 8059, 13, 2261, 4566, 14, 298, 288, 399, 2, 5556, 883, 7908, 314, 22671, 315, 5634, 9516, 298, 288, 399, 2, 4941, 314, 1323, 7705, 4936, 5688, 1402, 2122, 267, 776, 267, 372, 6183, 4667, 342, 339, 1067, 275, 469, 267, 283, 88, 2261, 63, 5892, 878, 356, 2022, 14, 4180, 2561, 288, 2881, 26, 13626, 288, 367, 2881, 315, 4370, 63, 9756, 267, 3828, 272, 789, 272, 372, 3795, 63, 475, 63, 1310, 360, 30967, 63, 10088, 15, 88, 2261, 63, 3280, 14, 1360, 297, 1067, 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 ]
[ 21180, 367, 29310, 8059, 13, 2261, 4145, 14, 408, 199, 646, 2050, 199, 646, 2022, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 2581, 63, 1606, 199, 504, 1639, 14, 1014, 492, 6183, 4667, 199, 504, 22435, 19491, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 199, 504, 1275, 992, 492, 1323, 7705, 4936, 5688, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 56, 7378, 63, 20026, 63, 8677, 63, 8899, 275, 2519, 8, 1751, 12, 283, 56, 7378, 63, 20026, 63, 8677, 63, 8899, 297, 5212, 627, 4114, 9, 421, 199, 32, 1637, 63, 1606, 8, 56, 7378, 63, 20026, 63, 8677, 63, 8899, 9, 199, 318, 671, 2261, 63, 3280, 8, 1069, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 272, 408, 1505, 432, 314, 671, 2261, 4566, 2034, 14, 339, 22026, 7910, 22732, 1749, 1630, 440, 3222, 5494, 2556, 543, 445, 4149, 12, 272, 1314, 4910, 781, 883, 1133, 1852, 8059, 13, 2261, 8761, 4145, 626, 272, 4409, 6299, 334, 509, 2893, 12, 687, 314, 2518, 2436, 272, 2034, 641, 314, 2216, 13800, 4770, 370, 314, 14869, 3261, 272, 370, 2599, 13, 14695, 282, 922, 315, 376, 298, 19923, 2, 4426, 680, 339, 710, 1323, 7705, 3555, 359, 2859, 921, 5031, 14, 957, 15, 11538, 778, 11131, 15, 88, 2261, 61, 272, 6571, 376, 13943, 370, 1808, 445, 4149, 14, 339, 710, 3555, 5419, 465, 11924, 26, 339, 413, 9, 437, 2955, 4163, 570, 1689, 88, 2261, 63, 3280, 14, 1360, 531, 365, 19733, 687, 13588, 14, 8268, 14, 1308, 14, 2126, 710, 570, 6952, 15250, 436, 282, 2881, 22671, 14, 339, 499, 9, 710, 2518, 2436, 2034, 334, 265, 22435, 14, 1308, 9, 8491, 376, 315, 6604, 340, 1186, 2126, 626, 14404, 314, 4566, 4163, 570, 14, 339, 650, 9, 437, 18001, 25905, 3555, 641, 314, 2518, 2436, 2034, 13926, 83, 2126, 437, 42, 9839, 4145, 436, 13882, 2335, 543, 15250, 641, 314, 340, 1186, 68, 2034, 14, 2126, 710, 340, 1186, 68, 2034, 2066, 14942, 314, 1056, 370, 314, 27540, 14, 2126, 9336, 314, 340, 1186, 68, 2034, 365, 19733, 687, 13588, 14, 8268, 14, 1308, 12, 2126, 642, 365, 282, 2011, 13, 2261, 1056, 12, 880, 1006, 10049, 367, 314, 2881, 2126, 787, 4847, 3180, 543, 314, 1056, 14, 339, 2047, 883, 4756, 642, 3878, 436, 7908, 314, 2881, 22671, 272, 1808, 5634, 4628, 14, 339, 408, 272, 1101, 275, 1323, 7705, 4936, 5688, 14, 1818, 342, 272, 340, 440, 1101, 14, 3827, 26, 267, 372, 6183, 4667, 342, 339, 4370, 63, 9756, 275, 942, 272, 367, 2881, 315, 1101, 14, 14189, 14, 1294, 4582, 78, 2349, 267, 340, 2881, 14, 1913, 837, 288, 4370, 63, 9756, 14, 740, 8, 2261, 14, 1913, 1012, 339, 340, 440, 4370, 63, 9756, 26, 267, 943, 14, 3764, 8, 288, 399, 2, 1944, 22671, 7526, 367, 8059, 13, 2261, 4566, 14, 298, 288, 399, 2, 5556, 883, 7908, 314, 22671, 315, 5634, 9516, 298, 288, 399, 2, 4941, 314, 1323, 7705, 4936, 5688, 1402, 2122, 267, 776, 267, 372, 6183, 4667, 342, 339, 1067, 275, 469, 267, 283, 88, 2261, 63, 5892, 878, 356, 2022, 14, 4180, 2561, 288, 2881, 26, 13626, 288, 367, 2881, 315, 4370, 63, 9756, 267, 3828, 272, 789, 272, 372, 3795, 63, 475, 63, 1310, 360, 30967, 63, 10088, 15, 88, 2261, 63, 3280, 14, 1360, 297, 1067, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
iulian787/spack
var/spack/repos/builtin/packages/double-conversion/package.py
5
1446
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class DoubleConversion(CMakePackage): """This project (double-conversion) provides binary-decimal and decimal-binary routines for IEEE doubles. The library consists of efficient conversion routines that have been extracted from the V8 JavaScript engine. The code has been refactored and improved so that it can be used more easily in other projects. There is extensive documentation in src/double-conversion.h. Other examples can be found in test/cctest/test-conversions.cc. """ homepage = "https://github.com/google/double-conversion" url = "https://github.com/google/double-conversion/archive/v2.0.1.zip" version('2.0.1', sha256='476aefbdc2051bbcca0d5919ebc293c90a7ad2c0cb6c4ad877d6e665f469146b') version('2.0.0', sha256='437df89059bfa6c1c0f8703693c2584a57f75289ed7020d801c9befb23f46a26') version('1.1.5', sha256='496fd3354fa0ff17562907632f5560c1d444ea98b6069f1436fa573949b94fb0') version('1.1.4', sha256='24b5edce8c88f0f632c83e60e0bde11252656dc3b714ba195619c1798ff28834') version('1.1.3', sha256='f0d1b8621592a3cf010c04c3e1c0f08455fc0fc7ee22e1583e2a63dc6d3e3871') def cmake_args(self): return ['-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true']
lgpl-2.1
[ 3, 1898, 6171, 13, 13934, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 436, 1163, 199, 3, 428, 1389, 7290, 23493, 14, 1666, 314, 2746, 13, 1896, 5877, 570, 367, 2436, 14, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 334, 28993, 13, 18, 14, 16, 1549, 10697, 9, 199, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 22945, 20403, 8, 27984, 8599, 304, 272, 408, 2765, 2199, 334, 3157, 13, 15083, 9, 6571, 3366, 13, 6355, 436, 6107, 13, 3008, 272, 14975, 367, 473, 29146, 4270, 83, 14, 339, 710, 3555, 18581, 402, 13402, 8603, 14975, 626, 1172, 2757, 272, 12509, 687, 314, 812, 24, 15250, 6869, 14, 710, 1233, 965, 2757, 295, 7783, 2908, 272, 436, 1742, 26429, 880, 626, 652, 883, 506, 1202, 1655, 16174, 315, 1163, 11336, 14, 339, 6006, 365, 2178, 3398, 3794, 315, 2928, 15, 3157, 13, 15083, 14, 72, 14, 5439, 7251, 272, 883, 506, 1911, 315, 511, 15, 2055, 396, 15, 396, 13, 388, 6234, 14, 2055, 14, 272, 408, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 3098, 15, 3157, 13, 15083, 2, 272, 1166, 420, 275, 298, 2859, 921, 5031, 14, 957, 15, 3098, 15, 3157, 13, 15083, 15, 6404, 15, 86, 18, 14, 16, 14, 17, 14, 3065, 2, 339, 1015, 360, 18, 14, 16, 14, 17, 297, 7793, 3912, 534, 22351, 65, 2829, 3691, 67, 1165, 2869, 27621, 696, 16, 68, 1427, 1167, 26816, 16417, 67, 2710, 65, 23, 350, 18, 67, 16, 2894, 22, 67, 20, 350, 24, 1138, 68, 22, 69, 16373, 70, 16112, 11432, 66, 358, 272, 1015, 360, 18, 14, 16, 14, 16, 297, 7793, 3912, 534, 21717, 1587, 13173, 1427, 66, 667, 22, 67, 17, 67, 16, 70, 15790, 1344, 3129, 67, 28681, 65, 1641, 70, 18778, 1407, 379, 23, 10173, 68, 26172, 67, 25, 1235, 4675, 1789, 70, 2466, 65, 1479, 358, 272, 1015, 360, 17, 14, 17, 14, 21, 297, 7793, 3912, 534, 18105, 2592, 1153, 1477, 667, 16, 556, 1196, 1367, 1398, 21439, 708, 70, 1229, 2259, 67, 17, 68, 18078, 4489, 2905, 66, 16220, 25, 70, 1079, 1344, 667, 1641, 1355, 1887, 66, 2635, 4675, 16, 358, 272, 1015, 360, 17, 14, 17, 14, 20, 297, 7793, 3912, 534, 1194, 66, 21, 379, 301, 24, 67, 1299, 70, 16, 70, 27250, 67, 2658, 69, 2259, 69, 16, 66, 271, 6094, 29227, 1367, 3833, 19, 66, 29044, 2470, 1167, 1367, 1167, 67, 1196, 2905, 556, 10740, 1082, 358, 272, 1015, 360, 17, 14, 17, 14, 19, 297, 7793, 3912, 534, 70, 16, 68, 17, 66, 1184, 7842, 2942, 65, 19, 2177, 9523, 67, 966, 67, 19, 69, 17, 67, 16, 70, 26107, 1229, 3003, 16, 3003, 23, 1024, 1081, 69, 1046, 2658, 69, 18, 65, 2766, 3833, 22, 68, 19, 69, 12399, 17, 358, 339, 347, 19773, 63, 589, 8, 277, 304, 267, 372, 11573, 5196, 18421, 63, 15717, 63, 568, 25743, 1309, 63, 6012, 26, 16026, 29, 2052, 418, 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 ]
[ 1898, 6171, 13, 13934, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 436, 1163, 199, 3, 428, 1389, 7290, 23493, 14, 1666, 314, 2746, 13, 1896, 5877, 570, 367, 2436, 14, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 334, 28993, 13, 18, 14, 16, 1549, 10697, 9, 199, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 22945, 20403, 8, 27984, 8599, 304, 272, 408, 2765, 2199, 334, 3157, 13, 15083, 9, 6571, 3366, 13, 6355, 436, 6107, 13, 3008, 272, 14975, 367, 473, 29146, 4270, 83, 14, 339, 710, 3555, 18581, 402, 13402, 8603, 14975, 626, 1172, 2757, 272, 12509, 687, 314, 812, 24, 15250, 6869, 14, 710, 1233, 965, 2757, 295, 7783, 2908, 272, 436, 1742, 26429, 880, 626, 652, 883, 506, 1202, 1655, 16174, 315, 1163, 11336, 14, 339, 6006, 365, 2178, 3398, 3794, 315, 2928, 15, 3157, 13, 15083, 14, 72, 14, 5439, 7251, 272, 883, 506, 1911, 315, 511, 15, 2055, 396, 15, 396, 13, 388, 6234, 14, 2055, 14, 272, 408, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 3098, 15, 3157, 13, 15083, 2, 272, 1166, 420, 275, 298, 2859, 921, 5031, 14, 957, 15, 3098, 15, 3157, 13, 15083, 15, 6404, 15, 86, 18, 14, 16, 14, 17, 14, 3065, 2, 339, 1015, 360, 18, 14, 16, 14, 17, 297, 7793, 3912, 534, 22351, 65, 2829, 3691, 67, 1165, 2869, 27621, 696, 16, 68, 1427, 1167, 26816, 16417, 67, 2710, 65, 23, 350, 18, 67, 16, 2894, 22, 67, 20, 350, 24, 1138, 68, 22, 69, 16373, 70, 16112, 11432, 66, 358, 272, 1015, 360, 18, 14, 16, 14, 16, 297, 7793, 3912, 534, 21717, 1587, 13173, 1427, 66, 667, 22, 67, 17, 67, 16, 70, 15790, 1344, 3129, 67, 28681, 65, 1641, 70, 18778, 1407, 379, 23, 10173, 68, 26172, 67, 25, 1235, 4675, 1789, 70, 2466, 65, 1479, 358, 272, 1015, 360, 17, 14, 17, 14, 21, 297, 7793, 3912, 534, 18105, 2592, 1153, 1477, 667, 16, 556, 1196, 1367, 1398, 21439, 708, 70, 1229, 2259, 67, 17, 68, 18078, 4489, 2905, 66, 16220, 25, 70, 1079, 1344, 667, 1641, 1355, 1887, 66, 2635, 4675, 16, 358, 272, 1015, 360, 17, 14, 17, 14, 20, 297, 7793, 3912, 534, 1194, 66, 21, 379, 301, 24, 67, 1299, 70, 16, 70, 27250, 67, 2658, 69, 2259, 69, 16, 66, 271, 6094, 29227, 1367, 3833, 19, 66, 29044, 2470, 1167, 1367, 1167, 67, 1196, 2905, 556, 10740, 1082, 358, 272, 1015, 360, 17, 14, 17, 14, 19, 297, 7793, 3912, 534, 70, 16, 68, 17, 66, 1184, 7842, 2942, 65, 19, 2177, 9523, 67, 966, 67, 19, 69, 17, 67, 16, 70, 26107, 1229, 3003, 16, 3003, 23, 1024, 1081, 69, 1046, 2658, 69, 18, 65, 2766, 3833, 22, 68, 19, 69, 12399, 17, 358, 339, 347, 19773, 63, 589, 8, 277, 304, 267, 372, 11573, 5196, 18421, 63, 15717, 63, 568, 25743, 1309, 63, 6012, 26, 16026, 29, 2052, 418, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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216
import re from SCons.Script import * # the usual scons stuff you get in a SConscript def generate(env): """ Add builders and construction variables for the SubstInFile tool. Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT from the source to the target. The values of SUBST_DICT first have any construction variables expanded (its keys are not expanded). If a value of SUBST_DICT is a python callable function, it is called and the result is expanded as the value. If there's more than one source and more than one target, each target gets substituted from the corresponding source. """ def do_subst_in_file(targetfile, sourcefile, dict): """Replace all instances of the keys of dict with their values. For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'}, then all instances of %VERSION% in the file will be replaced with 1.2345 etc. """ try: f = open(sourcefile, 'rb') contents = f.read() f.close() except: raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile for (k,v) in dict.items(): contents = re.sub(k, v, contents) try: f = open(targetfile, 'wb') f.write(contents) f.close() except: raise SCons.Errors.UserError, "Can't write target file %s"%targetfile return 0 # success def subst_in_file(target, source, env): if not env.has_key('SUBST_DICT'): raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set." d = dict(env['SUBST_DICT']) # copy it for (k,v) in d.items(): if callable(v): d[k] = env.subst(v()).replace('\\','\\\\') elif SCons.Util.is_String(v): d[k] = env.subst(v).replace('\\','\\\\') else: raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v)) for (t,s) in zip(target, source): return do_subst_in_file(str(t), str(s), d) def subst_in_file_string(target, source, env): """This is what gets printed on the console.""" return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t)) for (t,s) in zip(target, source)]) def subst_emitter(target, source, env): """Add dependency from substituted SUBST_DICT to target. Returns original target, source tuple unchanged. """ d = env['SUBST_DICT'].copy() # copy it for (k,v) in d.items(): if callable(v): d[k] = env.subst(v()) elif SCons.Util.is_String(v): d[k]=env.subst(v) Depends(target, SCons.Node.Python.Value(d)) return target, source ## env.Append(TOOLS = 'substinfile') # this should be automaticaly done by Scons ?!? subst_action = SCons.Action.Action( subst_in_file, subst_in_file_string ) env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter) def exists(env): """ Make sure tool exists. """ return True
apache-2.0
[ 646, 295, 199, 504, 8218, 14, 5229, 492, 627, 221, 327, 314, 20195, 31551, 8292, 1265, 664, 315, 282, 428, 29687, 199, 199, 318, 3550, 8, 1813, 304, 272, 408, 272, 2654, 27378, 436, 14538, 2860, 367, 314, 272, 4804, 270, 607, 1173, 4744, 14, 339, 15747, 4804, 270, 607, 1173, 6545, 12, 1314, 10004, 3862, 314, 2883, 5118, 1459, 402, 7605, 840, 63, 12511, 272, 687, 314, 1350, 370, 314, 1347, 14, 272, 710, 1338, 402, 7605, 840, 63, 12511, 1642, 1172, 1263, 14538, 2860, 11507, 272, 334, 1405, 2883, 787, 440, 11507, 680, 272, 982, 282, 574, 402, 7605, 840, 63, 12511, 365, 282, 2366, 4550, 805, 12, 652, 365, 2797, 436, 272, 314, 754, 365, 11507, 465, 314, 574, 14, 272, 982, 2337, 1159, 1655, 2419, 1373, 1350, 436, 1655, 2419, 1373, 1347, 12, 1924, 1347, 7545, 272, 10004, 4241, 687, 314, 5226, 1350, 14, 272, 408, 272, 347, 886, 63, 16747, 63, 262, 63, 493, 8, 1375, 493, 12, 1350, 493, 12, 1211, 304, 267, 408, 11328, 1006, 4454, 402, 314, 2883, 402, 1211, 543, 3932, 1338, 14, 267, 2104, 2893, 12, 340, 1211, 365, 791, 5, 4612, 5, 356, 283, 17, 14, 5533, 21, 297, 1543, 5825, 5, 356, 283, 5713, 919, 71, 2267, 267, 2066, 1006, 4454, 402, 450, 4612, 5, 315, 314, 570, 911, 506, 8717, 543, 413, 14, 5533, 21, 5423, 14, 267, 408, 267, 862, 26, 288, 289, 275, 1551, 8, 32666, 12, 283, 4848, 358, 288, 4072, 275, 289, 14, 739, 342, 288, 289, 14, 1600, 342, 267, 871, 26, 288, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 6049, 1133, 1586, 1350, 570, 450, 83, 6808, 32666, 267, 367, 334, 75, 12, 86, 9, 315, 1211, 14, 1744, 837, 288, 4072, 275, 295, 14, 954, 8, 75, 12, 373, 12, 4072, 9, 267, 862, 26, 288, 289, 275, 1551, 8, 1375, 493, 12, 283, 6603, 358, 288, 289, 14, 952, 8, 4407, 9, 288, 289, 14, 1600, 342, 267, 871, 26, 288, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 6049, 1133, 2218, 1347, 570, 450, 83, 6808, 1375, 493, 267, 372, 378, 327, 3182, 339, 347, 27321, 63, 262, 63, 493, 8, 1375, 12, 1350, 12, 2589, 304, 267, 340, 440, 2589, 14, 1989, 63, 498, 360, 6348, 840, 63, 12511, 735, 288, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 2610, 270, 607, 1173, 5074, 7605, 840, 63, 12511, 370, 506, 663, 2122, 267, 366, 275, 1211, 8, 1813, 459, 6348, 840, 63, 12511, 1105, 327, 1331, 652, 267, 367, 334, 75, 12, 86, 9, 315, 366, 14, 1744, 837, 288, 340, 4550, 8, 86, 304, 355, 366, 59, 75, 61, 275, 2589, 14, 16747, 8, 86, 8801, 1814, 11671, 1673, 8712, 358, 288, 916, 8218, 14, 9562, 14, 374, 63, 1558, 8, 86, 304, 355, 366, 59, 75, 61, 275, 2589, 14, 16747, 8, 86, 680, 1814, 11671, 1673, 8712, 358, 288, 587, 26, 355, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 2610, 270, 607, 1173, 26, 790, 450, 83, 26, 450, 83, 1471, 506, 282, 1059, 503, 4550, 14007, 75, 12, 4700, 8, 86, 430, 267, 367, 334, 84, 12, 83, 9, 315, 3482, 8, 1375, 12, 1350, 304, 288, 372, 886, 63, 16747, 63, 262, 63, 493, 8, 495, 8, 84, 395, 620, 8, 83, 395, 366, 9, 339, 347, 27321, 63, 262, 63, 493, 63, 875, 8, 1375, 12, 1350, 12, 2589, 304, 267, 408, 2765, 365, 4052, 7545, 12487, 641, 314, 8559, 1041, 267, 372, 1557, 78, 1370, 904, 2941, 2610, 6329, 4655, 6802, 687, 450, 83, 1901, 450, 83, 13328, 495, 8, 83, 395, 620, 8, 84, 430, 2079, 367, 334, 84, 12, 83, 9, 315, 3482, 8, 1375, 12, 1350, 3948, 339, 347, 27321, 63, 8159, 351, 8, 1375, 12, 1350, 12, 2589, 304, 267, 408, 1123, 5936, 687, 10004, 4241, 7605, 840, 63, 12511, 370, 1347, 14, 267, 1803, 3379, 1347, 12, 1350, 2008, 14874, 14, 267, 408, 267, 366, 275, 2589, 459, 6348, 840, 63, 12511, 2278, 1574, 342, 327, 1331, 652, 267, 367, 334, 75, 12, 86, 9, 315, 366, 14, 1744, 837, 288, 340, 4550, 8, 86, 304, 355, 366, 59, 75, 61, 275, 2589, 14, 16747, 8, 86, 1012, 288, 916, 8218, 14, 9562, 14, 374, 63, 1558, 8, 86, 304, 355, 366, 59, 75, 10404, 1813, 14, 16747, 8, 86, 9, 267, 21588, 3198, 8, 1375, 12, 8218, 14, 1716, 14, 4718, 14, 1110, 8, 68, 430, 267, 372, 1347, 12, 1350, 199, 199, 309, 259, 2589, 14, 8310, 8, 20261, 275, 283, 16747, 13880, 358, 755, 327, 642, 1077, 506, 4834, 2618, 4224, 701, 428, 8704, 5805, 1, 31, 272, 27321, 63, 1287, 275, 8218, 14, 3310, 14, 3310, 8, 27321, 63, 262, 63, 493, 12, 27321, 63, 262, 63, 493, 63, 875, 776, 272, 2589, 459, 8248, 3960, 2545, 2610, 270, 607, 1173, 418, 275, 19286, 8, 1287, 29, 16747, 63, 1287, 12, 8689, 351, 29, 16747, 63, 8159, 351, 9, 199, 199, 318, 3495, 8, 1813, 304, 272, 408, 272, 4155, 3238, 4744, 3495, 14, 272, 408, 272, 372, 715, 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 ]
[ 295, 199, 504, 8218, 14, 5229, 492, 627, 221, 327, 314, 20195, 31551, 8292, 1265, 664, 315, 282, 428, 29687, 199, 199, 318, 3550, 8, 1813, 304, 272, 408, 272, 2654, 27378, 436, 14538, 2860, 367, 314, 272, 4804, 270, 607, 1173, 4744, 14, 339, 15747, 4804, 270, 607, 1173, 6545, 12, 1314, 10004, 3862, 314, 2883, 5118, 1459, 402, 7605, 840, 63, 12511, 272, 687, 314, 1350, 370, 314, 1347, 14, 272, 710, 1338, 402, 7605, 840, 63, 12511, 1642, 1172, 1263, 14538, 2860, 11507, 272, 334, 1405, 2883, 787, 440, 11507, 680, 272, 982, 282, 574, 402, 7605, 840, 63, 12511, 365, 282, 2366, 4550, 805, 12, 652, 365, 2797, 436, 272, 314, 754, 365, 11507, 465, 314, 574, 14, 272, 982, 2337, 1159, 1655, 2419, 1373, 1350, 436, 1655, 2419, 1373, 1347, 12, 1924, 1347, 7545, 272, 10004, 4241, 687, 314, 5226, 1350, 14, 272, 408, 272, 347, 886, 63, 16747, 63, 262, 63, 493, 8, 1375, 493, 12, 1350, 493, 12, 1211, 304, 267, 408, 11328, 1006, 4454, 402, 314, 2883, 402, 1211, 543, 3932, 1338, 14, 267, 2104, 2893, 12, 340, 1211, 365, 791, 5, 4612, 5, 356, 283, 17, 14, 5533, 21, 297, 1543, 5825, 5, 356, 283, 5713, 919, 71, 2267, 267, 2066, 1006, 4454, 402, 450, 4612, 5, 315, 314, 570, 911, 506, 8717, 543, 413, 14, 5533, 21, 5423, 14, 267, 408, 267, 862, 26, 288, 289, 275, 1551, 8, 32666, 12, 283, 4848, 358, 288, 4072, 275, 289, 14, 739, 342, 288, 289, 14, 1600, 342, 267, 871, 26, 288, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 6049, 1133, 1586, 1350, 570, 450, 83, 6808, 32666, 267, 367, 334, 75, 12, 86, 9, 315, 1211, 14, 1744, 837, 288, 4072, 275, 295, 14, 954, 8, 75, 12, 373, 12, 4072, 9, 267, 862, 26, 288, 289, 275, 1551, 8, 1375, 493, 12, 283, 6603, 358, 288, 289, 14, 952, 8, 4407, 9, 288, 289, 14, 1600, 342, 267, 871, 26, 288, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 6049, 1133, 2218, 1347, 570, 450, 83, 6808, 1375, 493, 267, 372, 378, 327, 3182, 339, 347, 27321, 63, 262, 63, 493, 8, 1375, 12, 1350, 12, 2589, 304, 267, 340, 440, 2589, 14, 1989, 63, 498, 360, 6348, 840, 63, 12511, 735, 288, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 2610, 270, 607, 1173, 5074, 7605, 840, 63, 12511, 370, 506, 663, 2122, 267, 366, 275, 1211, 8, 1813, 459, 6348, 840, 63, 12511, 1105, 327, 1331, 652, 267, 367, 334, 75, 12, 86, 9, 315, 366, 14, 1744, 837, 288, 340, 4550, 8, 86, 304, 355, 366, 59, 75, 61, 275, 2589, 14, 16747, 8, 86, 8801, 1814, 11671, 1673, 8712, 358, 288, 916, 8218, 14, 9562, 14, 374, 63, 1558, 8, 86, 304, 355, 366, 59, 75, 61, 275, 2589, 14, 16747, 8, 86, 680, 1814, 11671, 1673, 8712, 358, 288, 587, 26, 355, 746, 8218, 14, 9298, 14, 1899, 547, 12, 298, 2610, 270, 607, 1173, 26, 790, 450, 83, 26, 450, 83, 1471, 506, 282, 1059, 503, 4550, 14007, 75, 12, 4700, 8, 86, 430, 267, 367, 334, 84, 12, 83, 9, 315, 3482, 8, 1375, 12, 1350, 304, 288, 372, 886, 63, 16747, 63, 262, 63, 493, 8, 495, 8, 84, 395, 620, 8, 83, 395, 366, 9, 339, 347, 27321, 63, 262, 63, 493, 63, 875, 8, 1375, 12, 1350, 12, 2589, 304, 267, 408, 2765, 365, 4052, 7545, 12487, 641, 314, 8559, 1041, 267, 372, 1557, 78, 1370, 904, 2941, 2610, 6329, 4655, 6802, 687, 450, 83, 1901, 450, 83, 13328, 495, 8, 83, 395, 620, 8, 84, 430, 2079, 367, 334, 84, 12, 83, 9, 315, 3482, 8, 1375, 12, 1350, 3948, 339, 347, 27321, 63, 8159, 351, 8, 1375, 12, 1350, 12, 2589, 304, 267, 408, 1123, 5936, 687, 10004, 4241, 7605, 840, 63, 12511, 370, 1347, 14, 267, 1803, 3379, 1347, 12, 1350, 2008, 14874, 14, 267, 408, 267, 366, 275, 2589, 459, 6348, 840, 63, 12511, 2278, 1574, 342, 327, 1331, 652, 267, 367, 334, 75, 12, 86, 9, 315, 366, 14, 1744, 837, 288, 340, 4550, 8, 86, 304, 355, 366, 59, 75, 61, 275, 2589, 14, 16747, 8, 86, 1012, 288, 916, 8218, 14, 9562, 14, 374, 63, 1558, 8, 86, 304, 355, 366, 59, 75, 10404, 1813, 14, 16747, 8, 86, 9, 267, 21588, 3198, 8, 1375, 12, 8218, 14, 1716, 14, 4718, 14, 1110, 8, 68, 430, 267, 372, 1347, 12, 1350, 199, 199, 309, 259, 2589, 14, 8310, 8, 20261, 275, 283, 16747, 13880, 358, 755, 327, 642, 1077, 506, 4834, 2618, 4224, 701, 428, 8704, 5805, 1, 31, 272, 27321, 63, 1287, 275, 8218, 14, 3310, 14, 3310, 8, 27321, 63, 262, 63, 493, 12, 27321, 63, 262, 63, 493, 63, 875, 776, 272, 2589, 459, 8248, 3960, 2545, 2610, 270, 607, 1173, 418, 275, 19286, 8, 1287, 29, 16747, 63, 1287, 12, 8689, 351, 29, 16747, 63, 8159, 351, 9, 199, 199, 318, 3495, 8, 1813, 304, 272, 408, 272, 4155, 3238, 4744, 3495, 14, 272, 408, 272, 372, 715, 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, 0 ]
[ 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
krafczyk/spack
var/spack/repos/builtin/packages/r-forcats/package.py
5
1945
############################################################################## # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-647188 # # For details, see https://github.com/spack/spack # Please also see the NOTICE and LICENSE files for our notice and the LGPL. # # This program 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) version 2.1, February 1999. # # 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 terms and # conditions of 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 program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * class RForcats(RPackage): """Helpers for reordering factor levels (including moving specified levels to front, ordering by first appearance, reversing, and randomly shuffling), and tools for modifying factor levels (including collapsing rare levels into other, 'anonymising', and manually 'recoding').""" homepage = "http://forcats.tidyverse.org/" url = "https://cran.r-project.org/src/contrib/forcats_0.2.0.tar.gz" list_url = "https://cran.r-project.org/src/contrib/Archive/forcats" version('0.2.0', 'e4ba2c0a59dcdfcc02274c519bf3dbfc') depends_on('r-tibble', type=('build', 'run')) depends_on('r-magrittr', type=('build', 'run'))
lgpl-2.1
[ 4605, 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 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, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 820, 1858, 25729, 8, 50, 8599, 304, 272, 408, 4433, 83, 367, 295, 7128, 6535, 11106, 334, 15768, 12876, 2013, 11106, 2126, 370, 13738, 12, 7794, 701, 1642, 7468, 554, 12, 29465, 1044, 12, 436, 19311, 2126, 28126, 2983, 395, 436, 7249, 367, 24662, 6535, 11106, 334, 15768, 1048, 4762, 1044, 2126, 24063, 11106, 1901, 1163, 12, 283, 290, 5220, 1292, 316, 297, 436, 10250, 283, 264, 1523, 358, 1041, 339, 26586, 275, 298, 1014, 921, 509, 25729, 14, 5700, 89, 2077, 14, 1308, 6687, 272, 1166, 420, 275, 298, 2859, 921, 67, 1312, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 509, 25729, 63, 16, 14, 18, 14, 16, 14, 5369, 14, 6838, 2, 272, 769, 63, 633, 275, 298, 2859, 921, 67, 1312, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 13042, 15, 509, 25729, 2, 339, 1015, 360, 16, 14, 18, 14, 16, 297, 283, 69, 20, 2470, 18, 67, 16, 65, 1427, 3833, 1587, 2055, 996, 9014, 67, 30432, 4361, 19, 697, 3003, 358, 339, 8350, 63, 265, 360, 82, 13, 280, 20541, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 5615, 11133, 454, 297, 730, 7782, 1506, 297, 283, 1065, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 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, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 820, 1858, 25729, 8, 50, 8599, 304, 272, 408, 4433, 83, 367, 295, 7128, 6535, 11106, 334, 15768, 12876, 2013, 11106, 2126, 370, 13738, 12, 7794, 701, 1642, 7468, 554, 12, 29465, 1044, 12, 436, 19311, 2126, 28126, 2983, 395, 436, 7249, 367, 24662, 6535, 11106, 334, 15768, 1048, 4762, 1044, 2126, 24063, 11106, 1901, 1163, 12, 283, 290, 5220, 1292, 316, 297, 436, 10250, 283, 264, 1523, 358, 1041, 339, 26586, 275, 298, 1014, 921, 509, 25729, 14, 5700, 89, 2077, 14, 1308, 6687, 272, 1166, 420, 275, 298, 2859, 921, 67, 1312, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 509, 25729, 63, 16, 14, 18, 14, 16, 14, 5369, 14, 6838, 2, 272, 769, 63, 633, 275, 298, 2859, 921, 67, 1312, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 13042, 15, 509, 25729, 2, 339, 1015, 360, 16, 14, 18, 14, 16, 297, 283, 69, 20, 2470, 18, 67, 16, 65, 1427, 3833, 1587, 2055, 996, 9014, 67, 30432, 4361, 19, 697, 3003, 358, 339, 8350, 63, 265, 360, 82, 13, 280, 20541, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 5615, 11133, 454, 297, 730, 7782, 1506, 297, 283, 1065, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0 ]
idncom/odoo
openerp/addons/test_new_api/tests/test_related.py
247
8446
# # test cases for related fields, etc. # import unittest from openerp.osv import fields from openerp.tests import common class TestRelatedField(common.TransactionCase): def setUp(self): super(TestRelatedField, self).setUp() self.partner = self.registry('res.partner') self.company = self.registry('res.company') def test_0_related(self): """ test an usual related field """ # find a company with a non-null partner_id ids = self.company.search(self.cr, self.uid, [('partner_id', '!=', False)], limit=1) id = ids[0] # find partners that satisfy [('partner_id.company_id', '=', id)] company_ids = self.company.search(self.cr, self.uid, [('partner_id', '=', id)]) partner_ids1 = self.partner.search(self.cr, self.uid, [('company_id', 'in', company_ids)]) partner_ids2 = self.partner.search(self.cr, self.uid, [('related_company_partner_id', '=', id)]) self.assertEqual(partner_ids1, partner_ids2) def do_test_company_field(self, field): # get a partner with a non-null company_id ids = self.partner.search(self.cr, self.uid, [('company_id', '!=', False)], limit=1) partner = self.partner.browse(self.cr, self.uid, ids[0]) # check reading related field self.assertEqual(partner[field], partner.company_id) # check that search on related field is equivalent to original field ids1 = self.partner.search(self.cr, self.uid, [('company_id', '=', partner.company_id.id)]) ids2 = self.partner.search(self.cr, self.uid, [(field, '=', partner.company_id.id)]) self.assertEqual(ids1, ids2) def test_1_single_related(self): """ test a related field with a single indirection like fields.related('foo') """ self.do_test_company_field('single_related_company_id') def test_2_related_related(self): """ test a related field referring to a related field """ self.do_test_company_field('related_related_company_id') def test_3_read_write(self): """ write on a related field """ # find a company with a non-null partner_id company_ids = self.company.search(self.cr, self.uid, [('partner_id', '!=', False)], limit=1) company = self.company.browse(self.cr, self.uid, company_ids[0]) # find partners that satisfy [('company_id.partner_id', '=', company.partner_id.id)] partner_ids = self.partner.search(self.cr, self.uid, [('related_company_partner_id', '=', company.partner_id.id)]) self.assertGreater(len(partner_ids), 0) partner = self.partner.browse(self.cr, self.uid, partner_ids[0]) # create a new partner, and assign it to company new_partner_id = self.partner.create(self.cr, self.uid, {'name': 'Foo'}) partner.write({'related_company_partner_id': new_partner_id}) company = self.company.browse(self.cr, self.uid, company_ids[0]) self.assertEqual(company.partner_id.id, new_partner_id) partner = self.partner.browse(self.cr, self.uid, partner_ids[0]) self.assertEqual(partner.related_company_partner_id.id, new_partner_id) class TestPropertyField(common.TransactionCase): def setUp(self): super(TestPropertyField, self).setUp() self.user = self.registry('res.users') self.partner = self.registry('res.partner') self.company = self.registry('res.company') self.country = self.registry('res.country') self.property = self.registry('ir.property') self.imd = self.registry('ir.model.data') @unittest.skip("invalid monkey-patching") def test_1_property_multicompany(self): cr, uid = self.cr, self.uid parent_company_id = self.imd.get_object_reference(cr, uid, 'base', 'main_company')[1] country_be = self.imd.get_object_reference(cr, uid, 'base', 'be')[1] country_fr = self.imd.get_object_reference(cr, uid, 'base', 'fr')[1] group_partner_manager = self.imd.get_object_reference(cr, uid, 'base', 'group_partner_manager')[1] group_multi_company = self.imd.get_object_reference(cr, uid, 'base', 'group_multi_company')[1] sub_company = self.company.create(cr, uid, {'name': 'MegaCorp', 'parent_id': parent_company_id}) alice = self.user.create(cr, uid, {'name': 'Alice', 'login':'alice', 'email':'alice@youcompany.com', 'company_id':parent_company_id, 'company_ids':[(6, 0, [parent_company_id, sub_company])], 'country_id':country_be, 'groups_id': [(6, 0, [group_partner_manager, group_multi_company])] }) bob = self.user.create(cr, uid, {'name': 'Bob', 'login':'bob', 'email':'bob@megacorp.com', 'company_id':sub_company, 'company_ids':[(6, 0, [parent_company_id, sub_company])], 'country_id':country_fr, 'groups_id': [(6, 0, [group_partner_manager, group_multi_company])] }) self.partner._columns = dict(self.partner._columns) self.partner._columns.update({ 'property_country': fields.property(type='many2one', relation="res.country", string="Country by company"), }) self.partner._field_create(cr) partner_id = self.partner.create(cr, alice, { 'name': 'An International Partner', 'email': 'partner@example.com', 'company_id': parent_company_id, }) self.partner.write(cr, bob, [partner_id], {'property_country': country_fr}) self.assertEqual(self.partner.browse(cr, bob, partner_id).property_country.id, country_fr, "Bob does not see the value he has set on the property field") self.partner.write(cr, alice, [partner_id], {'property_country': country_be}) self.assertEqual(self.partner.browse(cr, alice, partner_id).property_country.id, country_be, "Alice does not see the value he has set on the property field") self.assertEqual(self.partner.browse(cr, bob, partner_id).property_country.id, country_fr, "Changes made by Alice have overwritten Bob's value") class TestHtmlField(common.TransactionCase): def setUp(self): super(TestHtmlField, self).setUp() self.partner = self.registry('res.partner') def test_00_sanitize(self): cr, uid, context = self.cr, self.uid, {} old_columns = self.partner._columns self.partner._columns = dict(old_columns) self.partner._columns.update({ 'comment': fields.html('Secure Html', sanitize=False), }) some_ugly_html = """<p>Oops this should maybe be sanitized % if object.some_field and not object.oriented: <table> % if object.other_field: <tr style="border: 10px solid black;"> ${object.mako_thing} <td> </tr> % endif <tr> %if object.dummy_field: <p>Youpie</p> %endif""" pid = self.partner.create(cr, uid, { 'name': 'Raoul Poilvache', 'comment': some_ugly_html, }, context=context) partner = self.partner.browse(cr, uid, pid, context=context) self.assertEqual(partner.comment, some_ugly_html, 'Error in HTML field: content was sanitized but field has sanitize=False') self.partner._columns.update({ 'comment': fields.html('Unsecure Html', sanitize=True), }) self.partner.write(cr, uid, [pid], { 'comment': some_ugly_html, }, context=context) partner = self.partner.browse(cr, uid, pid, context=context) # sanitize should have closed tags left open in the original html self.assertIn('</table>', partner.comment, 'Error in HTML field: content does not seem to have been sanitized despise sanitize=True') self.assertIn('</td>', partner.comment, 'Error in HTML field: content does not seem to have been sanitized despise sanitize=True') self.assertIn('<tr style="', partner.comment, 'Style attr should not have been stripped') self.partner._columns['comment'] = fields.html('Stripped Html', sanitize=True, strip_style=True) self.partner.write(cr, uid, [pid], {'comment': some_ugly_html}, context=context) partner = self.partner.browse(cr, uid, pid, context=context) self.assertNotIn('<tr style="', partner.comment, 'Style attr should have been stripped') self.partner._columns = old_columns
agpl-3.0
[ 3, 199, 3, 511, 5560, 367, 4048, 1504, 12, 5423, 14, 199, 3, 199, 646, 2882, 199, 199, 504, 5166, 14, 4795, 492, 1504, 199, 504, 5166, 14, 2219, 492, 2863, 199, 199, 533, 1379, 13885, 792, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 13885, 792, 12, 291, 680, 5996, 342, 267, 291, 14, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 267, 291, 14, 4627, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 339, 347, 511, 63, 16, 63, 2407, 8, 277, 304, 267, 408, 511, 376, 20195, 4048, 901, 408, 267, 327, 2342, 282, 7233, 543, 282, 2222, 13, 2307, 5854, 63, 344, 267, 2762, 275, 291, 14, 4627, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 3899, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 9, 267, 1305, 275, 2762, 59, 16, 61, 398, 327, 2342, 18943, 626, 23082, 4274, 3899, 63, 344, 14, 4627, 63, 344, 297, 6291, 1305, 1874, 267, 7233, 63, 1580, 275, 291, 14, 4627, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 3899, 63, 344, 297, 6291, 1305, 3948, 267, 5854, 63, 1580, 17, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 4627, 63, 344, 297, 283, 262, 297, 7233, 63, 1580, 3948, 267, 5854, 63, 1580, 18, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 2407, 63, 4627, 63, 3899, 63, 344, 297, 6291, 1305, 3948, 267, 291, 14, 629, 8, 3899, 63, 1580, 17, 12, 5854, 63, 1580, 18, 9, 339, 347, 886, 63, 396, 63, 4627, 63, 698, 8, 277, 12, 901, 304, 267, 327, 664, 282, 5854, 543, 282, 2222, 13, 2307, 7233, 63, 344, 267, 2762, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 4627, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 9, 267, 5854, 275, 291, 14, 3899, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2762, 59, 16, 566, 398, 327, 1104, 7664, 4048, 901, 267, 291, 14, 629, 8, 3899, 59, 698, 467, 5854, 14, 4627, 63, 344, 9, 398, 327, 1104, 626, 2754, 641, 4048, 901, 365, 7353, 370, 3379, 901, 267, 2762, 17, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 4627, 63, 344, 297, 6291, 5854, 14, 4627, 63, 344, 14, 344, 3948, 267, 2762, 18, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 3842, 698, 12, 6291, 5854, 14, 4627, 63, 344, 14, 344, 3948, 267, 291, 14, 629, 8, 1580, 17, 12, 2762, 18, 9, 339, 347, 511, 63, 17, 63, 4780, 63, 2407, 8, 277, 304, 267, 408, 511, 282, 4048, 901, 543, 282, 2849, 2539, 4017, 2839, 1504, 14, 2407, 360, 1421, 358, 408, 267, 291, 14, 1117, 63, 396, 63, 4627, 63, 698, 360, 4780, 63, 2407, 63, 4627, 63, 344, 358, 339, 347, 511, 63, 18, 63, 2407, 63, 2407, 8, 277, 304, 267, 408, 511, 282, 4048, 901, 21864, 370, 282, 4048, 901, 408, 267, 291, 14, 1117, 63, 396, 63, 4627, 63, 698, 360, 2407, 63, 2407, 63, 4627, 63, 344, 358, 339, 347, 511, 63, 19, 63, 739, 63, 952, 8, 277, 304, 267, 408, 2218, 641, 282, 4048, 901, 408, 267, 327, 2342, 282, 7233, 543, 282, 2222, 13, 2307, 5854, 63, 344, 267, 7233, 63, 1580, 275, 291, 14, 4627, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 3899, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 9, 267, 7233, 275, 291, 14, 4627, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 1580, 59, 16, 566, 398, 327, 2342, 18943, 626, 23082, 4274, 4627, 63, 344, 14, 3899, 63, 344, 297, 6291, 7233, 14, 3899, 63, 344, 14, 344, 1874, 267, 5854, 63, 1580, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 2407, 63, 4627, 63, 3899, 63, 344, 297, 6291, 7233, 14, 3899, 63, 344, 14, 344, 3948, 267, 291, 14, 15070, 8, 552, 8, 3899, 63, 1580, 395, 378, 9, 267, 5854, 275, 291, 14, 3899, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 5854, 63, 1580, 59, 16, 566, 398, 327, 1218, 282, 892, 5854, 12, 436, 5090, 652, 370, 7233, 267, 892, 63, 3899, 63, 344, 275, 291, 14, 3899, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 791, 354, 356, 283, 5686, 3071, 267, 5854, 14, 952, 3252, 2407, 63, 4627, 63, 3899, 63, 344, 356, 892, 63, 3899, 63, 344, 1552, 398, 7233, 275, 291, 14, 4627, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 1580, 59, 16, 566, 267, 291, 14, 629, 8, 4627, 14, 3899, 63, 344, 14, 344, 12, 892, 63, 3899, 63, 344, 9, 398, 5854, 275, 291, 14, 3899, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 5854, 63, 1580, 59, 16, 566, 267, 291, 14, 629, 8, 3899, 14, 2407, 63, 4627, 63, 3899, 63, 344, 14, 344, 12, 892, 63, 3899, 63, 344, 9, 421, 199, 533, 1379, 3697, 792, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 3697, 792, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 291, 14, 5189, 360, 470, 14, 3707, 358, 267, 291, 14, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 267, 291, 14, 4627, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 267, 291, 14, 6063, 275, 291, 14, 5189, 360, 470, 14, 6063, 358, 267, 291, 14, 1829, 275, 291, 14, 5189, 360, 723, 14, 1829, 358, 267, 291, 14, 1017, 68, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 358, 339, 768, 2796, 14, 2759, 480, 3197, 14198, 13, 2068, 316, 531, 272, 347, 511, 63, 17, 63, 1829, 63, 3029, 4627, 8, 277, 304, 267, 2467, 12, 1747, 275 ]
[ 199, 3, 511, 5560, 367, 4048, 1504, 12, 5423, 14, 199, 3, 199, 646, 2882, 199, 199, 504, 5166, 14, 4795, 492, 1504, 199, 504, 5166, 14, 2219, 492, 2863, 199, 199, 533, 1379, 13885, 792, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 13885, 792, 12, 291, 680, 5996, 342, 267, 291, 14, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 267, 291, 14, 4627, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 339, 347, 511, 63, 16, 63, 2407, 8, 277, 304, 267, 408, 511, 376, 20195, 4048, 901, 408, 267, 327, 2342, 282, 7233, 543, 282, 2222, 13, 2307, 5854, 63, 344, 267, 2762, 275, 291, 14, 4627, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 3899, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 9, 267, 1305, 275, 2762, 59, 16, 61, 398, 327, 2342, 18943, 626, 23082, 4274, 3899, 63, 344, 14, 4627, 63, 344, 297, 6291, 1305, 1874, 267, 7233, 63, 1580, 275, 291, 14, 4627, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 3899, 63, 344, 297, 6291, 1305, 3948, 267, 5854, 63, 1580, 17, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 4627, 63, 344, 297, 283, 262, 297, 7233, 63, 1580, 3948, 267, 5854, 63, 1580, 18, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 2407, 63, 4627, 63, 3899, 63, 344, 297, 6291, 1305, 3948, 267, 291, 14, 629, 8, 3899, 63, 1580, 17, 12, 5854, 63, 1580, 18, 9, 339, 347, 886, 63, 396, 63, 4627, 63, 698, 8, 277, 12, 901, 304, 267, 327, 664, 282, 5854, 543, 282, 2222, 13, 2307, 7233, 63, 344, 267, 2762, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 4627, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 9, 267, 5854, 275, 291, 14, 3899, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2762, 59, 16, 566, 398, 327, 1104, 7664, 4048, 901, 267, 291, 14, 629, 8, 3899, 59, 698, 467, 5854, 14, 4627, 63, 344, 9, 398, 327, 1104, 626, 2754, 641, 4048, 901, 365, 7353, 370, 3379, 901, 267, 2762, 17, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 4627, 63, 344, 297, 6291, 5854, 14, 4627, 63, 344, 14, 344, 3948, 267, 2762, 18, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 3842, 698, 12, 6291, 5854, 14, 4627, 63, 344, 14, 344, 3948, 267, 291, 14, 629, 8, 1580, 17, 12, 2762, 18, 9, 339, 347, 511, 63, 17, 63, 4780, 63, 2407, 8, 277, 304, 267, 408, 511, 282, 4048, 901, 543, 282, 2849, 2539, 4017, 2839, 1504, 14, 2407, 360, 1421, 358, 408, 267, 291, 14, 1117, 63, 396, 63, 4627, 63, 698, 360, 4780, 63, 2407, 63, 4627, 63, 344, 358, 339, 347, 511, 63, 18, 63, 2407, 63, 2407, 8, 277, 304, 267, 408, 511, 282, 4048, 901, 21864, 370, 282, 4048, 901, 408, 267, 291, 14, 1117, 63, 396, 63, 4627, 63, 698, 360, 2407, 63, 2407, 63, 4627, 63, 344, 358, 339, 347, 511, 63, 19, 63, 739, 63, 952, 8, 277, 304, 267, 408, 2218, 641, 282, 4048, 901, 408, 267, 327, 2342, 282, 7233, 543, 282, 2222, 13, 2307, 5854, 63, 344, 267, 7233, 63, 1580, 275, 291, 14, 4627, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 3899, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 9, 267, 7233, 275, 291, 14, 4627, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 1580, 59, 16, 566, 398, 327, 2342, 18943, 626, 23082, 4274, 4627, 63, 344, 14, 3899, 63, 344, 297, 6291, 7233, 14, 3899, 63, 344, 14, 344, 1874, 267, 5854, 63, 1580, 275, 291, 14, 3899, 14, 1733, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 4274, 2407, 63, 4627, 63, 3899, 63, 344, 297, 6291, 7233, 14, 3899, 63, 344, 14, 344, 3948, 267, 291, 14, 15070, 8, 552, 8, 3899, 63, 1580, 395, 378, 9, 267, 5854, 275, 291, 14, 3899, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 5854, 63, 1580, 59, 16, 566, 398, 327, 1218, 282, 892, 5854, 12, 436, 5090, 652, 370, 7233, 267, 892, 63, 3899, 63, 344, 275, 291, 14, 3899, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 791, 354, 356, 283, 5686, 3071, 267, 5854, 14, 952, 3252, 2407, 63, 4627, 63, 3899, 63, 344, 356, 892, 63, 3899, 63, 344, 1552, 398, 7233, 275, 291, 14, 4627, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 7233, 63, 1580, 59, 16, 566, 267, 291, 14, 629, 8, 4627, 14, 3899, 63, 344, 14, 344, 12, 892, 63, 3899, 63, 344, 9, 398, 5854, 275, 291, 14, 3899, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 5854, 63, 1580, 59, 16, 566, 267, 291, 14, 629, 8, 3899, 14, 2407, 63, 4627, 63, 3899, 63, 344, 14, 344, 12, 892, 63, 3899, 63, 344, 9, 421, 199, 533, 1379, 3697, 792, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 3697, 792, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 291, 14, 5189, 360, 470, 14, 3707, 358, 267, 291, 14, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 267, 291, 14, 4627, 275, 291, 14, 5189, 360, 470, 14, 4627, 358, 267, 291, 14, 6063, 275, 291, 14, 5189, 360, 470, 14, 6063, 358, 267, 291, 14, 1829, 275, 291, 14, 5189, 360, 723, 14, 1829, 358, 267, 291, 14, 1017, 68, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 358, 339, 768, 2796, 14, 2759, 480, 3197, 14198, 13, 2068, 316, 531, 272, 347, 511, 63, 17, 63, 1829, 63, 3029, 4627, 8, 277, 304, 267, 2467, 12, 1747, 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,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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 ]
dwillmer/numpy
numpy/distutils/fcompiler/nag.py
228
1403
from __future__ import division, absolute_import, print_function import sys from numpy.distutils.fcompiler import FCompiler compilers = ['NAGFCompiler'] class NAGFCompiler(FCompiler): compiler_type = 'nag' description = 'NAGWare Fortran 95 Compiler' version_pattern = r'NAGWare Fortran 95 compiler Release (?P<version>[^\s]*)' executables = { 'version_cmd' : ["<F90>", "-V"], 'compiler_f77' : ["f95", "-fixed"], 'compiler_fix' : ["f95", "-fixed"], 'compiler_f90' : ["f95"], 'linker_so' : ["<F90>"], 'archiver' : ["ar", "-cr"], 'ranlib' : ["ranlib"] } def get_flags_linker_so(self): if sys.platform=='darwin': return ['-unsharedf95', '-Wl,-bundle,-flat_namespace,-undefined,suppress'] return ["-Wl,-shared"] def get_flags_opt(self): return ['-O4'] def get_flags_arch(self): version = self.get_version() if version and version < '5.1': return ['-target=native'] else: return [''] def get_flags_debug(self): return ['-g', '-gline', '-g90', '-nan', '-C'] if __name__ == '__main__': from distutils import log log.set_verbosity(2) from numpy.distutils.fcompiler import new_fcompiler compiler = new_fcompiler(compiler='nag') compiler.customize() print(compiler.get_version())
bsd-3-clause
[ 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 504, 2680, 14, 13350, 14, 32070, 492, 481, 9131, 199, 199, 32593, 275, 788, 46, 1254, 38, 9131, 418, 199, 199, 533, 653, 1254, 38, 9131, 8, 38, 9131, 304, 339, 6365, 63, 466, 275, 283, 78, 643, 7, 272, 1369, 275, 283, 46, 1254, 55, 1530, 19998, 16102, 27154, 7, 272, 1015, 63, 3401, 275, 221, 519, 7, 46, 1254, 55, 1530, 19998, 16102, 6365, 17646, 7558, 48, 28, 1023, 13489, 60, 83, 3672, 3171, 339, 31172, 275, 469, 267, 283, 1023, 63, 1760, 7, 221, 520, 24652, 38, 2710, 7166, 3905, 54, 2255, 267, 283, 5772, 63, 70, 1138, 7, 520, 2097, 70, 2720, 401, 3905, 5964, 2255, 267, 283, 5772, 63, 970, 7, 520, 2097, 70, 2720, 401, 3905, 5964, 2255, 267, 283, 5772, 63, 70, 2710, 7, 520, 2097, 70, 2720, 2255, 267, 283, 20311, 63, 1152, 7, 259, 520, 24652, 38, 2710, 30, 2255, 267, 283, 1047, 4380, 7, 258, 520, 2097, 285, 401, 3905, 1556, 2255, 267, 283, 1312, 773, 7, 755, 520, 2097, 1312, 773, 937, 267, 789, 339, 347, 664, 63, 2469, 63, 20311, 63, 1152, 8, 277, 304, 267, 340, 984, 14, 3246, 6803, 13245, 356, 288, 372, 11573, 324, 5555, 70, 2720, 297, 2475, 16239, 3057, 6469, 3057, 7088, 63, 3251, 3057, 10705, 12, 17381, 418, 267, 372, 16984, 16239, 3057, 5555, 937, 272, 347, 664, 63, 2469, 63, 2992, 8, 277, 304, 267, 372, 11573, 47, 20, 418, 272, 347, 664, 63, 2469, 63, 1047, 8, 277, 304, 267, 1015, 275, 291, 14, 362, 63, 1023, 342, 267, 340, 1015, 436, 1015, 665, 283, 21, 14, 17, 356, 288, 372, 11573, 1375, 29, 6106, 418, 267, 587, 26, 288, 372, 24506, 272, 347, 664, 63, 2469, 63, 1757, 8, 277, 304, 267, 372, 11573, 71, 297, 2475, 71, 604, 297, 2475, 71, 2710, 297, 2475, 4304, 297, 2475, 35, 418, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 7065, 492, 943, 272, 943, 14, 409, 63, 9833, 8, 18, 9, 272, 687, 2680, 14, 13350, 14, 32070, 492, 892, 63, 32070, 272, 6365, 275, 892, 63, 32070, 8, 5772, 534, 78, 643, 358, 272, 6365, 14, 26660, 342, 272, 870, 8, 5772, 14, 362, 63, 1023, 1012, 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 ]
[ 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 504, 2680, 14, 13350, 14, 32070, 492, 481, 9131, 199, 199, 32593, 275, 788, 46, 1254, 38, 9131, 418, 199, 199, 533, 653, 1254, 38, 9131, 8, 38, 9131, 304, 339, 6365, 63, 466, 275, 283, 78, 643, 7, 272, 1369, 275, 283, 46, 1254, 55, 1530, 19998, 16102, 27154, 7, 272, 1015, 63, 3401, 275, 221, 519, 7, 46, 1254, 55, 1530, 19998, 16102, 6365, 17646, 7558, 48, 28, 1023, 13489, 60, 83, 3672, 3171, 339, 31172, 275, 469, 267, 283, 1023, 63, 1760, 7, 221, 520, 24652, 38, 2710, 7166, 3905, 54, 2255, 267, 283, 5772, 63, 70, 1138, 7, 520, 2097, 70, 2720, 401, 3905, 5964, 2255, 267, 283, 5772, 63, 970, 7, 520, 2097, 70, 2720, 401, 3905, 5964, 2255, 267, 283, 5772, 63, 70, 2710, 7, 520, 2097, 70, 2720, 2255, 267, 283, 20311, 63, 1152, 7, 259, 520, 24652, 38, 2710, 30, 2255, 267, 283, 1047, 4380, 7, 258, 520, 2097, 285, 401, 3905, 1556, 2255, 267, 283, 1312, 773, 7, 755, 520, 2097, 1312, 773, 937, 267, 789, 339, 347, 664, 63, 2469, 63, 20311, 63, 1152, 8, 277, 304, 267, 340, 984, 14, 3246, 6803, 13245, 356, 288, 372, 11573, 324, 5555, 70, 2720, 297, 2475, 16239, 3057, 6469, 3057, 7088, 63, 3251, 3057, 10705, 12, 17381, 418, 267, 372, 16984, 16239, 3057, 5555, 937, 272, 347, 664, 63, 2469, 63, 2992, 8, 277, 304, 267, 372, 11573, 47, 20, 418, 272, 347, 664, 63, 2469, 63, 1047, 8, 277, 304, 267, 1015, 275, 291, 14, 362, 63, 1023, 342, 267, 340, 1015, 436, 1015, 665, 283, 21, 14, 17, 356, 288, 372, 11573, 1375, 29, 6106, 418, 267, 587, 26, 288, 372, 24506, 272, 347, 664, 63, 2469, 63, 1757, 8, 277, 304, 267, 372, 11573, 71, 297, 2475, 71, 604, 297, 2475, 71, 2710, 297, 2475, 4304, 297, 2475, 35, 418, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 7065, 492, 943, 272, 943, 14, 409, 63, 9833, 8, 18, 9, 272, 687, 2680, 14, 13350, 14, 32070, 492, 892, 63, 32070, 272, 6365, 275, 892, 63, 32070, 8, 5772, 534, 78, 643, 358, 272, 6365, 14, 26660, 342, 272, 870, 8, 5772, 14, 362, 63, 1023, 1012, 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, 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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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 ]
Darkmer/masterchief
CourseBuilderenv/lib/python2.7/distutils/__init__.py
1211
3983
import os import sys import warnings import imp import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib # Important! To work on pypy, this must be a module that resides in the # lib-python/modified-x.y.z directory dirname = os.path.dirname distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils') if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)): warnings.warn( "The virtualenv distutils package at %s appears to be in the same location as the system distutils?") else: __path__.insert(0, distutils_path) real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY)) # Copy the relevant attributes try: __revision__ = real_distutils.__revision__ except AttributeError: pass __version__ = real_distutils.__version__ from distutils import dist, sysconfig try: basestring except NameError: basestring = str ## patch build_ext (distutils doesn't know how to get the libs directory ## path on windows - it hardcodes the paths around the patched sys.prefix) if sys.platform == 'win32': from distutils.command.build_ext import build_ext as old_build_ext class build_ext(old_build_ext): def finalize_options (self): if self.library_dirs is None: self.library_dirs = [] elif isinstance(self.library_dirs, basestring): self.library_dirs = self.library_dirs.split(os.pathsep) self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs")) old_build_ext.finalize_options(self) from distutils.command import build_ext as build_ext_module build_ext_module.build_ext = build_ext ## distutils.dist patches: old_find_config_files = dist.Distribution.find_config_files def find_config_files(self): found = old_find_config_files(self) system_distutils = os.path.join(distutils_path, 'distutils.cfg') #if os.path.exists(system_distutils): # found.insert(0, system_distutils) # What to call the per-user config file if os.name == 'posix': user_filename = ".pydistutils.cfg" else: user_filename = "pydistutils.cfg" user_filename = os.path.join(sys.prefix, user_filename) if os.path.isfile(user_filename): for item in list(found): if item.endswith('pydistutils.cfg'): found.remove(item) found.append(user_filename) return found dist.Distribution.find_config_files = find_config_files ## distutils.sysconfig patches: old_get_python_inc = sysconfig.get_python_inc def sysconfig_get_python_inc(plat_specific=0, prefix=None): if prefix is None: prefix = sys.real_prefix return old_get_python_inc(plat_specific, prefix) sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__ sysconfig.get_python_inc = sysconfig_get_python_inc old_get_python_lib = sysconfig.get_python_lib def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None): if standard_lib and prefix is None: prefix = sys.real_prefix return old_get_python_lib(plat_specific, standard_lib, prefix) sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__ sysconfig.get_python_lib = sysconfig_get_python_lib old_get_config_vars = sysconfig.get_config_vars def sysconfig_get_config_vars(*args): real_vars = old_get_config_vars(*args) if sys.platform == 'win32': lib_dir = os.path.join(sys.real_prefix, "libs") if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars: real_vars['LIBDIR'] = lib_dir # asked for all elif isinstance(real_vars, list) and 'LIBDIR' in args: real_vars = real_vars + [lib_dir] # asked for list return real_vars sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__ sysconfig.get_config_vars = sysconfig_get_config_vars
mit
[ 646, 747, 199, 646, 984, 199, 646, 3598, 221, 199, 646, 1742, 199, 646, 10508, 327, 10508, 365, 440, 282, 19128, 859, 12, 880, 781, 883, 675, 652, 370, 2342, 314, 26678, 1598, 327, 3161, 867, 1, 4005, 1736, 641, 1134, 647, 12, 642, 1471, 506, 282, 859, 626, 295, 19564, 315, 314, 1598, 327, 1973, 13, 1548, 15, 5540, 13, 88, 14, 89, 14, 90, 2082, 199, 199, 3475, 275, 747, 14, 515, 14, 3475, 199, 199, 13350, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 14325, 855, 493, 10139, 283, 13350, 358, 199, 692, 747, 14, 515, 14, 9267, 8, 13350, 63, 515, 9, 508, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 9267, 3460, 493, 363, 2298, 272, 3598, 14, 4050, 8, 267, 298, 1918, 19128, 7065, 2559, 737, 450, 83, 11337, 370, 506, 315, 314, 2011, 2909, 465, 314, 2656, 7065, 18582, 199, 2836, 26, 272, 636, 515, 4343, 3176, 8, 16, 12, 7065, 63, 515, 9, 272, 3363, 63, 13350, 275, 1742, 14, 912, 63, 578, 11008, 21611, 63, 13350, 401, 488, 12, 7065, 63, 515, 12, 13134, 3260, 1742, 14, 18150, 63, 16436, 430, 272, 327, 11247, 314, 12082, 3004, 272, 862, 26, 267, 636, 5792, 363, 275, 3363, 63, 13350, 855, 5792, 363, 272, 871, 4281, 26, 267, 986, 272, 636, 1023, 363, 275, 3363, 63, 13350, 855, 1023, 363, 199, 199, 504, 7065, 492, 2917, 12, 22381, 199, 199, 893, 26, 272, 7116, 199, 2590, 12746, 26, 272, 7116, 275, 620, 199, 199, 309, 3371, 1900, 63, 832, 334, 13350, 3181, 1133, 5715, 4212, 370, 664, 314, 20314, 2082, 199, 309, 931, 641, 10061, 446, 652, 7508, 6021, 314, 3792, 6818, 314, 19483, 984, 14, 1861, 9, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 272, 687, 7065, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 465, 2269, 63, 1506, 63, 832, 272, 1021, 1900, 63, 832, 8, 1753, 63, 1506, 63, 832, 304, 267, 347, 17284, 63, 1419, 334, 277, 304, 288, 340, 291, 14, 4342, 63, 3220, 365, 488, 26, 355, 291, 14, 4342, 63, 3220, 275, 942, 288, 916, 1228, 8, 277, 14, 4342, 63, 3220, 12, 7116, 304, 355, 291, 14, 4342, 63, 3220, 275, 291, 14, 4342, 63, 3220, 14, 1294, 8, 736, 14, 17843, 9, 7846, 291, 14, 4342, 63, 3220, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 13009, 1533, 2237, 288, 2269, 63, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 15567, 687, 7065, 14, 1531, 492, 1900, 63, 832, 465, 1900, 63, 832, 63, 578, 5591, 1900, 63, 832, 63, 578, 14, 1506, 63, 832, 275, 1900, 63, 832, 199, 199, 309, 7065, 14, 2686, 12385, 26, 199, 199, 1753, 63, 1623, 63, 888, 63, 1725, 275, 2917, 14, 8580, 14, 1623, 63, 888, 63, 1725, 199, 318, 2342, 63, 888, 63, 1725, 8, 277, 304, 272, 1911, 275, 2269, 63, 1623, 63, 888, 63, 1725, 8, 277, 9, 272, 2656, 63, 13350, 275, 747, 14, 515, 14, 904, 8, 13350, 63, 515, 12, 283, 13350, 14, 4128, 358, 272, 327, 692, 747, 14, 515, 14, 2444, 8, 2253, 63, 13350, 304, 272, 327, 259, 1911, 14, 3176, 8, 16, 12, 2656, 63, 13350, 9, 267, 327, 14791, 370, 1240, 314, 1126, 13, 751, 1101, 570, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 922, 63, 1501, 275, 3680, 647, 13350, 14, 4128, 2, 272, 587, 26, 267, 922, 63, 1501, 275, 298, 647, 13350, 14, 4128, 2, 272, 922, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 1861, 12, 922, 63, 1501, 9, 272, 340, 747, 14, 515, 14, 6292, 8, 751, 63, 1501, 304, 267, 367, 1242, 315, 769, 8, 4214, 304, 288, 340, 1242, 14, 4130, 360, 647, 13350, 14, 4128, 735, 355, 1911, 14, 2168, 8, 1053, 9, 267, 1911, 14, 740, 8, 751, 63, 1501, 9, 272, 372, 1911, 199, 2686, 14, 8580, 14, 1623, 63, 888, 63, 1725, 275, 2342, 63, 888, 63, 1725, 199, 199, 309, 7065, 14, 24030, 12385, 26, 199, 199, 1753, 63, 362, 63, 1548, 63, 6559, 275, 22381, 14, 362, 63, 1548, 63, 6559, 199, 318, 22381, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 12, 2403, 9, 199, 24030, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 6559, 275, 22381, 63, 362, 63, 1548, 63, 6559, 199, 199, 1753, 63, 362, 63, 1548, 63, 773, 275, 22381, 14, 362, 63, 1548, 63, 773, 199, 318, 22381, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 29, 16, 12, 4465, 63, 773, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 4465, 63, 773, 436, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 12, 4465, 63, 773, 12, 2403, 9, 199, 24030, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 773, 275, 22381, 63, 362, 63, 1548, 63, 773, 199, 199, 1753, 63, 362, 63, 888, 63, 2936, 275, 22381, 14, 362, 63, 888, 63, 2936, 199, 318, 22381, 63, 362, 63, 888, 63, 2936, 2031, 589, 304, 272, 3363, 63, 2936, 275, 2269, 63, 362, 63, 888, 63, 2936, 2031, 589, 9, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 356, 267, 1973, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 8450, 531, 267, 340, 1228, 8, 3093, 63, 2936, 12, 1211, 9, 436, 283, 5617, 3022, 7, 440, 315, 3363, 63, 2936, 26, 288, 3363, 63, 2936, 459, 5617, 3022, 418, 275 ]
[ 747, 199, 646, 984, 199, 646, 3598, 221, 199, 646, 1742, 199, 646, 10508, 327, 10508, 365, 440, 282, 19128, 859, 12, 880, 781, 883, 675, 652, 370, 2342, 314, 26678, 1598, 327, 3161, 867, 1, 4005, 1736, 641, 1134, 647, 12, 642, 1471, 506, 282, 859, 626, 295, 19564, 315, 314, 1598, 327, 1973, 13, 1548, 15, 5540, 13, 88, 14, 89, 14, 90, 2082, 199, 199, 3475, 275, 747, 14, 515, 14, 3475, 199, 199, 13350, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 14325, 855, 493, 10139, 283, 13350, 358, 199, 692, 747, 14, 515, 14, 9267, 8, 13350, 63, 515, 9, 508, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 9267, 3460, 493, 363, 2298, 272, 3598, 14, 4050, 8, 267, 298, 1918, 19128, 7065, 2559, 737, 450, 83, 11337, 370, 506, 315, 314, 2011, 2909, 465, 314, 2656, 7065, 18582, 199, 2836, 26, 272, 636, 515, 4343, 3176, 8, 16, 12, 7065, 63, 515, 9, 272, 3363, 63, 13350, 275, 1742, 14, 912, 63, 578, 11008, 21611, 63, 13350, 401, 488, 12, 7065, 63, 515, 12, 13134, 3260, 1742, 14, 18150, 63, 16436, 430, 272, 327, 11247, 314, 12082, 3004, 272, 862, 26, 267, 636, 5792, 363, 275, 3363, 63, 13350, 855, 5792, 363, 272, 871, 4281, 26, 267, 986, 272, 636, 1023, 363, 275, 3363, 63, 13350, 855, 1023, 363, 199, 199, 504, 7065, 492, 2917, 12, 22381, 199, 199, 893, 26, 272, 7116, 199, 2590, 12746, 26, 272, 7116, 275, 620, 199, 199, 309, 3371, 1900, 63, 832, 334, 13350, 3181, 1133, 5715, 4212, 370, 664, 314, 20314, 2082, 199, 309, 931, 641, 10061, 446, 652, 7508, 6021, 314, 3792, 6818, 314, 19483, 984, 14, 1861, 9, 199, 199, 692, 984, 14, 3246, 508, 283, 2676, 708, 356, 272, 687, 7065, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 465, 2269, 63, 1506, 63, 832, 272, 1021, 1900, 63, 832, 8, 1753, 63, 1506, 63, 832, 304, 267, 347, 17284, 63, 1419, 334, 277, 304, 288, 340, 291, 14, 4342, 63, 3220, 365, 488, 26, 355, 291, 14, 4342, 63, 3220, 275, 942, 288, 916, 1228, 8, 277, 14, 4342, 63, 3220, 12, 7116, 304, 355, 291, 14, 4342, 63, 3220, 275, 291, 14, 4342, 63, 3220, 14, 1294, 8, 736, 14, 17843, 9, 7846, 291, 14, 4342, 63, 3220, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 13009, 1533, 2237, 288, 2269, 63, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 15567, 687, 7065, 14, 1531, 492, 1900, 63, 832, 465, 1900, 63, 832, 63, 578, 5591, 1900, 63, 832, 63, 578, 14, 1506, 63, 832, 275, 1900, 63, 832, 199, 199, 309, 7065, 14, 2686, 12385, 26, 199, 199, 1753, 63, 1623, 63, 888, 63, 1725, 275, 2917, 14, 8580, 14, 1623, 63, 888, 63, 1725, 199, 318, 2342, 63, 888, 63, 1725, 8, 277, 304, 272, 1911, 275, 2269, 63, 1623, 63, 888, 63, 1725, 8, 277, 9, 272, 2656, 63, 13350, 275, 747, 14, 515, 14, 904, 8, 13350, 63, 515, 12, 283, 13350, 14, 4128, 358, 272, 327, 692, 747, 14, 515, 14, 2444, 8, 2253, 63, 13350, 304, 272, 327, 259, 1911, 14, 3176, 8, 16, 12, 2656, 63, 13350, 9, 267, 327, 14791, 370, 1240, 314, 1126, 13, 751, 1101, 570, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 922, 63, 1501, 275, 3680, 647, 13350, 14, 4128, 2, 272, 587, 26, 267, 922, 63, 1501, 275, 298, 647, 13350, 14, 4128, 2, 272, 922, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 1861, 12, 922, 63, 1501, 9, 272, 340, 747, 14, 515, 14, 6292, 8, 751, 63, 1501, 304, 267, 367, 1242, 315, 769, 8, 4214, 304, 288, 340, 1242, 14, 4130, 360, 647, 13350, 14, 4128, 735, 355, 1911, 14, 2168, 8, 1053, 9, 267, 1911, 14, 740, 8, 751, 63, 1501, 9, 272, 372, 1911, 199, 2686, 14, 8580, 14, 1623, 63, 888, 63, 1725, 275, 2342, 63, 888, 63, 1725, 199, 199, 309, 7065, 14, 24030, 12385, 26, 199, 199, 1753, 63, 362, 63, 1548, 63, 6559, 275, 22381, 14, 362, 63, 1548, 63, 6559, 199, 318, 22381, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 12, 2403, 9, 199, 24030, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 6559, 275, 22381, 63, 362, 63, 1548, 63, 6559, 199, 199, 1753, 63, 362, 63, 1548, 63, 773, 275, 22381, 14, 362, 63, 1548, 63, 773, 199, 318, 22381, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 29, 16, 12, 4465, 63, 773, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 4465, 63, 773, 436, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 12, 4465, 63, 773, 12, 2403, 9, 199, 24030, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 773, 275, 22381, 63, 362, 63, 1548, 63, 773, 199, 199, 1753, 63, 362, 63, 888, 63, 2936, 275, 22381, 14, 362, 63, 888, 63, 2936, 199, 318, 22381, 63, 362, 63, 888, 63, 2936, 2031, 589, 304, 272, 3363, 63, 2936, 275, 2269, 63, 362, 63, 888, 63, 2936, 2031, 589, 9, 272, 340, 984, 14, 3246, 508, 283, 2676, 708, 356, 267, 1973, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 8450, 531, 267, 340, 1228, 8, 3093, 63, 2936, 12, 1211, 9, 436, 283, 5617, 3022, 7, 440, 315, 3363, 63, 2936, 26, 288, 3363, 63, 2936, 459, 5617, 3022, 418, 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, 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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 ]
arvinsingla/CouchPotatoServer
libs/guessit/matchtree.py
102
9116
#!/usr/bin/env python # -*- coding: utf-8 -*- # # GuessIt - A library for guessing information from filenames # Copyright (c) 2011 Nicolas Wack <wackou@gmail.com> # # GuessIt is free software; you can redistribute it and/or modify it under # the terms of the Lesser GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GuessIt 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 # Lesser GNU General Public License for more details. # # You should have received a copy of the Lesser GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from __future__ import unicode_literals from guessit import UnicodeMixin, base_text_type, Guess from guessit.textutils import clean_string, str_fill from guessit.patterns import group_delimiters from guessit.guess import (merge_similar_guesses, merge_all, choose_int, choose_string) import copy import logging log = logging.getLogger(__name__) class BaseMatchTree(UnicodeMixin): """A MatchTree represents the hierarchical split of a string into its constituent semantic groups.""" def __init__(self, string='', span=None, parent=None): self.string = string self.span = span or (0, len(string)) self.parent = parent self.children = [] self.guess = Guess() @property def value(self): return self.string[self.span[0]:self.span[1]] @property def clean_value(self): return clean_string(self.value) @property def offset(self): return self.span[0] @property def info(self): result = dict(self.guess) for c in self.children: result.update(c.info) return result @property def root(self): if not self.parent: return self return self.parent.root @property def depth(self): if self.is_leaf(): return 0 return 1 + max(c.depth for c in self.children) def is_leaf(self): return self.children == [] def add_child(self, span): child = MatchTree(self.string, span=span, parent=self) self.children.append(child) def partition(self, indices): indices = sorted(indices) if indices[0] != 0: indices.insert(0, 0) if indices[-1] != len(self.value): indices.append(len(self.value)) for start, end in zip(indices[:-1], indices[1:]): self.add_child(span=(self.offset + start, self.offset + end)) def split_on_components(self, components): offset = 0 for c in components: start = self.value.find(c, offset) end = start + len(c) self.add_child(span=(self.offset + start, self.offset + end)) offset = end def nodes_at_depth(self, depth): if depth == 0: yield self for child in self.children: for node in child.nodes_at_depth(depth - 1): yield node @property def node_idx(self): if self.parent is None: return () return self.parent.node_idx + (self.parent.children.index(self),) def node_at(self, idx): if not idx: return self try: return self.children[idx[0]].node_at(idx[1:]) except: raise ValueError('Non-existent node index: %s' % (idx,)) def nodes(self): yield self for child in self.children: for node in child.nodes(): yield node def _leaves(self): if self.is_leaf(): yield self else: for child in self.children: # pylint: disable=W0212 for leaf in child._leaves(): yield leaf def leaves(self): return list(self._leaves()) def to_string(self): empty_line = ' ' * len(self.string) def to_hex(x): if isinstance(x, int): return str(x) if x < 10 else chr(55 + x) return x def meaning(result): mmap = { 'episodeNumber': 'E', 'season': 'S', 'extension': 'e', 'format': 'f', 'language': 'l', 'country': 'C', 'videoCodec': 'v', 'audioCodec': 'a', 'website': 'w', 'container': 'c', 'series': 'T', 'title': 't', 'date': 'd', 'year': 'y', 'releaseGroup': 'r', 'screenSize': 's' } if result is None: return ' ' for prop, l in mmap.items(): if prop in result: return l return 'x' lines = [ empty_line ] * (self.depth + 2) # +2: remaining, meaning lines[-2] = self.string for node in self.nodes(): if node == self: continue idx = node.node_idx depth = len(idx) - 1 if idx: lines[depth] = str_fill(lines[depth], node.span, to_hex(idx[-1])) if node.guess: lines[-2] = str_fill(lines[-2], node.span, '_') lines[-1] = str_fill(lines[-1], node.span, meaning(node.guess)) lines.append(self.string) return '\n'.join(lines) def __unicode__(self): return self.to_string() class MatchTree(BaseMatchTree): """The MatchTree contains a few "utility" methods which are not necessary for the BaseMatchTree, but add a lot of convenience for writing higher-level rules.""" def _unidentified_leaves(self, valid=lambda leaf: len(leaf.clean_value) >= 2): for leaf in self._leaves(): if not leaf.guess and valid(leaf): yield leaf def unidentified_leaves(self, valid=lambda leaf: len(leaf.clean_value) >= 2): return list(self._unidentified_leaves(valid)) def _leaves_containing(self, property_name): if isinstance(property_name, base_text_type): property_name = [ property_name ] for leaf in self._leaves(): for prop in property_name: if prop in leaf.guess: yield leaf break def leaves_containing(self, property_name): return list(self._leaves_containing(property_name)) def first_leaf_containing(self, property_name): try: return next(self._leaves_containing(property_name)) except StopIteration: return None def _previous_unidentified_leaves(self, node): node_idx = node.node_idx for leaf in self._unidentified_leaves(): if leaf.node_idx < node_idx: yield leaf def previous_unidentified_leaves(self, node): return list(self._previous_unidentified_leaves(node)) def _previous_leaves_containing(self, node, property_name): node_idx = node.node_idx for leaf in self._leaves_containing(property_name): if leaf.node_idx < node_idx: yield leaf def previous_leaves_containing(self, node, property_name): return list(self._previous_leaves_containing(node, property_name)) def is_explicit(self): """Return whether the group was explicitly enclosed by parentheses/square brackets/etc.""" return (self.value[0] + self.value[-1]) in group_delimiters def matched(self): # we need to make a copy here, as the merge functions work in place and # calling them on the match tree would modify it parts = [node.guess for node in self.nodes() if node.guess] parts = copy.deepcopy(parts) # 1- try to merge similar information together and give it a higher # confidence for int_part in ('year', 'season', 'episodeNumber'): merge_similar_guesses(parts, int_part, choose_int) for string_part in ('title', 'series', 'container', 'format', 'releaseGroup', 'website', 'audioCodec', 'videoCodec', 'screenSize', 'episodeFormat', 'audioChannels', 'idNumber'): merge_similar_guesses(parts, string_part, choose_string) # 2- merge the rest, potentially discarding information not properly # merged before result = merge_all(parts, append=['language', 'subtitleLanguage', 'other']) log.debug('Final result: ' + result.nice_string()) return result
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 24570, 7940, 446, 437, 3555, 367, 9519, 316, 2556, 687, 6203, 199, 3, 1898, 334, 67, 9, 7760, 30650, 761, 305, 644, 564, 665, 87, 564, 810, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 24570, 7940, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 6401, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 24570, 7940, 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, 6401, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 6401, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 19977, 2221, 492, 6140, 4256, 12, 1300, 63, 505, 63, 466, 12, 24570, 199, 504, 19977, 2221, 14, 505, 1208, 492, 3633, 63, 875, 12, 620, 63, 4498, 199, 504, 19977, 2221, 14, 7435, 492, 1572, 63, 6933, 20378, 199, 504, 19977, 2221, 14, 11636, 492, 334, 5628, 63, 23079, 63, 71, 10138, 874, 12, 5389, 63, 452, 12, 2574, 11496, 63, 442, 12, 11496, 63, 875, 9, 199, 646, 1331, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3523, 4486, 3987, 8, 7087, 4256, 304, 272, 408, 33, 9814, 3987, 8469, 314, 24787, 3715, 402, 282, 1059, 1901, 2399, 272, 950, 390, 85, 484, 32451, 4652, 1041, 339, 347, 636, 826, 721, 277, 12, 1059, 4581, 13598, 29, 403, 12, 1676, 29, 403, 304, 267, 291, 14, 875, 275, 1059, 267, 291, 14, 3751, 275, 13598, 503, 334, 16, 12, 822, 8, 875, 430, 267, 291, 14, 1708, 275, 1676, 267, 291, 14, 3223, 275, 942, 267, 291, 14, 11636, 275, 24570, 342, 339, 768, 1829, 272, 347, 574, 8, 277, 304, 267, 372, 291, 14, 875, 59, 277, 14, 3751, 59, 16, 2189, 277, 14, 3751, 59, 17, 2677, 339, 768, 1829, 272, 347, 3633, 63, 585, 8, 277, 304, 267, 372, 3633, 63, 875, 8, 277, 14, 585, 9, 339, 768, 1829, 272, 347, 3268, 8, 277, 304, 267, 372, 291, 14, 3751, 59, 16, 61, 339, 768, 1829, 272, 347, 2256, 8, 277, 304, 267, 754, 275, 1211, 8, 277, 14, 11636, 9, 398, 367, 286, 315, 291, 14, 3223, 26, 288, 754, 14, 873, 8, 67, 14, 815, 9, 398, 372, 754, 339, 768, 1829, 272, 347, 1738, 8, 277, 304, 267, 340, 440, 291, 14, 1708, 26, 288, 372, 291, 398, 372, 291, 14, 1708, 14, 1231, 339, 768, 1829, 272, 347, 5818, 8, 277, 304, 267, 340, 291, 14, 374, 63, 8914, 837, 288, 372, 378, 398, 372, 413, 435, 1390, 8, 67, 14, 4631, 367, 286, 315, 291, 14, 3223, 9, 339, 347, 365, 63, 8914, 8, 277, 304, 267, 372, 291, 14, 3223, 508, 942, 339, 347, 1050, 63, 1739, 8, 277, 12, 13598, 304, 267, 1982, 275, 9814, 3987, 8, 277, 14, 875, 12, 13598, 29, 3751, 12, 1676, 29, 277, 9, 267, 291, 14, 3223, 14, 740, 8, 1739, 9, 339, 347, 6484, 8, 277, 12, 4918, 304, 267, 4918, 275, 3355, 8, 4108, 9, 267, 340, 4918, 59, 16, 61, 1137, 378, 26, 288, 4918, 14, 3176, 8, 16, 12, 378, 9, 267, 340, 4918, 1988, 17, 61, 1137, 822, 8, 277, 14, 585, 304, 288, 4918, 14, 740, 8, 552, 8, 277, 14, 585, 430, 398, 367, 1343, 12, 1284, 315, 3482, 8, 4108, 4439, 17, 467, 4918, 59, 17, 28847, 288, 291, 14, 525, 63, 1739, 8, 3751, 2687, 277, 14, 2743, 435, 1343, 12, 639, 291, 14, 2743, 435, 1284, 430, 339, 347, 3715, 63, 265, 63, 4608, 8, 277, 12, 7323, 304, 267, 3268, 275, 378, 267, 367, 286, 315, 7323, 26, 288, 1343, 275, 291, 14, 585, 14, 1623, 8, 67, 12, 3268, 9, 288, 1284, 275, 1343, 435, 822, 8, 67, 9, 288, 291, 14, 525, 63, 1739, 8, 3751, 2687, 277, 14, 2743, 435, 1343, 12, 639, 291, 14, 2743, 435, 1284, 430, 288, 3268, 275, 1284, 339, 347, 3380, 63, 292, 63, 4631, 8, 277, 12, 5818, 304, 267, 340, 5818, 508, 378, 26, 288, 1995, 291, 398, 367, 1982, 315, 291, 14, 3223, 26, 288, 367, 1031, 315, 1982, 14, 2415, 63, 292, 63, 4631, 8, 4631, 446, 413, 304, 355, 1995, 1031, 339, 768, 1829, 272, 347, 1031, 63, 2996, 8, 277, 304, 267, 340, 291, 14, 1708, 365, 488, 26, 288, 372, 6248, 267, 372, 291, 14, 1708, 14, 932, 63, 2996, 435, 334, 277, 14, 1708, 14, 3223, 14, 1080, 8, 277, 16945, 339, 347, 1031, 63, 292, 8, 277, 12, 4280, 304, 267, 340, 440, 4280, 26, 288, 372, 291, 398, 862, 26, 288, 372, 291, 14, 3223, 59, 2996, 59, 16, 20230, 932, 63, 292, 8, 2996, 59, 17, 5728, 267, 871, 26, 288, 746, 1722, 360, 6932, 13, 15025, 1031, 1478, 26, 450, 83, 7, 450, 334, 2996, 4641, 339, 347, 3380, 8, 277, 304, 267, 1995, 291, 267, 367, 1982, 315, 291, 14, 3223, 26, 288, 367, 1031, 315, 1982, 14, 2415, 837, 355, 1995, 1031, 339, 347, 485, 16554, 8, 277, 304, 267, 340, 291, 14, 374, 63, 8914, 837, 288, 1995, 291, 267, 587, 26, 288, 367, 1982, 315, 291, 14, 3223, 26, 355, 327, 4287, 26, 3507, 29, 55, 996, 713, 355, 367, 11747, 315, 1982, 423, 16554, 837, 490, 1995, 11747, 339, 347, 16733, 8, 277, 304, 267, 372, 769, 8, 277, 423, 16554, 1012, 339, 347, 370, 63, 875, 8, 277, 304, 267 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 24570, 7940, 446, 437, 3555, 367, 9519, 316, 2556, 687, 6203, 199, 3, 1898, 334, 67, 9, 7760, 30650, 761, 305, 644, 564, 665, 87, 564, 810, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 24570, 7940, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 6401, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 24570, 7940, 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, 6401, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 6401, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 19977, 2221, 492, 6140, 4256, 12, 1300, 63, 505, 63, 466, 12, 24570, 199, 504, 19977, 2221, 14, 505, 1208, 492, 3633, 63, 875, 12, 620, 63, 4498, 199, 504, 19977, 2221, 14, 7435, 492, 1572, 63, 6933, 20378, 199, 504, 19977, 2221, 14, 11636, 492, 334, 5628, 63, 23079, 63, 71, 10138, 874, 12, 5389, 63, 452, 12, 2574, 11496, 63, 442, 12, 11496, 63, 875, 9, 199, 646, 1331, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3523, 4486, 3987, 8, 7087, 4256, 304, 272, 408, 33, 9814, 3987, 8469, 314, 24787, 3715, 402, 282, 1059, 1901, 2399, 272, 950, 390, 85, 484, 32451, 4652, 1041, 339, 347, 636, 826, 721, 277, 12, 1059, 4581, 13598, 29, 403, 12, 1676, 29, 403, 304, 267, 291, 14, 875, 275, 1059, 267, 291, 14, 3751, 275, 13598, 503, 334, 16, 12, 822, 8, 875, 430, 267, 291, 14, 1708, 275, 1676, 267, 291, 14, 3223, 275, 942, 267, 291, 14, 11636, 275, 24570, 342, 339, 768, 1829, 272, 347, 574, 8, 277, 304, 267, 372, 291, 14, 875, 59, 277, 14, 3751, 59, 16, 2189, 277, 14, 3751, 59, 17, 2677, 339, 768, 1829, 272, 347, 3633, 63, 585, 8, 277, 304, 267, 372, 3633, 63, 875, 8, 277, 14, 585, 9, 339, 768, 1829, 272, 347, 3268, 8, 277, 304, 267, 372, 291, 14, 3751, 59, 16, 61, 339, 768, 1829, 272, 347, 2256, 8, 277, 304, 267, 754, 275, 1211, 8, 277, 14, 11636, 9, 398, 367, 286, 315, 291, 14, 3223, 26, 288, 754, 14, 873, 8, 67, 14, 815, 9, 398, 372, 754, 339, 768, 1829, 272, 347, 1738, 8, 277, 304, 267, 340, 440, 291, 14, 1708, 26, 288, 372, 291, 398, 372, 291, 14, 1708, 14, 1231, 339, 768, 1829, 272, 347, 5818, 8, 277, 304, 267, 340, 291, 14, 374, 63, 8914, 837, 288, 372, 378, 398, 372, 413, 435, 1390, 8, 67, 14, 4631, 367, 286, 315, 291, 14, 3223, 9, 339, 347, 365, 63, 8914, 8, 277, 304, 267, 372, 291, 14, 3223, 508, 942, 339, 347, 1050, 63, 1739, 8, 277, 12, 13598, 304, 267, 1982, 275, 9814, 3987, 8, 277, 14, 875, 12, 13598, 29, 3751, 12, 1676, 29, 277, 9, 267, 291, 14, 3223, 14, 740, 8, 1739, 9, 339, 347, 6484, 8, 277, 12, 4918, 304, 267, 4918, 275, 3355, 8, 4108, 9, 267, 340, 4918, 59, 16, 61, 1137, 378, 26, 288, 4918, 14, 3176, 8, 16, 12, 378, 9, 267, 340, 4918, 1988, 17, 61, 1137, 822, 8, 277, 14, 585, 304, 288, 4918, 14, 740, 8, 552, 8, 277, 14, 585, 430, 398, 367, 1343, 12, 1284, 315, 3482, 8, 4108, 4439, 17, 467, 4918, 59, 17, 28847, 288, 291, 14, 525, 63, 1739, 8, 3751, 2687, 277, 14, 2743, 435, 1343, 12, 639, 291, 14, 2743, 435, 1284, 430, 339, 347, 3715, 63, 265, 63, 4608, 8, 277, 12, 7323, 304, 267, 3268, 275, 378, 267, 367, 286, 315, 7323, 26, 288, 1343, 275, 291, 14, 585, 14, 1623, 8, 67, 12, 3268, 9, 288, 1284, 275, 1343, 435, 822, 8, 67, 9, 288, 291, 14, 525, 63, 1739, 8, 3751, 2687, 277, 14, 2743, 435, 1343, 12, 639, 291, 14, 2743, 435, 1284, 430, 288, 3268, 275, 1284, 339, 347, 3380, 63, 292, 63, 4631, 8, 277, 12, 5818, 304, 267, 340, 5818, 508, 378, 26, 288, 1995, 291, 398, 367, 1982, 315, 291, 14, 3223, 26, 288, 367, 1031, 315, 1982, 14, 2415, 63, 292, 63, 4631, 8, 4631, 446, 413, 304, 355, 1995, 1031, 339, 768, 1829, 272, 347, 1031, 63, 2996, 8, 277, 304, 267, 340, 291, 14, 1708, 365, 488, 26, 288, 372, 6248, 267, 372, 291, 14, 1708, 14, 932, 63, 2996, 435, 334, 277, 14, 1708, 14, 3223, 14, 1080, 8, 277, 16945, 339, 347, 1031, 63, 292, 8, 277, 12, 4280, 304, 267, 340, 440, 4280, 26, 288, 372, 291, 398, 862, 26, 288, 372, 291, 14, 3223, 59, 2996, 59, 16, 20230, 932, 63, 292, 8, 2996, 59, 17, 5728, 267, 871, 26, 288, 746, 1722, 360, 6932, 13, 15025, 1031, 1478, 26, 450, 83, 7, 450, 334, 2996, 4641, 339, 347, 3380, 8, 277, 304, 267, 1995, 291, 267, 367, 1982, 315, 291, 14, 3223, 26, 288, 367, 1031, 315, 1982, 14, 2415, 837, 355, 1995, 1031, 339, 347, 485, 16554, 8, 277, 304, 267, 340, 291, 14, 374, 63, 8914, 837, 288, 1995, 291, 267, 587, 26, 288, 367, 1982, 315, 291, 14, 3223, 26, 355, 327, 4287, 26, 3507, 29, 55, 996, 713, 355, 367, 11747, 315, 1982, 423, 16554, 837, 490, 1995, 11747, 339, 347, 16733, 8, 277, 304, 267, 372, 769, 8, 277, 423, 16554, 1012, 339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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pschwartz/ansible
lib/ansible/cli/playbook.py
11
8150
#!/usr/bin/env python # (c) 2012, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ######################################################## import os import stat import sys from ansible import constants as C from ansible.cli import CLI from ansible.errors import AnsibleError, AnsibleOptionsError from ansible.executor.playbook_executor import PlaybookExecutor from ansible.inventory import Inventory from ansible.parsing import DataLoader from ansible.parsing.splitter import parse_kv from ansible.playbook import Playbook from ansible.playbook.task import Task from ansible.utils.display import Display from ansible.utils.unicode import to_unicode from ansible.utils.vars import combine_vars from ansible.utils.vault import read_vault_file from ansible.vars import VariableManager #--------------------------------------------------------------------------------------------------- class PlaybookCLI(CLI): ''' code behind ansible playbook cli''' def parse(self): # create parser for CLI options parser = CLI.base_parser( usage = "%prog playbook.yml", connect_opts=True, meta_opts=True, runas_opts=True, subset_opts=True, check_opts=True, diff_opts=True, runtask_opts=True, vault_opts=True, fork_opts=True, ) # ansible playbook specific opts parser.add_option('--list-tasks', dest='listtasks', action='store_true', help="list all tasks that would be executed") parser.add_option('--step', dest='step', action='store_true', help="one-step-at-a-time: confirm each task before running") parser.add_option('--start-at-task', dest='start_at', help="start the playbook at the task matching this name") parser.add_option('--list-tags', dest='listtags', action='store_true', help="list all available tags") self.options, self.args = parser.parse_args() self.parser = parser if len(self.args) == 0: raise AnsibleOptionsError("You must specify a playbook file to run") self.display.verbosity = self.options.verbosity self.validate_conflicts(runas_opts=True, vault_opts=True) def run(self): # Note: slightly wrong, this is written so that implicit localhost # Manage passwords sshpass = None becomepass = None vault_pass = None passwords = {} # don't deal with privilege escalation or passwords when we don't need to if not self.options.listhosts and not self.options.listtasks and not self.options.listtags and not self.options.syntax: self.normalize_become_options() (sshpass, becomepass) = self.ask_passwords() passwords = { 'conn_pass': sshpass, 'become_pass': becomepass } if self.options.vault_password_file: # read vault_pass from a file vault_pass = read_vault_file(self.options.vault_password_file) elif self.options.ask_vault_pass: vault_pass = self.ask_vault_passwords(ask_vault_pass=True, ask_new_vault_pass=False, confirm_new=False)[0] loader = DataLoader(vault_password=vault_pass) extra_vars = {} for extra_vars_opt in self.options.extra_vars: extra_vars_opt = to_unicode(extra_vars_opt, errors='strict') if extra_vars_opt.startswith(u"@"): # Argument is a YAML file (JSON is a subset of YAML) data = loader.load_from_file(extra_vars_opt[1:]) elif extra_vars_opt and extra_vars_opt[0] in u'[{': # Arguments as YAML data = loader.load(extra_vars_opt) else: # Arguments as Key-value data = parse_kv(extra_vars_opt) extra_vars = combine_vars(extra_vars, data) # FIXME: this should be moved inside the playbook executor code only_tags = self.options.tags.split(",") skip_tags = self.options.skip_tags if self.options.skip_tags is not None: skip_tags = self.options.skip_tags.split(",") # initial error check, to make sure all specified playbooks are accessible # before we start running anything through the playbook executor for playbook in self.args: if not os.path.exists(playbook): raise AnsibleError("the playbook: %s could not be found" % playbook) if not (os.path.isfile(playbook) or stat.S_ISFIFO(os.stat(playbook).st_mode)): raise AnsibleError("the playbook: %s does not appear to be a file" % playbook) # create the variable manager, which will be shared throughout # the code, ensuring a consistent view of global variables variable_manager = VariableManager() variable_manager.extra_vars = extra_vars # create the inventory, and filter it based on the subset specified (if any) inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=self.options.inventory) variable_manager.set_inventory(inventory) # (which is not returned in list_hosts()) is taken into account for # warning if inventory is empty. But it can't be taken into account for # checking if limit doesn't match any hosts. Instead we don't worry about # limit if only implicit localhost was in inventory to start with. # # Fix this when we rewrite inventory by making localhost a real host (and thus show up in list_hosts()) no_hosts = False if len(inventory.list_hosts()) == 0: # Empty inventory self.display.warning("provided hosts list is empty, only localhost is available") no_hosts = True inventory.subset(self.options.subset) if len(inventory.list_hosts()) == 0 and no_hosts is False: # Invalid limit raise AnsibleError("Specified --limit does not match any hosts") # create the playbook executor, which manages running the plays via a task queue manager pbex = PlaybookExecutor(playbooks=self.args, inventory=inventory, variable_manager=variable_manager, loader=loader, display=self.display, options=self.options, passwords=passwords) results = pbex.run() if isinstance(results, list): for p in results: self.display.display('\nplaybook: %s\n' % p['playbook']) for play in p['plays']: if self.options.listhosts: self.display.display("\n %s (%s): host count=%d" % (play['name'], play['pattern'], len(play['hosts']))) for host in play['hosts']: self.display.display(" %s" % host) if self.options.listtasks: #TODO: do we want to display block info? self.display.display("\n %s" % (play['name'])) for task in play['tasks']: self.display.display(" %s" % task) if self.options.listtags: #TODO: fix once we figure out block handling above self.display.display("\n %s: tags count=%d" % (play['name'], len(play['tags']))) for tag in play['tags']: self.display.display(" %s" % tag) return 0 else: return results
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 26207, 199, 646, 747, 199, 646, 5672, 199, 646, 984, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2764, 492, 14214, 199, 504, 3242, 14, 2550, 492, 13358, 12, 2622, 4558, 547, 199, 504, 3242, 14, 13471, 14, 14205, 63, 13471, 492, 16527, 2706, 16752, 199, 504, 3242, 14, 7212, 492, 19337, 199, 504, 3242, 14, 11059, 492, 3918, 5455, 199, 504, 3242, 14, 11059, 14, 25234, 492, 2198, 63, 11475, 199, 504, 3242, 14, 14205, 492, 16527, 2706, 199, 504, 3242, 14, 14205, 14, 1765, 492, 8495, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 14, 1208, 14, 2975, 492, 370, 63, 2975, 199, 504, 3242, 14, 1208, 14, 2936, 492, 13323, 63, 2936, 199, 504, 3242, 14, 1208, 14, 10077, 492, 1586, 63, 10077, 63, 493, 199, 504, 3242, 14, 2936, 492, 4905, 2988, 199, 199, 7656, 1444, 2595, 199, 199, 533, 16527, 2706, 7802, 8, 7802, 304, 272, 1449, 1233, 22172, 3242, 15695, 5053, 2344, 339, 347, 2198, 8, 277, 304, 398, 327, 1218, 1798, 367, 14214, 1511, 267, 1798, 275, 14214, 14, 1095, 63, 2087, 8, 288, 4503, 275, 2071, 6595, 15695, 14, 11714, 401, 288, 4907, 63, 3291, 29, 549, 12, 288, 3404, 63, 3291, 29, 549, 12, 288, 1255, 305, 63, 3291, 29, 549, 12, 288, 10026, 63, 3291, 29, 549, 12, 288, 1104, 63, 3291, 29, 549, 12, 288, 3915, 63, 3291, 29, 549, 12, 288, 519, 638, 813, 63, 3291, 29, 549, 12, 288, 12738, 63, 3291, 29, 549, 12, 288, 14926, 63, 3291, 29, 549, 12, 267, 776, 398, 327, 3242, 15695, 2488, 3999, 267, 1798, 14, 525, 63, 1422, 4517, 513, 13, 5054, 297, 2053, 534, 513, 5054, 297, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 513, 1006, 6527, 626, 3955, 506, 7934, 531, 267, 1798, 14, 525, 63, 1422, 4517, 2926, 297, 2053, 534, 2926, 297, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 368, 13, 2926, 13, 292, 13, 65, 13, 521, 26, 12679, 1924, 2120, 2544, 3879, 531, 267, 1798, 14, 525, 63, 1422, 4517, 928, 13, 292, 13, 1765, 297, 2053, 534, 928, 63, 292, 297, 288, 1720, 628, 928, 314, 15695, 737, 314, 2120, 4877, 642, 536, 531, 267, 1798, 14, 525, 63, 1422, 4517, 513, 13, 2969, 297, 2053, 534, 513, 2969, 297, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 513, 1006, 2808, 3762, 531, 398, 291, 14, 1419, 12, 291, 14, 589, 275, 1798, 14, 1122, 63, 589, 342, 7318, 291, 14, 2087, 275, 1798, 398, 340, 822, 8, 277, 14, 589, 9, 508, 378, 26, 288, 746, 2622, 4558, 547, 480, 5556, 1471, 4165, 282, 15695, 570, 370, 1255, 531, 398, 291, 14, 2918, 14, 9833, 275, 291, 14, 1419, 14, 9833, 267, 291, 14, 3502, 63, 22654, 8, 1065, 305, 63, 3291, 29, 549, 12, 12738, 63, 3291, 29, 549, 9, 339, 347, 1255, 8, 277, 304, 398, 327, 3390, 26, 18023, 6835, 12, 642, 365, 5313, 880, 626, 9227, 11667, 267, 327, 14944, 19572, 267, 8635, 1529, 259, 275, 488, 267, 8649, 1529, 259, 275, 488, 267, 12738, 63, 1529, 275, 488, 267, 19572, 275, 1052, 398, 327, 2793, 1133, 7962, 543, 1979, 17228, 325, 4732, 425, 503, 19572, 1380, 781, 2793, 1133, 1929, 370, 267, 340, 440, 291, 14, 1419, 14, 513, 5146, 436, 440, 291, 14, 1419, 14, 513, 5054, 436, 440, 291, 14, 1419, 14, 513, 2969, 436, 440, 291, 14, 1419, 14, 7093, 26, 288, 291, 14, 7721, 63, 13970, 63, 1419, 342, 288, 334, 5510, 1529, 12, 8649, 1529, 9, 275, 291, 14, 813, 63, 28608, 342, 288, 19572, 275, 469, 283, 1631, 63, 1529, 356, 8635, 1529, 12, 283, 13970, 63, 1529, 356, 8649, 1529, 789, 398, 340, 291, 14, 1419, 14, 10077, 63, 2060, 63, 493, 26, 288, 327, 1586, 12738, 63, 1529, 687, 282, 570, 288, 12738, 63, 1529, 275, 1586, 63, 10077, 63, 493, 8, 277, 14, 1419, 14, 10077, 63, 2060, 63, 493, 9, 267, 916, 291, 14, 1419, 14, 813, 63, 10077, 63, 1529, 26, 288, 12738, 63, 1529, 275, 291, 14, 813, 63, 10077, 63, 28608, 8, 813, 63, 10077, 63, 1529, 29, 549, 12, 7198, 63, 1222, 63, 10077, 63, 1529, 29, 797, 12, 12679, 63, 1222, 29, 797, 2788, 16, 61, 398, 5077, 275, 3918, 5455, 8, 10077, 63, 2060, 29, 10077, 63, 1529, 9, 398, 2402, 63, 2936, 275, 1052, 267, 367, 2402, 63, 2936, 63, 2992, 315, 291, 14, 1419, 14, 2911, 63, 2936, 26, 288, 2402, 63, 2936, 63, 2992, 275, 370, 63, 2975, 8, 2911, 63, 2936, 63, 2992, 12, 2552, 534, 4768, 358, 288, 340, 2402, 63, 2936, 63, 2992, 14, 2460, 8, 85, 2, 32, 2349, 355, 327, 5886, 365, 282, 18916, 570, 334, 6243, 365, 282, 10026, 402, 18916, 9, 355, 666, 275, 5077, 14, 912, 63, 504, 63, 493, 8, 2911, 63, 2936, 63, 2992, 59, 17, 5728, 288, 916, 2402, 63, 2936, 63, 2992, 436, 2402, 63, 2936, 63, 2992, 59, 16 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 26207, 199, 646, 747, 199, 646, 5672, 199, 646, 984, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 2764, 492, 14214, 199, 504, 3242, 14, 2550, 492, 13358, 12, 2622, 4558, 547, 199, 504, 3242, 14, 13471, 14, 14205, 63, 13471, 492, 16527, 2706, 16752, 199, 504, 3242, 14, 7212, 492, 19337, 199, 504, 3242, 14, 11059, 492, 3918, 5455, 199, 504, 3242, 14, 11059, 14, 25234, 492, 2198, 63, 11475, 199, 504, 3242, 14, 14205, 492, 16527, 2706, 199, 504, 3242, 14, 14205, 14, 1765, 492, 8495, 199, 504, 3242, 14, 1208, 14, 2918, 492, 12175, 199, 504, 3242, 14, 1208, 14, 2975, 492, 370, 63, 2975, 199, 504, 3242, 14, 1208, 14, 2936, 492, 13323, 63, 2936, 199, 504, 3242, 14, 1208, 14, 10077, 492, 1586, 63, 10077, 63, 493, 199, 504, 3242, 14, 2936, 492, 4905, 2988, 199, 199, 7656, 1444, 2595, 199, 199, 533, 16527, 2706, 7802, 8, 7802, 304, 272, 1449, 1233, 22172, 3242, 15695, 5053, 2344, 339, 347, 2198, 8, 277, 304, 398, 327, 1218, 1798, 367, 14214, 1511, 267, 1798, 275, 14214, 14, 1095, 63, 2087, 8, 288, 4503, 275, 2071, 6595, 15695, 14, 11714, 401, 288, 4907, 63, 3291, 29, 549, 12, 288, 3404, 63, 3291, 29, 549, 12, 288, 1255, 305, 63, 3291, 29, 549, 12, 288, 10026, 63, 3291, 29, 549, 12, 288, 1104, 63, 3291, 29, 549, 12, 288, 3915, 63, 3291, 29, 549, 12, 288, 519, 638, 813, 63, 3291, 29, 549, 12, 288, 12738, 63, 3291, 29, 549, 12, 288, 14926, 63, 3291, 29, 549, 12, 267, 776, 398, 327, 3242, 15695, 2488, 3999, 267, 1798, 14, 525, 63, 1422, 4517, 513, 13, 5054, 297, 2053, 534, 513, 5054, 297, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 513, 1006, 6527, 626, 3955, 506, 7934, 531, 267, 1798, 14, 525, 63, 1422, 4517, 2926, 297, 2053, 534, 2926, 297, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 368, 13, 2926, 13, 292, 13, 65, 13, 521, 26, 12679, 1924, 2120, 2544, 3879, 531, 267, 1798, 14, 525, 63, 1422, 4517, 928, 13, 292, 13, 1765, 297, 2053, 534, 928, 63, 292, 297, 288, 1720, 628, 928, 314, 15695, 737, 314, 2120, 4877, 642, 536, 531, 267, 1798, 14, 525, 63, 1422, 4517, 513, 13, 2969, 297, 2053, 534, 513, 2969, 297, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 513, 1006, 2808, 3762, 531, 398, 291, 14, 1419, 12, 291, 14, 589, 275, 1798, 14, 1122, 63, 589, 342, 7318, 291, 14, 2087, 275, 1798, 398, 340, 822, 8, 277, 14, 589, 9, 508, 378, 26, 288, 746, 2622, 4558, 547, 480, 5556, 1471, 4165, 282, 15695, 570, 370, 1255, 531, 398, 291, 14, 2918, 14, 9833, 275, 291, 14, 1419, 14, 9833, 267, 291, 14, 3502, 63, 22654, 8, 1065, 305, 63, 3291, 29, 549, 12, 12738, 63, 3291, 29, 549, 9, 339, 347, 1255, 8, 277, 304, 398, 327, 3390, 26, 18023, 6835, 12, 642, 365, 5313, 880, 626, 9227, 11667, 267, 327, 14944, 19572, 267, 8635, 1529, 259, 275, 488, 267, 8649, 1529, 259, 275, 488, 267, 12738, 63, 1529, 275, 488, 267, 19572, 275, 1052, 398, 327, 2793, 1133, 7962, 543, 1979, 17228, 325, 4732, 425, 503, 19572, 1380, 781, 2793, 1133, 1929, 370, 267, 340, 440, 291, 14, 1419, 14, 513, 5146, 436, 440, 291, 14, 1419, 14, 513, 5054, 436, 440, 291, 14, 1419, 14, 513, 2969, 436, 440, 291, 14, 1419, 14, 7093, 26, 288, 291, 14, 7721, 63, 13970, 63, 1419, 342, 288, 334, 5510, 1529, 12, 8649, 1529, 9, 275, 291, 14, 813, 63, 28608, 342, 288, 19572, 275, 469, 283, 1631, 63, 1529, 356, 8635, 1529, 12, 283, 13970, 63, 1529, 356, 8649, 1529, 789, 398, 340, 291, 14, 1419, 14, 10077, 63, 2060, 63, 493, 26, 288, 327, 1586, 12738, 63, 1529, 687, 282, 570, 288, 12738, 63, 1529, 275, 1586, 63, 10077, 63, 493, 8, 277, 14, 1419, 14, 10077, 63, 2060, 63, 493, 9, 267, 916, 291, 14, 1419, 14, 813, 63, 10077, 63, 1529, 26, 288, 12738, 63, 1529, 275, 291, 14, 813, 63, 10077, 63, 28608, 8, 813, 63, 10077, 63, 1529, 29, 549, 12, 7198, 63, 1222, 63, 10077, 63, 1529, 29, 797, 12, 12679, 63, 1222, 29, 797, 2788, 16, 61, 398, 5077, 275, 3918, 5455, 8, 10077, 63, 2060, 29, 10077, 63, 1529, 9, 398, 2402, 63, 2936, 275, 1052, 267, 367, 2402, 63, 2936, 63, 2992, 315, 291, 14, 1419, 14, 2911, 63, 2936, 26, 288, 2402, 63, 2936, 63, 2992, 275, 370, 63, 2975, 8, 2911, 63, 2936, 63, 2992, 12, 2552, 534, 4768, 358, 288, 340, 2402, 63, 2936, 63, 2992, 14, 2460, 8, 85, 2, 32, 2349, 355, 327, 5886, 365, 282, 18916, 570, 334, 6243, 365, 282, 10026, 402, 18916, 9, 355, 666, 275, 5077, 14, 912, 63, 504, 63, 493, 8, 2911, 63, 2936, 63, 2992, 59, 17, 5728, 288, 916, 2402, 63, 2936, 63, 2992, 436, 2402, 63, 2936, 63, 2992, 59, 16, 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,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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 ]
agoodm/climate
ocw-ui/backend/local_file_metadata_extractors.py
12
7096
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ''' Helpers for local model/observation file metadata extraction. ''' import sys import netCDF4 import json from bottle import Bottle, request, route, response import ocw.utils lfme_app = Bottle() @lfme_app.route('/list_latlon/<file_path:path>') def list_latlon(file_path): ''' Retrieve lat/lon information from given file. :param file_path: Path to the NetCDF file from which lat/lon information should be extracted :type file_path: string: :returns: Dictionary containing lat/lon information if successful, otherwise failure information is returned. **Example successful JSON return** .. sourcecode:: javascript { 'success': true, 'lat_name': The guessed latitude variable name, 'lon_name': the guessed longitude variable name, 'lat_min': The minimum latitude value, 'lat_max': The maximum latitude value, 'lon_min': The minimum longitude value, 'lon_max': The maximum longitude value } **Example failure JSON return** .. sourcecode:: javascript { 'success': false, 'variables': List of all variables present in the NetCDF file } ''' in_file = netCDF4.Dataset(file_path, mode='r') var_names = set([key.encode().lower() for key in in_file.variables.keys()]) var_names_list = list(var_names) lat_name_guesses = set(['latitude','lat','lats','latitudes']) lon_name_guesses = set(['longitude','lon','lons','longitudes']) # Attempt to determine the lat name found_lat_name = False # Find the intersection (if there is one) of the var names with the lat guesses lat_guesses = list(var_names & lat_name_guesses) if len(lat_guesses) >= 1: found_lat_name = True lat_name = var_names_list[var_names_list.index(lat_guesses[0])] lats = in_file.variables[lat_name][:] # Change 0 - 360 degree values to be -180 to 180 lats[lats > 180] = lats[lats > 180] - 360 lat_min = float(lats.min()) lat_max = float(lats.max()) # Attempt to determine the lon name found_lon_name = False # Find the intersection (if there is one) of the var names with the lon guesses lon_guesses = list(var_names & lon_name_guesses) if len(lon_guesses) >= 1: found_lon_name = True lon_name = var_names_list[var_names_list.index(lon_guesses[0])] lons = in_file.variables[lon_name][:] # Change 0 - 360 degree values to be -180 to 180 lons[lons > 180] = lons[lons > 180] - 360 lon_min = float(lons.min()) lon_max = float(lons.max()) in_file.close() success = found_lat_name and found_lon_name if success: values = [success, lat_name, lon_name, lat_min, lat_max, lon_min, lon_max] value_names = ['success', 'lat_name', 'lon_name', 'lat_min', 'lat_max', 'lon_min', 'lon_max'] output = dict(zip(value_names, values)) else: output = {'success': success, 'variables': var_names_list} if request.query.callback: return '%s(%s)' % (request.query.callback, json.dumps(output)) return output @lfme_app.route('/list_time/<file_path:path>') def list_time(file_path): ''' Retrieve time information from provided file. :param file_path: Path to the NetCDF file from which time information should be extracted :type file_path: String: :returns: Dictionary containing time information if successful, otherwise failure information is returned. **Example successful JSON return** .. sourcecode:: javascript { "success": true, "time_name": The guessed time variable name, "start_time": "1988-06-10 00:00:00", "end_time": "2008-01-27 00:00:00" } **Example failure JSON return** .. sourcecode:: javascript { "success": false "variables": List of all variable names in the file } ''' in_file = netCDF4.Dataset(file_path, mode='r') var_names = set([key.encode().lower() for key in in_file.variables.keys()]) var_names_list = list(var_names) time_name_guesses = set(['time', 'times', 't', 'date', 'dates', 'julian']) # Find the intersection (if there is one) of the var names with the lat guesses time_guesses = list(var_names & time_name_guesses) if len(time_guesses) >= 1: # Convert time data to datetime objects time_var_name = time_guesses[0] times = ocw.utils.decode_time_values(in_file, time_var_name) start_time = str(min(times)) end_time = str(max(times)) output = { 'success': True, 'time_name': time_var_name, 'start_time': start_time, 'end_time': end_time } else: output = {'success': False, 'variables': var_names_list} if request.query.callback: return '%s(%s)' % (request.query.callback, json.dumps(output)) return output @lfme_app.route('/list_vars/<file_path:path>') def list_vars(file_path): ''' Retrieve variable names from file. :param file_path: Path to the NetCDF file from which variable information should be extracted :type file_path: String: :returns: Dictionary containing variable information if succesful, otherwise failure information is returned. **Example successful JSON return** .. sourcecode:: javascript { "success": true, "variables": List of variable names in the file } **Example failure JSON return** .. sourcecode:: javascript { "success": false } ''' try: in_file = netCDF4.Dataset(file_path, mode='r') except RuntimeError: output = {'success': False} else: output = {'success': True, 'variables': in_file.variables.keys()} in_file.close() finally: if request.query.callback: return "%s(%s)" % (request.query.callback, json.dumps(output)) return output @lfme_app.hook('after_request') def enable_cors(): ''' Allow Cross-Origin Resource Sharing for all URLs. ''' response.headers['Access-Control-Allow-Origin'] = '*'
apache-2.0
[ 3, 199, 3, 221, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 221, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 221, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 221, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 221, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 221, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 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, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 2344, 11642, 83, 367, 2257, 1402, 15, 24299, 570, 3341, 19967, 14, 1449, 199, 199, 646, 984, 199, 646, 1851, 18967, 20, 199, 646, 2022, 199, 199, 504, 5888, 1118, 492, 24896, 1118, 12, 1056, 12, 7475, 12, 1177, 199, 199, 646, 4244, 87, 14, 1208, 199, 199, 276, 278, 63, 571, 275, 24896, 1118, 342, 199, 199, 32, 276, 278, 63, 571, 14, 4449, 2336, 513, 63, 4452, 5298, 8316, 493, 63, 515, 26, 515, 5971, 199, 318, 769, 63, 4452, 5298, 8, 493, 63, 515, 304, 272, 1449, 13939, 8396, 15, 5298, 2556, 687, 1627, 570, 14, 2286, 520, 635, 570, 63, 515, 26, 6912, 370, 314, 5365, 18967, 570, 687, 1314, 8396, 15, 5298, 2556, 267, 1077, 506, 12509, 272, 520, 466, 570, 63, 515, 26, 1059, 26, 339, 520, 5808, 26, 11932, 3035, 8396, 15, 5298, 2556, 340, 9512, 12, 4257, 267, 5988, 2556, 365, 2138, 14, 339, 1011, 9846, 9512, 4840, 372, 538, 339, 2508, 25468, 447, 18910, 398, 469, 288, 283, 3742, 356, 2549, 12, 288, 283, 4452, 63, 354, 356, 710, 29950, 18896, 1750, 536, 12, 288, 283, 5298, 63, 354, 356, 314, 29950, 18154, 1750, 536, 12, 288, 283, 4452, 63, 827, 356, 710, 7481, 18896, 574, 12, 288, 283, 4452, 63, 988, 356, 710, 5696, 18896, 574, 12, 288, 283, 5298, 63, 827, 356, 710, 7481, 18154, 574, 12, 288, 283, 5298, 63, 988, 356, 710, 5696, 18154, 574, 267, 789, 339, 1011, 9846, 5988, 4840, 372, 538, 339, 2508, 25468, 447, 18910, 398, 469, 288, 283, 3742, 356, 3055, 12, 288, 283, 3669, 356, 3820, 402, 1006, 2860, 3451, 315, 314, 5365, 18967, 570, 267, 789, 272, 1449, 272, 315, 63, 493, 275, 1851, 18967, 20, 14, 9271, 8, 493, 63, 515, 12, 818, 534, 82, 358, 339, 2729, 63, 1247, 275, 663, 779, 498, 14, 2143, 1252, 2325, 342, 367, 790, 315, 315, 63, 493, 14, 3669, 14, 1612, 9383, 272, 2729, 63, 1247, 63, 513, 275, 769, 8, 1391, 63, 1247, 9, 339, 8396, 63, 354, 63, 71, 10138, 874, 275, 663, 2941, 13331, 1673, 4452, 1673, 76, 1956, 1673, 416, 6403, 26783, 1105, 272, 6132, 63, 354, 63, 71, 10138, 874, 275, 663, 2941, 13803, 1673, 5298, 1673, 76, 4654, 1673, 2809, 390, 26783, 1105, 339, 327, 23115, 370, 6705, 314, 8396, 536, 272, 1911, 63, 4452, 63, 354, 275, 756, 339, 327, 6668, 314, 16223, 334, 692, 2337, 365, 1373, 9, 402, 314, 2729, 1561, 543, 314, 8396, 19977, 874, 272, 8396, 63, 71, 10138, 874, 275, 769, 8, 1391, 63, 1247, 1253, 8396, 63, 354, 63, 71, 10138, 874, 9, 339, 340, 822, 8, 4452, 63, 71, 10138, 874, 9, 2356, 413, 26, 267, 1911, 63, 4452, 63, 354, 275, 715, 267, 8396, 63, 354, 275, 2729, 63, 1247, 63, 513, 59, 1391, 63, 1247, 63, 513, 14, 1080, 8, 4452, 63, 71, 10138, 874, 59, 16, 12457, 398, 634, 1956, 275, 315, 63, 493, 14, 3669, 59, 4452, 63, 354, 61, 5873, 398, 327, 7743, 378, 446, 19434, 13666, 1338, 370, 506, 446, 7663, 370, 13576, 267, 634, 1956, 59, 76, 1956, 690, 13576, 61, 275, 634, 1956, 59, 76, 1956, 690, 13576, 61, 446, 19434, 398, 8396, 63, 827, 275, 2069, 8, 76, 1956, 14, 827, 1012, 267, 8396, 63, 988, 275, 2069, 8, 76, 1956, 14, 988, 1012, 339, 327, 23115, 370, 6705, 314, 6132, 536, 272, 1911, 63, 5298, 63, 354, 275, 756, 339, 327, 6668, 314, 16223, 334, 692, 2337, 365, 1373, 9, 402, 314, 2729, 1561, 543, 314, 6132, 19977, 874, 272, 6132, 63, 71, 10138, 874, 275, 769, 8, 1391, 63, 1247, 1253, 6132, 63, 354, 63, 71, 10138, 874, 9, 339, 340, 822, 8, 5298, 63, 71, 10138, 874, 9, 2356, 413, 26, 267, 1911, 63, 5298, 63, 354, 275, 715, 267, 6132, 63, 354, 275, 2729, 63, 1247, 63, 513, 59, 1391, 63, 1247, 63, 513, 14, 1080, 8, 5298, 63, 71, 10138, 874, 59, 16, 12457, 398, 634, 4654, 275, 315, 63, 493, 14, 3669, 59, 5298, 63, 354, 61, 5873, 398, 327, 7743, 378, 446, 19434, 13666, 1338, 370, 506, 446, 7663, 370, 13576, 267, 634, 4654, 59, 76, 4654, 690, 13576, 61, 275, 634, 4654, 59, 76, 4654, 690, 13576, 61, 446, 19434, 398, 6132, 63, 827, 275, 2069, 8, 76, 4654, 14, 827, 1012, 267, 6132, 63, 988, 275, 2069, 8, 76, 4654, 14, 988, 1012, 339, 315, 63, 493, 14, 1600, 342, 339, 3182, 275, 1911, 63, 4452, 63, 354, 436, 1911, 63, 5298, 63, 354, 272, 340, 3182, 26, 267, 1338, 275, 359, 3742, 12, 8396, 63, 354, 12, 6132, 63, 354, 12, 8396, 63, 827, 12, 8396, 63, 988, 12, 6132, 63, 827, 12, 6132, 63, 988, 61, 267, 574, 63, 1247, 275, 788, 3742, 297, 283, 4452, 63, 354, 297, 283, 5298, 63, 354, 297, 283, 4452, 63, 827, 297, 283, 4452, 63, 988, 297, 283, 5298, 63, 827, 297, 283, 5298, 63, 988, 418, 267, 1072, 275, 1211, 8, 3065 ]
[ 199, 3, 221, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 221, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 221, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 221, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 221, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 221, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 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, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 2344, 11642, 83, 367, 2257, 1402, 15, 24299, 570, 3341, 19967, 14, 1449, 199, 199, 646, 984, 199, 646, 1851, 18967, 20, 199, 646, 2022, 199, 199, 504, 5888, 1118, 492, 24896, 1118, 12, 1056, 12, 7475, 12, 1177, 199, 199, 646, 4244, 87, 14, 1208, 199, 199, 276, 278, 63, 571, 275, 24896, 1118, 342, 199, 199, 32, 276, 278, 63, 571, 14, 4449, 2336, 513, 63, 4452, 5298, 8316, 493, 63, 515, 26, 515, 5971, 199, 318, 769, 63, 4452, 5298, 8, 493, 63, 515, 304, 272, 1449, 13939, 8396, 15, 5298, 2556, 687, 1627, 570, 14, 2286, 520, 635, 570, 63, 515, 26, 6912, 370, 314, 5365, 18967, 570, 687, 1314, 8396, 15, 5298, 2556, 267, 1077, 506, 12509, 272, 520, 466, 570, 63, 515, 26, 1059, 26, 339, 520, 5808, 26, 11932, 3035, 8396, 15, 5298, 2556, 340, 9512, 12, 4257, 267, 5988, 2556, 365, 2138, 14, 339, 1011, 9846, 9512, 4840, 372, 538, 339, 2508, 25468, 447, 18910, 398, 469, 288, 283, 3742, 356, 2549, 12, 288, 283, 4452, 63, 354, 356, 710, 29950, 18896, 1750, 536, 12, 288, 283, 5298, 63, 354, 356, 314, 29950, 18154, 1750, 536, 12, 288, 283, 4452, 63, 827, 356, 710, 7481, 18896, 574, 12, 288, 283, 4452, 63, 988, 356, 710, 5696, 18896, 574, 12, 288, 283, 5298, 63, 827, 356, 710, 7481, 18154, 574, 12, 288, 283, 5298, 63, 988, 356, 710, 5696, 18154, 574, 267, 789, 339, 1011, 9846, 5988, 4840, 372, 538, 339, 2508, 25468, 447, 18910, 398, 469, 288, 283, 3742, 356, 3055, 12, 288, 283, 3669, 356, 3820, 402, 1006, 2860, 3451, 315, 314, 5365, 18967, 570, 267, 789, 272, 1449, 272, 315, 63, 493, 275, 1851, 18967, 20, 14, 9271, 8, 493, 63, 515, 12, 818, 534, 82, 358, 339, 2729, 63, 1247, 275, 663, 779, 498, 14, 2143, 1252, 2325, 342, 367, 790, 315, 315, 63, 493, 14, 3669, 14, 1612, 9383, 272, 2729, 63, 1247, 63, 513, 275, 769, 8, 1391, 63, 1247, 9, 339, 8396, 63, 354, 63, 71, 10138, 874, 275, 663, 2941, 13331, 1673, 4452, 1673, 76, 1956, 1673, 416, 6403, 26783, 1105, 272, 6132, 63, 354, 63, 71, 10138, 874, 275, 663, 2941, 13803, 1673, 5298, 1673, 76, 4654, 1673, 2809, 390, 26783, 1105, 339, 327, 23115, 370, 6705, 314, 8396, 536, 272, 1911, 63, 4452, 63, 354, 275, 756, 339, 327, 6668, 314, 16223, 334, 692, 2337, 365, 1373, 9, 402, 314, 2729, 1561, 543, 314, 8396, 19977, 874, 272, 8396, 63, 71, 10138, 874, 275, 769, 8, 1391, 63, 1247, 1253, 8396, 63, 354, 63, 71, 10138, 874, 9, 339, 340, 822, 8, 4452, 63, 71, 10138, 874, 9, 2356, 413, 26, 267, 1911, 63, 4452, 63, 354, 275, 715, 267, 8396, 63, 354, 275, 2729, 63, 1247, 63, 513, 59, 1391, 63, 1247, 63, 513, 14, 1080, 8, 4452, 63, 71, 10138, 874, 59, 16, 12457, 398, 634, 1956, 275, 315, 63, 493, 14, 3669, 59, 4452, 63, 354, 61, 5873, 398, 327, 7743, 378, 446, 19434, 13666, 1338, 370, 506, 446, 7663, 370, 13576, 267, 634, 1956, 59, 76, 1956, 690, 13576, 61, 275, 634, 1956, 59, 76, 1956, 690, 13576, 61, 446, 19434, 398, 8396, 63, 827, 275, 2069, 8, 76, 1956, 14, 827, 1012, 267, 8396, 63, 988, 275, 2069, 8, 76, 1956, 14, 988, 1012, 339, 327, 23115, 370, 6705, 314, 6132, 536, 272, 1911, 63, 5298, 63, 354, 275, 756, 339, 327, 6668, 314, 16223, 334, 692, 2337, 365, 1373, 9, 402, 314, 2729, 1561, 543, 314, 6132, 19977, 874, 272, 6132, 63, 71, 10138, 874, 275, 769, 8, 1391, 63, 1247, 1253, 6132, 63, 354, 63, 71, 10138, 874, 9, 339, 340, 822, 8, 5298, 63, 71, 10138, 874, 9, 2356, 413, 26, 267, 1911, 63, 5298, 63, 354, 275, 715, 267, 6132, 63, 354, 275, 2729, 63, 1247, 63, 513, 59, 1391, 63, 1247, 63, 513, 14, 1080, 8, 5298, 63, 71, 10138, 874, 59, 16, 12457, 398, 634, 4654, 275, 315, 63, 493, 14, 3669, 59, 5298, 63, 354, 61, 5873, 398, 327, 7743, 378, 446, 19434, 13666, 1338, 370, 506, 446, 7663, 370, 13576, 267, 634, 4654, 59, 76, 4654, 690, 13576, 61, 275, 634, 4654, 59, 76, 4654, 690, 13576, 61, 446, 19434, 398, 6132, 63, 827, 275, 2069, 8, 76, 4654, 14, 827, 1012, 267, 6132, 63, 988, 275, 2069, 8, 76, 4654, 14, 988, 1012, 339, 315, 63, 493, 14, 1600, 342, 339, 3182, 275, 1911, 63, 4452, 63, 354, 436, 1911, 63, 5298, 63, 354, 272, 340, 3182, 26, 267, 1338, 275, 359, 3742, 12, 8396, 63, 354, 12, 6132, 63, 354, 12, 8396, 63, 827, 12, 8396, 63, 988, 12, 6132, 63, 827, 12, 6132, 63, 988, 61, 267, 574, 63, 1247, 275, 788, 3742, 297, 283, 4452, 63, 354, 297, 283, 5298, 63, 354, 297, 283, 4452, 63, 827, 297, 283, 4452, 63, 988, 297, 283, 5298, 63, 827, 297, 283, 5298, 63, 988, 418, 267, 1072, 275, 1211, 8, 3065, 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 ]
mexeniz/django-oscar
src/oscar/apps/offer/views.py
23
2060
from django.views.generic import ListView from django import http from django.conf import settings from django.shortcuts import get_object_or_404 from oscar.core.loading import get_model ConditionalOffer = get_model('offer', 'ConditionalOffer') Range = get_model('offer', 'Range') Product = get_model('catalogue', 'Product') class OfferListView(ListView): model = ConditionalOffer context_object_name = 'offers' template_name = 'offer/list.html' def get_queryset(self): return ConditionalOffer.active.filter( offer_type=ConditionalOffer.SITE) class OfferDetailView(ListView): context_object_name = 'products' template_name = 'offer/detail.html' paginate_by = settings.OSCAR_OFFERS_PER_PAGE def get(self, request, *args, **kwargs): try: self.offer = ConditionalOffer.objects.select_related().get( slug=self.kwargs['slug']) except ConditionalOffer.DoesNotExist: raise http.Http404 return super(OfferDetailView, self).get(request, *args, **kwargs) def get_context_data(self, **kwargs): ctx = super(OfferDetailView, self).get_context_data(**kwargs) ctx['offer'] = self.offer ctx['upsell_message'] = self.offer.get_upsell_message( self.request.basket) return ctx def get_queryset(self): return self.offer.products() class RangeDetailView(ListView): template_name = 'offer/range.html' context_object_name = 'products' def dispatch(self, request, *args, **kwargs): self.range = get_object_or_404( Range, slug=kwargs['slug'], is_public=True) return super(RangeDetailView, self).dispatch( request, *args, **kwargs) def get_queryset(self): products = self.range.included_products.all() return products.order_by('rangeproduct__display_order') def get_context_data(self, **kwargs): ctx = super(RangeDetailView, self).get_context_data(**kwargs) ctx['range'] = self.range return ctx
bsd-3-clause
[ 504, 1639, 14, 4196, 14, 6767, 492, 3820, 2768, 199, 504, 1639, 492, 1455, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 1238, 199, 199, 21321, 22154, 275, 664, 63, 1238, 360, 12786, 297, 283, 21321, 22154, 358, 199, 4709, 275, 664, 63, 1238, 360, 12786, 297, 283, 4709, 358, 199, 5884, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 358, 421, 199, 533, 593, 1260, 23239, 8, 23239, 304, 272, 1402, 275, 24191, 22154, 272, 1067, 63, 785, 63, 354, 275, 283, 1997, 1192, 7, 272, 1978, 63, 354, 275, 283, 12786, 15, 513, 14, 1360, 7, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 24191, 22154, 14, 2682, 14, 1541, 8, 288, 19793, 63, 466, 29, 21321, 22154, 14, 7917, 9, 421, 199, 533, 593, 1260, 28539, 8, 23239, 304, 272, 1067, 63, 785, 63, 354, 275, 283, 13336, 7, 272, 1978, 63, 354, 275, 283, 12786, 15, 5506, 14, 1360, 7, 272, 9881, 23043, 63, 991, 275, 2202, 14, 3100, 28395, 63, 7517, 3960, 63, 4227, 63, 12898, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 291, 14, 12786, 275, 24191, 22154, 14, 1462, 14, 2416, 63, 2407, 1252, 362, 8, 355, 8889, 29, 277, 14, 958, 459, 5464, 1105, 267, 871, 24191, 22154, 14, 7400, 26, 288, 746, 1455, 14, 5779, 5188, 267, 372, 1613, 8, 22154, 28539, 12, 291, 680, 362, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 4027, 275, 1613, 8, 22154, 28539, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 4027, 459, 12786, 418, 275, 291, 14, 12786, 267, 4027, 459, 384, 23235, 63, 1188, 418, 275, 291, 14, 12786, 14, 362, 63, 384, 23235, 63, 1188, 8, 288, 291, 14, 1069, 14, 18136, 9, 267, 372, 4027, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 291, 14, 12786, 14, 13336, 342, 421, 199, 533, 13114, 28539, 8, 23239, 304, 272, 1978, 63, 354, 275, 283, 12786, 15, 1842, 14, 1360, 7, 272, 1067, 63, 785, 63, 354, 275, 283, 13336, 7, 339, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1842, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 288, 13114, 12, 8889, 29, 958, 459, 5464, 995, 365, 63, 3455, 29, 549, 9, 267, 372, 1613, 8, 4709, 28539, 12, 291, 680, 6052, 8, 288, 1056, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 7585, 275, 291, 14, 1842, 14, 12409, 63, 13336, 14, 452, 342, 267, 372, 7585, 14, 1648, 63, 991, 360, 1842, 2558, 363, 2918, 63, 1648, 358, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 4027, 275, 1613, 8, 4709, 28539, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 4027, 459, 1842, 418, 275, 291, 14, 1842, 267, 372, 4027, 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 ]
[ 1639, 14, 4196, 14, 6767, 492, 3820, 2768, 199, 504, 1639, 492, 1455, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 1238, 199, 199, 21321, 22154, 275, 664, 63, 1238, 360, 12786, 297, 283, 21321, 22154, 358, 199, 4709, 275, 664, 63, 1238, 360, 12786, 297, 283, 4709, 358, 199, 5884, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 358, 421, 199, 533, 593, 1260, 23239, 8, 23239, 304, 272, 1402, 275, 24191, 22154, 272, 1067, 63, 785, 63, 354, 275, 283, 1997, 1192, 7, 272, 1978, 63, 354, 275, 283, 12786, 15, 513, 14, 1360, 7, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 24191, 22154, 14, 2682, 14, 1541, 8, 288, 19793, 63, 466, 29, 21321, 22154, 14, 7917, 9, 421, 199, 533, 593, 1260, 28539, 8, 23239, 304, 272, 1067, 63, 785, 63, 354, 275, 283, 13336, 7, 272, 1978, 63, 354, 275, 283, 12786, 15, 5506, 14, 1360, 7, 272, 9881, 23043, 63, 991, 275, 2202, 14, 3100, 28395, 63, 7517, 3960, 63, 4227, 63, 12898, 339, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 291, 14, 12786, 275, 24191, 22154, 14, 1462, 14, 2416, 63, 2407, 1252, 362, 8, 355, 8889, 29, 277, 14, 958, 459, 5464, 1105, 267, 871, 24191, 22154, 14, 7400, 26, 288, 746, 1455, 14, 5779, 5188, 267, 372, 1613, 8, 22154, 28539, 12, 291, 680, 362, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 4027, 275, 1613, 8, 22154, 28539, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 4027, 459, 12786, 418, 275, 291, 14, 12786, 267, 4027, 459, 384, 23235, 63, 1188, 418, 275, 291, 14, 12786, 14, 362, 63, 384, 23235, 63, 1188, 8, 288, 291, 14, 1069, 14, 18136, 9, 267, 372, 4027, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 291, 14, 12786, 14, 13336, 342, 421, 199, 533, 13114, 28539, 8, 23239, 304, 272, 1978, 63, 354, 275, 283, 12786, 15, 1842, 14, 1360, 7, 272, 1067, 63, 785, 63, 354, 275, 283, 13336, 7, 339, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1842, 275, 664, 63, 785, 63, 269, 63, 5188, 8, 288, 13114, 12, 8889, 29, 958, 459, 5464, 995, 365, 63, 3455, 29, 549, 9, 267, 372, 1613, 8, 4709, 28539, 12, 291, 680, 6052, 8, 288, 1056, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 7585, 275, 291, 14, 1842, 14, 12409, 63, 13336, 14, 452, 342, 267, 372, 7585, 14, 1648, 63, 991, 360, 1842, 2558, 363, 2918, 63, 1648, 358, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 4027, 275, 1613, 8, 4709, 28539, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 4027, 459, 1842, 418, 275, 291, 14, 1842, 267, 372, 4027, 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, 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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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 ]
FreeAgent/djangoappengine-starter
django/contrib/gis/geos/base.py
321
1698
from ctypes import c_void_p from types import NoneType from django.contrib.gis.geos.error import GEOSException, GEOSIndexError # Trying to import GDAL libraries, if available. Have to place in # try/except since this package may be used outside GeoDjango. try: from django.contrib.gis import gdal except ImportError: # A 'dummy' gdal module. class GDALInfo(object): HAS_GDAL = False GEOJSON = False gdal = GDALInfo() # NumPy supported? try: import numpy except ImportError: numpy = False class GEOSBase(object): """ Base object for GEOS objects that has a pointer access property that controls access to the underlying C pointer. """ # Initially the pointer is NULL. _ptr = None # Default allowed pointer type. ptr_type = c_void_p # Pointer access property. def _get_ptr(self): # Raise an exception if the pointer isn't valid don't # want to be passing NULL pointers to routines -- # that's very bad. if self._ptr: return self._ptr else: raise GEOSException('NULL GEOS %s pointer encountered.' % self.__class__.__name__) def _set_ptr(self, ptr): # Only allow the pointer to be set with pointers of the # compatible type or None (NULL). if isinstance(ptr, (self.ptr_type, NoneType)): self._ptr = ptr else: raise TypeError('Incompatible pointer type') # Property for controlling access to the GEOS object pointers. Using # this raises an exception when the pointer is NULL, thus preventing # the C library from attempting to access an invalid memory location. ptr = property(_get_ptr, _set_ptr)
bsd-3-clause
[ 504, 5577, 492, 286, 63, 1647, 63, 80, 199, 504, 2943, 492, 488, 804, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 705, 492, 21390, 21686, 12, 11920, 12129, 199, 199, 3, 7649, 316, 370, 492, 15801, 8363, 12, 340, 2808, 14, 221, 26858, 370, 4192, 315, 199, 3, 862, 15, 2590, 3967, 642, 2559, 1443, 506, 1202, 9682, 8875, 9323, 14, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 5668, 492, 15834, 199, 2590, 3545, 26, 272, 327, 437, 283, 5869, 7, 15834, 859, 14, 272, 1021, 15801, 2354, 8, 785, 304, 267, 7509, 63, 17835, 275, 756, 267, 21390, 6243, 275, 756, 272, 15834, 275, 15801, 2354, 342, 199, 199, 3, 20602, 3748, 31, 199, 893, 26, 272, 492, 2680, 199, 2590, 3545, 26, 272, 2680, 275, 756, 199, 199, 533, 11920, 1563, 8, 785, 304, 272, 408, 272, 3523, 909, 367, 11920, 2251, 626, 965, 282, 7849, 2879, 3324, 272, 626, 13467, 2879, 370, 314, 8793, 445, 7849, 14, 272, 408, 272, 327, 21412, 1183, 314, 7849, 365, 5962, 14, 272, 485, 4695, 275, 488, 339, 327, 3758, 4370, 7849, 730, 14, 272, 12448, 63, 466, 275, 286, 63, 1647, 63, 80, 339, 327, 28833, 2879, 3324, 14, 272, 347, 485, 362, 63, 4695, 8, 277, 304, 267, 327, 14771, 376, 1919, 340, 314, 7849, 5712, 1133, 1686, 2793, 1133, 267, 327, 2934, 370, 506, 9476, 5962, 21116, 370, 14975, 1553, 267, 327, 626, 1159, 7437, 4875, 14, 267, 340, 291, 423, 4695, 26, 372, 291, 423, 4695, 267, 587, 26, 746, 21390, 21686, 360, 8084, 11920, 450, 83, 7849, 14556, 3530, 450, 291, 855, 533, 4914, 354, 3368, 339, 347, 485, 409, 63, 4695, 8, 277, 12, 12448, 304, 267, 327, 5972, 2040, 314, 7849, 370, 506, 663, 543, 21116, 402, 314, 267, 327, 9025, 730, 503, 488, 334, 8084, 680, 267, 340, 1228, 8, 4695, 12, 334, 277, 14, 4695, 63, 466, 12, 488, 804, 2298, 288, 291, 423, 4695, 275, 12448, 267, 587, 26, 288, 746, 3146, 360, 607, 6490, 7849, 730, 358, 339, 327, 16158, 367, 30350, 2879, 370, 314, 11920, 909, 21116, 14, 221, 11719, 272, 327, 642, 6534, 376, 1919, 1380, 314, 7849, 365, 5962, 12, 12850, 7981, 316, 272, 327, 314, 445, 3555, 687, 19595, 370, 2879, 376, 3866, 4402, 2909, 14, 272, 12448, 275, 3324, 1547, 362, 63, 4695, 12, 485, 409, 63, 4695, 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 ]
[ 5577, 492, 286, 63, 1647, 63, 80, 199, 504, 2943, 492, 488, 804, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 705, 492, 21390, 21686, 12, 11920, 12129, 199, 199, 3, 7649, 316, 370, 492, 15801, 8363, 12, 340, 2808, 14, 221, 26858, 370, 4192, 315, 199, 3, 862, 15, 2590, 3967, 642, 2559, 1443, 506, 1202, 9682, 8875, 9323, 14, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 5668, 492, 15834, 199, 2590, 3545, 26, 272, 327, 437, 283, 5869, 7, 15834, 859, 14, 272, 1021, 15801, 2354, 8, 785, 304, 267, 7509, 63, 17835, 275, 756, 267, 21390, 6243, 275, 756, 272, 15834, 275, 15801, 2354, 342, 199, 199, 3, 20602, 3748, 31, 199, 893, 26, 272, 492, 2680, 199, 2590, 3545, 26, 272, 2680, 275, 756, 199, 199, 533, 11920, 1563, 8, 785, 304, 272, 408, 272, 3523, 909, 367, 11920, 2251, 626, 965, 282, 7849, 2879, 3324, 272, 626, 13467, 2879, 370, 314, 8793, 445, 7849, 14, 272, 408, 272, 327, 21412, 1183, 314, 7849, 365, 5962, 14, 272, 485, 4695, 275, 488, 339, 327, 3758, 4370, 7849, 730, 14, 272, 12448, 63, 466, 275, 286, 63, 1647, 63, 80, 339, 327, 28833, 2879, 3324, 14, 272, 347, 485, 362, 63, 4695, 8, 277, 304, 267, 327, 14771, 376, 1919, 340, 314, 7849, 5712, 1133, 1686, 2793, 1133, 267, 327, 2934, 370, 506, 9476, 5962, 21116, 370, 14975, 1553, 267, 327, 626, 1159, 7437, 4875, 14, 267, 340, 291, 423, 4695, 26, 372, 291, 423, 4695, 267, 587, 26, 746, 21390, 21686, 360, 8084, 11920, 450, 83, 7849, 14556, 3530, 450, 291, 855, 533, 4914, 354, 3368, 339, 347, 485, 409, 63, 4695, 8, 277, 12, 12448, 304, 267, 327, 5972, 2040, 314, 7849, 370, 506, 663, 543, 21116, 402, 314, 267, 327, 9025, 730, 503, 488, 334, 8084, 680, 267, 340, 1228, 8, 4695, 12, 334, 277, 14, 4695, 63, 466, 12, 488, 804, 2298, 288, 291, 423, 4695, 275, 12448, 267, 587, 26, 288, 746, 3146, 360, 607, 6490, 7849, 730, 358, 339, 327, 16158, 367, 30350, 2879, 370, 314, 11920, 909, 21116, 14, 221, 11719, 272, 327, 642, 6534, 376, 1919, 1380, 314, 7849, 365, 5962, 12, 12850, 7981, 316, 272, 327, 314, 445, 3555, 687, 19595, 370, 2879, 376, 3866, 4402, 2909, 14, 272, 12448, 275, 3324, 1547, 362, 63, 4695, 12, 485, 409, 63, 4695, 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, 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, 0 ]
superdesk/eve
eve/tests/renders.py
1
11071
# -*- coding: utf-8 -*- from eve.tests import TestBase from eve.utils import api_prefix from eve.tests.test_settings import MONGO_DBNAME import simplejson as json class TestRenders(TestBase): def test_default_render(self): r = self.test_client.get('/') self.assertEqual(r.content_type, 'application/json') def test_json_render(self): r = self.test_client.get('/', headers=[('Accept', 'application/json')]) self.assertEqual(r.content_type, 'application/json') def test_xml_render(self): r = self.test_client.get('/', headers=[('Accept', 'application/xml')]) self.assertTrue('application/xml' in r.content_type) def test_xml_url_escaping(self): r = self.test_client.get('%s?max_results=1' % self.known_resource_url, headers=[('Accept', 'application/xml')]) self.assertTrue(b'&amp;' in r.get_data()) def test_xml_leaf_escaping(self): # test that even xml leaves content is being properly escaped # We need to assign a `person` to our test invoice _db = self.connection[MONGO_DBNAME] fake_contact = self.random_contacts(1) fake_contact[0]['ref'] = "12345 & 67890" fake_contact_id = _db.contacts.insert(fake_contact)[0] r = self.test_client.get('%s/%s' % (self.known_resource_url, fake_contact_id), headers=[('Accept', 'application/xml')]) self.assertTrue(b'12345 &amp; 6789' in r.get_data()) def test_xml_ordered_nodes(self): """ Test that xml nodes are ordered and #441 is addressed. """ r = self.test_client.get('%s?max_results=1' % self.known_resource_url, headers=[('Accept', 'application/xml')]) data = r.get_data() idx1 = data.index(b'_created') idx2 = data.index(b'_etag') idx3 = data.index(b'_id') idx4 = data.index(b'_updated') self.assertTrue(idx1 < idx2 < idx3 < idx4) idx1 = data.index(b'max_results') idx2 = data.index(b'page') idx3 = data.index(b'total') self.assertTrue(idx1 < idx2 < idx3) idx1 = data.index(b'last') idx2 = data.index(b'next') idx3 = data.index(b'parent') self.assertTrue(idx1 < idx2 < idx3) def test_unknown_render(self): r = self.test_client.get('/', headers=[('Accept', 'application/html')]) self.assertEqual(r.content_type, 'application/json') def test_json_xml_disabled(self): self.app.config['JSON'] = False self.app.config['XML'] = False r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/json')]) self.assert500(r.status_code) r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/xml')]) self.assert500(r.status_code) r = self.test_client.get(self.known_resource_url) self.assert500(r.status_code) def test_json_disabled(self): self.app.config['JSON'] = False r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/json')]) self.assertTrue('application/xml' in r.content_type) r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/xml')]) self.assertTrue('application/xml' in r.content_type) r = self.test_client.get(self.known_resource_url) self.assertTrue('application/xml' in r.content_type) def test_xml_disabled(self): self.app.config['XML'] = False r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/xml')]) self.assertEqual(r.content_type, 'application/json') r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/json')]) self.assertEqual(r.content_type, 'application/json') r = self.test_client.get(self.known_resource_url) self.assertEqual(r.content_type, 'application/json') def test_json_keys_sorted(self): self.app.config['JSON_SORT_KEYS'] = True r = self.test_client.get(self.known_resource_url, headers=[('Accept', 'application/json')]) self.assertEqual( json.dumps(json.loads(r.get_data()), sort_keys=True).encode(), r.get_data() ) def test_CORS(self): # no CORS headers if Origin is not provided with the request. r = self.test_client.get('/') self.assertFalse('Access-Control-Allow-Origin' in r.headers) self.assertFalse('Access-Control-Allow-Methods' in r.headers) self.assertFalse('Access-Control-Allow-Max-Age' in r.headers) self.assertFalse('Access-Control-Expose-Headers' in r.headers) self.assert200(r.status_code) # test that if X_DOMAINS is set to '*', then any Origin value is # allowed. Also test that only the Origin header included with the # request will be # returned back to the client. self.app.config['X_DOMAINS'] = '*' r = self.test_client.get('/', headers=[('Origin', 'http://example.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], 'http://example.com') self.assertEqual(r.headers['Vary'], 'Origin') # test that if a list is set for X_DOMAINS, then: # 1. only list values are accepted; # 2. only the value included with the request is returned back. self.app.config['X_DOMAINS'] = ['http://1of2.com', 'http://2of2.com'] r = self.test_client.get('/', headers=[('Origin', 'http://1of2.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], 'http://1of2.com') r = self.test_client.get('/', headers=[('Origin', 'http://2of2.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], 'http://2of2.com') r = self.test_client.get('/', headers=[('Origin', 'http://notreally.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], '') # other Access-Control-Allow- headers are included. self.assertTrue('Access-Control-Allow-Headers' in r.headers) self.assertTrue('Access-Control-Allow-Methods' in r.headers) self.assertTrue('Access-Control-Allow-Max-Age' in r.headers) self.assertTrue('Access-Control-Expose-Headers' in r.headers) def test_CORS_MAX_AGE(self): self.app.config['X_DOMAINS'] = '*' r = self.test_client.get('/', headers=[('Origin', 'http://example.com')]) self.assertEqual(r.headers['Access-Control-Allow-Max-Age'], '21600') self.app.config['X_MAX_AGE'] = 2000 r = self.test_client.get('/', headers=[('Origin', 'http://example.com')]) self.assertEqual(r.headers['Access-Control-Allow-Max-Age'], '2000') def test_CORS_OPTIONS(self, url='/', methods=None): if methods is None: methods = [] r = self.test_client.open(url, method='OPTIONS') self.assertFalse('Access-Control-Allow-Origin' in r.headers) self.assertFalse('Access-Control-Allow-Methods' in r.headers) self.assertFalse('Access-Control-Allow-Max-Age' in r.headers) self.assertFalse('Access-Control-Expose-Headers' in r.headers) self.assert200(r.status_code) # test that if X_DOMAINS is set to '*', then any Origin value is # allowed. Also test that only the Origin header included with the # request will be # returned back to the client. self.app.config['X_DOMAINS'] = '*' r = self.test_client.open(url, method='OPTIONS', headers=[('Origin', 'http://example.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], 'http://example.com') self.assertEqual(r.headers['Vary'], 'Origin') for m in methods: self.assertTrue(m in r.headers['Access-Control-Allow-Methods']) self.app.config['X_DOMAINS'] = ['http://1of2.com', 'http://2of2.com'] r = self.test_client.open(url, method='OPTIONS', headers=[('Origin', 'http://1of2.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], 'http://1of2.com') r = self.test_client.open(url, method='OPTIONS', headers=[('Origin', 'http://2of2.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], 'http://2of2.com') for m in methods: self.assertTrue(m in r.headers['Access-Control-Allow-Methods']) self.assertTrue('Access-Control-Allow-Origin' in r.headers) self.assertTrue('Access-Control-Allow-Max-Age' in r.headers) self.assertTrue('Access-Control-Expose-Headers' in r.headers) r = self.test_client.get(url, headers=[('Origin', 'http://not_an_example.com')]) self.assert200(r.status_code) self.assertEqual(r.headers['Access-Control-Allow-Origin'], '') for m in methods: self.assertTrue(m in r.headers['Access-Control-Allow-Methods']) def test_CORS_OPTIONS_resources(self): prefix = api_prefix(self.app.config['URL_PREFIX'], self.app.config['API_VERSION']) del(self.domain['peopleinvoices']) del(self.domain['peoplesearches']) del(self.domain['internal_transactions']) for _, settings in self.app.config['DOMAIN'].items(): # resource endpoint url = '%s/%s/' % (prefix, settings['url']) methods = settings['resource_methods'] + ['OPTIONS'] self.test_CORS_OPTIONS(url, methods) def test_CORS_OPTIONS_item(self): prefix = api_prefix(self.app.config['URL_PREFIX'], self.app.config['API_VERSION']) url = '%s%s' % (prefix, self.item_id_url) methods = (self.domain[self.known_resource]['resource_methods'] + ['OPTIONS']) self.test_CORS_OPTIONS(url, methods) url = '%s%s/%s' % (prefix, self.known_resource_url, self.item_ref) methods = ['GET', 'OPTIONS'] self.test_CORS_OPTIONS(url, methods)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 325, 432, 14, 2219, 492, 1379, 1563, 199, 504, 325, 432, 14, 1208, 492, 2986, 63, 1861, 199, 504, 325, 432, 14, 2219, 14, 396, 63, 1751, 492, 603, 26477, 63, 2846, 2339, 199, 646, 13804, 465, 2022, 421, 199, 533, 1379, 5349, 7735, 8, 14440, 304, 339, 347, 511, 63, 885, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 7825, 267, 291, 14, 629, 8, 82, 14, 1317, 63, 466, 12, 283, 3578, 15, 1001, 358, 339, 347, 511, 63, 1001, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 10998, 2323, 11699, 8422, 297, 283, 3578, 15, 1001, 2023, 267, 291, 14, 629, 8, 82, 14, 1317, 63, 466, 12, 283, 3578, 15, 1001, 358, 339, 347, 511, 63, 1652, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 10998, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 339, 347, 511, 63, 1652, 63, 633, 63, 26306, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 3508, 83, 31, 988, 63, 2604, 29, 17, 7, 450, 291, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 8, 66, 21840, 5282, 8942, 315, 519, 14, 362, 63, 576, 1012, 339, 347, 511, 63, 1652, 63, 8914, 63, 26306, 8, 277, 304, 267, 327, 511, 626, 2755, 2748, 16733, 1564, 365, 3769, 7684, 11077, 398, 327, 2136, 1929, 370, 5090, 282, 658, 5484, 64, 370, 4154, 511, 8485, 267, 485, 697, 275, 291, 14, 2105, 59, 45, 26477, 63, 2846, 2339, 61, 267, 4026, 63, 7811, 275, 291, 14, 2355, 63, 18147, 8, 17, 9, 267, 4026, 63, 7811, 59, 16, 2733, 1121, 418, 275, 298, 13261, 1253, 13296, 13173, 2, 267, 4026, 63, 7811, 63, 344, 275, 485, 697, 14, 18147, 14, 3176, 8, 3183, 63, 7811, 2788, 16, 61, 398, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 3508, 83, 3149, 83, 7, 450, 639, 334, 277, 14, 3159, 63, 1927, 63, 633, 12, 4026, 63, 7811, 63, 344, 395, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 8, 66, 7, 13261, 1253, 5282, 27, 13296, 1407, 7, 315, 519, 14, 362, 63, 576, 1012, 339, 347, 511, 63, 1652, 63, 8235, 63, 2415, 8, 277, 304, 267, 408, 1379, 626, 2748, 3380, 787, 7741, 436, 327, 24284, 365, 1050, 5111, 14, 267, 408, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 3508, 83, 31, 988, 63, 2604, 29, 17, 7, 450, 291, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 666, 275, 519, 14, 362, 63, 576, 342, 267, 4280, 17, 275, 666, 14, 1080, 8, 66, 26142, 3966, 358, 267, 4280, 18, 275, 666, 14, 1080, 8, 66, 26142, 11304, 358, 267, 4280, 19, 275, 666, 14, 1080, 8, 66, 26142, 344, 358, 267, 4280, 20, 275, 666, 14, 1080, 8, 66, 26142, 5334, 358, 267, 291, 14, 1815, 8, 2996, 17, 665, 4280, 18, 665, 4280, 19, 665, 4280, 20, 9, 267, 4280, 17, 275, 666, 14, 1080, 8, 66, 6704, 1219, 63, 2604, 358, 267, 4280, 18, 275, 666, 14, 1080, 8, 66, 7, 1606, 358, 267, 4280, 19, 275, 666, 14, 1080, 8, 66, 1133, 1735, 358, 267, 291, 14, 1815, 8, 2996, 17, 665, 4280, 18, 665, 4280, 19, 9, 267, 4280, 17, 275, 666, 14, 1080, 8, 66, 7, 2019, 358, 267, 4280, 18, 275, 666, 14, 1080, 8, 66, 7, 2184, 358, 267, 4280, 19, 275, 666, 14, 1080, 8, 66, 7, 1708, 358, 267, 291, 14, 1815, 8, 2996, 17, 665, 4280, 18, 665, 4280, 19, 9, 339, 347, 511, 63, 5187, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 10998, 2323, 11699, 8422, 297, 283, 3578, 15, 1360, 2023, 267, 291, 14, 629, 8, 82, 14, 1317, 63, 466, 12, 283, 3578, 15, 1001, 358, 339, 347, 511, 63, 1001, 63, 1652, 63, 7011, 8, 277, 304, 267, 291, 14, 571, 14, 888, 459, 6243, 418, 275, 756, 267, 291, 14, 571, 14, 888, 459, 4317, 418, 275, 756, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1001, 2023, 267, 291, 14, 479, 5783, 8, 82, 14, 1205, 63, 600, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 479, 5783, 8, 82, 14, 1205, 63, 600, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 9, 267, 291, 14, 479, 5783, 8, 82, 14, 1205, 63, 600, 9, 339, 347, 511, 63, 1001, 63, 7011, 8, 277, 304, 267, 291, 14, 571, 14, 888, 459, 6243, 418, 275, 756, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1001, 2023, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 9, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 339, 347, 511, 63, 1652, 63, 7011, 8, 277, 304, 267, 291, 14, 571, 14, 888, 459, 4317, 418, 275, 756, 267, 519, 275, 291 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 325, 432, 14, 2219, 492, 1379, 1563, 199, 504, 325, 432, 14, 1208, 492, 2986, 63, 1861, 199, 504, 325, 432, 14, 2219, 14, 396, 63, 1751, 492, 603, 26477, 63, 2846, 2339, 199, 646, 13804, 465, 2022, 421, 199, 533, 1379, 5349, 7735, 8, 14440, 304, 339, 347, 511, 63, 885, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 7825, 267, 291, 14, 629, 8, 82, 14, 1317, 63, 466, 12, 283, 3578, 15, 1001, 358, 339, 347, 511, 63, 1001, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 10998, 2323, 11699, 8422, 297, 283, 3578, 15, 1001, 2023, 267, 291, 14, 629, 8, 82, 14, 1317, 63, 466, 12, 283, 3578, 15, 1001, 358, 339, 347, 511, 63, 1652, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 10998, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 339, 347, 511, 63, 1652, 63, 633, 63, 26306, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 3508, 83, 31, 988, 63, 2604, 29, 17, 7, 450, 291, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 8, 66, 21840, 5282, 8942, 315, 519, 14, 362, 63, 576, 1012, 339, 347, 511, 63, 1652, 63, 8914, 63, 26306, 8, 277, 304, 267, 327, 511, 626, 2755, 2748, 16733, 1564, 365, 3769, 7684, 11077, 398, 327, 2136, 1929, 370, 5090, 282, 658, 5484, 64, 370, 4154, 511, 8485, 267, 485, 697, 275, 291, 14, 2105, 59, 45, 26477, 63, 2846, 2339, 61, 267, 4026, 63, 7811, 275, 291, 14, 2355, 63, 18147, 8, 17, 9, 267, 4026, 63, 7811, 59, 16, 2733, 1121, 418, 275, 298, 13261, 1253, 13296, 13173, 2, 267, 4026, 63, 7811, 63, 344, 275, 485, 697, 14, 18147, 14, 3176, 8, 3183, 63, 7811, 2788, 16, 61, 398, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 3508, 83, 3149, 83, 7, 450, 639, 334, 277, 14, 3159, 63, 1927, 63, 633, 12, 4026, 63, 7811, 63, 344, 395, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 8, 66, 7, 13261, 1253, 5282, 27, 13296, 1407, 7, 315, 519, 14, 362, 63, 576, 1012, 339, 347, 511, 63, 1652, 63, 8235, 63, 2415, 8, 277, 304, 267, 408, 1379, 626, 2748, 3380, 787, 7741, 436, 327, 24284, 365, 1050, 5111, 14, 267, 408, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 3508, 83, 31, 988, 63, 2604, 29, 17, 7, 450, 291, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 666, 275, 519, 14, 362, 63, 576, 342, 267, 4280, 17, 275, 666, 14, 1080, 8, 66, 26142, 3966, 358, 267, 4280, 18, 275, 666, 14, 1080, 8, 66, 26142, 11304, 358, 267, 4280, 19, 275, 666, 14, 1080, 8, 66, 26142, 344, 358, 267, 4280, 20, 275, 666, 14, 1080, 8, 66, 26142, 5334, 358, 267, 291, 14, 1815, 8, 2996, 17, 665, 4280, 18, 665, 4280, 19, 665, 4280, 20, 9, 267, 4280, 17, 275, 666, 14, 1080, 8, 66, 6704, 1219, 63, 2604, 358, 267, 4280, 18, 275, 666, 14, 1080, 8, 66, 7, 1606, 358, 267, 4280, 19, 275, 666, 14, 1080, 8, 66, 1133, 1735, 358, 267, 291, 14, 1815, 8, 2996, 17, 665, 4280, 18, 665, 4280, 19, 9, 267, 4280, 17, 275, 666, 14, 1080, 8, 66, 7, 2019, 358, 267, 4280, 18, 275, 666, 14, 1080, 8, 66, 7, 2184, 358, 267, 4280, 19, 275, 666, 14, 1080, 8, 66, 7, 1708, 358, 267, 291, 14, 1815, 8, 2996, 17, 665, 4280, 18, 665, 4280, 19, 9, 339, 347, 511, 63, 5187, 63, 3352, 8, 277, 304, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 10998, 2323, 11699, 8422, 297, 283, 3578, 15, 1360, 2023, 267, 291, 14, 629, 8, 82, 14, 1317, 63, 466, 12, 283, 3578, 15, 1001, 358, 339, 347, 511, 63, 1001, 63, 1652, 63, 7011, 8, 277, 304, 267, 291, 14, 571, 14, 888, 459, 6243, 418, 275, 756, 267, 291, 14, 571, 14, 888, 459, 4317, 418, 275, 756, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1001, 2023, 267, 291, 14, 479, 5783, 8, 82, 14, 1205, 63, 600, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 479, 5783, 8, 82, 14, 1205, 63, 600, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 9, 267, 291, 14, 479, 5783, 8, 82, 14, 1205, 63, 600, 9, 339, 347, 511, 63, 1001, 63, 7011, 8, 277, 304, 267, 291, 14, 571, 14, 888, 459, 6243, 418, 275, 756, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1001, 2023, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 12, 639, 2323, 11699, 8422, 297, 283, 3578, 15, 1652, 2023, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 267, 519, 275, 291, 14, 396, 63, 1258, 14, 362, 8, 277, 14, 3159, 63, 1927, 63, 633, 9, 267, 291, 14, 1815, 360, 3578, 15, 1652, 7, 315, 519, 14, 1317, 63, 466, 9, 339, 347, 511, 63, 1652, 63, 7011, 8, 277, 304, 267, 291, 14, 571, 14, 888, 459, 4317, 418, 275, 756, 267, 519, 275, 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, 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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 ]
MaxLinCode/tardy-HackIllinois-2017
alexa/lambda_function.py
1
6803
""" This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit. The Intent Schema, Built-in Slots, and Sample Utterances for this skill, as well as testing instructions are located at http://amzn.to/1LzFrj6 For additional samples, visit the Alexa Skills Kit Getting Started guide at http://amzn.to/1LGWsLG """ from __future__ import print_function from twilio.rest import TwilioRestClient from loadData import rawToTime, getNumber from config import * accountSid = 'ACcf54ef49063aaa784c99aec82d7f16c2' authToken = '31f817a48ee7cd461c07c57490eac6ce' fromNumber = '19163183442' # --------------- Helpers that build all of the responses ---------------------- def build_speechlet_response(title, output, reprompt_text, should_end_session): return { 'outputSpeech': { 'type': 'PlainText', 'text': output }, 'card': { 'type': 'Simple', 'title': 'SessionSpeechlet - ' + title, 'content': 'SessionSpeechlet - ' + output }, 'reprompt': { 'outputSpeech': { 'type': 'PlainText', 'text': reprompt_text } }, 'shouldEndSession': should_end_session } def build_response(session_attributes, speechlet_response): return { 'version': '1.0', 'sessionAttributes': session_attributes, 'response': speechlet_response } # --------------- Functions that control the skill's behavior ------------------ def get_welcome_response(): session_attributes = {} card_title = "Welcome" speech_output = "Hello, welcome to the Tardy skill." # If the user either does not reply to the welcome message or says something # that is not understood, they will be prompted again with this text. reprompt_text = "You can ask me to send a message to your friends." should_end_session = False return build_response(session_attributes, build_speechlet_response( card_title, speech_output, reprompt_text, should_end_session)) def sarah_intent_handler(intent): card_title = "Sarah" speech_output = "Sarah is the best" return build_response(None, build_speechlet_response( card_title, speech_output, None, False)) def formatMessage(userName, targetName, time, place): return "Hello %s, %s would like to meet at %s at %s." % (targetName.title(), userName.title(), place.title(), time) def getInfo(userId, target, time, place): d = {} time = rawToTime(time) userName = "" for x in target: arr = getNumber(userId, target) if userName == "": username = arr[0] d[arr[1]] = [arr[2], formatMessage(userName, a[1], time, place)] for key in d: sendText(d[key][0], d[key][1]) def twilio_intent_handler(intent): card_title = "Twilio" #print(intent['slots']) target = intent["slots"]["nameSlot"]["value"] time = intent["slots"]["timeSlot"]["value"] place = intent["slots"]["placeSlot"]["value"] #userID = kijZjJJ5ozPZxfeHYfjh3zd3TUh1 getInfo('kijZjJJ5ozPZxfeHYfjh3zd3TUh1', target, time, place) #cellNumber = "" #messageText = "" #slots = intent['slots'] #cellNumber = slots['numberSlot']['value'] #messageText = slots['msgSlot']['value'] # call the method to send text speech_output = "Message sent." # Setting reprompt_text to None signifies that we do not want to reprompt # the user. If the user does not respond or says something that is not # understood, the session will end. return build_response(None, build_speechlet_response( card_title, speech_output, None, False)) #number,message def sendText(to_num, msg_text): try: client = TwilioRestClient(accountSid, authToken) client.messages.create( to=to_num, from_=from_num, body=msg_text ) return True except Exception as e: print("Failed to send message: ") print(e.code) return False def help_intent_handler(intent): card_title = "Help" speech_output = "Ask me to send someone a text." return build_response(None, build_speechlet_response( card_title, speech_output, None, False)) def misunderstood_handler(intent): card_title = "Misunderstood" speech_output = "Sorry, please try again." return build_response(None, build_speechlet_response( card_title, speech_output, None, True)) def handle_session_end_request(): card_title = "Session Ended" speech_output = "Thank you for trying our Tardy skill. " \ "Have a great time at Hack Illinois! " # Setting this to true ends the session and exits the skill. should_end_session = True return build_response(None, build_speechlet_response( card_title, speech_output, None, should_end_session)) # --------------- Events ------------------ def on_launch(launch_request): """ Called when the user launches the skill without specifying what they want """ print("on_launch requestId=" + launch_request['requestId']) # Dispatch to your skill's launch return get_welcome_response() def on_intent(intent_request): """ Called when the user specifies an intent for this skill """ print("on_intent requestId=" + intent_request['requestId']) intent = intent_request['intent'] intent_name = intent_request['intent']['name'] # Dispatch to your skill's intent handlers if intent_name == "SarahIntent": return sarah_intent_handler(intent) elif intent_name == "TwilioIntent": return twilio_intent_handler(intent) elif intent_name == "HelpIntent": return help_intent_handler(intent) elif intent_name == "AMAZON.CancelIntent" or intent_name == "AMAZON.StopIntent": return handle_session_end_request() else: return misunderstood_handler(intent) # --------------- Main handler ------------------ def lambda_handler(event, context): """ Route the incoming request based on type (LaunchRequest, IntentRequest, etc.) The JSON body of the request is provided in the event parameter. """ session_attributes = {} #applicationId = event['session']['application']['applicationId'] #if applicationId != TWILIO_APPLICATION_ID: # should_end_session = True # bad_request_output = "Bad Request" # print("Bad ApplicationId Received: "+applicationId) # return build_response(session_attributes, build_speechlet_response("Twilio", bad_request_output, None, should_end_session)) if event['request']['type'] == "LaunchRequest": return on_launch(event['request']) elif event['request']['type'] == "IntentRequest": return on_intent(event['request'])
mit
[ 624, 199, 2765, 2690, 23789, 31216, 282, 3486, 2386, 778, 6137, 543, 314, 14347, 7235, 29201, 15350, 1804, 390, 14, 199, 1918, 1010, 767, 13268, 12, 4779, 4803, 13, 262, 428, 4555, 12, 436, 15227, 738, 84, 351, 13236, 367, 642, 2386, 778, 12, 465, 5521, 199, 305, 5343, 15794, 787, 16180, 737, 1455, 921, 455, 31591, 14, 475, 15, 17, 44, 90, 13848, 74, 22, 199, 199, 1858, 4722, 5845, 12, 5684, 314, 7235, 29201, 15350, 1804, 390, 20703, 1933, 5015, 22885, 737, 199, 1014, 921, 455, 31591, 14, 475, 15, 17, 44, 19674, 83, 44, 39, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 8900, 23533, 14, 3911, 492, 377, 87, 23533, 13726, 3041, 199, 504, 2248, 1451, 492, 3066, 1378, 1366, 12, 664, 3259, 199, 504, 1101, 492, 627, 199, 199, 2048, 26686, 275, 283, 1348, 2177, 1477, 2829, 1887, 22653, 11629, 28394, 67, 1020, 65, 825, 2564, 68, 23, 70, 975, 67, 18, 7, 199, 1178, 3264, 275, 283, 2192, 70, 31023, 65, 2006, 1024, 23, 2866, 26127, 67, 1780, 67, 10950, 2710, 28870, 22, 301, 7, 199, 504, 3259, 275, 283, 1167, 11931, 1085, 1082, 2260, 7, 199, 199, 3, 3001, 12797, 11642, 83, 626, 1900, 1006, 402, 314, 9320, 10652, 8648, 421, 199, 318, 1900, 63, 23660, 2723, 63, 1310, 8, 1213, 12, 1072, 12, 295, 7650, 63, 505, 12, 1077, 63, 500, 63, 1730, 304, 272, 372, 469, 267, 283, 1199, 27047, 12736, 356, 469, 288, 283, 466, 356, 283, 20711, 1872, 297, 288, 283, 505, 356, 1072, 267, 1660, 267, 283, 5841, 356, 469, 288, 283, 466, 356, 283, 3184, 297, 288, 283, 1213, 356, 283, 4434, 27047, 12736, 2723, 446, 283, 435, 2538, 12, 288, 283, 1317, 356, 283, 4434, 27047, 12736, 2723, 446, 283, 435, 1072, 267, 1660, 267, 283, 264, 7650, 356, 469, 288, 283, 1199, 27047, 12736, 356, 469, 355, 283, 466, 356, 283, 20711, 1872, 297, 355, 283, 505, 356, 295, 7650, 63, 505, 288, 789, 267, 1660, 267, 283, 5626, 3005, 4434, 356, 1077, 63, 500, 63, 1730, 272, 789, 421, 199, 318, 1900, 63, 1310, 8, 1730, 63, 2987, 12, 32093, 2723, 63, 1310, 304, 272, 372, 469, 267, 283, 1023, 356, 283, 17, 14, 16, 297, 267, 283, 1730, 5379, 356, 2351, 63, 2987, 12, 267, 283, 1310, 356, 32093, 2723, 63, 1310, 272, 789, 199, 199, 3, 3001, 12797, 17471, 626, 3304, 314, 2386, 778, 1159, 5953, 10652, 306, 199, 199, 318, 664, 63, 28508, 63, 1310, 837, 272, 2351, 63, 2987, 275, 1052, 272, 12564, 63, 1213, 275, 298, 24679, 2, 339, 32093, 63, 1199, 275, 298, 6257, 12, 336, 14628, 370, 314, 377, 1005, 89, 2386, 778, 2122, 339, 327, 982, 314, 922, 1902, 1630, 440, 9351, 370, 314, 336, 14628, 1245, 503, 20065, 6020, 272, 327, 626, 365, 440, 1334, 14308, 364, 12, 2985, 911, 506, 21652, 471, 4020, 543, 642, 1318, 14, 272, 295, 7650, 63, 505, 275, 298, 5556, 883, 7198, 562, 370, 3222, 282, 1245, 370, 2195, 26157, 2122, 339, 1077, 63, 500, 63, 1730, 275, 756, 272, 372, 1900, 63, 1310, 8, 1730, 63, 2987, 12, 1900, 63, 23660, 2723, 63, 1310, 8, 267, 12564, 63, 1213, 12, 32093, 63, 1199, 12, 295, 7650, 63, 505, 12, 1077, 63, 500, 63, 1730, 430, 199, 199, 318, 308, 285, 11326, 63, 17456, 63, 2232, 8, 17456, 304, 272, 12564, 63, 1213, 275, 298, 51, 285, 11326, 2, 272, 32093, 63, 1199, 275, 298, 51, 285, 11326, 365, 314, 5526, 2, 339, 372, 1900, 63, 1310, 8, 403, 12, 1900, 63, 23660, 2723, 63, 1310, 8, 267, 12564, 63, 1213, 12, 32093, 63, 1199, 12, 488, 12, 756, 430, 199, 199, 318, 1475, 2209, 8, 751, 985, 12, 1347, 985, 12, 900, 12, 4192, 304, 272, 372, 298, 6257, 450, 83, 12, 450, 83, 3955, 2839, 370, 26743, 737, 450, 83, 737, 450, 83, 2122, 450, 334, 1375, 985, 14, 1213, 1062, 922, 985, 14, 1213, 1062, 4192, 14, 1213, 1062, 900, 9, 199, 199, 318, 664, 2354, 8, 751, 1304, 12, 1347, 12, 900, 12, 4192, 304, 272, 366, 275, 1052, 272, 900, 275, 3066, 1378, 1366, 8, 521, 9, 272, 922, 985, 275, 3087, 272, 367, 671, 315, 1347, 26, 267, 7953, 275, 664, 3259, 8, 751, 1304, 12, 1347, 9, 267, 340, 922, 985, 508, 10812, 288, 3434, 275, 7953, 59, 16, 61, 267, 366, 59, 5250, 59, 17, 2677, 275, 359, 5250, 59, 18, 467, 1475, 2209, 8, 751, 985, 12, 282, 59, 17, 467, 900, 12, 4192, 1874, 339, 367, 790, 315, 366, 26, 267, 3222, 1872, 8, 68, 59, 498, 1527, 16, 467, 366, 59, 498, 1527, 17, 566, 199, 199, 318, 8900, 23533, 63, 17456, 63, 2232, 8, 17456, 304, 272, 12564, 63, 1213, 275, 298, 22879, 23533, 2, 272, 327, 1361, 8, 17456, 459, 7257, 1105, 272, 1347, 275, 21020, 905, 7257, 6611, 354, 15183, 6611, 585, 937, 272, 900, 275, 21020, 905, 7257, 6611, 521, 15183, 6611, 585, 937, 272, 4192, 275, 21020, 905, 7257, 6611, 2778, 15183, 6611, 585, 937, 339, 327, 751, 998, 275, 1022, 7879, 58, 74, 29211, 21, 26051, 48, 58, 8371, 16255, 70, 31623, 19, 23670, 19, 21364, 72, 17, 272, 664, 2354, 360, 75, 7879, 58, 74, 29211, 21, 26051, 48, 58, 8371, 16255, 70, 31623, 19, 23670, 19, 21364, 72, 17, 297, 1347, 12, 900, 12, 4192, 9, 272, 327, 3890, 3259, 275, 3087, 272, 327, 1188, 1872, 275, 3087, 272, 327, 7257, 275, 21020, 459, 7257, 418, 272, 327, 3890, 3259, 275, 14319, 459, 1955, 15183, 2545, 585, 418, 272, 327, 1188, 1872, 275, 14319, 459, 1328, 15183, 2545, 585, 418, 339, 327, 1240, 314, 1083, 370, 3222, 1318, 272, 32093, 63, 1199, 275, 298, 2209, 4847, 2122, 339, 327, 13510, 295, 7650, 63, 505, 370, 488, 2070, 11594, 626, 781, 886, 440, 2934, 370, 295, 7650, 272, 327, 314, 922, 14, 982, 314, 922, 1630, 440, 22722, 503, 20065, 6020, 626, 365, 440, 272, 327, 1334, 14308, 364, 12, 314, 2351, 911, 1284, 14, 272, 372, 1900, 63, 1310, 8, 403, 12, 1900, 63, 23660, 2723, 63, 1310 ]
[ 199, 2765, 2690, 23789, 31216, 282, 3486, 2386, 778, 6137, 543, 314, 14347, 7235, 29201, 15350, 1804, 390, 14, 199, 1918, 1010, 767, 13268, 12, 4779, 4803, 13, 262, 428, 4555, 12, 436, 15227, 738, 84, 351, 13236, 367, 642, 2386, 778, 12, 465, 5521, 199, 305, 5343, 15794, 787, 16180, 737, 1455, 921, 455, 31591, 14, 475, 15, 17, 44, 90, 13848, 74, 22, 199, 199, 1858, 4722, 5845, 12, 5684, 314, 7235, 29201, 15350, 1804, 390, 20703, 1933, 5015, 22885, 737, 199, 1014, 921, 455, 31591, 14, 475, 15, 17, 44, 19674, 83, 44, 39, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 8900, 23533, 14, 3911, 492, 377, 87, 23533, 13726, 3041, 199, 504, 2248, 1451, 492, 3066, 1378, 1366, 12, 664, 3259, 199, 504, 1101, 492, 627, 199, 199, 2048, 26686, 275, 283, 1348, 2177, 1477, 2829, 1887, 22653, 11629, 28394, 67, 1020, 65, 825, 2564, 68, 23, 70, 975, 67, 18, 7, 199, 1178, 3264, 275, 283, 2192, 70, 31023, 65, 2006, 1024, 23, 2866, 26127, 67, 1780, 67, 10950, 2710, 28870, 22, 301, 7, 199, 504, 3259, 275, 283, 1167, 11931, 1085, 1082, 2260, 7, 199, 199, 3, 3001, 12797, 11642, 83, 626, 1900, 1006, 402, 314, 9320, 10652, 8648, 421, 199, 318, 1900, 63, 23660, 2723, 63, 1310, 8, 1213, 12, 1072, 12, 295, 7650, 63, 505, 12, 1077, 63, 500, 63, 1730, 304, 272, 372, 469, 267, 283, 1199, 27047, 12736, 356, 469, 288, 283, 466, 356, 283, 20711, 1872, 297, 288, 283, 505, 356, 1072, 267, 1660, 267, 283, 5841, 356, 469, 288, 283, 466, 356, 283, 3184, 297, 288, 283, 1213, 356, 283, 4434, 27047, 12736, 2723, 446, 283, 435, 2538, 12, 288, 283, 1317, 356, 283, 4434, 27047, 12736, 2723, 446, 283, 435, 1072, 267, 1660, 267, 283, 264, 7650, 356, 469, 288, 283, 1199, 27047, 12736, 356, 469, 355, 283, 466, 356, 283, 20711, 1872, 297, 355, 283, 505, 356, 295, 7650, 63, 505, 288, 789, 267, 1660, 267, 283, 5626, 3005, 4434, 356, 1077, 63, 500, 63, 1730, 272, 789, 421, 199, 318, 1900, 63, 1310, 8, 1730, 63, 2987, 12, 32093, 2723, 63, 1310, 304, 272, 372, 469, 267, 283, 1023, 356, 283, 17, 14, 16, 297, 267, 283, 1730, 5379, 356, 2351, 63, 2987, 12, 267, 283, 1310, 356, 32093, 2723, 63, 1310, 272, 789, 199, 199, 3, 3001, 12797, 17471, 626, 3304, 314, 2386, 778, 1159, 5953, 10652, 306, 199, 199, 318, 664, 63, 28508, 63, 1310, 837, 272, 2351, 63, 2987, 275, 1052, 272, 12564, 63, 1213, 275, 298, 24679, 2, 339, 32093, 63, 1199, 275, 298, 6257, 12, 336, 14628, 370, 314, 377, 1005, 89, 2386, 778, 2122, 339, 327, 982, 314, 922, 1902, 1630, 440, 9351, 370, 314, 336, 14628, 1245, 503, 20065, 6020, 272, 327, 626, 365, 440, 1334, 14308, 364, 12, 2985, 911, 506, 21652, 471, 4020, 543, 642, 1318, 14, 272, 295, 7650, 63, 505, 275, 298, 5556, 883, 7198, 562, 370, 3222, 282, 1245, 370, 2195, 26157, 2122, 339, 1077, 63, 500, 63, 1730, 275, 756, 272, 372, 1900, 63, 1310, 8, 1730, 63, 2987, 12, 1900, 63, 23660, 2723, 63, 1310, 8, 267, 12564, 63, 1213, 12, 32093, 63, 1199, 12, 295, 7650, 63, 505, 12, 1077, 63, 500, 63, 1730, 430, 199, 199, 318, 308, 285, 11326, 63, 17456, 63, 2232, 8, 17456, 304, 272, 12564, 63, 1213, 275, 298, 51, 285, 11326, 2, 272, 32093, 63, 1199, 275, 298, 51, 285, 11326, 365, 314, 5526, 2, 339, 372, 1900, 63, 1310, 8, 403, 12, 1900, 63, 23660, 2723, 63, 1310, 8, 267, 12564, 63, 1213, 12, 32093, 63, 1199, 12, 488, 12, 756, 430, 199, 199, 318, 1475, 2209, 8, 751, 985, 12, 1347, 985, 12, 900, 12, 4192, 304, 272, 372, 298, 6257, 450, 83, 12, 450, 83, 3955, 2839, 370, 26743, 737, 450, 83, 737, 450, 83, 2122, 450, 334, 1375, 985, 14, 1213, 1062, 922, 985, 14, 1213, 1062, 4192, 14, 1213, 1062, 900, 9, 199, 199, 318, 664, 2354, 8, 751, 1304, 12, 1347, 12, 900, 12, 4192, 304, 272, 366, 275, 1052, 272, 900, 275, 3066, 1378, 1366, 8, 521, 9, 272, 922, 985, 275, 3087, 272, 367, 671, 315, 1347, 26, 267, 7953, 275, 664, 3259, 8, 751, 1304, 12, 1347, 9, 267, 340, 922, 985, 508, 10812, 288, 3434, 275, 7953, 59, 16, 61, 267, 366, 59, 5250, 59, 17, 2677, 275, 359, 5250, 59, 18, 467, 1475, 2209, 8, 751, 985, 12, 282, 59, 17, 467, 900, 12, 4192, 1874, 339, 367, 790, 315, 366, 26, 267, 3222, 1872, 8, 68, 59, 498, 1527, 16, 467, 366, 59, 498, 1527, 17, 566, 199, 199, 318, 8900, 23533, 63, 17456, 63, 2232, 8, 17456, 304, 272, 12564, 63, 1213, 275, 298, 22879, 23533, 2, 272, 327, 1361, 8, 17456, 459, 7257, 1105, 272, 1347, 275, 21020, 905, 7257, 6611, 354, 15183, 6611, 585, 937, 272, 900, 275, 21020, 905, 7257, 6611, 521, 15183, 6611, 585, 937, 272, 4192, 275, 21020, 905, 7257, 6611, 2778, 15183, 6611, 585, 937, 339, 327, 751, 998, 275, 1022, 7879, 58, 74, 29211, 21, 26051, 48, 58, 8371, 16255, 70, 31623, 19, 23670, 19, 21364, 72, 17, 272, 664, 2354, 360, 75, 7879, 58, 74, 29211, 21, 26051, 48, 58, 8371, 16255, 70, 31623, 19, 23670, 19, 21364, 72, 17, 297, 1347, 12, 900, 12, 4192, 9, 272, 327, 3890, 3259, 275, 3087, 272, 327, 1188, 1872, 275, 3087, 272, 327, 7257, 275, 21020, 459, 7257, 418, 272, 327, 3890, 3259, 275, 14319, 459, 1955, 15183, 2545, 585, 418, 272, 327, 1188, 1872, 275, 14319, 459, 1328, 15183, 2545, 585, 418, 339, 327, 1240, 314, 1083, 370, 3222, 1318, 272, 32093, 63, 1199, 275, 298, 2209, 4847, 2122, 339, 327, 13510, 295, 7650, 63, 505, 370, 488, 2070, 11594, 626, 781, 886, 440, 2934, 370, 295, 7650, 272, 327, 314, 922, 14, 982, 314, 922, 1630, 440, 22722, 503, 20065, 6020, 626, 365, 440, 272, 327, 1334, 14308, 364, 12, 314, 2351, 911, 1284, 14, 272, 372, 1900, 63, 1310, 8, 403, 12, 1900, 63, 23660, 2723, 63, 1310, 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 ]
klusark/android_external_chromium_org
media/tools/layout_tests/trend_graph.py
174
3309
# Copyright (c) 2012 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. """A module for manipulating trend graph with analyzer result history.""" import os import layouttest_analyzer_helpers DEFAULT_TREND_GRAPH_PATH = os.path.join('graph', 'graph.html') # The following is necesasry to decide the point to insert. LINE_INSERT_POINT_FOR_NUMBERS = r'// insert 1' LINE_INSERT_POINT_FOR_PASSING_RATE = r'// insert 2' class TrendGraph(object): """A class to manage trend graph which is using Google Visualization APIs. Google Visualization API (http://code.google.com/apis/chart/interactive/docs/ gallery/annotatedtimeline.html) is used to present the historical analyzer result. Currently, data is directly written to JavaScript file using file in-place replacement for simplicity. TODO(imasaki): use GoogleSpreadsheet to store the analyzer result. """ def __init__(self, location=DEFAULT_TREND_GRAPH_PATH): """Initialize this object with the location of trend graph.""" self._location = location def Update(self, datetime_string, data_map): """Update trend graphs using |datetime_string| and |data_map|. There are two kinds of graphs to be updated (one is for numbers and the other is for passing rates). Args: datetime_string: a datetime string delimited by ',' (e.g., '2008,1,1,13,45,00)'. For example, in the case of the year 2008, this ranges from '2008,1,1,0,0,00' to '2008,12,31,23,59,99'. data_map: a dictionary containing 'whole', 'skip' , 'nonskip', 'passingrate' as its keys and (number, tile, text) string tuples as values for graph annotation. """ joined_str = '' # For a date format in GViz, month is shifted (e.g., '2008,2,1' means # March 1, 2008). So, the input parameter |datetime_string| (before this # conversion) must be shifted in order to show the date properly on GViz. # After the below conversion, for example, in the case of the year 2008, # |datetime_string| ranges from '2008,0,1,0,0,00' to '2008,11,31,23,59,99'. str_list = datetime_string.split(',') str_list[1] = str(int(str_list[1])-1) # Month datetime_string = ','.join(str_list) for key in ['whole', 'skip', 'nonskip']: joined_str += str(len(data_map[key][0])) + ',' joined_str += ','.join(data_map[key][1:]) + ',' new_line_for_numbers = ' [new Date(%s),%s],\n' % (datetime_string, joined_str) new_line_for_numbers += ' %s\n' % ( LINE_INSERT_POINT_FOR_NUMBERS) layouttest_analyzer_helpers.ReplaceLineInFile( self._location, LINE_INSERT_POINT_FOR_NUMBERS, new_line_for_numbers) joined_str = '%s,%s,%s' % ( str(data_map['passingrate'][0]), data_map['nonskip'][1], data_map['nonskip'][2]) new_line_for_passingrate = ' [new Date(%s),%s],\n' % ( datetime_string, joined_str) new_line_for_passingrate += ' %s\n' % ( LINE_INSERT_POINT_FOR_PASSING_RATE) layouttest_analyzer_helpers.ReplaceLineInFile( self._location, LINE_INSERT_POINT_FOR_PASSING_RATE, new_line_for_passingrate)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 33, 859, 367, 13335, 20529, 307, 16479, 3343, 543, 24608, 754, 7994, 1041, 199, 199, 646, 747, 199, 199, 646, 7054, 396, 63, 17965, 63, 7546, 199, 199, 3472, 63, 1766, 3902, 63, 25302, 63, 3243, 275, 747, 14, 515, 14, 904, 360, 2180, 297, 283, 2180, 14, 1360, 358, 199, 199, 3, 710, 2569, 365, 1279, 823, 305, 651, 370, 19822, 314, 2376, 370, 5518, 14, 199, 6174, 63, 10258, 63, 7217, 63, 2707, 63, 8861, 3960, 275, 519, 28866, 5518, 413, 7, 199, 6174, 63, 10258, 63, 7217, 63, 2707, 63, 6909, 1206, 63, 16553, 275, 519, 28866, 5518, 499, 7, 421, 199, 533, 377, 16479, 4578, 8, 785, 304, 523, 408, 33, 1021, 370, 9635, 307, 16479, 3343, 1314, 365, 1808, 4475, 14702, 2072, 15913, 14, 819, 4475, 14702, 2072, 3261, 334, 1014, 921, 600, 14, 3098, 14, 957, 15, 12662, 15, 9019, 15, 13543, 15, 4757, 15, 523, 486, 17787, 15, 3226, 972, 19369, 14, 1360, 9, 365, 1202, 370, 3451, 314, 32530, 24608, 523, 754, 14, 13550, 12, 666, 365, 5370, 5313, 370, 15250, 570, 1808, 570, 523, 315, 13, 2778, 8343, 367, 17553, 3690, 14, 819, 3254, 8, 1017, 305, 27387, 304, 675, 4475, 30693, 370, 3877, 314, 24608, 754, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 2909, 29, 3472, 63, 1766, 3902, 63, 25302, 63, 3243, 304, 272, 408, 9345, 642, 909, 543, 314, 2909, 402, 307, 16479, 3343, 1041, 272, 291, 423, 1985, 275, 2909, 819, 347, 6162, 8, 277, 12, 2197, 63, 875, 12, 666, 63, 1130, 304, 272, 408, 4152, 307, 16479, 18312, 1808, 1204, 2083, 63, 875, 92, 436, 1204, 576, 63, 1130, 18257, 339, 6006, 787, 2877, 24241, 402, 18312, 370, 506, 4588, 334, 368, 365, 367, 5579, 436, 314, 272, 1163, 365, 367, 9476, 24434, 680, 339, 3033, 26, 267, 2197, 63, 875, 26, 282, 2197, 1059, 21941, 701, 13647, 881, 334, 69, 14, 71, 2020, 283, 9300, 12, 17, 12, 17, 12, 969, 12, 2322, 12, 383, 9, 1370, 2104, 2893, 12, 315, 314, 1930, 402, 314, 5361, 881, 9079, 12, 642, 12271, 687, 283, 9300, 12, 17, 12, 17, 12, 16, 12, 16, 12, 383, 7, 370, 283, 9300, 12, 713, 12, 2192, 12, 1789, 12, 1427, 12, 1020, 1370, 267, 666, 63, 1130, 26, 282, 2600, 3035, 283, 21224, 297, 283, 2759, 7, 2360, 283, 2865, 2759, 297, 881, 283, 29436, 1866, 7, 465, 2399, 2883, 436, 334, 1955, 12, 12835, 12, 1318, 9, 1059, 6346, 881, 465, 1338, 367, 3343, 11262, 14, 272, 408, 272, 16538, 63, 495, 275, 2125, 272, 327, 2104, 282, 1434, 1475, 315, 598, 32068, 12, 5794, 365, 31915, 334, 69, 14, 71, 2020, 283, 9300, 12, 18, 12, 17, 7, 4910, 272, 327, 603, 1047, 413, 12, 9079, 680, 2002, 12, 314, 1324, 2725, 1204, 2083, 63, 875, 92, 334, 5182, 642, 272, 327, 8603, 9, 1471, 506, 31915, 315, 1865, 370, 2498, 314, 1434, 7684, 641, 598, 32068, 14, 272, 327, 12836, 314, 5084, 8603, 12, 367, 2893, 12, 315, 314, 1930, 402, 314, 5361, 9079, 12, 272, 327, 1204, 2083, 63, 875, 92, 12271, 687, 283, 9300, 12, 16, 12, 17, 12, 16, 12, 16, 12, 383, 7, 370, 283, 9300, 12, 845, 12, 2192, 12, 1789, 12, 1427, 12, 1020, 1370, 272, 620, 63, 513, 275, 2197, 63, 875, 14, 1294, 11917, 272, 620, 63, 513, 59, 17, 61, 275, 620, 8, 442, 8, 495, 63, 513, 59, 17, 566, 13, 17, 9, 221, 327, 28835, 272, 2197, 63, 875, 275, 12814, 904, 8, 495, 63, 513, 9, 272, 367, 790, 315, 788, 21224, 297, 283, 2759, 297, 283, 2865, 2759, 2565, 489, 16538, 63, 495, 847, 620, 8, 552, 8, 576, 63, 1130, 59, 498, 1527, 16, 2459, 435, 13647, 489, 16538, 63, 495, 847, 12814, 904, 8, 576, 63, 1130, 59, 498, 1527, 17, 5728, 435, 13647, 272, 892, 63, 604, 63, 509, 63, 10548, 275, 283, 260, 359, 1222, 6148, 4042, 83, 395, 5, 83, 26670, 78, 7, 450, 334, 2083, 63, 875, 12, 16854, 16538, 63, 495, 9, 272, 892, 63, 604, 63, 509, 63, 10548, 847, 283, 260, 450, 83, 60, 78, 7, 450, 334, 267, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 8861, 3960, 9, 272, 7054, 396, 63, 17965, 63, 7546, 14, 11328, 3049, 607, 1173, 8, 267, 291, 423, 1985, 12, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 8861, 3960, 12, 267, 892, 63, 604, 63, 509, 63, 10548, 9, 339, 16538, 63, 495, 275, 1543, 83, 8719, 83, 8719, 83, 7, 450, 334, 267, 620, 8, 576, 63, 1130, 459, 29436, 1866, 3488, 16, 2522, 666, 63, 1130, 459, 2865, 2759, 3488, 17, 467, 267, 666, 63, 1130, 459, 2865, 2759, 3488, 18, 566, 272, 892, 63, 604, 63, 509, 63, 29436, 1866, 275, 283, 260, 359, 1222, 6148, 4042, 83, 395, 5, 83, 26670, 78, 7, 450, 334, 267, 2197, 63, 875, 12, 16538, 63, 495, 9, 272, 892, 63, 604, 63, 509, 63, 29436, 1866, 847, 283, 260, 450, 83, 60, 78, 7, 450, 334, 267, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 6909, 1206, 63, 16553, 9, 272, 7054, 396, 63, 17965, 63, 7546, 14, 11328, 3049, 607, 1173, 8, 267, 291, 423, 1985, 12, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 6909, 1206, 63, 16553, 12, 267, 892, 63, 604, 63, 509, 63, 29436, 1866, 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 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 33, 859, 367, 13335, 20529, 307, 16479, 3343, 543, 24608, 754, 7994, 1041, 199, 199, 646, 747, 199, 199, 646, 7054, 396, 63, 17965, 63, 7546, 199, 199, 3472, 63, 1766, 3902, 63, 25302, 63, 3243, 275, 747, 14, 515, 14, 904, 360, 2180, 297, 283, 2180, 14, 1360, 358, 199, 199, 3, 710, 2569, 365, 1279, 823, 305, 651, 370, 19822, 314, 2376, 370, 5518, 14, 199, 6174, 63, 10258, 63, 7217, 63, 2707, 63, 8861, 3960, 275, 519, 28866, 5518, 413, 7, 199, 6174, 63, 10258, 63, 7217, 63, 2707, 63, 6909, 1206, 63, 16553, 275, 519, 28866, 5518, 499, 7, 421, 199, 533, 377, 16479, 4578, 8, 785, 304, 523, 408, 33, 1021, 370, 9635, 307, 16479, 3343, 1314, 365, 1808, 4475, 14702, 2072, 15913, 14, 819, 4475, 14702, 2072, 3261, 334, 1014, 921, 600, 14, 3098, 14, 957, 15, 12662, 15, 9019, 15, 13543, 15, 4757, 15, 523, 486, 17787, 15, 3226, 972, 19369, 14, 1360, 9, 365, 1202, 370, 3451, 314, 32530, 24608, 523, 754, 14, 13550, 12, 666, 365, 5370, 5313, 370, 15250, 570, 1808, 570, 523, 315, 13, 2778, 8343, 367, 17553, 3690, 14, 819, 3254, 8, 1017, 305, 27387, 304, 675, 4475, 30693, 370, 3877, 314, 24608, 754, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 2909, 29, 3472, 63, 1766, 3902, 63, 25302, 63, 3243, 304, 272, 408, 9345, 642, 909, 543, 314, 2909, 402, 307, 16479, 3343, 1041, 272, 291, 423, 1985, 275, 2909, 819, 347, 6162, 8, 277, 12, 2197, 63, 875, 12, 666, 63, 1130, 304, 272, 408, 4152, 307, 16479, 18312, 1808, 1204, 2083, 63, 875, 92, 436, 1204, 576, 63, 1130, 18257, 339, 6006, 787, 2877, 24241, 402, 18312, 370, 506, 4588, 334, 368, 365, 367, 5579, 436, 314, 272, 1163, 365, 367, 9476, 24434, 680, 339, 3033, 26, 267, 2197, 63, 875, 26, 282, 2197, 1059, 21941, 701, 13647, 881, 334, 69, 14, 71, 2020, 283, 9300, 12, 17, 12, 17, 12, 969, 12, 2322, 12, 383, 9, 1370, 2104, 2893, 12, 315, 314, 1930, 402, 314, 5361, 881, 9079, 12, 642, 12271, 687, 283, 9300, 12, 17, 12, 17, 12, 16, 12, 16, 12, 383, 7, 370, 283, 9300, 12, 713, 12, 2192, 12, 1789, 12, 1427, 12, 1020, 1370, 267, 666, 63, 1130, 26, 282, 2600, 3035, 283, 21224, 297, 283, 2759, 7, 2360, 283, 2865, 2759, 297, 881, 283, 29436, 1866, 7, 465, 2399, 2883, 436, 334, 1955, 12, 12835, 12, 1318, 9, 1059, 6346, 881, 465, 1338, 367, 3343, 11262, 14, 272, 408, 272, 16538, 63, 495, 275, 2125, 272, 327, 2104, 282, 1434, 1475, 315, 598, 32068, 12, 5794, 365, 31915, 334, 69, 14, 71, 2020, 283, 9300, 12, 18, 12, 17, 7, 4910, 272, 327, 603, 1047, 413, 12, 9079, 680, 2002, 12, 314, 1324, 2725, 1204, 2083, 63, 875, 92, 334, 5182, 642, 272, 327, 8603, 9, 1471, 506, 31915, 315, 1865, 370, 2498, 314, 1434, 7684, 641, 598, 32068, 14, 272, 327, 12836, 314, 5084, 8603, 12, 367, 2893, 12, 315, 314, 1930, 402, 314, 5361, 9079, 12, 272, 327, 1204, 2083, 63, 875, 92, 12271, 687, 283, 9300, 12, 16, 12, 17, 12, 16, 12, 16, 12, 383, 7, 370, 283, 9300, 12, 845, 12, 2192, 12, 1789, 12, 1427, 12, 1020, 1370, 272, 620, 63, 513, 275, 2197, 63, 875, 14, 1294, 11917, 272, 620, 63, 513, 59, 17, 61, 275, 620, 8, 442, 8, 495, 63, 513, 59, 17, 566, 13, 17, 9, 221, 327, 28835, 272, 2197, 63, 875, 275, 12814, 904, 8, 495, 63, 513, 9, 272, 367, 790, 315, 788, 21224, 297, 283, 2759, 297, 283, 2865, 2759, 2565, 489, 16538, 63, 495, 847, 620, 8, 552, 8, 576, 63, 1130, 59, 498, 1527, 16, 2459, 435, 13647, 489, 16538, 63, 495, 847, 12814, 904, 8, 576, 63, 1130, 59, 498, 1527, 17, 5728, 435, 13647, 272, 892, 63, 604, 63, 509, 63, 10548, 275, 283, 260, 359, 1222, 6148, 4042, 83, 395, 5, 83, 26670, 78, 7, 450, 334, 2083, 63, 875, 12, 16854, 16538, 63, 495, 9, 272, 892, 63, 604, 63, 509, 63, 10548, 847, 283, 260, 450, 83, 60, 78, 7, 450, 334, 267, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 8861, 3960, 9, 272, 7054, 396, 63, 17965, 63, 7546, 14, 11328, 3049, 607, 1173, 8, 267, 291, 423, 1985, 12, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 8861, 3960, 12, 267, 892, 63, 604, 63, 509, 63, 10548, 9, 339, 16538, 63, 495, 275, 1543, 83, 8719, 83, 8719, 83, 7, 450, 334, 267, 620, 8, 576, 63, 1130, 459, 29436, 1866, 3488, 16, 2522, 666, 63, 1130, 459, 2865, 2759, 3488, 17, 467, 267, 666, 63, 1130, 459, 2865, 2759, 3488, 18, 566, 272, 892, 63, 604, 63, 509, 63, 29436, 1866, 275, 283, 260, 359, 1222, 6148, 4042, 83, 395, 5, 83, 26670, 78, 7, 450, 334, 267, 2197, 63, 875, 12, 16538, 63, 495, 9, 272, 892, 63, 604, 63, 509, 63, 29436, 1866, 847, 283, 260, 450, 83, 60, 78, 7, 450, 334, 267, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 6909, 1206, 63, 16553, 9, 272, 7054, 396, 63, 17965, 63, 7546, 14, 11328, 3049, 607, 1173, 8, 267, 291, 423, 1985, 12, 13587, 63, 10258, 63, 7217, 63, 2707, 63, 6909, 1206, 63, 16553, 12, 267, 892, 63, 604, 63, 509, 63, 29436, 1866, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
RapidApplicationDevelopment/tensorflow
tensorflow/contrib/training/python/training/feeder_test.py
9
10130
# Copyright 2016 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 tf.contrib.training.feeder.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections import portpicker import tensorflow as tf class FeederThread(object): # Helper class, wrapping a feeder and making sure it's located on the proper # device def __init__(self, test_case, coord, servers, job, task_num, prefix=''): self.graph = tf.Graph() self.coord = coord self.server = servers[job][task_num] self.remote_devices = [] # Just because we do tf.session(X) doesn't mean ops will located # on the X task; wrapping all feeder creation/interaction in an # extra tf.device(X) ensures that any ops that don't provider # their own tf.device() wrapper will be placed on the correct "local" # feeder task. A session can and does put ops that have no device # assignment onto any of the tasks it knows about, not just the # task passed as its target= argument! self.device = '/job:%s/task:%d' % (job, task_num) self.prefix = prefix self.thread = test_case.checkedThread(target=self._feed_thread) with self.graph.as_default(), tf.device(self.device): self.feeder = tf.contrib.training.Feeder([tf.string, tf.string], [[], []], capacity=1) self.feeder.set_many_fed_tensors(self._get_feed_values()) def _get_feed_values(self): # Return some feeding strings, possibly prefixed. return [ tf.constant( ['%s%s' % (self.prefix, x) for x in ['a0', 'a1', 'a2']]), tf.constant( ['%s%s' % (self.prefix, x) for x in ['b0', 'b1', 'b2']])] def add_remote_device(self, dev): with self.graph.as_default(), tf.device(self.device): self.feeder.add_remote_device(dev) def start(self): self.thread.start() self.feeder.wait_until_feeding() # wait until it's up & feeding if self.coord.should_stop(): self.coord.join() # rethrows errors encountered in run_feeding_forever def join(self): self.thread.join() def _session(self): return tf.Session(target=self.server.target) def _feed_thread(self): with self.coord.stop_on_exception(): with self.graph.as_default(), tf.device(self.device): self.feeder.run_feeding_forever(self._session, self.coord) class FeederTest(tf.test.TestCase): # Tests for Feeder def _create_local_cluster(self, **kargs): """Creates a local cluster.""" cluster_dict = {} for (k, v) in kargs.items(): cluster_dict[k] = [ 'localhost:%d' % portpicker.pick_unused_port() for _ in range(v)] # Launch servers: servers = {} for (k, v) in kargs.items(): servers[k] = [tf.train.Server(cluster_dict, job_name=k, task_index=idx, start=True) for idx in range(v)] return servers def testFeederActsLikeQueue(self): # Tests that a feeder acts like a queue feeder = tf.contrib.training.Feeder( dtypes=[tf.string, tf.string], shapes=[[], []], capacity=10) feeder.set_many_fed_tensors([tf.constant(['a0', 'a1', 'a2']), tf.constant(['b0', 'b1', 'b2'])]) out_a, out_b = feeder.get_fed_tensors() with self.test_session() as session: coord = tf.train.Coordinator() tf.train.start_queue_runners(session, coord=coord) a, b = session.run([out_a, out_b]) self.assertEquals(b'a0', a) self.assertEquals(b'b0', b) a = session.run(out_a) # Omit b! self.assertEquals(b'a1', a) a, b = session.run([out_a, out_b]) self.assertEquals(b'a2', a) self.assertEquals(b'b2', b) # queued together a, b = session.run([out_a, out_b]) # loops around self.assertEquals(b'a0', a) self.assertEquals(b'b0', b) # queued together coord.request_stop() coord.join() def testFeederSeparateThread(self): # Start a feeder on a seperate thread, but with a shared local queue servers = self._create_local_cluster(worker=1) coord = tf.train.Coordinator() feed_thread = FeederThread(self, coord, servers, 'worker', 0) feed_thread.start() with tf.Graph().as_default(): with tf.device('/job:worker/task:0'): feeder = tf.contrib.training.Feeder( dtypes=[tf.string, tf.string], shapes=[[], []], capacity=1) out_a, out_b = feeder.get_fed_tensors() with tf.Session(servers['worker'][0].target) as session: a, b = session.run([out_a, out_b]) self.assertEquals(b'a0', a) self.assertEquals(b'b0', b) a = session.run(out_a) # Omit b! self.assertEquals(b'a1', a) coord.request_stop() coord.join() feed_thread.join() def testOneEachFeeding(self): # One feeder, one consumer servers = self._create_local_cluster(consumer=1, feeder=1) coord = tf.train.Coordinator() feeder_thread = FeederThread(self, coord, servers, 'feeder', 0) feeder_thread.add_remote_device('/job:consumer/task:0') feeder_thread.start() with tf.Graph().as_default(): with tf.device('/job:consumer/task:0'): feeder = tf.contrib.training.Feeder( dtypes=[tf.string, tf.string], shapes=[[], []], capacity=1) out_a, out_b = feeder.get_fed_tensors() with tf.Session(servers['consumer'][0].target) as session: a, b = session.run([out_a, out_b]) self.assertEquals(b'a0', a) self.assertEquals(b'b0', b) a = session.run(out_a) # Omit b! self.assertEquals(b'a1', a) coord.request_stop() coord.join() feeder_thread.join() def testMultipleProducersAndConsumers(self): # Three feeders, three consumers. servers = self._create_local_cluster(consumer=3, feeder=3) coord = tf.train.Coordinator() # Start the three feeders: f0 = FeederThread(self, coord, servers, 'feeder', 0, prefix='feed0_') f0.add_remote_device('/job:consumer/task:0') f0.add_remote_device('/job:consumer/task:1') f0.start() f1 = FeederThread(self, coord, servers, 'feeder', 1, prefix='feed1_') f1.add_remote_device('/job:consumer/task:2') f1.add_remote_device('/job:consumer/task:0') f1.start() f2 = FeederThread(self, coord, servers, 'feeder', 2, prefix='feed2_') f2.add_remote_device('/job:consumer/task:1') f2.add_remote_device('/job:consumer/task:2') f2.start() # Three consumers. def _run_consumer(task, expected_keys): server = servers['consumer'][task] # Runs until everything in expected_keys has been seen at least once; # fails if any prefix not in expected_keys shows up with tf.Graph().as_default(), tf.device('/job:consumer/task:%d' % task): feeder = tf.contrib.training.Feeder( dtypes=[tf.string, tf.string], shapes=[[], []], capacity=1) out_a, out_b = feeder.get_fed_tensors() counts = collections.Counter() with tf.Session(server.target) as sess: while True: a, b = sess.run([out_a, out_b]) counts[a[:-1]] += 1 counts[b[:-1]] += 1 self.assertTrue(a[:-1] in expected_keys) self.assertTrue(b[:-1] in expected_keys) if all(counts[k] > 0 for k in expected_keys): return _run_consumer(0, [b'feed0_a', b'feed0_b', b'feed1_a', b'feed1_b']) _run_consumer(1, [b'feed0_a', b'feed0_b', b'feed2_a', b'feed2_b']) _run_consumer(2, [b'feed1_a', b'feed1_b', b'feed2_a', b'feed2_b']) coord.request_stop() coord.join() f0.join() f1.join() f2.join() def testAddRemoteReplicas(self): with tf.Graph().as_default(): for idx in range(3): with tf.name_scope('replica_%d' % idx): feeder = tf.contrib.training.Feeder( dtypes=[tf.string, tf.string], shapes=[[], []], capacity=10) feeder.add_remote_replicas('consumer', replica_count=3, feeder_task_num=idx, replicas_per_feeder=2, base_device_spec='/device:cpu:0') # Examine ops... op_types_by_scope_and_device = collections.defaultdict( lambda: collections.defaultdict(collections.Counter)) for op in tf.get_default_graph().get_operations(): scope = '/'.join(op.name.split('/')[:-1]) dev = op.device op_types_by_scope_and_device[scope][dev][op.type] += 1 expected_ops = collections.Counter({'QueueEnqueue': 1, 'FIFOQueue': 1}) expected_enq_devices = [ ('replica_0', ['/job:consumer/replica:0/device:cpu:0', '/job:consumer/replica:1/device:cpu:0',]), ('replica_1', ['/job:consumer/replica:2/device:cpu:0', '/job:consumer/replica:0/device:cpu:0',]), ('replica_2', ['/job:consumer/replica:1/device:cpu:0', '/job:consumer/replica:2/device:cpu:0',])] for scope, devs in expected_enq_devices: for dev in devs: self.assertEqual( expected_ops, op_types_by_scope_and_device[scope][dev]) if __name__ == '__main__': tf.test.main()
apache-2.0
[ 3, 1898, 7800, 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, 199, 624, 2925, 367, 2833, 14, 2828, 14, 7588, 14, 11195, 424, 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, 199, 646, 1844, 4510, 281, 199, 646, 3228, 465, 2833, 421, 199, 533, 481, 1024, 424, 4436, 8, 785, 304, 523, 327, 11642, 1021, 12, 19696, 282, 14751, 424, 436, 10663, 3238, 652, 1159, 16180, 641, 314, 5576, 523, 327, 2243, 819, 347, 636, 826, 721, 277, 12, 511, 63, 2546, 12, 11021, 12, 8037, 12, 3906, 12, 2120, 63, 1507, 12, 2403, 9280, 272, 291, 14, 2180, 275, 2833, 14, 4578, 342, 272, 291, 14, 7988, 275, 11021, 272, 291, 14, 1000, 275, 8037, 59, 2423, 1527, 1765, 63, 1507, 61, 272, 291, 14, 3846, 63, 6410, 275, 942, 339, 327, 13870, 2952, 781, 886, 2833, 14, 1730, 8, 56, 9, 3181, 1133, 4615, 4156, 911, 16180, 272, 327, 641, 314, 1323, 2120, 27, 19696, 1006, 14751, 424, 7143, 15, 21679, 315, 376, 272, 327, 2402, 2833, 14, 1782, 8, 56, 9, 15620, 626, 1263, 4156, 626, 2793, 1133, 5022, 272, 327, 3932, 5705, 2833, 14, 1782, 342, 4975, 911, 506, 15090, 641, 314, 3211, 298, 1832, 2, 272, 327, 14751, 424, 2120, 14, 437, 2351, 883, 436, 1630, 5324, 4156, 626, 1172, 949, 2243, 272, 327, 9801, 14602, 1263, 402, 314, 6527, 652, 19428, 3595, 12, 440, 2951, 314, 272, 327, 2120, 3032, 465, 2399, 1347, 29, 1423, 1, 272, 291, 14, 1782, 275, 1994, 2423, 2689, 83, 15, 1765, 2689, 68, 7, 450, 334, 2423, 12, 2120, 63, 1507, 9, 272, 291, 14, 1861, 275, 2403, 272, 291, 14, 2671, 275, 511, 63, 2546, 14, 10718, 4436, 8, 1375, 29, 277, 423, 3871, 63, 2671, 9, 339, 543, 291, 14, 2180, 14, 305, 63, 885, 1062, 2833, 14, 1782, 8, 277, 14, 1782, 304, 489, 291, 14, 11195, 424, 275, 2833, 14, 2828, 14, 7588, 14, 28042, 424, 779, 3249, 14, 875, 12, 2833, 14, 875, 467, 6901, 3474, 467, 942, 467, 6901, 14893, 29, 17, 9, 489, 291, 14, 11195, 424, 14, 409, 63, 3479, 63, 15800, 63, 10206, 8, 277, 423, 362, 63, 3871, 63, 1459, 1012, 819, 347, 485, 362, 63, 3871, 63, 1459, 8, 277, 304, 272, 327, 1432, 2005, 4733, 316, 3326, 12, 12570, 18239, 14, 272, 372, 359, 267, 2833, 14, 4083, 8, 288, 15926, 83, 5, 83, 7, 450, 334, 277, 14, 1861, 12, 671, 9, 367, 671, 315, 788, 65, 16, 297, 283, 65, 17, 297, 283, 65, 18, 418, 2522, 267, 2833, 14, 4083, 8, 288, 15926, 83, 5, 83, 7, 450, 334, 277, 14, 1861, 12, 671, 9, 367, 671, 315, 788, 66, 16, 297, 283, 66, 17, 297, 283, 66, 18, 12121, 61, 819, 347, 1050, 63, 3846, 63, 1782, 8, 277, 12, 4866, 304, 272, 543, 291, 14, 2180, 14, 305, 63, 885, 1062, 2833, 14, 1782, 8, 277, 14, 1782, 304, 489, 291, 14, 11195, 424, 14, 525, 63, 3846, 63, 1782, 8, 2374, 9, 819, 347, 1343, 8, 277, 304, 272, 291, 14, 2671, 14, 928, 342, 272, 291, 14, 11195, 424, 14, 2573, 63, 8111, 63, 3871, 316, 342, 221, 327, 3618, 5133, 652, 1159, 1536, 1253, 4733, 316, 272, 340, 291, 14, 7988, 14, 5626, 63, 2379, 837, 489, 291, 14, 7988, 14, 904, 342, 221, 327, 295, 32229, 2552, 14556, 315, 1255, 63, 3871, 316, 63, 21327, 819, 347, 4263, 8, 277, 304, 272, 291, 14, 2671, 14, 904, 342, 819, 347, 485, 1730, 8, 277, 304, 272, 372, 2833, 14, 4434, 8, 1375, 29, 277, 14, 1000, 14, 1375, 9, 819, 347, 485, 3871, 63, 2671, 8, 277, 304, 272, 543, 291, 14, 7988, 14, 2379, 63, 265, 63, 1971, 837, 489, 543, 291, 14, 2180, 14, 305, 63, 885, 1062, 2833, 14, 1782, 8, 277, 14, 1782, 304, 267, 291, 14, 11195, 424, 14, 1065, 63, 3871, 316, 63, 21327, 8, 277, 423, 1730, 12, 291, 14, 7988, 9, 421, 199, 533, 481, 1024, 424, 774, 8, 3249, 14, 396, 14, 1746, 304, 523, 327, 6496, 367, 481, 1024, 424, 819, 347, 485, 981, 63, 1832, 63, 4201, 8, 277, 12, 1011, 24459, 304, 272, 408, 10607, 282, 2257, 4350, 1041, 272, 4350, 63, 807, 275, 1052, 272, 367, 334, 75, 12, 373, 9, 315, 1022, 589, 14, 1744, 837, 489, 4350, 63, 807, 59, 75, 61, 275, 359, 881, 283, 5967, 2689, 68, 7, 450, 1844, 4510, 281, 14, 4510, 63, 8618, 63, 719, 342, 367, 485, 315, 1425, 8, 86, 1874, 339, 327, 23615, 8037, 26, 272, 8037, 275, 1052, 272, 367, 334, 75, 12, 373, 9, 315, 1022, 589, 14, 1744, 837, 489, 8037, 59, 75, 61, 275, 359, 3249, 14, 2834, 14, 3120, 8, 4201, 63, 807, 12, 2511, 3906, 63, 354, 29, 75, 12, 2511, 2120, 63, 1080, 29, 2996, 12, 2511, 1343, 29, 549, 9, 367, 4280, 315, 1425, 8, 86, 1874, 272, 372, 8037, 819, 347, 511, 28042, 424, 33, 3021, 12545, 3737, 8, 277, 304, 272, 327, 6496, 626, 282, 14751, 424, 17795, 2839, 282, 4126, 272, 14751, 424, 275, 2833, 14, 2828, 14, 7588, 14, 28042, 424, 8, 267, 6674, 1524, 3249, 14, 875 ]
[ 1898, 7800, 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, 199, 624, 2925, 367, 2833, 14, 2828, 14, 7588, 14, 11195, 424, 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, 199, 646, 1844, 4510, 281, 199, 646, 3228, 465, 2833, 421, 199, 533, 481, 1024, 424, 4436, 8, 785, 304, 523, 327, 11642, 1021, 12, 19696, 282, 14751, 424, 436, 10663, 3238, 652, 1159, 16180, 641, 314, 5576, 523, 327, 2243, 819, 347, 636, 826, 721, 277, 12, 511, 63, 2546, 12, 11021, 12, 8037, 12, 3906, 12, 2120, 63, 1507, 12, 2403, 9280, 272, 291, 14, 2180, 275, 2833, 14, 4578, 342, 272, 291, 14, 7988, 275, 11021, 272, 291, 14, 1000, 275, 8037, 59, 2423, 1527, 1765, 63, 1507, 61, 272, 291, 14, 3846, 63, 6410, 275, 942, 339, 327, 13870, 2952, 781, 886, 2833, 14, 1730, 8, 56, 9, 3181, 1133, 4615, 4156, 911, 16180, 272, 327, 641, 314, 1323, 2120, 27, 19696, 1006, 14751, 424, 7143, 15, 21679, 315, 376, 272, 327, 2402, 2833, 14, 1782, 8, 56, 9, 15620, 626, 1263, 4156, 626, 2793, 1133, 5022, 272, 327, 3932, 5705, 2833, 14, 1782, 342, 4975, 911, 506, 15090, 641, 314, 3211, 298, 1832, 2, 272, 327, 14751, 424, 2120, 14, 437, 2351, 883, 436, 1630, 5324, 4156, 626, 1172, 949, 2243, 272, 327, 9801, 14602, 1263, 402, 314, 6527, 652, 19428, 3595, 12, 440, 2951, 314, 272, 327, 2120, 3032, 465, 2399, 1347, 29, 1423, 1, 272, 291, 14, 1782, 275, 1994, 2423, 2689, 83, 15, 1765, 2689, 68, 7, 450, 334, 2423, 12, 2120, 63, 1507, 9, 272, 291, 14, 1861, 275, 2403, 272, 291, 14, 2671, 275, 511, 63, 2546, 14, 10718, 4436, 8, 1375, 29, 277, 423, 3871, 63, 2671, 9, 339, 543, 291, 14, 2180, 14, 305, 63, 885, 1062, 2833, 14, 1782, 8, 277, 14, 1782, 304, 489, 291, 14, 11195, 424, 275, 2833, 14, 2828, 14, 7588, 14, 28042, 424, 779, 3249, 14, 875, 12, 2833, 14, 875, 467, 6901, 3474, 467, 942, 467, 6901, 14893, 29, 17, 9, 489, 291, 14, 11195, 424, 14, 409, 63, 3479, 63, 15800, 63, 10206, 8, 277, 423, 362, 63, 3871, 63, 1459, 1012, 819, 347, 485, 362, 63, 3871, 63, 1459, 8, 277, 304, 272, 327, 1432, 2005, 4733, 316, 3326, 12, 12570, 18239, 14, 272, 372, 359, 267, 2833, 14, 4083, 8, 288, 15926, 83, 5, 83, 7, 450, 334, 277, 14, 1861, 12, 671, 9, 367, 671, 315, 788, 65, 16, 297, 283, 65, 17, 297, 283, 65, 18, 418, 2522, 267, 2833, 14, 4083, 8, 288, 15926, 83, 5, 83, 7, 450, 334, 277, 14, 1861, 12, 671, 9, 367, 671, 315, 788, 66, 16, 297, 283, 66, 17, 297, 283, 66, 18, 12121, 61, 819, 347, 1050, 63, 3846, 63, 1782, 8, 277, 12, 4866, 304, 272, 543, 291, 14, 2180, 14, 305, 63, 885, 1062, 2833, 14, 1782, 8, 277, 14, 1782, 304, 489, 291, 14, 11195, 424, 14, 525, 63, 3846, 63, 1782, 8, 2374, 9, 819, 347, 1343, 8, 277, 304, 272, 291, 14, 2671, 14, 928, 342, 272, 291, 14, 11195, 424, 14, 2573, 63, 8111, 63, 3871, 316, 342, 221, 327, 3618, 5133, 652, 1159, 1536, 1253, 4733, 316, 272, 340, 291, 14, 7988, 14, 5626, 63, 2379, 837, 489, 291, 14, 7988, 14, 904, 342, 221, 327, 295, 32229, 2552, 14556, 315, 1255, 63, 3871, 316, 63, 21327, 819, 347, 4263, 8, 277, 304, 272, 291, 14, 2671, 14, 904, 342, 819, 347, 485, 1730, 8, 277, 304, 272, 372, 2833, 14, 4434, 8, 1375, 29, 277, 14, 1000, 14, 1375, 9, 819, 347, 485, 3871, 63, 2671, 8, 277, 304, 272, 543, 291, 14, 7988, 14, 2379, 63, 265, 63, 1971, 837, 489, 543, 291, 14, 2180, 14, 305, 63, 885, 1062, 2833, 14, 1782, 8, 277, 14, 1782, 304, 267, 291, 14, 11195, 424, 14, 1065, 63, 3871, 316, 63, 21327, 8, 277, 423, 1730, 12, 291, 14, 7988, 9, 421, 199, 533, 481, 1024, 424, 774, 8, 3249, 14, 396, 14, 1746, 304, 523, 327, 6496, 367, 481, 1024, 424, 819, 347, 485, 981, 63, 1832, 63, 4201, 8, 277, 12, 1011, 24459, 304, 272, 408, 10607, 282, 2257, 4350, 1041, 272, 4350, 63, 807, 275, 1052, 272, 367, 334, 75, 12, 373, 9, 315, 1022, 589, 14, 1744, 837, 489, 4350, 63, 807, 59, 75, 61, 275, 359, 881, 283, 5967, 2689, 68, 7, 450, 1844, 4510, 281, 14, 4510, 63, 8618, 63, 719, 342, 367, 485, 315, 1425, 8, 86, 1874, 339, 327, 23615, 8037, 26, 272, 8037, 275, 1052, 272, 367, 334, 75, 12, 373, 9, 315, 1022, 589, 14, 1744, 837, 489, 8037, 59, 75, 61, 275, 359, 3249, 14, 2834, 14, 3120, 8, 4201, 63, 807, 12, 2511, 3906, 63, 354, 29, 75, 12, 2511, 2120, 63, 1080, 29, 2996, 12, 2511, 1343, 29, 549, 9, 367, 4280, 315, 1425, 8, 86, 1874, 272, 372, 8037, 819, 347, 511, 28042, 424, 33, 3021, 12545, 3737, 8, 277, 304, 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 ]
dokterbob/satchmo
satchmo/apps/product/modules/subscription/models.py
8
6116
from django.db import models from django.utils.translation import ugettext_lazy as _ from product.models import Product, get_product_quantity_price, get_product_quantity_adjustments from decimal import Decimal import datetime from satchmo_utils import add_month from satchmo_utils.fields import CurrencyField SATCHMO_PRODUCT=True def get_product_types(): return ('SubscriptionProduct',) class SubscriptionProduct(models.Model): """ This type of Product is for recurring billing (memberships, subscriptions, payment terms) """ product = models.OneToOneField(Product, verbose_name=_("Product"), primary_key=True) recurring = models.BooleanField(_("Recurring Billing"), help_text=_("Customer will be charged the regular product price on a periodic basis."), default=False) recurring_times = models.IntegerField(_("Recurring Times"), help_text=_("Number of payments which will occur at the regular rate. (optional)"), null=True, blank=True) expire_length = models.IntegerField(_("Duration"), help_text=_("Length of each billing cycle"), null=True, blank=True) SUBSCRIPTION_UNITS = ( ('DAY', _('Days')), ('MONTH', _('Months')) ) expire_unit = models.CharField(_("Expire Unit"), max_length=5, choices=SUBSCRIPTION_UNITS, default="DAY", null=False) SHIPPING_CHOICES = ( ('0', _('No Shipping Charges')), ('1', _('Pay Shipping Once')), ('2', _('Pay Shipping Each Billing Cycle')), ) is_shippable = models.IntegerField(_("Shippable?"), help_text=_("Is this product shippable?"), max_length=1, choices=SHIPPING_CHOICES) is_subscription = True def _get_subtype(self): return 'SubscriptionProduct' def __unicode__(self): return self.product.slug def _get_fullPrice(self): """ returns price as a Decimal """ return self.get_qty_price(1) unit_price = property(_get_fullPrice) def get_qty_price(self, qty, show_trial=True, include_discount=True): """ If QTY_DISCOUNT prices are specified, then return the appropriate discount price for the specified qty. Otherwise, return the unit_price returns price as a Decimal Note: If a subscription has a trial, then we'll return the first trial price, otherwise the checkout won't balance and it will look like there are items to be paid on the order. """ if show_trial: trial = self.get_trial_terms(0) else: trial = None if trial: price = trial.price * qty else: if include_discount: price = get_product_quantity_price(self.product, qty) else: adjustment = get_product_quantity_adjustments(self, qty) if adjustment.price is not None: price = adjustment.price.price else: price = None if not price and qty == Decimal('1'): # Prevent a recursive loop. price = Decimal("0.00") elif not price: price = self.product._get_fullPrice() return price def recurring_price(self): """ Get the non-trial price. """ return self.get_qty_price(Decimal('1'), show_trial=False) # use order_success() and DownloadableProduct.create_key() to add user to group and perform other tasks def get_trial_terms(self, trial=None): """Get the trial terms for this subscription""" if trial is None: return self.trial_set.all().order_by('id') else: try: return self.trial_set.all().order_by('id')[trial] except IndexError: return None def calc_expire_date(self, date=None): if date is None: date = datetime.datetime.now() if self.expire_unit == "DAY": expiredate = date + datetime.timedelta(days=self.expire_length) else: expiredate = add_month(date, n=self.expire_length) return expiredate def save(self, **kwargs): if hasattr(self.product,'_sub_types'): del self.product._sub_types super(SubscriptionProduct, self).save(**kwargs) class Meta: verbose_name = _("Subscription Product") verbose_name_plural = _("Subscription Products") class Trial(models.Model): """ Trial billing terms for subscription products. Separating it out lets us have as many trial periods as we want. Note that some third party payment processors support only a limited number of trial billing periods. For example, PayPal limits us to 2 trial periods, so if you are using PayPal for a billing option, you need to create no more than 2 trial periods for your product. However, gateway based processors like Authorize.net can support as many billing periods as you wish. """ subscription = models.ForeignKey(SubscriptionProduct) price = CurrencyField(_("Price"), help_text=_("Set to 0 for a free trial. Leave empty if product does not have a trial."), max_digits=10, decimal_places=2, null=True, ) expire_length = models.IntegerField(_("Trial Duration"), help_text=_("Length of trial billing cycle. Leave empty if product does not have a trial."), null=True, blank=True) def __unicode__(self): return unicode(self.price) def _occurrences(self): if self.expire_length: return int(self.expire_length/self.subscription.expire_length) else: return 0 occurrences = property(fget=_occurrences) def calc_expire_date(self, date=None): if date is None: date = datetime.datetime.now() if self.subscription.expire_unit == "DAY": expiredate = date + datetime.timedelta(days=self.expire_length) else: expiredate = add_month(date, n=self.expire_length) return expiredate class Meta: ordering = ['-id'] verbose_name = _("Trial Terms") verbose_name_plural = _("Trial Terms")
bsd-3-clause
[ 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 3336, 14, 992, 492, 12705, 12, 664, 63, 2558, 63, 10577, 63, 4777, 12, 664, 63, 2558, 63, 10577, 63, 10917, 1470, 199, 504, 6107, 492, 6345, 199, 646, 2197, 199, 504, 308, 693, 573, 63, 1208, 492, 1050, 63, 4482, 199, 504, 308, 693, 573, 63, 1208, 14, 955, 492, 7319, 3860, 792, 199, 199, 51, 8078, 2679, 63, 14853, 29, 549, 199, 199, 318, 664, 63, 2558, 63, 1313, 837, 272, 372, 661, 19120, 5884, 9538, 199, 199, 533, 29763, 5884, 8, 992, 14, 1685, 304, 272, 408, 272, 961, 730, 402, 12705, 365, 367, 5344, 5985, 32663, 334, 13105, 83, 12, 25708, 12, 11628, 2895, 9, 272, 408, 272, 3336, 275, 1709, 14, 14298, 8, 5884, 12, 3376, 63, 354, 9384, 5884, 1288, 5062, 63, 498, 29, 549, 9, 272, 5344, 5985, 275, 1709, 14, 5036, 6115, 14244, 5985, 699, 12687, 1288, 1720, 63, 505, 9384, 17025, 911, 506, 1495, 3046, 314, 5578, 3336, 8033, 641, 282, 18745, 5597, 7651, 849, 29, 797, 9, 272, 5344, 5985, 63, 4508, 275, 1709, 14, 3901, 6115, 14244, 5985, 4703, 83, 1288, 1720, 63, 505, 9384, 3259, 402, 8633, 1470, 1314, 911, 4781, 737, 314, 5578, 6634, 14, 221, 334, 4144, 13185, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 16667, 63, 1267, 275, 1709, 14, 3901, 6115, 13283, 1288, 1720, 63, 505, 9384, 4625, 402, 1924, 32663, 8643, 1288, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 7605, 10484, 1075, 63, 27522, 275, 334, 267, 661, 11655, 297, 4018, 25589, 3855, 267, 661, 16413, 297, 4018, 14306, 83, 1333, 272, 776, 272, 16667, 63, 3248, 275, 1709, 14, 2183, 6115, 14000, 264, 12008, 1288, 1390, 63, 1267, 29, 21, 12, 3415, 29, 6348, 10484, 1075, 63, 27522, 12, 849, 628, 11655, 401, 2973, 29, 797, 9, 272, 4410, 1772, 15675, 63, 16236, 275, 334, 267, 661, 16, 297, 4018, 1944, 5244, 711, 4073, 6659, 3389, 3855, 267, 661, 17, 297, 4018, 10517, 5244, 711, 4073, 19468, 3855, 267, 661, 18, 297, 4018, 10517, 5244, 711, 4073, 7048, 699, 12687, 18461, 2265, 3855, 272, 776, 272, 365, 63, 3319, 80, 461, 275, 1709, 14, 3901, 6115, 30707, 80, 461, 31, 1288, 1720, 63, 505, 9384, 1831, 642, 3336, 15924, 80, 461, 31, 1288, 1390, 63, 1267, 29, 17, 12, 3415, 29, 3234, 1772, 15675, 63, 16236, 9, 339, 365, 63, 6645, 275, 715, 339, 347, 485, 362, 63, 10512, 8, 277, 304, 267, 372, 283, 19120, 5884, 7, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2558, 14, 5464, 339, 347, 485, 362, 63, 2861, 11826, 8, 277, 304, 267, 408, 267, 2529, 8033, 465, 282, 6345, 267, 408, 267, 372, 291, 14, 362, 63, 5643, 63, 4777, 8, 17, 9, 339, 4137, 63, 4777, 275, 3324, 1547, 362, 63, 2861, 11826, 9, 339, 347, 664, 63, 5643, 63, 4777, 8, 277, 12, 13556, 12, 2498, 63, 14443, 29, 549, 12, 2387, 63, 15446, 29, 549, 304, 267, 408, 267, 982, 1413, 2099, 63, 6178, 8760, 1979, 823, 787, 2013, 12, 2066, 372, 314, 5827, 25309, 8033, 367, 267, 314, 2013, 13556, 14, 221, 6630, 12, 372, 314, 4137, 63, 4777, 267, 2529, 8033, 465, 282, 6345, 398, 3390, 26, 982, 282, 9966, 965, 282, 16324, 12, 2066, 781, 7171, 372, 314, 1642, 16324, 8033, 12, 4257, 314, 15243, 7859, 1133, 267, 14094, 436, 652, 911, 3648, 2839, 2337, 787, 2974, 370, 506, 30677, 641, 314, 1865, 14, 267, 408, 267, 340, 2498, 63, 14443, 26, 288, 16324, 275, 291, 14, 362, 63, 14443, 63, 9187, 8, 16, 9, 267, 587, 26, 288, 16324, 275, 488, 398, 340, 16324, 26, 288, 8033, 275, 16324, 14, 4777, 627, 13556, 267, 587, 26, 288, 340, 2387, 63, 15446, 26, 355, 8033, 275, 664, 63, 2558, 63, 10577, 63, 4777, 8, 277, 14, 2558, 12, 13556, 9, 288, 587, 26, 355, 27999, 275, 664, 63, 2558, 63, 10577, 63, 10917, 1470, 8, 277, 12, 13556, 9, 355, 340, 27999, 14, 4777, 365, 440, 488, 26, 490, 8033, 275, 27999, 14, 4777, 14, 4777, 355, 587, 26, 490, 8033, 275, 488, 953, 340, 440, 8033, 436, 13556, 508, 6345, 360, 17, 735, 420, 327, 29861, 282, 9133, 4438, 14, 355, 8033, 275, 6345, 480, 16, 14, 383, 531, 288, 916, 440, 8033, 26, 355, 8033, 275, 291, 14, 2558, 423, 362, 63, 2861, 11826, 342, 267, 372, 8033, 339, 347, 5344, 5985, 63, 4777, 8, 277, 304, 267, 408, 267, 2372, 314, 2222, 13, 14443, 8033, 14, 267, 408, 267, 372, 291, 14, 362, 63, 5643, 63, 4777, 8, 6745, 360, 17, 659, 2498, 63, 14443, 29, 797, 9, 339, 327, 675, 1865, 63, 3742, 342, 436, 17955, 461, 5884, 14, 981, 63, 498, 342, 370, 1050, 922, 370, 1572, 436, 5147, 1163, 6527, 272, 347, 664, 63, 14443, 63, 9187, 8, 277, 12, 16324, 29, 403, 304, 267, 408, 1002, 314, 16324, 2895, 367, 642, 9966, 624, 267, 340, 16324, 365, 488, 26, 288, 372, 291, 14, 14443, 63, 409, 14, 452, 1252, 1648, 63, 991, 360, 344, 358, 267, 587, 26, 288, 862, 26, 355, 372, 291, 14, 14443, 63, 409, 14, 452, 1252, 1648, 63, 991, 360, 344, 5832, 14443, 61, 288, 871, 7888, 26, 355, 372, 488, 339, 347, 12831, 63, 14691, 63, 602, 8, 277, 12, 1434, 29, 403, 304, 267, 340, 1434, 365, 488, 26, 288, 1434, 275, 2197, 14, 2083, 14, 2131, 342, 267, 340, 291, 14, 14691, 63, 3248, 508, 298, 11655, 582, 288, 14721, 323, 275, 1434, 435, 2197, 14, 7473, 8, 4899, 29, 277, 14, 14691, 63, 1267, 9, 267, 587, 26, 288, 14721, 323, 275, 1050, 63, 4482, 8, 602, 12, 302, 29, 277, 14, 14691, 63, 1267, 9, 398, 372, 14721, 323, 339, 347, 3354, 8, 277, 12, 1011, 958, 304, 267, 340, 2688, 8, 277, 14, 2558, 2584, 63, 954, 63, 1313, 735, 288, 2150, 291, 14, 2558, 423, 954, 63, 1313, 267, 1613, 8, 19120, 5884, 12, 291, 680, 2117, 3682, 958, 9, 339, 1021, 6288, 26, 267 ]
[ 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 3336, 14, 992, 492, 12705, 12, 664, 63, 2558, 63, 10577, 63, 4777, 12, 664, 63, 2558, 63, 10577, 63, 10917, 1470, 199, 504, 6107, 492, 6345, 199, 646, 2197, 199, 504, 308, 693, 573, 63, 1208, 492, 1050, 63, 4482, 199, 504, 308, 693, 573, 63, 1208, 14, 955, 492, 7319, 3860, 792, 199, 199, 51, 8078, 2679, 63, 14853, 29, 549, 199, 199, 318, 664, 63, 2558, 63, 1313, 837, 272, 372, 661, 19120, 5884, 9538, 199, 199, 533, 29763, 5884, 8, 992, 14, 1685, 304, 272, 408, 272, 961, 730, 402, 12705, 365, 367, 5344, 5985, 32663, 334, 13105, 83, 12, 25708, 12, 11628, 2895, 9, 272, 408, 272, 3336, 275, 1709, 14, 14298, 8, 5884, 12, 3376, 63, 354, 9384, 5884, 1288, 5062, 63, 498, 29, 549, 9, 272, 5344, 5985, 275, 1709, 14, 5036, 6115, 14244, 5985, 699, 12687, 1288, 1720, 63, 505, 9384, 17025, 911, 506, 1495, 3046, 314, 5578, 3336, 8033, 641, 282, 18745, 5597, 7651, 849, 29, 797, 9, 272, 5344, 5985, 63, 4508, 275, 1709, 14, 3901, 6115, 14244, 5985, 4703, 83, 1288, 1720, 63, 505, 9384, 3259, 402, 8633, 1470, 1314, 911, 4781, 737, 314, 5578, 6634, 14, 221, 334, 4144, 13185, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 16667, 63, 1267, 275, 1709, 14, 3901, 6115, 13283, 1288, 1720, 63, 505, 9384, 4625, 402, 1924, 32663, 8643, 1288, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 7605, 10484, 1075, 63, 27522, 275, 334, 267, 661, 11655, 297, 4018, 25589, 3855, 267, 661, 16413, 297, 4018, 14306, 83, 1333, 272, 776, 272, 16667, 63, 3248, 275, 1709, 14, 2183, 6115, 14000, 264, 12008, 1288, 1390, 63, 1267, 29, 21, 12, 3415, 29, 6348, 10484, 1075, 63, 27522, 12, 849, 628, 11655, 401, 2973, 29, 797, 9, 272, 4410, 1772, 15675, 63, 16236, 275, 334, 267, 661, 16, 297, 4018, 1944, 5244, 711, 4073, 6659, 3389, 3855, 267, 661, 17, 297, 4018, 10517, 5244, 711, 4073, 19468, 3855, 267, 661, 18, 297, 4018, 10517, 5244, 711, 4073, 7048, 699, 12687, 18461, 2265, 3855, 272, 776, 272, 365, 63, 3319, 80, 461, 275, 1709, 14, 3901, 6115, 30707, 80, 461, 31, 1288, 1720, 63, 505, 9384, 1831, 642, 3336, 15924, 80, 461, 31, 1288, 1390, 63, 1267, 29, 17, 12, 3415, 29, 3234, 1772, 15675, 63, 16236, 9, 339, 365, 63, 6645, 275, 715, 339, 347, 485, 362, 63, 10512, 8, 277, 304, 267, 372, 283, 19120, 5884, 7, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2558, 14, 5464, 339, 347, 485, 362, 63, 2861, 11826, 8, 277, 304, 267, 408, 267, 2529, 8033, 465, 282, 6345, 267, 408, 267, 372, 291, 14, 362, 63, 5643, 63, 4777, 8, 17, 9, 339, 4137, 63, 4777, 275, 3324, 1547, 362, 63, 2861, 11826, 9, 339, 347, 664, 63, 5643, 63, 4777, 8, 277, 12, 13556, 12, 2498, 63, 14443, 29, 549, 12, 2387, 63, 15446, 29, 549, 304, 267, 408, 267, 982, 1413, 2099, 63, 6178, 8760, 1979, 823, 787, 2013, 12, 2066, 372, 314, 5827, 25309, 8033, 367, 267, 314, 2013, 13556, 14, 221, 6630, 12, 372, 314, 4137, 63, 4777, 267, 2529, 8033, 465, 282, 6345, 398, 3390, 26, 982, 282, 9966, 965, 282, 16324, 12, 2066, 781, 7171, 372, 314, 1642, 16324, 8033, 12, 4257, 314, 15243, 7859, 1133, 267, 14094, 436, 652, 911, 3648, 2839, 2337, 787, 2974, 370, 506, 30677, 641, 314, 1865, 14, 267, 408, 267, 340, 2498, 63, 14443, 26, 288, 16324, 275, 291, 14, 362, 63, 14443, 63, 9187, 8, 16, 9, 267, 587, 26, 288, 16324, 275, 488, 398, 340, 16324, 26, 288, 8033, 275, 16324, 14, 4777, 627, 13556, 267, 587, 26, 288, 340, 2387, 63, 15446, 26, 355, 8033, 275, 664, 63, 2558, 63, 10577, 63, 4777, 8, 277, 14, 2558, 12, 13556, 9, 288, 587, 26, 355, 27999, 275, 664, 63, 2558, 63, 10577, 63, 10917, 1470, 8, 277, 12, 13556, 9, 355, 340, 27999, 14, 4777, 365, 440, 488, 26, 490, 8033, 275, 27999, 14, 4777, 14, 4777, 355, 587, 26, 490, 8033, 275, 488, 953, 340, 440, 8033, 436, 13556, 508, 6345, 360, 17, 735, 420, 327, 29861, 282, 9133, 4438, 14, 355, 8033, 275, 6345, 480, 16, 14, 383, 531, 288, 916, 440, 8033, 26, 355, 8033, 275, 291, 14, 2558, 423, 362, 63, 2861, 11826, 342, 267, 372, 8033, 339, 347, 5344, 5985, 63, 4777, 8, 277, 304, 267, 408, 267, 2372, 314, 2222, 13, 14443, 8033, 14, 267, 408, 267, 372, 291, 14, 362, 63, 5643, 63, 4777, 8, 6745, 360, 17, 659, 2498, 63, 14443, 29, 797, 9, 339, 327, 675, 1865, 63, 3742, 342, 436, 17955, 461, 5884, 14, 981, 63, 498, 342, 370, 1050, 922, 370, 1572, 436, 5147, 1163, 6527, 272, 347, 664, 63, 14443, 63, 9187, 8, 277, 12, 16324, 29, 403, 304, 267, 408, 1002, 314, 16324, 2895, 367, 642, 9966, 624, 267, 340, 16324, 365, 488, 26, 288, 372, 291, 14, 14443, 63, 409, 14, 452, 1252, 1648, 63, 991, 360, 344, 358, 267, 587, 26, 288, 862, 26, 355, 372, 291, 14, 14443, 63, 409, 14, 452, 1252, 1648, 63, 991, 360, 344, 5832, 14443, 61, 288, 871, 7888, 26, 355, 372, 488, 339, 347, 12831, 63, 14691, 63, 602, 8, 277, 12, 1434, 29, 403, 304, 267, 340, 1434, 365, 488, 26, 288, 1434, 275, 2197, 14, 2083, 14, 2131, 342, 267, 340, 291, 14, 14691, 63, 3248, 508, 298, 11655, 582, 288, 14721, 323, 275, 1434, 435, 2197, 14, 7473, 8, 4899, 29, 277, 14, 14691, 63, 1267, 9, 267, 587, 26, 288, 14721, 323, 275, 1050, 63, 4482, 8, 602, 12, 302, 29, 277, 14, 14691, 63, 1267, 9, 398, 372, 14721, 323, 339, 347, 3354, 8, 277, 12, 1011, 958, 304, 267, 340, 2688, 8, 277, 14, 2558, 2584, 63, 954, 63, 1313, 735, 288, 2150, 291, 14, 2558, 423, 954, 63, 1313, 267, 1613, 8, 19120, 5884, 12, 291, 680, 2117, 3682, 958, 9, 339, 1021, 6288, 26, 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, 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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 ]
mapr/hue
desktop/core/ext-py/Django-1.6.10/django/contrib/messages/tests/base.py
104
14243
from django import http from django.conf import settings, global_settings from django.contrib.messages import constants, utils, get_level, set_level from django.contrib.messages.api import MessageFailure from django.contrib.messages.storage import default_storage, base from django.contrib.messages.storage.base import Message from django.core.urlresolvers import reverse from django.test.utils import override_settings from django.utils.translation import ugettext_lazy from django.utils.unittest import skipIf def skipUnlessAuthIsInstalled(func): return skipIf( 'django.contrib.auth' not in settings.INSTALLED_APPS, "django.contrib.auth isn't installed")(func) def add_level_messages(storage): """ Adds 6 messages from different levels (including a custom one) to a storage instance. """ storage.add(constants.INFO, 'A generic info message') storage.add(29, 'Some custom level') storage.add(constants.DEBUG, 'A debugging message', extra_tags='extra-tag') storage.add(constants.WARNING, 'A warning') storage.add(constants.ERROR, 'An error') storage.add(constants.SUCCESS, 'This was a triumph.') class override_settings_tags(override_settings): def enable(self): super(override_settings_tags, self).enable() # LEVEL_TAGS is a constant defined in the # django.contrib.messages.storage.base module, so after changing # settings.MESSAGE_TAGS, we need to update that constant too. self.old_level_tags = base.LEVEL_TAGS base.LEVEL_TAGS = utils.get_level_tags() def disable(self): super(override_settings_tags, self).disable() base.LEVEL_TAGS = self.old_level_tags class BaseTests(object): storage_class = default_storage urls = 'django.contrib.messages.tests.urls' levels = { 'debug': constants.DEBUG, 'info': constants.INFO, 'success': constants.SUCCESS, 'warning': constants.WARNING, 'error': constants.ERROR, } def setUp(self): self.settings_override = override_settings_tags( TEMPLATE_DIRS = (), TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS, MESSAGE_TAGS = '', MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__, self.storage_class.__name__), SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer', ) self.settings_override.enable() def tearDown(self): self.settings_override.disable() def get_request(self): return http.HttpRequest() def get_response(self): return http.HttpResponse() def get_storage(self, data=None): """ Returns the storage backend, setting its loaded data to the ``data`` argument. This method avoids the storage ``_get`` method from getting called so that other parts of the storage backend can be tested independent of the message retrieval logic. """ storage = self.storage_class(self.get_request()) storage._loaded_data = data or [] return storage def test_add(self): storage = self.get_storage() self.assertFalse(storage.added_new) storage.add(constants.INFO, 'Test message 1') self.assertTrue(storage.added_new) storage.add(constants.INFO, 'Test message 2', extra_tags='tag') self.assertEqual(len(storage), 2) def test_add_lazy_translation(self): storage = self.get_storage() response = self.get_response() storage.add(constants.INFO, ugettext_lazy('lazy message')) storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 1) def test_no_update(self): storage = self.get_storage() response = self.get_response() storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 0) def test_add_update(self): storage = self.get_storage() response = self.get_response() storage.add(constants.INFO, 'Test message 1') storage.add(constants.INFO, 'Test message 1', extra_tags='tag') storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 2) def test_existing_add_read_update(self): storage = self.get_existing_storage() response = self.get_response() storage.add(constants.INFO, 'Test message 3') list(storage) # Simulates a read storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 0) def test_existing_read_add_update(self): storage = self.get_existing_storage() response = self.get_response() list(storage) # Simulates a read storage.add(constants.INFO, 'Test message 3') storage.update(response) storing = self.stored_messages_count(storage, response) self.assertEqual(storing, 1) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_full_request_response_cycle(self): """ With the message middleware enabled, tests that messages are properly stored and then retrieved across the full request/redirect/response cycle. """ data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show') for level in ('debug', 'info', 'success', 'warning', 'error'): add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) response = self.client.post(add_url, data, follow=True) self.assertRedirects(response, show_url) self.assertTrue('messages' in response.context) messages = [Message(self.levels[level], msg) for msg in data['messages']] self.assertEqual(list(response.context['messages']), messages) for msg in data['messages']: self.assertContains(response, msg) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_with_template_response(self): data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show_template_response') for level in self.levels.keys(): add_url = reverse('django.contrib.messages.tests.urls.add_template_response', args=(level,)) response = self.client.post(add_url, data, follow=True) self.assertRedirects(response, show_url) self.assertTrue('messages' in response.context) for msg in data['messages']: self.assertContains(response, msg) # there shouldn't be any messages on second GET request response = self.client.get(show_url) for msg in data['messages']: self.assertNotContains(response, msg) @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_multiple_posts(self): """ Tests that messages persist properly when multiple POSTs are made before a GET. """ data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show') messages = [] for level in ('debug', 'info', 'success', 'warning', 'error'): messages.extend([Message(self.levels[level], msg) for msg in data['messages']]) add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) self.client.post(add_url, data) response = self.client.get(show_url) self.assertTrue('messages' in response.context) self.assertEqual(list(response.context['messages']), messages) for msg in data['messages']: self.assertContains(response, msg) @override_settings( INSTALLED_APPS=filter( lambda app:app!='django.contrib.messages', settings.INSTALLED_APPS), MIDDLEWARE_CLASSES=filter( lambda m:'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), TEMPLATE_CONTEXT_PROCESSORS=filter( lambda p:'context_processors.messages' not in p, settings.TEMPLATE_CONTEXT_PROCESSORS), MESSAGE_LEVEL=constants.DEBUG ) def test_middleware_disabled(self): """ Tests that, when the middleware is disabled, an exception is raised when one attempts to store a message. """ data = { 'messages': ['Test message %d' % x for x in range(5)], } show_url = reverse('django.contrib.messages.tests.urls.show') for level in ('debug', 'info', 'success', 'warning', 'error'): add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) self.assertRaises(MessageFailure, self.client.post, add_url, data, follow=True) @override_settings( INSTALLED_APPS=filter( lambda app:app!='django.contrib.messages', settings.INSTALLED_APPS), MIDDLEWARE_CLASSES=filter( lambda m:'MessageMiddleware' not in m, settings.MIDDLEWARE_CLASSES), TEMPLATE_CONTEXT_PROCESSORS=filter( lambda p:'context_processors.messages' not in p, settings.TEMPLATE_CONTEXT_PROCESSORS), MESSAGE_LEVEL=constants.DEBUG ) def test_middleware_disabled_fail_silently(self): """ Tests that, when the middleware is disabled, an exception is not raised if 'fail_silently' = True """ data = { 'messages': ['Test message %d' % x for x in range(5)], 'fail_silently': True, } show_url = reverse('django.contrib.messages.tests.urls.show') for level in ('debug', 'info', 'success', 'warning', 'error'): add_url = reverse('django.contrib.messages.tests.urls.add', args=(level,)) response = self.client.post(add_url, data, follow=True) self.assertRedirects(response, show_url) self.assertFalse('messages' in response.context) def stored_messages_count(self, storage, response): """ Returns the number of messages being stored after a ``storage.update()`` call. """ raise NotImplementedError('This method must be set by a subclass.') def test_get(self): raise NotImplementedError('This method must be set by a subclass.') def get_existing_storage(self): return self.get_storage([Message(constants.INFO, 'Test message 1'), Message(constants.INFO, 'Test message 2', extra_tags='tag')]) def test_existing_read(self): """ Tests that reading the existing storage doesn't cause the data to be lost. """ storage = self.get_existing_storage() self.assertFalse(storage.used) # After iterating the storage engine directly, the used flag is set. data = list(storage) self.assertTrue(storage.used) # The data does not disappear because it has been iterated. self.assertEqual(data, list(storage)) def test_existing_add(self): storage = self.get_existing_storage() self.assertFalse(storage.added_new) storage.add(constants.INFO, 'Test message 3') self.assertTrue(storage.added_new) def test_default_level(self): # get_level works even with no storage on the request. request = self.get_request() self.assertEqual(get_level(request), constants.INFO) # get_level returns the default level if it hasn't been set. storage = self.get_storage() request._messages = storage self.assertEqual(get_level(request), constants.INFO) # Only messages of sufficient level get recorded. add_level_messages(storage) self.assertEqual(len(storage), 5) def test_low_level(self): request = self.get_request() storage = self.storage_class(request) request._messages = storage self.assertTrue(set_level(request, 5)) self.assertEqual(get_level(request), 5) add_level_messages(storage) self.assertEqual(len(storage), 6) def test_high_level(self): request = self.get_request() storage = self.storage_class(request) request._messages = storage self.assertTrue(set_level(request, 30)) self.assertEqual(get_level(request), 30) add_level_messages(storage) self.assertEqual(len(storage), 2) @override_settings(MESSAGE_LEVEL=29) def test_settings_level(self): request = self.get_request() storage = self.storage_class(request) self.assertEqual(get_level(request), 29) add_level_messages(storage) self.assertEqual(len(storage), 3) def test_tags(self): storage = self.get_storage() storage.level = 0 add_level_messages(storage) tags = [msg.tags for msg in storage] self.assertEqual(tags, ['info', '', 'extra-tag debug', 'warning', 'error', 'success']) @override_settings_tags(MESSAGE_TAGS={ constants.INFO: 'info', constants.DEBUG: '', constants.WARNING: '', constants.ERROR: 'bad', 29: 'custom', } ) def test_custom_tags(self): storage = self.get_storage() storage.level = 0 add_level_messages(storage) tags = [msg.tags for msg in storage] self.assertEqual(tags, ['info', 'custom', 'extra-tag', '', 'bad', 'success'])
apache-2.0
[ 504, 1639, 492, 1455, 199, 504, 1639, 14, 2190, 492, 2202, 12, 2288, 63, 1751, 199, 504, 1639, 14, 2828, 14, 3431, 492, 5262, 12, 3778, 12, 664, 63, 1896, 12, 663, 63, 1896, 199, 504, 1639, 14, 2828, 14, 3431, 14, 1246, 492, 6430, 6782, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 492, 849, 63, 3494, 12, 1300, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 6430, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 3917, 421, 199, 318, 3372, 5524, 2817, 1831, 21268, 8, 1532, 304, 272, 372, 3372, 3917, 8, 267, 283, 1176, 14, 2828, 14, 1178, 7, 440, 315, 2202, 14, 15942, 63, 14219, 12, 267, 298, 1176, 14, 2828, 14, 1178, 5712, 1133, 4903, 25232, 1532, 9, 421, 199, 318, 1050, 63, 1896, 63, 3431, 8, 3494, 304, 272, 408, 272, 15747, 1227, 3788, 687, 3365, 11106, 334, 15768, 282, 3537, 1373, 9, 370, 282, 4887, 272, 1256, 14, 272, 408, 272, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 33, 7809, 2256, 1245, 358, 272, 4887, 14, 525, 8, 1398, 12, 283, 7700, 3537, 2166, 358, 272, 4887, 14, 525, 8, 5559, 14, 5287, 12, 283, 33, 10201, 1245, 297, 2402, 63, 2969, 534, 2911, 13, 1450, 358, 272, 4887, 14, 525, 8, 5559, 14, 9171, 12, 283, 33, 5721, 358, 272, 4887, 14, 525, 8, 5559, 14, 3170, 12, 283, 2493, 1125, 358, 272, 4887, 14, 525, 8, 5559, 14, 12779, 12, 283, 2765, 1990, 282, 3229, 1220, 72, 2659, 421, 199, 533, 4278, 63, 1751, 63, 2969, 8, 4415, 63, 1751, 304, 1362, 347, 4756, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 4296, 342, 267, 327, 6124, 10429, 63, 17626, 365, 282, 4413, 3247, 315, 314, 267, 327, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 859, 12, 880, 2410, 13729, 267, 327, 2202, 14, 8272, 63, 17626, 12, 781, 1929, 370, 1678, 626, 4413, 4634, 14, 267, 291, 14, 1753, 63, 1896, 63, 2969, 275, 1300, 14, 11817, 63, 17626, 267, 1300, 14, 11817, 63, 17626, 275, 3778, 14, 362, 63, 1896, 63, 2969, 342, 1362, 347, 3507, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 5993, 342, 267, 1300, 14, 11817, 63, 17626, 275, 291, 14, 1753, 63, 1896, 63, 2969, 421, 199, 533, 3523, 2925, 8, 785, 304, 272, 4887, 63, 533, 275, 849, 63, 3494, 272, 8187, 275, 283, 1176, 14, 2828, 14, 3431, 14, 2219, 14, 3603, 7, 272, 11106, 275, 469, 267, 283, 1757, 356, 5262, 14, 5287, 12, 267, 283, 815, 356, 5262, 14, 4531, 12, 267, 283, 3742, 356, 5262, 14, 12779, 12, 267, 283, 3764, 356, 5262, 14, 9171, 12, 267, 283, 705, 356, 5262, 14, 3170, 12, 272, 789, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 275, 4278, 63, 1751, 63, 2969, 8, 288, 24877, 63, 14455, 257, 275, 11969, 288, 24877, 63, 9059, 63, 10494, 4149, 275, 2288, 63, 1751, 14, 7433, 63, 9059, 63, 10494, 4149, 12, 288, 603, 1608, 2962, 63, 17626, 259, 275, 3260, 288, 603, 1608, 2962, 63, 17467, 275, 1543, 83, 4111, 83, 7, 450, 334, 277, 14, 3494, 63, 533, 855, 578, 3108, 1460, 291, 14, 3494, 63, 533, 855, 354, 10139, 288, 428, 9577, 63, 19637, 5357, 540, 275, 283, 1176, 14, 2828, 14, 11676, 14, 12844, 14, 6243, 7299, 297, 267, 776, 267, 291, 14, 1751, 63, 4415, 14, 4296, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 14, 5993, 342, 339, 347, 664, 63, 1069, 8, 277, 304, 267, 372, 1455, 14, 10441, 342, 339, 347, 664, 63, 1310, 8, 277, 304, 267, 372, 1455, 14, 16287, 342, 339, 347, 664, 63, 3494, 8, 277, 12, 666, 29, 403, 304, 267, 408, 267, 1803, 314, 4887, 4865, 12, 4260, 2399, 6511, 666, 370, 314, 1124, 576, 1040, 267, 1423, 14, 398, 961, 1083, 23674, 314, 4887, 24507, 362, 1040, 1083, 687, 10232, 2797, 880, 267, 626, 1163, 4184, 402, 314, 4887, 4865, 883, 506, 12470, 12717, 402, 267, 314, 1245, 27157, 9661, 14, 267, 408, 267, 4887, 275, 291, 14, 3494, 63, 533, 8, 277, 14, 362, 63, 1069, 1012, 267, 4887, 423, 4591, 63, 576, 275, 666, 503, 942, 267, 372, 4887, 339, 347, 511, 63, 525, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 291, 14, 3334, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 413, 358, 267, 291, 14, 1815, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 499, 297, 2402, 63, 2969, 534, 1450, 358, 267, 291, 14, 629, 8, 552, 8, 3494, 395, 499, 9, 339, 347, 511, 63, 525, 63, 6395, 63, 6893, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 10366, 63, 6395, 360, 6395, 1245, 1333, 267, 4887, 14, 873, 8, 1310, 9, 398, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 413, 9, 339, 347, 511, 63, 889, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 267, 4887, 14, 873, 8, 1310, 9, 267, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 378, 9, 339, 347, 511, 63, 525, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 413, 358, 267, 4887, 14, 525, 8, 5559 ]
[ 1639, 492, 1455, 199, 504, 1639, 14, 2190, 492, 2202, 12, 2288, 63, 1751, 199, 504, 1639, 14, 2828, 14, 3431, 492, 5262, 12, 3778, 12, 664, 63, 1896, 12, 663, 63, 1896, 199, 504, 1639, 14, 2828, 14, 3431, 14, 1246, 492, 6430, 6782, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 492, 849, 63, 3494, 12, 1300, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 6430, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 3917, 421, 199, 318, 3372, 5524, 2817, 1831, 21268, 8, 1532, 304, 272, 372, 3372, 3917, 8, 267, 283, 1176, 14, 2828, 14, 1178, 7, 440, 315, 2202, 14, 15942, 63, 14219, 12, 267, 298, 1176, 14, 2828, 14, 1178, 5712, 1133, 4903, 25232, 1532, 9, 421, 199, 318, 1050, 63, 1896, 63, 3431, 8, 3494, 304, 272, 408, 272, 15747, 1227, 3788, 687, 3365, 11106, 334, 15768, 282, 3537, 1373, 9, 370, 282, 4887, 272, 1256, 14, 272, 408, 272, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 33, 7809, 2256, 1245, 358, 272, 4887, 14, 525, 8, 1398, 12, 283, 7700, 3537, 2166, 358, 272, 4887, 14, 525, 8, 5559, 14, 5287, 12, 283, 33, 10201, 1245, 297, 2402, 63, 2969, 534, 2911, 13, 1450, 358, 272, 4887, 14, 525, 8, 5559, 14, 9171, 12, 283, 33, 5721, 358, 272, 4887, 14, 525, 8, 5559, 14, 3170, 12, 283, 2493, 1125, 358, 272, 4887, 14, 525, 8, 5559, 14, 12779, 12, 283, 2765, 1990, 282, 3229, 1220, 72, 2659, 421, 199, 533, 4278, 63, 1751, 63, 2969, 8, 4415, 63, 1751, 304, 1362, 347, 4756, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 4296, 342, 267, 327, 6124, 10429, 63, 17626, 365, 282, 4413, 3247, 315, 314, 267, 327, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 859, 12, 880, 2410, 13729, 267, 327, 2202, 14, 8272, 63, 17626, 12, 781, 1929, 370, 1678, 626, 4413, 4634, 14, 267, 291, 14, 1753, 63, 1896, 63, 2969, 275, 1300, 14, 11817, 63, 17626, 267, 1300, 14, 11817, 63, 17626, 275, 3778, 14, 362, 63, 1896, 63, 2969, 342, 1362, 347, 3507, 8, 277, 304, 267, 1613, 8, 4415, 63, 1751, 63, 2969, 12, 291, 680, 5993, 342, 267, 1300, 14, 11817, 63, 17626, 275, 291, 14, 1753, 63, 1896, 63, 2969, 421, 199, 533, 3523, 2925, 8, 785, 304, 272, 4887, 63, 533, 275, 849, 63, 3494, 272, 8187, 275, 283, 1176, 14, 2828, 14, 3431, 14, 2219, 14, 3603, 7, 272, 11106, 275, 469, 267, 283, 1757, 356, 5262, 14, 5287, 12, 267, 283, 815, 356, 5262, 14, 4531, 12, 267, 283, 3742, 356, 5262, 14, 12779, 12, 267, 283, 3764, 356, 5262, 14, 9171, 12, 267, 283, 705, 356, 5262, 14, 3170, 12, 272, 789, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 275, 4278, 63, 1751, 63, 2969, 8, 288, 24877, 63, 14455, 257, 275, 11969, 288, 24877, 63, 9059, 63, 10494, 4149, 275, 2288, 63, 1751, 14, 7433, 63, 9059, 63, 10494, 4149, 12, 288, 603, 1608, 2962, 63, 17626, 259, 275, 3260, 288, 603, 1608, 2962, 63, 17467, 275, 1543, 83, 4111, 83, 7, 450, 334, 277, 14, 3494, 63, 533, 855, 578, 3108, 1460, 291, 14, 3494, 63, 533, 855, 354, 10139, 288, 428, 9577, 63, 19637, 5357, 540, 275, 283, 1176, 14, 2828, 14, 11676, 14, 12844, 14, 6243, 7299, 297, 267, 776, 267, 291, 14, 1751, 63, 4415, 14, 4296, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 1751, 63, 4415, 14, 5993, 342, 339, 347, 664, 63, 1069, 8, 277, 304, 267, 372, 1455, 14, 10441, 342, 339, 347, 664, 63, 1310, 8, 277, 304, 267, 372, 1455, 14, 16287, 342, 339, 347, 664, 63, 3494, 8, 277, 12, 666, 29, 403, 304, 267, 408, 267, 1803, 314, 4887, 4865, 12, 4260, 2399, 6511, 666, 370, 314, 1124, 576, 1040, 267, 1423, 14, 398, 961, 1083, 23674, 314, 4887, 24507, 362, 1040, 1083, 687, 10232, 2797, 880, 267, 626, 1163, 4184, 402, 314, 4887, 4865, 883, 506, 12470, 12717, 402, 267, 314, 1245, 27157, 9661, 14, 267, 408, 267, 4887, 275, 291, 14, 3494, 63, 533, 8, 277, 14, 362, 63, 1069, 1012, 267, 4887, 423, 4591, 63, 576, 275, 666, 503, 942, 267, 372, 4887, 339, 347, 511, 63, 525, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 291, 14, 3334, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 413, 358, 267, 291, 14, 1815, 8, 3494, 14, 3270, 63, 1222, 9, 267, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 499, 297, 2402, 63, 2969, 534, 1450, 358, 267, 291, 14, 629, 8, 552, 8, 3494, 395, 499, 9, 339, 347, 511, 63, 525, 63, 6395, 63, 6893, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 10366, 63, 6395, 360, 6395, 1245, 1333, 267, 4887, 14, 873, 8, 1310, 9, 398, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 413, 9, 339, 347, 511, 63, 889, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 267, 4887, 14, 873, 8, 1310, 9, 267, 16915, 275, 291, 14, 16431, 63, 3431, 63, 835, 8, 3494, 12, 1177, 9, 267, 291, 14, 629, 8, 270, 6854, 12, 378, 9, 339, 347, 511, 63, 525, 63, 873, 8, 277, 304, 267, 4887, 275, 291, 14, 362, 63, 3494, 342, 267, 1177, 275, 291, 14, 362, 63, 1310, 342, 398, 4887, 14, 525, 8, 5559, 14, 4531, 12, 283, 774, 1245, 413, 358, 267, 4887, 14, 525, 8, 5559, 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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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 ]
theflofly/tensorflow
tensorflow/python/data/benchmarks/filter_benchmark.py
22
1636
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Benchmarks for `tf.data.Dataset.filter()`.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.data.benchmarks import benchmark_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.ops import array_ops # TODO(b/119837791): Add eager benchmarks. class FilterBenchmark(benchmark_base.DatasetBenchmarkBase): """Benchmarks for `tf.data.Dataset.filter()`.""" def _benchmark(self, predicate, name): dataset = ( dataset_ops.Dataset.from_tensors(True).repeat(None).filter(predicate)) self.run_and_report_benchmark(dataset, num_elements=100000, name=name) def benchmark_simple_function(self): self._benchmark(array_ops.identity, "simple_function") def benchmark_return_component_optimization(self): self._benchmark(lambda x: x, "return_component") if __name__ == "__main__": benchmark_base.test.main()
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 18644, 83, 367, 658, 3249, 14, 576, 14, 9271, 14, 1541, 11995, 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, 504, 3228, 14, 1548, 14, 576, 14, 11861, 83, 492, 12338, 63, 1095, 199, 504, 3228, 14, 1548, 14, 576, 14, 1483, 492, 4789, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 421, 199, 3, 3254, 8, 66, 15, 7119, 2658, 1138, 3328, 304, 2654, 21719, 12338, 83, 14, 199, 533, 9388, 18644, 8, 11861, 63, 1095, 14, 9271, 18644, 1563, 304, 523, 408, 18644, 83, 367, 658, 3249, 14, 576, 14, 9271, 14, 1541, 11995, 1041, 819, 347, 485, 11861, 8, 277, 12, 11944, 12, 536, 304, 272, 4789, 275, 334, 267, 4789, 63, 1483, 14, 9271, 14, 504, 63, 10206, 8, 549, 680, 8755, 8, 403, 680, 1541, 8, 14463, 430, 272, 291, 14, 1065, 63, 460, 63, 3070, 63, 11861, 8, 5214, 12, 1967, 63, 5527, 29, 15274, 12, 536, 29, 354, 9, 819, 347, 12338, 63, 4129, 63, 1593, 8, 277, 304, 272, 291, 423, 11861, 8, 1144, 63, 1483, 14, 5582, 12, 298, 4129, 63, 1593, 531, 819, 347, 12338, 63, 1107, 63, 3173, 63, 31405, 8, 277, 304, 272, 291, 423, 11861, 8, 2734, 671, 26, 671, 12, 298, 1107, 63, 3173, 531, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 12338, 63, 1095, 14, 396, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 18644, 83, 367, 658, 3249, 14, 576, 14, 9271, 14, 1541, 11995, 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, 504, 3228, 14, 1548, 14, 576, 14, 11861, 83, 492, 12338, 63, 1095, 199, 504, 3228, 14, 1548, 14, 576, 14, 1483, 492, 4789, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 421, 199, 3, 3254, 8, 66, 15, 7119, 2658, 1138, 3328, 304, 2654, 21719, 12338, 83, 14, 199, 533, 9388, 18644, 8, 11861, 63, 1095, 14, 9271, 18644, 1563, 304, 523, 408, 18644, 83, 367, 658, 3249, 14, 576, 14, 9271, 14, 1541, 11995, 1041, 819, 347, 485, 11861, 8, 277, 12, 11944, 12, 536, 304, 272, 4789, 275, 334, 267, 4789, 63, 1483, 14, 9271, 14, 504, 63, 10206, 8, 549, 680, 8755, 8, 403, 680, 1541, 8, 14463, 430, 272, 291, 14, 1065, 63, 460, 63, 3070, 63, 11861, 8, 5214, 12, 1967, 63, 5527, 29, 15274, 12, 536, 29, 354, 9, 819, 347, 12338, 63, 4129, 63, 1593, 8, 277, 304, 272, 291, 423, 11861, 8, 1144, 63, 1483, 14, 5582, 12, 298, 4129, 63, 1593, 531, 819, 347, 12338, 63, 1107, 63, 3173, 63, 31405, 8, 277, 304, 272, 291, 423, 11861, 8, 2734, 671, 26, 671, 12, 298, 1107, 63, 3173, 531, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 12338, 63, 1095, 14, 396, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0 ]
Kazade/NeHe-Website
django/contrib/auth/handlers/modpython.py
436
1899
from mod_python import apache import os def authenhandler(req, **kwargs): """ Authentication handler that checks against Django's auth database. """ # mod_python fakes the environ, and thus doesn't process SetEnv. This fixes # that so that the following import works os.environ.update(req.subprocess_env) # apache 2.2 requires a call to req.get_basic_auth_pw() before # req.user and friends are available. req.get_basic_auth_pw() # check for PythonOptions _str_to_bool = lambda s: s.lower() in ('1', 'true', 'on', 'yes') options = req.get_options() permission_name = options.get('DjangoPermissionName', None) staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', "on")) superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off")) settings_module = options.get('DJANGO_SETTINGS_MODULE', None) if settings_module: os.environ['DJANGO_SETTINGS_MODULE'] = settings_module from django.contrib.auth.models import User from django import db db.reset_queries() # check that the username is valid kwargs = {'username': req.user, 'is_active': True} if staff_only: kwargs['is_staff'] = True if superuser_only: kwargs['is_superuser'] = True try: try: user = User.objects.get(**kwargs) except User.DoesNotExist: return apache.HTTP_UNAUTHORIZED # check the password and any permission given if user.check_password(req.get_basic_auth_pw()): if permission_name: if user.has_perm(permission_name): return apache.OK else: return apache.HTTP_UNAUTHORIZED else: return apache.OK else: return apache.HTTP_UNAUTHORIZED finally: db.connection.close()
bsd-3-clause
[ 504, 3413, 63, 1548, 492, 17098, 199, 646, 747, 199, 199, 318, 1790, 287, 2232, 8, 2103, 12, 1011, 958, 304, 272, 408, 272, 15995, 3016, 626, 5920, 6169, 5634, 1159, 1790, 3050, 14, 272, 408, 339, 327, 3413, 63, 1548, 14063, 314, 6160, 12, 436, 12850, 3181, 1133, 2112, 2494, 7744, 14, 221, 961, 25079, 272, 327, 626, 880, 626, 314, 2569, 492, 5419, 272, 747, 14, 2314, 14, 873, 8, 2103, 14, 5781, 63, 1813, 9, 339, 327, 17098, 499, 14, 18, 5074, 282, 1240, 370, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 2544, 5591, 327, 2648, 14, 751, 436, 26157, 787, 2808, 14, 272, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 339, 327, 1104, 367, 2018, 4558, 272, 485, 495, 63, 475, 63, 2245, 275, 2400, 308, 26, 308, 14, 2325, 342, 315, 661, 17, 297, 283, 2052, 297, 283, 265, 297, 283, 5066, 358, 339, 1511, 275, 2648, 14, 362, 63, 1419, 342, 272, 4983, 63, 354, 275, 1511, 14, 362, 360, 9323, 7980, 985, 297, 488, 9, 272, 12622, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 18963, 3694, 297, 298, 265, 2237, 272, 32590, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 11823, 751, 3694, 297, 298, 1997, 2237, 272, 2202, 63, 578, 275, 1511, 14, 362, 360, 22848, 63, 13931, 63, 10001, 297, 488, 9, 272, 340, 2202, 63, 578, 26, 267, 747, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 2202, 63, 578, 339, 687, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 272, 687, 1639, 492, 1592, 272, 1592, 14, 3958, 63, 10590, 342, 339, 327, 1104, 626, 314, 3434, 365, 1686, 272, 2074, 275, 791, 2473, 356, 2648, 14, 751, 12, 283, 374, 63, 2682, 356, 715, 93, 272, 340, 12622, 63, 2118, 26, 267, 2074, 459, 374, 63, 7018, 418, 275, 715, 272, 340, 32590, 63, 2118, 26, 267, 2074, 459, 374, 63, 11434, 418, 275, 715, 272, 862, 26, 267, 862, 26, 288, 922, 275, 2876, 14, 1462, 14, 362, 3682, 958, 9, 267, 871, 2876, 14, 7400, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 13857, 327, 1104, 314, 2505, 436, 1263, 4983, 1627, 267, 340, 922, 14, 1074, 63, 2060, 8, 2103, 14, 362, 63, 4316, 63, 1178, 63, 8796, 5109, 288, 340, 4983, 63, 354, 26, 355, 340, 922, 14, 1989, 63, 8220, 8, 5693, 63, 354, 304, 490, 372, 17098, 14, 3593, 355, 587, 26, 490, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 288, 587, 26, 355, 372, 17098, 14, 3593, 267, 587, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 272, 3753, 26, 267, 1592, 14, 2105, 14, 1600, 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 ]
[ 3413, 63, 1548, 492, 17098, 199, 646, 747, 199, 199, 318, 1790, 287, 2232, 8, 2103, 12, 1011, 958, 304, 272, 408, 272, 15995, 3016, 626, 5920, 6169, 5634, 1159, 1790, 3050, 14, 272, 408, 339, 327, 3413, 63, 1548, 14063, 314, 6160, 12, 436, 12850, 3181, 1133, 2112, 2494, 7744, 14, 221, 961, 25079, 272, 327, 626, 880, 626, 314, 2569, 492, 5419, 272, 747, 14, 2314, 14, 873, 8, 2103, 14, 5781, 63, 1813, 9, 339, 327, 17098, 499, 14, 18, 5074, 282, 1240, 370, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 2544, 5591, 327, 2648, 14, 751, 436, 26157, 787, 2808, 14, 272, 2648, 14, 362, 63, 4316, 63, 1178, 63, 8796, 342, 339, 327, 1104, 367, 2018, 4558, 272, 485, 495, 63, 475, 63, 2245, 275, 2400, 308, 26, 308, 14, 2325, 342, 315, 661, 17, 297, 283, 2052, 297, 283, 265, 297, 283, 5066, 358, 339, 1511, 275, 2648, 14, 362, 63, 1419, 342, 272, 4983, 63, 354, 275, 1511, 14, 362, 360, 9323, 7980, 985, 297, 488, 9, 272, 12622, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 18963, 3694, 297, 298, 265, 2237, 272, 32590, 63, 2118, 275, 485, 495, 63, 475, 63, 2245, 8, 1419, 14, 362, 360, 9323, 13902, 11823, 751, 3694, 297, 298, 1997, 2237, 272, 2202, 63, 578, 275, 1511, 14, 362, 360, 22848, 63, 13931, 63, 10001, 297, 488, 9, 272, 340, 2202, 63, 578, 26, 267, 747, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 2202, 63, 578, 339, 687, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 272, 687, 1639, 492, 1592, 272, 1592, 14, 3958, 63, 10590, 342, 339, 327, 1104, 626, 314, 3434, 365, 1686, 272, 2074, 275, 791, 2473, 356, 2648, 14, 751, 12, 283, 374, 63, 2682, 356, 715, 93, 272, 340, 12622, 63, 2118, 26, 267, 2074, 459, 374, 63, 7018, 418, 275, 715, 272, 340, 32590, 63, 2118, 26, 267, 2074, 459, 374, 63, 11434, 418, 275, 715, 272, 862, 26, 267, 862, 26, 288, 922, 275, 2876, 14, 1462, 14, 362, 3682, 958, 9, 267, 871, 2876, 14, 7400, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 13857, 327, 1104, 314, 2505, 436, 1263, 4983, 1627, 267, 340, 922, 14, 1074, 63, 2060, 8, 2103, 14, 362, 63, 4316, 63, 1178, 63, 8796, 5109, 288, 340, 4983, 63, 354, 26, 355, 340, 922, 14, 1989, 63, 8220, 8, 5693, 63, 354, 304, 490, 372, 17098, 14, 3593, 355, 587, 26, 490, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 288, 587, 26, 355, 372, 17098, 14, 3593, 267, 587, 26, 288, 372, 17098, 14, 2856, 63, 1734, 25303, 1149, 272, 3753, 26, 267, 1592, 14, 2105, 14, 1600, 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,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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 ]
peircej/moviepy
moviepy/video/fx/headblur.py
16
1768
import numpy as np #------- CHECKING DEPENDENCIES ----------------------------------------- try: import cv2 headblur_possible = True except: headblur_possible = False #----------------------------------------------------------------------- def headblur(clip,fx,fy,r_zone,r_blur=None): """ Returns a filter that will blurr a moving part (a head ?) of the frames. The position of the blur at time t is defined by (fx(t), fy(t)), the radius of the blurring by ``r_zone`` and the intensity of the blurring by ``r_blur``. Requires OpenCV for the circling and the blurring. Automatically deals with the case where part of the image goes offscreen. """ if r_blur is None: r_blur = 2*r_zone/3 def fl(gf,t): im = gf(t) h,w,d = im.shape x,y = int(fx(t)),int(fy(t)) x1,x2 = max(0,x-r_zone),min(x+r_zone,w) y1,y2 = max(0,y-r_zone),min(y+r_zone,h) region_size = y2-y1,x2-x1 mask = np.zeros(region_size).astype('uint8') cv2.circle(mask, (r_zone,r_zone), r_zone, 255, -1, lineType=cv2.CV_AA) mask = np.dstack(3*[(1.0/255)*mask]) orig = im[y1:y2, x1:x2] blurred = cv2.blur(orig,(r_blur, r_blur)) im[y1:y2, x1:x2] = mask*blurred + (1-mask)*orig return im return clip.fl(fl) #------- OVERWRITE IF REQUIREMENTS NOT MET ----------------------------- if not headblur_possible: doc = headblur.__doc__ def headblur(clip,fx,fy,r_zone,r_blur=None): raise IOError("fx painting needs scikit-image or scipy") headblur.__doc__ = doc #-----------------------------------------------------------------------
mit
[ 646, 2680, 465, 980, 421, 199, 3, 12797, 17654, 1206, 30850, 3902, 9415, 2563, 11016, 9960, 221, 199, 893, 26, 272, 492, 6277, 18, 272, 4854, 3345, 300, 63, 13893, 275, 715, 199, 2590, 26, 272, 4854, 3345, 300, 63, 13893, 275, 756, 199, 7656, 12797, 421, 199, 318, 4854, 3345, 300, 8, 7548, 12, 12220, 12, 1399, 12, 82, 63, 2619, 12, 82, 63, 3345, 300, 29, 403, 304, 272, 408, 272, 1803, 282, 2457, 626, 911, 6826, 300, 82, 282, 12876, 1777, 334, 65, 4854, 5805, 9, 402, 272, 314, 11223, 14, 710, 3421, 402, 314, 6826, 300, 737, 900, 307, 365, 272, 3247, 701, 334, 12220, 8, 84, 395, 289, 89, 8, 84, 1826, 314, 9362, 402, 314, 6826, 300, 5985, 272, 701, 1124, 82, 63, 2619, 1040, 436, 314, 28873, 402, 314, 6826, 300, 5985, 701, 1124, 82, 63, 3345, 300, 4345, 272, 15127, 3232, 12847, 367, 314, 286, 723, 429, 316, 436, 314, 6826, 300, 5985, 14, 272, 9195, 17174, 477, 2551, 543, 314, 1930, 2382, 1777, 402, 314, 1834, 13538, 272, 2331, 5410, 14, 272, 408, 2286, 340, 519, 63, 3345, 300, 365, 488, 26, 519, 63, 3345, 300, 275, 499, 10, 82, 63, 2619, 15, 19, 2286, 347, 2717, 8, 7102, 12, 84, 304, 2728, 3416, 275, 15719, 8, 84, 9, 267, 394, 12, 87, 12, 68, 275, 3416, 14, 1392, 267, 671, 12, 89, 275, 1109, 8, 12220, 8, 84, 1826, 442, 8, 1399, 8, 84, 430, 267, 671, 17, 12, 88, 18, 275, 1390, 8, 16, 12, 88, 13, 82, 63, 2619, 395, 827, 8, 88, 11, 82, 63, 2619, 12, 87, 9, 267, 612, 17, 12, 89, 18, 275, 1390, 8, 16, 12, 89, 13, 82, 63, 2619, 395, 827, 8, 89, 11, 82, 63, 2619, 12, 72, 9, 267, 4897, 63, 890, 275, 612, 18, 13, 89, 17, 12, 88, 18, 13, 88, 17, 2728, 3656, 275, 980, 14, 4250, 8, 4551, 63, 890, 680, 6041, 360, 1635, 24, 358, 267, 6277, 18, 14, 11001, 8, 2629, 12, 334, 82, 63, 2619, 12, 82, 63, 2619, 395, 519, 63, 2619, 12, 5450, 12, 446, 17, 12, 673, 1004, 804, 29, 5107, 18, 14, 12847, 63, 2276, 9, 1816, 267, 3656, 275, 980, 14, 68, 2340, 8, 19, 10, 7528, 17, 14, 16, 15, 2299, 3342, 2629, 566, 2728, 2306, 275, 3416, 59, 89, 17, 26, 89, 18, 12, 671, 17, 26, 88, 18, 61, 267, 6826, 300, 581, 275, 6277, 18, 14, 3345, 300, 8, 2981, 12803, 82, 63, 3345, 300, 12, 519, 63, 3345, 300, 430, 267, 3416, 59, 89, 17, 26, 89, 18, 12, 671, 17, 26, 88, 18, 61, 275, 3656, 10, 3345, 300, 581, 435, 334, 17, 13, 2629, 3342, 2981, 267, 372, 3416, 2286, 372, 11353, 14, 2327, 8, 2327, 9, 4388, 199, 3, 12797, 593, 2111, 10387, 8036, 17023, 21201, 20967, 2845, 19357, 10652, 8684, 199, 692, 440, 4854, 3345, 300, 63, 13893, 26, 272, 1382, 275, 4854, 3345, 300, 855, 1301, 363, 272, 347, 4854, 3345, 300, 8, 7548, 12, 12220, 12, 1399, 12, 82, 63, 2619, 12, 82, 63, 3345, 300, 29, 403, 304, 267, 746, 5925, 480, 12220, 32055, 316, 4839, 6276, 6065, 13, 1569, 503, 7026, 531, 2286, 4854, 3345, 300, 855, 1301, 363, 275, 1382, 199, 7656, 12797, 9948, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 465, 980, 421, 199, 3, 12797, 17654, 1206, 30850, 3902, 9415, 2563, 11016, 9960, 221, 199, 893, 26, 272, 492, 6277, 18, 272, 4854, 3345, 300, 63, 13893, 275, 715, 199, 2590, 26, 272, 4854, 3345, 300, 63, 13893, 275, 756, 199, 7656, 12797, 421, 199, 318, 4854, 3345, 300, 8, 7548, 12, 12220, 12, 1399, 12, 82, 63, 2619, 12, 82, 63, 3345, 300, 29, 403, 304, 272, 408, 272, 1803, 282, 2457, 626, 911, 6826, 300, 82, 282, 12876, 1777, 334, 65, 4854, 5805, 9, 402, 272, 314, 11223, 14, 710, 3421, 402, 314, 6826, 300, 737, 900, 307, 365, 272, 3247, 701, 334, 12220, 8, 84, 395, 289, 89, 8, 84, 1826, 314, 9362, 402, 314, 6826, 300, 5985, 272, 701, 1124, 82, 63, 2619, 1040, 436, 314, 28873, 402, 314, 6826, 300, 5985, 701, 1124, 82, 63, 3345, 300, 4345, 272, 15127, 3232, 12847, 367, 314, 286, 723, 429, 316, 436, 314, 6826, 300, 5985, 14, 272, 9195, 17174, 477, 2551, 543, 314, 1930, 2382, 1777, 402, 314, 1834, 13538, 272, 2331, 5410, 14, 272, 408, 2286, 340, 519, 63, 3345, 300, 365, 488, 26, 519, 63, 3345, 300, 275, 499, 10, 82, 63, 2619, 15, 19, 2286, 347, 2717, 8, 7102, 12, 84, 304, 2728, 3416, 275, 15719, 8, 84, 9, 267, 394, 12, 87, 12, 68, 275, 3416, 14, 1392, 267, 671, 12, 89, 275, 1109, 8, 12220, 8, 84, 1826, 442, 8, 1399, 8, 84, 430, 267, 671, 17, 12, 88, 18, 275, 1390, 8, 16, 12, 88, 13, 82, 63, 2619, 395, 827, 8, 88, 11, 82, 63, 2619, 12, 87, 9, 267, 612, 17, 12, 89, 18, 275, 1390, 8, 16, 12, 89, 13, 82, 63, 2619, 395, 827, 8, 89, 11, 82, 63, 2619, 12, 72, 9, 267, 4897, 63, 890, 275, 612, 18, 13, 89, 17, 12, 88, 18, 13, 88, 17, 2728, 3656, 275, 980, 14, 4250, 8, 4551, 63, 890, 680, 6041, 360, 1635, 24, 358, 267, 6277, 18, 14, 11001, 8, 2629, 12, 334, 82, 63, 2619, 12, 82, 63, 2619, 395, 519, 63, 2619, 12, 5450, 12, 446, 17, 12, 673, 1004, 804, 29, 5107, 18, 14, 12847, 63, 2276, 9, 1816, 267, 3656, 275, 980, 14, 68, 2340, 8, 19, 10, 7528, 17, 14, 16, 15, 2299, 3342, 2629, 566, 2728, 2306, 275, 3416, 59, 89, 17, 26, 89, 18, 12, 671, 17, 26, 88, 18, 61, 267, 6826, 300, 581, 275, 6277, 18, 14, 3345, 300, 8, 2981, 12803, 82, 63, 3345, 300, 12, 519, 63, 3345, 300, 430, 267, 3416, 59, 89, 17, 26, 89, 18, 12, 671, 17, 26, 88, 18, 61, 275, 3656, 10, 3345, 300, 581, 435, 334, 17, 13, 2629, 3342, 2981, 267, 372, 3416, 2286, 372, 11353, 14, 2327, 8, 2327, 9, 4388, 199, 3, 12797, 593, 2111, 10387, 8036, 17023, 21201, 20967, 2845, 19357, 10652, 8684, 199, 692, 440, 4854, 3345, 300, 63, 13893, 26, 272, 1382, 275, 4854, 3345, 300, 855, 1301, 363, 272, 347, 4854, 3345, 300, 8, 7548, 12, 12220, 12, 1399, 12, 82, 63, 2619, 12, 82, 63, 3345, 300, 29, 403, 304, 267, 746, 5925, 480, 12220, 32055, 316, 4839, 6276, 6065, 13, 1569, 503, 7026, 531, 2286, 4854, 3345, 300, 855, 1301, 363, 275, 1382, 199, 7656, 12797, 9948, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
quru/qis
src/imageserver/errors.py
1
2593
# # Quru Image Server # # Document: errors.py # Date started: 31 Mar 2011 # By: Matt Fozard # Purpose: Internal errors and exceptions # Requires: # Copyright: Quru Ltd (www.quru.com) # Licence: # # 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/ # # Last Changed: $Date$ $Rev$ by $Author$ # # Notable modifications: # Date By Details # ========= ==== ============================================================ # class ImageError(ValueError): """ An error resulting from an invalid or unsupported imaging operation. """ pass class AlreadyExistsError(ValueError): """ An error resulting from a duplicate value or an attempt to create an object that already exists. """ pass class DoesNotExistError(ValueError): """ An error resulting from an attempt to use an object that does not exist. """ pass class SecurityError(Exception): """ An error resulting from some unauthorised action. """ pass class StartupError(Exception): """ An error that should prevent server startup. """ pass class AuthenticationError(Exception): """ An error resulting from a failure to authenticate. """ pass class DBError(Exception): """ An error resulting from a database operation. Adds an optional extra 'sql' attribute. """ def __init__(self, message, sql=None): Exception.__init__(self, message) self.sql = sql if sql is not None else '' class DBDataError(DBError): """ An error resulting from incorrect database data. """ pass class ParameterError(ValueError): """ An error resulting from an invalid parameter value. """ pass class TimeoutError(RuntimeError): """ An error resulting from an operation timeout. """ pass class ServerTooBusyError(RuntimeError): """ Raised when the server is too busy to service a request. """ pass
agpl-3.0
[ 3, 199, 3, 1413, 300, 85, 6047, 7146, 199, 3, 199, 3, 7543, 26, 420, 2552, 14, 647, 199, 3, 6148, 8239, 26, 221, 7105, 16794, 7760, 199, 3, 4885, 26, 3322, 31653, 481, 26051, 1005, 199, 3, 23177, 4070, 26, 755, 12624, 2552, 436, 4967, 199, 3, 15127, 26, 199, 3, 1898, 26, 258, 1413, 300, 85, 12126, 334, 1544, 14, 81, 300, 85, 14, 957, 9, 199, 3, 491, 530, 4894, 26, 199, 3, 199, 3, 257, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 257, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 257, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 257, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 199, 3, 199, 3, 15237, 25649, 26, 221, 2672, 2506, 4, 2672, 26176, 4, 701, 2672, 5949, 4, 199, 3, 199, 3, 2832, 461, 23070, 26, 199, 3, 6148, 755, 4885, 259, 15621, 199, 3, 275, 763, 221, 275, 5918, 221, 19691, 21326, 199, 3, 421, 199, 533, 6047, 547, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 3866, 503, 16313, 18884, 1540, 3439, 14, 272, 408, 272, 986, 421, 199, 533, 21086, 23839, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 282, 9250, 574, 503, 376, 7427, 370, 1218, 376, 272, 909, 626, 2575, 3495, 14, 272, 408, 272, 986, 421, 199, 533, 12078, 1763, 6439, 547, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 7427, 370, 675, 376, 909, 626, 1630, 440, 2187, 14, 272, 408, 272, 986, 421, 199, 533, 13863, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 9183, 687, 2005, 625, 2502, 9096, 1595, 14, 272, 408, 272, 986, 421, 199, 533, 7707, 384, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 626, 1077, 7981, 1654, 14210, 14, 272, 408, 272, 986, 421, 199, 533, 15995, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 9183, 687, 282, 5988, 370, 12895, 14, 272, 408, 272, 986, 421, 199, 533, 6249, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 9183, 687, 282, 3050, 3439, 14, 272, 15747, 376, 2716, 2402, 283, 3009, 7, 2225, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 3875, 29, 403, 304, 267, 2186, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 3009, 275, 3875, 340, 3875, 365, 440, 488, 587, 2125, 421, 199, 533, 6249, 1451, 547, 8, 2846, 547, 304, 272, 408, 272, 1626, 1125, 9183, 687, 8927, 3050, 666, 14, 272, 408, 272, 986, 421, 199, 533, 12009, 547, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 3866, 2725, 574, 14, 272, 408, 272, 986, 421, 199, 533, 31886, 8, 13281, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 3439, 2653, 14, 272, 408, 272, 986, 421, 199, 533, 7146, 13749, 28759, 547, 8, 13281, 304, 272, 408, 272, 24997, 1380, 314, 1654, 365, 4634, 10414, 89, 370, 2435, 282, 1056, 14, 272, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1413, 300, 85, 6047, 7146, 199, 3, 199, 3, 7543, 26, 420, 2552, 14, 647, 199, 3, 6148, 8239, 26, 221, 7105, 16794, 7760, 199, 3, 4885, 26, 3322, 31653, 481, 26051, 1005, 199, 3, 23177, 4070, 26, 755, 12624, 2552, 436, 4967, 199, 3, 15127, 26, 199, 3, 1898, 26, 258, 1413, 300, 85, 12126, 334, 1544, 14, 81, 300, 85, 14, 957, 9, 199, 3, 491, 530, 4894, 26, 199, 3, 199, 3, 257, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 257, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 199, 3, 257, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 257, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 257, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 199, 3, 199, 3, 15237, 25649, 26, 221, 2672, 2506, 4, 2672, 26176, 4, 701, 2672, 5949, 4, 199, 3, 199, 3, 2832, 461, 23070, 26, 199, 3, 6148, 755, 4885, 259, 15621, 199, 3, 275, 763, 221, 275, 5918, 221, 19691, 21326, 199, 3, 421, 199, 533, 6047, 547, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 3866, 503, 16313, 18884, 1540, 3439, 14, 272, 408, 272, 986, 421, 199, 533, 21086, 23839, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 282, 9250, 574, 503, 376, 7427, 370, 1218, 376, 272, 909, 626, 2575, 3495, 14, 272, 408, 272, 986, 421, 199, 533, 12078, 1763, 6439, 547, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 7427, 370, 675, 376, 909, 626, 1630, 440, 2187, 14, 272, 408, 272, 986, 421, 199, 533, 13863, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 9183, 687, 2005, 625, 2502, 9096, 1595, 14, 272, 408, 272, 986, 421, 199, 533, 7707, 384, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 626, 1077, 7981, 1654, 14210, 14, 272, 408, 272, 986, 421, 199, 533, 15995, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 9183, 687, 282, 5988, 370, 12895, 14, 272, 408, 272, 986, 421, 199, 533, 6249, 547, 8, 1726, 304, 272, 408, 272, 1626, 1125, 9183, 687, 282, 3050, 3439, 14, 272, 15747, 376, 2716, 2402, 283, 3009, 7, 2225, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 3875, 29, 403, 304, 267, 2186, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 3009, 275, 3875, 340, 3875, 365, 440, 488, 587, 2125, 421, 199, 533, 6249, 1451, 547, 8, 2846, 547, 304, 272, 408, 272, 1626, 1125, 9183, 687, 8927, 3050, 666, 14, 272, 408, 272, 986, 421, 199, 533, 12009, 547, 8, 3393, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 3866, 2725, 574, 14, 272, 408, 272, 986, 421, 199, 533, 31886, 8, 13281, 304, 272, 408, 272, 1626, 1125, 9183, 687, 376, 3439, 2653, 14, 272, 408, 272, 986, 421, 199, 533, 7146, 13749, 28759, 547, 8, 13281, 304, 272, 408, 272, 24997, 1380, 314, 1654, 365, 4634, 10414, 89, 370, 2435, 282, 1056, 14, 272, 408, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
GladeRom/android_external_chromium_org
chrome/browser/resources/chromeos/chromevox/tools/generate_test_messages.py
62
1237
#!/usr/bin/env python # Copyright 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. '''Generates test_messages.js from an extension message json file.''' import optparse import sys def Die(message): '''Prints an error message and exit the program.''' print >>sys.stderr, message sys.exit(1) # Tempalte for the test_messages.js. _JS_TEMPLATE = '''// GENERATED FROM %(in_file)s goog.provide('cvox.TestMessages'); cvox.TestMessages = %(json)s; ''' def main(): parser = optparse.OptionParser(description=__doc__) parser.add_option('-o', '--output_file', action='store', metavar='SPEC', help=('Where to output the generated deps file.')) options, args = parser.parse_args() if options.output_file is None: Die('Output file not specified') if len(args) != 1: Die('Exactly one input file must be specified') in_file_name = args[0]; with open(in_file_name) as in_file: json = in_file.read().strip() with open(options.output_file, 'w') as out_file: out_file.write(_JS_TEMPLATE % {'in_file': in_file_name, 'json': json}) if __name__ == '__main__': main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 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, 199, 199, 2344, 20551, 511, 63, 3431, 14, 3596, 687, 376, 3329, 1245, 2022, 570, 10595, 199, 199, 646, 8691, 199, 646, 984, 199, 199, 318, 577, 1873, 8, 1188, 304, 523, 1449, 26113, 376, 1125, 1245, 436, 4458, 314, 2240, 10595, 523, 870, 4331, 1274, 14, 3083, 12, 1245, 523, 984, 14, 2224, 8, 17, 9, 421, 199, 3, 12540, 279, 266, 367, 314, 511, 63, 3431, 14, 3596, 14, 199, 63, 11378, 63, 7433, 275, 1449, 501, 29087, 6989, 4442, 2818, 262, 63, 493, 9, 83, 199, 199, 28069, 14, 20824, 360, 67, 2392, 88, 14, 774, 14508, 11339, 199, 199, 67, 2392, 88, 14, 774, 14508, 275, 2818, 1001, 9, 83, 27, 199, 2344, 421, 199, 318, 2446, 837, 523, 1798, 275, 8691, 14, 14553, 8, 1802, 18971, 1301, 3368, 523, 1798, 14, 525, 63, 1422, 3654, 79, 297, 2850, 1199, 63, 493, 297, 1595, 534, 1617, 297, 490, 8214, 534, 24147, 297, 490, 1720, 7782, 26493, 370, 1072, 314, 4046, 10140, 570, 12459, 523, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 523, 340, 1511, 14, 1199, 63, 493, 365, 488, 26, 272, 577, 1873, 360, 2959, 570, 440, 2013, 358, 523, 340, 822, 8, 589, 9, 1137, 413, 26, 272, 577, 1873, 360, 29751, 590, 1373, 1324, 570, 1471, 506, 2013, 358, 523, 315, 63, 493, 63, 354, 275, 1249, 59, 16, 11566, 523, 543, 1551, 8, 262, 63, 493, 63, 354, 9, 465, 315, 63, 493, 26, 272, 2022, 275, 315, 63, 493, 14, 739, 1252, 1913, 342, 523, 543, 1551, 8, 1419, 14, 1199, 63, 493, 12, 283, 87, 358, 465, 734, 63, 493, 26, 272, 734, 63, 493, 14, 952, 1547, 11378, 63, 7433, 450, 791, 262, 63, 493, 356, 315, 63, 493, 63, 354, 12, 283, 1001, 356, 2022, 1552, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2446, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 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, 199, 199, 2344, 20551, 511, 63, 3431, 14, 3596, 687, 376, 3329, 1245, 2022, 570, 10595, 199, 199, 646, 8691, 199, 646, 984, 199, 199, 318, 577, 1873, 8, 1188, 304, 523, 1449, 26113, 376, 1125, 1245, 436, 4458, 314, 2240, 10595, 523, 870, 4331, 1274, 14, 3083, 12, 1245, 523, 984, 14, 2224, 8, 17, 9, 421, 199, 3, 12540, 279, 266, 367, 314, 511, 63, 3431, 14, 3596, 14, 199, 63, 11378, 63, 7433, 275, 1449, 501, 29087, 6989, 4442, 2818, 262, 63, 493, 9, 83, 199, 199, 28069, 14, 20824, 360, 67, 2392, 88, 14, 774, 14508, 11339, 199, 199, 67, 2392, 88, 14, 774, 14508, 275, 2818, 1001, 9, 83, 27, 199, 2344, 421, 199, 318, 2446, 837, 523, 1798, 275, 8691, 14, 14553, 8, 1802, 18971, 1301, 3368, 523, 1798, 14, 525, 63, 1422, 3654, 79, 297, 2850, 1199, 63, 493, 297, 1595, 534, 1617, 297, 490, 8214, 534, 24147, 297, 490, 1720, 7782, 26493, 370, 1072, 314, 4046, 10140, 570, 12459, 523, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 523, 340, 1511, 14, 1199, 63, 493, 365, 488, 26, 272, 577, 1873, 360, 2959, 570, 440, 2013, 358, 523, 340, 822, 8, 589, 9, 1137, 413, 26, 272, 577, 1873, 360, 29751, 590, 1373, 1324, 570, 1471, 506, 2013, 358, 523, 315, 63, 493, 63, 354, 275, 1249, 59, 16, 11566, 523, 543, 1551, 8, 262, 63, 493, 63, 354, 9, 465, 315, 63, 493, 26, 272, 2022, 275, 315, 63, 493, 14, 739, 1252, 1913, 342, 523, 543, 1551, 8, 1419, 14, 1199, 63, 493, 12, 283, 87, 358, 465, 734, 63, 493, 26, 272, 734, 63, 493, 14, 952, 1547, 11378, 63, 7433, 450, 791, 262, 63, 493, 356, 315, 63, 493, 63, 354, 12, 283, 1001, 356, 2022, 1552, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2446, 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,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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 ]
Theer108/invenio
invenio/modules/upgrader/logging.py
20
2014
# -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2012, 2013, 2014 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. from __future__ import absolute_import import logging class InvenioUpgraderLogFormatter(logging.Formatter): """ Custom logging formatter allowing different log formats for different error levels. """ def __init__(self, fmt, **overwrites): self.fmt = fmt self.overwrites = overwrites self.prefix = '' self.plugin_id = '' logging.Formatter.__init__(self, fmt) def get_level_fmt(self, level): """ Get format for log level """ key = None if level == logging.DEBUG: key = 'debug' elif level == logging.INFO: key = 'info' elif level == logging.WARNING: key = 'warning' elif level == logging.ERROR: key = 'error' elif level == logging.CRITICAL: key = 'critical' return self.overwrites.get(key, self.fmt) def format(self, record): """ Format log record """ format_orig = self._fmt self._fmt = self.get_level_fmt(record.levelno) record.prefix = self.prefix record.plugin_id = self.plugin_id result = logging.Formatter.format(self, record) self._fmt = format_orig return result
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6029, 12, 6171, 12, 6927, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 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, 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, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 421, 199, 533, 12235, 1721, 17556, 2445, 7772, 8, 4806, 14, 7772, 304, 272, 408, 272, 8388, 2050, 9698, 17266, 3365, 943, 6752, 367, 3365, 272, 1125, 11106, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 7104, 12, 1011, 1883, 16334, 304, 267, 291, 14, 5045, 275, 7104, 267, 291, 14, 1883, 16334, 275, 1806, 16334, 267, 291, 14, 1861, 275, 2125, 267, 291, 14, 2718, 63, 344, 275, 2125, 267, 2050, 14, 7772, 855, 826, 721, 277, 12, 7104, 9, 339, 347, 664, 63, 1896, 63, 5045, 8, 277, 12, 2166, 304, 267, 408, 2372, 1475, 367, 943, 2166, 408, 267, 790, 275, 488, 267, 340, 2166, 508, 2050, 14, 5287, 26, 288, 790, 275, 283, 1757, 7, 267, 916, 2166, 508, 2050, 14, 4531, 26, 288, 790, 275, 283, 815, 7, 267, 916, 2166, 508, 2050, 14, 9171, 26, 288, 790, 275, 283, 3764, 7, 267, 916, 2166, 508, 2050, 14, 3170, 26, 288, 790, 275, 283, 705, 7, 267, 916, 2166, 508, 2050, 14, 21539, 26, 288, 790, 275, 283, 13138, 7, 267, 372, 291, 14, 1883, 16334, 14, 362, 8, 498, 12, 291, 14, 5045, 9, 339, 347, 1475, 8, 277, 12, 2777, 304, 267, 408, 9701, 943, 2777, 408, 267, 1475, 63, 2981, 275, 291, 423, 5045, 267, 291, 423, 5045, 275, 291, 14, 362, 63, 1896, 63, 5045, 8, 3059, 14, 1896, 889, 9, 267, 2777, 14, 1861, 275, 291, 14, 1861, 267, 2777, 14, 2718, 63, 344, 275, 291, 14, 2718, 63, 344, 267, 754, 275, 2050, 14, 7772, 14, 908, 8, 277, 12, 2777, 9, 267, 291, 423, 5045, 275, 1475, 63, 2981, 267, 372, 754, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6029, 12, 6171, 12, 6927, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 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, 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, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 421, 199, 533, 12235, 1721, 17556, 2445, 7772, 8, 4806, 14, 7772, 304, 272, 408, 272, 8388, 2050, 9698, 17266, 3365, 943, 6752, 367, 3365, 272, 1125, 11106, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 7104, 12, 1011, 1883, 16334, 304, 267, 291, 14, 5045, 275, 7104, 267, 291, 14, 1883, 16334, 275, 1806, 16334, 267, 291, 14, 1861, 275, 2125, 267, 291, 14, 2718, 63, 344, 275, 2125, 267, 2050, 14, 7772, 855, 826, 721, 277, 12, 7104, 9, 339, 347, 664, 63, 1896, 63, 5045, 8, 277, 12, 2166, 304, 267, 408, 2372, 1475, 367, 943, 2166, 408, 267, 790, 275, 488, 267, 340, 2166, 508, 2050, 14, 5287, 26, 288, 790, 275, 283, 1757, 7, 267, 916, 2166, 508, 2050, 14, 4531, 26, 288, 790, 275, 283, 815, 7, 267, 916, 2166, 508, 2050, 14, 9171, 26, 288, 790, 275, 283, 3764, 7, 267, 916, 2166, 508, 2050, 14, 3170, 26, 288, 790, 275, 283, 705, 7, 267, 916, 2166, 508, 2050, 14, 21539, 26, 288, 790, 275, 283, 13138, 7, 267, 372, 291, 14, 1883, 16334, 14, 362, 8, 498, 12, 291, 14, 5045, 9, 339, 347, 1475, 8, 277, 12, 2777, 304, 267, 408, 9701, 943, 2777, 408, 267, 1475, 63, 2981, 275, 291, 423, 5045, 267, 291, 423, 5045, 275, 291, 14, 362, 63, 1896, 63, 5045, 8, 3059, 14, 1896, 889, 9, 267, 2777, 14, 1861, 275, 291, 14, 1861, 267, 2777, 14, 2718, 63, 344, 275, 291, 14, 2718, 63, 344, 267, 754, 275, 2050, 14, 7772, 14, 908, 8, 277, 12, 2777, 9, 267, 291, 423, 5045, 275, 1475, 63, 2981, 267, 372, 754, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
lukas-bednar/python-rrmngmnt
rrmngmnt/ssh.py
1
10209
import os import time import socket import paramiko import contextlib import subprocess from rrmngmnt.executor import Executor AUTHORIZED_KEYS = os.path.join("%s", ".ssh/authorized_keys") KNOWN_HOSTS = os.path.join("%s", ".ssh/known_hosts") ID_RSA_PUB = os.path.join("%s", ".ssh/id_rsa.pub") ID_RSA_PRV = os.path.join("%s", ".ssh/id_rsa") CONNECTIVITY_TIMEOUT = 600 CONNECTIVITY_SAMPLE_TIME = 20 class RemoteExecutor(Executor): """ Any resource which provides SSH service. This class is meant to replace our current utilities.machine.LinuxMachine classs. This allows you to lower access to communicate with ssh. Like a live interaction, getting rid of True/False results, and mixing stdout with stderr. You can still use use 'run_cmd' method if you don't care. But I would recommed you to work like this: """ TCP_TIMEOUT = 10.0 class LoggerAdapter(Executor.LoggerAdapter): """ Makes sure that all logs which are done via this class, has appropriate prefix. [user@IP/password] """ def process(self, msg, kwargs): return ( "[%s@%s/%s] %s" % ( self.extra['self'].user.name, self.extra['self'].address, self.extra['self'].user.password, msg, ), kwargs, ) class Session(Executor.Session): """ Represents active ssh connection """ def __init__(self, executor, timeout=None, use_pkey=False): super(RemoteExecutor.Session, self).__init__(executor) if timeout is None: timeout = RemoteExecutor.TCP_TIMEOUT self._timeout = timeout self._ssh = paramiko.SSHClient() self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) if use_pkey: self.pkey = paramiko.RSAKey.from_private_key_file( ID_RSA_PRV % os.path.expanduser('~') ) self._executor.user.password = None else: self.pkey = None def __exit__(self, type_, value, tb): if type_ is socket.timeout: self._update_timeout_exception(value) try: self.close() except Exception as ex: if type_ is None: raise else: self._executor.logger.debug( "Can not close ssh session %s", ex, ) def open(self): self._ssh.get_host_keys().clear() try: self._ssh.connect( self._executor.address, username=self._executor.user.name, password=self._executor.user.password, timeout=self._timeout, pkey=self.pkey ) except (socket.gaierror, socket.herror) as ex: args = list(ex.args) message = "%s: %s" % (self._executor.address, args[1]) args[1] = message ex.strerror = message ex.args = tuple(args) raise except socket.timeout as ex: self._update_timeout_exception(ex) raise def close(self): self._ssh.close() def _update_timeout_exception(self, ex, timeout=None): if getattr(ex, '_updated', False): return if timeout is None: timeout = self._timeout message = "%s: timeout(%s)" % ( self._executor.address, timeout ) ex.args = (message,) ex._updated = True def command(self, cmd): return RemoteExecutor.Command(cmd, self) def run_cmd(self, cmd, input_=None, timeout=None): cmd = self.command(cmd) return cmd.run(input_, timeout) @contextlib.contextmanager def open_file(self, path, mode='r', bufsize=-1): with contextlib.closing(self._ssh.open_sftp()) as sftp: with contextlib.closing( sftp.file( path, mode, bufsize, ) ) as fh: yield fh class Command(Executor.Command): """ This class holds all data related to command execution. - the command itself - stdout/stderr streams - out/err string which were produced by command - returncode the exit status of command """ def __init__(self, cmd, session): super(RemoteExecutor.Command, self).__init__( subprocess.list2cmdline(cmd), session, ) self._in = None self._out = None self._err = None def get_rc(self, wait=False): if self._rc is None: if self._out is not None: if self._out.channel.exit_status_ready() or wait: self._rc = self._out.channel.recv_exit_status() return self._rc @contextlib.contextmanager def execute(self, bufsize=-1, timeout=None, get_pty=False): """ This method allows you to work directly with streams. with cmd.execute() as in_, out, err: # where in_, out and err are file-like objects # where you can read data from these """ try: self.logger.debug("Executing: %s", self.cmd) self._in, self._out, self._err = self._ss._ssh.exec_command( self.cmd, bufsize=bufsize, timeout=timeout, get_pty=get_pty, ) yield self._in, self._out, self._err self.get_rc(True) except socket.timeout as ex: self._ss._update_timeout_exception(ex, timeout) raise finally: if self._in is not None: self._in.close() if self._out is not None: self._out.close() if self._err is not None: self._err.close() self.logger.debug("Results of command: %s", self.cmd) self.logger.debug(" OUT: %s", self.out) self.logger.debug(" ERR: %s", self.err) self.logger.debug(" RC: %s", self.rc) def run(self, input_, timeout=None, get_pty=False): with self.execute( timeout=timeout, get_pty=get_pty ) as (in_, out, err): if input_: in_.write(input_) in_.close() self.out = out.read() self.err = err.read() return self.rc, self.out, self.err def __init__(self, user, address, use_pkey=False): """ :param user: user :type user: instance of User :param address: ip / hostname :type address: str :param use_pkey: use ssh private key in the connection :type use_pkey: bool """ super(RemoteExecutor, self).__init__(user) self.address = address self.use_pkey = use_pkey def session(self, timeout=None): """ :param timeout: tcp timeout :type timeout: float :return: the session :rtype: instance of RemoteExecutor.Session """ return RemoteExecutor.Session(self, timeout, self.use_pkey) def run_cmd(self, cmd, input_=None, tcp_timeout=None, io_timeout=None): """ :param cmd: command :type cmd: list :param input_: input data :type input_: str :param tcp_timeout: tcp timeout :type tcp_timeout: float :param io_timeout: timeout for data operation (read/write) :type io_timeout: float :return: rc, out, err :rtype: tuple (int, str, str) """ with self.session(tcp_timeout) as session: return session.run_cmd(cmd, input_, io_timeout) def is_connective(self, tcp_timeout=20.0): """ Check if address is connective via ssh :param tcp_timeout: time to wait for response :type tcp_timeout: float :return: True if address is connective, False otherwise :rtype: bool """ try: self.logger.info( "Check if address is connective via ssh in given timeout %s", tcp_timeout ) self.run_cmd(['true'], tcp_timeout=tcp_timeout) return True except (socket.timeout, socket.error) as e: self.logger.debug("Socket error: %s", e) except Exception as e: self.logger.debug("SSH exception: %s", e) return False def wait_for_connectivity_state( self, positive, timeout=CONNECTIVITY_TIMEOUT, sample_time=CONNECTIVITY_SAMPLE_TIME ): """ Wait until address will be connective or not via ssh :param positive: wait for the positive or negative connective state :type positive: bool :param timeout: wait timeout :type timeout: int :param sample_time: sample the ssh each sample_time seconds :type sample_time: int :return: True, if positive and ssh is connective or negative and ssh does not connective, otherwise False :rtype: bool """ reachable = "unreachable" if positive else "reachable" timeout_counter = 0 while self.is_connective() != positive: if timeout_counter > timeout: self.logger.error( "Address %s is still %s via ssh, after %s seconds", self.address, reachable, timeout ) return False time.sleep(sample_time) timeout_counter += sample_time return True
gpl-2.0
[ 646, 747, 199, 646, 900, 199, 646, 2838, 199, 646, 26162, 199, 646, 15502, 199, 646, 3873, 199, 504, 519, 5682, 2753, 20481, 14, 13471, 492, 9434, 4139, 199, 199, 25303, 1149, 63, 17434, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 11497, 63, 1612, 531, 199, 20004, 63, 23775, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 3159, 63, 5146, 531, 199, 998, 63, 12115, 63, 13047, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 344, 63, 13487, 14, 5645, 531, 199, 998, 63, 12115, 63, 3311, 54, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 344, 63, 13487, 531, 199, 14657, 6882, 1922, 63, 8899, 275, 11624, 199, 14657, 6882, 1922, 63, 15827, 63, 4961, 275, 3388, 421, 199, 533, 17283, 16752, 8, 16752, 304, 272, 408, 272, 6184, 2073, 1314, 6571, 12027, 2435, 14, 339, 961, 1021, 365, 18329, 370, 3350, 4154, 1453, 15841, 14, 6744, 14, 14091, 8412, 272, 824, 305, 385, 14, 961, 6127, 1265, 370, 5117, 2879, 370, 26808, 543, 8635, 14, 272, 16485, 282, 12166, 18752, 12, 10232, 16146, 402, 715, 15, 797, 2058, 12, 436, 272, 13667, 316, 3839, 543, 4635, 14, 339, 2047, 883, 5139, 675, 675, 283, 1065, 63, 1760, 7, 1083, 340, 1265, 2793, 1133, 10296, 14, 272, 11017, 473, 3955, 295, 957, 3594, 1265, 370, 1736, 2839, 642, 26, 272, 408, 339, 13488, 63, 8899, 275, 1616, 14, 16, 339, 1021, 15996, 10200, 8, 16752, 14, 4455, 10200, 304, 267, 408, 267, 23365, 3238, 626, 1006, 9610, 1314, 787, 4224, 4799, 642, 1021, 12, 965, 267, 5827, 2403, 14, 359, 751, 32, 1772, 15, 2060, 61, 267, 408, 267, 347, 2112, 8, 277, 12, 1499, 12, 2074, 304, 288, 372, 334, 355, 26503, 83, 19437, 83, 3149, 83, 61, 450, 83, 2, 450, 334, 490, 291, 14, 2911, 459, 277, 2278, 751, 14, 354, 12, 490, 291, 14, 2911, 459, 277, 2278, 1562, 12, 490, 291, 14, 2911, 459, 277, 2278, 751, 14, 2060, 12, 490, 1499, 12, 355, 2318, 355, 2074, 12, 288, 776, 339, 1021, 8596, 8, 16752, 14, 4434, 304, 267, 408, 267, 21591, 4702, 8635, 1950, 267, 408, 267, 347, 636, 826, 721, 277, 12, 13270, 12, 2653, 29, 403, 12, 675, 63, 23749, 29, 797, 304, 288, 1613, 8, 6713, 16752, 14, 4434, 12, 291, 2843, 826, 721, 13471, 9, 288, 340, 2653, 365, 488, 26, 355, 2653, 275, 17283, 16752, 14, 9735, 63, 8899, 288, 291, 423, 2593, 275, 2653, 288, 291, 423, 5510, 275, 26162, 14, 13716, 3041, 342, 288, 291, 423, 5510, 14, 409, 63, 4752, 63, 1102, 63, 498, 63, 3185, 8, 635, 16625, 14, 3358, 1123, 4845, 1012, 288, 340, 675, 63, 23749, 26, 355, 291, 14, 23749, 275, 26162, 14, 12115, 1197, 14, 504, 63, 4239, 63, 498, 63, 493, 8, 490, 2870, 63, 12115, 63, 3311, 54, 450, 747, 14, 515, 14, 12131, 21114, 358, 355, 776, 355, 291, 423, 13471, 14, 751, 14, 2060, 275, 488, 288, 587, 26, 355, 291, 14, 23749, 275, 488, 398, 347, 636, 2224, 721, 277, 12, 730, 3131, 574, 12, 7070, 304, 288, 340, 730, 63, 365, 2838, 14, 2593, 26, 355, 291, 423, 873, 63, 2593, 63, 1971, 8, 585, 9, 288, 862, 26, 355, 291, 14, 1600, 342, 288, 871, 2186, 465, 444, 26, 355, 340, 730, 63, 365, 488, 26, 490, 746, 355, 587, 26, 490, 291, 423, 13471, 14, 2921, 14, 1757, 8, 717, 298, 6049, 440, 4002, 8635, 2351, 450, 83, 401, 444, 12, 490, 776, 398, 347, 1551, 8, 277, 304, 288, 291, 423, 5510, 14, 362, 63, 1102, 63, 1612, 1252, 3584, 342, 288, 862, 26, 355, 291, 423, 5510, 14, 2242, 8, 490, 291, 423, 13471, 14, 1562, 12, 490, 3434, 29, 277, 423, 13471, 14, 751, 14, 354, 12, 490, 2505, 29, 277, 423, 13471, 14, 751, 14, 2060, 12, 490, 2653, 29, 277, 423, 2593, 12, 490, 31130, 29, 277, 14, 23749, 355, 776, 288, 871, 334, 3450, 14, 5294, 73, 705, 12, 2838, 14, 72, 705, 9, 465, 444, 26, 355, 1249, 275, 769, 8, 476, 14, 589, 9, 355, 1245, 275, 2071, 83, 26, 450, 83, 2, 450, 334, 277, 423, 13471, 14, 1562, 12, 1249, 59, 17, 566, 355, 1249, 59, 17, 61, 275, 1245, 355, 444, 14, 20395, 275, 1245, 355, 444, 14, 589, 275, 2008, 8, 589, 9, 355, 746, 288, 871, 2838, 14, 2593, 465, 444, 26, 355, 291, 423, 873, 63, 2593, 63, 1971, 8, 476, 9, 355, 746, 398, 347, 4002, 8, 277, 304, 288, 291, 423, 5510, 14, 1600, 342, 398, 347, 485, 873, 63, 2593, 63, 1971, 8, 277, 12, 444, 12, 2653, 29, 403, 304, 288, 340, 2519, 8, 476, 12, 2513, 5334, 297, 756, 304, 355, 372, 288, 340, 2653, 365, 488, 26, 355, 2653, 275, 291, 423, 2593, 288, 1245, 275, 2071, 83, 26, 2653, 4042, 83, 2924, 450, 334, 355, 291, 423, 13471, 14, 1562, 12, 2653, 288, 776, 288, 444, 14, 589, 275, 334, 1188, 4258, 288, 444, 423, 5334, 275, 715, 398, 347, 1414, 8, 277, 12, 2088, 304, 288, 372, 17283, 16752, 14, 3110, 8, 1760, 12, 291, 9, 398, 347, 1255, 63, 1760, 8, 277, 12, 2088, 12, 1324, 10683, 403, 12, 2653, 29, 403, 304, 288, 2088, 275, 291, 14, 1531, 8, 1760, 9, 288, 372, 2088, 14, 1065, 8, 1210, 3131, 2653, 9, 398, 768, 23464, 14, 14237, 267, 347, 1551, 63, 493, 8, 277, 12, 931, 12, 818, 534, 82, 297, 17080, 4022, 17, 304, 288, 543, 15502, 14, 11707, 8, 277, 423, 5510, 14, 1490, 63, 25032, 1012, 465, 308, 8915, 26, 355, 543, 15502, 14, 11707, 8, 490, 308, 8915, 14, 493, 8, 717, 931, 12, 717, 818, 12, 717, 17080, 12, 490, 776, 355, 776, 465, 11155, 26, 490, 1995, 11155, 339, 1021, 5817, 8, 16752, 14, 3110, 304, 267, 408, 267, 961, 1021, 15164, 1006, 666, 4048, 370, 1414, 6451, 14, 268, 446, 314, 1414, 6337, 268, 446, 3839, 15, 3083, 13788, 268, 446, 734, 15, 1508, 1059, 1314, 4898, 13584, 701 ]
[ 747, 199, 646, 900, 199, 646, 2838, 199, 646, 26162, 199, 646, 15502, 199, 646, 3873, 199, 504, 519, 5682, 2753, 20481, 14, 13471, 492, 9434, 4139, 199, 199, 25303, 1149, 63, 17434, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 11497, 63, 1612, 531, 199, 20004, 63, 23775, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 3159, 63, 5146, 531, 199, 998, 63, 12115, 63, 13047, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 344, 63, 13487, 14, 5645, 531, 199, 998, 63, 12115, 63, 3311, 54, 275, 747, 14, 515, 14, 904, 3647, 83, 401, 3680, 5510, 15, 344, 63, 13487, 531, 199, 14657, 6882, 1922, 63, 8899, 275, 11624, 199, 14657, 6882, 1922, 63, 15827, 63, 4961, 275, 3388, 421, 199, 533, 17283, 16752, 8, 16752, 304, 272, 408, 272, 6184, 2073, 1314, 6571, 12027, 2435, 14, 339, 961, 1021, 365, 18329, 370, 3350, 4154, 1453, 15841, 14, 6744, 14, 14091, 8412, 272, 824, 305, 385, 14, 961, 6127, 1265, 370, 5117, 2879, 370, 26808, 543, 8635, 14, 272, 16485, 282, 12166, 18752, 12, 10232, 16146, 402, 715, 15, 797, 2058, 12, 436, 272, 13667, 316, 3839, 543, 4635, 14, 339, 2047, 883, 5139, 675, 675, 283, 1065, 63, 1760, 7, 1083, 340, 1265, 2793, 1133, 10296, 14, 272, 11017, 473, 3955, 295, 957, 3594, 1265, 370, 1736, 2839, 642, 26, 272, 408, 339, 13488, 63, 8899, 275, 1616, 14, 16, 339, 1021, 15996, 10200, 8, 16752, 14, 4455, 10200, 304, 267, 408, 267, 23365, 3238, 626, 1006, 9610, 1314, 787, 4224, 4799, 642, 1021, 12, 965, 267, 5827, 2403, 14, 359, 751, 32, 1772, 15, 2060, 61, 267, 408, 267, 347, 2112, 8, 277, 12, 1499, 12, 2074, 304, 288, 372, 334, 355, 26503, 83, 19437, 83, 3149, 83, 61, 450, 83, 2, 450, 334, 490, 291, 14, 2911, 459, 277, 2278, 751, 14, 354, 12, 490, 291, 14, 2911, 459, 277, 2278, 1562, 12, 490, 291, 14, 2911, 459, 277, 2278, 751, 14, 2060, 12, 490, 1499, 12, 355, 2318, 355, 2074, 12, 288, 776, 339, 1021, 8596, 8, 16752, 14, 4434, 304, 267, 408, 267, 21591, 4702, 8635, 1950, 267, 408, 267, 347, 636, 826, 721, 277, 12, 13270, 12, 2653, 29, 403, 12, 675, 63, 23749, 29, 797, 304, 288, 1613, 8, 6713, 16752, 14, 4434, 12, 291, 2843, 826, 721, 13471, 9, 288, 340, 2653, 365, 488, 26, 355, 2653, 275, 17283, 16752, 14, 9735, 63, 8899, 288, 291, 423, 2593, 275, 2653, 288, 291, 423, 5510, 275, 26162, 14, 13716, 3041, 342, 288, 291, 423, 5510, 14, 409, 63, 4752, 63, 1102, 63, 498, 63, 3185, 8, 635, 16625, 14, 3358, 1123, 4845, 1012, 288, 340, 675, 63, 23749, 26, 355, 291, 14, 23749, 275, 26162, 14, 12115, 1197, 14, 504, 63, 4239, 63, 498, 63, 493, 8, 490, 2870, 63, 12115, 63, 3311, 54, 450, 747, 14, 515, 14, 12131, 21114, 358, 355, 776, 355, 291, 423, 13471, 14, 751, 14, 2060, 275, 488, 288, 587, 26, 355, 291, 14, 23749, 275, 488, 398, 347, 636, 2224, 721, 277, 12, 730, 3131, 574, 12, 7070, 304, 288, 340, 730, 63, 365, 2838, 14, 2593, 26, 355, 291, 423, 873, 63, 2593, 63, 1971, 8, 585, 9, 288, 862, 26, 355, 291, 14, 1600, 342, 288, 871, 2186, 465, 444, 26, 355, 340, 730, 63, 365, 488, 26, 490, 746, 355, 587, 26, 490, 291, 423, 13471, 14, 2921, 14, 1757, 8, 717, 298, 6049, 440, 4002, 8635, 2351, 450, 83, 401, 444, 12, 490, 776, 398, 347, 1551, 8, 277, 304, 288, 291, 423, 5510, 14, 362, 63, 1102, 63, 1612, 1252, 3584, 342, 288, 862, 26, 355, 291, 423, 5510, 14, 2242, 8, 490, 291, 423, 13471, 14, 1562, 12, 490, 3434, 29, 277, 423, 13471, 14, 751, 14, 354, 12, 490, 2505, 29, 277, 423, 13471, 14, 751, 14, 2060, 12, 490, 2653, 29, 277, 423, 2593, 12, 490, 31130, 29, 277, 14, 23749, 355, 776, 288, 871, 334, 3450, 14, 5294, 73, 705, 12, 2838, 14, 72, 705, 9, 465, 444, 26, 355, 1249, 275, 769, 8, 476, 14, 589, 9, 355, 1245, 275, 2071, 83, 26, 450, 83, 2, 450, 334, 277, 423, 13471, 14, 1562, 12, 1249, 59, 17, 566, 355, 1249, 59, 17, 61, 275, 1245, 355, 444, 14, 20395, 275, 1245, 355, 444, 14, 589, 275, 2008, 8, 589, 9, 355, 746, 288, 871, 2838, 14, 2593, 465, 444, 26, 355, 291, 423, 873, 63, 2593, 63, 1971, 8, 476, 9, 355, 746, 398, 347, 4002, 8, 277, 304, 288, 291, 423, 5510, 14, 1600, 342, 398, 347, 485, 873, 63, 2593, 63, 1971, 8, 277, 12, 444, 12, 2653, 29, 403, 304, 288, 340, 2519, 8, 476, 12, 2513, 5334, 297, 756, 304, 355, 372, 288, 340, 2653, 365, 488, 26, 355, 2653, 275, 291, 423, 2593, 288, 1245, 275, 2071, 83, 26, 2653, 4042, 83, 2924, 450, 334, 355, 291, 423, 13471, 14, 1562, 12, 2653, 288, 776, 288, 444, 14, 589, 275, 334, 1188, 4258, 288, 444, 423, 5334, 275, 715, 398, 347, 1414, 8, 277, 12, 2088, 304, 288, 372, 17283, 16752, 14, 3110, 8, 1760, 12, 291, 9, 398, 347, 1255, 63, 1760, 8, 277, 12, 2088, 12, 1324, 10683, 403, 12, 2653, 29, 403, 304, 288, 2088, 275, 291, 14, 1531, 8, 1760, 9, 288, 372, 2088, 14, 1065, 8, 1210, 3131, 2653, 9, 398, 768, 23464, 14, 14237, 267, 347, 1551, 63, 493, 8, 277, 12, 931, 12, 818, 534, 82, 297, 17080, 4022, 17, 304, 288, 543, 15502, 14, 11707, 8, 277, 423, 5510, 14, 1490, 63, 25032, 1012, 465, 308, 8915, 26, 355, 543, 15502, 14, 11707, 8, 490, 308, 8915, 14, 493, 8, 717, 931, 12, 717, 818, 12, 717, 17080, 12, 490, 776, 355, 776, 465, 11155, 26, 490, 1995, 11155, 339, 1021, 5817, 8, 16752, 14, 3110, 304, 267, 408, 267, 961, 1021, 15164, 1006, 666, 4048, 370, 1414, 6451, 14, 268, 446, 314, 1414, 6337, 268, 446, 3839, 15, 3083, 13788, 268, 446, 734, 15, 1508, 1059, 1314, 4898, 13584, 701, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ardi69/pyload-0.4.10
pyload/Api/types.py
1
11175
# -*- coding: utf-8 -*- # Autogenerated by pyload # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING class BaseObject(object): __slots__ = [] class Destination(object): Collector = 0 Queue = 1 class DownloadStatus(object): Aborted = 9 Custom = 11 Decrypting = 10 Downloading = 12 Failed = 8 Finished = 0 Offline = 1 Online = 2 Processing = 13 Queued = 3 Skipped = 4 Starting = 7 TempOffline = 6 Unknown = 14 Waiting = 5 class ElementType(object): File = 1 Package = 0 class Input(object): BOOL = 4 CHOICE = 6 CLICK = 5 LIST = 8 MULTIPLE = 7 NONE = 0 PASSWORD = 3 TABLE = 9 TEXT = 1 TEXTBOX = 2 class Output(object): CAPTCHA = 1 NOTIFICATION = 4 QUESTION = 2 class AccountInfo(BaseObject): __slots__ = ['validuntil', 'login', 'options', 'valid', 'trafficleft', 'maxtraffic', 'premium', 'type'] def __init__(self, validuntil=None, login=None, options=None, valid=None, trafficleft=None, maxtraffic=None, premium=None, type=None): self.validuntil = validuntil self.login = login self.options = options self.valid = valid self.trafficleft = trafficleft self.maxtraffic = maxtraffic self.premium = premium self.type = type class CaptchaTask(BaseObject): __slots__ = ['tid', 'data', 'type', 'resultType'] def __init__(self, tid=None, data=None, type=None, resultType=None): self.tid = tid self.data = data self.type = type self.resultType = resultType class ConfigItem(BaseObject): __slots__ = ['name', 'description', 'value', 'type'] def __init__(self, name=None, description=None, value=None, type=None): self.name = name self.description = description self.value = value self.type = type class ConfigSection(BaseObject): __slots__ = ['name', 'description', 'items', 'outline'] def __init__(self, name=None, description=None, items=None, outline=None): self.name = name self.description = description self.items = items self.outline = outline class DownloadInfo(BaseObject): __slots__ = ['fid', 'name', 'speed', 'eta', 'format_eta', 'bleft', 'size', 'format_size', 'percent', 'status', 'statusmsg', 'format_wait', 'wait_until', 'packageID', 'packageName', 'plugin'] def __init__(self, fid=None, name=None, speed=None, eta=None, format_eta=None, bleft=None, size=None, format_size=None, percent=None, status=None, statusmsg=None, format_wait=None, wait_until=None, packageID=None, packageName=None, plugin=None): self.fid = fid self.name = name self.speed = speed self.eta = eta self.format_eta = format_eta self.bleft = bleft self.size = size self.format_size = format_size self.percent = percent self.status = status self.statusmsg = statusmsg self.format_wait = format_wait self.wait_until = wait_until self.packageID = packageID self.packageName = packageName self.plugin = plugin class EventInfo(BaseObject): __slots__ = ['eventname', 'id', 'type', 'destination'] def __init__(self, eventname=None, id=None, type=None, destination=None): self.eventname = eventname self.id = id self.type = type self.destination = destination class FileData(BaseObject): __slots__ = ['fid', 'url', 'name', 'plugin', 'size', 'format_size', 'status', 'statusmsg', 'packageID', 'error', 'order'] def __init__(self, fid=None, url=None, name=None, plugin=None, size=None, format_size=None, status=None, statusmsg=None, packageID=None, error=None, order=None): self.fid = fid self.url = url self.name = name self.plugin = plugin self.size = size self.format_size = format_size self.status = status self.statusmsg = statusmsg self.packageID = packageID self.error = error self.order = order class FileDoesNotExists(Exception): __slots__ = ['fid'] def __init__(self, fid=None): self.fid = fid class InteractionTask(BaseObject): __slots__ = ['iid', 'input', 'structure', 'preset', 'output', 'data', 'title', 'description', 'plugin'] def __init__(self, iid=None, input=None, structure=None, preset=None, output=None, data=None, title=None, description=None, plugin=None): self.iid = iid self.input = input self.structure = structure self.preset = preset self.output = output self.data = data self.title = title self.description = description self.plugin = plugin class OnlineCheck(BaseObject): __slots__ = ['rid', 'data'] def __init__(self, rid=None, data=None): self.rid = rid self.data = data class OnlineStatus(BaseObject): __slots__ = ['name', 'plugin', 'packagename', 'status', 'size'] def __init__(self, name=None, plugin=(None, None), packagename=None, status=None, size=None): self.name = name self.plugin = plugin self.packagename = packagename self.status = status self.size = size class PackageData(BaseObject): __slots__ = ['pid', 'name', 'folder', 'site', 'password', 'dest', 'order', 'linksdone', 'sizedone', 'sizetotal', 'linkstotal', 'links', 'fids'] def __init__(self, pid=None, name=None, folder=None, site=None, password=None, dest=None, order=None, linksdone=None, sizedone=None, sizetotal=None, linkstotal=None, links=None, fids=None): self.pid = pid self.name = name self.folder = folder self.site = site self.password = password self.dest = dest self.order = order self.linksdone = linksdone self.sizedone = sizedone self.sizetotal = sizetotal self.linkstotal = linkstotal self.links = links self.fids = fids class PackageDoesNotExists(Exception): __slots__ = ['pid'] def __init__(self, pid=None): self.pid = pid class ServerStatus(BaseObject): __slots__ = ['pause', 'active', 'queue', 'total', 'speed', 'download', 'reconnect'] def __init__(self, pause=None, active=None, queue=None, total=None, speed=None, download=None, reconnect=None): self.pause = pause self.active = active self.queue = queue self.total = total self.speed = speed self.download = download self.reconnect = reconnect class ServiceCall(BaseObject): __slots__ = ['plugin', 'func', 'arguments', 'parseArguments'] def __init__(self, plugin=None, func=None, arguments=None, parseArguments=None): self.plugin = plugin self.func = func self.arguments = arguments self.parseArguments = parseArguments class ServiceDoesNotExists(Exception): __slots__ = ['plugin', 'func'] def __init__(self, plugin=None, func=None): self.plugin = plugin self.func = func class ServiceException(Exception): __slots__ = ['msg'] def __init__(self, msg=None): self.msg = msg class UserData(BaseObject): __slots__ = ['name', 'email', 'role', 'permission', 'templateName'] def __init__(self, name=None, email=None, role=None, permission=None, templateName=None): self.name = name self.email = email self.role = role self.permission = permission self.templateName = templateName class Iface(object): def addFiles(self, pid, links): pass def addPackage(self, name, links, dest): pass def call(self, info): pass def checkOnlineStatus(self, urls): pass def checkOnlineStatusContainer(self, urls, filename, data): pass def checkURLs(self, urls): pass def deleteFiles(self, fids): pass def deleteFinished(self): pass def deletePackages(self, pids): pass def freeSpace(self): pass def generateAndAddPackages(self, links, dest): pass def generatePackages(self, links): pass def getAccountTypes(self): pass def getAccounts(self, refresh): pass def getAllInfo(self): pass def getAllUserData(self): pass def getCaptchaTask(self, exclusive): pass def getCaptchaTaskStatus(self, tid): pass def getCollector(self): pass def getCollectorData(self): pass def getConfig(self): pass def getConfigValue(self, category, option, section): pass def getEvents(self, uuid): pass def getFileData(self, fid): pass def getFileOrder(self, pid): pass def getInfoByPlugin(self, plugin): pass def getLog(self, offset): pass def getPackageData(self, pid): pass def getPackageInfo(self, pid): pass def getPackageOrder(self, destination): pass def getPluginConfig(self): pass def getQueue(self): pass def getQueueData(self): pass def getServerVersion(self): pass def getServices(self): pass def getUserData(self, username, password): pass def hasService(self, plugin, func): pass def isCaptchaWaiting(self): pass def isTimeDownload(self): pass def isTimeReconnect(self): pass def kill(self): pass def login(self, username, password): pass def moveFiles(self, fids, pid): pass def movePackage(self, destination, pid): pass def orderFile(self, fid, position): pass def orderPackage(self, pid, position): pass def parseURLs(self, html, url): pass def pauseServer(self): pass def pollResults(self, rid): pass def pullFromQueue(self, pid): pass def pushToQueue(self, pid): pass def recheckPackage(self, pid): pass def removeAccount(self, plugin, account): pass def restart(self): pass def restartFailed(self): pass def restartFile(self, fid): pass def restartPackage(self, pid): pass def setCaptchaResult(self, tid, result): pass def setConfigValue(self, category, option, value, section): pass def setPackageData(self, pid, data): pass def setPackageName(self, pid, name): pass def statusDownloads(self): pass def statusServer(self): pass def stopAllDownloads(self): pass def stopDownloads(self, fids): pass def togglePause(self): pass def toggleReconnect(self): pass def unpauseServer(self): pass def updateAccount(self, plugin, account, password, options): pass def uploadContainer(self, filename, data): pass
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 27722, 16741, 701, 1134, 912, 199, 3, 3506, 2845, 24981, 6778, 30928, 1488, 22050, 9315, 428, 3942, 4221, 619, 1488, 22050, 1804, 14283, 28752, 1488, 22050, 9315, 3506, 1206, 199, 199, 533, 3523, 1692, 8, 785, 304, 272, 636, 7257, 363, 275, 942, 421, 199, 533, 28505, 8, 785, 304, 272, 3626, 3283, 275, 378, 272, 10703, 275, 413, 421, 199, 533, 17955, 3694, 8, 785, 304, 272, 8351, 1376, 275, 1749, 272, 8388, 275, 4119, 272, 13966, 13656, 316, 275, 1616, 272, 13392, 8786, 275, 3144, 272, 16277, 275, 1695, 272, 11711, 4387, 275, 378, 272, 28856, 604, 275, 413, 272, 4068, 604, 275, 499, 272, 20157, 275, 4944, 272, 10703, 68, 275, 650, 272, 8232, 1915, 275, 841, 272, 24175, 275, 1520, 272, 12540, 5195, 604, 275, 1227, 272, 14831, 275, 4329, 272, 13144, 316, 275, 959, 421, 199, 533, 6566, 804, 8, 785, 304, 272, 3814, 275, 413, 272, 15665, 275, 378, 421, 199, 533, 6924, 8, 785, 304, 272, 25849, 275, 841, 272, 445, 2979, 4047, 275, 1227, 272, 445, 2507, 43, 275, 959, 272, 21716, 275, 1695, 272, 24895, 1772, 906, 275, 1520, 272, 653, 4817, 275, 378, 272, 21705, 5172, 275, 650, 272, 9934, 275, 1749, 272, 11951, 275, 413, 272, 11951, 15694, 275, 499, 421, 199, 533, 7242, 8, 785, 304, 272, 445, 26086, 26363, 275, 413, 272, 2845, 14456, 2594, 275, 841, 272, 22828, 275, 499, 421, 199, 533, 9973, 2354, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 1078, 8111, 297, 283, 2886, 297, 283, 1419, 297, 283, 1078, 297, 283, 17297, 3039, 297, 283, 391, 400, 345, 8376, 297, 283, 657, 23481, 297, 283, 466, 418, 2378, 347, 636, 826, 721, 277, 12, 1686, 8111, 29, 403, 12, 4676, 29, 403, 12, 1511, 29, 403, 12, 1686, 29, 403, 12, 15602, 3039, 29, 403, 12, 610, 400, 345, 8376, 29, 403, 12, 876, 23481, 29, 403, 12, 730, 29, 403, 304, 267, 291, 14, 1078, 8111, 275, 1686, 8111, 267, 291, 14, 2886, 275, 4676, 267, 291, 14, 1419, 275, 1511, 267, 291, 14, 1078, 275, 1686, 267, 291, 14, 17297, 3039, 275, 15602, 3039, 267, 291, 14, 391, 400, 345, 8376, 275, 610, 400, 345, 8376, 267, 291, 14, 657, 23481, 275, 876, 23481, 267, 291, 14, 466, 275, 730, 421, 199, 533, 25534, 9518, 4476, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 5700, 297, 283, 576, 297, 283, 466, 297, 283, 1099, 804, 418, 2378, 347, 636, 826, 721, 277, 12, 11559, 29, 403, 12, 666, 29, 403, 12, 730, 29, 403, 12, 754, 804, 29, 403, 304, 267, 291, 14, 5700, 275, 11559, 267, 291, 14, 576, 275, 666, 267, 291, 14, 466, 275, 730, 267, 291, 14, 1099, 804, 275, 754, 804, 421, 199, 533, 4094, 2081, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 354, 297, 283, 1802, 297, 283, 585, 297, 283, 466, 418, 2378, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 1369, 29, 403, 12, 574, 29, 403, 12, 730, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 585, 275, 574, 267, 291, 14, 466, 275, 730, 421, 199, 533, 4094, 8660, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 354, 297, 283, 1802, 297, 283, 1744, 297, 283, 11550, 418, 2378, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 1369, 29, 403, 12, 2974, 29, 403, 12, 17964, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 1744, 275, 2974, 267, 291, 14, 11550, 275, 17964, 421, 199, 533, 17955, 2354, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 9430, 297, 283, 354, 297, 283, 7625, 297, 283, 1841, 297, 283, 908, 63, 1841, 297, 283, 830, 856, 297, 283, 890, 297, 283, 908, 63, 890, 297, 283, 7045, 297, 283, 1205, 297, 283, 1205, 1328, 297, 283, 908, 63, 2573, 297, 283, 2573, 63, 8111, 297, 283, 2491, 998, 297, 283, 2491, 985, 297, 283, 2718, 418, 2378, 347, 636, 826, 721, 277, 12, 8289, 29, 403, 12, 536, 29, 403, 12, 8112, 29, 403, 12, 20356, 29, 403, 12, 1475, 63, 1841, 29, 403, 12, 330, 3039, 29, 403, 12, 1568, 29, 403, 12, 1475, 63, 890, 29, 403, 12, 8878, 29, 403, 12, 2004, 29, 403, 12, 2004, 1328, 29, 403, 12, 1475, 63, 2573, 29, 403, 12, 3618, 63, 8111, 29, 403, 12, 2559, 998, 29, 403, 12, 2559, 985, 29, 403, 12, 3589, 29, 403, 304, 267, 291, 14, 9430, 275, 8289, 267, 291, 14, 354, 275, 536, 267, 291, 14, 7625, 275, 8112, 267, 291, 14, 1841, 275, 20356, 267, 291, 14, 908, 63, 1841, 275, 1475, 63, 1841, 267, 291, 14, 830, 856, 275, 330, 3039, 267, 291, 14, 890, 275, 1568, 267, 291, 14, 908, 63, 890, 275, 1475, 63, 890, 267, 291, 14, 7045, 275, 8878, 267, 291, 14, 1205, 275, 2004, 267, 291, 14, 1205, 1328, 275, 2004, 1328, 267, 291, 14, 908, 63, 2573, 275, 1475, 63, 2573, 267, 291, 14, 2573, 63, 8111, 275, 3618, 63, 8111, 267, 291, 14, 2491, 998, 275, 2559, 998, 267, 291, 14, 2491, 985, 275, 2559, 985, 267, 291, 14, 2718, 275, 3589, 421, 199, 533, 6763, 2354, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 1430, 354, 297, 283, 344, 297, 283, 466, 297, 283, 6881, 418, 2378, 347, 636, 826, 721, 277, 12, 1566, 354, 29, 403, 12, 1305, 29, 403, 12, 730, 29, 403, 12, 5724, 29, 403, 304, 267, 291, 14, 1430, 354, 275, 1566, 354, 267, 291, 14, 344, 275, 1305, 267, 291, 14, 466, 275, 730, 267, 291, 14, 6881, 275, 5724, 421, 199, 533, 3814, 1451, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 9430, 297, 283, 633, 297, 283, 354, 297, 283, 2718, 297, 283, 890, 297, 283, 908, 63, 890, 297, 283, 1205, 297, 283, 1205, 1328, 297, 283, 2491, 998, 297, 283, 705, 297, 283, 1648, 418, 2378, 347 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 27722, 16741, 701, 1134, 912, 199, 3, 3506, 2845, 24981, 6778, 30928, 1488, 22050, 9315, 428, 3942, 4221, 619, 1488, 22050, 1804, 14283, 28752, 1488, 22050, 9315, 3506, 1206, 199, 199, 533, 3523, 1692, 8, 785, 304, 272, 636, 7257, 363, 275, 942, 421, 199, 533, 28505, 8, 785, 304, 272, 3626, 3283, 275, 378, 272, 10703, 275, 413, 421, 199, 533, 17955, 3694, 8, 785, 304, 272, 8351, 1376, 275, 1749, 272, 8388, 275, 4119, 272, 13966, 13656, 316, 275, 1616, 272, 13392, 8786, 275, 3144, 272, 16277, 275, 1695, 272, 11711, 4387, 275, 378, 272, 28856, 604, 275, 413, 272, 4068, 604, 275, 499, 272, 20157, 275, 4944, 272, 10703, 68, 275, 650, 272, 8232, 1915, 275, 841, 272, 24175, 275, 1520, 272, 12540, 5195, 604, 275, 1227, 272, 14831, 275, 4329, 272, 13144, 316, 275, 959, 421, 199, 533, 6566, 804, 8, 785, 304, 272, 3814, 275, 413, 272, 15665, 275, 378, 421, 199, 533, 6924, 8, 785, 304, 272, 25849, 275, 841, 272, 445, 2979, 4047, 275, 1227, 272, 445, 2507, 43, 275, 959, 272, 21716, 275, 1695, 272, 24895, 1772, 906, 275, 1520, 272, 653, 4817, 275, 378, 272, 21705, 5172, 275, 650, 272, 9934, 275, 1749, 272, 11951, 275, 413, 272, 11951, 15694, 275, 499, 421, 199, 533, 7242, 8, 785, 304, 272, 445, 26086, 26363, 275, 413, 272, 2845, 14456, 2594, 275, 841, 272, 22828, 275, 499, 421, 199, 533, 9973, 2354, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 1078, 8111, 297, 283, 2886, 297, 283, 1419, 297, 283, 1078, 297, 283, 17297, 3039, 297, 283, 391, 400, 345, 8376, 297, 283, 657, 23481, 297, 283, 466, 418, 2378, 347, 636, 826, 721, 277, 12, 1686, 8111, 29, 403, 12, 4676, 29, 403, 12, 1511, 29, 403, 12, 1686, 29, 403, 12, 15602, 3039, 29, 403, 12, 610, 400, 345, 8376, 29, 403, 12, 876, 23481, 29, 403, 12, 730, 29, 403, 304, 267, 291, 14, 1078, 8111, 275, 1686, 8111, 267, 291, 14, 2886, 275, 4676, 267, 291, 14, 1419, 275, 1511, 267, 291, 14, 1078, 275, 1686, 267, 291, 14, 17297, 3039, 275, 15602, 3039, 267, 291, 14, 391, 400, 345, 8376, 275, 610, 400, 345, 8376, 267, 291, 14, 657, 23481, 275, 876, 23481, 267, 291, 14, 466, 275, 730, 421, 199, 533, 25534, 9518, 4476, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 5700, 297, 283, 576, 297, 283, 466, 297, 283, 1099, 804, 418, 2378, 347, 636, 826, 721, 277, 12, 11559, 29, 403, 12, 666, 29, 403, 12, 730, 29, 403, 12, 754, 804, 29, 403, 304, 267, 291, 14, 5700, 275, 11559, 267, 291, 14, 576, 275, 666, 267, 291, 14, 466, 275, 730, 267, 291, 14, 1099, 804, 275, 754, 804, 421, 199, 533, 4094, 2081, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 354, 297, 283, 1802, 297, 283, 585, 297, 283, 466, 418, 2378, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 1369, 29, 403, 12, 574, 29, 403, 12, 730, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 585, 275, 574, 267, 291, 14, 466, 275, 730, 421, 199, 533, 4094, 8660, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 354, 297, 283, 1802, 297, 283, 1744, 297, 283, 11550, 418, 2378, 347, 636, 826, 721, 277, 12, 536, 29, 403, 12, 1369, 29, 403, 12, 2974, 29, 403, 12, 17964, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1802, 275, 1369, 267, 291, 14, 1744, 275, 2974, 267, 291, 14, 11550, 275, 17964, 421, 199, 533, 17955, 2354, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 9430, 297, 283, 354, 297, 283, 7625, 297, 283, 1841, 297, 283, 908, 63, 1841, 297, 283, 830, 856, 297, 283, 890, 297, 283, 908, 63, 890, 297, 283, 7045, 297, 283, 1205, 297, 283, 1205, 1328, 297, 283, 908, 63, 2573, 297, 283, 2573, 63, 8111, 297, 283, 2491, 998, 297, 283, 2491, 985, 297, 283, 2718, 418, 2378, 347, 636, 826, 721, 277, 12, 8289, 29, 403, 12, 536, 29, 403, 12, 8112, 29, 403, 12, 20356, 29, 403, 12, 1475, 63, 1841, 29, 403, 12, 330, 3039, 29, 403, 12, 1568, 29, 403, 12, 1475, 63, 890, 29, 403, 12, 8878, 29, 403, 12, 2004, 29, 403, 12, 2004, 1328, 29, 403, 12, 1475, 63, 2573, 29, 403, 12, 3618, 63, 8111, 29, 403, 12, 2559, 998, 29, 403, 12, 2559, 985, 29, 403, 12, 3589, 29, 403, 304, 267, 291, 14, 9430, 275, 8289, 267, 291, 14, 354, 275, 536, 267, 291, 14, 7625, 275, 8112, 267, 291, 14, 1841, 275, 20356, 267, 291, 14, 908, 63, 1841, 275, 1475, 63, 1841, 267, 291, 14, 830, 856, 275, 330, 3039, 267, 291, 14, 890, 275, 1568, 267, 291, 14, 908, 63, 890, 275, 1475, 63, 890, 267, 291, 14, 7045, 275, 8878, 267, 291, 14, 1205, 275, 2004, 267, 291, 14, 1205, 1328, 275, 2004, 1328, 267, 291, 14, 908, 63, 2573, 275, 1475, 63, 2573, 267, 291, 14, 2573, 63, 8111, 275, 3618, 63, 8111, 267, 291, 14, 2491, 998, 275, 2559, 998, 267, 291, 14, 2491, 985, 275, 2559, 985, 267, 291, 14, 2718, 275, 3589, 421, 199, 533, 6763, 2354, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 1430, 354, 297, 283, 344, 297, 283, 466, 297, 283, 6881, 418, 2378, 347, 636, 826, 721, 277, 12, 1566, 354, 29, 403, 12, 1305, 29, 403, 12, 730, 29, 403, 12, 5724, 29, 403, 304, 267, 291, 14, 1430, 354, 275, 1566, 354, 267, 291, 14, 344, 275, 1305, 267, 291, 14, 466, 275, 730, 267, 291, 14, 6881, 275, 5724, 421, 199, 533, 3814, 1451, 8, 1563, 1692, 304, 272, 636, 7257, 363, 275, 788, 9430, 297, 283, 633, 297, 283, 354, 297, 283, 2718, 297, 283, 890, 297, 283, 908, 63, 890, 297, 283, 1205, 297, 283, 1205, 1328, 297, 283, 2491, 998, 297, 283, 705, 297, 283, 1648, 418, 2378, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
40223102/w110519
static/Brython3.1.1-20150328-091302/Lib/multiprocessing/pool.py
694
23263
# # Module providing the `Pool` class for managing a process pool # # multiprocessing/pool.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # __all__ = ['Pool'] # # Imports # import threading import queue import itertools import collections import time from multiprocessing import Process, cpu_count, TimeoutError from multiprocessing.util import Finalize, debug # # Constants representing the state of a pool # RUN = 0 CLOSE = 1 TERMINATE = 2 # # Miscellaneous # job_counter = itertools.count() def mapstar(args): return list(map(*args)) def starmapstar(args): return list(itertools.starmap(args[0], args[1])) # # Code run by worker processes # class MaybeEncodingError(Exception): """Wraps possible unpickleable errors, so they can be safely sent through the socket.""" def __init__(self, exc, value): self.exc = repr(exc) self.value = repr(value) super(MaybeEncodingError, self).__init__(self.exc, self.value) def __str__(self): return "Error sending result: '%s'. Reason: '%s'" % (self.value, self.exc) def __repr__(self): return "<MaybeEncodingError: %s>" % str(self) def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None): assert maxtasks is None or (type(maxtasks) == int and maxtasks > 0) put = outqueue.put get = inqueue.get if hasattr(inqueue, '_writer'): inqueue._writer.close() outqueue._reader.close() if initializer is not None: initializer(*initargs) completed = 0 while maxtasks is None or (maxtasks and completed < maxtasks): try: task = get() except (EOFError, IOError): debug('worker got EOFError or IOError -- exiting') break if task is None: debug('worker got sentinel -- exiting') break job, i, func, args, kwds = task try: result = (True, func(*args, **kwds)) except Exception as e: result = (False, e) try: put((job, i, result)) except Exception as e: wrapped = MaybeEncodingError(e, result[1]) debug("Possible encoding error while sending result: %s" % ( wrapped)) put((job, i, (False, wrapped))) completed += 1 debug('worker exiting after %d tasks' % completed) # # Class representing a process pool # class Pool(object): ''' Class which supports an async version of applying functions to arguments. ''' Process = Process def __init__(self, processes=None, initializer=None, initargs=(), maxtasksperchild=None): self._setup_queues() self._taskqueue = queue.Queue() self._cache = {} self._state = RUN self._maxtasksperchild = maxtasksperchild self._initializer = initializer self._initargs = initargs if processes is None: try: processes = cpu_count() except NotImplementedError: processes = 1 if processes < 1: raise ValueError("Number of processes must be at least 1") if initializer is not None and not callable(initializer): raise TypeError('initializer must be a callable') self._processes = processes self._pool = [] self._repopulate_pool() self._worker_handler = threading.Thread( target=Pool._handle_workers, args=(self, ) ) self._worker_handler.daemon = True self._worker_handler._state = RUN self._worker_handler.start() self._task_handler = threading.Thread( target=Pool._handle_tasks, args=(self._taskqueue, self._quick_put, self._outqueue, self._pool) ) self._task_handler.daemon = True self._task_handler._state = RUN self._task_handler.start() self._result_handler = threading.Thread( target=Pool._handle_results, args=(self._outqueue, self._quick_get, self._cache) ) self._result_handler.daemon = True self._result_handler._state = RUN self._result_handler.start() self._terminate = Finalize( self, self._terminate_pool, args=(self._taskqueue, self._inqueue, self._outqueue, self._pool, self._worker_handler, self._task_handler, self._result_handler, self._cache), exitpriority=15 ) def _join_exited_workers(self): """Cleanup after any worker processes which have exited due to reaching their specified lifetime. Returns True if any workers were cleaned up. """ cleaned = False for i in reversed(range(len(self._pool))): worker = self._pool[i] if worker.exitcode is not None: # worker exited debug('cleaning up worker %d' % i) worker.join() cleaned = True del self._pool[i] return cleaned def _repopulate_pool(self): """Bring the number of pool processes up to the specified number, for use after reaping workers which have exited. """ for i in range(self._processes - len(self._pool)): w = self.Process(target=worker, args=(self._inqueue, self._outqueue, self._initializer, self._initargs, self._maxtasksperchild) ) self._pool.append(w) w.name = w.name.replace('Process', 'PoolWorker') w.daemon = True w.start() debug('added worker') def _maintain_pool(self): """Clean up any exited workers and start replacements for them. """ if self._join_exited_workers(): self._repopulate_pool() def _setup_queues(self): from .queues import SimpleQueue self._inqueue = SimpleQueue() self._outqueue = SimpleQueue() self._quick_put = self._inqueue._writer.send self._quick_get = self._outqueue._reader.recv def apply(self, func, args=(), kwds={}): ''' Equivalent of `func(*args, **kwds)`. ''' assert self._state == RUN return self.apply_async(func, args, kwds).get() def map(self, func, iterable, chunksize=None): ''' Apply `func` to each element in `iterable`, collecting the results in a list that is returned. ''' return self._map_async(func, iterable, mapstar, chunksize).get() def starmap(self, func, iterable, chunksize=None): ''' Like `map()` method but the elements of the `iterable` are expected to be iterables as well and will be unpacked as arguments. Hence `func` and (a, b) becomes func(a, b). ''' return self._map_async(func, iterable, starmapstar, chunksize).get() def starmap_async(self, func, iterable, chunksize=None, callback=None, error_callback=None): ''' Asynchronous version of `starmap()` method. ''' return self._map_async(func, iterable, starmapstar, chunksize, callback, error_callback) def imap(self, func, iterable, chunksize=1): ''' Equivalent of `map()` -- can be MUCH slower than `Pool.map()`. ''' if self._state != RUN: raise ValueError("Pool not running") if chunksize == 1: result = IMapIterator(self._cache) self._taskqueue.put((((result._job, i, func, (x,), {}) for i, x in enumerate(iterable)), result._set_length)) return result else: assert chunksize > 1 task_batches = Pool._get_tasks(func, iterable, chunksize) result = IMapIterator(self._cache) self._taskqueue.put((((result._job, i, mapstar, (x,), {}) for i, x in enumerate(task_batches)), result._set_length)) return (item for chunk in result for item in chunk) def imap_unordered(self, func, iterable, chunksize=1): ''' Like `imap()` method but ordering of results is arbitrary. ''' if self._state != RUN: raise ValueError("Pool not running") if chunksize == 1: result = IMapUnorderedIterator(self._cache) self._taskqueue.put((((result._job, i, func, (x,), {}) for i, x in enumerate(iterable)), result._set_length)) return result else: assert chunksize > 1 task_batches = Pool._get_tasks(func, iterable, chunksize) result = IMapUnorderedIterator(self._cache) self._taskqueue.put((((result._job, i, mapstar, (x,), {}) for i, x in enumerate(task_batches)), result._set_length)) return (item for chunk in result for item in chunk) def apply_async(self, func, args=(), kwds={}, callback=None, error_callback=None): ''' Asynchronous version of `apply()` method. ''' if self._state != RUN: raise ValueError("Pool not running") result = ApplyResult(self._cache, callback, error_callback) self._taskqueue.put(([(result._job, None, func, args, kwds)], None)) return result def map_async(self, func, iterable, chunksize=None, callback=None, error_callback=None): ''' Asynchronous version of `map()` method. ''' return self._map_async(func, iterable, mapstar, chunksize, callback, error_callback) def _map_async(self, func, iterable, mapper, chunksize=None, callback=None, error_callback=None): ''' Helper function to implement map, starmap and their async counterparts. ''' if self._state != RUN: raise ValueError("Pool not running") if not hasattr(iterable, '__len__'): iterable = list(iterable) if chunksize is None: chunksize, extra = divmod(len(iterable), len(self._pool) * 4) if extra: chunksize += 1 if len(iterable) == 0: chunksize = 0 task_batches = Pool._get_tasks(func, iterable, chunksize) result = MapResult(self._cache, chunksize, len(iterable), callback, error_callback=error_callback) self._taskqueue.put((((result._job, i, mapper, (x,), {}) for i, x in enumerate(task_batches)), None)) return result @staticmethod def _handle_workers(pool): thread = threading.current_thread() # Keep maintaining workers until the cache gets drained, unless the pool # is terminated. while thread._state == RUN or (pool._cache and thread._state != TERMINATE): pool._maintain_pool() time.sleep(0.1) # send sentinel to stop workers pool._taskqueue.put(None) debug('worker handler exiting') @staticmethod def _handle_tasks(taskqueue, put, outqueue, pool): thread = threading.current_thread() for taskseq, set_length in iter(taskqueue.get, None): i = -1 for i, task in enumerate(taskseq): if thread._state: debug('task handler found thread._state != RUN') break try: put(task) except IOError: debug('could not put task on queue') break else: if set_length: debug('doing set_length()') set_length(i+1) continue break else: debug('task handler got sentinel') try: # tell result handler to finish when cache is empty debug('task handler sending sentinel to result handler') outqueue.put(None) # tell workers there is no more work debug('task handler sending sentinel to workers') for p in pool: put(None) except IOError: debug('task handler got IOError when sending sentinels') debug('task handler exiting') @staticmethod def _handle_results(outqueue, get, cache): thread = threading.current_thread() while 1: try: task = get() except (IOError, EOFError): debug('result handler got EOFError/IOError -- exiting') return if thread._state: assert thread._state == TERMINATE debug('result handler found thread._state=TERMINATE') break if task is None: debug('result handler got sentinel') break job, i, obj = task try: cache[job]._set(i, obj) except KeyError: pass while cache and thread._state != TERMINATE: try: task = get() except (IOError, EOFError): debug('result handler got EOFError/IOError -- exiting') return if task is None: debug('result handler ignoring extra sentinel') continue job, i, obj = task try: cache[job]._set(i, obj) except KeyError: pass if hasattr(outqueue, '_reader'): debug('ensuring that outqueue is not full') # If we don't make room available in outqueue then # attempts to add the sentinel (None) to outqueue may # block. There is guaranteed to be no more than 2 sentinels. try: for i in range(10): if not outqueue._reader.poll(): break get() except (IOError, EOFError): pass debug('result handler exiting: len(cache)=%s, thread._state=%s', len(cache), thread._state) @staticmethod def _get_tasks(func, it, size): it = iter(it) while 1: x = tuple(itertools.islice(it, size)) if not x: return yield (func, x) def __reduce__(self): raise NotImplementedError( 'pool objects cannot be passed between processes or pickled' ) def close(self): debug('closing pool') if self._state == RUN: self._state = CLOSE self._worker_handler._state = CLOSE def terminate(self): debug('terminating pool') self._state = TERMINATE self._worker_handler._state = TERMINATE self._terminate() def join(self): debug('joining pool') assert self._state in (CLOSE, TERMINATE) self._worker_handler.join() self._task_handler.join() self._result_handler.join() for p in self._pool: p.join() @staticmethod def _help_stuff_finish(inqueue, task_handler, size): # task_handler may be blocked trying to put items on inqueue debug('removing tasks from inqueue until task handler finished') inqueue._rlock.acquire() while task_handler.is_alive() and inqueue._reader.poll(): inqueue._reader.recv() time.sleep(0) @classmethod def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool, worker_handler, task_handler, result_handler, cache): # this is guaranteed to only be called once debug('finalizing pool') worker_handler._state = TERMINATE task_handler._state = TERMINATE debug('helping task handler/workers to finish') cls._help_stuff_finish(inqueue, task_handler, len(pool)) assert result_handler.is_alive() or len(cache) == 0 result_handler._state = TERMINATE outqueue.put(None) # sentinel # We must wait for the worker handler to exit before terminating # workers because we don't want workers to be restarted behind our back. debug('joining worker handler') if threading.current_thread() is not worker_handler: worker_handler.join() # Terminate workers which haven't already finished. if pool and hasattr(pool[0], 'terminate'): debug('terminating workers') for p in pool: if p.exitcode is None: p.terminate() debug('joining task handler') if threading.current_thread() is not task_handler: task_handler.join() debug('joining result handler') if threading.current_thread() is not result_handler: result_handler.join() if pool and hasattr(pool[0], 'terminate'): debug('joining pool workers') for p in pool: if p.is_alive(): # worker has not yet exited debug('cleaning up worker %d' % p.pid) p.join() def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.terminate() # # Class whose instances are returned by `Pool.apply_async()` # class ApplyResult(object): def __init__(self, cache, callback, error_callback): self._event = threading.Event() self._job = next(job_counter) self._cache = cache self._callback = callback self._error_callback = error_callback cache[self._job] = self def ready(self): return self._event.is_set() def successful(self): assert self.ready() return self._success def wait(self, timeout=None): self._event.wait(timeout) def get(self, timeout=None): self.wait(timeout) if not self.ready(): raise TimeoutError if self._success: return self._value else: raise self._value def _set(self, i, obj): self._success, self._value = obj if self._callback and self._success: self._callback(self._value) if self._error_callback and not self._success: self._error_callback(self._value) self._event.set() del self._cache[self._job] AsyncResult = ApplyResult # create alias -- see #17805 # # Class whose instances are returned by `Pool.map_async()` # class MapResult(ApplyResult): def __init__(self, cache, chunksize, length, callback, error_callback): ApplyResult.__init__(self, cache, callback, error_callback=error_callback) self._success = True self._value = [None] * length self._chunksize = chunksize if chunksize <= 0: self._number_left = 0 self._event.set() del cache[self._job] else: self._number_left = length//chunksize + bool(length % chunksize) def _set(self, i, success_result): success, result = success_result if success: self._value[i*self._chunksize:(i+1)*self._chunksize] = result self._number_left -= 1 if self._number_left == 0: if self._callback: self._callback(self._value) del self._cache[self._job] self._event.set() else: self._success = False self._value = result if self._error_callback: self._error_callback(self._value) del self._cache[self._job] self._event.set() # # Class whose instances are returned by `Pool.imap()` # class IMapIterator(object): def __init__(self, cache): self._cond = threading.Condition(threading.Lock()) self._job = next(job_counter) self._cache = cache self._items = collections.deque() self._index = 0 self._length = None self._unsorted = {} cache[self._job] = self def __iter__(self): return self def next(self, timeout=None): self._cond.acquire() try: try: item = self._items.popleft() except IndexError: if self._index == self._length: raise StopIteration self._cond.wait(timeout) try: item = self._items.popleft() except IndexError: if self._index == self._length: raise StopIteration raise TimeoutError finally: self._cond.release() success, value = item if success: return value raise value __next__ = next # XXX def _set(self, i, obj): self._cond.acquire() try: if self._index == i: self._items.append(obj) self._index += 1 while self._index in self._unsorted: obj = self._unsorted.pop(self._index) self._items.append(obj) self._index += 1 self._cond.notify() else: self._unsorted[i] = obj if self._index == self._length: del self._cache[self._job] finally: self._cond.release() def _set_length(self, length): self._cond.acquire() try: self._length = length if self._index == self._length: self._cond.notify() del self._cache[self._job] finally: self._cond.release() # # Class whose instances are returned by `Pool.imap_unordered()` # class IMapUnorderedIterator(IMapIterator): def _set(self, i, obj): self._cond.acquire() try: self._items.append(obj) self._index += 1 self._cond.notify() if self._index == self._length: del self._cache[self._job] finally: self._cond.release() # # # class ThreadPool(Pool): from .dummy import Process def __init__(self, processes=None, initializer=None, initargs=()): Pool.__init__(self, processes, initializer, initargs) def _setup_queues(self): self._inqueue = queue.Queue() self._outqueue = queue.Queue() self._quick_put = self._inqueue.put self._quick_get = self._outqueue.get @staticmethod def _help_stuff_finish(inqueue, task_handler, size): # put sentinels at head of inqueue to make workers finish inqueue.not_empty.acquire() try: inqueue.queue.clear() inqueue.queue.extend([None] * size) inqueue.not_empty.notify_all() finally: inqueue.not_empty.release()
agpl-3.0
[ 3, 199, 3, 5673, 13070, 314, 658, 5453, 64, 1021, 367, 28453, 282, 2112, 4203, 199, 3, 199, 3, 12866, 15, 2293, 14, 647, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 199, 199, 363, 452, 363, 275, 788, 5453, 418, 199, 199, 3, 199, 3, 24339, 199, 3, 199, 199, 646, 5796, 199, 646, 4126, 199, 646, 7975, 199, 646, 5055, 199, 646, 900, 199, 199, 504, 12866, 492, 7132, 12, 5033, 63, 835, 12, 31886, 199, 504, 12866, 14, 1974, 492, 21789, 794, 12, 3105, 199, 199, 3, 199, 3, 22296, 6144, 314, 1174, 402, 282, 4203, 199, 3, 199, 199, 9390, 275, 378, 199, 18219, 275, 413, 199, 28376, 1951, 275, 499, 199, 199, 3, 199, 3, 12481, 19549, 199, 3, 199, 199, 2423, 63, 5337, 275, 7975, 14, 835, 342, 199, 199, 318, 2341, 7848, 8, 589, 304, 272, 372, 769, 8, 1130, 2031, 589, 430, 199, 199, 318, 14664, 1130, 7848, 8, 589, 304, 272, 372, 769, 8, 17691, 14, 7848, 1130, 8, 589, 59, 16, 467, 1249, 59, 17, 2459, 199, 199, 3, 199, 3, 5495, 1255, 701, 7239, 10358, 199, 3, 199, 199, 533, 23038, 7630, 547, 8, 1726, 304, 272, 408, 55, 8146, 3962, 625, 8092, 461, 2552, 12, 880, 2985, 883, 506, 272, 19353, 4847, 4012, 314, 2838, 1041, 339, 347, 636, 826, 721, 277, 12, 3178, 12, 574, 304, 267, 291, 14, 2804, 275, 4700, 8, 2804, 9, 267, 291, 14, 585, 275, 4700, 8, 585, 9, 267, 1613, 8, 15586, 1235, 7630, 547, 12, 291, 2843, 826, 721, 277, 14, 2804, 12, 291, 14, 585, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 547, 10209, 754, 26, 1543, 83, 1370, 799, 2660, 26, 1543, 83, 4065, 450, 334, 277, 14, 585, 12, 18193, 291, 14, 2804, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 15586, 1235, 7630, 547, 26, 450, 83, 4335, 450, 620, 8, 277, 9, 421, 199, 318, 7239, 8, 262, 1825, 12, 734, 1825, 12, 11130, 29, 403, 12, 4205, 589, 16729, 610, 400, 813, 83, 29, 403, 304, 272, 702, 610, 400, 813, 83, 365, 488, 503, 334, 466, 8, 391, 400, 813, 83, 9, 508, 1109, 436, 610, 400, 813, 83, 690, 378, 9, 272, 5324, 275, 734, 1825, 14, 524, 272, 664, 275, 315, 1825, 14, 362, 272, 340, 2688, 8, 262, 1825, 12, 2513, 5491, 735, 267, 315, 1825, 423, 5491, 14, 1600, 342, 267, 734, 1825, 423, 5503, 14, 1600, 342, 339, 340, 11130, 365, 440, 488, 26, 267, 11130, 2031, 826, 589, 9, 339, 9709, 275, 378, 272, 1830, 610, 400, 813, 83, 365, 488, 503, 334, 391, 400, 813, 83, 436, 9709, 665, 610, 400, 813, 83, 304, 267, 862, 26, 288, 2120, 275, 664, 342, 267, 871, 334, 13178, 547, 12, 5925, 304, 288, 3105, 360, 6599, 4788, 21157, 503, 5925, 1553, 24234, 358, 288, 2059, 398, 340, 2120, 365, 488, 26, 288, 3105, 360, 6599, 4788, 13792, 1553, 24234, 358, 288, 2059, 398, 3906, 12, 284, 12, 2562, 12, 1249, 12, 16286, 275, 2120, 267, 862, 26, 288, 754, 275, 334, 549, 12, 2562, 2031, 589, 12, 1011, 10340, 430, 267, 871, 2186, 465, 325, 26, 288, 754, 275, 334, 797, 12, 325, 9, 267, 862, 26, 288, 5324, 1332, 2423, 12, 284, 12, 754, 430, 267, 871, 2186, 465, 325, 26, 288, 8072, 275, 23038, 7630, 547, 8, 69, 12, 754, 59, 17, 566, 288, 3105, 480, 28096, 2644, 1125, 1830, 10209, 754, 26, 450, 83, 2, 450, 334, 355, 8072, 430, 288, 5324, 1332, 2423, 12, 284, 12, 334, 797, 12, 8072, 1724, 267, 9709, 847, 413, 272, 3105, 360, 6599, 24234, 2410, 450, 68, 6527, 7, 450, 9709, 9, 199, 199, 3, 199, 3, 8089, 6144, 282, 2112, 4203, 199, 3, 199, 199, 533, 15553, 8, 785, 304, 272, 1449, 272, 8089, 1314, 5171, 376, 5316, 1015, 402, 18876, 3423, 370, 2368, 14, 272, 1449, 272, 7132, 275, 7132, 339, 347, 636, 826, 721, 277, 12, 10358, 29, 403, 12, 11130, 29, 403, 12, 4205, 589, 16729, 326, 610, 400, 813, 83, 529, 1739, 29, 403, 304, 267, 291, 423, 2758, 63, 18849, 342, 267, 291, 423, 1765, 1825, 275, 4126, 14, 3737, 342, 267, 291, 423, 1637, 275, 1052, 267, 291, 423, 929, 275, 21277, 267, 291, 423, 391, 400, 813, 83, 529, 1739, 275, 610, 400, 813, 83, 529, 1739, 267, 291, 423, 6498, 275, 11130, 267, 291, 423, 826, 589, 275, 4205, 589, 398, 340, 10358, 365, 488, 26, 288, 862, 26, 355, 10358, 275, 5033, 63, 835, 342, 288, 871, 4279, 26, 355, 10358, 275, 413, 267, 340, 10358, 665, 413, 26, 288, 746, 1722, 480, 3259, 402, 10358, 1471, 506, 737, 5210, 413, 531, 398, 340, 11130, 365, 440, 488, 436, 440, 4550, 8, 6498, 304, 288, 746, 3146, 360, 6498, 1471, 506, 282, 4550, 358, 398, 291, 423, 11816, 275, 10358, 267, 291, 423, 2293, 275, 942, 267, 291, 423, 1155, 411, 5434, 63, 2293, 342, 398, 291, 423, 6599, 63, 2232, 275, 5796, 14, 4436, 8, 288, 1347, 29, 5453, 423, 2479, 63, 11009, 12, 288, 1249, 2687, 277, 12, 776, 288, 776, 267, 291, 423, 6599, 63, 2232, 14, 10824, 275, 715, 267, 291, 423, 6599, 63, 2232, 423, 929, 275, 21277, 267, 291, 423, 6599, 63, 2232, 14, 928, 342, 7318, 291, 423, 1765, 63, 2232, 275, 5796, 14, 4436, 8, 288, 1347, 29, 5453, 423, 2479, 63, 5054, 12, 288, 1249, 2687, 277, 423, 1765, 1825, 12, 291, 423, 13239, 63, 524, 12, 291, 423, 548, 1825, 12, 291, 423, 2293, 9, 288, 776, 267, 291, 423, 1765, 63, 2232, 14, 10824, 275, 715, 267, 291, 423, 1765, 63, 2232, 423, 929, 275, 21277, 267, 291, 423, 1765, 63, 2232, 14, 928, 342, 398, 291, 423, 1099, 63, 2232, 275, 5796, 14, 4436, 8, 288, 1347, 29, 5453, 423, 2479, 63, 2604, 12, 288, 1249, 2687, 277, 423, 548, 1825, 12, 291, 423, 13239, 63, 362, 12, 291, 423, 1637, 9 ]
[ 199, 3, 5673, 13070, 314, 658, 5453, 64, 1021, 367, 28453, 282, 2112, 4203, 199, 3, 199, 3, 12866, 15, 2293, 14, 647, 199, 3, 199, 3, 1898, 334, 67, 9, 8315, 13, 9300, 12, 820, 593, 1181, 2570, 75, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 199, 199, 363, 452, 363, 275, 788, 5453, 418, 199, 199, 3, 199, 3, 24339, 199, 3, 199, 199, 646, 5796, 199, 646, 4126, 199, 646, 7975, 199, 646, 5055, 199, 646, 900, 199, 199, 504, 12866, 492, 7132, 12, 5033, 63, 835, 12, 31886, 199, 504, 12866, 14, 1974, 492, 21789, 794, 12, 3105, 199, 199, 3, 199, 3, 22296, 6144, 314, 1174, 402, 282, 4203, 199, 3, 199, 199, 9390, 275, 378, 199, 18219, 275, 413, 199, 28376, 1951, 275, 499, 199, 199, 3, 199, 3, 12481, 19549, 199, 3, 199, 199, 2423, 63, 5337, 275, 7975, 14, 835, 342, 199, 199, 318, 2341, 7848, 8, 589, 304, 272, 372, 769, 8, 1130, 2031, 589, 430, 199, 199, 318, 14664, 1130, 7848, 8, 589, 304, 272, 372, 769, 8, 17691, 14, 7848, 1130, 8, 589, 59, 16, 467, 1249, 59, 17, 2459, 199, 199, 3, 199, 3, 5495, 1255, 701, 7239, 10358, 199, 3, 199, 199, 533, 23038, 7630, 547, 8, 1726, 304, 272, 408, 55, 8146, 3962, 625, 8092, 461, 2552, 12, 880, 2985, 883, 506, 272, 19353, 4847, 4012, 314, 2838, 1041, 339, 347, 636, 826, 721, 277, 12, 3178, 12, 574, 304, 267, 291, 14, 2804, 275, 4700, 8, 2804, 9, 267, 291, 14, 585, 275, 4700, 8, 585, 9, 267, 1613, 8, 15586, 1235, 7630, 547, 12, 291, 2843, 826, 721, 277, 14, 2804, 12, 291, 14, 585, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 547, 10209, 754, 26, 1543, 83, 1370, 799, 2660, 26, 1543, 83, 4065, 450, 334, 277, 14, 585, 12, 18193, 291, 14, 2804, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 15586, 1235, 7630, 547, 26, 450, 83, 4335, 450, 620, 8, 277, 9, 421, 199, 318, 7239, 8, 262, 1825, 12, 734, 1825, 12, 11130, 29, 403, 12, 4205, 589, 16729, 610, 400, 813, 83, 29, 403, 304, 272, 702, 610, 400, 813, 83, 365, 488, 503, 334, 466, 8, 391, 400, 813, 83, 9, 508, 1109, 436, 610, 400, 813, 83, 690, 378, 9, 272, 5324, 275, 734, 1825, 14, 524, 272, 664, 275, 315, 1825, 14, 362, 272, 340, 2688, 8, 262, 1825, 12, 2513, 5491, 735, 267, 315, 1825, 423, 5491, 14, 1600, 342, 267, 734, 1825, 423, 5503, 14, 1600, 342, 339, 340, 11130, 365, 440, 488, 26, 267, 11130, 2031, 826, 589, 9, 339, 9709, 275, 378, 272, 1830, 610, 400, 813, 83, 365, 488, 503, 334, 391, 400, 813, 83, 436, 9709, 665, 610, 400, 813, 83, 304, 267, 862, 26, 288, 2120, 275, 664, 342, 267, 871, 334, 13178, 547, 12, 5925, 304, 288, 3105, 360, 6599, 4788, 21157, 503, 5925, 1553, 24234, 358, 288, 2059, 398, 340, 2120, 365, 488, 26, 288, 3105, 360, 6599, 4788, 13792, 1553, 24234, 358, 288, 2059, 398, 3906, 12, 284, 12, 2562, 12, 1249, 12, 16286, 275, 2120, 267, 862, 26, 288, 754, 275, 334, 549, 12, 2562, 2031, 589, 12, 1011, 10340, 430, 267, 871, 2186, 465, 325, 26, 288, 754, 275, 334, 797, 12, 325, 9, 267, 862, 26, 288, 5324, 1332, 2423, 12, 284, 12, 754, 430, 267, 871, 2186, 465, 325, 26, 288, 8072, 275, 23038, 7630, 547, 8, 69, 12, 754, 59, 17, 566, 288, 3105, 480, 28096, 2644, 1125, 1830, 10209, 754, 26, 450, 83, 2, 450, 334, 355, 8072, 430, 288, 5324, 1332, 2423, 12, 284, 12, 334, 797, 12, 8072, 1724, 267, 9709, 847, 413, 272, 3105, 360, 6599, 24234, 2410, 450, 68, 6527, 7, 450, 9709, 9, 199, 199, 3, 199, 3, 8089, 6144, 282, 2112, 4203, 199, 3, 199, 199, 533, 15553, 8, 785, 304, 272, 1449, 272, 8089, 1314, 5171, 376, 5316, 1015, 402, 18876, 3423, 370, 2368, 14, 272, 1449, 272, 7132, 275, 7132, 339, 347, 636, 826, 721, 277, 12, 10358, 29, 403, 12, 11130, 29, 403, 12, 4205, 589, 16729, 326, 610, 400, 813, 83, 529, 1739, 29, 403, 304, 267, 291, 423, 2758, 63, 18849, 342, 267, 291, 423, 1765, 1825, 275, 4126, 14, 3737, 342, 267, 291, 423, 1637, 275, 1052, 267, 291, 423, 929, 275, 21277, 267, 291, 423, 391, 400, 813, 83, 529, 1739, 275, 610, 400, 813, 83, 529, 1739, 267, 291, 423, 6498, 275, 11130, 267, 291, 423, 826, 589, 275, 4205, 589, 398, 340, 10358, 365, 488, 26, 288, 862, 26, 355, 10358, 275, 5033, 63, 835, 342, 288, 871, 4279, 26, 355, 10358, 275, 413, 267, 340, 10358, 665, 413, 26, 288, 746, 1722, 480, 3259, 402, 10358, 1471, 506, 737, 5210, 413, 531, 398, 340, 11130, 365, 440, 488, 436, 440, 4550, 8, 6498, 304, 288, 746, 3146, 360, 6498, 1471, 506, 282, 4550, 358, 398, 291, 423, 11816, 275, 10358, 267, 291, 423, 2293, 275, 942, 267, 291, 423, 1155, 411, 5434, 63, 2293, 342, 398, 291, 423, 6599, 63, 2232, 275, 5796, 14, 4436, 8, 288, 1347, 29, 5453, 423, 2479, 63, 11009, 12, 288, 1249, 2687, 277, 12, 776, 288, 776, 267, 291, 423, 6599, 63, 2232, 14, 10824, 275, 715, 267, 291, 423, 6599, 63, 2232, 423, 929, 275, 21277, 267, 291, 423, 6599, 63, 2232, 14, 928, 342, 7318, 291, 423, 1765, 63, 2232, 275, 5796, 14, 4436, 8, 288, 1347, 29, 5453, 423, 2479, 63, 5054, 12, 288, 1249, 2687, 277, 423, 1765, 1825, 12, 291, 423, 13239, 63, 524, 12, 291, 423, 548, 1825, 12, 291, 423, 2293, 9, 288, 776, 267, 291, 423, 1765, 63, 2232, 14, 10824, 275, 715, 267, 291, 423, 1765, 63, 2232, 423, 929, 275, 21277, 267, 291, 423, 1765, 63, 2232, 14, 928, 342, 398, 291, 423, 1099, 63, 2232, 275, 5796, 14, 4436, 8, 288, 1347, 29, 5453, 423, 2479, 63, 2604, 12, 288, 1249, 2687, 277, 423, 548, 1825, 12, 291, 423, 13239, 63, 362, 12, 291, 423, 1637, 9, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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*- # # This file is part of JSONAlchemy. # Copyright (C) 2013, 2014, 2015 CERN. # # JSONAlchemy 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. # # JSONAlchemy 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 JSONAlchemy; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """JSONAlchemy wrappers.""" import copy import re import six from collections import MutableMapping from six import iteritems class SmartDict(object): """This dictionary allows to do some 'smart queries' to its content. Example: .. code-block:: python >>> d = SmartDict() >>> d['foo'] = {'a': 'world', 'b':'hello'} >>> d['a'] = [ {'b':1}, {'b':2}, {'b':3} ] >>> d['a'] [ {'b':1}, {'b':2}, {'b':3} ] >>> d['a[0]'] {'b':1} >>> d['a.b'] [1,2,3] >>> d['a[1:]'] [{'b':2}, {'b':3}] .. note:: You can't use the reserved words '.', '[', ']' like a key. .. code-block:: python >>> d['.'] >>> d[']'] >>> d['.a'] It is also not recommended initialize `SmartDict` with keys from within the list of reserved words. .. code-block:: python >>> d = SmartDict({'a': 3, 'b': {'.': 5}}) """ split_key_pattern = re.compile('\.|\[') main_key_pattern = re.compile('\..*|\[.*') def __init__(self, d=None): self._dict = d if d is not None else dict() def __getitem__(self, key): """Return item as `dict.__getitem__` but using 'smart queries'. .. note:: Accessing one value in a normal way, meaning d['a'], is almost as fast as accessing a regular dictionary. But using the special name convention is a bit slower than using the regular access: .. code-block:: python >>> %timeit x = dd['a[0].b'] 100000 loops, best of 3: 3.94 us per loop >>> %timeit x = dd['a'][0]['b'] 1000000 loops, best of 3: 598 ns per loop """ def getitem(k, v): if isinstance(v, dict): return v[k] elif ']' in k: k = k[:-1].replace('n', '-1') # Work around for list indexes and slices try: return v[int(k)] except ValueError: return v[slice(*map( lambda x: int(x.strip()) if x.strip() else None, k.split(':') ))] else: tmp = [] for inner_v in v: tmp.append(getitem(k, inner_v)) return tmp # Check if we are using python regular keys try: return self._dict[key] except KeyError: pass keys = SmartDict.split_key_pattern.split(key) value = self._dict for k in keys: value = getitem(k, value) return value def __setitem__(self, key, value, extend=False, **kwargs): # check if the key is composed only by special chars if key[0] in ['.', ']', '[']: # this kind of key is not supported! raise KeyError if '.' not in key and ']' not in key and not extend: self._dict[key] = value else: keys = SmartDict.split_key_pattern.split(key) self.__setitem(self._dict, keys[0], keys[1:], value, extend) def __delitem__(self, key): """Delete item only from first level dictionary keys.""" del self._dict[key] def __contains__(self, key): if '.' not in key and '[' not in key: return key in self._dict try: self[key] except: return False return True def __eq__(self, other): return (isinstance(other, self.__class__) and self._dict == other._dict) def __iter__(self): return iter(self._dict) def __len__(self): return len(self._dict) def keys(self): return self._dict.keys() def items(self): return self._dict.items() def iteritems(self): """Proxy to `dict.iteritems`.""" return iteritems(self._dict) def iterkeys(self): """Proxy to `dict.iterkeys`.""" return self._dict.iterkeys() def itervalues(self): """Proxy to `dict.itervalues`.""" return self._dict.itervalues() def has_key(self, key): """Return ``True`` if ``key`` is in dictionary.""" return key in self def __repr__(self): """Proxy to `dict.__repr__`.""" return repr(self._dict) def __setitem(self, chunk, key, keys, value, extend=False): """Helper function to fill up the dictionary.""" def setitem(chunk): if keys: return self.__setitem(chunk, keys[0], keys[1:], value, extend) else: return value if key in ['.', ']']: chunk[key] = value elif ']' in key: # list key = int(key[:-1].replace('n', '-1')) if extend: if chunk is None: chunk = [None, ] else: if not isinstance(chunk, list): chunk = [chunk, ] if key != -1: chunk.insert(key, None) else: chunk.append(None) else: if chunk is None: chunk = [None, ] chunk[key] = setitem(chunk[key]) else: # dict if extend: if chunk is None: chunk = {} chunk[key] = None chunk[key] = setitem(chunk[key]) elif key not in chunk: chunk[key] = None chunk[key] = setitem(chunk[key]) else: if keys: chunk[key] = setitem(chunk[key]) else: if not isinstance(chunk[key], list): chunk[key] = [chunk[key], ] chunk[key].append(None) chunk[key][-1] = setitem(chunk[key][-1]) else: if chunk is None: chunk = {} if key not in chunk: chunk[key] = None chunk[key] = setitem(chunk[key]) return chunk def get(self, key, default=None): """Return value for given ``key`` or ``default`` value.""" try: return self[key] except KeyError: return default def set(self, key, value, extend=False, **kwargs): """Extended standard set function.""" self.__setitem__(key, value, extend, **kwargs) def update(self, E, **F): """Proxy `dict` update method.""" self._dict.update(E, **F) MutableMapping.register(SmartDict) class DotableDict(dict): """Make nested python dictionaries accessable using dot notation. Example: .. code-block:: python >>> dotable = DotableDict({'a': [{'b': 3, 'c': 5}]}) >>> dotable.a ... [{'b': 3, 'c': 5}] """ def __getattr__(self, key): """Return value from dictionary. .. todo:: allow ``dotable.a[0].b`` """ return self[key] def __setattr__(self, key, value): """Set value for given key in dictionary.""" self[key] = value class SmartJson(SmartDict): """Base class for Json structures.""" def __init__(self, json=None, set_default_values=False, process_model_info=False, metadata=None, **kwargs): """If no JSON, a new structure will be created. Typically the JSON structure needs a few mandatory fields and subfields that are created here, the final JSON should look like this:: { '__meta_metadata__': { '__additional_info__': {...}, '__model_info__': {'model_names': [...], ....}, '__aliases__': {...}, '__errors__': [...], '__continuable_errors__': [] } } The content of `__additional_info__` is, usually, the content of kwargs. This object maintains two different dictionaries, one with the pure JSON representation, `_dict` and a second one with the BSON representation of the former. This behavior helps whenever dealing with JSON databases as MongoDB or PostgreSQL. The content of the BSON dictionary is typically the same as in the JSON one, only if the `json` section is described in the definition of the field the content might change, a good example of this behavior are the date fields. See :class:`~.jsonext.parsers.json_extra_parser:JsonExtraParser`. :param json: JSON to build the dictionary. :param set_defaul_values: If `True` default values will be set. :param process_model_info: If `True` all model info will be parsed. :param kwargs: Everything that would be useful inside `__additional_info__`. Although it could be used also for: * `model=['model1', 'model2']`, in this case this key will be deleted from `kwargs` and used as model names inside `__model_info__`. """ super(SmartJson, self).__init__(json) self._dict_bson = SmartDict() self._metadata = metadata self._model_parser = None if not json or '__meta_metadata__' not in json: model_names = kwargs.get('model', ['__default__', ]) if 'model' in kwargs: del kwargs['model'] if isinstance(model_names, six.string_types): model_names = [model_names, ] self._dict['__meta_metadata__'] = dict() self._dict['__meta_metadata__']['__additional_info__'] = kwargs self._dict['__meta_metadata__']['__model_info__'] = \ dict(names=model_names) self._dict['__meta_metadata__']['__aliases__'] = dict() self._dict['__meta_metadata__']['__errors__'] = list() self._dict['__meta_metadata__']['__continuable_errors__'] = list() if process_model_info: self.metadata.reader.process_model_info(self) if set_default_values: self.set_default_values() @property def metadata(self): if self._metadata is None: raise RuntimeError("SmartJSON has no binded metadata.") return self._metadata def bind(self, metadata): self._metadata = metadata @property def reader(self): if getattr(self, '_reader', None) is None: cls = self.metadata.readers[self.additional_info['master_format']] self._reader = cls(self, blob=self._dict_bson, metadata=self.metadata) return self._reader @property def additional_info(self): """Shortcut to `__meta_metadata__.__additional_info__`.""" return DotableDict(self['__meta_metadata__']['__additional_info__']) @property def errors(self): """Shortcut to `__meta_metadata__.__errors__`.""" return self._dict['__meta_metadata__']['__errors__'] @property def continuable_errors(self): """Shortcut to `__meta_metadata__.__continuable_errors__`.""" return self._dict['__meta_metadata__']['__continuable_errors__'] @property def meta_metadata(self): """Shortcut to `__meta_metadata__`.""" return DotableDict(self._dict['__meta_metadata__']) @property def model_info(self): """Shortcut to `__meta_metadata__.__model_info__`.""" return DotableDict(self._dict['__meta_metadata__']['__model_info__']) def __getitem__(self, key, reset=False, **kwargs): """Like in `dict.__getitem__`. First it tries to load the value from the value from the BSON object, if it fails, or reset is set to `True`, looks into the JSON object for the `key`, applies all the extensions and decorators and return the value that is stored in the BSON object as a cached version. If the key is not found inside the dictionary, it tries before raising `KeyError` to figure out if it is dealing with an alias. :param key: :param reset: If the key corresponds to a field calculated on the fly the value will be calculated again. :param kwargs: Typically used to set: * `action`, Whether we are performing a `set` or a `get`. *`exclude`, from the list of extensions and decorators excludes the ones that are not required. :return: Like in `dict.__getitem__` """ try: value = self._dict_bson[key] if value and not reset: return value except KeyError: # Try to find the key inside the json dict and load it pass main_key = SmartDict.main_key_pattern.sub('', key) if main_key == '__meta_metadata__': return super(SmartJson, self).__getitem__(key) elif main_key in self._dict: if main_key not in self.meta_metadata: self.reader.set(main_key) action = kwargs.get('action', 'get') exclude = kwargs.get('exclude', []) if 'extensions' not in exclude: for ext, args in \ six.iteritems(self.meta_metadata[main_key]['ext']): if ext in exclude: continue self.metadata.field_extensions[ext].evaluate( self, main_key, action, args) if 'decorators' not in exclude: for ext, args in \ six.iteritems(self.meta_metadata[main_key]['after']): if ext in exclude: continue self.metadata.decorator_after_extensions[ext].evaluate( self, main_key, action, args) return self._dict_bson[key] else: try: rest_of_key = SmartDict.main_key_pattern.findall(key)[0] except IndexError: rest_of_key = '' return self[ self._dict['__meta_metadata__']['__aliases__'][main_key] + rest_of_key] def __setitem__(self, key, value, extend=False, **kwargs): """Like in `dict.__setitem__`. There are two possible scenarios, i) the key is already present in the dictionary (also its metadata), therefore a simple set in the first step, ii) or the key is not inside the dictionary, in this case the metadata for the field is fetched before performing the rest of the actions. Like in `__getitem__` after setting the value to the BSON dictionary the decorators and the extensions are evaluated and, if needed, the JSON representation of `value` is set into the JSON dictionary. :param key: :param value: :param extend: If `False` it behaves as `ditc.__setitem__`, if `True` creates a list with the previous content and append `value` to it. :param kwargs:Typically used to set: * `action`, Whether we are performing a `set` or a `get`. *`exclude`, from the list of extensions and decorators excludes the ones that are not required. """ main_key = SmartDict.main_key_pattern.sub('', key) # If we have meta_metadata for the main key go ahead if main_key in self.meta_metadata: self._dict_bson.__setitem__(key, value, extend) # Othewise we need the meta_metadata else: self.reader.set(main_key) self._dict_bson.__setitem__(key, value, extend, **kwargs) action = kwargs.get('action', 'set') exclude = kwargs.get('exclude', []) if 'decorators' not in exclude: for ext, args in \ six.iteritems(self.meta_metadata[main_key]['after']): if ext in exclude: continue self.metadata.decorator_after_extensions[ext].evaluate( self, main_key, action, args) if 'extensions' not in exclude: for ext, args in \ six.iteritems(self.meta_metadata[main_key]['ext']): if ext in exclude: continue self.metadata.field_extensions[ext].evaluate( self, main_key, action, args) def __str__(self): """Representation of the object **without** the meta_metadata.""" return self.dumps(without_meta_metadata=True).__str__() def __repr__(self): """Full string representation of the JSON object.""" return self._dict.__repr__() def __delitem__(self, key): """Delete on key from the dictionary and its meta_metadata. Note: It only works with default python keys """ self._dict.__delitem__(key) del self._dict['__meta_metadata__'][key] try: del self._dict_bson[key] except KeyError: pass def get(self, key, default=None, reset=False, **kwargs): """Like in `dict.get`.""" try: return self.__getitem__(key, reset, **kwargs) except (KeyError, IndexError): return default def items(self, without_meta_metadata=False): """Like in `dict.items`.""" for key in self.keys(): if key == '__meta_metadata__' and without_meta_metadata: continue yield (key, self[key]) iteritems = items def keys(self, without_meta_metadata=False): """Like in `dict.keys`.""" for key in super(SmartJson, self).keys(): if key == '__meta_metadata__' and without_meta_metadata: continue yield key def get_blob(self, *args, **kwargs): """To be override in the specific class. Should look for the original version of the file where the json came from. """ raise NotImplementedError() def dumps(self, without_meta_metadata=False, with_calculated_fields=False, clean=False, keywords=None, filter_hidden=False): """Create the JSON friendly representation of the current object. :param without_meta_metadata: by default ``False``, if set to ``True`` all the ``__meta_metadata__`` will be removed from the output. :param wit_calculated_fields: by default the calculated fields are not dump, if they are needed in the output set it to ``True`` :param clean: if set to ``True`` all the keys stating with ``_`` will be removed from the ouput :param keywords: list of keywords to dump. if None, return all :return: JSON friendly object """ dict_ = copy.copy(self._dict) filter_keywords = keywords is not None and any(keywords) if without_meta_metadata: del dict_['__meta_metadata__'] # skip the dict iteration if not any([clean, filter_keywords, filter_hidden, with_calculated_fields]): return dict_ for key, value in six.iteritems(self._dict): if (clean and key.startswith('_')) or ( filter_keywords and key not in keywords) or ( filter_hidden and self.meta_metadata.get(key, {}).get( 'hidden', False)): del dict_[key] continue if with_calculated_fields: if value is None and \ self.meta_metadata[key]['type'] == 'calculated': dict_[key] = self[key] return dict_ def loads(self, without_meta_metadata=False, with_calculated_fields=True, clean=False): """Create the BSON representation of the current object. :param without_meta_metadata: if set to ``True`` all the ``__meta_metadata__`` will be removed from the output. :param wit_calculated_fields: by default the calculated fields are in the output, if they are not needed set it to ``False`` :param clean: if set to ``True`` all the keys stating with ``_`` will be removed from the ouput :return: JSON friendly object """ dict_ = dict() for key in self.keys(): dict_[key] = self[key] if without_meta_metadata: del dict_['__meta_metadata__'] if not with_calculated_fields: for key in self.keys(): if self.meta_metadata[key]['type'] == 'calculated': del dict_[key] if clean: for key in list(dict_.keys()): if key.startswith('_'): del dict_[key] return dict_ def produce(self, producer_code, fields=None): """Create a different flavor of `JSON` depending on `procuder_code`. :param producer_code: One of the possible producers listed in the `producer` section inside the field definitions. :param fields: List of fields that should be present in the output, if `None` all fields from `self` will be used. :return: It depends on each producer, see producer folder inside `jsonext`, typically `dict`. """ return self.metadata.producers[producer_code](self, fields=fields) def set_default_values(self, fields=None): """Set default value for the fields using the schema definition. :param fields: List of fields to set the default value, if `None` all. """ raise NotImplementedError('Missing implementation in this version') def validate(self, validator=None): """Validate using current JSON content using Cerberus. See: (Cerberus)[http://cerberus.readthedocs.org/en/latest]. :param validator: Validator to be used, if `None` :class:`~.validator.Validator` """ if validator is None: from .validator import Validator as validator schema = dict() model_fields = self.metadata.model_parser.resolve_models( self.model_info.names, # self.additional_info.namespace ).get('fields', {}) for field in self.keys(): if not field == '__meta_metadata__' and \ field not in model_fields and \ self.meta_metadata[field]['json_id'] not in model_fields: model_fields[field] = self.meta_metadata[field]['json_id'] for json_id in model_fields.keys(): try: schema.update( self.metadata.model_parser.field_parser. field_definitions[json_id].get( 'schema', {})) except (TypeError, KeyError): pass _validator = validator(schema=schema) _validator.validate(self) return _validator.errors class SmartJsonLD(SmartJson): """Utility class for JSON-LD serialization.""" def translate(self, context_name, context): """Translate object to fit given JSON-LD context. Should not inject context as this will be done at publication time. """ raise NotImplementedError('Translation not required') def get_context(self, context): """Return the context definition identified by the parameter. If the context is not found in the current namespace, the received parameter is returned as is, the assumption being that a IRI was passed. :param context: context identifier """ return self.metadata.contexts.get(context, context) def get_jsonld(self, context, new_context={}, format="full"): """Return the JSON-LD serialization. :param: context the context to use for raw publishing; each SmartJsonLD instance is expected to have a default context associated. :param: new_context the context to use for formatted publishing, usually supplied by the client; used by the 'compacted', 'framed', and 'normalized' formats. :param: format the publishing format; can be 'full', 'inline', 'compacted', 'expanded', 'flattened', 'framed' or 'normalized'. Note that 'full' and 'inline' are synonims, referring to the document form which includes the context; for more information see: [http://www.w3.org/TR/json-ld/] """ from pyld import jsonld if isinstance(context, six.string_types): ctx = self.get_context(context) elif isinstance(context, dict): ctx = context else: raise TypeError('JSON-LD context must be a string or dictionary') try: doc = self.translate(context, ctx) except NotImplementedError: # model does not require translation doc = self.dumps(clean=True) doc["@context"] = ctx if format in ["full", "inline"]: return doc if format == "compacted": return jsonld.compact(doc, new_context) elif format == "expanded": return jsonld.expand(doc) elif format == "flattened": return jsonld.flatten(doc) elif format == "framed": return jsonld.frame(doc, new_context) elif format == "normalized": return jsonld.normalize(doc, new_context) raise ValueError('Invalid JSON-LD serialization format')
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 4840, 12800, 14, 199, 3, 1898, 334, 35, 9, 6171, 12, 6927, 12, 6900, 24354, 14, 199, 3, 199, 3, 4840, 12800, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 4840, 12800, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 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, 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, 4840, 12800, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 6243, 12800, 17995, 1041, 199, 199, 646, 1331, 199, 646, 295, 199, 646, 3816, 199, 199, 504, 5055, 492, 29396, 199, 504, 3816, 492, 10849, 421, 199, 533, 26017, 2141, 8, 785, 304, 339, 408, 2765, 2600, 6127, 370, 886, 2005, 283, 7853, 9212, 7, 370, 2399, 1564, 14, 339, 5679, 26, 339, 2508, 1233, 13, 1457, 447, 2366, 398, 1306, 366, 275, 26017, 2141, 342, 267, 1306, 366, 459, 1421, 418, 275, 791, 65, 356, 283, 7617, 297, 283, 66, 5242, 5006, 936, 267, 1306, 366, 459, 65, 418, 275, 359, 791, 66, 356, 17, 1386, 791, 66, 356, 18, 1386, 791, 66, 356, 19, 93, 1622, 267, 1306, 366, 459, 65, 418, 267, 359, 791, 66, 356, 17, 1386, 791, 66, 356, 18, 1386, 791, 66, 356, 19, 93, 1622, 267, 1306, 366, 459, 65, 59, 16, 61, 418, 267, 791, 66, 356, 17, 93, 267, 1306, 366, 459, 65, 14, 66, 418, 267, 359, 17, 12, 18, 12, 19, 61, 267, 1306, 366, 459, 65, 59, 17, 2938, 418, 267, 9016, 66, 356, 18, 1386, 791, 66, 356, 19, 11049, 339, 2508, 5317, 447, 267, 2047, 883, 1133, 675, 314, 4644, 5932, 22608, 6730, 297, 24840, 2839, 282, 790, 14, 398, 2508, 1233, 13, 1457, 447, 2366, 953, 1306, 366, 459, 14, 418, 288, 1306, 366, 59, 418, 418, 288, 1306, 366, 459, 14, 65, 418, 398, 2779, 365, 2597, 440, 14318, 8265, 658, 29111, 2141, 64, 543, 2883, 687, 267, 4453, 314, 769, 402, 4644, 5932, 14, 398, 2508, 1233, 13, 1457, 447, 2366, 953, 1306, 366, 275, 26017, 2141, 3252, 65, 356, 650, 12, 283, 66, 356, 791, 10586, 959, 19575, 272, 408, 339, 3715, 63, 498, 63, 3401, 275, 295, 14, 2014, 2258, 14, 6113, 59, 358, 272, 2446, 63, 498, 63, 3401, 275, 295, 14, 2014, 2258, 703, 10, 6113, 59, 24915, 339, 347, 636, 826, 721, 277, 12, 366, 29, 403, 304, 267, 291, 423, 807, 275, 366, 340, 366, 365, 440, 488, 587, 1211, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 408, 1767, 1242, 465, 658, 807, 855, 6095, 29341, 1325, 1808, 283, 7853, 9212, 1370, 398, 2508, 5317, 447, 288, 11003, 316, 1373, 574, 315, 282, 3293, 4340, 12, 11150, 366, 459, 65, 995, 365, 18871, 465, 288, 7377, 465, 18549, 282, 5578, 2600, 14, 11017, 1808, 314, 4539, 288, 536, 16129, 365, 282, 4546, 26200, 2419, 1808, 314, 5578, 2879, 26, 953, 2508, 1233, 13, 1457, 447, 2366, 2234, 1306, 450, 521, 390, 671, 275, 13972, 459, 65, 59, 16, 1055, 66, 418, 355, 25761, 17222, 12, 5526, 402, 650, 26, 650, 14, 2635, 2739, 1126, 4438, 355, 1306, 450, 521, 390, 671, 275, 13972, 459, 65, 3488, 16, 2733, 66, 418, 355, 19492, 17222, 12, 5526, 402, 650, 26, 959, 2905, 700, 1126, 4438, 267, 408, 267, 347, 2312, 4484, 8, 75, 12, 373, 304, 288, 340, 1228, 8, 86, 12, 1211, 304, 355, 372, 373, 59, 75, 61, 288, 916, 24840, 315, 1022, 26, 355, 1022, 275, 1022, 4439, 17, 1055, 1814, 360, 78, 297, 2475, 17, 358, 355, 327, 9361, 6818, 367, 769, 10507, 436, 17184, 355, 862, 26, 490, 372, 373, 59, 442, 8, 75, 1874, 355, 871, 1722, 26, 490, 372, 373, 59, 5224, 2031, 1130, 8, 717, 2400, 671, 26, 1109, 8, 88, 14, 1913, 1012, 340, 671, 14, 1913, 342, 587, 488, 12, 717, 1022, 14, 1294, 11633, 490, 5082, 61, 288, 587, 26, 355, 3529, 275, 942, 355, 367, 6506, 63, 86, 315, 373, 26, 490, 3529, 14, 740, 8, 6095, 8, 75, 12, 6506, 63, 86, 430, 355, 372, 3529, 398, 327, 2670, 340, 781, 787, 1808, 2366, 5578, 2883, 267, 862, 26, 288, 372, 291, 423, 807, 59, 498, 61, 267, 871, 4067, 26, 288, 986, 398, 2883, 275, 26017, 2141, 14, 1294, 63, 498, 63, 3401, 14, 1294, 8, 498, 9, 267, 574, 275, 291, 423, 807, 267, 367, 1022, 315, 2883, 26, 288, 574, 275, 2312, 4484, 8, 75, 12, 574, 9, 267, 372, 574, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 12, 12247, 29, 797, 12, 1011, 958, 304, 267, 327, 1104, 340, 314, 790, 365, 26356, 1454, 701, 4539, 8365, 267, 340, 790, 59, 16, 61, 315, 788, 3130, 283, 4300, 6730, 2565, 288, 327, 642, 4928, 402, 790, 365, 440, 3748, 1, 288, 746, 4067, 398, 340, 7815, 440, 315, 790, 436, 24840, 440, 315, 790, 436, 440, 12247, 26, 288, 291, 423, 807, 59, 498, 61, 275, 574, 267, 587, 26, 288, 2883, 275, 26017, 2141, 14, 1294, 63, 498, 63, 3401, 14, 1294, 8, 498, 9, 288, 291, 855, 8617, 8, 277, 423, 807, 12, 2883, 59, 16, 467, 2883, 59, 17, 8429, 574, 12, 12247, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 408, 5392, 1242, 1454, 687, 1642, 2166, 2600, 2883, 1041, 267, 2150, 291, 423, 807, 59, 498, 61, 339, 347, 636 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 4840, 12800, 14, 199, 3, 1898, 334, 35, 9, 6171, 12, 6927, 12, 6900, 24354, 14, 199, 3, 199, 3, 4840, 12800, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 4840, 12800, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 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, 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, 4840, 12800, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 6243, 12800, 17995, 1041, 199, 199, 646, 1331, 199, 646, 295, 199, 646, 3816, 199, 199, 504, 5055, 492, 29396, 199, 504, 3816, 492, 10849, 421, 199, 533, 26017, 2141, 8, 785, 304, 339, 408, 2765, 2600, 6127, 370, 886, 2005, 283, 7853, 9212, 7, 370, 2399, 1564, 14, 339, 5679, 26, 339, 2508, 1233, 13, 1457, 447, 2366, 398, 1306, 366, 275, 26017, 2141, 342, 267, 1306, 366, 459, 1421, 418, 275, 791, 65, 356, 283, 7617, 297, 283, 66, 5242, 5006, 936, 267, 1306, 366, 459, 65, 418, 275, 359, 791, 66, 356, 17, 1386, 791, 66, 356, 18, 1386, 791, 66, 356, 19, 93, 1622, 267, 1306, 366, 459, 65, 418, 267, 359, 791, 66, 356, 17, 1386, 791, 66, 356, 18, 1386, 791, 66, 356, 19, 93, 1622, 267, 1306, 366, 459, 65, 59, 16, 61, 418, 267, 791, 66, 356, 17, 93, 267, 1306, 366, 459, 65, 14, 66, 418, 267, 359, 17, 12, 18, 12, 19, 61, 267, 1306, 366, 459, 65, 59, 17, 2938, 418, 267, 9016, 66, 356, 18, 1386, 791, 66, 356, 19, 11049, 339, 2508, 5317, 447, 267, 2047, 883, 1133, 675, 314, 4644, 5932, 22608, 6730, 297, 24840, 2839, 282, 790, 14, 398, 2508, 1233, 13, 1457, 447, 2366, 953, 1306, 366, 459, 14, 418, 288, 1306, 366, 59, 418, 418, 288, 1306, 366, 459, 14, 65, 418, 398, 2779, 365, 2597, 440, 14318, 8265, 658, 29111, 2141, 64, 543, 2883, 687, 267, 4453, 314, 769, 402, 4644, 5932, 14, 398, 2508, 1233, 13, 1457, 447, 2366, 953, 1306, 366, 275, 26017, 2141, 3252, 65, 356, 650, 12, 283, 66, 356, 791, 10586, 959, 19575, 272, 408, 339, 3715, 63, 498, 63, 3401, 275, 295, 14, 2014, 2258, 14, 6113, 59, 358, 272, 2446, 63, 498, 63, 3401, 275, 295, 14, 2014, 2258, 703, 10, 6113, 59, 24915, 339, 347, 636, 826, 721, 277, 12, 366, 29, 403, 304, 267, 291, 423, 807, 275, 366, 340, 366, 365, 440, 488, 587, 1211, 342, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 408, 1767, 1242, 465, 658, 807, 855, 6095, 29341, 1325, 1808, 283, 7853, 9212, 1370, 398, 2508, 5317, 447, 288, 11003, 316, 1373, 574, 315, 282, 3293, 4340, 12, 11150, 366, 459, 65, 995, 365, 18871, 465, 288, 7377, 465, 18549, 282, 5578, 2600, 14, 11017, 1808, 314, 4539, 288, 536, 16129, 365, 282, 4546, 26200, 2419, 1808, 314, 5578, 2879, 26, 953, 2508, 1233, 13, 1457, 447, 2366, 2234, 1306, 450, 521, 390, 671, 275, 13972, 459, 65, 59, 16, 1055, 66, 418, 355, 25761, 17222, 12, 5526, 402, 650, 26, 650, 14, 2635, 2739, 1126, 4438, 355, 1306, 450, 521, 390, 671, 275, 13972, 459, 65, 3488, 16, 2733, 66, 418, 355, 19492, 17222, 12, 5526, 402, 650, 26, 959, 2905, 700, 1126, 4438, 267, 408, 267, 347, 2312, 4484, 8, 75, 12, 373, 304, 288, 340, 1228, 8, 86, 12, 1211, 304, 355, 372, 373, 59, 75, 61, 288, 916, 24840, 315, 1022, 26, 355, 1022, 275, 1022, 4439, 17, 1055, 1814, 360, 78, 297, 2475, 17, 358, 355, 327, 9361, 6818, 367, 769, 10507, 436, 17184, 355, 862, 26, 490, 372, 373, 59, 442, 8, 75, 1874, 355, 871, 1722, 26, 490, 372, 373, 59, 5224, 2031, 1130, 8, 717, 2400, 671, 26, 1109, 8, 88, 14, 1913, 1012, 340, 671, 14, 1913, 342, 587, 488, 12, 717, 1022, 14, 1294, 11633, 490, 5082, 61, 288, 587, 26, 355, 3529, 275, 942, 355, 367, 6506, 63, 86, 315, 373, 26, 490, 3529, 14, 740, 8, 6095, 8, 75, 12, 6506, 63, 86, 430, 355, 372, 3529, 398, 327, 2670, 340, 781, 787, 1808, 2366, 5578, 2883, 267, 862, 26, 288, 372, 291, 423, 807, 59, 498, 61, 267, 871, 4067, 26, 288, 986, 398, 2883, 275, 26017, 2141, 14, 1294, 63, 498, 63, 3401, 14, 1294, 8, 498, 9, 267, 574, 275, 291, 423, 807, 267, 367, 1022, 315, 2883, 26, 288, 574, 275, 2312, 4484, 8, 75, 12, 574, 9, 267, 372, 574, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 12, 12247, 29, 797, 12, 1011, 958, 304, 267, 327, 1104, 340, 314, 790, 365, 26356, 1454, 701, 4539, 8365, 267, 340, 790, 59, 16, 61, 315, 788, 3130, 283, 4300, 6730, 2565, 288, 327, 642, 4928, 402, 790, 365, 440, 3748, 1, 288, 746, 4067, 398, 340, 7815, 440, 315, 790, 436, 24840, 440, 315, 790, 436, 440, 12247, 26, 288, 291, 423, 807, 59, 498, 61, 275, 574, 267, 587, 26, 288, 2883, 275, 26017, 2141, 14, 1294, 63, 498,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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 ]
lipro-yocto/git-repo
subcmds/cherry_pick.py
1
3421
# Copyright (C) 2010 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import re import sys from command import Command from git_command import GitCommand CHANGE_ID_RE = re.compile(r'^\s*Change-Id: I([0-9a-f]{40})\s*$') class CherryPick(Command): common = True helpSummary = "Cherry-pick a change." helpUsage = """ %prog <sha1> """ helpDescription = """ '%prog' cherry-picks a change from one branch to another. The change id will be updated, and a reference to the old change id will be added. """ def _Options(self, p): pass def ValidateOptions(self, opt, args): if len(args) != 1: self.Usage() def Execute(self, opt, args): reference = args[0] p = GitCommand(None, ['rev-parse', '--verify', reference], capture_stdout=True, capture_stderr=True) if p.Wait() != 0: print(p.stderr, file=sys.stderr) sys.exit(1) sha1 = p.stdout.strip() p = GitCommand(None, ['cat-file', 'commit', sha1], capture_stdout=True) if p.Wait() != 0: print("error: Failed to retrieve old commit message", file=sys.stderr) sys.exit(1) old_msg = self._StripHeader(p.stdout) p = GitCommand(None, ['cherry-pick', sha1], capture_stdout=True, capture_stderr=True) status = p.Wait() print(p.stdout, file=sys.stdout) print(p.stderr, file=sys.stderr) if status == 0: # The cherry-pick was applied correctly. We just need to edit the # commit message. new_msg = self._Reformat(old_msg, sha1) p = GitCommand(None, ['commit', '--amend', '-F', '-'], provide_stdin=True, capture_stdout=True, capture_stderr=True) p.stdin.write(new_msg) p.stdin.close() if p.Wait() != 0: print("error: Failed to update commit message", file=sys.stderr) sys.exit(1) else: print('NOTE: When committing (please see above) and editing the commit ' 'message, please remove the old Change-Id-line and add:') print(self._GetReference(sha1), file=sys.stderr) print(file=sys.stderr) def _IsChangeId(self, line): return CHANGE_ID_RE.match(line) def _GetReference(self, sha1): return "(cherry picked from commit %s)" % sha1 def _StripHeader(self, commit_msg): lines = commit_msg.splitlines() return "\n".join(lines[lines.index("") + 1:]) def _Reformat(self, old_msg, sha1): new_msg = [] for line in old_msg.splitlines(): if not self._IsChangeId(line): new_msg.append(line) # Add a blank line between the message and the change id/reference try: if new_msg[-1].strip() != "": new_msg.append("") except IndexError: pass new_msg.append(self._GetReference(sha1)) return "\n".join(new_msg)
apache-2.0
[ 3, 1898, 334, 35, 9, 7129, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 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, 295, 199, 646, 984, 199, 504, 1414, 492, 5817, 199, 504, 6135, 63, 1531, 492, 12579, 3110, 199, 199, 16062, 63, 998, 63, 907, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 4001, 13, 1304, 26, 473, 779, 16, 13, 25, 65, 13, 70, 8194, 2167, 30446, 83, 10, 9988, 421, 199, 533, 30992, 651, 8587, 8, 3110, 304, 523, 2863, 275, 715, 523, 1720, 10407, 275, 298, 1049, 281, 651, 13, 4510, 282, 1570, 2122, 523, 1720, 7692, 275, 408, 199, 5, 6595, 665, 4835, 17, 30, 199, 624, 523, 1720, 5831, 275, 408, 199, 5956, 6595, 7, 12907, 651, 13, 4510, 83, 282, 1570, 687, 1373, 5246, 370, 4573, 14, 199, 1918, 1570, 1305, 911, 506, 4588, 12, 436, 282, 3659, 370, 314, 2269, 199, 1461, 1305, 911, 506, 3483, 14, 199, 624, 819, 347, 485, 4558, 8, 277, 12, 299, 304, 272, 986, 819, 347, 12134, 4558, 8, 277, 12, 2450, 12, 1249, 304, 272, 340, 822, 8, 589, 9, 1137, 413, 26, 489, 291, 14, 7692, 342, 819, 347, 17009, 8, 277, 12, 2450, 12, 1249, 304, 272, 3659, 275, 1249, 59, 16, 61, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 4964, 13, 1122, 297, 2850, 4712, 297, 3659, 467, 673, 12296, 63, 2703, 29, 549, 12, 673, 12296, 63, 3083, 29, 549, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 8, 80, 14, 3083, 12, 570, 29, 1274, 14, 3083, 9, 489, 984, 14, 2224, 8, 17, 9, 272, 7793, 17, 275, 299, 14, 2703, 14, 1913, 342, 339, 299, 275, 12579, 3110, 8, 403, 12, 788, 3385, 13, 493, 297, 283, 3543, 297, 7793, 17, 467, 12296, 63, 2703, 29, 549, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 480, 705, 26, 16277, 370, 8044, 2269, 5532, 1245, 401, 570, 29, 1274, 14, 3083, 9, 489, 984, 14, 2224, 8, 17, 9, 272, 2269, 63, 1328, 275, 291, 423, 21332, 2567, 8, 80, 14, 2703, 9, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 7641, 651, 13, 4510, 297, 7793, 17, 467, 673, 12296, 63, 2703, 29, 549, 12, 673, 12296, 63, 3083, 29, 549, 9, 272, 2004, 275, 299, 14, 7536, 342, 339, 870, 8, 80, 14, 2703, 12, 570, 29, 1274, 14, 2703, 9, 272, 870, 8, 80, 14, 3083, 12, 570, 29, 1274, 14, 3083, 9, 339, 340, 2004, 508, 378, 26, 489, 327, 710, 12907, 651, 13, 4510, 1990, 6781, 6657, 14, 2136, 2951, 1929, 370, 5283, 314, 489, 327, 5532, 1245, 14, 489, 892, 63, 1328, 275, 291, 423, 497, 908, 8, 1753, 63, 1328, 12, 7793, 17, 9, 2541, 299, 275, 12579, 3110, 8, 403, 12, 788, 3543, 297, 2850, 313, 977, 297, 2475, 38, 297, 2475, 995, 2151, 5647, 63, 6626, 29, 549, 12, 2151, 12296, 63, 2703, 29, 549, 12, 2151, 12296, 63, 3083, 29, 549, 9, 489, 299, 14, 6626, 14, 952, 8, 1222, 63, 1328, 9, 489, 299, 14, 6626, 14, 1600, 342, 489, 340, 299, 14, 7536, 342, 1137, 378, 26, 267, 870, 480, 705, 26, 16277, 370, 1678, 5532, 1245, 401, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 8, 17, 9, 339, 587, 26, 489, 870, 360, 19855, 26, 3979, 5532, 1337, 334, 27567, 1937, 3432, 9, 436, 20401, 314, 5532, 283, 288, 283, 1188, 12, 8749, 2813, 314, 2269, 7743, 13, 1304, 13, 604, 436, 1050, 10993, 489, 870, 8, 277, 423, 1002, 5083, 8, 4835, 17, 395, 570, 29, 1274, 14, 3083, 9, 489, 870, 8, 493, 29, 1274, 14, 3083, 9, 819, 347, 485, 1831, 4001, 1304, 8, 277, 12, 1004, 304, 272, 372, 6624, 9011, 63, 998, 63, 907, 14, 1431, 8, 604, 9, 819, 347, 485, 1002, 5083, 8, 277, 12, 7793, 17, 304, 272, 372, 7340, 7641, 651, 29438, 687, 5532, 450, 83, 2924, 450, 7793, 17, 819, 347, 485, 21332, 2567, 8, 277, 12, 5532, 63, 1328, 304, 272, 2385, 275, 5532, 63, 1328, 14, 7644, 342, 272, 372, 1867, 78, 1674, 904, 8, 1278, 59, 1278, 14, 1080, 10804, 435, 413, 5728, 819, 347, 485, 497, 908, 8, 277, 12, 2269, 63, 1328, 12, 7793, 17, 304, 272, 892, 63, 1328, 275, 942, 339, 367, 1004, 315, 2269, 63, 1328, 14, 7644, 837, 489, 340, 440, 291, 423, 1831, 4001, 1304, 8, 604, 304, 267, 892, 63, 1328, 14, 740, 8, 604, 9, 339, 327, 2654, 282, 4596, 1004, 3382, 314, 1245, 436, 314, 1570, 1305, 15, 4443, 272, 862, 26, 489, 340, 892, 63, 1328, 1988, 17, 1055, 1913, 342, 1137, 10812, 267, 892, 63, 1328, 14, 740, 10804, 272, 871, 7888, 26, 489, 986, 339, 892, 63, 1328, 14, 740, 8, 277, 423, 1002, 5083, 8, 4835, 17, 430, 272, 372, 1867, 78, 1674, 904, 8, 1222, 63, 1328, 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 ]
[ 1898, 334, 35, 9, 7129, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 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, 295, 199, 646, 984, 199, 504, 1414, 492, 5817, 199, 504, 6135, 63, 1531, 492, 12579, 3110, 199, 199, 16062, 63, 998, 63, 907, 275, 295, 14, 2014, 8, 82, 15542, 83, 10, 4001, 13, 1304, 26, 473, 779, 16, 13, 25, 65, 13, 70, 8194, 2167, 30446, 83, 10, 9988, 421, 199, 533, 30992, 651, 8587, 8, 3110, 304, 523, 2863, 275, 715, 523, 1720, 10407, 275, 298, 1049, 281, 651, 13, 4510, 282, 1570, 2122, 523, 1720, 7692, 275, 408, 199, 5, 6595, 665, 4835, 17, 30, 199, 624, 523, 1720, 5831, 275, 408, 199, 5956, 6595, 7, 12907, 651, 13, 4510, 83, 282, 1570, 687, 1373, 5246, 370, 4573, 14, 199, 1918, 1570, 1305, 911, 506, 4588, 12, 436, 282, 3659, 370, 314, 2269, 199, 1461, 1305, 911, 506, 3483, 14, 199, 624, 819, 347, 485, 4558, 8, 277, 12, 299, 304, 272, 986, 819, 347, 12134, 4558, 8, 277, 12, 2450, 12, 1249, 304, 272, 340, 822, 8, 589, 9, 1137, 413, 26, 489, 291, 14, 7692, 342, 819, 347, 17009, 8, 277, 12, 2450, 12, 1249, 304, 272, 3659, 275, 1249, 59, 16, 61, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 4964, 13, 1122, 297, 2850, 4712, 297, 3659, 467, 673, 12296, 63, 2703, 29, 549, 12, 673, 12296, 63, 3083, 29, 549, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 8, 80, 14, 3083, 12, 570, 29, 1274, 14, 3083, 9, 489, 984, 14, 2224, 8, 17, 9, 272, 7793, 17, 275, 299, 14, 2703, 14, 1913, 342, 339, 299, 275, 12579, 3110, 8, 403, 12, 788, 3385, 13, 493, 297, 283, 3543, 297, 7793, 17, 467, 12296, 63, 2703, 29, 549, 9, 272, 340, 299, 14, 7536, 342, 1137, 378, 26, 489, 870, 480, 705, 26, 16277, 370, 8044, 2269, 5532, 1245, 401, 570, 29, 1274, 14, 3083, 9, 489, 984, 14, 2224, 8, 17, 9, 272, 2269, 63, 1328, 275, 291, 423, 21332, 2567, 8, 80, 14, 2703, 9, 339, 299, 275, 12579, 3110, 8, 403, 12, 673, 788, 7641, 651, 13, 4510, 297, 7793, 17, 467, 673, 12296, 63, 2703, 29, 549, 12, 673, 12296, 63, 3083, 29, 549, 9, 272, 2004, 275, 299, 14, 7536, 342, 339, 870, 8, 80, 14, 2703, 12, 570, 29, 1274, 14, 2703, 9, 272, 870, 8, 80, 14, 3083, 12, 570, 29, 1274, 14, 3083, 9, 339, 340, 2004, 508, 378, 26, 489, 327, 710, 12907, 651, 13, 4510, 1990, 6781, 6657, 14, 2136, 2951, 1929, 370, 5283, 314, 489, 327, 5532, 1245, 14, 489, 892, 63, 1328, 275, 291, 423, 497, 908, 8, 1753, 63, 1328, 12, 7793, 17, 9, 2541, 299, 275, 12579, 3110, 8, 403, 12, 788, 3543, 297, 2850, 313, 977, 297, 2475, 38, 297, 2475, 995, 2151, 5647, 63, 6626, 29, 549, 12, 2151, 12296, 63, 2703, 29, 549, 12, 2151, 12296, 63, 3083, 29, 549, 9, 489, 299, 14, 6626, 14, 952, 8, 1222, 63, 1328, 9, 489, 299, 14, 6626, 14, 1600, 342, 489, 340, 299, 14, 7536, 342, 1137, 378, 26, 267, 870, 480, 705, 26, 16277, 370, 1678, 5532, 1245, 401, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 8, 17, 9, 339, 587, 26, 489, 870, 360, 19855, 26, 3979, 5532, 1337, 334, 27567, 1937, 3432, 9, 436, 20401, 314, 5532, 283, 288, 283, 1188, 12, 8749, 2813, 314, 2269, 7743, 13, 1304, 13, 604, 436, 1050, 10993, 489, 870, 8, 277, 423, 1002, 5083, 8, 4835, 17, 395, 570, 29, 1274, 14, 3083, 9, 489, 870, 8, 493, 29, 1274, 14, 3083, 9, 819, 347, 485, 1831, 4001, 1304, 8, 277, 12, 1004, 304, 272, 372, 6624, 9011, 63, 998, 63, 907, 14, 1431, 8, 604, 9, 819, 347, 485, 1002, 5083, 8, 277, 12, 7793, 17, 304, 272, 372, 7340, 7641, 651, 29438, 687, 5532, 450, 83, 2924, 450, 7793, 17, 819, 347, 485, 21332, 2567, 8, 277, 12, 5532, 63, 1328, 304, 272, 2385, 275, 5532, 63, 1328, 14, 7644, 342, 272, 372, 1867, 78, 1674, 904, 8, 1278, 59, 1278, 14, 1080, 10804, 435, 413, 5728, 819, 347, 485, 497, 908, 8, 277, 12, 2269, 63, 1328, 12, 7793, 17, 304, 272, 892, 63, 1328, 275, 942, 339, 367, 1004, 315, 2269, 63, 1328, 14, 7644, 837, 489, 340, 440, 291, 423, 1831, 4001, 1304, 8, 604, 304, 267, 892, 63, 1328, 14, 740, 8, 604, 9, 339, 327, 2654, 282, 4596, 1004, 3382, 314, 1245, 436, 314, 1570, 1305, 15, 4443, 272, 862, 26, 489, 340, 892, 63, 1328, 1988, 17, 1055, 1913, 342, 1137, 10812, 267, 892, 63, 1328, 14, 740, 10804, 272, 871, 7888, 26, 489, 986, 339, 892, 63, 1328, 14, 740, 8, 277, 423, 1002, 5083, 8, 4835, 17, 430, 272, 372, 1867, 78, 1674, 904, 8, 1222, 63, 1328, 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, 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,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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 ]
40223142/CDA0629
static/Brython3.1.1-20150328-091302/Lib/_abcoll.py
688
5155
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Abstract Base Classes (ABCs) for collections, according to PEP 3119. DON'T USE THIS MODULE DIRECTLY! The classes here should be imported via collections; they are defined here only to alleviate certain bootstrapping issues. Unit tests are in test_collections. """ from abc import ABCMeta, abstractmethod import sys __all__ = ["Hashable", "Iterable", "Iterator", "Sized", "Container", "Callable", "Set", "MutableSet", "Mapping", "MutableMapping", "MappingView", "KeysView", "ItemsView", "ValuesView", "Sequence", "MutableSequence", "ByteString", ] """ ### collection related types which are not exposed through builtin ### ## iterators ## #fixme brython #bytes_iterator = type(iter(b'')) bytes_iterator = type(iter('')) #fixme brython #bytearray_iterator = type(iter(bytearray())) #callable_iterator = ??? dict_keyiterator = type(iter({}.keys())) dict_valueiterator = type(iter({}.values())) dict_itemiterator = type(iter({}.items())) list_iterator = type(iter([])) list_reverseiterator = type(iter(reversed([]))) range_iterator = type(iter(range(0))) set_iterator = type(iter(set())) str_iterator = type(iter("")) tuple_iterator = type(iter(())) zip_iterator = type(iter(zip())) ## views ## dict_keys = type({}.keys()) dict_values = type({}.values()) dict_items = type({}.items()) ## misc ## dict_proxy = type(type.__dict__) """ def abstractmethod(self): return self ### ONE-TRICK PONIES ### #class Iterable(metaclass=ABCMeta): class Iterable: @abstractmethod def __iter__(self): while False: yield None @classmethod def __subclasshook__(cls, C): if cls is Iterable: if any("__iter__" in B.__dict__ for B in C.__mro__): return True return NotImplemented #class Sized(metaclass=ABCMeta): class Sized: @abstractmethod def __len__(self): return 0 @classmethod def __subclasshook__(cls, C): if cls is Sized: if any("__len__" in B.__dict__ for B in C.__mro__): return True return NotImplemented #class Container(metaclass=ABCMeta): class Container: @abstractmethod def __contains__(self, x): return False @classmethod def __subclasshook__(cls, C): if cls is Container: if any("__contains__" in B.__dict__ for B in C.__mro__): return True return NotImplemented ### MAPPINGS ### class Mapping(Sized, Iterable, Container): @abstractmethod def __getitem__(self, key): raise KeyError def get(self, key, default=None): try: return self[key] except KeyError: return default def __contains__(self, key): try: self[key] except KeyError: return False else: return True def keys(self): return KeysView(self) def items(self): return ItemsView(self) def values(self): return ValuesView(self) def __eq__(self, other): if not isinstance(other, Mapping): return NotImplemented return dict(self.items()) == dict(other.items()) def __ne__(self, other): return not (self == other) class MutableMapping(Mapping): @abstractmethod def __setitem__(self, key, value): raise KeyError @abstractmethod def __delitem__(self, key): raise KeyError __marker = object() def pop(self, key, default=__marker): try: value = self[key] except KeyError: if default is self.__marker: raise return default else: del self[key] return value def popitem(self): try: key = next(iter(self)) except StopIteration: raise KeyError value = self[key] del self[key] return key, value def clear(self): try: while True: self.popitem() except KeyError: pass def update(*args, **kwds): if len(args) > 2: raise TypeError("update() takes at most 2 positional " "arguments ({} given)".format(len(args))) elif not args: raise TypeError("update() takes at least 1 argument (0 given)") self = args[0] other = args[1] if len(args) >= 2 else () if isinstance(other, Mapping): for key in other: self[key] = other[key] elif hasattr(other, "keys"): for key in other.keys(): self[key] = other[key] else: for key, value in other: self[key] = value for key, value in kwds.items(): self[key] = value def setdefault(self, key, default=None): try: return self[key] except KeyError: self[key] = default return default #MutableMapping.register(dict)
gpl-3.0
[ 3, 1898, 10219, 4475, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 199, 624, 8458, 3523, 27939, 334, 8390, 83, 9, 367, 5055, 12, 7182, 370, 13663, 650, 7119, 14, 199, 199, 36, 615, 7, 52, 4815, 5749, 30223, 8703, 6084, 1, 221, 710, 3992, 2348, 1077, 506, 8439, 199, 12897, 5055, 27, 2985, 787, 3247, 2348, 1454, 370, 27458, 433, 323, 9842, 199, 4930, 14183, 3637, 10876, 14, 221, 12008, 2295, 787, 315, 511, 63, 7882, 14, 199, 624, 199, 199, 504, 13022, 492, 29565, 12, 9006, 765, 199, 646, 984, 199, 199, 363, 452, 363, 275, 2097, 3476, 461, 401, 298, 20852, 401, 298, 3585, 401, 1779, 298, 51, 1759, 401, 298, 4076, 401, 298, 16410, 401, 1779, 298, 1084, 401, 298, 17707, 1084, 401, 1779, 298, 7674, 401, 298, 17707, 7674, 401, 1779, 298, 7674, 2768, 401, 298, 6340, 2768, 401, 298, 7412, 2768, 401, 298, 6550, 2768, 401, 1779, 298, 5826, 401, 298, 17707, 5826, 401, 1779, 298, 4861, 1558, 401, 1779, 1622, 199, 199, 624, 199, 5680, 3245, 4048, 2943, 1314, 787, 440, 19282, 4012, 6762, 6754, 199, 309, 28241, 925, 199, 3, 970, 278, 330, 23196, 199, 3, 2394, 63, 5778, 275, 730, 8, 1661, 8, 66, 7, 1333, 199, 2394, 63, 5778, 275, 730, 8, 1661, 30991, 199, 3, 970, 278, 330, 23196, 199, 3, 20108, 63, 5778, 275, 730, 8, 1661, 8, 20108, 4059, 199, 3, 8296, 63, 5778, 275, 5805, 10674, 199, 807, 63, 498, 5778, 275, 730, 8, 1661, 24692, 14, 1612, 4059, 199, 807, 63, 585, 5778, 275, 730, 8, 1661, 24692, 14, 1459, 4059, 199, 807, 63, 1053, 5778, 275, 730, 8, 1661, 24692, 14, 1744, 4059, 199, 513, 63, 5778, 275, 730, 8, 1661, 26064, 199, 513, 63, 4471, 5778, 275, 730, 8, 1661, 8, 13501, 779, 11845, 199, 1842, 63, 5778, 275, 730, 8, 1661, 8, 1842, 8, 16, 1724, 199, 409, 63, 5778, 275, 730, 8, 1661, 8, 409, 4059, 199, 495, 63, 5778, 275, 730, 8, 1661, 31348, 199, 2960, 63, 5778, 275, 730, 8, 1661, 8, 4059, 199, 3065, 63, 5778, 275, 730, 8, 1661, 8, 3065, 4059, 199, 309, 6858, 925, 199, 807, 63, 1612, 275, 730, 24692, 14, 1612, 1012, 199, 807, 63, 1459, 275, 730, 24692, 14, 1459, 1012, 199, 807, 63, 1744, 275, 730, 24692, 14, 1744, 1012, 199, 309, 18576, 925, 199, 807, 63, 3280, 275, 730, 8, 466, 855, 807, 3368, 199, 624, 199, 199, 318, 9006, 765, 8, 277, 304, 272, 372, 291, 199, 199, 5680, 13051, 13, 1766, 13884, 510, 615, 2563, 6754, 421, 199, 3, 533, 19937, 8, 6577, 29, 22254, 304, 199, 533, 19937, 26, 339, 768, 10315, 272, 347, 636, 1661, 721, 277, 304, 267, 1830, 756, 26, 288, 1995, 488, 339, 768, 3744, 272, 347, 636, 6083, 3664, 721, 1886, 12, 445, 304, 267, 340, 843, 365, 19937, 26, 288, 340, 1263, 16232, 1661, 16526, 315, 699, 855, 807, 363, 367, 699, 315, 445, 855, 17335, 18580, 355, 372, 715, 267, 372, 3784, 421, 199, 3, 533, 428, 1759, 8, 6577, 29, 22254, 304, 199, 533, 428, 1759, 26, 339, 768, 10315, 272, 347, 636, 552, 721, 277, 304, 267, 372, 378, 339, 768, 3744, 272, 347, 636, 6083, 3664, 721, 1886, 12, 445, 304, 267, 340, 843, 365, 428, 1759, 26, 288, 340, 1263, 16232, 552, 16526, 315, 699, 855, 807, 363, 367, 699, 315, 445, 855, 17335, 18580, 355, 372, 715, 267, 372, 3784, 421, 199, 3, 533, 15395, 8, 6577, 29, 22254, 304, 199, 533, 15395, 26, 339, 768, 10315, 272, 347, 636, 6134, 721, 277, 12, 671, 304, 267, 372, 756, 339, 768, 3744, 272, 347, 636, 6083, 3664, 721, 1886, 12, 445, 304, 267, 340, 843, 365, 15395, 26, 288, 340, 1263, 16232, 6134, 16526, 315, 699, 855, 807, 363, 367, 699, 315, 445, 855, 17335, 18580, 355, 372, 715, 267, 372, 3784, 199, 199, 5680, 603, 7121, 3881, 6754, 421, 199, 533, 12340, 8, 51, 1759, 12, 19937, 12, 15395, 304, 339, 768, 10315, 272, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 746, 4067, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 862, 26, 288, 372, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 849, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 862, 26, 288, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 756, 267, 587, 26, 288, 372, 715, 339, 347, 2883, 8, 277, 304, 267, 372, 17276, 2768, 8, 277, 9, 339, 347, 2974, 8, 277, 304, 267, 372, 20720, 2768, 8, 277, 9, 339, 347, 1338, 8, 277, 304, 267, 372, 13468, 2768, 8, 277, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 12340, 304, 288, 372, 3784, 267, 372, 1211, 8, 277, 14, 1744, 1012, 508, 1211, 8, 1848, 14, 1744, 1012, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 334, 277, 508, 1163, 9, 421, 199, 533, 29396, 8, 7674, 304, 339, 768, 10315, 272, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 746, 4067, 339, 768, 10315, 272, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 746, 4067, 339, 636, 4211, 275, 909, 342, 339, 347, 4560, 8, 277, 12, 790, 12, 849, 18971, 4211, 304, 267, 862, 26, 288, 574, 275, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 340, 849, 365, 291, 855, 4211, 26, 355, 746, 288, 372, 849, 267, 587, 26, 288, 2150, 291, 59, 498, 61, 288, 372, 574, 339, 347, 4560, 1053, 8, 277, 304, 267, 862, 26, 288, 790, 275, 2163, 8, 1661, 8, 277, 430, 267, 871, 10852, 26, 288, 746, 4067, 267, 574, 275, 291, 59, 498, 61, 267, 2150, 291, 59, 498, 61, 267, 372, 790, 12, 574, 339, 347, 5436, 8, 277, 304, 267, 862, 26, 288, 1830, 715, 26, 355, 291, 14, 24882, 342, 267, 871, 4067, 26, 288, 986, 339, 347, 1678, 2031, 589, 12, 1011, 10340, 304, 267, 340, 822, 8, 589, 9, 690, 499, 26, 288 ]
[ 1898, 10219, 4475, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 199, 624, 8458, 3523, 27939, 334, 8390, 83, 9, 367, 5055, 12, 7182, 370, 13663, 650, 7119, 14, 199, 199, 36, 615, 7, 52, 4815, 5749, 30223, 8703, 6084, 1, 221, 710, 3992, 2348, 1077, 506, 8439, 199, 12897, 5055, 27, 2985, 787, 3247, 2348, 1454, 370, 27458, 433, 323, 9842, 199, 4930, 14183, 3637, 10876, 14, 221, 12008, 2295, 787, 315, 511, 63, 7882, 14, 199, 624, 199, 199, 504, 13022, 492, 29565, 12, 9006, 765, 199, 646, 984, 199, 199, 363, 452, 363, 275, 2097, 3476, 461, 401, 298, 20852, 401, 298, 3585, 401, 1779, 298, 51, 1759, 401, 298, 4076, 401, 298, 16410, 401, 1779, 298, 1084, 401, 298, 17707, 1084, 401, 1779, 298, 7674, 401, 298, 17707, 7674, 401, 1779, 298, 7674, 2768, 401, 298, 6340, 2768, 401, 298, 7412, 2768, 401, 298, 6550, 2768, 401, 1779, 298, 5826, 401, 298, 17707, 5826, 401, 1779, 298, 4861, 1558, 401, 1779, 1622, 199, 199, 624, 199, 5680, 3245, 4048, 2943, 1314, 787, 440, 19282, 4012, 6762, 6754, 199, 309, 28241, 925, 199, 3, 970, 278, 330, 23196, 199, 3, 2394, 63, 5778, 275, 730, 8, 1661, 8, 66, 7, 1333, 199, 2394, 63, 5778, 275, 730, 8, 1661, 30991, 199, 3, 970, 278, 330, 23196, 199, 3, 20108, 63, 5778, 275, 730, 8, 1661, 8, 20108, 4059, 199, 3, 8296, 63, 5778, 275, 5805, 10674, 199, 807, 63, 498, 5778, 275, 730, 8, 1661, 24692, 14, 1612, 4059, 199, 807, 63, 585, 5778, 275, 730, 8, 1661, 24692, 14, 1459, 4059, 199, 807, 63, 1053, 5778, 275, 730, 8, 1661, 24692, 14, 1744, 4059, 199, 513, 63, 5778, 275, 730, 8, 1661, 26064, 199, 513, 63, 4471, 5778, 275, 730, 8, 1661, 8, 13501, 779, 11845, 199, 1842, 63, 5778, 275, 730, 8, 1661, 8, 1842, 8, 16, 1724, 199, 409, 63, 5778, 275, 730, 8, 1661, 8, 409, 4059, 199, 495, 63, 5778, 275, 730, 8, 1661, 31348, 199, 2960, 63, 5778, 275, 730, 8, 1661, 8, 4059, 199, 3065, 63, 5778, 275, 730, 8, 1661, 8, 3065, 4059, 199, 309, 6858, 925, 199, 807, 63, 1612, 275, 730, 24692, 14, 1612, 1012, 199, 807, 63, 1459, 275, 730, 24692, 14, 1459, 1012, 199, 807, 63, 1744, 275, 730, 24692, 14, 1744, 1012, 199, 309, 18576, 925, 199, 807, 63, 3280, 275, 730, 8, 466, 855, 807, 3368, 199, 624, 199, 199, 318, 9006, 765, 8, 277, 304, 272, 372, 291, 199, 199, 5680, 13051, 13, 1766, 13884, 510, 615, 2563, 6754, 421, 199, 3, 533, 19937, 8, 6577, 29, 22254, 304, 199, 533, 19937, 26, 339, 768, 10315, 272, 347, 636, 1661, 721, 277, 304, 267, 1830, 756, 26, 288, 1995, 488, 339, 768, 3744, 272, 347, 636, 6083, 3664, 721, 1886, 12, 445, 304, 267, 340, 843, 365, 19937, 26, 288, 340, 1263, 16232, 1661, 16526, 315, 699, 855, 807, 363, 367, 699, 315, 445, 855, 17335, 18580, 355, 372, 715, 267, 372, 3784, 421, 199, 3, 533, 428, 1759, 8, 6577, 29, 22254, 304, 199, 533, 428, 1759, 26, 339, 768, 10315, 272, 347, 636, 552, 721, 277, 304, 267, 372, 378, 339, 768, 3744, 272, 347, 636, 6083, 3664, 721, 1886, 12, 445, 304, 267, 340, 843, 365, 428, 1759, 26, 288, 340, 1263, 16232, 552, 16526, 315, 699, 855, 807, 363, 367, 699, 315, 445, 855, 17335, 18580, 355, 372, 715, 267, 372, 3784, 421, 199, 3, 533, 15395, 8, 6577, 29, 22254, 304, 199, 533, 15395, 26, 339, 768, 10315, 272, 347, 636, 6134, 721, 277, 12, 671, 304, 267, 372, 756, 339, 768, 3744, 272, 347, 636, 6083, 3664, 721, 1886, 12, 445, 304, 267, 340, 843, 365, 15395, 26, 288, 340, 1263, 16232, 6134, 16526, 315, 699, 855, 807, 363, 367, 699, 315, 445, 855, 17335, 18580, 355, 372, 715, 267, 372, 3784, 199, 199, 5680, 603, 7121, 3881, 6754, 421, 199, 533, 12340, 8, 51, 1759, 12, 19937, 12, 15395, 304, 339, 768, 10315, 272, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 746, 4067, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 304, 267, 862, 26, 288, 372, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 849, 339, 347, 636, 6134, 721, 277, 12, 790, 304, 267, 862, 26, 288, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 756, 267, 587, 26, 288, 372, 715, 339, 347, 2883, 8, 277, 304, 267, 372, 17276, 2768, 8, 277, 9, 339, 347, 2974, 8, 277, 304, 267, 372, 20720, 2768, 8, 277, 9, 339, 347, 1338, 8, 277, 304, 267, 372, 13468, 2768, 8, 277, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 340, 440, 1228, 8, 1848, 12, 12340, 304, 288, 372, 3784, 267, 372, 1211, 8, 277, 14, 1744, 1012, 508, 1211, 8, 1848, 14, 1744, 1012, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 334, 277, 508, 1163, 9, 421, 199, 533, 29396, 8, 7674, 304, 339, 768, 10315, 272, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 746, 4067, 339, 768, 10315, 272, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 746, 4067, 339, 636, 4211, 275, 909, 342, 339, 347, 4560, 8, 277, 12, 790, 12, 849, 18971, 4211, 304, 267, 862, 26, 288, 574, 275, 291, 59, 498, 61, 267, 871, 4067, 26, 288, 340, 849, 365, 291, 855, 4211, 26, 355, 746, 288, 372, 849, 267, 587, 26, 288, 2150, 291, 59, 498, 61, 288, 372, 574, 339, 347, 4560, 1053, 8, 277, 304, 267, 862, 26, 288, 790, 275, 2163, 8, 1661, 8, 277, 430, 267, 871, 10852, 26, 288, 746, 4067, 267, 574, 275, 291, 59, 498, 61, 267, 2150, 291, 59, 498, 61, 267, 372, 790, 12, 574, 339, 347, 5436, 8, 277, 304, 267, 862, 26, 288, 1830, 715, 26, 355, 291, 14, 24882, 342, 267, 871, 4067, 26, 288, 986, 339, 347, 1678, 2031, 589, 12, 1011, 10340, 304, 267, 340, 822, 8, 589, 9, 690, 499, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
CloudBoltSoftware/cloudbolt-forge
ui_extensions/multilevelapprovals/views.py
1
14185
from urllib.parse import urlparse from django.contrib import messages from django.http import HttpResponseRedirect from django.shortcuts import render, get_object_or_404 from django.template import loader from django.urls import reverse from django.utils.translation import ugettext as _, ungettext from accounts.models import UserProfile from accounts.templatetags import account_tags from cbhooks.exceptions import HookFailureException from common.views import clear_cached_submenu from costs.utils import ( is_rates_feature_enabled, ) from cscv.models import CITConf, can_order_be_tested, CITTest from orders.forms import DenyOrderForm from orders.models import Order from orders.templatetags.order_tags import order_pictograph, order_status_icon from quota.exceptions import QuotaError from servicecatalog.models import ServiceBlueprint from utilities.decorators import json_view, dialog_view from utilities.exceptions import ( InvalidCartException, InvalidConfigurationException, CloudBoltException ) from utilities.cb_http import django_sort_cols_from_datatable_request from utilities.logger import ThreadLogger from utilities.templatetags.helper_tags import link_or_label, how_long_ago from utilities.views import access_denied from .models import CustomOrder from extensions.views import admin_extension #@admin_extension(title='Multilevel Approvals Extension') logger = ThreadLogger(__name__) # Intentionally not protected at view level @admin_extension(title='Multilevel Approvals Extension') def order_list(request, message=""): profile = request.get_user_profile() # NOTE: order info will be sent via AJAX return render(request, 'multilevelapprovals/templates/list.html', { 'pagetitle': _("Order List"), 'message': message, 'profile': profile, 'enable_rates_feature': is_rates_feature_enabled(), }) # Intentionally not protected at view level @json_view def order_list_json(request, extra_context={}): profile = request.get_user_profile() # List of orders the user has permissions to view: orders = Order.objects_for_profile(profile) num_total_records = orders.count() search = request.GET.get('sSearch') if search: orders = orders.search(search) num_filtered_records = orders.count() # Sorting: client passes column # which must be translated to model field sort_cols = django_sort_cols_from_datatable_request(request, [ 'id', None, 'status', 'group', # order by first & last which is how it's presented ['owner__user__first_name', 'owner__user__last_name'], 'create_date', None, # Actions column is not sortable ]) orders = orders.order_by(*sort_cols) # Pagination: start = int(request.GET.get('iDisplayStart', None)) if start is not None: end = int(start) + int(request.GET.get('iDisplayLength', 0)) orders = orders[start:end] # Cache links to objects (since generating each requires a database hit): _group_link_or_label_cache = {} _owner_link_or_label_cache = {} profiles_visible_to_this_profile = UserProfile.objects_for_profile(profile) def cached_group_link_or_label(group): try: return _group_link_or_label_cache[group] except KeyError: rendered = link_or_label(group, profile) _group_link_or_label_cache[group] = rendered return rendered def cached_owner_link_or_label(owner): """ Ensure that owner avatar and link-or-label is only constructed once per page view. """ if not owner or not owner.user: return "" try: rendered = _owner_link_or_label_cache[owner] except KeyError: rendered = account_tags.rich_gravatar( owner, size=20, link=(owner in profiles_visible_to_this_profile), full_name=True ) _owner_link_or_label_cache[owner] = rendered return rendered actions_template = loader.get_template('multilevelapprovals/templates/actions.html') rows = [] for order in orders: # Render the actions column value as HTML: actions_html = actions_template.render(context={ 'order': order, 'profile': profile, 'is_owner': order.owner == profile, 'can_approve': profile.has_permission('order.approve', order), 'can_cancel': order.can_cancel(profile), 'can_save_to_catalog': order.can_save_to_catalog(profile), }, request=request) #approval_str = "" #SRM #for dict in is_multilevel_approval(order): # for key in dict.keys(): # strng = UserProfile.objects.get(id=dict[key]).user.username # if not approval_str: # approval_str = key + ":", strng # else: # approval_str += "<BR>" + key + ":", strng row = [ # We know that the user has access to view this order already, # so show URL instead of link_or_label: '<a href="%s">%s</a>' % (order.get_absolute_url(), order.nickname()), order_pictograph(order), order_status_icon(order), cached_group_link_or_label(order.group), cached_owner_link_or_label(order.owner), how_long_ago(order.create_date), actions_html, ] rows.append(row) return { # unaltered from client-side value, but cast to int to avoid XSS # http://datatables.net/usage/server-side "sEcho": int(request.GET.get('sEcho', 1)), "iTotalRecords": num_total_records, "iTotalDisplayRecords": num_filtered_records, "aaData": rows, # Orders for the current page only } def modify(request, order_id): """ POST requests from the order list and detail views go here. """ order = get_object_or_404(Order, pk=order_id) profile = request.get_user_profile() # action matches the button values in order_actions templatetag. action = request.POST.get('action', ['']) logger.info(f'SRM: in modify: action == {action}') if action in ['approve', 'deny']: if not profile.has_permission('order.approve', order): return access_denied( request, _("You do not have permission to approve this item.")) msg = "" redirect_url = request.META['HTTP_REFERER'] if action == 'submit': if not profile.has_permission('order.submit', order): return access_denied( request, _("You do not have permission to submit this order.")) try: order.submit() msg += order.start_approval_process(request) messages.info(request, msg) except QuotaError as e: # could happen if order is auto-approved messages.error(request, e) except InvalidConfigurationException as e: messages.error(request, e) except HookFailureException as e: messages.error(request, e) redirect_url = reverse('order_detail', args=[order.id]) elif action == 'approve': logger.info('SRM: in modify: action == approve (should work) -- b4 approve_my_grms') logger.info(f'SRM: order = {order}') logger.info(f'SRM: profile = {profile}') if CustomOrder.is_multilevel_approval(order): logger.info(f'SRM: is multilevel -- approving GRMs') CustomOrder.approve_my_grms(order, profile) if all(CustomOrder.is_multilevel_approval(order).values()): logger.info(f'SRM: all values return true - can approve') else: logger.info(f'SRM: not all values return true - cant approve') messages.info(request, "partial approval processed") return HttpResponseRedirect(reverse('order_detail', args=[order.id])) try: jobs, extramsg = order.approve(profile) if jobs: # template tweaks the message based on where we are going next redirect_parsed = urlparse(redirect_url) msg = loader.render_to_string('orders/approved_msg.html', { 'order': order, 'autoapproved': False, 'num_jobs': len(jobs), 'extramsg': extramsg, 'request': request, 'redirect_url': redirect_parsed.path, }) else: msg = extramsg messages.info(request, msg) except QuotaError as e: messages.error(request, e) except CloudBoltException as e: messages.warning(request, e) except: raise elif action == 'cancel': if not order.can_cancel(profile): return access_denied( request, _("You do not have permission to cancel this order.")) order.cancel() if order.owner: clear_cached_submenu(order.owner.user_id, 'orders') msg = _("Order #{order_id} has been canceled.").format(order_id=order.id) messages.info(request, msg) elif action == 'clear': order.group = None order.blueprint = None order.save() for order_item in order.orderitem_set.all(): order_item.delete() if order.owner: clear_cached_submenu(order.owner.user_id, 'orders') messages.success(request, _("Your current order has been cleared.")) elif action == 'remind': logger.info(_("User requested order approval reminder for order {order_id}").format(order_id=order_id)) try: msg = order.send_reminder(request) logger.debug(msg) messages.info(request, msg) except InvalidConfigurationException as e: messages.error(request, e) elif action == 'duplicate': # Global Viewers are a special case where objects_for_profile will # return True since they can view all orders, but we don't want them to # be able to do anything like duplicate it (unless they have additional # permissions) duplicable, reason = order.can_duplicate(profile) if not duplicable: if reason == 'permission': return access_denied( request, _("You do not have permission to duplicate this order.")) elif reason == 'group': messages.error(request, _("Orders with no group cannot be duplicated.")) return HttpResponseRedirect(reverse('order_detail', args=[order.id])) try: profile = request.get_user_profile() cart = profile.get_current_order() cart = order.duplicate(cart) items_duplicated = cart.items_duplicated hostnames_updated = cart.hostnames_updated msg = ungettext("Duplicated {num_items} order item under " "<a href='{url}'>your current order</a>.", "Duplicated {num_items} order items under " "<a href='{url}'>your current order</a>.", items_duplicated).format(num_items=items_duplicated, url=cart.get_absolute_url()) if hostnames_updated: uniq_msg = ungettext("{updated_count} order item was updated to " "avoid creating identical hostnames.", "{updated_count} order items were updated to " "avoid creating identical hostnames.", hostnames_updated).format(updated_count=hostnames_updated) msg += uniq_msg clear_cached_submenu(profile.user_id, 'orders') messages.success(request, msg) return HttpResponseRedirect(reverse('current_order')) except InvalidCartException as e: messages.error(request, e) elif action == 'save_as_blueprint': profile = request.get_user_profile() if order.group and not profile.has_permission('blueprint.manage', order.group): return access_denied( request, _("You need to have blueprint management permission for " "group '{group}' to create a blueprint from this order.").format(group=order.group)) bp = ServiceBlueprint.from_order(order) clear_cached_submenu(profile.user_id, 'catalog') messages.success( request, _("Successfully saved the <a href='{order_url}'>order</a> " "as blueprint <a href='{blueprint_url}'>{blueprint_name}</a>").format( order_url=order.get_absolute_url(), blueprint_url=bp.get_absolute_url(), blueprint_name=bp.name)) redirect_url = bp.get_absolute_url() elif action == 'add_to_cit': if can_order_be_tested(order): cit_test = CITTest.objects.create( name=order.name, order=order, cit_conf=CITConf.objects.first(), expected_status=order.status, ) messages.success( request, _('Created CIT test "{}". It will be automatically tested during ' 'the text text run.'.format(link_or_label(cit_test, profile))) ) else: messages.error(request, "This order could not be added to CIT.") return HttpResponseRedirect(redirect_url)
apache-2.0
[ 504, 4011, 14, 1122, 492, 7097, 2999, 199, 504, 1639, 14, 2828, 492, 3788, 202, 199, 504, 1639, 14, 1014, 492, 14935, 202, 199, 504, 1639, 14, 17469, 492, 3795, 12, 664, 63, 785, 63, 269, 63, 5188, 202, 199, 504, 1639, 14, 1160, 492, 5077, 202, 199, 504, 1639, 14, 3603, 492, 3837, 202, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 26843, 2999, 199, 504, 12639, 14, 992, 492, 19037, 202, 199, 504, 12639, 14, 1160, 2969, 492, 2933, 63, 2969, 202, 199, 504, 7434, 7922, 14, 3924, 492, 24837, 6782, 1726, 202, 199, 504, 2863, 14, 4196, 492, 5436, 63, 5245, 63, 954, 4470, 202, 199, 504, 26819, 14, 1208, 492, 334, 1128, 365, 63, 17153, 63, 4445, 63, 3827, 12, 202, 199, 9, 202, 199, 504, 28308, 86, 14, 992, 492, 445, 649, 8930, 12, 883, 63, 1648, 63, 1235, 63, 10453, 12, 445, 649, 774, 202, 199, 504, 15460, 14, 3351, 492, 25187, 89, 4738, 2821, 202, 199, 504, 15460, 14, 992, 492, 9240, 202, 199, 504, 15460, 14, 1160, 2969, 14, 1648, 63, 2969, 492, 1865, 63, 1038, 319, 79, 2180, 12, 1865, 63, 1205, 63, 4677, 202, 199, 504, 12132, 14, 3924, 492, 5843, 12041, 547, 202, 199, 504, 2435, 7959, 14, 992, 492, 7591, 15617, 1361, 202, 199, 504, 15841, 14, 11582, 492, 2022, 63, 1345, 12, 9592, 63, 1345, 202, 199, 504, 15841, 14, 3924, 492, 334, 1128, 6378, 31667, 1726, 12, 6378, 5688, 1726, 12, 1128, 8142, 34, 28934, 1726, 202, 199, 9, 202, 199, 504, 15841, 14, 2894, 63, 1014, 492, 1639, 63, 3191, 63, 4574, 63, 504, 63, 4616, 15511, 63, 1069, 202, 199, 504, 15841, 14, 2921, 492, 11086, 4455, 202, 199, 504, 15841, 14, 1160, 2969, 14, 3676, 63, 2969, 492, 2142, 63, 269, 63, 1302, 12, 4212, 63, 2809, 63, 14315, 202, 199, 504, 15841, 14, 4196, 492, 2879, 63, 28180, 2999, 199, 504, 1275, 992, 492, 8388, 4738, 8065, 199, 504, 5478, 14, 4196, 492, 4628, 63, 3435, 1223, 8065, 199, 17577, 2113, 63, 3435, 8, 1213, 534, 3947, 1896, 19615, 3643, 13282, 358, 202, 199, 2921, 275, 11086, 4455, 3460, 354, 3368, 2999, 199, 3, 1010, 9553, 1183, 440, 17819, 737, 2455, 2166, 202, 199, 32, 2113, 63, 3435, 8, 1213, 534, 3947, 1896, 19615, 3643, 13282, 358, 202, 199, 318, 1865, 63, 513, 8, 1069, 12, 1245, 17364, 1128, 4690, 275, 1056, 14, 362, 63, 751, 63, 2913, 342, 2958, 327, 6944, 26, 1865, 2256, 911, 506, 4847, 4799, 437, 42, 9839, 1128, 372, 3795, 8, 1069, 12, 283, 3029, 1896, 11227, 3643, 15, 5876, 15, 513, 14, 1360, 297, 469, 1039, 283, 1606, 1213, 356, 3824, 4738, 3820, 1288, 1039, 283, 1188, 356, 1245, 12, 1039, 283, 2913, 356, 4690, 12, 1039, 283, 4296, 63, 17153, 63, 4445, 356, 365, 63, 17153, 63, 4445, 63, 3827, 1062, 1128, 3828, 2999, 199, 3, 1010, 9553, 1183, 440, 17819, 737, 2455, 2166, 202, 199, 32, 1001, 63, 1345, 202, 199, 318, 1865, 63, 513, 63, 1001, 8, 1069, 12, 2402, 63, 1100, 16420, 1128, 4690, 275, 1056, 14, 362, 63, 751, 63, 2913, 342, 2958, 327, 3820, 402, 15460, 314, 922, 965, 3443, 370, 2455, 26, 1128, 15460, 275, 9240, 14, 1462, 63, 509, 63, 2913, 8, 2913, 9, 1128, 1967, 63, 2923, 63, 6502, 275, 15460, 14, 835, 342, 2958, 2754, 275, 1056, 14, 2970, 14, 362, 360, 83, 5278, 358, 1128, 340, 2754, 26, 1039, 15460, 275, 15460, 14, 1733, 8, 1733, 9, 2958, 1967, 63, 11142, 63, 6502, 275, 15460, 14, 835, 342, 2958, 327, 16722, 316, 26, 1890, 14933, 2763, 327, 1314, 1471, 506, 14598, 370, 1402, 901, 1128, 4069, 63, 4574, 275, 1639, 63, 3191, 63, 4574, 63, 504, 63, 4616, 15511, 63, 1069, 8, 1069, 12, 359, 1039, 283, 344, 297, 1039, 488, 12, 1039, 283, 1205, 297, 1039, 283, 923, 297, 1039, 327, 1865, 701, 1642, 1253, 2061, 1314, 365, 4212, 652, 1159, 26568, 1039, 788, 4597, 363, 751, 363, 2246, 63, 354, 297, 283, 4597, 363, 751, 363, 2019, 63, 354, 995, 1039, 283, 981, 63, 602, 297, 1039, 488, 12, 221, 327, 24367, 2763, 365, 440, 4069, 461, 1128, 4794, 1128, 15460, 275, 15460, 14, 1648, 63, 991, 2031, 3191, 63, 4574, 9, 2958, 327, 28006, 3155, 26, 1128, 1343, 275, 1109, 8, 1069, 14, 2970, 14, 362, 360, 73, 7687, 3162, 297, 488, 430, 1128, 340, 1343, 365, 440, 488, 26, 1039, 1284, 275, 1109, 8, 928, 9, 435, 1109, 8, 1069, 14, 2970, 14, 362, 360, 73, 7687, 4625, 297, 378, 430, 1039, 15460, 275, 15460, 59, 928, 26, 500, 61, 2958, 327, 11977, 6220, 370, 2251, 334, 8585, 12999, 1924, 5074, 282, 3050, 9793, 304, 1128, 485, 923, 63, 1073, 63, 269, 63, 1302, 63, 1637, 275, 1052, 1128, 485, 4597, 63, 1073, 63, 269, 63, 1302, 63, 1637, 275, 1052, 1128, 17390, 63, 6604, 63, 475, 63, 3749, 63, 2913, 275, 19037, 14, 1462, 63, 509, 63, 2913, 8, 2913, 9, 2958, 347, 6328, 63, 923, 63, 1073, 63, 269, 63, 1302, 8, 923, 304, 1039, 862, 26, 1675, 372, 485, 923, 63, 1073, 63, 269, 63, 1302, 63, 1637, 59, 923, 61, 1039, 871, 4067, 26, 1675, 8018, 275, 2142, 63, 269, 63, 1302, 8, 923, 12, 4690, 9, 1675, 485, 923, 63, 1073, 63, 269, 63, 1302, 63, 1637, 59, 923, 61, 275, 8018, 1675, 372, 8018, 2958, 347, 6328, 63, 4597, 63, 1073, 63, 269, 63, 1302, 8, 4597, 304, 1039, 408, 1039, 7523, 626, 5771, 20913, 436, 2142, 13, 269, 13, 1302, 365, 1454, 14701, 5403, 1039, 1126, 2034, 2455, 14, 1039, 408, 1039, 340, 440, 5771, 503, 440, 5771, 14, 751, 26, 1675, 372, 3087, 1039, 862, 26, 1675, 8018, 275, 485, 4597, 63, 1073, 63, 269, 63, 1302, 63, 1637, 59, 4597, 61, 1039, 871, 4067, 26, 1675, 8018, 275, 2933, 63, 2969, 14, 10399, 63, 926, 28694, 8, 2628, 5771, 12, 2628, 1568, 29, 1165, 12, 2628, 2142, 2687, 4597, 315, 17390, 63, 6604, 63, 475, 63, 3749, 63, 2913, 395, 2628, 2615, 63, 354, 29, 549, 1675, 776, 11556, 485, 4597, 63, 1073 ]
[ 4011, 14, 1122, 492, 7097, 2999, 199, 504, 1639, 14, 2828, 492, 3788, 202, 199, 504, 1639, 14, 1014, 492, 14935, 202, 199, 504, 1639, 14, 17469, 492, 3795, 12, 664, 63, 785, 63, 269, 63, 5188, 202, 199, 504, 1639, 14, 1160, 492, 5077, 202, 199, 504, 1639, 14, 3603, 492, 3837, 202, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 26843, 2999, 199, 504, 12639, 14, 992, 492, 19037, 202, 199, 504, 12639, 14, 1160, 2969, 492, 2933, 63, 2969, 202, 199, 504, 7434, 7922, 14, 3924, 492, 24837, 6782, 1726, 202, 199, 504, 2863, 14, 4196, 492, 5436, 63, 5245, 63, 954, 4470, 202, 199, 504, 26819, 14, 1208, 492, 334, 1128, 365, 63, 17153, 63, 4445, 63, 3827, 12, 202, 199, 9, 202, 199, 504, 28308, 86, 14, 992, 492, 445, 649, 8930, 12, 883, 63, 1648, 63, 1235, 63, 10453, 12, 445, 649, 774, 202, 199, 504, 15460, 14, 3351, 492, 25187, 89, 4738, 2821, 202, 199, 504, 15460, 14, 992, 492, 9240, 202, 199, 504, 15460, 14, 1160, 2969, 14, 1648, 63, 2969, 492, 1865, 63, 1038, 319, 79, 2180, 12, 1865, 63, 1205, 63, 4677, 202, 199, 504, 12132, 14, 3924, 492, 5843, 12041, 547, 202, 199, 504, 2435, 7959, 14, 992, 492, 7591, 15617, 1361, 202, 199, 504, 15841, 14, 11582, 492, 2022, 63, 1345, 12, 9592, 63, 1345, 202, 199, 504, 15841, 14, 3924, 492, 334, 1128, 6378, 31667, 1726, 12, 6378, 5688, 1726, 12, 1128, 8142, 34, 28934, 1726, 202, 199, 9, 202, 199, 504, 15841, 14, 2894, 63, 1014, 492, 1639, 63, 3191, 63, 4574, 63, 504, 63, 4616, 15511, 63, 1069, 202, 199, 504, 15841, 14, 2921, 492, 11086, 4455, 202, 199, 504, 15841, 14, 1160, 2969, 14, 3676, 63, 2969, 492, 2142, 63, 269, 63, 1302, 12, 4212, 63, 2809, 63, 14315, 202, 199, 504, 15841, 14, 4196, 492, 2879, 63, 28180, 2999, 199, 504, 1275, 992, 492, 8388, 4738, 8065, 199, 504, 5478, 14, 4196, 492, 4628, 63, 3435, 1223, 8065, 199, 17577, 2113, 63, 3435, 8, 1213, 534, 3947, 1896, 19615, 3643, 13282, 358, 202, 199, 2921, 275, 11086, 4455, 3460, 354, 3368, 2999, 199, 3, 1010, 9553, 1183, 440, 17819, 737, 2455, 2166, 202, 199, 32, 2113, 63, 3435, 8, 1213, 534, 3947, 1896, 19615, 3643, 13282, 358, 202, 199, 318, 1865, 63, 513, 8, 1069, 12, 1245, 17364, 1128, 4690, 275, 1056, 14, 362, 63, 751, 63, 2913, 342, 2958, 327, 6944, 26, 1865, 2256, 911, 506, 4847, 4799, 437, 42, 9839, 1128, 372, 3795, 8, 1069, 12, 283, 3029, 1896, 11227, 3643, 15, 5876, 15, 513, 14, 1360, 297, 469, 1039, 283, 1606, 1213, 356, 3824, 4738, 3820, 1288, 1039, 283, 1188, 356, 1245, 12, 1039, 283, 2913, 356, 4690, 12, 1039, 283, 4296, 63, 17153, 63, 4445, 356, 365, 63, 17153, 63, 4445, 63, 3827, 1062, 1128, 3828, 2999, 199, 3, 1010, 9553, 1183, 440, 17819, 737, 2455, 2166, 202, 199, 32, 1001, 63, 1345, 202, 199, 318, 1865, 63, 513, 63, 1001, 8, 1069, 12, 2402, 63, 1100, 16420, 1128, 4690, 275, 1056, 14, 362, 63, 751, 63, 2913, 342, 2958, 327, 3820, 402, 15460, 314, 922, 965, 3443, 370, 2455, 26, 1128, 15460, 275, 9240, 14, 1462, 63, 509, 63, 2913, 8, 2913, 9, 1128, 1967, 63, 2923, 63, 6502, 275, 15460, 14, 835, 342, 2958, 2754, 275, 1056, 14, 2970, 14, 362, 360, 83, 5278, 358, 1128, 340, 2754, 26, 1039, 15460, 275, 15460, 14, 1733, 8, 1733, 9, 2958, 1967, 63, 11142, 63, 6502, 275, 15460, 14, 835, 342, 2958, 327, 16722, 316, 26, 1890, 14933, 2763, 327, 1314, 1471, 506, 14598, 370, 1402, 901, 1128, 4069, 63, 4574, 275, 1639, 63, 3191, 63, 4574, 63, 504, 63, 4616, 15511, 63, 1069, 8, 1069, 12, 359, 1039, 283, 344, 297, 1039, 488, 12, 1039, 283, 1205, 297, 1039, 283, 923, 297, 1039, 327, 1865, 701, 1642, 1253, 2061, 1314, 365, 4212, 652, 1159, 26568, 1039, 788, 4597, 363, 751, 363, 2246, 63, 354, 297, 283, 4597, 363, 751, 363, 2019, 63, 354, 995, 1039, 283, 981, 63, 602, 297, 1039, 488, 12, 221, 327, 24367, 2763, 365, 440, 4069, 461, 1128, 4794, 1128, 15460, 275, 15460, 14, 1648, 63, 991, 2031, 3191, 63, 4574, 9, 2958, 327, 28006, 3155, 26, 1128, 1343, 275, 1109, 8, 1069, 14, 2970, 14, 362, 360, 73, 7687, 3162, 297, 488, 430, 1128, 340, 1343, 365, 440, 488, 26, 1039, 1284, 275, 1109, 8, 928, 9, 435, 1109, 8, 1069, 14, 2970, 14, 362, 360, 73, 7687, 4625, 297, 378, 430, 1039, 15460, 275, 15460, 59, 928, 26, 500, 61, 2958, 327, 11977, 6220, 370, 2251, 334, 8585, 12999, 1924, 5074, 282, 3050, 9793, 304, 1128, 485, 923, 63, 1073, 63, 269, 63, 1302, 63, 1637, 275, 1052, 1128, 485, 4597, 63, 1073, 63, 269, 63, 1302, 63, 1637, 275, 1052, 1128, 17390, 63, 6604, 63, 475, 63, 3749, 63, 2913, 275, 19037, 14, 1462, 63, 509, 63, 2913, 8, 2913, 9, 2958, 347, 6328, 63, 923, 63, 1073, 63, 269, 63, 1302, 8, 923, 304, 1039, 862, 26, 1675, 372, 485, 923, 63, 1073, 63, 269, 63, 1302, 63, 1637, 59, 923, 61, 1039, 871, 4067, 26, 1675, 8018, 275, 2142, 63, 269, 63, 1302, 8, 923, 12, 4690, 9, 1675, 485, 923, 63, 1073, 63, 269, 63, 1302, 63, 1637, 59, 923, 61, 275, 8018, 1675, 372, 8018, 2958, 347, 6328, 63, 4597, 63, 1073, 63, 269, 63, 1302, 8, 4597, 304, 1039, 408, 1039, 7523, 626, 5771, 20913, 436, 2142, 13, 269, 13, 1302, 365, 1454, 14701, 5403, 1039, 1126, 2034, 2455, 14, 1039, 408, 1039, 340, 440, 5771, 503, 440, 5771, 14, 751, 26, 1675, 372, 3087, 1039, 862, 26, 1675, 8018, 275, 485, 4597, 63, 1073, 63, 269, 63, 1302, 63, 1637, 59, 4597, 61, 1039, 871, 4067, 26, 1675, 8018, 275, 2933, 63, 2969, 14, 10399, 63, 926, 28694, 8, 2628, 5771, 12, 2628, 1568, 29, 1165, 12, 2628, 2142, 2687, 4597, 315, 17390, 63, 6604, 63, 475, 63, 3749, 63, 2913, 395, 2628, 2615, 63, 354, 29, 549, 1675, 776, 11556, 485, 4597, 63, 1073, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
LeandroRoberto/sapl
sapl/comissoes/views.py
1
3353
from django.core.urlresolvers import reverse from django.db.models import F from django.views.generic import ListView from sapl.crud.base import RP_DETAIL, RP_LIST, Crud, CrudAux, MasterDetailCrud from sapl.materia.models import MateriaLegislativa, Tramitacao from .models import (CargoComissao, Comissao, Composicao, Participacao, Periodo, TipoComissao) def pegar_url_composicao(pk): participacao = Participacao.objects.get(id=pk) comp_pk = participacao.composicao.pk url = reverse('sapl.comissoes:composicao_detail', kwargs={'pk': comp_pk}) return url CargoCrud = CrudAux.build(CargoComissao, 'cargo_comissao') PeriodoComposicaoCrud = CrudAux.build(Periodo, 'periodo_composicao_comissao') TipoComissaoCrud = CrudAux.build( TipoComissao, 'tipo_comissao', list_field_names=[ 'sigla', 'nome', 'natureza', 'dispositivo_regimental']) class ParticipacaoCrud(MasterDetailCrud): model = Participacao parent_field = 'composicao__comissao' public = [RP_DETAIL, ] ListView = None is_m2m = True link_return_to_parent_field = True class BaseMixin(MasterDetailCrud.BaseMixin): list_field_names = ['composicao', 'parlamentar', 'cargo'] class ComposicaoCrud(MasterDetailCrud): model = Composicao parent_field = 'comissao' model_set = 'participacao_set' public = [RP_LIST, RP_DETAIL, ] class ListView(MasterDetailCrud.ListView): template_name = "comissoes/composicao_list.html" paginate_by = None def take_composicao_pk(self): try: return int(self.request.GET['pk']) except: return 0 def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['composicao_pk'] = context['composicao_list'].last( ).pk if self.take_composicao_pk( ) == 0 else self.take_composicao_pk() context['participacao_set'] = Participacao.objects.filter( composicao__pk=context['composicao_pk'] ).order_by('parlamentar') return context class ComissaoCrud(Crud): model = Comissao help_path = 'modulo_comissoes' public = [RP_LIST, RP_DETAIL, ] class BaseMixin(Crud.BaseMixin): list_field_names = ['nome', 'sigla', 'tipo', 'data_criacao', 'ativa'] ordering = '-ativa', 'sigla' class MateriasTramitacaoListView(ListView): template_name = "comissoes/materias_em_tramitacao.html" paginate_by = 10 def get_queryset(self): # FIXME: Otimizar consulta ts = Tramitacao.objects.order_by( 'materia', '-data_tramitacao', '-id').annotate( comissao=F('unidade_tramitacao_destino__comissao')).distinct( 'materia').values_list('materia', 'comissao') ts = list(filter(lambda x: x[1] == int(self.kwargs['pk']), ts)) ts = list(zip(*ts)) ts = ts[0] if ts else [] materias = MateriaLegislativa.objects.filter( pk__in=ts).order_by('tipo', '-ano', '-numero') return materias def get_context_data(self, **kwargs): context = super( MateriasTramitacaoListView, self).get_context_data(**kwargs) context['object'] = Comissao.objects.get(id=self.kwargs['pk']) return context
gpl-3.0
[ 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 14, 992, 492, 481, 199, 504, 1639, 14, 4196, 14, 6767, 492, 3820, 2768, 199, 199, 504, 308, 439, 76, 14, 28941, 14, 1095, 492, 820, 48, 63, 25081, 12, 820, 48, 63, 4924, 12, 30277, 1181, 12, 30277, 1181, 30731, 12, 26728, 8064, 17345, 1181, 199, 504, 308, 439, 76, 14, 17684, 23714, 14, 992, 492, 603, 323, 23714, 2553, 5668, 416, 280, 3042, 12, 12643, 1147, 645, 8035, 199, 199, 504, 1275, 992, 492, 334, 35, 16308, 4373, 374, 2231, 79, 12, 5429, 374, 2231, 79, 12, 27506, 338, 696, 79, 12, 2235, 31089, 387, 696, 79, 12, 2151, 16532, 79, 12, 377, 73, 555, 4373, 374, 2231, 79, 9, 421, 199, 318, 4837, 23909, 63, 633, 63, 7784, 338, 696, 79, 8, 2051, 304, 272, 623, 31089, 387, 696, 79, 275, 2235, 31089, 387, 696, 79, 14, 1462, 14, 362, 8, 344, 29, 2051, 9, 272, 1013, 63, 2051, 275, 623, 31089, 387, 696, 79, 14, 7784, 338, 696, 79, 14, 2051, 272, 1166, 275, 3837, 360, 83, 439, 76, 14, 957, 374, 1152, 397, 26, 7784, 338, 696, 79, 63, 5506, 297, 2074, 3713, 2051, 356, 1013, 63, 2051, 1552, 272, 372, 1166, 199, 199, 35, 16308, 17345, 1181, 275, 30277, 1181, 30731, 14, 1506, 8, 35, 16308, 4373, 374, 2231, 79, 12, 283, 67, 16308, 63, 957, 374, 2231, 79, 358, 199, 15518, 79, 16273, 338, 696, 79, 17345, 1181, 275, 30277, 1181, 30731, 14, 1506, 8, 15518, 79, 12, 283, 5191, 79, 63, 7784, 338, 696, 79, 63, 957, 374, 2231, 79, 358, 199, 199, 22731, 555, 4373, 374, 2231, 79, 17345, 1181, 275, 30277, 1181, 30731, 14, 1506, 8, 272, 377, 73, 555, 4373, 374, 2231, 79, 12, 283, 280, 555, 63, 957, 374, 2231, 79, 297, 769, 63, 698, 63, 1247, 1524, 267, 283, 4093, 416, 297, 283, 29897, 297, 283, 78, 1463, 8076, 297, 283, 2297, 555, 338, 280, 2392, 63, 1135, 73, 434, 279, 1105, 421, 199, 533, 2235, 31089, 387, 696, 79, 17345, 1181, 8, 12288, 8064, 17345, 1181, 304, 272, 1402, 275, 2235, 31089, 387, 696, 79, 272, 1676, 63, 698, 275, 283, 7784, 338, 696, 79, 363, 957, 374, 2231, 79, 7, 272, 4575, 275, 359, 18612, 63, 25081, 12, 1622, 272, 3820, 2768, 275, 488, 272, 365, 63, 77, 18, 77, 275, 715, 272, 2142, 63, 1107, 63, 475, 63, 1708, 63, 698, 275, 715, 339, 1021, 3523, 4256, 8, 12288, 8064, 17345, 1181, 14, 1563, 4256, 304, 267, 769, 63, 698, 63, 1247, 275, 788, 7784, 338, 696, 79, 297, 283, 462, 76, 14040, 285, 297, 283, 67, 16308, 418, 421, 199, 533, 27506, 338, 696, 79, 17345, 1181, 8, 12288, 8064, 17345, 1181, 304, 272, 1402, 275, 27506, 338, 696, 79, 272, 1676, 63, 698, 275, 283, 957, 374, 2231, 79, 7, 272, 1402, 63, 409, 275, 283, 23512, 559, 387, 696, 79, 63, 409, 7, 272, 4575, 275, 359, 18612, 63, 4924, 12, 820, 48, 63, 25081, 12, 1622, 339, 1021, 3820, 2768, 8, 12288, 8064, 17345, 1181, 14, 23239, 304, 267, 1978, 63, 354, 275, 298, 957, 374, 1152, 397, 15, 7784, 338, 696, 79, 63, 513, 14, 1360, 2, 267, 9881, 23043, 63, 991, 275, 488, 398, 347, 5452, 63, 7784, 338, 696, 79, 63, 2051, 8, 277, 304, 288, 862, 26, 355, 372, 1109, 8, 277, 14, 1069, 14, 2970, 459, 2051, 1105, 288, 871, 26, 355, 372, 378, 398, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 288, 1067, 275, 1613, 1252, 362, 63, 1100, 63, 576, 3682, 958, 9, 288, 1067, 459, 7784, 338, 696, 79, 63, 2051, 418, 275, 1067, 459, 7784, 338, 696, 79, 63, 513, 2278, 2019, 8, 355, 7092, 2051, 340, 291, 14, 11066, 63, 7784, 338, 696, 79, 63, 2051, 8, 355, 776, 508, 378, 587, 291, 14, 11066, 63, 7784, 338, 696, 79, 63, 2051, 342, 288, 1067, 459, 23512, 559, 387, 696, 79, 63, 409, 418, 275, 2235, 31089, 387, 696, 79, 14, 1462, 14, 1541, 8, 355, 11395, 338, 696, 79, 363, 2051, 29, 1100, 459, 7784, 338, 696, 79, 63, 2051, 418, 355, 7092, 1648, 63, 991, 360, 462, 76, 14040, 285, 358, 288, 372, 1067, 421, 199, 533, 5429, 374, 2231, 79, 17345, 1181, 8, 17345, 1181, 304, 272, 1402, 275, 5429, 374, 2231, 79, 272, 1720, 63, 515, 275, 283, 1494, 13957, 63, 957, 374, 1152, 397, 7, 272, 4575, 275, 359, 18612, 63, 4924, 12, 820, 48, 63, 25081, 12, 1622, 339, 1021, 3523, 4256, 8, 17345, 1181, 14, 1563, 4256, 304, 267, 769, 63, 698, 63, 1247, 275, 788, 29897, 297, 283, 4093, 416, 297, 283, 280, 555, 297, 283, 576, 63, 1408, 645, 8035, 297, 283, 2159, 3042, 418, 267, 7794, 275, 2475, 2159, 3042, 297, 283, 4093, 416, 7, 421, 199, 533, 603, 323, 322, 305, 2437, 1147, 645, 8035, 23239, 8, 23239, 304, 272, 1978, 63, 354, 275, 298, 957, 374, 1152, 397, 15, 17684, 322, 305, 63, 5633, 63, 1239, 1147, 645, 8035, 14, 1360, 2, 272, 9881, 23043, 63, 991, 275, 1616, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 327, 7600, 26, 593, 2906, 565, 285, 13447, 427, 65, 267, 6714, 275, 12643, 1147, 645, 8035, 14, 1462, 14, 1648, 63, 991, 8, 288, 283, 17684, 23714, 297, 2475, 576, 63, 1239, 1147, 645, 8035, 297, 2475, 344, 1959, 10898, 8, 288, 512, 1292, 2231, 79, 29, 38, 360, 324, 344, 9587, 63, 1239, 1147, 645, 8035, 63, 2614, 10175, 363, 957, 374, 2231, 79, 11103, 12926, 8, 355, 283, 17684, 23714, 1959, 1459, 63, 513, 360, 17684, 23714, 297, 283, 957, 374, 2231, 79, 358, 398, 6714, 275, 769, 8, 1541, 8, 2734, 671, 26, 671, 59, 17, 61, 508, 1109, 8, 277, 14, 958, 459, 2051, 3815, 6714, 430, 267, 6714, 275, 769, 8, 3065, 2031, 1086, 430, 267, 6714, 275, 6714, 59, 16, 61, 340, 6714, 587, 942, 398, 333, 323, 322, 305, 275, 603, 323, 23714, 2553, 5668, 416, 280, 3042, 14, 1462, 14, 1541, 8, 288, 3803, 363, 262 ]
[ 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 14, 992, 492, 481, 199, 504, 1639, 14, 4196, 14, 6767, 492, 3820, 2768, 199, 199, 504, 308, 439, 76, 14, 28941, 14, 1095, 492, 820, 48, 63, 25081, 12, 820, 48, 63, 4924, 12, 30277, 1181, 12, 30277, 1181, 30731, 12, 26728, 8064, 17345, 1181, 199, 504, 308, 439, 76, 14, 17684, 23714, 14, 992, 492, 603, 323, 23714, 2553, 5668, 416, 280, 3042, 12, 12643, 1147, 645, 8035, 199, 199, 504, 1275, 992, 492, 334, 35, 16308, 4373, 374, 2231, 79, 12, 5429, 374, 2231, 79, 12, 27506, 338, 696, 79, 12, 2235, 31089, 387, 696, 79, 12, 2151, 16532, 79, 12, 377, 73, 555, 4373, 374, 2231, 79, 9, 421, 199, 318, 4837, 23909, 63, 633, 63, 7784, 338, 696, 79, 8, 2051, 304, 272, 623, 31089, 387, 696, 79, 275, 2235, 31089, 387, 696, 79, 14, 1462, 14, 362, 8, 344, 29, 2051, 9, 272, 1013, 63, 2051, 275, 623, 31089, 387, 696, 79, 14, 7784, 338, 696, 79, 14, 2051, 272, 1166, 275, 3837, 360, 83, 439, 76, 14, 957, 374, 1152, 397, 26, 7784, 338, 696, 79, 63, 5506, 297, 2074, 3713, 2051, 356, 1013, 63, 2051, 1552, 272, 372, 1166, 199, 199, 35, 16308, 17345, 1181, 275, 30277, 1181, 30731, 14, 1506, 8, 35, 16308, 4373, 374, 2231, 79, 12, 283, 67, 16308, 63, 957, 374, 2231, 79, 358, 199, 15518, 79, 16273, 338, 696, 79, 17345, 1181, 275, 30277, 1181, 30731, 14, 1506, 8, 15518, 79, 12, 283, 5191, 79, 63, 7784, 338, 696, 79, 63, 957, 374, 2231, 79, 358, 199, 199, 22731, 555, 4373, 374, 2231, 79, 17345, 1181, 275, 30277, 1181, 30731, 14, 1506, 8, 272, 377, 73, 555, 4373, 374, 2231, 79, 12, 283, 280, 555, 63, 957, 374, 2231, 79, 297, 769, 63, 698, 63, 1247, 1524, 267, 283, 4093, 416, 297, 283, 29897, 297, 283, 78, 1463, 8076, 297, 283, 2297, 555, 338, 280, 2392, 63, 1135, 73, 434, 279, 1105, 421, 199, 533, 2235, 31089, 387, 696, 79, 17345, 1181, 8, 12288, 8064, 17345, 1181, 304, 272, 1402, 275, 2235, 31089, 387, 696, 79, 272, 1676, 63, 698, 275, 283, 7784, 338, 696, 79, 363, 957, 374, 2231, 79, 7, 272, 4575, 275, 359, 18612, 63, 25081, 12, 1622, 272, 3820, 2768, 275, 488, 272, 365, 63, 77, 18, 77, 275, 715, 272, 2142, 63, 1107, 63, 475, 63, 1708, 63, 698, 275, 715, 339, 1021, 3523, 4256, 8, 12288, 8064, 17345, 1181, 14, 1563, 4256, 304, 267, 769, 63, 698, 63, 1247, 275, 788, 7784, 338, 696, 79, 297, 283, 462, 76, 14040, 285, 297, 283, 67, 16308, 418, 421, 199, 533, 27506, 338, 696, 79, 17345, 1181, 8, 12288, 8064, 17345, 1181, 304, 272, 1402, 275, 27506, 338, 696, 79, 272, 1676, 63, 698, 275, 283, 957, 374, 2231, 79, 7, 272, 1402, 63, 409, 275, 283, 23512, 559, 387, 696, 79, 63, 409, 7, 272, 4575, 275, 359, 18612, 63, 4924, 12, 820, 48, 63, 25081, 12, 1622, 339, 1021, 3820, 2768, 8, 12288, 8064, 17345, 1181, 14, 23239, 304, 267, 1978, 63, 354, 275, 298, 957, 374, 1152, 397, 15, 7784, 338, 696, 79, 63, 513, 14, 1360, 2, 267, 9881, 23043, 63, 991, 275, 488, 398, 347, 5452, 63, 7784, 338, 696, 79, 63, 2051, 8, 277, 304, 288, 862, 26, 355, 372, 1109, 8, 277, 14, 1069, 14, 2970, 459, 2051, 1105, 288, 871, 26, 355, 372, 378, 398, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 288, 1067, 275, 1613, 1252, 362, 63, 1100, 63, 576, 3682, 958, 9, 288, 1067, 459, 7784, 338, 696, 79, 63, 2051, 418, 275, 1067, 459, 7784, 338, 696, 79, 63, 513, 2278, 2019, 8, 355, 7092, 2051, 340, 291, 14, 11066, 63, 7784, 338, 696, 79, 63, 2051, 8, 355, 776, 508, 378, 587, 291, 14, 11066, 63, 7784, 338, 696, 79, 63, 2051, 342, 288, 1067, 459, 23512, 559, 387, 696, 79, 63, 409, 418, 275, 2235, 31089, 387, 696, 79, 14, 1462, 14, 1541, 8, 355, 11395, 338, 696, 79, 363, 2051, 29, 1100, 459, 7784, 338, 696, 79, 63, 2051, 418, 355, 7092, 1648, 63, 991, 360, 462, 76, 14040, 285, 358, 288, 372, 1067, 421, 199, 533, 5429, 374, 2231, 79, 17345, 1181, 8, 17345, 1181, 304, 272, 1402, 275, 5429, 374, 2231, 79, 272, 1720, 63, 515, 275, 283, 1494, 13957, 63, 957, 374, 1152, 397, 7, 272, 4575, 275, 359, 18612, 63, 4924, 12, 820, 48, 63, 25081, 12, 1622, 339, 1021, 3523, 4256, 8, 17345, 1181, 14, 1563, 4256, 304, 267, 769, 63, 698, 63, 1247, 275, 788, 29897, 297, 283, 4093, 416, 297, 283, 280, 555, 297, 283, 576, 63, 1408, 645, 8035, 297, 283, 2159, 3042, 418, 267, 7794, 275, 2475, 2159, 3042, 297, 283, 4093, 416, 7, 421, 199, 533, 603, 323, 322, 305, 2437, 1147, 645, 8035, 23239, 8, 23239, 304, 272, 1978, 63, 354, 275, 298, 957, 374, 1152, 397, 15, 17684, 322, 305, 63, 5633, 63, 1239, 1147, 645, 8035, 14, 1360, 2, 272, 9881, 23043, 63, 991, 275, 1616, 339, 347, 664, 63, 7924, 8, 277, 304, 267, 327, 7600, 26, 593, 2906, 565, 285, 13447, 427, 65, 267, 6714, 275, 12643, 1147, 645, 8035, 14, 1462, 14, 1648, 63, 991, 8, 288, 283, 17684, 23714, 297, 2475, 576, 63, 1239, 1147, 645, 8035, 297, 2475, 344, 1959, 10898, 8, 288, 512, 1292, 2231, 79, 29, 38, 360, 324, 344, 9587, 63, 1239, 1147, 645, 8035, 63, 2614, 10175, 363, 957, 374, 2231, 79, 11103, 12926, 8, 355, 283, 17684, 23714, 1959, 1459, 63, 513, 360, 17684, 23714, 297, 283, 957, 374, 2231, 79, 358, 398, 6714, 275, 769, 8, 1541, 8, 2734, 671, 26, 671, 59, 17, 61, 508, 1109, 8, 277, 14, 958, 459, 2051, 3815, 6714, 430, 267, 6714, 275, 769, 8, 3065, 2031, 1086, 430, 267, 6714, 275, 6714, 59, 16, 61, 340, 6714, 587, 942, 398, 333, 323, 322, 305, 275, 603, 323, 23714, 2553, 5668, 416, 280, 3042, 14, 1462, 14, 1541, 8, 288, 3803, 363, 262, 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,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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 ]
HKUST-SING/tensorflow
tensorflow/contrib/learn/python/learn/trainable.py
68
3234
# Copyright 2016 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. # ============================================================================== """`Trainable` interface.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import abc class Trainable(object): """Interface for objects that are trainable by, e.g., `Experiment`. """ __metaclass__ = abc.ABCMeta @abc.abstractmethod def fit(self, x=None, y=None, input_fn=None, steps=None, batch_size=None, monitors=None, max_steps=None): """Trains a model given training data `x` predictions and `y` labels. Args: x: Matrix of shape [n_samples, n_features...] or the dictionary of Matrices. Can be iterator that returns arrays of features or dictionary of arrays of features. The training input samples for fitting the model. If set, `input_fn` must be `None`. y: Vector or matrix [n_samples] or [n_samples, n_outputs] or the dictionary of same. Can be iterator that returns array of labels or dictionary of array of labels. The training label values (class labels in classification, real numbers in regression). If set, `input_fn` must be `None`. Note: For classification, label values must be integers representing the class index (i.e. values from 0 to n_classes-1). input_fn: Input function returning a tuple of: features - `Tensor` or dictionary of string feature name to `Tensor`. labels - `Tensor` or dictionary of `Tensor` with labels. If input_fn is set, `x`, `y`, and `batch_size` must be `None`. steps: Number of steps for which to train model. If `None`, train forever. 'steps' works incrementally. If you call two times fit(steps=10) then training occurs in total 20 steps. If you don't want to have incremental behaviour please set `max_steps` instead. If set, `max_steps` must be `None`. batch_size: minibatch size to use on the input, defaults to first dimension of `x`. Must be `None` if `input_fn` is provided. monitors: List of `BaseMonitor` subclass instances. Used for callbacks inside the training loop. max_steps: Number of total steps for which to train model. If `None`, train forever. If set, `steps` must be `None`. Two calls to `fit(steps=100)` means 200 training iterations. On the other hand, two calls to `fit(max_steps=100)` means that the second call will not do any iteration since first call did all 100 steps. Returns: `self`, for chaining. """ raise NotImplementedError
apache-2.0
[ 3, 1898, 7800, 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, 199, 624, 64, 18591, 461, 64, 3217, 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, 646, 13022, 421, 199, 533, 16732, 461, 8, 785, 304, 523, 408, 4267, 367, 2251, 626, 787, 17029, 701, 12, 325, 14, 71, 2020, 658, 20781, 2313, 523, 408, 523, 636, 6577, 363, 275, 13022, 14, 22254, 819, 768, 3175, 14, 10315, 523, 347, 5542, 8, 277, 12, 671, 29, 403, 12, 612, 29, 403, 12, 1324, 63, 2324, 29, 403, 12, 7124, 29, 403, 12, 3522, 63, 890, 29, 403, 12, 881, 26862, 29, 403, 12, 1390, 63, 5895, 29, 403, 304, 272, 408, 2437, 3617, 282, 1402, 1627, 6093, 666, 658, 88, 64, 7914, 436, 658, 89, 64, 3628, 14, 339, 3033, 26, 489, 671, 26, 8449, 402, 2215, 359, 78, 63, 3356, 12, 302, 63, 3179, 18737, 503, 314, 2600, 402, 18619, 9355, 14, 268, 6855, 506, 6122, 626, 2529, 6572, 402, 4534, 503, 2600, 402, 6572, 402, 4534, 14, 268, 710, 6093, 1324, 5845, 367, 21774, 314, 1402, 14, 982, 663, 12, 658, 1210, 63, 2324, 64, 1471, 506, 658, 403, 2313, 489, 612, 26, 11388, 503, 3634, 359, 78, 63, 3356, 61, 503, 359, 78, 63, 3356, 12, 302, 63, 4467, 61, 503, 314, 2600, 402, 2011, 14, 268, 6855, 506, 6122, 626, 2529, 1625, 402, 3628, 503, 2600, 402, 1625, 402, 3628, 14, 268, 710, 6093, 1768, 1338, 334, 533, 3628, 315, 12505, 12, 3363, 5579, 315, 10864, 680, 268, 982, 663, 12, 658, 1210, 63, 2324, 64, 1471, 506, 658, 403, 2313, 3390, 26, 2104, 12505, 12, 1768, 1338, 1471, 268, 506, 9446, 6144, 314, 1021, 1478, 334, 73, 14, 69, 14, 1338, 687, 378, 370, 268, 302, 63, 2888, 13, 17, 680, 489, 1324, 63, 2324, 26, 6924, 805, 8152, 282, 2008, 402, 26, 881, 4534, 446, 658, 3861, 64, 503, 2600, 402, 1059, 3878, 536, 370, 658, 3861, 2313, 881, 3628, 446, 658, 3861, 64, 503, 2600, 402, 658, 3861, 64, 543, 3628, 14, 267, 982, 1324, 63, 2324, 365, 663, 12, 658, 88, 3559, 658, 89, 3559, 436, 658, 2912, 63, 890, 64, 1471, 506, 658, 403, 2313, 489, 7124, 26, 4860, 402, 7124, 367, 1314, 370, 3560, 1402, 14, 982, 658, 403, 3559, 3560, 28688, 14, 267, 283, 5895, 7, 5419, 11609, 1183, 14, 982, 1265, 1240, 2877, 5431, 5542, 8, 5895, 29, 709, 9, 2066, 267, 6093, 11058, 315, 3141, 3388, 7124, 14, 982, 1265, 2793, 1133, 2934, 370, 1172, 16316, 267, 13942, 8749, 663, 658, 988, 63, 5895, 64, 3140, 14, 982, 663, 12, 658, 988, 63, 5895, 64, 1471, 506, 267, 658, 403, 2313, 489, 3522, 63, 890, 26, 30829, 1568, 370, 675, 641, 314, 1324, 12, 4243, 370, 1642, 267, 6240, 402, 658, 88, 2313, 9498, 506, 658, 403, 64, 340, 658, 1210, 63, 2324, 64, 365, 2741, 14, 489, 26862, 26, 3820, 402, 658, 1563, 13189, 64, 5516, 4454, 14, 8051, 367, 13484, 267, 6272, 314, 6093, 4438, 14, 489, 1390, 63, 5895, 26, 4860, 402, 3141, 7124, 367, 1314, 370, 3560, 1402, 14, 982, 658, 403, 3559, 267, 3560, 28688, 14, 982, 663, 12, 658, 5895, 64, 1471, 506, 658, 403, 2313, 398, 16853, 4882, 370, 658, 3269, 8, 5895, 29, 1960, 12544, 4910, 1926, 6093, 267, 10615, 14, 4068, 314, 1163, 4926, 12, 2877, 4882, 370, 658, 3269, 8, 988, 63, 5895, 29, 1960, 12544, 4910, 267, 626, 314, 3499, 1240, 911, 440, 886, 1263, 8494, 3967, 1642, 1240, 8103, 267, 1006, 2948, 7124, 14, 339, 1803, 26, 489, 658, 277, 3559, 367, 6036, 316, 14, 272, 408, 272, 746, 4279, 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 ]
[ 1898, 7800, 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, 199, 624, 64, 18591, 461, 64, 3217, 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, 646, 13022, 421, 199, 533, 16732, 461, 8, 785, 304, 523, 408, 4267, 367, 2251, 626, 787, 17029, 701, 12, 325, 14, 71, 2020, 658, 20781, 2313, 523, 408, 523, 636, 6577, 363, 275, 13022, 14, 22254, 819, 768, 3175, 14, 10315, 523, 347, 5542, 8, 277, 12, 671, 29, 403, 12, 612, 29, 403, 12, 1324, 63, 2324, 29, 403, 12, 7124, 29, 403, 12, 3522, 63, 890, 29, 403, 12, 881, 26862, 29, 403, 12, 1390, 63, 5895, 29, 403, 304, 272, 408, 2437, 3617, 282, 1402, 1627, 6093, 666, 658, 88, 64, 7914, 436, 658, 89, 64, 3628, 14, 339, 3033, 26, 489, 671, 26, 8449, 402, 2215, 359, 78, 63, 3356, 12, 302, 63, 3179, 18737, 503, 314, 2600, 402, 18619, 9355, 14, 268, 6855, 506, 6122, 626, 2529, 6572, 402, 4534, 503, 2600, 402, 6572, 402, 4534, 14, 268, 710, 6093, 1324, 5845, 367, 21774, 314, 1402, 14, 982, 663, 12, 658, 1210, 63, 2324, 64, 1471, 506, 658, 403, 2313, 489, 612, 26, 11388, 503, 3634, 359, 78, 63, 3356, 61, 503, 359, 78, 63, 3356, 12, 302, 63, 4467, 61, 503, 314, 2600, 402, 2011, 14, 268, 6855, 506, 6122, 626, 2529, 1625, 402, 3628, 503, 2600, 402, 1625, 402, 3628, 14, 268, 710, 6093, 1768, 1338, 334, 533, 3628, 315, 12505, 12, 3363, 5579, 315, 10864, 680, 268, 982, 663, 12, 658, 1210, 63, 2324, 64, 1471, 506, 658, 403, 2313, 3390, 26, 2104, 12505, 12, 1768, 1338, 1471, 268, 506, 9446, 6144, 314, 1021, 1478, 334, 73, 14, 69, 14, 1338, 687, 378, 370, 268, 302, 63, 2888, 13, 17, 680, 489, 1324, 63, 2324, 26, 6924, 805, 8152, 282, 2008, 402, 26, 881, 4534, 446, 658, 3861, 64, 503, 2600, 402, 1059, 3878, 536, 370, 658, 3861, 2313, 881, 3628, 446, 658, 3861, 64, 503, 2600, 402, 658, 3861, 64, 543, 3628, 14, 267, 982, 1324, 63, 2324, 365, 663, 12, 658, 88, 3559, 658, 89, 3559, 436, 658, 2912, 63, 890, 64, 1471, 506, 658, 403, 2313, 489, 7124, 26, 4860, 402, 7124, 367, 1314, 370, 3560, 1402, 14, 982, 658, 403, 3559, 3560, 28688, 14, 267, 283, 5895, 7, 5419, 11609, 1183, 14, 982, 1265, 1240, 2877, 5431, 5542, 8, 5895, 29, 709, 9, 2066, 267, 6093, 11058, 315, 3141, 3388, 7124, 14, 982, 1265, 2793, 1133, 2934, 370, 1172, 16316, 267, 13942, 8749, 663, 658, 988, 63, 5895, 64, 3140, 14, 982, 663, 12, 658, 988, 63, 5895, 64, 1471, 506, 267, 658, 403, 2313, 489, 3522, 63, 890, 26, 30829, 1568, 370, 675, 641, 314, 1324, 12, 4243, 370, 1642, 267, 6240, 402, 658, 88, 2313, 9498, 506, 658, 403, 64, 340, 658, 1210, 63, 2324, 64, 365, 2741, 14, 489, 26862, 26, 3820, 402, 658, 1563, 13189, 64, 5516, 4454, 14, 8051, 367, 13484, 267, 6272, 314, 6093, 4438, 14, 489, 1390, 63, 5895, 26, 4860, 402, 3141, 7124, 367, 1314, 370, 3560, 1402, 14, 982, 658, 403, 3559, 267, 3560, 28688, 14, 982, 663, 12, 658, 5895, 64, 1471, 506, 658, 403, 2313, 398, 16853, 4882, 370, 658, 3269, 8, 5895, 29, 1960, 12544, 4910, 1926, 6093, 267, 10615, 14, 4068, 314, 1163, 4926, 12, 2877, 4882, 370, 658, 3269, 8, 988, 63, 5895, 29, 1960, 12544, 4910, 267, 626, 314, 3499, 1240, 911, 440, 886, 1263, 8494, 3967, 1642, 1240, 8103, 267, 1006, 2948, 7124, 14, 339, 1803, 26, 489, 658, 277, 3559, 367, 6036, 316, 14, 272, 408, 272, 746, 4279, 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, 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, 0 ]
k3nnyfr/s2a_fr-nsis
s2a/Python/Lib/distutils/tests/test_dist.py
83
15708
# -*- coding: utf8 -*- """Tests for distutils.dist.""" import os import StringIO import sys import unittest import warnings import textwrap from distutils.dist import Distribution, fix_help_options from distutils.cmd import Command import distutils.dist from test.test_support import TESTFN, captured_stdout, run_unittest from distutils.tests import support class test_dist(Command): """Sample distutils extension command.""" user_options = [ ("sample-option=", "S", "help text"), ] def initialize_options(self): self.sample_option = None class TestDistribution(Distribution): """Distribution subclasses that avoids the default search for configuration files. The ._config_files attribute must be set before .parse_config_files() is called. """ def find_config_files(self): return self._config_files class DistributionTestCase(support.TempdirManager, support.LoggingSilencer, support.EnvironGuard, unittest.TestCase): def setUp(self): super(DistributionTestCase, self).setUp() self.argv = sys.argv, sys.argv[:] del sys.argv[1:] def tearDown(self): sys.argv = self.argv[0] sys.argv[:] = self.argv[1] super(DistributionTestCase, self).tearDown() def create_distribution(self, configfiles=()): d = TestDistribution() d._config_files = configfiles d.parse_config_files() d.parse_command_line() return d def test_debug_mode(self): with open(TESTFN, "w") as f: f.write("[global]\n") f.write("command_packages = foo.bar, splat") files = [TESTFN] sys.argv.append("build") with captured_stdout() as stdout: self.create_distribution(files) stdout.seek(0) self.assertEqual(stdout.read(), '') distutils.dist.DEBUG = True try: with captured_stdout() as stdout: self.create_distribution(files) stdout.seek(0) self.assertEqual(stdout.read(), '') finally: distutils.dist.DEBUG = False def test_command_packages_unspecified(self): sys.argv.append("build") d = self.create_distribution() self.assertEqual(d.get_command_packages(), ["distutils.command"]) def test_command_packages_cmdline(self): from distutils.tests.test_dist import test_dist sys.argv.extend(["--command-packages", "foo.bar,distutils.tests", "test_dist", "-Ssometext", ]) d = self.create_distribution() # let's actually try to load our test command: self.assertEqual(d.get_command_packages(), ["distutils.command", "foo.bar", "distutils.tests"]) cmd = d.get_command_obj("test_dist") self.assertIsInstance(cmd, test_dist) self.assertEqual(cmd.sample_option, "sometext") def test_command_packages_configfile(self): sys.argv.append("build") self.addCleanup(os.unlink, TESTFN) f = open(TESTFN, "w") try: print >> f, "[global]" print >> f, "command_packages = foo.bar, splat" finally: f.close() d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command", "foo.bar", "splat"]) # ensure command line overrides config: sys.argv[1:] = ["--command-packages", "spork", "build"] d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command", "spork"]) # Setting --command-packages to '' should cause the default to # be used even if a config file specified something else: sys.argv[1:] = ["--command-packages", "", "build"] d = self.create_distribution([TESTFN]) self.assertEqual(d.get_command_packages(), ["distutils.command"]) def test_write_pkg_file(self): # Check DistributionMetadata handling of Unicode fields tmp_dir = self.mkdtemp() my_file = os.path.join(tmp_dir, 'f') klass = Distribution dist = klass(attrs={'author': u'Mister Café', 'name': 'my.package', 'maintainer': u'Café Junior', 'description': u'Café torréfié', 'long_description': u'Héhéhé'}) # let's make sure the file can be written # with Unicode fields. they are encoded with # PKG_INFO_ENCODING dist.metadata.write_pkg_file(open(my_file, 'w')) # regular ascii is of course always usable dist = klass(attrs={'author': 'Mister Cafe', 'name': 'my.package', 'maintainer': 'Cafe Junior', 'description': 'Cafe torrefie', 'long_description': 'Hehehe'}) my_file2 = os.path.join(tmp_dir, 'f2') dist.metadata.write_pkg_file(open(my_file2, 'w')) def test_empty_options(self): # an empty options dictionary should not stay in the # list of attributes # catching warnings warns = [] def _warn(msg): warns.append(msg) self.addCleanup(setattr, warnings, 'warn', warnings.warn) warnings.warn = _warn dist = Distribution(attrs={'author': 'xxx', 'name': 'xxx', 'version': 'xxx', 'url': 'xxxx', 'options': {}}) self.assertEqual(len(warns), 0) self.assertNotIn('options', dir(dist)) def test_finalize_options(self): attrs = {'keywords': 'one,two', 'platforms': 'one,two'} dist = Distribution(attrs=attrs) dist.finalize_options() # finalize_option splits platforms and keywords self.assertEqual(dist.metadata.platforms, ['one', 'two']) self.assertEqual(dist.metadata.keywords, ['one', 'two']) def test_get_command_packages(self): dist = Distribution() self.assertEqual(dist.command_packages, None) cmds = dist.get_command_packages() self.assertEqual(cmds, ['distutils.command']) self.assertEqual(dist.command_packages, ['distutils.command']) dist.command_packages = 'one,two' cmds = dist.get_command_packages() self.assertEqual(cmds, ['distutils.command', 'one', 'two']) def test_announce(self): # make sure the level is known dist = Distribution() args = ('ok',) kwargs = {'level': 'ok2'} self.assertRaises(ValueError, dist.announce, args, kwargs) def test_find_config_files_disable(self): # Ticket #1180: Allow user to disable their home config file. temp_home = self.mkdtemp() if os.name == 'posix': user_filename = os.path.join(temp_home, ".pydistutils.cfg") else: user_filename = os.path.join(temp_home, "pydistutils.cfg") with open(user_filename, 'w') as f: f.write('[distutils]\n') def _expander(path): return temp_home old_expander = os.path.expanduser os.path.expanduser = _expander try: d = distutils.dist.Distribution() all_files = d.find_config_files() d = distutils.dist.Distribution(attrs={'script_args': ['--no-user-cfg']}) files = d.find_config_files() finally: os.path.expanduser = old_expander # make sure --no-user-cfg disables the user cfg file self.assertEqual(len(all_files)-1, len(files)) class MetadataTestCase(support.TempdirManager, support.EnvironGuard, unittest.TestCase): def setUp(self): super(MetadataTestCase, self).setUp() self.argv = sys.argv, sys.argv[:] def tearDown(self): sys.argv = self.argv[0] sys.argv[:] = self.argv[1] super(MetadataTestCase, self).tearDown() def test_classifier(self): attrs = {'name': 'Boa', 'version': '3.0', 'classifiers': ['Programming Language :: Python :: 3']} dist = Distribution(attrs) meta = self.format_metadata(dist) self.assertIn('Metadata-Version: 1.1', meta) def test_download_url(self): attrs = {'name': 'Boa', 'version': '3.0', 'download_url': 'http://example.org/boa'} dist = Distribution(attrs) meta = self.format_metadata(dist) self.assertIn('Metadata-Version: 1.1', meta) def test_long_description(self): long_desc = textwrap.dedent("""\ example:: We start here and continue here and end here.""") attrs = {"name": "package", "version": "1.0", "long_description": long_desc} dist = Distribution(attrs) meta = self.format_metadata(dist) meta = meta.replace('\n' + 8 * ' ', '\n') self.assertIn(long_desc, meta) def test_simple_metadata(self): attrs = {"name": "package", "version": "1.0"} dist = Distribution(attrs) meta = self.format_metadata(dist) self.assertIn("Metadata-Version: 1.0", meta) self.assertNotIn("provides:", meta.lower()) self.assertNotIn("requires:", meta.lower()) self.assertNotIn("obsoletes:", meta.lower()) def test_provides(self): attrs = {"name": "package", "version": "1.0", "provides": ["package", "package.sub"]} dist = Distribution(attrs) self.assertEqual(dist.metadata.get_provides(), ["package", "package.sub"]) self.assertEqual(dist.get_provides(), ["package", "package.sub"]) meta = self.format_metadata(dist) self.assertIn("Metadata-Version: 1.1", meta) self.assertNotIn("requires:", meta.lower()) self.assertNotIn("obsoletes:", meta.lower()) def test_provides_illegal(self): self.assertRaises(ValueError, Distribution, {"name": "package", "version": "1.0", "provides": ["my.pkg (splat)"]}) def test_requires(self): attrs = {"name": "package", "version": "1.0", "requires": ["other", "another (==1.0)"]} dist = Distribution(attrs) self.assertEqual(dist.metadata.get_requires(), ["other", "another (==1.0)"]) self.assertEqual(dist.get_requires(), ["other", "another (==1.0)"]) meta = self.format_metadata(dist) self.assertIn("Metadata-Version: 1.1", meta) self.assertNotIn("provides:", meta.lower()) self.assertIn("Requires: other", meta) self.assertIn("Requires: another (==1.0)", meta) self.assertNotIn("obsoletes:", meta.lower()) def test_requires_illegal(self): self.assertRaises(ValueError, Distribution, {"name": "package", "version": "1.0", "requires": ["my.pkg (splat)"]}) def test_obsoletes(self): attrs = {"name": "package", "version": "1.0", "obsoletes": ["other", "another (<1.0)"]} dist = Distribution(attrs) self.assertEqual(dist.metadata.get_obsoletes(), ["other", "another (<1.0)"]) self.assertEqual(dist.get_obsoletes(), ["other", "another (<1.0)"]) meta = self.format_metadata(dist) self.assertIn("Metadata-Version: 1.1", meta) self.assertNotIn("provides:", meta.lower()) self.assertNotIn("requires:", meta.lower()) self.assertIn("Obsoletes: other", meta) self.assertIn("Obsoletes: another (<1.0)", meta) def test_obsoletes_illegal(self): self.assertRaises(ValueError, Distribution, {"name": "package", "version": "1.0", "obsoletes": ["my.pkg (splat)"]}) def format_metadata(self, dist): sio = StringIO.StringIO() dist.metadata.write_pkg_file(sio) return sio.getvalue() def test_custom_pydistutils(self): # fixes #2166 # make sure pydistutils.cfg is found if os.name == 'posix': user_filename = ".pydistutils.cfg" else: user_filename = "pydistutils.cfg" temp_dir = self.mkdtemp() user_filename = os.path.join(temp_dir, user_filename) f = open(user_filename, 'w') try: f.write('.') finally: f.close() try: dist = Distribution() # linux-style if sys.platform in ('linux', 'darwin'): os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertIn(user_filename, files) # win32-style if sys.platform == 'win32': # home drive should be found os.environ['HOME'] = temp_dir files = dist.find_config_files() self.assertIn(user_filename, files, '%r not found in %r' % (user_filename, files)) finally: os.remove(user_filename) def test_fix_help_options(self): help_tuples = [('a', 'b', 'c', 'd'), (1, 2, 3, 4)] fancy_options = fix_help_options(help_tuples) self.assertEqual(fancy_options[0], ('a', 'b', 'c')) self.assertEqual(fancy_options[1], (1, 2, 3)) def test_show_help(self): # smoke test, just makes sure some help is displayed dist = Distribution() sys.argv = [] dist.help = 1 dist.script_name = 'setup.py' with captured_stdout() as s: dist.parse_command_line() output = [line for line in s.getvalue().split('\n') if line.strip() != ''] self.assertTrue(output) def test_read_metadata(self): attrs = {"name": "package", "version": "1.0", "long_description": "desc", "description": "xxx", "download_url": "http://example.com", "keywords": ['one', 'two'], "requires": ['foo']} dist = Distribution(attrs) metadata = dist.metadata # write it then reloads it PKG_INFO = StringIO.StringIO() metadata.write_pkg_file(PKG_INFO) PKG_INFO.seek(0) metadata.read_pkg_file(PKG_INFO) self.assertEqual(metadata.name, "package") self.assertEqual(metadata.version, "1.0") self.assertEqual(metadata.description, "xxx") self.assertEqual(metadata.download_url, 'http://example.com') self.assertEqual(metadata.keywords, ['one', 'two']) self.assertEqual(metadata.platforms, ['UNKNOWN']) self.assertEqual(metadata.obsoletes, None) self.assertEqual(metadata.requires, ['foo']) def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(DistributionTestCase)) suite.addTest(unittest.makeSuite(MetadataTestCase)) return suite if __name__ == "__main__": run_unittest(test_suite())
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 24, 1882, 199, 199, 624, 2925, 367, 7065, 14, 2686, 1041, 199, 646, 747, 199, 646, 5228, 199, 646, 984, 199, 646, 2882, 199, 646, 3598, 199, 646, 13390, 199, 199, 504, 7065, 14, 2686, 492, 11839, 12, 5325, 63, 3437, 63, 1419, 199, 504, 7065, 14, 1760, 492, 5817, 199, 646, 7065, 14, 2686, 199, 504, 511, 14, 396, 63, 4058, 492, 25788, 12, 17487, 63, 2703, 12, 1255, 63, 2796, 199, 504, 7065, 14, 2219, 492, 2291, 421, 199, 533, 511, 63, 2686, 8, 3110, 304, 272, 408, 8176, 7065, 3329, 1414, 1041, 339, 922, 63, 1419, 275, 359, 267, 1689, 3271, 13, 1422, 11107, 298, 51, 401, 298, 3437, 1318, 1288, 267, 1622, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 3271, 63, 1422, 275, 488, 421, 199, 533, 1379, 8580, 8, 8580, 304, 272, 408, 8580, 9180, 626, 23674, 314, 849, 2754, 367, 272, 2897, 1584, 14, 339, 710, 13653, 888, 63, 1725, 2225, 1471, 506, 663, 2544, 272, 1275, 1122, 63, 888, 63, 1725, 342, 365, 2797, 14, 272, 408, 339, 347, 2342, 63, 888, 63, 1725, 8, 277, 304, 267, 372, 291, 423, 888, 63, 1725, 421, 199, 533, 11839, 1746, 8, 4058, 14, 6530, 694, 2988, 12, 2574, 2291, 14, 14054, 51, 441, 78, 2247, 12, 2574, 2291, 14, 23027, 18183, 12, 2574, 2882, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 8580, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 3020, 275, 984, 14, 3020, 12, 984, 14, 3020, 5873, 267, 2150, 984, 14, 3020, 59, 17, 2938, 339, 347, 6766, 8, 277, 304, 267, 984, 14, 3020, 275, 291, 14, 3020, 59, 16, 61, 267, 984, 14, 3020, 5873, 275, 291, 14, 3020, 59, 17, 61, 267, 1613, 8, 8580, 1746, 12, 291, 680, 12336, 342, 339, 347, 1218, 63, 4972, 8, 277, 12, 1101, 1725, 23603, 267, 366, 275, 1379, 8580, 342, 267, 366, 423, 888, 63, 1725, 275, 1101, 1725, 267, 366, 14, 1122, 63, 888, 63, 1725, 342, 267, 366, 14, 1122, 63, 1531, 63, 604, 342, 267, 372, 366, 339, 347, 511, 63, 1757, 63, 632, 8, 277, 304, 267, 543, 1551, 8, 10179, 12, 298, 87, 531, 465, 289, 26, 288, 289, 14, 952, 10994, 2966, 7272, 78, 531, 288, 289, 14, 952, 480, 1531, 63, 5154, 275, 3925, 14, 1700, 12, 308, 14156, 531, 398, 1584, 275, 359, 10179, 61, 267, 984, 14, 3020, 14, 740, 480, 1506, 531, 398, 543, 17487, 63, 2703, 342, 465, 3839, 26, 288, 291, 14, 981, 63, 4972, 8, 1725, 9, 267, 3839, 14, 5507, 8, 16, 9, 267, 291, 14, 629, 8, 2703, 14, 739, 1062, 4074, 267, 7065, 14, 2686, 14, 5287, 275, 715, 267, 862, 26, 288, 543, 17487, 63, 2703, 342, 465, 3839, 26, 355, 291, 14, 981, 63, 4972, 8, 1725, 9, 288, 3839, 14, 5507, 8, 16, 9, 288, 291, 14, 629, 8, 2703, 14, 739, 1062, 4074, 267, 3753, 26, 288, 7065, 14, 2686, 14, 5287, 275, 756, 339, 347, 511, 63, 1531, 63, 5154, 63, 324, 10085, 8, 277, 304, 267, 984, 14, 3020, 14, 740, 480, 1506, 531, 267, 366, 275, 291, 14, 981, 63, 4972, 342, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 2097, 13350, 14, 1531, 3135, 339, 347, 511, 63, 1531, 63, 5154, 63, 15612, 8, 277, 304, 267, 687, 7065, 14, 2219, 14, 396, 63, 2686, 492, 511, 63, 2686, 267, 984, 14, 3020, 14, 2880, 5234, 306, 1531, 13, 5154, 401, 586, 298, 1421, 14, 1700, 12, 13350, 14, 2219, 401, 586, 298, 396, 63, 2686, 401, 586, 3905, 51, 3972, 505, 401, 586, 4794, 267, 366, 275, 291, 14, 981, 63, 4972, 342, 267, 327, 4691, 1159, 5965, 862, 370, 2248, 4154, 511, 1414, 26, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 586, 2097, 13350, 14, 1531, 401, 298, 1421, 14, 1700, 401, 298, 13350, 14, 2219, 3135, 267, 2088, 275, 366, 14, 362, 63, 1531, 63, 1113, 480, 396, 63, 2686, 531, 267, 291, 14, 6926, 8, 1760, 12, 511, 63, 2686, 9, 267, 291, 14, 629, 8, 1760, 14, 3271, 63, 1422, 12, 298, 3972, 505, 531, 339, 347, 511, 63, 1531, 63, 5154, 63, 29217, 8, 277, 304, 267, 984, 14, 3020, 14, 740, 480, 1506, 531, 267, 291, 14, 12808, 8, 736, 14, 7162, 12, 25788, 9, 267, 289, 275, 1551, 8, 10179, 12, 298, 87, 531, 267, 862, 26, 288, 870, 4331, 289, 12, 7369, 2966, 8480, 288, 870, 4331, 289, 12, 298, 1531, 63, 5154, 275, 3925, 14, 1700, 12, 308, 14156, 2, 267, 3753, 26, 288, 289, 14, 1600, 342, 398, 366, 275, 291, 14, 981, 63, 4972, 779, 10179, 566, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 586, 2097, 13350, 14, 1531, 401, 298, 1421, 14, 1700, 401, 298, 681, 4452, 3135, 398, 327, 4868, 1414, 1004, 10580, 1101, 26, 267, 984, 14, 3020, 59, 17, 2938, 275, 22448, 1531, 13, 5154, 401, 298, 681, 4708, 401, 298, 1506, 937, 267, 366, 275, 291, 14, 981, 63, 4972, 779, 10179, 566, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 586, 2097, 13350, 14, 1531, 401, 298, 681, 4708, 3135, 398, 327, 13510, 1553, 1531, 13, 5154, 370, 2125, 1077, 7675, 314, 849, 370, 267, 327, 506, 1202, 2755, 340, 282, 1101, 570, 2013, 6020, 587, 26, 267, 984, 14, 3020, 59, 17, 2938, 275, 22448, 1531, 13, 5154, 401, 4873, 298, 1506, 937, 267, 366, 275, 291, 14, 981, 63, 4972, 779, 10179, 566, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 2097, 13350, 14, 1531, 3135, 339, 347, 511, 63, 952, 63, 4600, 63, 493, 8, 277, 304, 267, 327, 2670, 11839, 5142, 7252, 402, 6140, 1504, 267, 3529, 63, 694, 275, 291, 14, 11983, 342, 267, 3002, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2791, 63, 694, 12, 283, 70, 358, 267, 8531, 275, 11839, 398, 2917, 275, 8531, 8, 3288, 3713, 2502, 356, 399 ]
[ 1882, 2803, 26, 2774, 24, 1882, 199, 199, 624, 2925, 367, 7065, 14, 2686, 1041, 199, 646, 747, 199, 646, 5228, 199, 646, 984, 199, 646, 2882, 199, 646, 3598, 199, 646, 13390, 199, 199, 504, 7065, 14, 2686, 492, 11839, 12, 5325, 63, 3437, 63, 1419, 199, 504, 7065, 14, 1760, 492, 5817, 199, 646, 7065, 14, 2686, 199, 504, 511, 14, 396, 63, 4058, 492, 25788, 12, 17487, 63, 2703, 12, 1255, 63, 2796, 199, 504, 7065, 14, 2219, 492, 2291, 421, 199, 533, 511, 63, 2686, 8, 3110, 304, 272, 408, 8176, 7065, 3329, 1414, 1041, 339, 922, 63, 1419, 275, 359, 267, 1689, 3271, 13, 1422, 11107, 298, 51, 401, 298, 3437, 1318, 1288, 267, 1622, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 3271, 63, 1422, 275, 488, 421, 199, 533, 1379, 8580, 8, 8580, 304, 272, 408, 8580, 9180, 626, 23674, 314, 849, 2754, 367, 272, 2897, 1584, 14, 339, 710, 13653, 888, 63, 1725, 2225, 1471, 506, 663, 2544, 272, 1275, 1122, 63, 888, 63, 1725, 342, 365, 2797, 14, 272, 408, 339, 347, 2342, 63, 888, 63, 1725, 8, 277, 304, 267, 372, 291, 423, 888, 63, 1725, 421, 199, 533, 11839, 1746, 8, 4058, 14, 6530, 694, 2988, 12, 2574, 2291, 14, 14054, 51, 441, 78, 2247, 12, 2574, 2291, 14, 23027, 18183, 12, 2574, 2882, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 8580, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 3020, 275, 984, 14, 3020, 12, 984, 14, 3020, 5873, 267, 2150, 984, 14, 3020, 59, 17, 2938, 339, 347, 6766, 8, 277, 304, 267, 984, 14, 3020, 275, 291, 14, 3020, 59, 16, 61, 267, 984, 14, 3020, 5873, 275, 291, 14, 3020, 59, 17, 61, 267, 1613, 8, 8580, 1746, 12, 291, 680, 12336, 342, 339, 347, 1218, 63, 4972, 8, 277, 12, 1101, 1725, 23603, 267, 366, 275, 1379, 8580, 342, 267, 366, 423, 888, 63, 1725, 275, 1101, 1725, 267, 366, 14, 1122, 63, 888, 63, 1725, 342, 267, 366, 14, 1122, 63, 1531, 63, 604, 342, 267, 372, 366, 339, 347, 511, 63, 1757, 63, 632, 8, 277, 304, 267, 543, 1551, 8, 10179, 12, 298, 87, 531, 465, 289, 26, 288, 289, 14, 952, 10994, 2966, 7272, 78, 531, 288, 289, 14, 952, 480, 1531, 63, 5154, 275, 3925, 14, 1700, 12, 308, 14156, 531, 398, 1584, 275, 359, 10179, 61, 267, 984, 14, 3020, 14, 740, 480, 1506, 531, 398, 543, 17487, 63, 2703, 342, 465, 3839, 26, 288, 291, 14, 981, 63, 4972, 8, 1725, 9, 267, 3839, 14, 5507, 8, 16, 9, 267, 291, 14, 629, 8, 2703, 14, 739, 1062, 4074, 267, 7065, 14, 2686, 14, 5287, 275, 715, 267, 862, 26, 288, 543, 17487, 63, 2703, 342, 465, 3839, 26, 355, 291, 14, 981, 63, 4972, 8, 1725, 9, 288, 3839, 14, 5507, 8, 16, 9, 288, 291, 14, 629, 8, 2703, 14, 739, 1062, 4074, 267, 3753, 26, 288, 7065, 14, 2686, 14, 5287, 275, 756, 339, 347, 511, 63, 1531, 63, 5154, 63, 324, 10085, 8, 277, 304, 267, 984, 14, 3020, 14, 740, 480, 1506, 531, 267, 366, 275, 291, 14, 981, 63, 4972, 342, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 2097, 13350, 14, 1531, 3135, 339, 347, 511, 63, 1531, 63, 5154, 63, 15612, 8, 277, 304, 267, 687, 7065, 14, 2219, 14, 396, 63, 2686, 492, 511, 63, 2686, 267, 984, 14, 3020, 14, 2880, 5234, 306, 1531, 13, 5154, 401, 586, 298, 1421, 14, 1700, 12, 13350, 14, 2219, 401, 586, 298, 396, 63, 2686, 401, 586, 3905, 51, 3972, 505, 401, 586, 4794, 267, 366, 275, 291, 14, 981, 63, 4972, 342, 267, 327, 4691, 1159, 5965, 862, 370, 2248, 4154, 511, 1414, 26, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 586, 2097, 13350, 14, 1531, 401, 298, 1421, 14, 1700, 401, 298, 13350, 14, 2219, 3135, 267, 2088, 275, 366, 14, 362, 63, 1531, 63, 1113, 480, 396, 63, 2686, 531, 267, 291, 14, 6926, 8, 1760, 12, 511, 63, 2686, 9, 267, 291, 14, 629, 8, 1760, 14, 3271, 63, 1422, 12, 298, 3972, 505, 531, 339, 347, 511, 63, 1531, 63, 5154, 63, 29217, 8, 277, 304, 267, 984, 14, 3020, 14, 740, 480, 1506, 531, 267, 291, 14, 12808, 8, 736, 14, 7162, 12, 25788, 9, 267, 289, 275, 1551, 8, 10179, 12, 298, 87, 531, 267, 862, 26, 288, 870, 4331, 289, 12, 7369, 2966, 8480, 288, 870, 4331, 289, 12, 298, 1531, 63, 5154, 275, 3925, 14, 1700, 12, 308, 14156, 2, 267, 3753, 26, 288, 289, 14, 1600, 342, 398, 366, 275, 291, 14, 981, 63, 4972, 779, 10179, 566, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 586, 2097, 13350, 14, 1531, 401, 298, 1421, 14, 1700, 401, 298, 681, 4452, 3135, 398, 327, 4868, 1414, 1004, 10580, 1101, 26, 267, 984, 14, 3020, 59, 17, 2938, 275, 22448, 1531, 13, 5154, 401, 298, 681, 4708, 401, 298, 1506, 937, 267, 366, 275, 291, 14, 981, 63, 4972, 779, 10179, 566, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 586, 2097, 13350, 14, 1531, 401, 298, 681, 4708, 3135, 398, 327, 13510, 1553, 1531, 13, 5154, 370, 2125, 1077, 7675, 314, 849, 370, 267, 327, 506, 1202, 2755, 340, 282, 1101, 570, 2013, 6020, 587, 26, 267, 984, 14, 3020, 59, 17, 2938, 275, 22448, 1531, 13, 5154, 401, 4873, 298, 1506, 937, 267, 366, 275, 291, 14, 981, 63, 4972, 779, 10179, 566, 267, 291, 14, 629, 8, 68, 14, 362, 63, 1531, 63, 5154, 1062, 2097, 13350, 14, 1531, 3135, 339, 347, 511, 63, 952, 63, 4600, 63, 493, 8, 277, 304, 267, 327, 2670, 11839, 5142, 7252, 402, 6140, 1504, 267, 3529, 63, 694, 275, 291, 14, 11983, 342, 267, 3002, 63, 493, 275, 747,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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 ]
ansible/ansible-modules-extras
windows/win_timezone.py
23
1552
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Phil Schwartz <schwartzmx@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # this is a windows documentation stub. actual code lives in the .ps1 # file of the same name ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' --- module: win_timezone version_added: "2.1" short_description: Sets Windows machine timezone description: - Sets machine time to the specified timezone, the module will check if the provided timezone is supported on the machine. options: timezone: description: - Timezone to set to. Example Central Standard Time required: true default: null aliases: [] author: Phil Schwartz ''' EXAMPLES = ''' # Set machine's timezone to Central Standard Time win_timezone: timezone: "Central Standard Time" ''' RETURN = '''# '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 11308, 382, 22985, 87, 28124, 665, 15820, 87, 28124, 9457, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 642, 365, 282, 10061, 3794, 10098, 14, 221, 3503, 1233, 27576, 315, 314, 1275, 1190, 17, 199, 3, 570, 402, 314, 2011, 536, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4747, 63, 7145, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 3612, 63, 1802, 26, 10729, 5417, 6844, 7137, 199, 1802, 26, 272, 446, 10729, 6844, 900, 370, 314, 2013, 7137, 12, 314, 859, 911, 1104, 340, 314, 2741, 7137, 365, 3748, 641, 314, 6844, 14, 199, 1419, 26, 523, 7137, 26, 272, 1369, 26, 489, 446, 4703, 2619, 370, 663, 370, 14, 221, 5679, 32267, 9117, 9739, 4703, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 199, 199, 2502, 26, 11308, 382, 22985, 87, 28124, 199, 2344, 421, 199, 8918, 275, 1449, 523, 327, 2494, 6844, 1159, 7137, 370, 32267, 9117, 9739, 4703, 523, 4747, 63, 7145, 26, 272, 7137, 26, 298, 25290, 9739, 4703, 2, 199, 2344, 199, 199, 9677, 275, 1449, 3, 1449, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 11308, 382, 22985, 87, 28124, 665, 15820, 87, 28124, 9457, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 642, 365, 282, 10061, 3794, 10098, 14, 221, 3503, 1233, 27576, 315, 314, 1275, 1190, 17, 199, 3, 570, 402, 314, 2011, 536, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 4747, 63, 7145, 199, 1023, 63, 3270, 26, 298, 18, 14, 17, 2, 199, 3612, 63, 1802, 26, 10729, 5417, 6844, 7137, 199, 1802, 26, 272, 446, 10729, 6844, 900, 370, 314, 2013, 7137, 12, 314, 859, 911, 1104, 340, 314, 2741, 7137, 365, 3748, 641, 314, 6844, 14, 199, 1419, 26, 523, 7137, 26, 272, 1369, 26, 489, 446, 4703, 2619, 370, 663, 370, 14, 221, 5679, 32267, 9117, 9739, 4703, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 199, 199, 2502, 26, 11308, 382, 22985, 87, 28124, 199, 2344, 421, 199, 8918, 275, 1449, 523, 327, 2494, 6844, 1159, 7137, 370, 32267, 9117, 9739, 4703, 523, 4747, 63, 7145, 26, 272, 7137, 26, 298, 25290, 9739, 4703, 2, 199, 2344, 199, 199, 9677, 275, 1449, 3, 1449, 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, 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,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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 ]
Evervolv/android_kernel_lge_v500
tools/perf/scripts/python/sctop.py
11180
1924
# system call top # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(interval): while 1: clear_term() if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gammalib/gammalib
inst/cta/test/dev/test_irf_trafo.py
2
1694
#! /usr/bin/env python # ===========================================================================================# # Test coordinate transformations for IRF computation. # ===========================================================================================# from gammalib import * from math import * # ====================== # # Compute Omega0 # # ====================== # def omega0(): """ ... """ # Set pointing direction pointing = GSkyDir() pointing.radec_deg(10.0, 10.0) # Set model centre model = GSkyDir() model.radec_deg(12.0, 10.0) # Set measured photon direction p = GSkyDir() p.radec_deg(13.0, 9.0) # Determine angular distance between measured photon direction and model centre zeta = model.dist(p) # Determine angular distance between measured photon direction and pointing direction eta = pointing.dist(p) # Determine angular distance between model centre and pointing direction lamda = model.dist(pointing) # Compute Omega0 omega0 = 0.0 omega2 = 0.0 denom = sin(lamda) * sin(zeta) if denom != 0.0: arg = (cos(eta) - cos(lamda) * cos(zeta)) / denom arg2 = cos(eta) / denom - 1. / (tan(lamda) * tan(zeta)) omega0 = acos(arg) omega2 = acos(arg2) # Print results print "Omega0 ...: ", omega0 * 180.0 / pi print "Omega0 ...: ", omega2 * 180.0 / pi print "Zeta .....: ", zeta print "Eta ......: ", eta print "Lambda ...: ", lamda # Return return #==========================# # Main routine entry point # #==========================# if __name__ == '__main__': """ ... """ # ... omega0()
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 7819, 1280, 17575, 3, 199, 3, 1379, 10021, 25947, 367, 473, 11778, 14009, 14, 199, 3, 7819, 1280, 17575, 3, 199, 504, 486, 455, 2174, 1892, 492, 627, 199, 504, 3473, 492, 627, 421, 199, 3, 16248, 19989, 327, 199, 3, 8354, 593, 29073, 16, 327, 199, 3, 16248, 19989, 327, 199, 318, 29566, 16, 837, 272, 408, 272, 2263, 272, 408, 272, 327, 2494, 20686, 7581, 272, 20686, 275, 598, 51, 10562, 3567, 342, 272, 20686, 14, 345, 7778, 63, 6458, 8, 709, 14, 16, 12, 1616, 14, 16, 9, 339, 327, 2494, 1402, 13345, 264, 272, 1402, 275, 598, 51, 10562, 3567, 342, 272, 1402, 14, 345, 7778, 63, 6458, 8, 713, 14, 16, 12, 1616, 14, 16, 9, 339, 327, 2494, 27396, 3945, 357, 265, 7581, 272, 299, 275, 598, 51, 10562, 3567, 342, 272, 299, 14, 345, 7778, 63, 6458, 8, 969, 14, 16, 12, 1749, 14, 16, 9, 339, 327, 14703, 30921, 6033, 3382, 27396, 3945, 357, 265, 7581, 436, 1402, 13345, 264, 272, 1315, 1841, 275, 1402, 14, 2686, 8, 80, 9, 339, 327, 14703, 30921, 6033, 3382, 27396, 3945, 357, 265, 7581, 436, 20686, 7581, 272, 20356, 275, 20686, 14, 2686, 8, 80, 9, 339, 327, 14703, 30921, 6033, 3382, 1402, 13345, 264, 436, 20686, 7581, 272, 25917, 983, 275, 1402, 14, 2686, 8, 1403, 316, 9, 339, 327, 8354, 593, 29073, 16, 272, 29566, 16, 275, 378, 14, 16, 272, 29566, 18, 275, 378, 14, 16, 272, 27878, 275, 9829, 8, 17984, 983, 9, 627, 9829, 8, 90, 1841, 9, 272, 340, 27878, 1137, 378, 14, 16, 26, 267, 1680, 275, 334, 5197, 8, 1841, 9, 446, 9794, 8, 17984, 983, 9, 627, 9794, 8, 90, 1841, 430, 1182, 27878, 267, 1680, 18, 275, 9794, 8, 1841, 9, 1182, 27878, 446, 413, 14, 1182, 334, 12990, 8, 17984, 983, 9, 627, 20162, 8, 90, 1841, 430, 267, 29566, 16, 275, 282, 5197, 8, 1273, 9, 267, 29566, 18, 275, 282, 5197, 8, 1273, 18, 9, 339, 327, 9101, 2058, 272, 870, 298, 47, 29073, 16, 2263, 26, 3872, 29566, 16, 627, 13576, 14, 16, 1182, 6682, 272, 870, 298, 47, 29073, 16, 2263, 26, 3872, 29566, 18, 627, 13576, 14, 16, 1182, 6682, 272, 870, 298, 25929, 2508, 1396, 26, 3872, 1315, 1841, 272, 870, 298, 37, 502, 2508, 4496, 26, 3872, 20356, 272, 870, 298, 21350, 2263, 26, 3872, 25917, 983, 339, 327, 1432, 272, 372, 421, 199, 3, 1280, 17575, 3, 199, 3, 11298, 12981, 2397, 2376, 327, 199, 3, 1280, 17575, 3, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 408, 272, 2263, 272, 408, 272, 327, 2263, 272, 29566, 16, 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 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 7819, 1280, 17575, 3, 199, 3, 1379, 10021, 25947, 367, 473, 11778, 14009, 14, 199, 3, 7819, 1280, 17575, 3, 199, 504, 486, 455, 2174, 1892, 492, 627, 199, 504, 3473, 492, 627, 421, 199, 3, 16248, 19989, 327, 199, 3, 8354, 593, 29073, 16, 327, 199, 3, 16248, 19989, 327, 199, 318, 29566, 16, 837, 272, 408, 272, 2263, 272, 408, 272, 327, 2494, 20686, 7581, 272, 20686, 275, 598, 51, 10562, 3567, 342, 272, 20686, 14, 345, 7778, 63, 6458, 8, 709, 14, 16, 12, 1616, 14, 16, 9, 339, 327, 2494, 1402, 13345, 264, 272, 1402, 275, 598, 51, 10562, 3567, 342, 272, 1402, 14, 345, 7778, 63, 6458, 8, 713, 14, 16, 12, 1616, 14, 16, 9, 339, 327, 2494, 27396, 3945, 357, 265, 7581, 272, 299, 275, 598, 51, 10562, 3567, 342, 272, 299, 14, 345, 7778, 63, 6458, 8, 969, 14, 16, 12, 1749, 14, 16, 9, 339, 327, 14703, 30921, 6033, 3382, 27396, 3945, 357, 265, 7581, 436, 1402, 13345, 264, 272, 1315, 1841, 275, 1402, 14, 2686, 8, 80, 9, 339, 327, 14703, 30921, 6033, 3382, 27396, 3945, 357, 265, 7581, 436, 20686, 7581, 272, 20356, 275, 20686, 14, 2686, 8, 80, 9, 339, 327, 14703, 30921, 6033, 3382, 1402, 13345, 264, 436, 20686, 7581, 272, 25917, 983, 275, 1402, 14, 2686, 8, 1403, 316, 9, 339, 327, 8354, 593, 29073, 16, 272, 29566, 16, 275, 378, 14, 16, 272, 29566, 18, 275, 378, 14, 16, 272, 27878, 275, 9829, 8, 17984, 983, 9, 627, 9829, 8, 90, 1841, 9, 272, 340, 27878, 1137, 378, 14, 16, 26, 267, 1680, 275, 334, 5197, 8, 1841, 9, 446, 9794, 8, 17984, 983, 9, 627, 9794, 8, 90, 1841, 430, 1182, 27878, 267, 1680, 18, 275, 9794, 8, 1841, 9, 1182, 27878, 446, 413, 14, 1182, 334, 12990, 8, 17984, 983, 9, 627, 20162, 8, 90, 1841, 430, 267, 29566, 16, 275, 282, 5197, 8, 1273, 9, 267, 29566, 18, 275, 282, 5197, 8, 1273, 18, 9, 339, 327, 9101, 2058, 272, 870, 298, 47, 29073, 16, 2263, 26, 3872, 29566, 16, 627, 13576, 14, 16, 1182, 6682, 272, 870, 298, 47, 29073, 16, 2263, 26, 3872, 29566, 18, 627, 13576, 14, 16, 1182, 6682, 272, 870, 298, 25929, 2508, 1396, 26, 3872, 1315, 1841, 272, 870, 298, 37, 502, 2508, 4496, 26, 3872, 20356, 272, 870, 298, 21350, 2263, 26, 3872, 25917, 983, 339, 327, 1432, 272, 372, 421, 199, 3, 1280, 17575, 3, 199, 3, 11298, 12981, 2397, 2376, 327, 199, 3, 1280, 17575, 3, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 408, 272, 2263, 272, 408, 272, 327, 2263, 272, 29566, 16, 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, 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,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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 ]
sudheesh001/oh-mainline
mysite/search/tests.py
8
57916
# This file is part of OpenHatch. # Copyright (C) 2010 Parker Phinney # Copyright (C) 2010 Jack Grigg # Copyright (C) 2009, 2010 OpenHatch, Inc. # Copyright (C) 2010 Jessica McKellar # # 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 mysite.base.tests import make_twill_url, TwillTests import mysite.base.models import mysite.account.tests from mysite.profile.models import Person import mysite.profile.models import mysite.search.view_helpers from mysite.search.models import (Project, Bug, ProjectInvolvementQuestion, Answer, BugAlert) from mysite.search import views import datetime import logging import mysite.project.views from django.utils.unittest import skipIf from django.utils.unittest import expectedFailure import django.db import django.conf from django.utils import http import json import mock from twill import commands as tc from django.test import TestCase import django.core.cache from django.core.urlresolvers import reverse from django.core.files.base import ContentFile from django.contrib.auth.models import User logger = logging.getLogger(__name__) class SearchTest(TwillTests): def search_via_twill(self, query=None): search_url = "http://openhatch.org/search/" if query: search_url += '?q=%s' % query tc.go(make_twill_url(search_url)) def search_via_client(self, query=None): search_url = "/search/" return self.client.get(search_url, {u'q': query}) def compare_lists(self, one, two): self.assertEqual(len(one), len(two)) self.assertEqual(set(one), set(two)) def compare_lists_of_dicts(self, one, two, sort_key=None): if sort_key is not None: sort_fn = lambda thing: thing[sort_key] else: sort_fn = None sorted_one = sorted(one, key=sort_fn) sorted_two = sorted(two, key=sort_fn) for k in range(len(sorted_one)): try: self.assertEqual(sorted_one[k], sorted_two[k]) except AssertionError: import sys print >> sys.stderr, sorted_one print >> sys.stderr, sorted_two raise for k in range(len(sorted_two)): try: self.assertEqual(sorted_one[k], sorted_two[k]) except AssertionError: import sys print >> sys.stderr, sorted_one print >> sys.stderr, sorted_two raise class TestThatQueryTokenizesRespectingQuotationMarks(TwillTests): def test(self): difficult = "With spaces (and parens)" query = mysite.search.view_helpers.Query.create_from_GET_data( {u'q': u'"%s"' % difficult}) self.assertEqual(query.terms, [difficult]) # Make there be a bug to find project = Project.create_dummy(name=difficult) Bug.create_dummy(project=project) # How many bugs? num_bugs = query.get_bugs_unordered().count() self.assertEqual(num_bugs, 1) class SearchResults(TwillTests): fixtures = [u'bugs-for-two-projects.json'] @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def test_query_object_is_false_when_no_terms_or_facets(self): query = mysite.search.view_helpers.Query.create_from_GET_data({}) self.assertFalse(query) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def test_show_no_bugs_if_no_query(self): # Call up search page with no query. response = self.client.get(u'/search/') # The variable u'bunch_of_bugs', passed to the template, is a blank # list. self.assertEqual(response.context[0][u'bunch_of_bugs'], []) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def test_json_view(self): tc.go(make_twill_url(( u'http://openhatch.org/search/?format=json&jsoncallback=callback&' u'q=python'))) response = tc.show() self.assert_(response.startswith(u'callback')) json_string_with_parens = response.split(u'callback', 1)[1] self.assert_(json_string_with_parens[0] == u'(') self.assert_(json_string_with_parens[-1] == u')') json_string = json_string_with_parens[1:-1] objects = json.loads(json_string) self.assert_(u'pk' in objects[0][u'bugs'][0]) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def testPagination(self): url = u'http://openhatch.org/search/' tc.go(make_twill_url(url)) tc.fv(u'search_opps', u'q', u'python') tc.submit() # Grab descriptions of first 10 Exaile bugs bugs = Bug.all_bugs.filter( project__name=u'Exaile').order_by(u'-last_touched')[:10] for bug in bugs: tc.find(bug.description) # Hit the next button tc.follow(u'Next') # Grab descriptions of next 10 Exaile bugs bugs = Bug.all_bugs.filter( project__name=u'Exaile').order_by(u'-last_touched')[10:20] for bug in bugs: tc.find(bug.description) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") def testPaginationWithAnyFacet(self): url = u'http://openhatch.org/search/?q=&language=' tc.go(make_twill_url(url)) bugs = Bug.all_bugs.order_by(u'-last_touched') for bug in bugs[:10]: tc.find(bug.description) print "Found bug ", bug tc.follow(u'Next') bugs = bugs[10:20] for bug in bugs: tc.find(bug.description) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def testPaginationAndChangingSearchQuery(self): url = u'http://openhatch.org/search/' tc.go(make_twill_url(url)) tc.fv(u'search_opps', u'q', u'python') tc.submit() # Grab descriptions of first 10 Exaile bugs bugs = Bug.all_bugs.filter( project__name=u'Exaile').order_by(u'-last_touched')[:10] for bug in bugs: tc.find(bug.description) # Hit the next button tc.follow(u'Next') # Grab descriptions of next 10 Exaile bugs bugs = Bug.all_bugs.filter( project__name=u'Exaile').order_by(u'-last_touched')[10:20] for bug in bugs: tc.find(bug.description) # Now, change the query - do we stay that paginated? tc.fv(u'search_opps', u'q', u'c#') tc.submit() # Grab descriptions of first 10 GNOME-Do bugs bugs = Bug.all_bugs.filter( project__name=u'GNOME-Do').order_by(u'-last_touched')[:10] for bug in bugs: tc.find(bug.description) class SplitIntoTerms(TestCase): def test_split_into_terms(self): easy = '1 2 3' self.assertEqual( mysite.search.view_helpers.Query.split_into_terms(easy), ['1', '2', '3']) easy = '"1"' self.assertEqual( mysite.search.view_helpers.Query.split_into_terms(easy), ['1']) easy = 'c#' self.assertEqual( mysite.search.view_helpers.Query.split_into_terms(easy), ['c#']) class IconGetsScaled(SearchTest): @skipIf(not mysite.base.depends.Image, ("Skipping this test. Install PIL " "to run it; see " "ADVANCED_INSTALLATION.mkd.")) def test_project_scales_its_icon_down_for_use_in_badge(self): '''This test shows that the Project class successfully stores a scaled-down version of its icon in the icon_smaller_for_badge field.''' # Step 1: Create a project with an icon p = mysite.search.models.Project.create_dummy() image_data = open( mysite.account.tests.photo('static/sample-photo.png')).read() p.icon_raw.save('', ContentFile(image_data)) p.save() # Assertion 1: p.icon_smaller_for_badge is false (since not scaled yet) self.assertFalse(p.icon_smaller_for_badge) # Step 2: Call the scaling method p.update_scaled_icons_from_self_icon() p.save() # Assertion 2: Verify that it is now a true value self.assert_(p.icon_smaller_for_badge, "Expected p.icon_smaller_for_badge to be a true value.") # Assertion 3: Verify that it has the right width self.assertEqual( p.icon_smaller_for_badge.width, 40, "Expected p.icon_smaller_for_badge to be 40 pixels wide.") @skipIf(not mysite.base.depends.Image, ("Skipping this test. Install PIL " "to run it; see " "ADVANCED_INSTALLATION.mkd.")) def test_short_icon_is_scaled_correctly(self): '''Sometimes icons are rectangular and more wide than long. These icons shouldn't be trammeled into a square, but scaled respectfully of their original ratios.''' # Step 1: Create a project with an icon p = mysite.search.models.Project.create_dummy() # account.tests.photo finds the right path. image_data = open(mysite.account.tests.photo( 'static/images/icons/test-project-icon-64px-by-18px.png')).read() p.icon_raw.save('', ContentFile(image_data)) p.save() # Assertion 1: p.icon_smaller_for_badge is false (since not scaled yet) self.assertFalse(p.icon_smaller_for_badge) # Step 2: Call the scaling method p.update_scaled_icons_from_self_icon() p.save() # Assertion 2: Verify that it is now a true value self.assert_(p.icon_smaller_for_badge, "Expected p.icon_smaller_for_badge to be a true value.") # Assertion 3: Verify that it has the right width self.assertEqual( p.icon_smaller_for_badge.width, 40, "Expected p.icon_smaller_for_badge to be 40 pixels wide.") # Assertion 3: Verify that it has the right height # If we want to scale exactly we'll get 11.25 pixels, which rounds to # 11. self.assertEqual(p.icon_smaller_for_badge.height, 11) class SearchOnFullWords(SearchTest): @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_find_perl_not_properly(self): Project.create_dummy() Bug.create_dummy(description='properly') perl_bug = Bug.create_dummy(description='perl') self.assertEqual(Bug.all_bugs.all().count(), 2) results = mysite.search.view_helpers.Query( terms=['perl']).get_bugs_unordered() self.assertEqual(list(results), [perl_bug]) class SearchTemplateDecodesQueryString(SearchTest): def test_facets_appear_in_search_template_context(self): response = self.client.get('/search/', {'language': 'Python'}) expected_facets = {'language': 'Python'} self.assertEqual(response.context['query'].active_facet_options, expected_facets) class FacetsFilterResults(SearchTest): def test_facets_filter_results(self): facets = {u'language': u'Python'} # Those facets should pick up this bug: python_project = Project.create_dummy(language='Python') python_bug = Bug.create_dummy(project=python_project) # But not this bug not_python_project = Project.create_dummy(language='Nohtyp') Bug.create_dummy(project=not_python_project) results = mysite.search.view_helpers.Query( terms=[], active_facet_options=facets).get_bugs_unordered() self.assertEqual(list(results), [python_bug]) def test_any_facet(self): """In the search_index() method in the search module, the truthfulness of the Query object is evaluated to determine whether or not any results should be returned. Here, we test that if a facet in the GET data is the empty string, the query is still considered to be True. A facet set to the empty string is used to signify that the user selected the "any" option on the search page. If a facet is not provided at all, the user did not select anything on the search page, meaning no results should be returned. """ language_query = mysite.search.view_helpers.Query.create_from_GET_data( {'language': ''}) project_query = mysite.search.view_helpers.Query.create_from_GET_data( {'project': ''}) self.assertTrue(language_query) self.assertTrue(project_query) class QueryGetPossibleFacets(SearchTest): """Ask a query, what facets are you going to show on the left? E.g., search for gtk, it says C (541).""" def test_get_possible_facets(self): # Create three projects project1 = Project.create_dummy(language=u'c') project2 = Project.create_dummy(language=u'd') project3 = Project.create_dummy(language=u'e') # Give each project a bug Bug.create_dummy(project=project1, description=u'bug', good_for_newcomers=True) Bug.create_dummy(project=project2, description=u'bug') Bug.create_dummy(project=project3, description=u'bAg') # Search for bugs matching "bug", while constraining to the language C query = mysite.search.view_helpers.Query( terms=[u'bug'], terms_string=u'bug', active_facet_options={u'language': u'c'}) possible_facets = dict(query.get_possible_facets()) self.assertEqual(query.get_bugs_unordered().count(), 1) # We expect that, language-wise, you should be able to select any of # the other languages, or 'deselect' your language constraint. self.compare_lists_of_dicts( possible_facets[u'language'][u'options'], [ {u'name': u'c', u'query_string': u'q=bug&language=c', u'is_active': True, u'count': 1}, {u'name': u'd', u'query_string': u'q=bug&language=d', u'is_active': False, u'count': 1}, # e is excluded because its bug (u'bAg') doesn't match the # term 'bug' ], sort_key=u'name' ) self.compare_lists_of_dicts( possible_facets[u'toughness'][u'options'], [ # There's no 'any' option for toughness unless you've # selected a specific toughness value {u'name': u'bitesize', u'is_active': False, u'query_string': u'q=bug&toughness=bitesize&language=c', u'count': 1}, ], sort_key=u'name' ) self.assertEqual( possible_facets['language']['the_any_option'], {u'name': u'any', u'query_string': u'q=bug&language=', u'is_active': False, u'count': 2}, ) def test_possible_facets_always_includes_active_facet(self): # even when active facet has no results. c = Project.create_dummy(language=u'c') Project.create_dummy(language=u'd') Project.create_dummy(language=u'e') Bug.create_dummy(project=c, description=u'bug') query = mysite.search.view_helpers.Query.create_from_GET_data( {u'q': u'nothing matches this', u'language': u'c'}) language_options = dict( query.get_possible_facets())['language']['options'] language_options_named_c = [ opt for opt in language_options if opt['name'] == 'c'] self.assertEqual(len(language_options_named_c), 1) class SingleTerm(SearchTest): """Search for just a single term.""" def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language='Python') perl_project = Project.create_dummy(language='Perl') c_project = Project.create_dummy(language='C') # bitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=True, description='screensaver') # nonbitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=False, description='screensaver') # nonbitesize, matching bug in Perl Bug.create_dummy(project=perl_project, good_for_newcomers=False, description='screensaver') # nonbitesize, nonmatching bug in C Bug.create_dummy(project=c_project, good_for_newcomers=False, description='toast') GET_data = {'q': 'screensaver'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) self.assertEqual(query.terms, ['screensaver']) self.assertFalse(query.active_facet_options) # No facets self.output_possible_facets = dict(query.get_possible_facets()) def test_toughness_facet(self): # What options do we expect? toughness_option_bitesize = { 'name': 'bitesize', 'count': 1, 'is_active': False, 'query_string': 'q=screensaver&toughness=bitesize' } toughness_option_any = { 'name': 'any', 'count': 3, 'is_active': True, 'query_string': 'q=screensaver&toughness=' } expected_toughness_facet_options = [toughness_option_bitesize] self.assertEqual( self.output_possible_facets['toughness']['options'], expected_toughness_facet_options ) self.assertEqual( self.output_possible_facets['toughness']['the_any_option'], toughness_option_any ) def test_languages_facet(self): # What options do we expect? languages_option_python = { 'name': 'Python', 'count': 2, 'is_active': False, 'query_string': 'q=screensaver&language=Python' } languages_option_perl = { 'name': 'Perl', 'count': 1, 'is_active': False, 'query_string': 'q=screensaver&language=Perl' } languages_option_any = { 'name': 'any', 'count': 3, 'is_active': True, 'query_string': 'q=screensaver&language=' } expected_languages_facet_options = [ languages_option_python, languages_option_perl, ] self.compare_lists_of_dicts( self.output_possible_facets['language']['options'], expected_languages_facet_options ) self.assertEqual( self.output_possible_facets['language']['the_any_option'], languages_option_any) class SingleFacetOption(SearchTest): """Browse bugs matching a single facet option.""" def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language='Python') perl_project = Project.create_dummy(language='Perl') c_project = Project.create_dummy(language='C') # bitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=True, description='screensaver') # nonbitesize, matching bug in Python Bug.create_dummy(project=python_project, good_for_newcomers=False, description='screensaver') # nonbitesize, matching bug in Perl Bug.create_dummy(project=perl_project, good_for_newcomers=False, description='screensaver') # nonbitesize, nonmatching bug in C Bug.create_dummy(project=c_project, good_for_newcomers=False, description='toast') GET_data = {u'language': u'Python'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) self.assertFalse(query.terms) # No terms self.assertEqual(query.active_facet_options, {u'language': u'Python'}) self.output_possible_facets = dict(query.get_possible_facets()) def test_toughness_facet(self): # What options do we expect? toughness_option_bitesize = { u'name': u'bitesize', u'count': 1, u'is_active': False, u'query_string': u'q=&toughness=bitesize&language=Python' } toughness_option_any = { u'name': u'any', u'count': 2, u'is_active': True, u'query_string': u'q=&toughness=&language=Python' } expected_toughness_facet_options = [toughness_option_bitesize] self.compare_lists_of_dicts( self.output_possible_facets[u'toughness'][u'options'], expected_toughness_facet_options ) self.assertEqual( self.output_possible_facets[u'toughness'][u'the_any_option'], toughness_option_any ) def test_languages_facet(self): # What options do we expect? languages_option_python = { u'name': u'Python', u'count': 2, u'is_active': True, u'query_string': u'q=&language=Python' } languages_option_perl = { u'name': u'Perl', u'count': 1, u'is_active': False, u'query_string': u'q=&language=Perl' } languages_option_c = { u'name': u'C', u'count': 1, u'is_active': False, u'query_string': u'q=&language=C' } languages_option_any = { u'name': u'any', u'count': 4, u'is_active': False, u'query_string': u'q=&language=' } expected_languages_facet_options = [ languages_option_python, languages_option_perl, languages_option_c, ] self.compare_lists_of_dicts( self.output_possible_facets[u'language'][u'options'], expected_languages_facet_options ) self.assertEqual( self.output_possible_facets[u'language'][u'the_any_option'], languages_option_any, ) class QueryGetToughnessFacetOptions(SearchTest): def test_get_toughness_facet_options(self): # We create three "bitesize" bugs, but constrain the Query so # that we're only looking at bugs in Python. # Since only two of the bitesize bugs are in Python (one is # in a project whose language is Perl), we expect only 1 bitesize # bug to show up, and 2 total bugs. python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') Bug.create_dummy(project=python_project, good_for_newcomers=True) Bug.create_dummy(project=python_project, good_for_newcomers=False) Bug.create_dummy(project=perl_project, good_for_newcomers=True) query = mysite.search.view_helpers.Query( active_facet_options={u'language': u'Python'}, terms_string=u'') output = query.get_facet_options(u'toughness', [u'bitesize', u'']) bitesize_dict = [d for d in output if d[u'name'] == u'bitesize'][0] all_dict = [d for d in output if d[u'name'] == u'any'][0] self.assertEqual(bitesize_dict[u'count'], 1) self.assertEqual(all_dict[u'count'], 2) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_get_toughness_facet_options_with_terms(self): python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') Bug.create_dummy(project=python_project, good_for_newcomers=True, description=u'a') Bug.create_dummy(project=python_project, good_for_newcomers=False, description=u'a') Bug.create_dummy(project=perl_project, good_for_newcomers=True, description=u'b') GET_data = {u'q': u'a'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) output = query.get_facet_options(u'toughness', [u'bitesize', u'']) bitesize_dict = [d for d in output if d[u'name'] == u'bitesize'][0] all_dict = [d for d in output if d[u'name'] == u'any'][0] self.assertEqual(bitesize_dict[u'count'], 1) self.assertEqual(all_dict[u'count'], 2) class QueryGetPossibleLanguageFacetOptionNames(SearchTest): def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') c_project = Project.create_dummy(language=u'C') unknown_project = Project.create_dummy(language=u'') Bug.create_dummy(project=python_project, title=u'a') Bug.create_dummy(project=perl_project, title=u'a') Bug.create_dummy(project=c_project, title=u'b') Bug.create_dummy(project=unknown_project, title=u'unknowable') @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_with_term(self): # In the setUp we create three bugs, but only two of them would match # a search for 'a'. They are in two different languages, so let's make # sure that we show only those two languages. GET_data = {u'q': u'a'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) language_names = query.get_language_names() self.assertEqual( sorted(language_names), sorted([u'Python', u'Perl'])) def test_with_active_language_facet(self): # In the setUp we create bugs in three languages. # Here, we verify that the get_language_names() method correctly # returns all three languages, even though the GET data shows that # we are browsing by language. GET_data = {u'language': u'Python'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) language_names = query.get_language_names() self.assertEqual( sorted(language_names), sorted([u'Python', u'Perl', u'C', u'Unknown'])) def test_with_language_as_unknown(self): # In the setUp we create bugs in three languages. # Here, we verify that the get_language_names() method correctly # returns all three languages, even though the GET data shows that # we are browsing by language. GET_data = {u'language': u'Unknown'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) language_names = query.get_language_names() self.assertEqual( sorted(language_names), sorted([u'Python', u'Perl', u'C', u'Unknown'])) def test_with_language_as_unknown_and_query(self): # In the setUp we create bugs in three languages. # Here, we verify that the get_language_names() method correctly # returns all three languages, even though the GET data shows that # we are browsing by language. GET_data = {u'language': u'Unknown', u'q': u'unknowable'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) match_count = query.get_bugs_unordered().count() self.assertEqual(match_count, 1) class QueryGetPossibleProjectFacetOptions(SearchTest): def setUp(self): SearchTest.setUp(self) projects = [ Project.create_dummy(name=u'Miro'), Project.create_dummy(name=u'Dali'), Project.create_dummy(name=u'Magritte') ] for p in projects: Bug.create_dummy(project=p) def test_select_a_project_and_see_other_project_options(self): GET_data = {u'project': u'Miro'} query = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) possible_project_names = [x['name'] for x in dict( query.get_possible_facets())['project']['options']] self.assertEqual( sorted(possible_project_names), sorted(list(Project.objects.values_list('name', flat=True)))) class QueryContributionType(SearchTest): def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language=u'Python') perl_project = Project.create_dummy(language=u'Perl') c_project = Project.create_dummy(language=u'C') Bug.create_dummy(project=python_project, title=u'a') Bug.create_dummy(project=perl_project, title=u'a', concerns_just_documentation=True) Bug.create_dummy(project=c_project, title=u'b') def test_contribution_type_is_an_available_facet(self): GET_data = {} starting_query = mysite.search.view_helpers.Query.create_from_GET_data( GET_data) self.assert_( u'contribution_type' in dict(starting_query.get_possible_facets())) def test_contribution_type_options_are_reasonable(self): GET_data = {} starting_query = mysite.search.view_helpers.Query.create_from_GET_data( GET_data) cto = starting_query.get_facet_options(u'contribution_type', [u'documentation']) documentation_one, = [k for k in cto if k[u'name'] == u'documentation'] any_one = starting_query.get_facet_options( u'contribution_type', [u''])[0] self.assertEqual(documentation_one[u'count'], 1) self.assertEqual(any_one[u'count'], 3) class QueryProject(SearchTest): def setUp(self): SearchTest.setUp(self) python_project = Project.create_dummy(language=u'Python', name='thingamajig') c_project = Project.create_dummy(language=u'C', name='thingamabob') Bug.create_dummy(project=python_project, title=u'a') Bug.create_dummy(project=python_project, title=u'a', concerns_just_documentation=True) Bug.create_dummy(project=c_project, title=u'b') def test_project_is_an_available_facet(self): GET_data = {} starting_query = mysite.search.view_helpers.Query.create_from_GET_data( GET_data) self.assert_(u'project' in dict(starting_query.get_possible_facets())) def test_contribution_type_options_are_reasonable(self): GET_data = {} starting_query = mysite.search.view_helpers.Query.create_from_GET_data( GET_data) cto = starting_query.get_facet_options(u'project', [u'thingamajig', u'thingamabob']) jig_ones, = [k for k in cto if k[u'name'] == u'thingamajig'] any_one = starting_query.get_facet_options(u'project', [u''])[0] self.assertEqual(jig_ones[u'count'], 2) self.assertEqual(any_one[u'count'], 3) class QueryStringCaseInsensitive(SearchTest): def test_Language(self): """Do we redirect queries that use non-lowercase facet keys to pages that use lowercase facet keys?""" redirects = self.client.get( u'/search/', {u'LANguaGE': u'pytHon'}, follow=True).redirect_chain self.assertEqual( redirects, [(u'http://testserver/search/?language=pytHon', 302)]) class HashQueryData(SearchTest): def test_queries_with_identical_data_hash_alike(self): GET_data = {u'q': u'socialguides', u'language': u'looxii'} one = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) two = mysite.search.view_helpers.Query.create_from_GET_data(GET_data) self.assertEqual(one.get_sha1(), two.get_sha1()) def test_queries_with_equiv_data_expressed_differently_hash_alike(self): GET_data_1 = {u'q': u'socialguides zetapage', u'language': u'looxii'} GET_data_2 = {u'q': u'zetapage socialguides', u'language': u'looxii'} one = mysite.search.view_helpers.Query.create_from_GET_data(GET_data_1) two = mysite.search.view_helpers.Query.create_from_GET_data(GET_data_2) self.assertEqual(one.get_sha1(), two.get_sha1()) def test_queries_with_different_data_hash_differently(self): GET_data_1 = {u'q': u'socialguides zetapage', u'language': u'looxii'} GET_data_2 = {u'q': u'socialguides ninjapost', u'language': u'looxii'} one = mysite.search.view_helpers.Query.create_from_GET_data(GET_data_1) two = mysite.search.view_helpers.Query.create_from_GET_data(GET_data_2) self.assertNotEqual(one.get_sha1(), two.get_sha1()) # How on earth do we test for collisions? class FakeCache(object): def __init__(self): self._data = {} def get(self, key): return self._data.get(key, None) def set(self, key, value): self._data[key] = value class QueryGrabHitCount(SearchTest): @mock.patch('django.core.cache') def test_eventhive_grab_hitcount_once_stored(self, fake_cache): fake_cache.cache = FakeCache() data = {u'q': u'eventhive', u'language': u'shoutNOW'} query = mysite.search.view_helpers.Query.create_from_GET_data(data) stored_hit_count = 10 # Get the cache key used to store the hit count. hit_count_cache_key = query.get_hit_count_cache_key() # Set the cache value. django.core.cache.cache.set(hit_count_cache_key, stored_hit_count) # Test that it is fetched correctly. self.assertEqual(stored_hit_count, django.core.cache.cache.get(hit_count_cache_key)) self.assertEqual(query.get_or_create_cached_hit_count(), stored_hit_count) @mock.patch('django.core.cache') def test_shoutnow_cache_hitcount_on_grab(self, fake_cache): fake_cache.cache = FakeCache() project = Project.create_dummy(language=u'shoutNOW') Bug.create_dummy(project=project) data = {u'language': u'shoutNOW'} query = mysite.search.view_helpers.Query.create_from_GET_data(data) expected_hit_count = 1 self.assertEqual(query.get_or_create_cached_hit_count(), expected_hit_count) # Get the cache key used to store the hit count. hit_count_cache_key = query.get_hit_count_cache_key() # Get the cache value. stored_hit_count = django.core.cache.cache.get(hit_count_cache_key) logger.debug("Stored: %s" % stored_hit_count) # Test that it was stored correctly. self.assertEqual(stored_hit_count, expected_hit_count) class ClearCacheWhenBugsChange(SearchTest): @expectedFailure def test_cached_cleared_after_bug_save_or_delete(self): data = {u'language': u'shoutNOW'} query = mysite.search.view_helpers.Query.create_from_GET_data(data) old_hcc_timestamp = ( mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') ) # Cache entry created after hit count retrieval query.get_or_create_cached_hit_count() new_hcc_timestamp = ( mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') ) self.assertEqual(old_hcc_timestamp, new_hcc_timestamp) # Cache cleared after bug save project = Project.create_dummy(language=u'shoutNOW') bug = Bug.create_dummy(project=project) newer_hcc_timestamp = ( mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') ) self.assertNotEqual(new_hcc_timestamp, newer_hcc_timestamp) # Cache entry created after hit count retrieval query.get_or_create_cached_hit_count() newest_hcc_timestamp = ( mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') ) self.assertEqual(newer_hcc_timestamp, newest_hcc_timestamp) # Cache cleared after bug deletion bug.delete() newester_hcc_timestamp = ( mysite.base.models.Timestamp.get_timestamp_for_string( 'hit_count_cache_timestamp') ) self.assertNotEqual(newest_hcc_timestamp, newester_hcc_timestamp) class DontRecommendFutileSearchTerms(TwillTests): def test_removal_of_futile_terms(self): mysite.search.models.Bug.create_dummy_with_project( description=u'useful') self.assertEqual( Person.only_terms_with_results([u'useful', u'futile']), [u'useful']) class PublicizeBugTrackerIndex(SearchTest): def setUp(self): SearchTest.setUp(self) self.search_page_response = self.client.get( reverse(mysite.search.views.search_index)) self.bug_tracker_count = mysite.search.view_helpers.get_project_count() def test_search_template_contains_bug_tracker_count(self): self.assertEqual( self.search_page_response.context[0][u'project_count'], self.bug_tracker_count) class TestPotentialMentors(TwillTests): fixtures = ['user-paulproteus', 'person-paulproteus'] def test(self): '''Create a Banshee project mentor and verify that the Banshee project has one mentor.''' banshee = Project.create_dummy(name='Banshee', language='C#') can_mentor, _ = mysite.profile.models.TagType.objects.get_or_create( name=u'can_mentor') willing_to_mentor_banshee, _ = ( mysite.profile.models.Tag.objects. get_or_create(tag_type=can_mentor, text=u'Banshee')) link = mysite.profile.models.Link_Person_Tag( person=Person.objects.get(user__username=u'paulproteus'), tag=willing_to_mentor_banshee) link.save() banshee_mentor_count = banshee.mentor_count self.assertEqual(1, banshee_mentor_count) class SuggestAlertOnLastResultsPage(TwillTests): fixtures = ['user-paulproteus'] def exercise_alert(self, anonymous=True): """The 'anonymous' parameter allows the alert functionality to be tested for anonymous and logged-in users.""" if not anonymous: self.login_with_twill() # Create some dummy data p = Project.create_dummy(language='ruby') # 15 bugs matching 'ruby' for i in range(15): b = Bug.create_dummy(description='ruby') b.project = p b.save() # Visit the first page of a vol. opp. search results page. opps_view = mysite.search.views.search_index query = u'ruby' opps_query_string = {u'q': query, u'start': 1, u'end': 10} opps_url = make_twill_url('http://openhatch.org' + reverse(opps_view) + '?' + http.urlencode(opps_query_string)) tc.go(opps_url) # Make sure we *don't* have the comment that flags this as a page that # offers an email alert subscription button tc.notfind( "this page should offer a link to sign up for an email alert") # Visit the last page of results GET = {u'q': query, u'start': 11, u'end': 20} query_string = http.urlencode(GET) opps_url = make_twill_url( 'http://openhatch.org' + reverse(opps_view) + '?' + query_string) tc.go(opps_url) # make sure we /do/ have the comment that flags this as a page that # offers an email alert subscription button tc.find("this page should offer a link to sign up for an email alert") if not anonymous: # if the user is logged in, make sure that we have autopopulated # the form with her email address tc.find(User.objects.get(username='paulproteus').email) # Submit the 'alert' form. email_address = 'yetanother@ema.il' tc.fv('alert', 'email', email_address) tc.submit() if anonymous: client = self.client else: client = self.login_with_client() alert_data_in_form = { 'query_string': query_string, 'how_many_bugs_at_time_of_request': Bug.open_ones.filter(project=p).count(), 'email': email_address, } # Twill fails here for some reason, so let's continue the journey with # Django's built-in testing sweeeet response = client.post( reverse(mysite.search.views.subscribe_to_bug_alert_do), alert_data_in_form) # This response should be a HTTP redirect instruction self.assertEqual(response.status_code, 302) redirect_target_url = response._headers['location'][1] self.assert_(query_string in redirect_target_url) # The page redirects to the old kk response = client.get(redirect_target_url) self.assertContains( response, "this page should confirm that an email alert has been registered") # At this point, make sure that the DB contains a record of # * What the query was. # * When the request was made. # * How many bugs were returned by the query at the time of # request. # There should be only one alert all_alerts = BugAlert.objects.all() self.assertEqual(all_alerts.count(), 1) alert_record = all_alerts[0] self.assert_(alert_record) assert_that_record_has_this_data = alert_data_in_form # For the logged-in user, also check that the record contains the # identity of the user who made the alert request. if not anonymous: assert_that_record_has_this_data['user'] = ( User.objects.get(username='paulproteus')) for key, expected_value in assert_that_record_has_this_data.items(): self.assertEqual( alert_record.__getattribute__(key), expected_value, 'alert.%s = %s not (expected) %s' % ( key, alert_record.__getattribute__(key), expected_value) ) # run the above test for our two use cases: logged in and not def test_alert_anon(self): self.exercise_alert(anonymous=True) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_alert_logged_in(self): self.exercise_alert(anonymous=False) class DeleteAnswer(TwillTests): fixtures = ['user-paulproteus'] @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_delete_paragraph_answer(self): # create dummy question p = Project.create_dummy(name='Ubuntu') question__pk = 0 q = ProjectInvolvementQuestion.create_dummy( pk=question__pk, is_bug_style=False) # create our dummy answer a = Answer.create_dummy( text='i am saying thigns', question=q, project=p, author=User.objects.get(username='paulproteus')) # delete our answer POST_data = { 'answer__pk': a.pk, } POST_handler = reverse(mysite.project.views.delete_paragraph_answer_do) response = self.login_with_client().post(POST_handler, POST_data) # go back to the project page and make sure that our answer isn't there # anymore project_url = p.get_url() self.assertRedirects(response, project_url) project_page = self.login_with_client().get(project_url) self.assertNotContains(project_page, a.text) # and make sure our answer isn't in the db anymore self.assertEqual(Answer.objects.filter(pk=a.pk).count(), 0) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_delete_bug_answer(self): # create dummy question p = Project.create_dummy(name='Ubuntu') # it's important that this pk correspond to the pk of an actual # bug_style question, as specified in our view otherwise, we'll # get_or_create will try to create, but it won't be able to because of # a unique key error question__pk = 2 q = ProjectInvolvementQuestion.create_dummy( pk=question__pk, is_bug_style=True) # create our dummy answer a = Answer.create_dummy( title='i want this bug fixed', text='for these reasons', question=q, project=p, author=User.objects.get(username='paulproteus')) # delete our answer POST_data = { 'answer__pk': a.pk, } POST_handler = reverse(mysite.project.views.delete_paragraph_answer_do) response = self.login_with_client().post(POST_handler, POST_data) # go back to the project page and make sure that our answer isn't there # anymore project_url = p.get_url() self.assertRedirects(response, project_url) project_page = self.login_with_client().get(project_url) self.assertNotContains(project_page, a.title) # and make sure our answer isn't in the db anymore self.assertEqual(Answer.objects.filter(pk=a.pk).count(), 0) class CreateBugAnswer(TwillTests): fixtures = ['user-paulproteus'] @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_create_bug_answer(self): # go to the project page p = Project.create_dummy(name='Ubuntu') question__pk = 1 question = ProjectInvolvementQuestion.create_dummy( key_string='non_code_participation', is_bug_style=True) question.save() title = 'omfg i wish this bug would go away' text = 'kthxbai' POST_data = { 'project__pk': p.pk, 'question__pk': str(question__pk), 'answer__title': title, 'answer__text': text } POST_handler = reverse(mysite.project.views.create_answer_do) response = self.login_with_client().post(POST_handler, POST_data) # try to get the BugAnswer which we just submitted from the database our_bug_answer = Answer.objects.get(title=title) # make sure it has the right attributes self.assertEqual(our_bug_answer.text, text) self.assertEqual(our_bug_answer.question.pk, question__pk) self.assertEqual(our_bug_answer.project.pk, p.pk) project_url = p.get_url() self.assertRedirects(response, project_url) project_page = self.login_with_client().get(project_url) # make sure that our data shows up on the page self.assertContains(project_page, title) self.assertContains(project_page, text) class WeTakeOwnershipOfAnswersAtLogin(TwillTests): fixtures = ['user-paulproteus', 'person-paulproteus'] def test_create_answer_but_take_ownership_at_login_time(self): session = {} # Create the Answer object, but set its User to None answer = Answer.create_dummy() answer.author = None answer.is_published = False answer.save() # Verify that the Answer object is not available by .objects() self.assertFalse(Answer.objects.all()) # Store the Answer IDs in the session mysite.project.view_helpers.note_in_session_we_control_answer_id( session, answer.id) self.assertEqual(session['answer_ids_that_are_ours'], [answer.id]) # If you want to look at those answers, you can this way: stored_answers = (mysite.project.view_helpers. get_unsaved_answers_from_session(session)) self.assertEqual([answer.id for answer in stored_answers], [answer.id]) # Verify that the Answer object is still not available by .objects() self.assertFalse(Answer.objects.all()) # At login time, take ownership of those Answer IDs mysite.project.view_helpers.take_control_of_our_answers( User.objects.get(username='paulproteus'), session) # And now we own it! self.assertEqual(Answer.objects.all().count(), 1) class CreateAnonymousAnswer(TwillTests): fixtures = ['user-paulproteus'] @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_create_answer_anonymously(self): # Steps for this test # 1. User fills in the form anonymously # 2. We test that the Answer is not yet saved # 3. User logs in # 4. We test that the Answer is saved p = Project.create_dummy(name='Myproject') q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) # Do a GET on the project page to prove cookies work. self.client.get(p.get_url()) # POST some text to the answer creation post handler answer_text = ('Help produce official documentation, share the ' 'solution to a problem, or check, proof and test ' 'other documents for accuracy.') POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': answer_text, } response = self.client.post( reverse(mysite.project.views.create_answer_do), POST_data, follow=True) self.assertEqual(response.redirect_chain, [('http://testserver/account/login/?next=%2Fprojects%2FMyproject', 302)]) # If this were an Ajaxy post handler, we might assert something about # the response, like # self.assertEqual(response.content, '1') # check that the db contains a record with this text try: record = Answer.all_even_unowned.get( text=POST_data['answer__text']) except Answer.DoesNotExist: print "All Answers:", Answer.all_even_unowned.all() raise Answer.DoesNotExist self.assertEqual(record.project, p) self.assertEqual(record.question, q) self.assertFalse(Answer.objects.all()) # it's unowned # Now, the session will know about the answer, but the answer will # not be published. # Visit the login page, assert that the page contains the text of the # answer. response = self.client.get(reverse('oh_login')) self.assertContains(response, POST_data['answer__text']) # But when the user is logged in and *then* visits the project page login_worked = self.client.login( username='paulproteus', password="paulproteus's unbreakable password") self.assert_(login_worked) self.client.get(p.get_url()) # Now, the Answer should have an author whose username is paulproteus answer = Answer.objects.get() self.assertEqual(answer.text, POST_data['answer__text']) self.assertEqual(answer.author.username, 'paulproteus') # Finally, go to the project page and make sure that our Answer has # appeared response = self.client.get(p.get_url()) self.assertContains(response, answer_text) class CreateAnswer(TwillTests): fixtures = ['user-paulproteus'] def test_create_answer(self): p = Project.create_dummy() q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) # POST some text to the answer creation post handler POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': ('Help produce official documentation, share the ' 'solution to a problem, or check, proof and ' 'test other documents for accuracy.'), } self.login_with_client().post( reverse(mysite.project.views.create_answer_do), POST_data) # If this were an Ajaxy post handler, we might assert something about # the response, like # self.assertEqual(response.content, '1') # check that the db contains a record with this text try: record = Answer.objects.get(text=POST_data['answer__text']) except Answer.DoesNotExist: print "All Answers:", Answer.objects.all() raise Answer.DoesNotExist self.assertEqual(record.author, User.objects.get(username='paulproteus')) self.assertEqual(record.project, p) self.assertEqual(record.question, q) # check that the project page now includes this text project_page = self.client.get(p.get_url()) self.assertContains(project_page, POST_data['answer__text']) self.assertContains(project_page, record.author.username) @skipIf(django.db.connection.vendor == 'sqlite', "Skipping because using sqlite database") @expectedFailure def test_multiparagraph_answer(self): """ If a multi-paragraph answer is submitted, display it as a multi-paragraph answer. """ # go to the project page p = Project.create_dummy(name='Ubuntu') q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) q.save() text = ['This is a multiparagraph answer.', 'This is the second paragraph.', 'This is the third paragraph.'] POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': "\n".join(text) } POST_handler = reverse(mysite.project.views.create_answer_do) self.login_with_client().post(POST_handler, POST_data) project_page = self.login_with_client().get(p.get_url()) # Django documents publicly that linebreaks replaces one "\n" with # "<br />". # http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks self.assertContains(project_page, "<br />".join(text)) def test_answer_with_background_color(self): """ If a user submits HTML with embedded styles, they should be dropped. """ # go to the project page p = Project.create_dummy(name='Ubuntu') q = ProjectInvolvementQuestion.create_dummy( key_string='where_to_start', is_bug_style=False) q.save() text = u'<p style="background-color: red;">red</p>' POST_data = { 'project__pk': p.pk, 'question__pk': q.pk, 'answer__text': text } # Submit the data while logged in POST_handler = reverse(mysite.project.views.create_answer_do) self.login_with_client().post(POST_handler, POST_data) # Look at page while logged out (so we see the anonymous rendering) project_page = self.client.get(p.get_url()) # The urlize filter in the template should make sure we get a link self.assertNotContains(project_page, '''background-color: red''') class BugKnowsItsFreshness(TestCase): def test(self): b = mysite.search.models.Bug.create_dummy_with_project() b.last_polled = datetime.datetime.now() self.assertTrue(b.data_is_more_fresh_than_one_day()) b.last_polled -= datetime.timedelta( days=1, hours=1) self.assertFalse(b.data_is_more_fresh_than_one_day()) class WeCanPollSomethingToCheckIfAProjectIconIsLoaded(TestCase): def test(self): # Create a dummy project p = Project.create_dummy() # Make sure its ohloh icon download time is null self.assertEqual(p.date_icon_was_fetched_from_ohloh, None) # get the thing we poll response = self.client.get(reverse( mysite.search.views.project_has_icon, kwargs={'project_name': p.name})) self.assertEqual(response.content, 'keep polling') # okay, so now say we finished polling p.date_icon_was_fetched_from_ohloh = datetime.datetime.utcnow() p.save() # so what now? response = self.client.get(reverse( mysite.search.views.project_has_icon, kwargs={'project_name': p.name})) self.assertEqual(response.content, p.get_url_of_icon_or_generic())
agpl-3.0
[ 3, 961, 570, 365, 1777, 402, 3232, 40, 693, 14, 199, 3, 1898, 334, 35, 9, 7129, 510, 1096, 281, 11308, 262, 23263, 199, 3, 1898, 334, 35, 9, 7129, 1603, 564, 598, 322, 2721, 199, 3, 1898, 334, 35, 9, 8937, 12, 7129, 3232, 40, 693, 12, 3277, 14, 199, 3, 1898, 334, 35, 9, 7129, 1603, 28601, 696, 22895, 43, 1697, 285, 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, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 3002, 2124, 14, 1095, 14, 2219, 492, 1852, 63, 8122, 778, 63, 633, 12, 377, 14117, 2925, 199, 646, 3002, 2124, 14, 1095, 14, 992, 199, 199, 646, 3002, 2124, 14, 2048, 14, 2219, 199, 504, 3002, 2124, 14, 2913, 14, 992, 492, 8028, 199, 646, 3002, 2124, 14, 2913, 14, 992, 199, 646, 3002, 2124, 14, 1733, 14, 1345, 63, 7546, 199, 504, 3002, 2124, 14, 1733, 14, 992, 492, 334, 4761, 12, 21605, 12, 7290, 14883, 3344, 434, 16778, 12, 3303, 30675, 12, 21605, 18758, 9, 199, 504, 3002, 2124, 14, 1733, 492, 6858, 199, 646, 2197, 199, 646, 2050, 199, 646, 3002, 2124, 14, 1715, 14, 4196, 199, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 3917, 199, 504, 1639, 14, 1208, 14, 2796, 492, 1420, 6782, 199, 646, 1639, 14, 697, 199, 646, 1639, 14, 2190, 199, 199, 504, 1639, 14, 1208, 492, 1455, 199, 646, 2022, 199, 646, 1683, 199, 504, 8900, 778, 492, 3718, 465, 14415, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 646, 1639, 14, 1018, 14, 1637, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1095, 492, 6646, 1173, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 8730, 774, 8, 52, 14117, 2925, 304, 339, 347, 2754, 63, 12897, 63, 8122, 778, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 298, 1014, 921, 1490, 72, 693, 14, 1308, 15, 1733, 6687, 267, 340, 1827, 26, 288, 2754, 63, 633, 847, 8720, 81, 2458, 83, 7, 450, 1827, 267, 14415, 14, 1939, 8, 1875, 63, 8122, 778, 63, 633, 8, 1733, 63, 633, 430, 339, 347, 2754, 63, 12897, 63, 1258, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 3286, 1733, 6687, 267, 372, 291, 14, 1258, 14, 362, 8, 1733, 63, 633, 12, 469, 85, 7, 81, 356, 1827, 1552, 339, 347, 6540, 63, 6717, 8, 277, 12, 1373, 12, 2877, 304, 267, 291, 14, 629, 8, 552, 8, 368, 395, 822, 8, 5601, 430, 267, 291, 14, 629, 8, 409, 8, 368, 395, 663, 8, 5601, 430, 339, 347, 6540, 63, 6717, 63, 1618, 63, 7892, 8, 277, 12, 1373, 12, 2877, 12, 4069, 63, 498, 29, 403, 304, 398, 340, 4069, 63, 498, 365, 440, 488, 26, 288, 4069, 63, 2324, 275, 2400, 8377, 26, 8377, 59, 3191, 63, 498, 61, 267, 587, 26, 288, 4069, 63, 2324, 275, 488, 398, 3355, 63, 368, 275, 3355, 8, 368, 12, 790, 29, 3191, 63, 2324, 9, 267, 3355, 63, 5601, 275, 3355, 8, 5601, 12, 790, 29, 3191, 63, 2324, 9, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 368, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 5601, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 421, 199, 533, 1379, 17231, 3227, 3264, 6491, 1322, 1764, 316, 2371, 357, 425, 6470, 83, 8, 52, 14117, 2925, 304, 339, 347, 511, 8, 277, 304, 267, 29870, 275, 298, 3007, 7883, 334, 460, 32029, 2924, 267, 1827, 275, 3002, 2124, 14, 1733, 14, 1345, 63, 7546, 14, 3227, 14, 981, 63, 504, 63, 2970, 63, 576, 8, 288, 469, 85, 7, 81, 356, 399, 4065, 5, 83, 4507, 450, 29870, 1552, 267, 291, 14, 629, 8, 1131, 14, 9187, 12, 359, 7330, 1792, 427, 566, 267, 327, 4155, 2337, 506, 282, 6519, 370, 2342, 267, 2199, 275, 7290, 14, 981, 63, 5869, 8, 354, 29, 7330, 1792, 427, 9, 267, 21605, 14, 981, 63, 5869, 8, 1715, 29, 1715, 9, 267, 327, 7494, 5002, 18227, 31, 267, 1967, 63, 13017, 275, 1827, 14, 362, 63, 13017, 63, 24182, 1252, 835, 342, 267, 291, 14, 629, 8, 1507, 63, 13017, 12, 413, 9, 421, 199, 533, 8730, 6579, 8, 52, 14117, 2925, 304, 272, 15188, 275, 359, 85, 7, 13017, 13, 509, 13, 5601, 13, 6776, 14, 1001, 418, 339, 768, 15118, 8, 1176, 14, 697, 14, 2105, 14, 9884, 508, 283, 10659, 297, 288, 298, 18297, 2952, 1808, 11723, 3050, 531, 272, 347, 511, 63, 1131, 63, 785, 63, 374, 63, 3910, 63, 6526, 63, 889, 63, 9187, 63, 269, 63, 1409, 1086 ]
[ 961, 570, 365, 1777, 402, 3232, 40, 693, 14, 199, 3, 1898, 334, 35, 9, 7129, 510, 1096, 281, 11308, 262, 23263, 199, 3, 1898, 334, 35, 9, 7129, 1603, 564, 598, 322, 2721, 199, 3, 1898, 334, 35, 9, 8937, 12, 7129, 3232, 40, 693, 12, 3277, 14, 199, 3, 1898, 334, 35, 9, 7129, 1603, 28601, 696, 22895, 43, 1697, 285, 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, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 3002, 2124, 14, 1095, 14, 2219, 492, 1852, 63, 8122, 778, 63, 633, 12, 377, 14117, 2925, 199, 646, 3002, 2124, 14, 1095, 14, 992, 199, 199, 646, 3002, 2124, 14, 2048, 14, 2219, 199, 504, 3002, 2124, 14, 2913, 14, 992, 492, 8028, 199, 646, 3002, 2124, 14, 2913, 14, 992, 199, 646, 3002, 2124, 14, 1733, 14, 1345, 63, 7546, 199, 504, 3002, 2124, 14, 1733, 14, 992, 492, 334, 4761, 12, 21605, 12, 7290, 14883, 3344, 434, 16778, 12, 3303, 30675, 12, 21605, 18758, 9, 199, 504, 3002, 2124, 14, 1733, 492, 6858, 199, 646, 2197, 199, 646, 2050, 199, 646, 3002, 2124, 14, 1715, 14, 4196, 199, 199, 504, 1639, 14, 1208, 14, 2796, 492, 3372, 3917, 199, 504, 1639, 14, 1208, 14, 2796, 492, 1420, 6782, 199, 646, 1639, 14, 697, 199, 646, 1639, 14, 2190, 199, 199, 504, 1639, 14, 1208, 492, 1455, 199, 646, 2022, 199, 646, 1683, 199, 504, 8900, 778, 492, 3718, 465, 14415, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 646, 1639, 14, 1018, 14, 1637, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1095, 492, 6646, 1173, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 8730, 774, 8, 52, 14117, 2925, 304, 339, 347, 2754, 63, 12897, 63, 8122, 778, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 298, 1014, 921, 1490, 72, 693, 14, 1308, 15, 1733, 6687, 267, 340, 1827, 26, 288, 2754, 63, 633, 847, 8720, 81, 2458, 83, 7, 450, 1827, 267, 14415, 14, 1939, 8, 1875, 63, 8122, 778, 63, 633, 8, 1733, 63, 633, 430, 339, 347, 2754, 63, 12897, 63, 1258, 8, 277, 12, 1827, 29, 403, 304, 267, 2754, 63, 633, 275, 3286, 1733, 6687, 267, 372, 291, 14, 1258, 14, 362, 8, 1733, 63, 633, 12, 469, 85, 7, 81, 356, 1827, 1552, 339, 347, 6540, 63, 6717, 8, 277, 12, 1373, 12, 2877, 304, 267, 291, 14, 629, 8, 552, 8, 368, 395, 822, 8, 5601, 430, 267, 291, 14, 629, 8, 409, 8, 368, 395, 663, 8, 5601, 430, 339, 347, 6540, 63, 6717, 63, 1618, 63, 7892, 8, 277, 12, 1373, 12, 2877, 12, 4069, 63, 498, 29, 403, 304, 398, 340, 4069, 63, 498, 365, 440, 488, 26, 288, 4069, 63, 2324, 275, 2400, 8377, 26, 8377, 59, 3191, 63, 498, 61, 267, 587, 26, 288, 4069, 63, 2324, 275, 488, 398, 3355, 63, 368, 275, 3355, 8, 368, 12, 790, 29, 3191, 63, 2324, 9, 267, 3355, 63, 5601, 275, 3355, 8, 5601, 12, 790, 29, 3191, 63, 2324, 9, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 368, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 267, 367, 1022, 315, 1425, 8, 552, 8, 5917, 63, 5601, 2298, 288, 862, 26, 355, 291, 14, 629, 8, 5917, 63, 368, 59, 75, 467, 3355, 63, 5601, 59, 75, 566, 288, 871, 9070, 26, 355, 492, 984, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 368, 355, 870, 4331, 984, 14, 3083, 12, 3355, 63, 5601, 355, 746, 421, 199, 533, 1379, 17231, 3227, 3264, 6491, 1322, 1764, 316, 2371, 357, 425, 6470, 83, 8, 52, 14117, 2925, 304, 339, 347, 511, 8, 277, 304, 267, 29870, 275, 298, 3007, 7883, 334, 460, 32029, 2924, 267, 1827, 275, 3002, 2124, 14, 1733, 14, 1345, 63, 7546, 14, 3227, 14, 981, 63, 504, 63, 2970, 63, 576, 8, 288, 469, 85, 7, 81, 356, 399, 4065, 5, 83, 4507, 450, 29870, 1552, 267, 291, 14, 629, 8, 1131, 14, 9187, 12, 359, 7330, 1792, 427, 566, 267, 327, 4155, 2337, 506, 282, 6519, 370, 2342, 267, 2199, 275, 7290, 14, 981, 63, 5869, 8, 354, 29, 7330, 1792, 427, 9, 267, 21605, 14, 981, 63, 5869, 8, 1715, 29, 1715, 9, 267, 327, 7494, 5002, 18227, 31, 267, 1967, 63, 13017, 275, 1827, 14, 362, 63, 13017, 63, 24182, 1252, 835, 342, 267, 291, 14, 629, 8, 1507, 63, 13017, 12, 413, 9, 421, 199, 533, 8730, 6579, 8, 52, 14117, 2925, 304, 272, 15188, 275, 359, 85, 7, 13017, 13, 509, 13, 5601, 13, 6776, 14, 1001, 418, 339, 768, 15118, 8, 1176, 14, 697, 14, 2105, 14, 9884, 508, 283, 10659, 297, 288, 298, 18297, 2952, 1808, 11723, 3050, 531, 272, 347, 511, 63, 1131, 63, 785, 63, 374, 63, 3910, 63, 6526, 63, 889, 63, 9187, 63, 269, 63, 1409, 1086, 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 ]
mdovgialo/steam-vr-wheel
steam_vr_wheel/pyvjoy/_wrapper.py
1
2789
import os import sys from ctypes import * dll_filename = "vJoyInterface.dll" dll_path = os.path.dirname(__file__) + os.sep + dll_filename try: _vj = cdll.LoadLibrary(dll_path) except OSError: sys.exit("Unable to load vJoy SDK DLL. Ensure that %s is present" % dll_filename) def vJoyEnabled(): """Returns True if vJoy is installed and enabled""" result = _vj.vJoyEnabled() if result == 0: raise vJoyNotEnabledException() else: return True def DriverMatch(): """Check if the version of vJoyInterface.dll and the vJoy Driver match""" result = _vj.DriverMatch() if result == 0: raise vJoyDriverMismatch() else: return True def GetVJDStatus(rID): """Get the status of a given vJoy Device""" return _vj.GetVJDStatus(rID) def AcquireVJD(rID): """Attempt to acquire a vJoy Device""" result = _vj.AcquireVJD(rID) if result == 0: #Check status status = GetVJDStatus(rID) if status != VJD_STAT_FREE: raise vJoyFailedToAcquireException("Cannot acquire vJoy Device because it is not in VJD_STAT_FREE") else: raise vJoyFailedToAcquireException() else: return True def RelinquishVJD(rID): """Relinquish control of a vJoy Device""" result = _vj.RelinquishVJD(rID) if result == 0: raise vJoyFailedToRelinquishException() else: return True def SetBtn(state,rID,buttonID): """Sets the state of vJoy Button to on or off. SetBtn(state,rID,buttonID)""" result = _vj.SetBtn(state,rID,buttonID) if result == 0: raise vJoyButtonError() else: return True def SetDiscPov(PovValue, rID, PovID): """Write Value to a given discrete POV defined in the specified VDJ""" if PovValue < -1 or PovValue > 3: raise vJoyInvalidPovValueException() if PovID < 1 or PovID > 4: raise vJoyInvalidPovIDException return _vj.SetDiscPov(PovValue,rID,PovID) def SetContPov(PovValue, rID, PovID): """Write Value to a given continuous POV defined in the specified VDJ""" if PovValue < -1 or PovValue > 35999: raise vJoyInvalidPovValueException() if PovID < 1 or PovID > 4: raise vJoyInvalidPovIDException return _vj.SetContPov(PovValue,rID,PovID) def SetBtn(state,rID,buttonID): """Sets the state of vJoy Button to on or off. SetBtn(state,rID,buttonID)""" result = _vj.SetBtn(state,rID,buttonID) if result == 0: raise vJoyButtonError() else: return True def ResetVJD(rID): """Reset all axes and buttons to default for specified vJoy Device""" return _vj.ResetVJD(rID) def ResetButtons(rID): """Reset all buttons to default for specified vJoy Device""" return _vj.ResetButtons(rID) def ResetPovs(rID): """Reset all POV hats to default for specified vJoy Device""" return _vj.ResetButtons(rID)
mit
[ 646, 747, 202, 199, 646, 984, 202, 199, 504, 5577, 492, 627, 8065, 199, 9259, 63, 1501, 275, 298, 86, 5691, 89, 4267, 14, 9259, 2, 202, 199, 9259, 63, 515, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 435, 747, 14, 4127, 435, 17112, 63, 1501, 2999, 199, 893, 26, 1223, 198, 63, 86, 74, 275, 286, 9259, 14, 6200, 7424, 8, 9259, 63, 515, 9, 202, 199, 2590, 6440, 26, 1223, 198, 1274, 14, 2224, 480, 6005, 370, 2248, 373, 5691, 89, 15610, 577, 4464, 14, 221, 7523, 626, 450, 83, 365, 3451, 2, 450, 17112, 63, 1501, 9, 8065, 199, 318, 373, 5691, 89, 6589, 837, 1223, 198, 624, 3407, 715, 340, 373, 5691, 89, 365, 4903, 436, 5223, 624, 10060, 198, 1099, 275, 485, 86, 74, 14, 86, 5691, 89, 6589, 342, 10060, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 1763, 6589, 1726, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 19447, 4486, 837, 1223, 198, 624, 1799, 340, 314, 1015, 402, 373, 5691, 89, 4267, 14, 9259, 436, 314, 373, 5691, 89, 19447, 1336, 624, 1223, 198, 1099, 275, 485, 86, 74, 14, 6158, 4486, 342, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 6158, 23055, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 2372, 54, 42, 36, 3694, 8, 82, 998, 304, 1223, 198, 624, 1002, 314, 2004, 402, 282, 1627, 373, 5691, 89, 12272, 624, 10060, 198, 1107, 485, 86, 74, 14, 1002, 54, 42, 36, 3694, 8, 82, 998, 9, 8065, 199, 318, 4473, 2272, 54, 42, 36, 8, 82, 998, 304, 1223, 198, 624, 23272, 370, 16919, 282, 373, 5691, 89, 12272, 624, 10060, 198, 1099, 275, 485, 86, 74, 14, 1945, 2272, 54, 42, 36, 8, 82, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3, 1799, 2004, 4122, 198, 1205, 275, 2372, 54, 42, 36, 3694, 8, 82, 998, 9, 4122, 198, 692, 2004, 1137, 812, 42, 36, 63, 4315, 63, 28170, 26, 7903, 198, 3730, 373, 5691, 89, 4276, 1378, 1945, 2272, 1726, 480, 6612, 16919, 373, 5691, 89, 12272, 2952, 652, 365, 440, 315, 812, 42, 36, 63, 4315, 63, 28170, 531, 26045, 198, 2836, 26, 7903, 198, 3730, 373, 5691, 89, 4276, 1378, 1945, 2272, 1726, 342, 10060, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 9781, 262, 392, 2453, 54, 42, 36, 8, 82, 998, 304, 1223, 198, 624, 5640, 262, 392, 2453, 3304, 402, 282, 373, 5691, 89, 12272, 624, 10060, 198, 1099, 275, 485, 86, 74, 14, 5640, 262, 392, 2453, 54, 42, 36, 8, 82, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 4276, 1378, 5640, 262, 392, 2453, 1726, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 304, 1223, 198, 624, 9899, 314, 1174, 402, 373, 5691, 89, 16005, 370, 641, 503, 2331, 14, 221, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9471, 1223, 198, 1099, 275, 485, 86, 74, 14, 1084, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 4259, 547, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 2999, 199, 318, 2494, 18230, 1575, 86, 8, 1575, 86, 1110, 12, 519, 998, 12, 4376, 86, 998, 304, 1223, 198, 624, 3534, 1594, 370, 282, 1627, 24635, 3625, 54, 3247, 315, 314, 2013, 812, 17239, 624, 1223, 198, 692, 4376, 86, 1110, 665, 446, 17, 503, 4376, 86, 1110, 690, 650, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 1110, 1726, 342, 10060, 198, 692, 4376, 86, 998, 665, 413, 503, 4376, 86, 998, 690, 841, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 998, 1726, 10060, 198, 1107, 485, 86, 74, 14, 1084, 18230, 1575, 86, 8, 1575, 86, 1110, 12, 82, 998, 12, 1575, 86, 998, 9, 2999, 199, 318, 2494, 714, 84, 1575, 86, 8, 1575, 86, 1110, 12, 519, 998, 12, 4376, 86, 998, 304, 1223, 198, 624, 3534, 1594, 370, 282, 1627, 19922, 3625, 54, 3247, 315, 314, 2013, 812, 17239, 624, 1223, 198, 692, 4376, 86, 1110, 665, 446, 17, 503, 4376, 86, 1110, 690, 8685, 5637, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 1110, 1726, 342, 10060, 198, 692, 4376, 86, 998, 665, 413, 503, 4376, 86, 998, 690, 841, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 998, 1726, 10060, 198, 1107, 485, 86, 74, 14, 1084, 714, 84, 1575, 86, 8, 1575, 86, 1110, 12, 82, 998, 12, 1575, 86, 998, 9, 1223, 8065, 199, 318, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 304, 1223, 198, 624, 9899, 314, 1174, 402, 373, 5691, 89, 16005, 370, 641, 503, 2331, 14, 221, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9471, 1223, 198, 1099, 275, 485, 86, 74, 14, 1084, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 4259, 547, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 15510, 54, 42, 36, 8, 82, 998, 304, 1223, 198, 624, 9637, 1006, 7824, 436, 15766, 370, 849, 367, 2013, 373, 5691, 89, 12272, 624, 1223, 198, 1107, 485, 86, 74, 14, 9637, 54, 42, 36, 8, 82, 998, 9, 8065, 199, 318, 15510, 24021, 8, 82, 998, 304, 1223, 198, 624, 9637, 1006, 15766, 370, 849, 367, 2013, 373, 5691, 89, 12272, 624, 1223, 198, 1107, 485, 86, 74, 14, 9637, 24021, 8, 82, 998, 9, 8065, 199, 318, 15510, 1575, 3122, 8, 82, 998, 304, 1223, 198, 624, 9637, 1006, 3625, 54, 394, 1956, 370, 849, 367, 2013, 373, 5691, 89, 12272, 624, 1223, 198, 1107, 485, 86, 74, 14, 9637, 24021, 8, 82, 998, 9, 10060, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 202, 199, 646, 984, 202, 199, 504, 5577, 492, 627, 8065, 199, 9259, 63, 1501, 275, 298, 86, 5691, 89, 4267, 14, 9259, 2, 202, 199, 9259, 63, 515, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 435, 747, 14, 4127, 435, 17112, 63, 1501, 2999, 199, 893, 26, 1223, 198, 63, 86, 74, 275, 286, 9259, 14, 6200, 7424, 8, 9259, 63, 515, 9, 202, 199, 2590, 6440, 26, 1223, 198, 1274, 14, 2224, 480, 6005, 370, 2248, 373, 5691, 89, 15610, 577, 4464, 14, 221, 7523, 626, 450, 83, 365, 3451, 2, 450, 17112, 63, 1501, 9, 8065, 199, 318, 373, 5691, 89, 6589, 837, 1223, 198, 624, 3407, 715, 340, 373, 5691, 89, 365, 4903, 436, 5223, 624, 10060, 198, 1099, 275, 485, 86, 74, 14, 86, 5691, 89, 6589, 342, 10060, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 1763, 6589, 1726, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 19447, 4486, 837, 1223, 198, 624, 1799, 340, 314, 1015, 402, 373, 5691, 89, 4267, 14, 9259, 436, 314, 373, 5691, 89, 19447, 1336, 624, 1223, 198, 1099, 275, 485, 86, 74, 14, 6158, 4486, 342, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 6158, 23055, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 2372, 54, 42, 36, 3694, 8, 82, 998, 304, 1223, 198, 624, 1002, 314, 2004, 402, 282, 1627, 373, 5691, 89, 12272, 624, 10060, 198, 1107, 485, 86, 74, 14, 1002, 54, 42, 36, 3694, 8, 82, 998, 9, 8065, 199, 318, 4473, 2272, 54, 42, 36, 8, 82, 998, 304, 1223, 198, 624, 23272, 370, 16919, 282, 373, 5691, 89, 12272, 624, 10060, 198, 1099, 275, 485, 86, 74, 14, 1945, 2272, 54, 42, 36, 8, 82, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3, 1799, 2004, 4122, 198, 1205, 275, 2372, 54, 42, 36, 3694, 8, 82, 998, 9, 4122, 198, 692, 2004, 1137, 812, 42, 36, 63, 4315, 63, 28170, 26, 7903, 198, 3730, 373, 5691, 89, 4276, 1378, 1945, 2272, 1726, 480, 6612, 16919, 373, 5691, 89, 12272, 2952, 652, 365, 440, 315, 812, 42, 36, 63, 4315, 63, 28170, 531, 26045, 198, 2836, 26, 7903, 198, 3730, 373, 5691, 89, 4276, 1378, 1945, 2272, 1726, 342, 10060, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 9781, 262, 392, 2453, 54, 42, 36, 8, 82, 998, 304, 1223, 198, 624, 5640, 262, 392, 2453, 3304, 402, 282, 373, 5691, 89, 12272, 624, 10060, 198, 1099, 275, 485, 86, 74, 14, 5640, 262, 392, 2453, 54, 42, 36, 8, 82, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 4276, 1378, 5640, 262, 392, 2453, 1726, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 304, 1223, 198, 624, 9899, 314, 1174, 402, 373, 5691, 89, 16005, 370, 641, 503, 2331, 14, 221, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9471, 1223, 198, 1099, 275, 485, 86, 74, 14, 1084, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 4259, 547, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 2999, 199, 318, 2494, 18230, 1575, 86, 8, 1575, 86, 1110, 12, 519, 998, 12, 4376, 86, 998, 304, 1223, 198, 624, 3534, 1594, 370, 282, 1627, 24635, 3625, 54, 3247, 315, 314, 2013, 812, 17239, 624, 1223, 198, 692, 4376, 86, 1110, 665, 446, 17, 503, 4376, 86, 1110, 690, 650, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 1110, 1726, 342, 10060, 198, 692, 4376, 86, 998, 665, 413, 503, 4376, 86, 998, 690, 841, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 998, 1726, 10060, 198, 1107, 485, 86, 74, 14, 1084, 18230, 1575, 86, 8, 1575, 86, 1110, 12, 82, 998, 12, 1575, 86, 998, 9, 2999, 199, 318, 2494, 714, 84, 1575, 86, 8, 1575, 86, 1110, 12, 519, 998, 12, 4376, 86, 998, 304, 1223, 198, 624, 3534, 1594, 370, 282, 1627, 19922, 3625, 54, 3247, 315, 314, 2013, 812, 17239, 624, 1223, 198, 692, 4376, 86, 1110, 665, 446, 17, 503, 4376, 86, 1110, 690, 8685, 5637, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 1110, 1726, 342, 10060, 198, 692, 4376, 86, 998, 665, 413, 503, 4376, 86, 998, 690, 841, 26, 4122, 198, 3730, 373, 5691, 89, 3364, 1575, 86, 998, 1726, 10060, 198, 1107, 485, 86, 74, 14, 1084, 714, 84, 1575, 86, 8, 1575, 86, 1110, 12, 82, 998, 12, 1575, 86, 998, 9, 1223, 8065, 199, 318, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 304, 1223, 198, 624, 9899, 314, 1174, 402, 373, 5691, 89, 16005, 370, 641, 503, 2331, 14, 221, 2494, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9471, 1223, 198, 1099, 275, 485, 86, 74, 14, 1084, 22552, 8, 929, 12, 82, 998, 12, 3887, 998, 9, 1223, 198, 692, 754, 508, 378, 26, 4122, 198, 3730, 373, 5691, 89, 4259, 547, 342, 1223, 198, 2836, 26, 4122, 198, 1107, 715, 8065, 199, 318, 15510, 54, 42, 36, 8, 82, 998, 304, 1223, 198, 624, 9637, 1006, 7824, 436, 15766, 370, 849, 367, 2013, 373, 5691, 89, 12272, 624, 1223, 198, 1107, 485, 86, 74, 14, 9637, 54, 42, 36, 8, 82, 998, 9, 8065, 199, 318, 15510, 24021, 8, 82, 998, 304, 1223, 198, 624, 9637, 1006, 15766, 370, 849, 367, 2013, 373, 5691, 89, 12272, 624, 1223, 198, 1107, 485, 86, 74, 14, 9637, 24021, 8, 82, 998, 9, 8065, 199, 318, 15510, 1575, 3122, 8, 82, 998, 304, 1223, 198, 624, 9637, 1006, 3625, 54, 394, 1956, 370, 849, 367, 2013, 373, 5691, 89, 12272, 624, 1223, 198, 1107, 485, 86, 74, 14, 9637, 24021, 8, 82, 998, 9, 10060, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mbernasocchi/QGIS
python/plugins/processing/gui/AutofillDialog.py
30
2422
# -*- coding: utf-8 -*- """ *************************************************************************** AutofillDialog.py --------------------- Date : August 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'August 2012' __copyright__ = '(C) 2012, Victor Olaya' import os import warnings from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QDialog pluginPath = os.path.split(os.path.dirname(__file__))[0] with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) WIDGET, BASE = uic.loadUiType( os.path.join(pluginPath, 'ui', 'DlgAutofill.ui')) class AutofillDialog(BASE, WIDGET): DO_NOT_AUTOFILL = 0 FILL_WITH_NUMBERS = 1 FILL_WITH_PARAMETER = 2 def __init__(self, alg): super(AutofillDialog, self).__init__(None) self.setupUi(self) self.mode = None self.param_name = None self.alg = alg self.cmbFillType.currentIndexChanged.connect(self.toggleParameters) for param in self.alg.parameterDefinitions(): self.cmbParameters.addItem(param.description(), param.name()) def toggleParameters(self, index): if index == self.FILL_WITH_PARAMETER: self.lblParameters.setEnabled(True) self.cmbParameters.setEnabled(True) else: self.lblParameters.setEnabled(False) self.cmbParameters.setEnabled(False) def accept(self): self.mode = self.cmbFillType.currentIndex() self.param_name = self.cmbParameters.currentData() QDialog.accept(self) def reject(self): self.mode = None self.param_name = None QDialog.reject(self)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 9195, 4498, 5619, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 646, 747, 199, 646, 3598, 199, 199, 504, 15640, 14, 24107, 492, 399, 530, 199, 504, 15640, 14, 24107, 14, 29081, 492, 1413, 5619, 199, 199, 2718, 2042, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 59, 16, 61, 199, 199, 1045, 3598, 14, 9341, 63, 5451, 837, 272, 3598, 14, 23945, 480, 4247, 401, 4637, 29, 15561, 9, 272, 644, 998, 2970, 12, 19721, 275, 399, 530, 14, 912, 18203, 804, 8, 267, 747, 14, 515, 14, 904, 8, 2718, 2042, 12, 283, 1907, 297, 283, 20192, 3358, 4498, 14, 1907, 1333, 421, 199, 533, 9195, 4498, 5619, 8, 5825, 12, 644, 998, 2970, 304, 272, 3506, 63, 4609, 63, 10774, 3359, 14961, 275, 378, 272, 481, 14961, 63, 9139, 63, 8861, 3960, 275, 413, 272, 481, 14961, 63, 9139, 63, 14472, 275, 499, 339, 347, 636, 826, 721, 277, 12, 15760, 304, 267, 1613, 8, 3358, 4498, 5619, 12, 291, 2843, 826, 721, 403, 9, 267, 291, 14, 2758, 18203, 8, 277, 9, 267, 291, 14, 632, 275, 488, 267, 291, 14, 635, 63, 354, 275, 488, 267, 291, 14, 6731, 275, 15760, 398, 291, 14, 18892, 12914, 804, 14, 29003, 6970, 14, 2242, 8, 277, 14, 13396, 5976, 9, 398, 367, 1215, 315, 291, 14, 6731, 14, 5329, 16738, 837, 288, 291, 14, 18892, 5976, 14, 19798, 8, 635, 14, 1802, 1062, 1215, 14, 354, 1012, 339, 347, 19420, 5976, 8, 277, 12, 1478, 304, 267, 340, 1478, 508, 291, 14, 5110, 44, 63, 9139, 63, 14472, 26, 288, 291, 14, 18842, 5976, 14, 14329, 8, 549, 9, 288, 291, 14, 18892, 5976, 14, 14329, 8, 549, 9, 267, 587, 26, 288, 291, 14, 18842, 5976, 14, 14329, 8, 797, 9, 288, 291, 14, 18892, 5976, 14, 14329, 8, 797, 9, 339, 347, 4729, 8, 277, 304, 267, 291, 14, 632, 275, 291, 14, 18892, 12914, 804, 14, 29003, 342, 267, 291, 14, 635, 63, 354, 275, 291, 14, 18892, 5976, 14, 1818, 1451, 342, 267, 1413, 5619, 14, 5694, 8, 277, 9, 339, 347, 17100, 8, 277, 304, 267, 291, 14, 632, 275, 488, 267, 291, 14, 635, 63, 354, 275, 488, 267, 1413, 5619, 14, 16857, 8, 277, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 9195, 4498, 5619, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 646, 747, 199, 646, 3598, 199, 199, 504, 15640, 14, 24107, 492, 399, 530, 199, 504, 15640, 14, 24107, 14, 29081, 492, 1413, 5619, 199, 199, 2718, 2042, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 59, 16, 61, 199, 199, 1045, 3598, 14, 9341, 63, 5451, 837, 272, 3598, 14, 23945, 480, 4247, 401, 4637, 29, 15561, 9, 272, 644, 998, 2970, 12, 19721, 275, 399, 530, 14, 912, 18203, 804, 8, 267, 747, 14, 515, 14, 904, 8, 2718, 2042, 12, 283, 1907, 297, 283, 20192, 3358, 4498, 14, 1907, 1333, 421, 199, 533, 9195, 4498, 5619, 8, 5825, 12, 644, 998, 2970, 304, 272, 3506, 63, 4609, 63, 10774, 3359, 14961, 275, 378, 272, 481, 14961, 63, 9139, 63, 8861, 3960, 275, 413, 272, 481, 14961, 63, 9139, 63, 14472, 275, 499, 339, 347, 636, 826, 721, 277, 12, 15760, 304, 267, 1613, 8, 3358, 4498, 5619, 12, 291, 2843, 826, 721, 403, 9, 267, 291, 14, 2758, 18203, 8, 277, 9, 267, 291, 14, 632, 275, 488, 267, 291, 14, 635, 63, 354, 275, 488, 267, 291, 14, 6731, 275, 15760, 398, 291, 14, 18892, 12914, 804, 14, 29003, 6970, 14, 2242, 8, 277, 14, 13396, 5976, 9, 398, 367, 1215, 315, 291, 14, 6731, 14, 5329, 16738, 837, 288, 291, 14, 18892, 5976, 14, 19798, 8, 635, 14, 1802, 1062, 1215, 14, 354, 1012, 339, 347, 19420, 5976, 8, 277, 12, 1478, 304, 267, 340, 1478, 508, 291, 14, 5110, 44, 63, 9139, 63, 14472, 26, 288, 291, 14, 18842, 5976, 14, 14329, 8, 549, 9, 288, 291, 14, 18892, 5976, 14, 14329, 8, 549, 9, 267, 587, 26, 288, 291, 14, 18842, 5976, 14, 14329, 8, 797, 9, 288, 291, 14, 18892, 5976, 14, 14329, 8, 797, 9, 339, 347, 4729, 8, 277, 304, 267, 291, 14, 632, 275, 291, 14, 18892, 12914, 804, 14, 29003, 342, 267, 291, 14, 635, 63, 354, 275, 291, 14, 18892, 5976, 14, 1818, 1451, 342, 267, 1413, 5619, 14, 5694, 8, 277, 9, 339, 347, 17100, 8, 277, 304, 267, 291, 14, 632, 275, 488, 267, 291, 14, 635, 63, 354, 275, 488, 267, 1413, 5619, 14, 16857, 8, 277, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
baidurom/repo
manifest_xml.py
4
25259
# # Copyright (C) 2008 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function import itertools import os import re import sys import urlparse import xml.dom.minidom from git_config import GitConfig from git_refs import R_HEADS, HEAD from project import RemoteSpec, Project, MetaProject from error import ManifestParseError MANIFEST_FILE_NAME = 'manifest.xml' LOCAL_MANIFEST_NAME = 'local_manifest.xml' LOCAL_MANIFESTS_DIR_NAME = 'local_manifests' urlparse.uses_relative.extend(['ssh', 'git']) urlparse.uses_netloc.extend(['ssh', 'git']) class _Default(object): """Project defaults within the manifest.""" revisionExpr = None remote = None sync_j = 1 sync_c = False sync_s = False class _XmlRemote(object): def __init__(self, name, alias=None, fetch=None, manifestUrl=None, review=None): self.name = name self.fetchUrl = fetch self.manifestUrl = manifestUrl self.remoteAlias = alias self.reviewUrl = review self.resolvedFetchUrl = self._resolveFetchUrl() def __eq__(self, other): return self.__dict__ == other.__dict__ def __ne__(self, other): return self.__dict__ != other.__dict__ def _resolveFetchUrl(self): url = self.fetchUrl.rstrip('/') manifestUrl = self.manifestUrl.rstrip('/') p = manifestUrl.startswith('persistent-http') if p: manifestUrl = manifestUrl[len('persistent-'):] # urljoin will get confused if there is no scheme in the base url # ie, if manifestUrl is of the form <hostname:port> if manifestUrl.find(':') != manifestUrl.find('/') - 1: manifestUrl = 'gopher://' + manifestUrl url = urlparse.urljoin(manifestUrl, url) url = re.sub(r'^gopher://', '', url) if p: url = 'persistent-' + url return url def ToRemoteSpec(self, projectName): url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName remoteName = self.name if self.remoteAlias: remoteName = self.remoteAlias return RemoteSpec(remoteName, url, self.reviewUrl) class XmlManifest(object): """manages the repo configuration file""" def __init__(self, repodir): self.repodir = os.path.abspath(repodir) self.topdir = os.path.dirname(self.repodir) self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME) self.globalConfig = GitConfig.ForUser() self.repoProject = MetaProject(self, 'repo', gitdir = os.path.join(repodir, 'repo/.git'), worktree = os.path.join(repodir, 'repo')) self.manifestProject = MetaProject(self, 'manifests', gitdir = os.path.join(repodir, 'manifests.git'), worktree = os.path.join(repodir, 'manifests')) self._Unload() def Override(self, name): """Use a different manifest, just for the current instantiation. """ path = os.path.join(self.manifestProject.worktree, name) if not os.path.isfile(path): raise ManifestParseError('manifest %s not found' % name) old = self.manifestFile try: self.manifestFile = path self._Unload() self._Load() finally: self.manifestFile = old def Link(self, name): """Update the repo metadata to use a different manifest. """ self.Override(name) try: if os.path.lexists(self.manifestFile): os.remove(self.manifestFile) os.symlink('manifests/%s' % name, self.manifestFile) except OSError as e: raise ManifestParseError('cannot link manifest %s: %s' % (name, str(e))) def _RemoteToXml(self, r, doc, root): e = doc.createElement('remote') root.appendChild(e) e.setAttribute('name', r.name) e.setAttribute('fetch', r.fetchUrl) if r.reviewUrl is not None: e.setAttribute('review', r.reviewUrl) def Save(self, fd, peg_rev=False, peg_rev_upstream=True): """Write the current manifest out to the given file descriptor. """ mp = self.manifestProject groups = mp.config.GetString('manifest.groups') if groups: groups = [x for x in re.split(r'[,\s]+', groups) if x] doc = xml.dom.minidom.Document() root = doc.createElement('manifest') doc.appendChild(root) # Save out the notice. There's a little bit of work here to give it the # right whitespace, which assumes that the notice is automatically indented # by 4 by minidom. if self.notice: notice_element = root.appendChild(doc.createElement('notice')) notice_lines = self.notice.splitlines() indented_notice = ('\n'.join(" "*4 + line for line in notice_lines))[4:] notice_element.appendChild(doc.createTextNode(indented_notice)) d = self.default sort_remotes = list(self.remotes.keys()) sort_remotes.sort() for r in sort_remotes: self._RemoteToXml(self.remotes[r], doc, root) if self.remotes: root.appendChild(doc.createTextNode('')) have_default = False e = doc.createElement('default') if d.remote: have_default = True e.setAttribute('remote', d.remote.name) if d.revisionExpr: have_default = True e.setAttribute('revision', d.revisionExpr) if d.sync_j > 1: have_default = True e.setAttribute('sync-j', '%d' % d.sync_j) if d.sync_c: have_default = True e.setAttribute('sync-c', 'true') if d.sync_s: have_default = True e.setAttribute('sync-s', 'true') if have_default: root.appendChild(e) root.appendChild(doc.createTextNode('')) if self._manifest_server: e = doc.createElement('manifest-server') e.setAttribute('url', self._manifest_server) root.appendChild(e) root.appendChild(doc.createTextNode('')) def output_projects(parent, parent_node, projects): for p in projects: output_project(parent, parent_node, self.projects[p]) def output_project(parent, parent_node, p): if not p.MatchesGroups(groups): return name = p.name relpath = p.relpath if parent: name = self._UnjoinName(parent.name, name) relpath = self._UnjoinRelpath(parent.relpath, relpath) e = doc.createElement('project') parent_node.appendChild(e) e.setAttribute('name', name) if relpath != name: e.setAttribute('path', relpath) if not d.remote or p.remote.name != d.remote.name: e.setAttribute('remote', p.remote.name) if peg_rev: if self.IsMirror: value = p.bare_git.rev_parse(p.revisionExpr + '^0') else: value = p.work_git.rev_parse(HEAD + '^0') e.setAttribute('revision', value) if peg_rev_upstream and value != p.revisionExpr: # Only save the origin if the origin is not a sha1, and the default # isn't our value, and the if the default doesn't already have that # covered. e.setAttribute('upstream', p.revisionExpr) elif not d.revisionExpr or p.revisionExpr != d.revisionExpr: e.setAttribute('revision', p.revisionExpr) for c in p.copyfiles: ce = doc.createElement('copyfile') ce.setAttribute('src', c.src) ce.setAttribute('dest', c.dest) e.appendChild(ce) default_groups = ['all', 'name:%s' % p.name, 'path:%s' % p.relpath] egroups = [g for g in p.groups if g not in default_groups] if egroups: e.setAttribute('groups', ','.join(egroups)) for a in p.annotations: if a.keep == "true": ae = doc.createElement('annotation') ae.setAttribute('name', a.name) ae.setAttribute('value', a.value) e.appendChild(ae) if p.sync_c: e.setAttribute('sync-c', 'true') if p.sync_s: e.setAttribute('sync-s', 'true') if p.subprojects: sort_projects = [subp.name for subp in p.subprojects] sort_projects.sort() output_projects(p, e, sort_projects) sort_projects = [key for key in self.projects.keys() if not self.projects[key].parent] sort_projects.sort() output_projects(None, root, sort_projects) if self._repo_hooks_project: root.appendChild(doc.createTextNode('')) e = doc.createElement('repo-hooks') e.setAttribute('in-project', self._repo_hooks_project.name) e.setAttribute('enabled-list', ' '.join(self._repo_hooks_project.enabled_repo_hooks)) root.appendChild(e) doc.writexml(fd, '', ' ', '\n', 'UTF-8') @property def projects(self): self._Load() return self._projects @property def remotes(self): self._Load() return self._remotes @property def default(self): self._Load() return self._default @property def repo_hooks_project(self): self._Load() return self._repo_hooks_project @property def notice(self): self._Load() return self._notice @property def manifest_server(self): self._Load() return self._manifest_server @property def IsMirror(self): return self.manifestProject.config.GetBoolean('repo.mirror') def _Unload(self): self._loaded = False self._projects = {} self._remotes = {} self._default = None self._repo_hooks_project = None self._notice = None self.branch = None self._manifest_server = None def _Load(self): if not self._loaded: m = self.manifestProject b = m.GetBranch(m.CurrentBranch).merge if b is not None and b.startswith(R_HEADS): b = b[len(R_HEADS):] self.branch = b nodes = [] nodes.append(self._ParseManifestXml(self.manifestFile, self.manifestProject.worktree)) local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) if os.path.exists(local): print('warning: %s is deprecated; put local manifests in `%s` instead' % (LOCAL_MANIFEST_NAME, os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)), file=sys.stderr) nodes.append(self._ParseManifestXml(local, self.repodir)) local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)) try: for local_file in sorted(os.listdir(local_dir)): if local_file.endswith('.xml'): local = os.path.join(local_dir, local_file) nodes.append(self._ParseManifestXml(local, self.repodir)) except OSError: pass try: self._ParseManifest(nodes) except ManifestParseError as e: # There was a problem parsing, unload ourselves in case they catch # this error and try again later, we will show the correct error self._Unload() raise e if self.IsMirror: self._AddMetaProjectMirror(self.repoProject) self._AddMetaProjectMirror(self.manifestProject) self._loaded = True def _ParseManifestXml(self, path, include_root): try: root = xml.dom.minidom.parse(path) except (OSError, xml.parsers.expat.ExpatError) as e: raise ManifestParseError("error parsing manifest %s: %s" % (path, e)) if not root or not root.childNodes: raise ManifestParseError("no root node in %s" % (path,)) for manifest in root.childNodes: if manifest.nodeName == 'manifest': break else: raise ManifestParseError("no <manifest> in %s" % (path,)) nodes = [] for node in manifest.childNodes: # pylint:disable=W0631 # We only get here if manifest is initialised if node.nodeName == 'include': name = self._reqatt(node, 'name') fp = os.path.join(include_root, name) if not os.path.isfile(fp): raise ManifestParseError, \ "include %s doesn't exist or isn't a file" % \ (name,) try: nodes.extend(self._ParseManifestXml(fp, include_root)) # should isolate this to the exact exception, but that's # tricky. actual parsing implementation may vary. except (KeyboardInterrupt, RuntimeError, SystemExit): raise except Exception as e: raise ManifestParseError( "failed parsing included manifest %s: %s", (name, e)) else: nodes.append(node) return nodes def _ParseManifest(self, node_list): for node in itertools.chain(*node_list): if node.nodeName == 'remote': remote = self._ParseRemote(node) if remote: if remote.name in self._remotes: if remote != self._remotes[remote.name]: raise ManifestParseError( 'remote %s already exists with different attributes' % (remote.name)) else: self._remotes[remote.name] = remote for node in itertools.chain(*node_list): if node.nodeName == 'default': if self._default is not None: raise ManifestParseError( 'duplicate default in %s' % (self.manifestFile)) self._default = self._ParseDefault(node) if self._default is None: self._default = _Default() for node in itertools.chain(*node_list): if node.nodeName == 'notice': if self._notice is not None: raise ManifestParseError( 'duplicate notice in %s' % (self.manifestFile)) self._notice = self._ParseNotice(node) for node in itertools.chain(*node_list): if node.nodeName == 'manifest-server': url = self._reqatt(node, 'url') if self._manifest_server is not None: raise ManifestParseError( 'duplicate manifest-server in %s' % (self.manifestFile)) self._manifest_server = url def recursively_add_projects(project): if self._projects.get(project.name): raise ManifestParseError( 'duplicate project %s in %s' % (project.name, self.manifestFile)) self._projects[project.name] = project for subproject in project.subprojects: recursively_add_projects(subproject) for node in itertools.chain(*node_list): if node.nodeName == 'project': project = self._ParseProject(node) recursively_add_projects(project) if node.nodeName == 'repo-hooks': # Get the name of the project and the (space-separated) list of enabled. repo_hooks_project = self._reqatt(node, 'in-project') enabled_repo_hooks = self._reqatt(node, 'enabled-list').split() # Only one project can be the hooks project if self._repo_hooks_project is not None: raise ManifestParseError( 'duplicate repo-hooks in %s' % (self.manifestFile)) # Store a reference to the Project. try: self._repo_hooks_project = self._projects[repo_hooks_project] except KeyError: raise ManifestParseError( 'project %s not found for repo-hooks' % (repo_hooks_project)) # Store the enabled hooks in the Project object. self._repo_hooks_project.enabled_repo_hooks = enabled_repo_hooks if node.nodeName == 'remove-project': name = self._reqatt(node, 'name') try: del self._projects[name] except KeyError: raise ManifestParseError('remove-project element specifies non-existent ' 'project: %s' % name) # If the manifest removes the hooks project, treat it as if it deleted # the repo-hooks element too. if self._repo_hooks_project and (self._repo_hooks_project.name == name): self._repo_hooks_project = None def _AddMetaProjectMirror(self, m): name = None m_url = m.GetRemote(m.remote.name).url if m_url.endswith('/.git'): raise ManifestParseError, 'refusing to mirror %s' % m_url if self._default and self._default.remote: url = self._default.remote.resolvedFetchUrl if not url.endswith('/'): url += '/' if m_url.startswith(url): remote = self._default.remote name = m_url[len(url):] if name is None: s = m_url.rindex('/') + 1 manifestUrl = self.manifestProject.config.GetString('remote.origin.url') remote = _XmlRemote('origin', fetch=m_url[:s], manifestUrl=manifestUrl) name = m_url[s:] if name.endswith('.git'): name = name[:-4] if name not in self._projects: m.PreSync() gitdir = os.path.join(self.topdir, '%s.git' % name) project = Project(manifest = self, name = name, remote = remote.ToRemoteSpec(name), gitdir = gitdir, worktree = None, relpath = None, revisionExpr = m.revisionExpr, revisionId = None) self._projects[project.name] = project def _ParseRemote(self, node): """ reads a <remote> element from the manifest file """ name = self._reqatt(node, 'name') alias = node.getAttribute('alias') if alias == '': alias = None fetch = self._reqatt(node, 'fetch') review = node.getAttribute('review') if review == '': review = None manifestUrl = self.manifestProject.config.GetString('remote.origin.url') return _XmlRemote(name, alias, fetch, manifestUrl, review) def _ParseDefault(self, node): """ reads a <default> element from the manifest file """ d = _Default() d.remote = self._get_remote(node) d.revisionExpr = node.getAttribute('revision') if d.revisionExpr == '': d.revisionExpr = None sync_j = node.getAttribute('sync-j') if sync_j == '' or sync_j is None: d.sync_j = 1 else: d.sync_j = int(sync_j) sync_c = node.getAttribute('sync-c') if not sync_c: d.sync_c = False else: d.sync_c = sync_c.lower() in ("yes", "true", "1") sync_s = node.getAttribute('sync-s') if not sync_s: d.sync_s = False else: d.sync_s = sync_s.lower() in ("yes", "true", "1") return d def _ParseNotice(self, node): """ reads a <notice> element from the manifest file The <notice> element is distinct from other tags in the XML in that the data is conveyed between the start and end tag (it's not an empty-element tag). The white space (carriage returns, indentation) for the notice element is relevant and is parsed in a way that is based on how python docstrings work. In fact, the code is remarkably similar to here: http://www.python.org/dev/peps/pep-0257/ """ # Get the data out of the node... notice = node.childNodes[0].data # Figure out minimum indentation, skipping the first line (the same line # as the <notice> tag)... minIndent = sys.maxint lines = notice.splitlines() for line in lines[1:]: lstrippedLine = line.lstrip() if lstrippedLine: indent = len(line) - len(lstrippedLine) minIndent = min(indent, minIndent) # Strip leading / trailing blank lines and also indentation. cleanLines = [lines[0].strip()] for line in lines[1:]: cleanLines.append(line[minIndent:].rstrip()) # Clear completely blank lines from front and back... while cleanLines and not cleanLines[0]: del cleanLines[0] while cleanLines and not cleanLines[-1]: del cleanLines[-1] return '\n'.join(cleanLines) def _JoinName(self, parent_name, name): return os.path.join(parent_name, name) def _UnjoinName(self, parent_name, name): return os.path.relpath(name, parent_name) def _ParseProject(self, node, parent = None): """ reads a <project> element from the manifest file """ name = self._reqatt(node, 'name') if parent: name = self._JoinName(parent.name, name) remote = self._get_remote(node) if remote is None: remote = self._default.remote if remote is None: raise ManifestParseError, \ "no remote for project %s within %s" % \ (name, self.manifestFile) revisionExpr = node.getAttribute('revision') if not revisionExpr: revisionExpr = self._default.revisionExpr if not revisionExpr: raise ManifestParseError, \ "no revision for project %s within %s" % \ (name, self.manifestFile) path = node.getAttribute('path') if not path: path = name if path.startswith('/'): raise ManifestParseError, \ "project %s path cannot be absolute in %s" % \ (name, self.manifestFile) rebase = node.getAttribute('rebase') if not rebase: rebase = True else: rebase = rebase.lower() in ("yes", "true", "1") sync_c = node.getAttribute('sync-c') if not sync_c: sync_c = False else: sync_c = sync_c.lower() in ("yes", "true", "1") sync_s = node.getAttribute('sync-s') if not sync_s: sync_s = self._default.sync_s else: sync_s = sync_s.lower() in ("yes", "true", "1") upstream = node.getAttribute('upstream') groups = '' if node.hasAttribute('groups'): groups = node.getAttribute('groups') groups = [x for x in re.split(r'[,\s]+', groups) if x] if parent is None: relpath, worktree, gitdir = self.GetProjectPaths(name, path) else: relpath, worktree, gitdir = self.GetSubprojectPaths(parent, path) default_groups = ['all', 'name:%s' % name, 'path:%s' % relpath] groups.extend(set(default_groups).difference(groups)) project = Project(manifest = self, name = name, remote = remote.ToRemoteSpec(name), gitdir = gitdir, worktree = worktree, relpath = relpath, revisionExpr = revisionExpr, revisionId = None, rebase = rebase, groups = groups, sync_c = sync_c, sync_s = sync_s, upstream = upstream, parent = parent) for n in node.childNodes: if n.nodeName == 'copyfile': self._ParseCopyFile(project, n) if n.nodeName == 'annotation': self._ParseAnnotation(project, n) if n.nodeName == 'project': project.subprojects.append(self._ParseProject(n, parent = project)) return project def GetProjectPaths(self, name, path): relpath = path if self.IsMirror: worktree = None gitdir = os.path.join(self.topdir, '%s.git' % name) else: worktree = os.path.join(self.topdir, path).replace('\\', '/') gitdir = os.path.join(self.repodir, 'projects', '%s.git' % path) return relpath, worktree, gitdir def GetSubprojectName(self, parent, submodule_path): return os.path.join(parent.name, submodule_path) def _JoinRelpath(self, parent_relpath, relpath): return os.path.join(parent_relpath, relpath) def _UnjoinRelpath(self, parent_relpath, relpath): return os.path.relpath(relpath, parent_relpath) def GetSubprojectPaths(self, parent, path): relpath = self._JoinRelpath(parent.relpath, path) gitdir = os.path.join(parent.gitdir, 'subprojects', '%s.git' % path) if self.IsMirror: worktree = None else: worktree = os.path.join(parent.worktree, path).replace('\\', '/') return relpath, worktree, gitdir def _ParseCopyFile(self, project, node): src = self._reqatt(node, 'src') dest = self._reqatt(node, 'dest') if not self.IsMirror: # src is project relative; # dest is relative to the top of the tree project.AddCopyFile(src, dest, os.path.join(self.topdir, dest)) def _ParseAnnotation(self, project, node): name = self._reqatt(node, 'name') value = self._reqatt(node, 'value') try: keep = self._reqatt(node, 'keep').lower() except ManifestParseError: keep = "true" if keep != "true" and keep != "false": raise ManifestParseError, "optional \"keep\" attribute must be \"true\" or \"false\"" project.AddAnnotation(name, value, keep) def _get_remote(self, node): name = node.getAttribute('remote') if not name: return None v = self._remotes.get(name) if not v: raise ManifestParseError, \ "remote %s not defined in %s" % \ (name, self.manifestFile) return v def _reqatt(self, node, attname): """ reads a required attribute from the node. """ v = node.getAttribute(attname) if not v: raise ManifestParseError, \ "no %s in <%s> within %s" % \ (attname, node.nodeName, self.manifestFile) return v
apache-2.0
[ 3, 199, 3, 1898, 334, 35, 9, 9079, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7975, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 7097, 199, 646, 2748, 14, 4556, 14, 21827, 199, 199, 504, 6135, 63, 888, 492, 12579, 2028, 199, 504, 6135, 63, 7655, 492, 820, 63, 5211, 51, 12, 13053, 199, 504, 2199, 492, 17283, 5307, 12, 7290, 12, 6288, 4761, 199, 504, 1125, 492, 4688, 3944, 9123, 199, 199, 24067, 63, 3817, 63, 2339, 275, 283, 6418, 14, 1652, 7, 199, 7486, 63, 24067, 63, 2339, 275, 283, 1832, 63, 6418, 14, 1652, 7, 199, 7486, 63, 24067, 51, 63, 3022, 63, 2339, 275, 283, 1832, 63, 6418, 83, 7, 199, 199, 10290, 14, 5589, 63, 6188, 14, 2880, 2941, 5510, 297, 283, 3187, 1105, 199, 10290, 14, 5589, 63, 12652, 14, 2880, 2941, 5510, 297, 283, 3187, 1105, 199, 199, 533, 485, 2698, 8, 785, 304, 523, 408, 4761, 4243, 4453, 314, 7712, 1041, 819, 6974, 8561, 275, 488, 523, 3982, 275, 488, 523, 7604, 63, 74, 275, 413, 523, 7604, 63, 67, 275, 756, 523, 7604, 63, 83, 275, 756, 199, 199, 533, 485, 8672, 6713, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2049, 536, 12, 2049, 5162, 29, 403, 12, 2049, 5267, 29, 403, 12, 2049, 7712, 6417, 29, 403, 12, 2049, 11248, 29, 403, 304, 272, 291, 14, 354, 275, 536, 272, 291, 14, 3535, 6417, 275, 5267, 272, 291, 14, 6418, 6417, 275, 7712, 6417, 272, 291, 14, 3846, 14149, 275, 5162, 272, 291, 14, 8578, 6417, 275, 11248, 272, 291, 14, 13697, 11135, 6417, 275, 291, 423, 6983, 11135, 6417, 342, 819, 347, 636, 4077, 721, 277, 12, 1163, 304, 272, 372, 291, 855, 807, 363, 508, 1163, 855, 807, 363, 819, 347, 636, 685, 721, 277, 12, 1163, 304, 272, 372, 291, 855, 807, 363, 1137, 1163, 855, 807, 363, 819, 347, 485, 6983, 11135, 6417, 8, 277, 304, 272, 1166, 275, 291, 14, 3535, 6417, 14, 6735, 7825, 272, 7712, 6417, 275, 291, 14, 6418, 6417, 14, 6735, 7825, 272, 299, 275, 7712, 6417, 14, 2460, 360, 18539, 13, 1014, 358, 272, 340, 299, 26, 489, 7712, 6417, 275, 7712, 6417, 59, 552, 360, 18539, 13, 735, 61, 339, 327, 20818, 911, 664, 3743, 2972, 340, 2337, 365, 949, 5687, 315, 314, 1300, 1166, 272, 327, 13446, 12, 340, 7712, 6417, 365, 402, 314, 1824, 665, 4269, 26, 719, 30, 272, 340, 7712, 6417, 14, 1623, 11633, 1137, 7712, 6417, 14, 1623, 7825, 446, 413, 26, 489, 7712, 6417, 275, 283, 71, 411, 2523, 22399, 435, 7712, 6417, 272, 1166, 275, 7097, 14, 17755, 8, 6418, 6417, 12, 1166, 9, 272, 1166, 275, 295, 14, 954, 8, 82, 4289, 71, 411, 2523, 921, 297, 3260, 1166, 9, 272, 340, 299, 26, 489, 1166, 275, 283, 18539, 15668, 435, 1166, 272, 372, 1166, 819, 347, 4005, 6713, 5307, 8, 277, 12, 2199, 985, 304, 272, 1166, 275, 291, 14, 13697, 11135, 6417, 14, 6735, 7825, 435, 7324, 435, 2199, 985, 272, 3982, 985, 275, 291, 14, 354, 272, 340, 291, 14, 3846, 14149, 26, 489, 3982, 985, 275, 291, 14, 3846, 14149, 272, 372, 17283, 5307, 8, 3846, 985, 12, 1166, 12, 291, 14, 8578, 6417, 9, 199, 199, 533, 24881, 11038, 8, 785, 304, 523, 408, 1237, 7441, 314, 3831, 2897, 570, 624, 819, 347, 636, 826, 721, 277, 12, 3831, 694, 304, 272, 291, 14, 3417, 694, 275, 747, 14, 515, 14, 4832, 8, 3417, 694, 9, 272, 291, 14, 2119, 694, 275, 747, 14, 515, 14, 3475, 8, 277, 14, 3417, 694, 9, 272, 291, 14, 6418, 1173, 275, 747, 14, 515, 14, 904, 8, 277, 14, 3417, 694, 12, 26688, 20649, 63, 3817, 63, 2339, 9, 272, 291, 14, 2966, 2028, 275, 12579, 2028, 14, 1858, 1899, 342, 339, 291, 14, 3417, 4761, 275, 6288, 4761, 8, 277, 12, 283, 3417, 297, 489, 6135, 694, 257, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 3417, 8083, 3187, 659, 489, 1736, 2350, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 3417, 1333, 339, 291, 14, 6418, 4761, 275, 6288, 4761, 8, 277, 12, 283, 6418, 83, 297, 489, 6135, 694, 257, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 6418, 83, 14, 3187, 659, 489, 1736, 2350, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 6418, 83, 1333, 339, 291, 423, 31470, 342, 819, 347, 11041, 8, 277, 12, 536, 304, 272, 408, 6119, 282, 3365, 7712, 12, 2951, 367, 314, 1453, 26621, 14, 272, 408, 272, 931, 275, 747, 14, 515, 14, 904, 8, 277, 14, 6418, 4761, 14, 800, 2350, 12, 536, 9, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 515, 304, 489, 746, 4688, 3944, 9123, 360, 6418, 450, 83, 440, 1911, 7, 450, 536, 9, 339, 2269, 275, 291, 14, 6418, 1173, 272, 862, 26, 489, 291, 14, 6418, 1173, 275, 931, 489, 291, 423, 31470, 342, 489, 291, 423, 6200, 342, 272, 3753, 26, 489, 291, 14, 6418, 1173, 275, 2269, 819, 347, 10967, 8, 277, 12, 536, 304, 272, 408, 4152, 314, 3831, 3341, 370, 675, 282, 3365, 7712, 14, 272, 408, 272, 291, 14, 11954, 8, 354, 9, 339, 862, 26, 489 ]
[ 199, 3, 1898, 334, 35, 9, 9079, 710, 14694, 3232, 5800, 7290, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7975, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 7097, 199, 646, 2748, 14, 4556, 14, 21827, 199, 199, 504, 6135, 63, 888, 492, 12579, 2028, 199, 504, 6135, 63, 7655, 492, 820, 63, 5211, 51, 12, 13053, 199, 504, 2199, 492, 17283, 5307, 12, 7290, 12, 6288, 4761, 199, 504, 1125, 492, 4688, 3944, 9123, 199, 199, 24067, 63, 3817, 63, 2339, 275, 283, 6418, 14, 1652, 7, 199, 7486, 63, 24067, 63, 2339, 275, 283, 1832, 63, 6418, 14, 1652, 7, 199, 7486, 63, 24067, 51, 63, 3022, 63, 2339, 275, 283, 1832, 63, 6418, 83, 7, 199, 199, 10290, 14, 5589, 63, 6188, 14, 2880, 2941, 5510, 297, 283, 3187, 1105, 199, 10290, 14, 5589, 63, 12652, 14, 2880, 2941, 5510, 297, 283, 3187, 1105, 199, 199, 533, 485, 2698, 8, 785, 304, 523, 408, 4761, 4243, 4453, 314, 7712, 1041, 819, 6974, 8561, 275, 488, 523, 3982, 275, 488, 523, 7604, 63, 74, 275, 413, 523, 7604, 63, 67, 275, 756, 523, 7604, 63, 83, 275, 756, 199, 199, 533, 485, 8672, 6713, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 2049, 536, 12, 2049, 5162, 29, 403, 12, 2049, 5267, 29, 403, 12, 2049, 7712, 6417, 29, 403, 12, 2049, 11248, 29, 403, 304, 272, 291, 14, 354, 275, 536, 272, 291, 14, 3535, 6417, 275, 5267, 272, 291, 14, 6418, 6417, 275, 7712, 6417, 272, 291, 14, 3846, 14149, 275, 5162, 272, 291, 14, 8578, 6417, 275, 11248, 272, 291, 14, 13697, 11135, 6417, 275, 291, 423, 6983, 11135, 6417, 342, 819, 347, 636, 4077, 721, 277, 12, 1163, 304, 272, 372, 291, 855, 807, 363, 508, 1163, 855, 807, 363, 819, 347, 636, 685, 721, 277, 12, 1163, 304, 272, 372, 291, 855, 807, 363, 1137, 1163, 855, 807, 363, 819, 347, 485, 6983, 11135, 6417, 8, 277, 304, 272, 1166, 275, 291, 14, 3535, 6417, 14, 6735, 7825, 272, 7712, 6417, 275, 291, 14, 6418, 6417, 14, 6735, 7825, 272, 299, 275, 7712, 6417, 14, 2460, 360, 18539, 13, 1014, 358, 272, 340, 299, 26, 489, 7712, 6417, 275, 7712, 6417, 59, 552, 360, 18539, 13, 735, 61, 339, 327, 20818, 911, 664, 3743, 2972, 340, 2337, 365, 949, 5687, 315, 314, 1300, 1166, 272, 327, 13446, 12, 340, 7712, 6417, 365, 402, 314, 1824, 665, 4269, 26, 719, 30, 272, 340, 7712, 6417, 14, 1623, 11633, 1137, 7712, 6417, 14, 1623, 7825, 446, 413, 26, 489, 7712, 6417, 275, 283, 71, 411, 2523, 22399, 435, 7712, 6417, 272, 1166, 275, 7097, 14, 17755, 8, 6418, 6417, 12, 1166, 9, 272, 1166, 275, 295, 14, 954, 8, 82, 4289, 71, 411, 2523, 921, 297, 3260, 1166, 9, 272, 340, 299, 26, 489, 1166, 275, 283, 18539, 15668, 435, 1166, 272, 372, 1166, 819, 347, 4005, 6713, 5307, 8, 277, 12, 2199, 985, 304, 272, 1166, 275, 291, 14, 13697, 11135, 6417, 14, 6735, 7825, 435, 7324, 435, 2199, 985, 272, 3982, 985, 275, 291, 14, 354, 272, 340, 291, 14, 3846, 14149, 26, 489, 3982, 985, 275, 291, 14, 3846, 14149, 272, 372, 17283, 5307, 8, 3846, 985, 12, 1166, 12, 291, 14, 8578, 6417, 9, 199, 199, 533, 24881, 11038, 8, 785, 304, 523, 408, 1237, 7441, 314, 3831, 2897, 570, 624, 819, 347, 636, 826, 721, 277, 12, 3831, 694, 304, 272, 291, 14, 3417, 694, 275, 747, 14, 515, 14, 4832, 8, 3417, 694, 9, 272, 291, 14, 2119, 694, 275, 747, 14, 515, 14, 3475, 8, 277, 14, 3417, 694, 9, 272, 291, 14, 6418, 1173, 275, 747, 14, 515, 14, 904, 8, 277, 14, 3417, 694, 12, 26688, 20649, 63, 3817, 63, 2339, 9, 272, 291, 14, 2966, 2028, 275, 12579, 2028, 14, 1858, 1899, 342, 339, 291, 14, 3417, 4761, 275, 6288, 4761, 8, 277, 12, 283, 3417, 297, 489, 6135, 694, 257, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 3417, 8083, 3187, 659, 489, 1736, 2350, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 3417, 1333, 339, 291, 14, 6418, 4761, 275, 6288, 4761, 8, 277, 12, 283, 6418, 83, 297, 489, 6135, 694, 257, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 6418, 83, 14, 3187, 659, 489, 1736, 2350, 275, 747, 14, 515, 14, 904, 8, 3417, 694, 12, 283, 6418, 83, 1333, 339, 291, 423, 31470, 342, 819, 347, 11041, 8, 277, 12, 536, 304, 272, 408, 6119, 282, 3365, 7712, 12, 2951, 367, 314, 1453, 26621, 14, 272, 408, 272, 931, 275, 747, 14, 515, 14, 904, 8, 277, 14, 6418, 4761, 14, 800, 2350, 12, 536, 9, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 515, 304, 489, 746, 4688, 3944, 9123, 360, 6418, 450, 83, 440, 1911, 7, 450, 536, 9, 339, 2269, 275, 291, 14, 6418, 1173, 272, 862, 26, 489, 291, 14, 6418, 1173, 275, 931, 489, 291, 423, 31470, 342, 489, 291, 423, 6200, 342, 272, 3753, 26, 489, 291, 14, 6418, 1173, 275, 2269, 819, 347, 10967, 8, 277, 12, 536, 304, 272, 408, 4152, 314, 3831, 3341, 370, 675, 282, 3365, 7712, 14, 272, 408, 272, 291, 14, 11954, 8, 354, 9, 339, 862, 26, 489, 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, 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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 ]
mvaled/sentry
tests/sentry/attachments/test_redis.py
1
2148
# -*- coding: utf-8 -*- from __future__ import absolute_import import mock import zlib from sentry.cache.redis import RedisClusterCache, RbCache from sentry.testutils import TestCase from sentry.utils.imports import import_string class FakeClient(object): def get(self, key): if key == "c:1:foo:a": return '[{"name":"foo.txt","content_type":"text/plain"}]' elif key == "c:1:foo:a:0": return zlib.compress(b"Hello World!") class RbCluster(object): def get_routing_client(self): return CLIENT CLIENT = FakeClient() RB_CLUSTER = RbCluster() class RedisClusterAttachmentTest(TestCase): @mock.patch("sentry.utils.redis.redis_clusters.get", return_value=CLIENT) def test_process_pending_one_batch(self, cluster_get): attachment_cache = import_string("sentry.attachments.redis.RedisClusterAttachmentCache")() cluster_get.assert_any_call("rc-short") assert isinstance(attachment_cache.inner, RedisClusterCache) assert attachment_cache.inner.client is CLIENT rv = attachment_cache.get("foo") assert len(rv) == 1 attachment = rv[0] assert attachment.meta() == { "type": "event.attachment", "name": "foo.txt", "content_type": "text/plain", } assert attachment.data == b"Hello World!" class RbAttachmentTest(TestCase): @mock.patch("sentry.cache.redis.get_cluster_from_options", return_value=(RB_CLUSTER, {})) def test_process_pending_one_batch(self, cluster_get): attachment_cache = import_string("sentry.attachments.redis.RbAttachmentCache")(hosts=[]) cluster_get.assert_any_call("SENTRY_CACHE_OPTIONS", {"hosts": []}) assert isinstance(attachment_cache.inner, RbCache) assert attachment_cache.inner.client is CLIENT rv = attachment_cache.get("foo") assert len(rv) == 1 attachment = rv[0] assert attachment.meta() == { "type": "event.attachment", "name": "foo.txt", "content_type": "text/plain", } assert attachment.data == b"Hello World!"
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 1683, 199, 646, 12472, 199, 199, 504, 26230, 14, 1637, 14, 15369, 492, 25496, 9581, 4437, 12, 820, 66, 4437, 199, 504, 26230, 14, 396, 1208, 492, 7640, 199, 504, 26230, 14, 1208, 14, 12775, 492, 492, 63, 875, 421, 199, 533, 7777, 3041, 8, 785, 304, 272, 347, 664, 8, 277, 12, 790, 304, 267, 340, 790, 508, 298, 67, 26, 17, 26, 1421, 26, 65, 582, 288, 372, 6730, 6641, 354, 5122, 1421, 14, 2424, 2266, 1317, 63, 466, 5122, 505, 15, 6104, 3570, 6616, 267, 916, 790, 508, 298, 67, 26, 17, 26, 1421, 26, 65, 26, 16, 582, 288, 372, 12472, 14, 6447, 8, 66, 2, 6257, 13064, 9124, 421, 199, 533, 820, 66, 9581, 8, 785, 304, 272, 347, 664, 63, 9492, 63, 1258, 8, 277, 304, 267, 372, 14214, 1309, 421, 199, 9901, 275, 7777, 3041, 342, 199, 16567, 63, 26340, 275, 820, 66, 9581, 342, 421, 199, 533, 25496, 9581, 22662, 774, 8, 1746, 304, 272, 768, 1805, 14, 2068, 480, 3870, 14, 1208, 14, 15369, 14, 15369, 63, 9170, 14, 362, 401, 372, 63, 585, 29, 9901, 9, 272, 347, 511, 63, 1412, 63, 6455, 63, 368, 63, 2912, 8, 277, 12, 4350, 63, 362, 304, 267, 12193, 63, 1637, 275, 492, 63, 875, 480, 3870, 14, 15855, 14, 15369, 14, 29605, 9581, 22662, 4437, 531, 342, 267, 4350, 63, 362, 14, 479, 63, 1629, 63, 1250, 480, 1195, 13, 3612, 531, 267, 702, 1228, 8, 8905, 63, 1637, 14, 5216, 12, 25496, 9581, 4437, 9, 267, 702, 12193, 63, 1637, 14, 5216, 14, 1258, 365, 14214, 1309, 398, 4336, 275, 12193, 63, 1637, 14, 362, 480, 1421, 531, 267, 702, 822, 8, 6310, 9, 508, 413, 267, 12193, 275, 4336, 59, 16, 61, 267, 702, 12193, 14, 2024, 342, 508, 469, 288, 298, 466, 582, 298, 1430, 14, 8905, 401, 288, 298, 354, 582, 298, 1421, 14, 2424, 401, 288, 298, 1317, 63, 466, 582, 298, 505, 15, 6104, 401, 267, 789, 267, 702, 12193, 14, 576, 508, 330, 2, 6257, 13064, 9539, 421, 199, 533, 820, 66, 22662, 774, 8, 1746, 304, 272, 768, 1805, 14, 2068, 480, 3870, 14, 1637, 14, 15369, 14, 362, 63, 4201, 63, 504, 63, 1419, 401, 372, 63, 585, 2687, 16567, 63, 26340, 12, 17003, 272, 347, 511, 63, 1412, 63, 6455, 63, 368, 63, 2912, 8, 277, 12, 4350, 63, 362, 304, 267, 12193, 63, 1637, 275, 492, 63, 875, 480, 3870, 14, 15855, 14, 15369, 14, 50, 66, 22662, 4437, 25232, 5146, 14285, 267, 4350, 63, 362, 14, 479, 63, 1629, 63, 1250, 480, 51, 7285, 63, 8677, 63, 8808, 401, 2420, 5146, 582, 942, 1552, 267, 702, 1228, 8, 8905, 63, 1637, 14, 5216, 12, 820, 66, 4437, 9, 267, 702, 12193, 63, 1637, 14, 5216, 14, 1258, 365, 14214, 1309, 398, 4336, 275, 12193, 63, 1637, 14, 362, 480, 1421, 531, 267, 702, 822, 8, 6310, 9, 508, 413, 267, 12193, 275, 4336, 59, 16, 61, 267, 702, 12193, 14, 2024, 342, 508, 469, 288, 298, 466, 582, 298, 1430, 14, 8905, 401, 288, 298, 354, 582, 298, 1421, 14, 2424, 401, 288, 298, 1317, 63, 466, 582, 298, 505, 15, 6104, 401, 267, 789, 267, 702, 12193, 14, 576, 508, 330, 2, 6257, 13064, 9539, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 1683, 199, 646, 12472, 199, 199, 504, 26230, 14, 1637, 14, 15369, 492, 25496, 9581, 4437, 12, 820, 66, 4437, 199, 504, 26230, 14, 396, 1208, 492, 7640, 199, 504, 26230, 14, 1208, 14, 12775, 492, 492, 63, 875, 421, 199, 533, 7777, 3041, 8, 785, 304, 272, 347, 664, 8, 277, 12, 790, 304, 267, 340, 790, 508, 298, 67, 26, 17, 26, 1421, 26, 65, 582, 288, 372, 6730, 6641, 354, 5122, 1421, 14, 2424, 2266, 1317, 63, 466, 5122, 505, 15, 6104, 3570, 6616, 267, 916, 790, 508, 298, 67, 26, 17, 26, 1421, 26, 65, 26, 16, 582, 288, 372, 12472, 14, 6447, 8, 66, 2, 6257, 13064, 9124, 421, 199, 533, 820, 66, 9581, 8, 785, 304, 272, 347, 664, 63, 9492, 63, 1258, 8, 277, 304, 267, 372, 14214, 1309, 421, 199, 9901, 275, 7777, 3041, 342, 199, 16567, 63, 26340, 275, 820, 66, 9581, 342, 421, 199, 533, 25496, 9581, 22662, 774, 8, 1746, 304, 272, 768, 1805, 14, 2068, 480, 3870, 14, 1208, 14, 15369, 14, 15369, 63, 9170, 14, 362, 401, 372, 63, 585, 29, 9901, 9, 272, 347, 511, 63, 1412, 63, 6455, 63, 368, 63, 2912, 8, 277, 12, 4350, 63, 362, 304, 267, 12193, 63, 1637, 275, 492, 63, 875, 480, 3870, 14, 15855, 14, 15369, 14, 29605, 9581, 22662, 4437, 531, 342, 267, 4350, 63, 362, 14, 479, 63, 1629, 63, 1250, 480, 1195, 13, 3612, 531, 267, 702, 1228, 8, 8905, 63, 1637, 14, 5216, 12, 25496, 9581, 4437, 9, 267, 702, 12193, 63, 1637, 14, 5216, 14, 1258, 365, 14214, 1309, 398, 4336, 275, 12193, 63, 1637, 14, 362, 480, 1421, 531, 267, 702, 822, 8, 6310, 9, 508, 413, 267, 12193, 275, 4336, 59, 16, 61, 267, 702, 12193, 14, 2024, 342, 508, 469, 288, 298, 466, 582, 298, 1430, 14, 8905, 401, 288, 298, 354, 582, 298, 1421, 14, 2424, 401, 288, 298, 1317, 63, 466, 582, 298, 505, 15, 6104, 401, 267, 789, 267, 702, 12193, 14, 576, 508, 330, 2, 6257, 13064, 9539, 421, 199, 533, 820, 66, 22662, 774, 8, 1746, 304, 272, 768, 1805, 14, 2068, 480, 3870, 14, 1637, 14, 15369, 14, 362, 63, 4201, 63, 504, 63, 1419, 401, 372, 63, 585, 2687, 16567, 63, 26340, 12, 17003, 272, 347, 511, 63, 1412, 63, 6455, 63, 368, 63, 2912, 8, 277, 12, 4350, 63, 362, 304, 267, 12193, 63, 1637, 275, 492, 63, 875, 480, 3870, 14, 15855, 14, 15369, 14, 50, 66, 22662, 4437, 25232, 5146, 14285, 267, 4350, 63, 362, 14, 479, 63, 1629, 63, 1250, 480, 51, 7285, 63, 8677, 63, 8808, 401, 2420, 5146, 582, 942, 1552, 267, 702, 1228, 8, 8905, 63, 1637, 14, 5216, 12, 820, 66, 4437, 9, 267, 702, 12193, 63, 1637, 14, 5216, 14, 1258, 365, 14214, 1309, 398, 4336, 275, 12193, 63, 1637, 14, 362, 480, 1421, 531, 267, 702, 822, 8, 6310, 9, 508, 413, 267, 12193, 275, 4336, 59, 16, 61, 267, 702, 12193, 14, 2024, 342, 508, 469, 288, 298, 466, 582, 298, 1430, 14, 8905, 401, 288, 298, 354, 582, 298, 1421, 14, 2424, 401, 288, 298, 1317, 63, 466, 582, 298, 505, 15, 6104, 401, 267, 789, 267, 702, 12193, 14, 576, 508, 330, 2, 6257, 13064, 9539, 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, 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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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 ]
kcompher/thunder
thunder/extraction/source.py
6
31847
from numpy import asarray, mean, sqrt, ndarray, amin, amax, concatenate, sum, zeros, maximum, \ argmin, newaxis, ones, delete, NaN, inf, isnan, clip, logical_or, unique, where, all from thunder.utils.serializable import Serializable from thunder.utils.common import checkParams, aslist from thunder.rdds.images import Images from thunder.rdds.series import Series class Source(Serializable, object): """ A single source, represented as a list of coordinates and other optional specifications. A source also has a set of lazily computed attributes useful for representing and comparing its geometry, such as center, bounding box, and bounding polygon. These properties will be computed lazily and made available as attributes when requested. Parameters ---------- coordinates : array-like List of 2D or 3D coordinates, can be a list of lists or array of shape (n,2) or (n,3) values : list or array-like Value (or weight) associated with each coordiante id : int or string Arbitrary specification per source, typically an index or string label Attributes ---------- center : list or array-like The coordinates of the center of the source polygon : list or array-like The coordinates of a polygon bounding the region (a convex hull) bbox : list or array-like Boundaries of the source (with the lowest values for all axes followed by the highest values) area : scalar The area of the region """ from zope.cachedescriptors import property def __init__(self, coordinates, values=None, id=None): self.coordinates = asarray(coordinates) if self.coordinates.ndim == 1 and len(self.coordinates) > 0: self.coordinates = asarray([self.coordinates]) if values is not None: self.values = asarray(values) if self.values.ndim == 0: self.values = asarray([self.values]) if not (len(self.coordinates) == len(self.values)): raise ValueError("Lengths of coordinates %g and values %g do not match" % (len(self.coordinates), len(self.values))) if id is not None: self.id = id @property.Lazy def center(self): """ Find the region center using a mean. """ # TODO Add option to use weights return mean(self.coordinates, axis=0) @property.Lazy def polygon(self): """ Find the bounding polygon as a convex hull """ # TODO Add option for simplification from scipy.spatial import ConvexHull if len(self.coordinates) >= 4: inds = ConvexHull(self.coordinates).vertices return self.coordinates[inds] else: return self.coordinates @property.Lazy def bbox(self): """ Find the bounding box. """ mn = amin(self.coordinates, axis=0) mx = amax(self.coordinates, axis=0) return concatenate((mn, mx)) @property.Lazy def area(self): """ Find the region area. """ return len(self.coordinates) def restore(self, skip=None): """ Remove all lazy properties, will force recomputation """ if skip is None: skip = [] elif isinstance(skip, str): skip = [skip] for prop in LAZY_ATTRIBUTES: if prop in self.__dict__.keys() and prop not in skip: del self.__dict__[prop] return self def distance(self, other, method='euclidean'): """ Distance between the center of this source and another. Parameters ---------- other : Source, or array-like Either another source, or the center coordinates of another source method : str Specify a distance measure to used for spatial distance between source centers. Current options include Euclidean distance ('euclidean') and L1-norm ('l1'). """ from numpy.linalg import norm checkParams(method, ['euclidean', 'l1']) if method == 'l1': order = 1 else: order = 2 if isinstance(other, Source): return norm(self.center - other.center, ord=order) elif isinstance(other, list) or isinstance(other, ndarray): return norm(self.center - asarray(other), ord=order) def overlap(self, other, method='fraction'): """ Compute the overlap between this source and other. Options are a symmetric measure of overlap based on the fraction of intersecting pixels relative to the union ('fraction'), an assymmetric measure of overlap that expresses detected intersecting pixels (relative to this source) using precision and recall rates ('rates'), or a correlation coefficient of the weights within the intersection (not defined for binary weights) ('correlation') Parameters ---------- other : Source The source to compute overlap with. method : str Which estimate of overlap to compute, options are 'fraction' (symmetric) 'rates' (asymmetric) or 'correlation' """ checkParams(method, ['fraction', 'rates', 'correlation']) coordsSelf = aslist(self.coordinates) coordsOther = aslist(other.coordinates) intersection = [a for a in coordsSelf if a in coordsOther] nhit = float(len(intersection)) ntotal = float(len(set([tuple(x) for x in coordsSelf] + [tuple(x) for x in coordsOther]))) if method == 'rates': recall = nhit / len(coordsSelf) precision = nhit / len(coordsOther) return recall, precision if method == 'fraction': return nhit / float(ntotal) if method == 'correlation': from scipy.stats import spearmanr if not (hasattr(self, 'values') and hasattr(other, 'values')): raise ValueError('Sources must have values to compute correlation') else: valuesSelf = aslist(self.values) valuesOther = aslist(other.values) if len(intersection) > 0: left = [v for v, c in zip(valuesSelf, coordsSelf) if c in coordsOther] right = [v for v, c in zip(valuesOther, coordsOther) if c in coordsSelf] rho, _ = spearmanr(left, right) else: rho = 0.0 return rho def merge(self, other): """ Combine this source with other """ self.coordinates = concatenate((self.coordinates, other.coordinates)) if hasattr(self, 'values'): self.values = concatenate((self.values, other.values)) return self def tolist(self): """ Convert array-like attributes to list """ import copy new = copy.copy(self) for prop in ["coordinates", "values", "center", "bbox", "polygon"]: if prop in self.__dict__.keys(): val = new.__getattribute__(prop) if val is not None and not isinstance(val, list): setattr(new, prop, val.tolist()) return new def toarray(self): """ Convert array-like attributes to ndarray """ import copy new = copy.copy(self) for prop in ["coordinates", "values", "center", "bbox", "polygon"]: if prop in self.__dict__.keys(): val = new.__getattribute__(prop) if val is not None and not isinstance(val, ndarray): setattr(new, prop, asarray(val)) return new def crop(self, minBound, maxBound): """ Crop a source by removing coordinates outside bounds. Follows normal slice indexing conventions. Parameters ---------- minBound : tuple Minimum or starting bounds for each axis maxBound : tuple Maximum or ending bounds for each axis """ coords = self.coordinates newid = self.id if hasattr(self, 'id') else None if hasattr(self, 'values') and self.values is not None: values = self.values inside = [(c, v) for c, v in zip(coords, values) if c not in coords] newcoords, newvalues = zip(*inside) return Source(coordinates=newcoords, values=newvalues, id=newid) else: newcoords = [c for c in coords if all(c >= minBound) and all(c < maxBound)] return Source(coordinates=newcoords, id=newid) def dilate(self, size): """ Dilate a source using morphological operators. Parameters ---------- size : int Size of dilation in pixels """ if size == 0: newcoords = self.coordinates else: size = (size * 2) + 1 if hasattr(self, 'values') and self.values is not None: raise AttributeError('Cannot dilate sources with values') from skimage.morphology import binary_dilation coords = self.coordinates extent = self.bbox[len(self.center):] - self.bbox[0:len(self.center)] + 1 + size * 2 m = zeros(extent) coords = (coords - self.bbox[0:len(self.center)] + size) m[coords.T.tolist()] = 1 m = binary_dilation(m, ones((size, size))) newcoords = asarray(where(m)).T + self.bbox[0:len(self.center)] - size newcoords = [c for c in newcoords if all(c >= 0)] newid = self.id if hasattr(self, 'id') else None return Source(coordinates=newcoords, id=newid) def exclude(self, other): """ Remove coordinates derived from another Source or an array. If other is an array, will remove coordinates of all non-zero elements from this source. If other is a source, will remove any matching coordinates. Parameters ---------- other : ndarray or Source Source to remove """ if isinstance(other, ndarray): coordsOther = asarray(where(other)).T else: coordsOther = aslist(other.coordinates) coordsSelf = aslist(self.coordinates) newid = self.id if hasattr(self, 'id') else None if hasattr(self, 'values') and self.values is not None: valuesSelf = self.values complement = [(c, v) for c, v in zip(coordsSelf, valuesSelf) if c not in coordsOther] newcoords, newvalues = zip(*complement) return Source(coordinates=newcoords, values=newvalues, id=newid) else: complement = [a for a in coordsSelf if a not in coordsOther] return Source(coordinates=complement, id=newid) def outline(self, inner, outer): """ Compute source outline by differencing two dilations Parameters ---------- inner : int Size of inner outline boundary (in pixels) outer : int Size of outer outline boundary (in pixels) """ return self.dilate(outer).exclude(self.dilate(inner)) def transform(self, data, collect=True): """ Extract series from data using a list of sources. Currently only supports averaging over coordinates. Params ------ data : Images or Series object The data from which to extract collect : boolean, optional, default = True Whether to collect to local array or keep as a Series """ if not (isinstance(data, Images) or isinstance(data, Series)): raise Exception("Input must either be Images or Series (or a subclass)") # TODO add support for weighting if isinstance(data, Images): output = data.meanByRegions([self.coordinates]).toSeries() else: output = data.meanOfRegion(self.coordinates) if collect: return output.collectValuesAsArray() else: return output def mask(self, dims=None, binary=True, outline=False, color=None): """ Construct a mask from a source, either locally or within a larger image. Parameters ---------- dims : list or tuple, optional, default = None Dimensions of large image in which to draw mask. If none, will restrict to the bounding box of the region. binary : boolean, optional, deafult = True Whether to incoporate values or only show a binary mask outline : boolean, optional, deafult = False Whether to only show outlines (derived using binary dilation) color : str or array-like RGB triplet (from 0 to 1) or named color (e.g. 'red', 'blue') """ from thunder import Colorize coords = self.coordinates if dims is None: extent = self.bbox[len(self.center):] - self.bbox[0:len(self.center)] + 1 m = zeros(extent) coords = (coords - self.bbox[0:len(self.center)]) else: m = zeros(dims) if hasattr(self, 'values') and self.values is not None and binary is False: m[coords.T.tolist()] = self.values else: m[coords.T.tolist()] = 1 if outline: from skimage.morphology import binary_dilation m = binary_dilation(m, ones((3, 3))) - m if color is not None: m = Colorize(cmap='indexed', colors=[color]).transform([m]) return m def inbounds(self, minBound, maxBound): """ Check what fraction of coordinates are inside given bounds Parameters ---------- minBound : list or tuple Minimum bounds maxBounds : list or tuple Maximum bounds """ minCheck = sum(self.coordinates < minBound, axis=1) > 0 maxCheck = sum(self.coordinates > maxBound, axis=1) > 0 fraction = 1 - sum(logical_or(minCheck, maxCheck)) / float(len(self.coordinates)) return fraction @staticmethod def fromMask(mask, id=None): """ Genearte a source from a mask. Assumes that the mask is an image where all non-zero elements are part of the source. If all non-zero elements are 1, then values will be ignored as the source is assumed to be binary. Parameters ---------- mask : array-like An array (typically 2D or 3D) containing the image mask id : int or string Arbitrary identifier for the source, typically an int or string """ mask = asarray(mask) u = unique(mask) if len(u) == 2 and u[0] == 0 and u[1] == 1: inds = where(mask) return Source(coordinates=asarray(zip(*inds)), id=id) else: inds = where(mask) values = mask[inds] coords = asarray(zip(*inds)) return Source(coordinates=coords, values=values, id=id) @staticmethod def fromCoordinates(coordinates, values=None, id=None): """ Generate a source from a list of coordinates and values. Parameters ---------- coordinates : array-like List coordinates as a list of lists or array of shape (n,2) or (n,3) values : list or array-like Value (or weight) associated with each coordiante id : int or string Arbitrary specification per source, typically an index or string label """ return Source(coordinates, values, id) def __repr__(self): s = self.__class__.__name__ for opt in ["id", "center", "bbox"]: if hasattr(self, opt): o = self.__getattribute__(opt) os = o.tolist() if isinstance(o, ndarray) else o s += '\n%s: %s' % (opt, repr(os)) return s class SourceModel(Serializable, object): """ A source model as a collection of extracted sources. Parameters ---------- sources : list or Sources or a single Source The identified sources See also -------- Source """ def __init__(self, sources): if isinstance(sources, Source): self.sources = [sources] elif isinstance(sources, list) and isinstance(sources[0], Source): self.sources = sources elif isinstance(sources, list): self.sources = [] for ss in sources: self.sources.append(Source(ss)) else: raise Exception("Input type not recognized, must be Source, list of Sources, " "or list of coordinates, got %s" % type(sources)) def __getitem__(self, entry): if not isinstance(entry, int): raise IndexError("Selection not recognized, must be Int, got %s" % type(entry)) return self.sources[entry] def combiner(self, prop, tolist=True): combined = [] for s in self.sources: p = getattr(s, prop) if tolist: p = p.tolist() combined.append(p) return combined @property def coordinates(self): """ List of coordinates combined across sources """ return self.combiner('coordinates') @property def values(self): """ List of coordinates combined across sources """ return self.combiner('values') @property def centers(self): """ Array of centers combined across sources """ return asarray(self.combiner('center')) @property def polygons(self): """ List of polygons combined across sources """ return self.combiner('polygon') @property def areas(self): """ List of areas combined across sources """ return self.combiner('area', tolist=False) @property def count(self): """ Number of sources """ return len(self.sources) def masks(self, dims=None, binary=True, outline=False, base=None, color=None, inds=None): """ Composite masks combined across sources as an image. Parameters ---------- dims : list or tuple, optional, default = None Dimensions of image in which to create masks, must either provide these or provide a base image binary : boolean, optional, deafult = True Whether to incoporate values or only show a binary mask outline : boolean, optional, deafult = False Whether to only show outlines (derived using binary dilation) base : SourceModel or array-like, optional, deafult = None Base background image on which to put masks, or another set of sources (usually for comparisons). color : str, optional, deafult = None Color to assign regions, will assign randomly if 'random' inds : array-like, optional, deafult = None List of indices if only showing a subset """ from thunder import Colorize from matplotlib.cm import get_cmap if inds is None: inds = range(0, self.count) if dims is None and base is None: raise Exception("Must provide image dimensions for composite masks " "or provide a base image.") if base is not None and isinstance(base, SourceModel): outline = True if dims is None and base is not None: dims = asarray(base).shape if isinstance(base, SourceModel): base = base.masks(dims, color='silver') elif isinstance(base, ndarray): base = Colorize(cmap='indexed', colors=['white']).transform([base]) if base is not None and color is None: color = 'deeppink' if color == 'random': combined = zeros(list(dims) + [3]) ncolors = min(self.count, 20) colors = get_cmap('rainbow', ncolors)(range(0, ncolors, 1))[:, 0:3] for i in inds: combined = maximum(self.sources[i].mask(dims, binary, outline, colors[i % len(colors)]), combined) else: combined = zeros(dims) for i in inds: combined = maximum(self.sources[i].mask(dims, binary, outline), combined) if color is not None and color != 'random': combined = Colorize(cmap='indexed', colors=[color]).transform([combined]) if base is not None: combined = maximum(base, combined) return combined def match(self, other, unique=False, minDistance=inf): """ For each source in self, find the index of the closest source in other. Uses euclidean distances between centers to determine distances. Can select nearest matches with or without enforcing uniqueness; if unique is False, will return the closest source in other for each source in self, possibly repeating sources multiple times if unique is True, will only allow each source in other to be matched with a single source in self, as determined by a greedy selection procedure. The minDistance parameter can be used to prevent far-away sources from being chosen during greedy selection. Params ------ other : SourceModel The source model to match sources to unique : boolean, optional, deafult = True Whether to only return unique matches minDistance : scalar, optiona, default = inf Minimum distance to use when selecting matches """ from scipy.spatial.distance import cdist targets = other.centers targetInds = range(0, len(targets)) matches = [] for s in self.sources: update = 1 # skip if no targets left, otherwise update if len(targets) == 0: update = 0 else: dists = cdist(targets, s.center[newaxis]) if dists.min() < minDistance: ind = argmin(dists) else: update = 0 # apply updates, otherwise add a nan if update == 1: matches.append(targetInds[ind]) if unique is True: targets = delete(targets, ind, axis=0) targetInds = delete(targetInds, ind) else: matches.append(NaN) return matches def distance(self, other, minDistance=inf): """ Compute the distance between each source in self and other. First estimates a matching source from other for each source in self, then computes the distance between the two sources. The matches are unique, using a greedy procedure, and minDistance can be used to prevent outliers during matching. Parameters ---------- other : SourceModel The sources to compute distances to minDistance : scalar, optiona, default = inf Minimum distance to use when matching indices """ inds = self.match(other, unique=True, minDistance=minDistance) d = [] for jj, ii in enumerate(inds): if ii is not NaN: d.append(self[jj].distance(other[ii])) else: d.append(NaN) return asarray(d) def overlap(self, other, method='fraction', minDistance=inf): """ Estimate overlap between sources in self and other. Will compute the similarity of sources in self that are found in other, based on either source pixel overlap or correlation. Parameters ---------- other : SourceModel The sources to compare to method : str, optional, default = 'fraction" Method to use when computing overlap between sources ('fraction', 'rates', or 'correlation') minDistance : scalar, optional, default = inf Minimum distance to use when matching indices """ inds = self.match(other, unique=True, minDistance=minDistance) d = [] for jj, ii in enumerate(inds): if ii is not NaN: d.append(self[jj].overlap(other[ii], method=method)) else: if method == 'rates': d.append((NaN, NaN)) else: d.append(NaN) return asarray(d) def similarity(self, other, metric='distance', thresh=5, minDistance=inf): """ Estimate similarity to another set of sources using recall and precision. Will compute the number of sources in self that are also in other, based on a given distance metric and a threshold. The recall rate is the number of matches divided by the number in self, and the precision rate is the number of matches divided by the number in other. Typically self is ground truth and other is an estimate. The F score is defined as 2 * (recall * precision) / (recall + precision) Before computing metrics, all sources in self are matched to other, and a minimum distance can be set to control matching. Parameters ---------- other : SourceModel The sources to compare to. metric : str, optional, default = 'distance' Metric to use when computing distances, options include 'distance' and 'overlap' thresh : scalar, optional, default = 5 The distance below which a source is considered found. minDistance : scalar, optional, default = inf Minimum distance to use when matching indices. """ checkParams(metric, ['distance', 'overlap']) if metric == 'distance': # when evaluating distances, # minimum distance should be the threshold if minDistance == inf: minDistance = thresh vals = self.distance(other, minDistance=minDistance) vals[isnan(vals)] = inf compare = lambda x: x < thresh elif metric == 'overlap': vals = self.overlap(other, method='fraction', minDistance=minDistance) vals[isnan(vals)] = 0 compare = lambda x: x > thresh else: raise Exception("Metric not recognized") recall = sum(map(compare, vals)) / float(self.count) precision = sum(map(compare, vals)) / float(other.count) score = 2 * (recall * precision) / (recall + precision) return recall, precision, score def transform(self, data, collect=True): """ Extract series from data using a list of sources. Currently only supports simple averaging over coordinates. Params ------ data : Images or Series object The data from which to extract signals collect : boolean, optional, default = True Whether to collect to local array or keep as a Series """ if not (isinstance(data, Images) or isinstance(data, Series)): raise Exception("Input must either be Images or Series (or a subclass)") # TODO add support for weighting if isinstance(data, Images): output = data.meanByRegions(self.coordinates).toSeries() else: output = data.meanByRegions(self.coordinates) if collect: return output.collectValuesAsArray() else: return output def clean(self, cleaners=None): """ Apply one or more cleaners to sources, returning filtered sources Parameters ---------- cleaners : Cleaner or list of Cleaners, optional, default = None Which cleaners to apply, if None, will apply BasicCleaner with defaults """ from thunder.extraction.cleaners import Cleaner, BasicCleaner from copy import copy if isinstance(cleaners, list): for c in cleaners: if not isinstance(c, Cleaner): raise Exception("List must only contain Cleaners") elif isinstance(cleaners, Cleaner): cleaners = [cleaners] elif cleaners is None: cleaners = [BasicCleaner()] else: raise Exception("Must provide Cleaner or list of Cleaners, got %s" % type(cleaners)) newmodel = copy(self) for c in cleaners: newmodel = c.clean(newmodel) return newmodel def dilate(self, size): """ Dilate all sources using morphological operators Parameters ---------- size : int Size of dilation in pixels """ return SourceModel([s.dilate(size) for s in self.sources]) def outline(self, inner, outer): """ Outline all sources inner : int Size of inner outline boundary (in pixels) outer : int Size of outer outline boundary (in pixels) """ return SourceModel([s.outline(inner, outer) for s in self.sources]) def crop(self, minBound, maxBound): """ Crop all sources by removing coordinates outside of bounds Parameters ---------- minBound : tuple Minimum or starting bounds for each axis maxBound : tuple Maximum or ending bounds for each axis """ return SourceModel([s.crop(minBound, maxBound) for s in self.sources]) def save(self, f, include=None, overwrite=False, **kwargs): """ Custom save to file with simplified, human-readable output, and selection of lazy attributes. """ import copy output = copy.deepcopy(self) if isinstance(include, str): include = [include] if include is not None: for prop in include: map(lambda s: getattr(s, prop), output.sources) output.sources = map(lambda s: s.restore(include).tolist(), output.sources) simplify = lambda d: d['sources']['py/homogeneousList']['data'] super(SourceModel, output).save(f, simplify=simplify, overwrite=overwrite, **kwargs) @classmethod def load(cls, f, **kwargs): """ Custom load from file to handle simplified, human-readable output """ unsimplify = lambda d: {'sources': { 'py/homogeneousList': {'data': d, 'module': 'thunder.extraction.source', 'type': 'Source'}}} output = super(SourceModel, cls).load(f, unsimplify=unsimplify) output.sources = map(lambda s: s.toarray(), output.sources) return output @classmethod def deserialize(cls, d, **kwargs): """ Custom load from JSON to handle simplified, human-readable output """ unsimplify = lambda d: {'sources': { 'py/homogeneousList': {'data': d, 'module': 'thunder.extraction.source', 'type': 'Source'}}} output = super(SourceModel, cls).deserialize(d, unsimplify=unsimplify) output.sources = map(lambda s: s.toarray(), output.sources) return output def __repr__(self): s = self.__class__.__name__ s += '\n%g sources' % (len(self.sources)) return s LAZY_ATTRIBUTES = ["center", "polygon", "bbox", "area"]
apache-2.0
[ 504, 2680, 492, 24144, 12, 4615, 12, 7452, 12, 6800, 12, 282, 827, 12, 282, 988, 12, 24788, 12, 3089, 12, 10136, 12, 5696, 12, 971, 272, 1680, 827, 12, 892, 3127, 12, 7869, 12, 3145, 12, 16046, 12, 10739, 12, 365, 4304, 12, 11353, 12, 11461, 63, 269, 12, 3747, 12, 2382, 12, 1006, 199, 199, 504, 294, 7138, 14, 1208, 14, 2171, 14065, 492, 11973, 14065, 199, 504, 294, 7138, 14, 1208, 14, 2330, 492, 1104, 6007, 12, 465, 513, 199, 504, 294, 7138, 14, 20533, 83, 14, 4782, 492, 32658, 199, 504, 294, 7138, 14, 20533, 83, 14, 5602, 492, 12403, 421, 199, 533, 5800, 8, 3571, 14065, 12, 909, 304, 272, 408, 272, 437, 2849, 1350, 12, 11159, 465, 282, 769, 402, 8983, 436, 1163, 2716, 28754, 14, 339, 437, 1350, 2597, 965, 282, 663, 402, 29667, 3444, 9235, 3004, 2997, 367, 6144, 436, 20234, 272, 2399, 3400, 12, 4066, 465, 8126, 12, 16842, 5689, 12, 436, 16842, 17248, 14, 5723, 4382, 272, 911, 506, 9235, 29667, 3444, 436, 6326, 2808, 465, 3004, 1380, 5839, 14, 339, 3897, 272, 4143, 272, 8983, 520, 1625, 13, 2930, 267, 3820, 402, 499, 36, 503, 650, 36, 8983, 12, 883, 506, 282, 769, 402, 5548, 503, 1625, 402, 2215, 334, 78, 12, 18, 9, 503, 334, 78, 12, 19, 9, 339, 1338, 520, 769, 503, 1625, 13, 2930, 267, 1594, 334, 269, 5401, 9, 4568, 543, 1924, 512, 269, 6268, 266, 339, 1305, 520, 1109, 503, 1059, 267, 1952, 8734, 8929, 1126, 1350, 12, 13609, 376, 1478, 503, 1059, 1768, 339, 9382, 272, 4143, 272, 8126, 520, 769, 503, 1625, 13, 2930, 267, 710, 8983, 402, 314, 8126, 402, 314, 1350, 339, 17248, 520, 769, 503, 1625, 13, 2930, 267, 710, 8983, 402, 282, 17248, 16842, 314, 4897, 334, 65, 406, 26221, 394, 979, 9, 339, 12494, 520, 769, 503, 1625, 13, 2930, 267, 21972, 3433, 402, 314, 1350, 334, 1045, 314, 18966, 1338, 367, 1006, 7824, 9437, 701, 314, 15356, 1338, 9, 339, 9150, 520, 6917, 267, 710, 9150, 402, 314, 4897, 272, 408, 272, 687, 20110, 14, 1637, 17752, 492, 3324, 339, 347, 636, 826, 721, 277, 12, 8983, 12, 1338, 29, 403, 12, 1305, 29, 403, 304, 267, 291, 14, 12924, 275, 24144, 8, 12924, 9, 398, 340, 291, 14, 12924, 14, 8322, 508, 413, 436, 822, 8, 277, 14, 12924, 9, 690, 378, 26, 288, 291, 14, 12924, 275, 24144, 779, 277, 14, 12924, 566, 398, 340, 1338, 365, 440, 488, 26, 288, 291, 14, 1459, 275, 24144, 8, 1459, 9, 288, 340, 291, 14, 1459, 14, 8322, 508, 378, 26, 355, 291, 14, 1459, 275, 24144, 779, 277, 14, 1459, 566, 288, 340, 440, 334, 552, 8, 277, 14, 12924, 9, 508, 822, 8, 277, 14, 1459, 2298, 355, 746, 1722, 480, 4625, 83, 402, 8983, 450, 71, 436, 1338, 450, 71, 886, 440, 1336, 2, 639, 450, 334, 552, 8, 277, 14, 12924, 395, 822, 8, 277, 14, 1459, 1724, 398, 340, 1305, 365, 440, 488, 26, 288, 291, 14, 344, 275, 1305, 339, 768, 1829, 14, 14269, 272, 347, 8126, 8, 277, 304, 267, 408, 267, 6668, 314, 4897, 8126, 1808, 282, 4615, 14, 267, 408, 267, 327, 3254, 2654, 945, 370, 675, 4931, 267, 372, 4615, 8, 277, 14, 12924, 12, 3114, 29, 16, 9, 339, 768, 1829, 14, 14269, 272, 347, 17248, 8, 277, 304, 267, 408, 267, 6668, 314, 16842, 17248, 465, 282, 406, 26221, 394, 979, 267, 408, 267, 327, 3254, 2654, 945, 367, 17553, 3477, 267, 687, 7026, 14, 11679, 492, 1448, 26221, 40, 979, 267, 340, 822, 8, 277, 14, 12924, 9, 2356, 841, 26, 288, 315, 795, 275, 1448, 26221, 40, 979, 8, 277, 14, 12924, 680, 12637, 288, 372, 291, 14, 12924, 59, 18212, 61, 267, 587, 26, 288, 372, 291, 14, 12924, 339, 768, 1829, 14, 14269, 272, 347, 12494, 8, 277, 304, 267, 408, 267, 6668, 314, 16842, 5689, 14, 267, 408, 267, 21945, 275, 282, 827, 8, 277, 14, 12924, 12, 3114, 29, 16, 9, 267, 8728, 275, 282, 988, 8, 277, 14, 12924, 12, 3114, 29, 16, 9, 267, 372, 24788, 1332, 10344, 12, 8728, 430, 339, 768, 1829, 14, 14269, 272, 347, 9150, 8, 277, 304, 267, 408, 267, 6668, 314, 4897, 9150, 14, 267, 408, 267, 372, 822, 8, 277, 14, 12924, 9, 339, 347, 9066, 8, 277, 12, 3372, 29, 403, 304, 267, 408, 267, 5852, 1006, 9617, 4382, 12, 911, 3542, 295, 31598, 267, 408, 267, 340, 3372, 365, 488, 26, 288, 3372, 275, 942, 267, 916, 1228, 8, 2759, 12, 620, 304, 288, 3372, 275, 359, 2759, 61, 267, 367, 5931, 315, 491, 17613, 57, 63, 18166, 26, 288, 340, 5931, 315, 291, 855, 807, 4343, 1612, 342, 436, 5931, 440, 315, 3372, 26, 355, 2150, 291, 855, 807, 12298, 4469, 61, 267, 372, 291, 339, 347, 6033, 8, 277, 12, 1163, 12, 1083, 534, 26479, 735, 267, 408, 267, 21892, 3382, 314, 8126, 402, 642, 1350, 436, 4573, 14, 398, 3897, 267, 4143, 267, 1163, 520, 5800, 12, 503, 1625, 13, 2930, 288, 13083, 4573, 1350, 12, 503, 314, 8126, 8983, 402, 4573, 1350, 398, 1083, 520, 620, 288, 13327, 282, 6033, 9775, 370, 1202, 367, 11469, 6033, 3382, 1350, 288, 19190, 14, 9338, 1511, 2387, 662, 24941, 6033, 661, 26479, 358, 436, 7205, 491, 17, 13, 4791, 661, 76, 17, 1959, 24807, 408, 267, 687, 2680, 14, 10096, 492, 6316, 398, 1104, 6007, 8, 765, 12, 788, 26479, 297, 283, 76, 17, 1105, 398, 340, 1083, 508, 283, 76, 17, 356, 288, 1865, 275, 413, 267, 587, 26, 288, 1865, 275, 499, 398, 340, 1228, 8, 1848, 12, 5800, 304, 288, 372, 6316, 8, 277, 14, 4218, 446, 1163, 14, 4218, 12, 6206, 29, 1648, 9, 267, 916, 1228, 8, 1848, 12, 769, 9, 503, 1228, 8, 1848, 12, 6800, 304, 288, 372, 6316, 8, 277, 14, 4218, 446, 24144, 8, 1848, 395, 6206, 29, 1648, 9, 339, 347, 15145, 8, 277, 12, 1163, 12, 1083, 534, 13054, 735, 267, 408, 267, 8354, 314, 15145, 3382, 642, 1350, 436, 1163, 14, 398, 8394, 787, 282, 16371, 9775 ]
[ 2680, 492, 24144, 12, 4615, 12, 7452, 12, 6800, 12, 282, 827, 12, 282, 988, 12, 24788, 12, 3089, 12, 10136, 12, 5696, 12, 971, 272, 1680, 827, 12, 892, 3127, 12, 7869, 12, 3145, 12, 16046, 12, 10739, 12, 365, 4304, 12, 11353, 12, 11461, 63, 269, 12, 3747, 12, 2382, 12, 1006, 199, 199, 504, 294, 7138, 14, 1208, 14, 2171, 14065, 492, 11973, 14065, 199, 504, 294, 7138, 14, 1208, 14, 2330, 492, 1104, 6007, 12, 465, 513, 199, 504, 294, 7138, 14, 20533, 83, 14, 4782, 492, 32658, 199, 504, 294, 7138, 14, 20533, 83, 14, 5602, 492, 12403, 421, 199, 533, 5800, 8, 3571, 14065, 12, 909, 304, 272, 408, 272, 437, 2849, 1350, 12, 11159, 465, 282, 769, 402, 8983, 436, 1163, 2716, 28754, 14, 339, 437, 1350, 2597, 965, 282, 663, 402, 29667, 3444, 9235, 3004, 2997, 367, 6144, 436, 20234, 272, 2399, 3400, 12, 4066, 465, 8126, 12, 16842, 5689, 12, 436, 16842, 17248, 14, 5723, 4382, 272, 911, 506, 9235, 29667, 3444, 436, 6326, 2808, 465, 3004, 1380, 5839, 14, 339, 3897, 272, 4143, 272, 8983, 520, 1625, 13, 2930, 267, 3820, 402, 499, 36, 503, 650, 36, 8983, 12, 883, 506, 282, 769, 402, 5548, 503, 1625, 402, 2215, 334, 78, 12, 18, 9, 503, 334, 78, 12, 19, 9, 339, 1338, 520, 769, 503, 1625, 13, 2930, 267, 1594, 334, 269, 5401, 9, 4568, 543, 1924, 512, 269, 6268, 266, 339, 1305, 520, 1109, 503, 1059, 267, 1952, 8734, 8929, 1126, 1350, 12, 13609, 376, 1478, 503, 1059, 1768, 339, 9382, 272, 4143, 272, 8126, 520, 769, 503, 1625, 13, 2930, 267, 710, 8983, 402, 314, 8126, 402, 314, 1350, 339, 17248, 520, 769, 503, 1625, 13, 2930, 267, 710, 8983, 402, 282, 17248, 16842, 314, 4897, 334, 65, 406, 26221, 394, 979, 9, 339, 12494, 520, 769, 503, 1625, 13, 2930, 267, 21972, 3433, 402, 314, 1350, 334, 1045, 314, 18966, 1338, 367, 1006, 7824, 9437, 701, 314, 15356, 1338, 9, 339, 9150, 520, 6917, 267, 710, 9150, 402, 314, 4897, 272, 408, 272, 687, 20110, 14, 1637, 17752, 492, 3324, 339, 347, 636, 826, 721, 277, 12, 8983, 12, 1338, 29, 403, 12, 1305, 29, 403, 304, 267, 291, 14, 12924, 275, 24144, 8, 12924, 9, 398, 340, 291, 14, 12924, 14, 8322, 508, 413, 436, 822, 8, 277, 14, 12924, 9, 690, 378, 26, 288, 291, 14, 12924, 275, 24144, 779, 277, 14, 12924, 566, 398, 340, 1338, 365, 440, 488, 26, 288, 291, 14, 1459, 275, 24144, 8, 1459, 9, 288, 340, 291, 14, 1459, 14, 8322, 508, 378, 26, 355, 291, 14, 1459, 275, 24144, 779, 277, 14, 1459, 566, 288, 340, 440, 334, 552, 8, 277, 14, 12924, 9, 508, 822, 8, 277, 14, 1459, 2298, 355, 746, 1722, 480, 4625, 83, 402, 8983, 450, 71, 436, 1338, 450, 71, 886, 440, 1336, 2, 639, 450, 334, 552, 8, 277, 14, 12924, 395, 822, 8, 277, 14, 1459, 1724, 398, 340, 1305, 365, 440, 488, 26, 288, 291, 14, 344, 275, 1305, 339, 768, 1829, 14, 14269, 272, 347, 8126, 8, 277, 304, 267, 408, 267, 6668, 314, 4897, 8126, 1808, 282, 4615, 14, 267, 408, 267, 327, 3254, 2654, 945, 370, 675, 4931, 267, 372, 4615, 8, 277, 14, 12924, 12, 3114, 29, 16, 9, 339, 768, 1829, 14, 14269, 272, 347, 17248, 8, 277, 304, 267, 408, 267, 6668, 314, 16842, 17248, 465, 282, 406, 26221, 394, 979, 267, 408, 267, 327, 3254, 2654, 945, 367, 17553, 3477, 267, 687, 7026, 14, 11679, 492, 1448, 26221, 40, 979, 267, 340, 822, 8, 277, 14, 12924, 9, 2356, 841, 26, 288, 315, 795, 275, 1448, 26221, 40, 979, 8, 277, 14, 12924, 680, 12637, 288, 372, 291, 14, 12924, 59, 18212, 61, 267, 587, 26, 288, 372, 291, 14, 12924, 339, 768, 1829, 14, 14269, 272, 347, 12494, 8, 277, 304, 267, 408, 267, 6668, 314, 16842, 5689, 14, 267, 408, 267, 21945, 275, 282, 827, 8, 277, 14, 12924, 12, 3114, 29, 16, 9, 267, 8728, 275, 282, 988, 8, 277, 14, 12924, 12, 3114, 29, 16, 9, 267, 372, 24788, 1332, 10344, 12, 8728, 430, 339, 768, 1829, 14, 14269, 272, 347, 9150, 8, 277, 304, 267, 408, 267, 6668, 314, 4897, 9150, 14, 267, 408, 267, 372, 822, 8, 277, 14, 12924, 9, 339, 347, 9066, 8, 277, 12, 3372, 29, 403, 304, 267, 408, 267, 5852, 1006, 9617, 4382, 12, 911, 3542, 295, 31598, 267, 408, 267, 340, 3372, 365, 488, 26, 288, 3372, 275, 942, 267, 916, 1228, 8, 2759, 12, 620, 304, 288, 3372, 275, 359, 2759, 61, 267, 367, 5931, 315, 491, 17613, 57, 63, 18166, 26, 288, 340, 5931, 315, 291, 855, 807, 4343, 1612, 342, 436, 5931, 440, 315, 3372, 26, 355, 2150, 291, 855, 807, 12298, 4469, 61, 267, 372, 291, 339, 347, 6033, 8, 277, 12, 1163, 12, 1083, 534, 26479, 735, 267, 408, 267, 21892, 3382, 314, 8126, 402, 642, 1350, 436, 4573, 14, 398, 3897, 267, 4143, 267, 1163, 520, 5800, 12, 503, 1625, 13, 2930, 288, 13083, 4573, 1350, 12, 503, 314, 8126, 8983, 402, 4573, 1350, 398, 1083, 520, 620, 288, 13327, 282, 6033, 9775, 370, 1202, 367, 11469, 6033, 3382, 1350, 288, 19190, 14, 9338, 1511, 2387, 662, 24941, 6033, 661, 26479, 358, 436, 7205, 491, 17, 13, 4791, 661, 76, 17, 1959, 24807, 408, 267, 687, 2680, 14, 10096, 492, 6316, 398, 1104, 6007, 8, 765, 12, 788, 26479, 297, 283, 76, 17, 1105, 398, 340, 1083, 508, 283, 76, 17, 356, 288, 1865, 275, 413, 267, 587, 26, 288, 1865, 275, 499, 398, 340, 1228, 8, 1848, 12, 5800, 304, 288, 372, 6316, 8, 277, 14, 4218, 446, 1163, 14, 4218, 12, 6206, 29, 1648, 9, 267, 916, 1228, 8, 1848, 12, 769, 9, 503, 1228, 8, 1848, 12, 6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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 ]
marscher/tmpnb
dockworker.py
5
7431
from concurrent.futures import ThreadPoolExecutor from collections import namedtuple import re import docker import requests from docker.utils import create_host_config, kwargs_from_env from tornado import gen, web from tornado.log import app_log ContainerConfig = namedtuple('ContainerConfig', [ 'image', 'command', 'mem_limit', 'cpu_shares', 'container_ip', 'container_port' ]) # Number of times to retry API calls before giving up. RETRIES = 5 class AsyncDockerClient(): '''Completely ridiculous wrapper for a Docker client that returns futures on every single docker method called on it, configured with an executor. If no executor is passed, it defaults ThreadPoolExecutor(max_workers=2). ''' def __init__(self, docker_client, executor=None): if executor is None: executor = ThreadPoolExecutor(max_workers=2) self._docker_client = docker_client self.executor = executor def __getattr__(self, name): '''Creates a function, based on docker_client.name that returns a Future. If name is not a callable, returns the attribute directly. ''' fn = getattr(self._docker_client, name) # Make sure it really is a function first if not callable(fn): return fn def method(*args, **kwargs): return self.executor.submit(fn, *args, **kwargs) return method class DockerSpawner(): def __init__(self, docker_host='unix://var/run/docker.sock', version='auto', timeout=30, max_workers=64, assert_hostname=False): #kwargs = kwargs_from_env(assert_hostname=False) kwargs = kwargs_from_env(assert_hostname=assert_hostname) # environment variable DOCKER_HOST takes precedence kwargs.setdefault('base_url', docker_host) blocking_docker_client = docker.Client(version=version, timeout=timeout, **kwargs) executor = ThreadPoolExecutor(max_workers=max_workers) async_docker_client = AsyncDockerClient(blocking_docker_client, executor) self.docker_client = async_docker_client @gen.coroutine def create_notebook_server(self, base_path, container_name, container_config): '''Creates a notebook_server running off of `base_path`. Returns the (container_id, ip, port) tuple in a Future.''' port = container_config.container_port app_log.debug(container_config) # Assumes that the container_config.command is of a format like: # # ipython notebook --no-browser --port {port} --ip=0.0.0.0 # --NotebookApp.base_path=/{base_path} # --NotebookApp.tornado_settings=\"{ \"template_path\": [ \"/srv/ga\", # \"/srv/ipython/IPython/html\", # \"/srv/ipython/IPython/html/templates\" ] }\"" # # Important piece here is the parametrized base_path to let the # underlying process know where the proxy is routing it. rendered_command = container_config.command.format(base_path=base_path, port=port) command = [ "/bin/sh", "-c", rendered_command ] host_config = dict( mem_limit=container_config.mem_limit ) host_config = create_host_config(**host_config) cpu_shares = None if container_config.cpu_shares: # Some versions of Docker and docker-py won't cast from string to int cpu_shares = int(container_config.cpu_shares) resp = yield self._with_retries(self.docker_client.create_container, image=container_config.image, command=command, host_config=host_config, cpu_shares=cpu_shares, name=container_name) docker_warnings = resp.get('Warnings') if docker_warnings is not None: app_log.warn(docker_warnings) container_id = resp['Id'] app_log.info("Created container {}".format(container_id)) port_bindings = { container_config.container_port: (container_config.container_ip,) } yield self._with_retries(self.docker_client.start, container_id, port_bindings=port_bindings) container_network = yield self._with_retries(self.docker_client.port, container_id, container_config.container_port) host_port = container_network[0]['HostPort'] host_ip = container_network[0]['HostIp'] raise gen.Return((container_id, host_ip, int(host_port))) @gen.coroutine def shutdown_notebook_server(self, container_id, alive=True): '''Gracefully stop a running container.''' if alive: yield self._with_retries(self.docker_client.stop, container_id) yield self._with_retries(self.docker_client.remove_container, container_id) @gen.coroutine def list_notebook_servers(self, pool_regex, all=True): '''List containers that are managed by a specific pool.''' existing = yield self._with_retries(self.docker_client.containers, all=all, trunc=False) def name_matches(container): try: names = container['Names'] if names is None: app_log.warn("Docker API returned null Names, ignoring") return False except Exception: app_log.warn("Invalid container: %r", container) return False for name in names: if pool_regex.search(name): return True return False matching = [container for container in existing if name_matches(container)] raise gen.Return(matching) @gen.coroutine def _with_retries(self, fn, *args, **kwargs): '''Attempt a Docker API call. If an error occurs, retry up to "max_tries" times before letting the exception propagate up the stack.''' max_tries = kwargs.get('max_tries', RETRIES) try: if 'max_tries' in kwargs: del kwargs['max_tries'] result = yield fn(*args, **kwargs) raise gen.Return(result) except (docker.errors.APIError, requests.exceptions.RequestException) as e: app_log.error("Encountered a Docker error with {} ({} retries remain): {}".format(fn.__name__, max_tries, e)) if max_tries > 0: kwargs['max_tries'] = max_tries - 1 result = yield self._with_retries(fn, *args, **kwargs) raise gen.Return(result) else: raise e @gen.coroutine def copy_files(self, container_id, path): '''Returns a tarball of path from container_id''' tarball = yield self.docker_client.copy(container_id, path) raise gen.Return(tarball)
bsd-3-clause
[ 504, 23002, 14, 25513, 492, 11086, 5453, 16752, 199, 504, 5055, 492, 12863, 199, 646, 295, 199, 199, 646, 12424, 199, 646, 4145, 199, 199, 504, 12424, 14, 1208, 492, 1218, 63, 1102, 63, 888, 12, 2074, 63, 504, 63, 1813, 199, 199, 504, 12148, 492, 3805, 12, 3330, 199, 504, 12148, 14, 793, 492, 1145, 63, 793, 199, 199, 4076, 2028, 275, 12863, 360, 4076, 2028, 297, 359, 272, 283, 1569, 297, 283, 1531, 297, 283, 5286, 63, 3097, 297, 283, 3541, 63, 18318, 297, 283, 3600, 63, 711, 297, 283, 3600, 63, 719, 7, 199, 566, 199, 199, 3, 4860, 402, 5431, 370, 7269, 3261, 4882, 2544, 15131, 1536, 14, 199, 32528, 275, 959, 421, 199, 533, 15223, 31463, 3041, 837, 272, 1449, 14175, 590, 8012, 5000, 13957, 527, 4975, 367, 282, 22067, 1890, 626, 2529, 27471, 272, 641, 4036, 2849, 12424, 1083, 2797, 641, 652, 12, 7526, 543, 376, 13270, 14, 272, 982, 949, 13270, 365, 3032, 12, 652, 4243, 11086, 5453, 16752, 8, 988, 63, 11009, 29, 18, 680, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 12424, 63, 1258, 12, 13270, 29, 403, 304, 267, 340, 13270, 365, 488, 26, 288, 13270, 275, 11086, 5453, 16752, 8, 988, 63, 11009, 29, 18, 9, 267, 291, 423, 9991, 63, 1258, 275, 12424, 63, 1258, 267, 291, 14, 13471, 275, 13270, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 1449, 10607, 282, 805, 12, 4079, 641, 12424, 63, 1258, 14, 354, 626, 2529, 282, 267, 20799, 14, 982, 536, 365, 440, 282, 4550, 12, 2529, 314, 2225, 5370, 14, 267, 1449, 267, 4325, 275, 2519, 8, 277, 423, 9991, 63, 1258, 12, 536, 9, 398, 327, 4155, 3238, 652, 7710, 365, 282, 805, 1642, 267, 340, 440, 4550, 8, 2324, 304, 288, 372, 4325, 398, 347, 1083, 2031, 589, 12, 1011, 958, 304, 288, 372, 291, 14, 13471, 14, 7275, 8, 2324, 12, 627, 589, 12, 1011, 958, 9, 398, 372, 1083, 421, 199, 533, 22067, 12739, 4977, 837, 272, 347, 636, 826, 721, 277, 12, 326, 12424, 63, 1102, 534, 11864, 921, 1391, 15, 1065, 15, 9991, 14, 5096, 297, 326, 1015, 534, 2495, 297, 326, 2653, 29, 1216, 12, 326, 1390, 63, 11009, 29, 772, 12, 326, 702, 63, 4269, 29, 797, 304, 398, 327, 958, 275, 2074, 63, 504, 63, 1813, 8, 479, 63, 4269, 29, 797, 9, 267, 2074, 275, 2074, 63, 504, 63, 1813, 8, 479, 63, 4269, 29, 479, 63, 4269, 9, 398, 327, 3734, 1750, 3506, 2504, 540, 63, 5449, 6181, 13823, 267, 2074, 14, 5486, 360, 1095, 63, 633, 297, 12424, 63, 1102, 9, 398, 14592, 63, 9991, 63, 1258, 275, 12424, 14, 3041, 8, 1023, 29, 1023, 12, 6901, 2653, 29, 2593, 12, 6901, 1011, 958, 9, 398, 13270, 275, 11086, 5453, 16752, 8, 988, 63, 11009, 29, 988, 63, 11009, 9, 398, 5316, 63, 9991, 63, 1258, 275, 15223, 31463, 3041, 8, 13091, 63, 9991, 63, 1258, 12, 6059, 13270, 9, 267, 291, 14, 9991, 63, 1258, 275, 5316, 63, 9991, 63, 1258, 339, 768, 2268, 14, 16675, 272, 347, 1218, 63, 19174, 63, 1000, 8, 277, 12, 1300, 63, 515, 12, 3970, 63, 354, 12, 3970, 63, 888, 304, 267, 1449, 10607, 282, 20751, 63, 1000, 3879, 2331, 402, 658, 1095, 63, 515, 2313, 398, 1803, 314, 334, 3600, 63, 344, 12, 3384, 12, 1844, 9, 2008, 315, 282, 20799, 10595, 398, 1844, 275, 3970, 63, 888, 14, 3600, 63, 719, 398, 1145, 63, 793, 14, 1757, 8, 3600, 63, 888, 9, 398, 327, 30451, 626, 314, 3970, 63, 888, 14, 1531, 365, 402, 282, 1475, 2839, 26, 267, 327, 267, 327, 221, 284, 1548, 20751, 1553, 889, 13, 5750, 1553, 719, 469, 719, 93, 1553, 711, 29, 16, 14, 16, 14, 16, 14, 16, 267, 327, 259, 1553, 20114, 2640, 14, 1095, 63, 515, 29, 5321, 1095, 63, 515, 93, 267, 327, 259, 1553, 20114, 2640, 14, 18443, 63, 1751, 8178, 91, 8441, 1160, 63, 515, 19354, 359, 8441, 15, 15165, 15, 5294, 20756, 267, 327, 259, 8441, 15, 15165, 15, 22691, 15, 1772, 11361, 15, 1360, 20756, 267, 327, 259, 8441, 15, 15165, 15, 22691, 15, 1772, 11361, 15, 1360, 15, 5876, 4451, 1622, 789, 18781, 267, 327, 267, 327, 3161, 867, 14854, 2348, 365, 314, 18117, 599, 7068, 1300, 63, 515, 370, 4691, 314, 267, 327, 8793, 2112, 5715, 2382, 314, 4566, 365, 14870, 652, 14, 267, 8018, 63, 1531, 275, 3970, 63, 888, 14, 1531, 14, 908, 8, 1095, 63, 515, 29, 1095, 63, 515, 12, 1844, 29, 719, 9, 398, 1414, 275, 359, 288, 3286, 1393, 15, 609, 401, 288, 3905, 67, 401, 288, 8018, 63, 1531, 267, 1622, 398, 1591, 63, 888, 275, 1211, 8, 288, 7573, 63, 3097, 29, 3600, 63, 888, 14, 5286, 63, 3097, 267, 776, 398, 1591, 63, 888, 275, 1218, 63, 1102, 63, 888, 3682, 1102, 63, 888, 9, 2728, 5033, 63, 18318, 275, 488, 398, 340, 3970, 63, 888, 14, 3541, 63, 18318, 26, 288, 327, 6601, 5459, 402, 22067, 436, 12424, 13, 647, 7859, 1133, 9106, 687, 1059, 370, 1109, 288, 5033, 63, 18318, 275, 1109, 8, 3600, 63, 888, 14, 3541, 63, 18318, 9, 398, 3085, 275, 1995, 291, 423, 1045, 63, 10937, 8, 277, 14, 9991, 63, 1258, 14, 981, 63, 3600, 12, 3147, 1834, 29, 3600, 63, 888, 14, 1569, 12, 3147, 1414, 29, 1531, 12, 3147, 1591, 63, 888, 29, 1102, 63, 888, 12, 3147, 5033, 63, 18318, 29, 3541, 63, 18318, 12, 3147, 536, 29, 3600, 63, 354, 9, 398, 12424, 63, 5451, 275, 3085, 14, 362, 360, 15921, 358, 267, 340, 12424, 63, 5451, 365, 440, 488, 26, 288, 1145, 63, 793, 14, 4050, 8, 9991, 63, 5451, 9, 398, 3970, 63, 344, 275, 3085, 459, 1304, 418, 267, 1145, 63, 793, 14, 815, 480, 10502, 3970, 8352, 908, 8, 3600, 63, 344, 430, 398, 1844, 63, 10880, 275, 469, 288, 3970, 63, 888, 14, 3600, 63, 719, 26, 334, 3600, 63, 888, 14, 3600, 63, 711, 4258, 267, 789, 267, 1995, 291, 423, 1045, 63, 10937, 8, 277, 14, 9991, 63, 1258, 14, 928, 12, 639, 3970 ]
[ 23002, 14, 25513, 492, 11086, 5453, 16752, 199, 504, 5055, 492, 12863, 199, 646, 295, 199, 199, 646, 12424, 199, 646, 4145, 199, 199, 504, 12424, 14, 1208, 492, 1218, 63, 1102, 63, 888, 12, 2074, 63, 504, 63, 1813, 199, 199, 504, 12148, 492, 3805, 12, 3330, 199, 504, 12148, 14, 793, 492, 1145, 63, 793, 199, 199, 4076, 2028, 275, 12863, 360, 4076, 2028, 297, 359, 272, 283, 1569, 297, 283, 1531, 297, 283, 5286, 63, 3097, 297, 283, 3541, 63, 18318, 297, 283, 3600, 63, 711, 297, 283, 3600, 63, 719, 7, 199, 566, 199, 199, 3, 4860, 402, 5431, 370, 7269, 3261, 4882, 2544, 15131, 1536, 14, 199, 32528, 275, 959, 421, 199, 533, 15223, 31463, 3041, 837, 272, 1449, 14175, 590, 8012, 5000, 13957, 527, 4975, 367, 282, 22067, 1890, 626, 2529, 27471, 272, 641, 4036, 2849, 12424, 1083, 2797, 641, 652, 12, 7526, 543, 376, 13270, 14, 272, 982, 949, 13270, 365, 3032, 12, 652, 4243, 11086, 5453, 16752, 8, 988, 63, 11009, 29, 18, 680, 272, 1449, 272, 347, 636, 826, 721, 277, 12, 12424, 63, 1258, 12, 13270, 29, 403, 304, 267, 340, 13270, 365, 488, 26, 288, 13270, 275, 11086, 5453, 16752, 8, 988, 63, 11009, 29, 18, 9, 267, 291, 423, 9991, 63, 1258, 275, 12424, 63, 1258, 267, 291, 14, 13471, 275, 13270, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 1449, 10607, 282, 805, 12, 4079, 641, 12424, 63, 1258, 14, 354, 626, 2529, 282, 267, 20799, 14, 982, 536, 365, 440, 282, 4550, 12, 2529, 314, 2225, 5370, 14, 267, 1449, 267, 4325, 275, 2519, 8, 277, 423, 9991, 63, 1258, 12, 536, 9, 398, 327, 4155, 3238, 652, 7710, 365, 282, 805, 1642, 267, 340, 440, 4550, 8, 2324, 304, 288, 372, 4325, 398, 347, 1083, 2031, 589, 12, 1011, 958, 304, 288, 372, 291, 14, 13471, 14, 7275, 8, 2324, 12, 627, 589, 12, 1011, 958, 9, 398, 372, 1083, 421, 199, 533, 22067, 12739, 4977, 837, 272, 347, 636, 826, 721, 277, 12, 326, 12424, 63, 1102, 534, 11864, 921, 1391, 15, 1065, 15, 9991, 14, 5096, 297, 326, 1015, 534, 2495, 297, 326, 2653, 29, 1216, 12, 326, 1390, 63, 11009, 29, 772, 12, 326, 702, 63, 4269, 29, 797, 304, 398, 327, 958, 275, 2074, 63, 504, 63, 1813, 8, 479, 63, 4269, 29, 797, 9, 267, 2074, 275, 2074, 63, 504, 63, 1813, 8, 479, 63, 4269, 29, 479, 63, 4269, 9, 398, 327, 3734, 1750, 3506, 2504, 540, 63, 5449, 6181, 13823, 267, 2074, 14, 5486, 360, 1095, 63, 633, 297, 12424, 63, 1102, 9, 398, 14592, 63, 9991, 63, 1258, 275, 12424, 14, 3041, 8, 1023, 29, 1023, 12, 6901, 2653, 29, 2593, 12, 6901, 1011, 958, 9, 398, 13270, 275, 11086, 5453, 16752, 8, 988, 63, 11009, 29, 988, 63, 11009, 9, 398, 5316, 63, 9991, 63, 1258, 275, 15223, 31463, 3041, 8, 13091, 63, 9991, 63, 1258, 12, 6059, 13270, 9, 267, 291, 14, 9991, 63, 1258, 275, 5316, 63, 9991, 63, 1258, 339, 768, 2268, 14, 16675, 272, 347, 1218, 63, 19174, 63, 1000, 8, 277, 12, 1300, 63, 515, 12, 3970, 63, 354, 12, 3970, 63, 888, 304, 267, 1449, 10607, 282, 20751, 63, 1000, 3879, 2331, 402, 658, 1095, 63, 515, 2313, 398, 1803, 314, 334, 3600, 63, 344, 12, 3384, 12, 1844, 9, 2008, 315, 282, 20799, 10595, 398, 1844, 275, 3970, 63, 888, 14, 3600, 63, 719, 398, 1145, 63, 793, 14, 1757, 8, 3600, 63, 888, 9, 398, 327, 30451, 626, 314, 3970, 63, 888, 14, 1531, 365, 402, 282, 1475, 2839, 26, 267, 327, 267, 327, 221, 284, 1548, 20751, 1553, 889, 13, 5750, 1553, 719, 469, 719, 93, 1553, 711, 29, 16, 14, 16, 14, 16, 14, 16, 267, 327, 259, 1553, 20114, 2640, 14, 1095, 63, 515, 29, 5321, 1095, 63, 515, 93, 267, 327, 259, 1553, 20114, 2640, 14, 18443, 63, 1751, 8178, 91, 8441, 1160, 63, 515, 19354, 359, 8441, 15, 15165, 15, 5294, 20756, 267, 327, 259, 8441, 15, 15165, 15, 22691, 15, 1772, 11361, 15, 1360, 20756, 267, 327, 259, 8441, 15, 15165, 15, 22691, 15, 1772, 11361, 15, 1360, 15, 5876, 4451, 1622, 789, 18781, 267, 327, 267, 327, 3161, 867, 14854, 2348, 365, 314, 18117, 599, 7068, 1300, 63, 515, 370, 4691, 314, 267, 327, 8793, 2112, 5715, 2382, 314, 4566, 365, 14870, 652, 14, 267, 8018, 63, 1531, 275, 3970, 63, 888, 14, 1531, 14, 908, 8, 1095, 63, 515, 29, 1095, 63, 515, 12, 1844, 29, 719, 9, 398, 1414, 275, 359, 288, 3286, 1393, 15, 609, 401, 288, 3905, 67, 401, 288, 8018, 63, 1531, 267, 1622, 398, 1591, 63, 888, 275, 1211, 8, 288, 7573, 63, 3097, 29, 3600, 63, 888, 14, 5286, 63, 3097, 267, 776, 398, 1591, 63, 888, 275, 1218, 63, 1102, 63, 888, 3682, 1102, 63, 888, 9, 2728, 5033, 63, 18318, 275, 488, 398, 340, 3970, 63, 888, 14, 3541, 63, 18318, 26, 288, 327, 6601, 5459, 402, 22067, 436, 12424, 13, 647, 7859, 1133, 9106, 687, 1059, 370, 1109, 288, 5033, 63, 18318, 275, 1109, 8, 3600, 63, 888, 14, 3541, 63, 18318, 9, 398, 3085, 275, 1995, 291, 423, 1045, 63, 10937, 8, 277, 14, 9991, 63, 1258, 14, 981, 63, 3600, 12, 3147, 1834, 29, 3600, 63, 888, 14, 1569, 12, 3147, 1414, 29, 1531, 12, 3147, 1591, 63, 888, 29, 1102, 63, 888, 12, 3147, 5033, 63, 18318, 29, 3541, 63, 18318, 12, 3147, 536, 29, 3600, 63, 354, 9, 398, 12424, 63, 5451, 275, 3085, 14, 362, 360, 15921, 358, 267, 340, 12424, 63, 5451, 365, 440, 488, 26, 288, 1145, 63, 793, 14, 4050, 8, 9991, 63, 5451, 9, 398, 3970, 63, 344, 275, 3085, 459, 1304, 418, 267, 1145, 63, 793, 14, 815, 480, 10502, 3970, 8352, 908, 8, 3600, 63, 344, 430, 398, 1844, 63, 10880, 275, 469, 288, 3970, 63, 888, 14, 3600, 63, 719, 26, 334, 3600, 63, 888, 14, 3600, 63, 711, 4258, 267, 789, 267, 1995, 291, 423, 1045, 63, 10937, 8, 277, 14, 9991, 63, 1258, 14, 928, 12, 639, 3970, 0 ]
[ 1, 1, 1, 1, 1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1
mm/tools/perf/scripts/python/sctop.py
11180
1924
# system call top # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(interval): while 1: clear_term() if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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served. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. 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. # # 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 netforce.controller import Controller from netforce.template import render from netforce.model import get_model from netforce.database import get_connection,get_active_db # XXX: move this from netforce.locale import set_active_locale,get_active_locale from .cms_base import BaseController class Coupon(BaseController): _path="/ecom_coupon" def get(self): db=get_connection() try: ctx=self.context user_id = self.get_cookie("user_id") if not user_id: raise Exception("Can't access coupon page without login") user_id = int(user_id) user = get_model("base.user").browse(user_id) coupon_id=int(self.get_argument("coupon_id")) coupon=get_model("sale.coupon").browse(coupon_id) #if user.contact_id.id != coupon.contact_id.id: #raise Exception("Can't access coupon of other users") ctx["coupon"]=coupon content=render("ecom_coupon",ctx) ctx["content"]=content html=render("cms_layout",ctx) self.write(html) db.commit() except: self.redirect("cms_page_not_found") import traceback traceback.print_exc() db.rollback() def post(self): db=get_connection() try: ctx=self.context coupon_id=int(self.get_argument("coupon_id")) action=self.get_argument("action") try: if action=="use_coupon": coupon=get_model("sale.coupon").browse(coupon_id) coupon.use_coupon() db.commit() self.redirect("/ecom_coupon?coupon_id=%s"%coupon.id) except Exception as e: ctx["error_message"]=str(e) coupon=get_model("sale.coupon").browse(coupon_id) ctx["coupon"]=coupon content=render("ecom_coupon",ctx) ctx["content"]=content html=render("cms_layout",ctx) self.write(html) db.commit() except: import traceback traceback.print_exc() db.rollback() Coupon.register()
mit
[ 3, 1898, 334, 67, 9, 6900, 12, 5365, 3990, 1849, 2020, 12126, 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, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 259, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 259, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 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, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 1851, 3990, 14, 5538, 492, 16282, 199, 504, 1851, 3990, 14, 1160, 492, 3795, 199, 504, 1851, 3990, 14, 1238, 492, 664, 63, 1238, 199, 504, 1851, 3990, 14, 4659, 492, 664, 63, 2105, 12, 362, 63, 2682, 63, 697, 327, 5787, 26, 4057, 642, 199, 504, 1851, 3990, 14, 5508, 492, 663, 63, 2682, 63, 5508, 12, 362, 63, 2682, 63, 5508, 199, 504, 1275, 10781, 63, 1095, 492, 3523, 7506, 199, 199, 533, 1849, 13527, 8, 1563, 7506, 304, 272, 485, 515, 9555, 69, 957, 63, 20039, 2, 339, 347, 664, 8, 277, 304, 267, 1592, 29, 362, 63, 2105, 342, 267, 862, 26, 288, 4027, 29, 277, 14, 1100, 288, 922, 63, 344, 275, 291, 14, 362, 63, 5306, 480, 751, 63, 344, 531, 288, 340, 440, 922, 63, 344, 26, 355, 746, 2186, 480, 6049, 1133, 2879, 29054, 2034, 1928, 4676, 531, 288, 922, 63, 344, 275, 1109, 8, 751, 63, 344, 9, 288, 922, 275, 664, 63, 1238, 480, 1095, 14, 751, 3471, 4570, 8, 751, 63, 344, 9, 288, 29054, 63, 344, 29, 442, 8, 277, 14, 362, 63, 2094, 480, 20039, 63, 344, 2237, 288, 29054, 29, 362, 63, 1238, 480, 8515, 14, 20039, 3471, 4570, 8, 20039, 63, 344, 9, 288, 327, 692, 922, 14, 7811, 63, 344, 14, 344, 1137, 29054, 14, 7811, 63, 344, 14, 344, 26, 355, 327, 3730, 2186, 480, 6049, 1133, 2879, 29054, 402, 1163, 4390, 531, 288, 4027, 905, 20039, 8713, 20039, 288, 1564, 29, 3352, 480, 69, 957, 63, 20039, 401, 3799, 9, 288, 4027, 905, 1317, 8713, 1317, 288, 3517, 29, 3352, 480, 10781, 63, 4209, 401, 3799, 9, 288, 291, 14, 952, 8, 1360, 9, 288, 1592, 14, 3543, 342, 267, 871, 26, 288, 291, 14, 4876, 480, 10781, 63, 1606, 63, 1397, 63, 4214, 531, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 288, 1592, 14, 10437, 342, 339, 347, 2963, 8, 277, 304, 267, 1592, 29, 362, 63, 2105, 342, 267, 862, 26, 288, 4027, 29, 277, 14, 1100, 288, 29054, 63, 344, 29, 442, 8, 277, 14, 362, 63, 2094, 480, 20039, 63, 344, 2237, 288, 1595, 29, 277, 14, 362, 63, 2094, 480, 1287, 531, 288, 862, 26, 355, 340, 1595, 11800, 1180, 63, 20039, 582, 490, 29054, 29, 362, 63, 1238, 480, 8515, 14, 20039, 3471, 4570, 8, 20039, 63, 344, 9, 490, 29054, 14, 1180, 63, 20039, 342, 490, 1592, 14, 3543, 342, 490, 291, 14, 4876, 4769, 69, 957, 63, 20039, 31, 20039, 63, 344, 2458, 83, 6808, 20039, 14, 344, 9, 288, 871, 2186, 465, 325, 26, 355, 4027, 905, 705, 63, 1188, 8713, 495, 8, 69, 9, 355, 29054, 29, 362, 63, 1238, 480, 8515, 14, 20039, 3471, 4570, 8, 20039, 63, 344, 9, 355, 4027, 905, 20039, 8713, 20039, 355, 1564, 29, 3352, 480, 69, 957, 63, 20039, 401, 3799, 9, 355, 4027, 905, 1317, 8713, 1317, 355, 3517, 29, 3352, 480, 10781, 63, 4209, 401, 3799, 9, 355, 291, 14, 952, 8, 1360, 9, 355, 1592, 14, 3543, 342, 267, 871, 26, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 288, 1592, 14, 10437, 342, 199, 199, 967, 13527, 14, 2683, 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 ]
[ 1898, 334, 67, 9, 6900, 12, 5365, 3990, 1849, 2020, 12126, 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, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 199, 3, 259, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 259, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 3, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 3, 5258, 1821, 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, 1634, 5749, 199, 3, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 1851, 3990, 14, 5538, 492, 16282, 199, 504, 1851, 3990, 14, 1160, 492, 3795, 199, 504, 1851, 3990, 14, 1238, 492, 664, 63, 1238, 199, 504, 1851, 3990, 14, 4659, 492, 664, 63, 2105, 12, 362, 63, 2682, 63, 697, 327, 5787, 26, 4057, 642, 199, 504, 1851, 3990, 14, 5508, 492, 663, 63, 2682, 63, 5508, 12, 362, 63, 2682, 63, 5508, 199, 504, 1275, 10781, 63, 1095, 492, 3523, 7506, 199, 199, 533, 1849, 13527, 8, 1563, 7506, 304, 272, 485, 515, 9555, 69, 957, 63, 20039, 2, 339, 347, 664, 8, 277, 304, 267, 1592, 29, 362, 63, 2105, 342, 267, 862, 26, 288, 4027, 29, 277, 14, 1100, 288, 922, 63, 344, 275, 291, 14, 362, 63, 5306, 480, 751, 63, 344, 531, 288, 340, 440, 922, 63, 344, 26, 355, 746, 2186, 480, 6049, 1133, 2879, 29054, 2034, 1928, 4676, 531, 288, 922, 63, 344, 275, 1109, 8, 751, 63, 344, 9, 288, 922, 275, 664, 63, 1238, 480, 1095, 14, 751, 3471, 4570, 8, 751, 63, 344, 9, 288, 29054, 63, 344, 29, 442, 8, 277, 14, 362, 63, 2094, 480, 20039, 63, 344, 2237, 288, 29054, 29, 362, 63, 1238, 480, 8515, 14, 20039, 3471, 4570, 8, 20039, 63, 344, 9, 288, 327, 692, 922, 14, 7811, 63, 344, 14, 344, 1137, 29054, 14, 7811, 63, 344, 14, 344, 26, 355, 327, 3730, 2186, 480, 6049, 1133, 2879, 29054, 402, 1163, 4390, 531, 288, 4027, 905, 20039, 8713, 20039, 288, 1564, 29, 3352, 480, 69, 957, 63, 20039, 401, 3799, 9, 288, 4027, 905, 1317, 8713, 1317, 288, 3517, 29, 3352, 480, 10781, 63, 4209, 401, 3799, 9, 288, 291, 14, 952, 8, 1360, 9, 288, 1592, 14, 3543, 342, 267, 871, 26, 288, 291, 14, 4876, 480, 10781, 63, 1606, 63, 1397, 63, 4214, 531, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 288, 1592, 14, 10437, 342, 339, 347, 2963, 8, 277, 304, 267, 1592, 29, 362, 63, 2105, 342, 267, 862, 26, 288, 4027, 29, 277, 14, 1100, 288, 29054, 63, 344, 29, 442, 8, 277, 14, 362, 63, 2094, 480, 20039, 63, 344, 2237, 288, 1595, 29, 277, 14, 362, 63, 2094, 480, 1287, 531, 288, 862, 26, 355, 340, 1595, 11800, 1180, 63, 20039, 582, 490, 29054, 29, 362, 63, 1238, 480, 8515, 14, 20039, 3471, 4570, 8, 20039, 63, 344, 9, 490, 29054, 14, 1180, 63, 20039, 342, 490, 1592, 14, 3543, 342, 490, 291, 14, 4876, 4769, 69, 957, 63, 20039, 31, 20039, 63, 344, 2458, 83, 6808, 20039, 14, 344, 9, 288, 871, 2186, 465, 325, 26, 355, 4027, 905, 705, 63, 1188, 8713, 495, 8, 69, 9, 355, 29054, 29, 362, 63, 1238, 480, 8515, 14, 20039, 3471, 4570, 8, 20039, 63, 344, 9, 355, 4027, 905, 20039, 8713, 20039, 355, 1564, 29, 3352, 480, 69, 957, 63, 20039, 401, 3799, 9, 355, 4027, 905, 1317, 8713, 1317, 355, 3517, 29, 3352, 480, 10781, 63, 4209, 401, 3799, 9, 355, 291, 14, 952, 8, 1360, 9, 355, 1592, 14, 3543, 342, 267, 871, 26, 288, 492, 5190, 288, 5190, 14, 1361, 63, 2804, 342, 288, 1592, 14, 10437, 342, 199, 199, 967, 13527, 14, 2683, 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, 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 ]
zsoltdudas/lis-tempest
tempest/scenario/test_network_v6.py
2
10204
# Copyright 2014 Cisco Systems, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import functools import six from tempest import config from tempest.scenario import manager from tempest import test CONF = config.CONF class TestGettingAddress(manager.NetworkScenarioTest): """Test Summary: 1. Create network with subnets: 1.1. one IPv4 and 1.2. one or more IPv6 in a given address mode 2. Boot 2 VMs on this network 3. Allocate and assign 2 FIP4 4. Check that vNICs of all VMs gets all addresses actually assigned 5. Each VM will ping the other's v4 private address 6. If ping6 available in VM, each VM will ping all of the other's v6 addresses as well as the router's """ @classmethod def skip_checks(cls): super(TestGettingAddress, cls).skip_checks() if not (CONF.network_feature_enabled.ipv6 and CONF.network_feature_enabled.ipv6_subnet_attributes): raise cls.skipException('IPv6 or its attributes not supported') if not (CONF.network.tenant_networks_reachable or CONF.network.public_network_id): msg = ('Either tenant_networks_reachable must be "true", or ' 'public_network_id must be defined.') raise cls.skipException(msg) if CONF.baremetal.driver_enabled: msg = ('Baremetal does not currently support network isolation') raise cls.skipException(msg) @classmethod def setup_credentials(cls): # Create no network resources for these tests. cls.set_network_resources() super(TestGettingAddress, cls).setup_credentials() def setUp(self): super(TestGettingAddress, self).setUp() self.keypair = self.create_keypair() self.sec_grp = self._create_security_group(tenant_id=self.tenant_id) def prepare_network(self, address6_mode, n_subnets6=1, dualnet=False): """Prepare network Creates network with given number of IPv6 subnets in the given mode and one IPv4 subnet. Creates router with ports on all subnets. if dualnet - create IPv6 subnets on a different network :return: list of created networks """ self.network = self._create_network(tenant_id=self.tenant_id) if dualnet: self.network_v6 = self._create_network(tenant_id=self.tenant_id) sub4 = self._create_subnet(network=self.network, namestart='sub4', ip_version=4) router = self._get_router(tenant_id=self.tenant_id) sub4.add_to_router(router_id=router['id']) self.addCleanup(sub4.delete) self.subnets_v6 = [] for _ in range(n_subnets6): net6 = self.network_v6 if dualnet else self.network sub6 = self._create_subnet(network=net6, namestart='sub6', ip_version=6, ipv6_ra_mode=address6_mode, ipv6_address_mode=address6_mode) sub6.add_to_router(router_id=router['id']) self.addCleanup(sub6.delete) self.subnets_v6.append(sub6) return [self.network, self.network_v6] if dualnet else [self.network] @staticmethod def define_server_ips(srv): ips = {'4': None, '6': []} for net_name, nics in six.iteritems(srv['addresses']): for nic in nics: if nic['version'] == 6: ips['6'].append(nic['addr']) else: ips['4'] = nic['addr'] return ips def prepare_server(self, networks=None): username = CONF.validation.image_ssh_user networks = networks or [self.network] srv = self.create_server( key_name=self.keypair['name'], security_groups=[{'name': self.sec_grp['name']}], networks=[{'uuid': n.id} for n in networks], wait_until='ACTIVE') fip = self.create_floating_ip(thing=srv) ips = self.define_server_ips(srv=srv) ssh = self.get_remote_client( ip_address=fip.floating_ip_address, username=username) return ssh, ips, srv["id"] def turn_nic6_on(self, ssh, sid): """Turns the IPv6 vNIC on Required because guest images usually set only the first vNIC on boot. Searches for the IPv6 vNIC's MAC and brings it up. @param ssh: RemoteClient ssh instance to server @param sid: server uuid """ ports = [p["mac_address"] for p in self._list_ports(device_id=sid, network_id=self.network_v6.id)] self.assertEqual(1, len(ports), message=("Multiple IPv6 ports found on network %s. " "ports: %s") % (self.network_v6, ports)) mac6 = ports[0] ssh.set_nic_state(ssh.get_nic_name_by_mac(mac6)) def _prepare_and_test(self, address6_mode, n_subnets6=1, dualnet=False): net_list = self.prepare_network(address6_mode=address6_mode, n_subnets6=n_subnets6, dualnet=dualnet) sshv4_1, ips_from_api_1, sid1 = self.prepare_server(networks=net_list) sshv4_2, ips_from_api_2, sid2 = self.prepare_server(networks=net_list) def guest_has_address(ssh, addr): return addr in ssh.get_ip_list() # Turn on 2nd NIC for Cirros when dualnet if dualnet: self.turn_nic6_on(sshv4_1, sid1) self.turn_nic6_on(sshv4_2, sid2) # get addresses assigned to vNIC as reported by 'ip address' utility ips_from_ip_1 = sshv4_1.get_ip_list() ips_from_ip_2 = sshv4_2.get_ip_list() self.assertIn(ips_from_api_1['4'], ips_from_ip_1) self.assertIn(ips_from_api_2['4'], ips_from_ip_2) for i in range(n_subnets6): # v6 should be configured since the image supports it # It can take time for ipv6 automatic address to get assigned srv1_v6_addr_assigned = functools.partial( guest_has_address, sshv4_1, ips_from_api_1['6'][i]) srv2_v6_addr_assigned = functools.partial( guest_has_address, sshv4_2, ips_from_api_2['6'][i]) self.assertTrue(test.call_until_true(srv1_v6_addr_assigned, CONF.validation.ping_timeout, 1)) self.assertTrue(test.call_until_true(srv2_v6_addr_assigned, CONF.validation.ping_timeout, 1)) self._check_connectivity(sshv4_1, ips_from_api_2['4']) self._check_connectivity(sshv4_2, ips_from_api_1['4']) for i in range(n_subnets6): self._check_connectivity(sshv4_1, ips_from_api_2['6'][i]) self._check_connectivity(sshv4_1, self.subnets_v6[i].gateway_ip) self._check_connectivity(sshv4_2, ips_from_api_1['6'][i]) self._check_connectivity(sshv4_2, self.subnets_v6[i].gateway_ip) def _check_connectivity(self, source, dest): self.assertTrue( self._check_remote_connectivity(source, dest), "Timed out waiting for %s to become reachable from %s" % (dest, source.ssh_client.host) ) @test.attr(type='slow') @test.idempotent_id('2c92df61-29f0-4eaa-bee3-7c65bef62a43') @test.services('compute', 'network') def test_slaac_from_os(self): self._prepare_and_test(address6_mode='slaac') @test.attr(type='slow') @test.idempotent_id('d7e1f858-187c-45a6-89c9-bdafde619a9f') @test.services('compute', 'network') def test_dhcp6_stateless_from_os(self): self._prepare_and_test(address6_mode='dhcpv6-stateless') @test.attr(type='slow') @test.idempotent_id('7ab23f41-833b-4a16-a7c9-5b42fe6d4123') @test.services('compute', 'network') def test_multi_prefix_dhcpv6_stateless(self): self._prepare_and_test(address6_mode='dhcpv6-stateless', n_subnets6=2) @test.attr(type='slow') @test.idempotent_id('dec222b1-180c-4098-b8c5-cc1b8342d611') @test.services('compute', 'network') def test_multi_prefix_slaac(self): self._prepare_and_test(address6_mode='slaac', n_subnets6=2) @test.attr(type='slow') @test.idempotent_id('b6399d76-4438-4658-bcf5-0d6c8584fde2') @test.services('compute', 'network') def test_dualnet_slaac_from_os(self): self._prepare_and_test(address6_mode='slaac', dualnet=True) @test.attr(type='slow') @test.idempotent_id('76f26acd-9688-42b4-bc3e-cd134c4cb09e') @test.services('compute', 'network') def test_dualnet_dhcp6_stateless_from_os(self): self._prepare_and_test(address6_mode='dhcpv6-stateless', dualnet=True) @test.idempotent_id('cf1c4425-766b-45b8-be35-e2959728eb00') @test.services('compute', 'network') def test_dualnet_multi_prefix_dhcpv6_stateless(self): self._prepare_and_test(address6_mode='dhcpv6-stateless', n_subnets6=2, dualnet=True) @test.idempotent_id('9178ad42-10e4-47e9-8987-e02b170cc5cd') @test.services('compute', 'network') def test_dualnet_multi_prefix_slaac(self): self._prepare_and_test(address6_mode='slaac', n_subnets6=2, dualnet=True)
apache-2.0
[ 3, 1898, 6927, 28356, 15285, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 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, 646, 9143, 199, 199, 646, 3816, 199, 199, 504, 24076, 492, 1101, 199, 504, 24076, 14, 13444, 492, 5256, 199, 504, 24076, 492, 511, 421, 199, 3103, 275, 1101, 14, 3103, 421, 199, 533, 1379, 28277, 1476, 8, 2609, 14, 4491, 12327, 6936, 774, 304, 272, 408, 774, 22486, 26, 339, 413, 14, 2790, 2784, 543, 18709, 26, 267, 413, 14, 17, 14, 1373, 6509, 20, 436, 267, 413, 14, 18, 14, 1373, 503, 1655, 6509, 22, 315, 282, 1627, 2287, 818, 272, 499, 14, 27324, 499, 30641, 641, 642, 2784, 272, 650, 14, 4580, 6280, 436, 5090, 499, 481, 1772, 20, 272, 841, 14, 2670, 626, 373, 30374, 83, 402, 1006, 30641, 7545, 1006, 7149, 5965, 7943, 272, 959, 14, 7048, 7525, 911, 18249, 314, 1163, 1159, 373, 20, 5726, 2287, 272, 1227, 14, 982, 18249, 22, 2808, 315, 7525, 12, 1924, 7525, 911, 18249, 1006, 402, 314, 1163, 1159, 221, 373, 22, 2126, 7149, 465, 5521, 465, 314, 6197, 1159, 272, 408, 339, 768, 3744, 272, 347, 3372, 63, 8625, 8, 1886, 304, 267, 1613, 8, 774, 28277, 1476, 12, 843, 680, 2759, 63, 8625, 342, 267, 340, 440, 334, 3103, 14, 1200, 63, 4445, 63, 3827, 14, 4774, 22, 355, 436, 6392, 14, 1200, 63, 4445, 63, 3827, 14, 4774, 22, 63, 5327, 63, 2987, 304, 288, 746, 843, 14, 2759, 1726, 360, 12179, 22, 503, 2399, 3004, 440, 3748, 358, 267, 340, 440, 334, 3103, 14, 1200, 14, 4647, 63, 7642, 63, 15837, 355, 503, 6392, 14, 1200, 14, 3455, 63, 1200, 63, 344, 304, 288, 1499, 275, 661, 37, 1711, 8261, 63, 7642, 63, 15837, 1471, 506, 298, 2052, 401, 503, 283, 673, 283, 3455, 63, 1200, 63, 344, 1471, 506, 3247, 2659, 288, 746, 843, 14, 2759, 1726, 8, 1328, 9, 267, 340, 6392, 14, 14890, 22420, 14, 3090, 63, 3827, 26, 288, 1499, 275, 661, 34, 1530, 22420, 1630, 440, 5544, 2291, 2784, 30567, 358, 288, 746, 843, 14, 2759, 1726, 8, 1328, 9, 339, 768, 3744, 272, 347, 3272, 63, 6942, 8, 1886, 304, 267, 327, 2790, 949, 2784, 5944, 367, 3520, 2295, 14, 267, 843, 14, 409, 63, 1200, 63, 4435, 342, 267, 1613, 8, 774, 28277, 1476, 12, 843, 680, 2758, 63, 6942, 342, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 28277, 1476, 12, 291, 680, 5996, 342, 267, 291, 14, 19263, 275, 291, 14, 981, 63, 19263, 342, 267, 291, 14, 3321, 63, 12599, 275, 291, 423, 981, 63, 4416, 63, 923, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 339, 347, 9275, 63, 1200, 8, 277, 12, 2287, 22, 63, 632, 12, 302, 63, 14967, 22, 29, 17, 12, 21164, 846, 29, 797, 304, 267, 408, 22281, 2784, 398, 10560, 2784, 543, 1627, 1329, 402, 6509, 22, 18709, 315, 314, 1627, 818, 436, 267, 1373, 6509, 20, 6303, 14, 267, 10560, 6197, 543, 8873, 641, 1006, 18709, 14, 267, 340, 21164, 846, 446, 1218, 6509, 22, 18709, 641, 282, 3365, 2784, 267, 520, 1107, 26, 769, 402, 2737, 11759, 267, 408, 267, 291, 14, 1200, 275, 291, 423, 981, 63, 1200, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 267, 340, 21164, 846, 26, 288, 291, 14, 1200, 63, 86, 22, 275, 291, 423, 981, 63, 1200, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 398, 1007, 20, 275, 291, 423, 981, 63, 5327, 8, 1200, 29, 277, 14, 1200, 12, 3521, 536, 928, 534, 954, 20, 297, 3521, 3384, 63, 1023, 29, 20, 9, 398, 6197, 275, 291, 423, 362, 63, 4995, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 267, 1007, 20, 14, 525, 63, 475, 63, 4995, 8, 4995, 63, 344, 29, 4995, 459, 344, 1105, 267, 291, 14, 12808, 8, 954, 20, 14, 1807, 9, 398, 291, 14, 14967, 63, 86, 22, 275, 942, 267, 367, 485, 315, 1425, 8, 78, 63, 14967, 22, 304, 288, 1851, 22, 275, 291, 14, 1200, 63, 86, 22, 340, 21164, 846, 587, 291, 14, 1200, 288, 1007, 22, 275, 291, 423, 981, 63, 5327, 8, 1200, 29, 846, 22, 12, 4318, 536, 928, 534, 954, 22, 297, 4318, 3384, 63, 1023, 29, 22, 12, 4318, 3278, 22, 63, 345, 63, 632, 29, 1562, 22, 63, 632, 12, 4318, 3278, 22, 63, 1562, 63, 632, 29, 1562, 22, 63, 632, 9, 953, 1007, 22, 14, 525, 63, 475, 63, 4995, 8, 4995, 63, 344, 29, 4995, 459, 344, 1105, 288, 291, 14, 12808, 8, 954, 22, 14, 1807, 9, 288, 291, 14, 14967, 63, 86, 22, 14, 740, 8, 954, 22, 9, 398, 372, 359, 277, 14, 1200, 12, 291, 14, 1200, 63, 86, 22, 61, 340, 21164, 846, 587, 359, 277, 14, 1200, 61, 339, 768, 4639, 272, 347, 5627, 63, 1000, 63, 6142, 8, 15165, 304, 267, 15017, 275, 791, 20, 356, 488, 12, 283, 22, 356, 23455, 267, 367, 1851, 63, 354, 12, 302, 2932, 315, 3816, 14, 4611, 8, 15165, 459, 7423, 9090, 288, 367, 14304, 315, 302, 2932, 26, 355, 340, 14304, 459, 1023, 418, 508, 1227, 26, 490, 15017, 459, 22, 2278, 740, 8, 12165, 459, 2697, 1105, 355, 587, 26, 490, 15017, 459, 20, 418, 275, 14304 ]
[ 1898, 6927, 28356, 15285, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 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, 646, 9143, 199, 199, 646, 3816, 199, 199, 504, 24076, 492, 1101, 199, 504, 24076, 14, 13444, 492, 5256, 199, 504, 24076, 492, 511, 421, 199, 3103, 275, 1101, 14, 3103, 421, 199, 533, 1379, 28277, 1476, 8, 2609, 14, 4491, 12327, 6936, 774, 304, 272, 408, 774, 22486, 26, 339, 413, 14, 2790, 2784, 543, 18709, 26, 267, 413, 14, 17, 14, 1373, 6509, 20, 436, 267, 413, 14, 18, 14, 1373, 503, 1655, 6509, 22, 315, 282, 1627, 2287, 818, 272, 499, 14, 27324, 499, 30641, 641, 642, 2784, 272, 650, 14, 4580, 6280, 436, 5090, 499, 481, 1772, 20, 272, 841, 14, 2670, 626, 373, 30374, 83, 402, 1006, 30641, 7545, 1006, 7149, 5965, 7943, 272, 959, 14, 7048, 7525, 911, 18249, 314, 1163, 1159, 373, 20, 5726, 2287, 272, 1227, 14, 982, 18249, 22, 2808, 315, 7525, 12, 1924, 7525, 911, 18249, 1006, 402, 314, 1163, 1159, 221, 373, 22, 2126, 7149, 465, 5521, 465, 314, 6197, 1159, 272, 408, 339, 768, 3744, 272, 347, 3372, 63, 8625, 8, 1886, 304, 267, 1613, 8, 774, 28277, 1476, 12, 843, 680, 2759, 63, 8625, 342, 267, 340, 440, 334, 3103, 14, 1200, 63, 4445, 63, 3827, 14, 4774, 22, 355, 436, 6392, 14, 1200, 63, 4445, 63, 3827, 14, 4774, 22, 63, 5327, 63, 2987, 304, 288, 746, 843, 14, 2759, 1726, 360, 12179, 22, 503, 2399, 3004, 440, 3748, 358, 267, 340, 440, 334, 3103, 14, 1200, 14, 4647, 63, 7642, 63, 15837, 355, 503, 6392, 14, 1200, 14, 3455, 63, 1200, 63, 344, 304, 288, 1499, 275, 661, 37, 1711, 8261, 63, 7642, 63, 15837, 1471, 506, 298, 2052, 401, 503, 283, 673, 283, 3455, 63, 1200, 63, 344, 1471, 506, 3247, 2659, 288, 746, 843, 14, 2759, 1726, 8, 1328, 9, 267, 340, 6392, 14, 14890, 22420, 14, 3090, 63, 3827, 26, 288, 1499, 275, 661, 34, 1530, 22420, 1630, 440, 5544, 2291, 2784, 30567, 358, 288, 746, 843, 14, 2759, 1726, 8, 1328, 9, 339, 768, 3744, 272, 347, 3272, 63, 6942, 8, 1886, 304, 267, 327, 2790, 949, 2784, 5944, 367, 3520, 2295, 14, 267, 843, 14, 409, 63, 1200, 63, 4435, 342, 267, 1613, 8, 774, 28277, 1476, 12, 843, 680, 2758, 63, 6942, 342, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 28277, 1476, 12, 291, 680, 5996, 342, 267, 291, 14, 19263, 275, 291, 14, 981, 63, 19263, 342, 267, 291, 14, 3321, 63, 12599, 275, 291, 423, 981, 63, 4416, 63, 923, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 339, 347, 9275, 63, 1200, 8, 277, 12, 2287, 22, 63, 632, 12, 302, 63, 14967, 22, 29, 17, 12, 21164, 846, 29, 797, 304, 267, 408, 22281, 2784, 398, 10560, 2784, 543, 1627, 1329, 402, 6509, 22, 18709, 315, 314, 1627, 818, 436, 267, 1373, 6509, 20, 6303, 14, 267, 10560, 6197, 543, 8873, 641, 1006, 18709, 14, 267, 340, 21164, 846, 446, 1218, 6509, 22, 18709, 641, 282, 3365, 2784, 267, 520, 1107, 26, 769, 402, 2737, 11759, 267, 408, 267, 291, 14, 1200, 275, 291, 423, 981, 63, 1200, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 267, 340, 21164, 846, 26, 288, 291, 14, 1200, 63, 86, 22, 275, 291, 423, 981, 63, 1200, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 398, 1007, 20, 275, 291, 423, 981, 63, 5327, 8, 1200, 29, 277, 14, 1200, 12, 3521, 536, 928, 534, 954, 20, 297, 3521, 3384, 63, 1023, 29, 20, 9, 398, 6197, 275, 291, 423, 362, 63, 4995, 8, 4647, 63, 344, 29, 277, 14, 4647, 63, 344, 9, 267, 1007, 20, 14, 525, 63, 475, 63, 4995, 8, 4995, 63, 344, 29, 4995, 459, 344, 1105, 267, 291, 14, 12808, 8, 954, 20, 14, 1807, 9, 398, 291, 14, 14967, 63, 86, 22, 275, 942, 267, 367, 485, 315, 1425, 8, 78, 63, 14967, 22, 304, 288, 1851, 22, 275, 291, 14, 1200, 63, 86, 22, 340, 21164, 846, 587, 291, 14, 1200, 288, 1007, 22, 275, 291, 423, 981, 63, 5327, 8, 1200, 29, 846, 22, 12, 4318, 536, 928, 534, 954, 22, 297, 4318, 3384, 63, 1023, 29, 22, 12, 4318, 3278, 22, 63, 345, 63, 632, 29, 1562, 22, 63, 632, 12, 4318, 3278, 22, 63, 1562, 63, 632, 29, 1562, 22, 63, 632, 9, 953, 1007, 22, 14, 525, 63, 475, 63, 4995, 8, 4995, 63, 344, 29, 4995, 459, 344, 1105, 288, 291, 14, 12808, 8, 954, 22, 14, 1807, 9, 288, 291, 14, 14967, 63, 86, 22, 14, 740, 8, 954, 22, 9, 398, 372, 359, 277, 14, 1200, 12, 291, 14, 1200, 63, 86, 22, 61, 340, 21164, 846, 587, 359, 277, 14, 1200, 61, 339, 768, 4639, 272, 347, 5627, 63, 1000, 63, 6142, 8, 15165, 304, 267, 15017, 275, 791, 20, 356, 488, 12, 283, 22, 356, 23455, 267, 367, 1851, 63, 354, 12, 302, 2932, 315, 3816, 14, 4611, 8, 15165, 459, 7423, 9090, 288, 367, 14304, 315, 302, 2932, 26, 355, 340, 14304, 459, 1023, 418, 508, 1227, 26, 490, 15017, 459, 22, 2278, 740, 8, 12165, 459, 2697, 1105, 355, 587, 26, 490, 15017, 459, 20, 418, 275, 14304, 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,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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 ]
millken/simple-rtmp-server
trunk/research/community/server.py
1
4633
#!/usr/bin/python ''' The MIT License (MIT) Copyright (c) 2013-2014 winlin 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. ''' """ the community is a default demo server for srs """ import sys # reload sys model to enable the getdefaultencoding method. reload(sys) # set the default encoding to utf-8 # using exec to set the encoding, to avoid error in IDE. exec("sys.setdefaultencoding('utf-8')") assert sys.getdefaultencoding().lower() == "utf-8" import os, json, time, datetime, cherrypy, threading # simple log functions. def trace(msg): date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") print "[%s][trace] %s"%(date, msg) # enable crossdomain access for js-client # define the following method: # def OPTIONS(self, *args, **kwargs) # enable_crossdomain() # invoke this method to enable js to request crossdomain. def enable_crossdomain(): cherrypy.response.headers["Access-Control-Allow-Origin"] = "*" cherrypy.response.headers["Access-Control-Allow-Methods"] = "GET, POST, HEAD, PUT, DELETE" # generate allow headers for crossdomain. allow_headers = ["Cache-Control", "X-Proxy-Authorization", "X-Requested-With", "Content-Type"] cherrypy.response.headers["Access-Control-Allow-Headers"] = ",".join(allow_headers) # error codes definition class Error: # ok, success, completed. success = 0 # HTTP RESTful path. class Root(object): exposed = True def __init__(self): self.api = Api() def GET(self): enable_crossdomain(); return json.dumps({"code":Error.success, "urls":{"api":"the api root"}}) def OPTIONS(self, *args, **kwargs): enable_crossdomain(); # HTTP RESTful path. class Api(object): exposed = True def __init__(self): self.v1 = V1() def GET(self): enable_crossdomain(); return json.dumps({"code":Error.success, "urls": { "v1": "the api version 1.0" } }); def OPTIONS(self, *args, **kwargs): enable_crossdomain(); # HTTP RESTful path. to access as: # http://127.0.0.1:8085/api/v1/clients class V1(object): exposed = True def __init__(self): pass; def OPTIONS(self, *args, **kwargs): enable_crossdomain(); ''' main code start. ''' # donot support use this module as library. if __name__ != "__main__": raise Exception("embed not support") # check the user options if len(sys.argv) <= 1: print "SRS community server, Copyright (c) 2013-2014 winlin" print "Usage: python %s <port>"%(sys.argv[0]) print " port: the port to listen at." print "For example:" print " python %s 1949"%(sys.argv[0]) print "" print "See also: https://github.com/winlinvip/simple-rtmp-server" sys.exit(1) # parse port from user options. port = int(sys.argv[1]) static_dir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "static-dir")) trace("api server listen at port: %s, static_dir: %s"%(port, static_dir)) # cherrypy config. conf = { 'global': { 'server.shutdown_timeout': 1, 'server.socket_host': '0.0.0.0', 'server.socket_port': port, 'tools.encode.on': True, 'tools.staticdir.on': True, 'tools.encode.encoding': "utf-8", #'server.thread_pool': 2, # single thread server. }, '/': { 'tools.staticdir.dir': static_dir, 'tools.staticdir.index': "index.html", # for cherrypy RESTful api support 'request.dispatch': cherrypy.dispatch.MethodDispatcher() } } # start cherrypy web engine trace("start cherrypy server") root = Root() cherrypy.quickstart(root, '/', conf)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 2344, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6171, 13, 7280, 4747, 472, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 199, 3749, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 199, 1589, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 199, 1180, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 199, 1589, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 199, 5875, 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, 3092, 199, 2707, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 199, 32324, 5716, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 199, 568, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 18389, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 2344, 199, 199, 624, 199, 1589, 23633, 365, 282, 849, 14779, 1654, 367, 16191, 199, 624, 199, 199, 646, 984, 199, 3, 13101, 984, 1402, 370, 4756, 314, 664, 27205, 28139, 1083, 14, 199, 9233, 8, 1274, 9, 199, 3, 663, 314, 849, 2644, 370, 2774, 13, 24, 199, 3, 1808, 2146, 370, 663, 314, 2644, 12, 370, 5126, 1125, 315, 473, 1093, 14, 199, 1628, 480, 1274, 14, 409, 27205, 28139, 360, 1624, 13, 24, 26530, 199, 479, 984, 14, 362, 27205, 28139, 1252, 2325, 342, 508, 298, 1624, 13, 24, 2, 199, 199, 646, 747, 12, 2022, 12, 900, 12, 2197, 12, 13397, 12, 5796, 199, 199, 3, 3486, 943, 3423, 14, 199, 318, 3307, 8, 1328, 304, 272, 1434, 275, 2197, 14, 2083, 14, 2131, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 272, 870, 26503, 83, 1527, 3446, 61, 450, 83, 14007, 602, 12, 1499, 9, 199, 199, 3, 4756, 8059, 2261, 2879, 367, 8586, 13, 1258, 199, 3, 5627, 314, 2569, 1083, 26, 199, 3, 257, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 199, 3, 755, 4756, 63, 7925, 2261, 342, 199, 3, 12677, 642, 1083, 370, 4756, 8586, 370, 1056, 8059, 2261, 14, 199, 318, 4756, 63, 7925, 2261, 837, 272, 13397, 14, 1310, 14, 2139, 905, 3946, 13, 3717, 13, 7852, 13, 12834, 937, 275, 22423, 272, 13397, 14, 1310, 14, 2139, 905, 3946, 13, 3717, 13, 7852, 13, 10385, 937, 275, 298, 2970, 12, 8761, 12, 13053, 12, 18337, 12, 15137, 2, 272, 327, 3550, 2040, 2323, 367, 8059, 2261, 14, 272, 2040, 63, 2139, 275, 2097, 4437, 13, 3717, 401, 298, 56, 13, 4936, 13, 11626, 401, 298, 56, 13, 17935, 13, 3007, 401, 298, 2714, 13, 804, 937, 272, 13397, 14, 1310, 14, 2139, 905, 3946, 13, 3717, 13, 7852, 13, 9883, 937, 275, 19089, 904, 8, 3306, 63, 2139, 9, 199, 199, 3, 1125, 9479, 5492, 199, 533, 4520, 26, 272, 327, 4112, 12, 3182, 12, 9709, 14, 272, 3182, 275, 378, 199, 199, 3, 3101, 14880, 1893, 931, 14, 199, 533, 12826, 8, 785, 304, 272, 19282, 275, 715, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1246, 275, 13986, 342, 272, 347, 9576, 8, 277, 304, 267, 4756, 63, 7925, 2261, 7303, 267, 372, 2022, 14, 4180, 6333, 600, 582, 547, 14, 3742, 12, 298, 3603, 18517, 1246, 5122, 1589, 2986, 1738, 3570, 1552, 272, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 4756, 63, 7925, 2261, 7303, 199, 3, 3101, 14880, 1893, 931, 14, 199, 533, 13986, 8, 785, 304, 272, 19282, 275, 715, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 86, 17, 275, 812, 17, 342, 272, 347, 9576, 8, 277, 304, 267, 4756, 63, 7925, 2261, 7303, 267, 372, 2022, 14, 4180, 6333, 600, 582, 547, 14, 3742, 12, 7205, 298, 3603, 582, 469, 355, 298, 86, 17, 582, 298, 1589, 2986, 1015, 413, 14, 16, 2, 288, 789, 267, 789, 2736, 272, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 4756, 63, 7925, 2261, 7303, 199, 3, 3101, 14880, 1893, 931, 14, 370, 2879, 465, 26, 199, 3, 257, 1455, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1257, 2426, 15, 1246, 15, 86, 17, 15, 14555, 199, 533, 812, 17, 8, 785, 304, 272, 19282, 275, 715, 339, 347, 636, 826, 721, 277, 304, 267, 986, 27, 272, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 4756, 63, 7925, 2261, 7303, 199, 199, 2344, 199, 973, 1233, 1343, 14, 199, 2344, 199, 3, 2793, 357, 2291, 675, 642, 859, 465, 3555, 14, 199, 692, 636, 354, 363, 1137, 4396, 973, 5727, 272, 746, 2186, 480, 6427, 440, 2291, 531, 199, 199, 3, 1104, 314, 922, 1511, 199, 692, 822, 8, 1274, 14, 3020, 9, 2695, 413, 26, 272, 870, 298, 5943, 51, 23633, 1654, 12, 1898, 334, 67, 9, 6171, 13, 7280, 4747, 472, 2, 272, 870, 298, 7692, 26, 2366, 450, 83, 665, 719, 4335, 2840, 1274, 14, 3020, 59, 16, 566, 272, 870, 298, 259, 1844, 26, 314, 1844, 370, 6938, 737, 2122, 272, 870, 298, 1858, 2893, 5424, 272, 870, 298, 259, 2366, 450, 83, 5851, 1887, 14007, 1274, 14, 3020, 59, 16, 566, 272, 870, 3087, 272, 870, 298, 9295, 2597, 26, 4178, 921, 5031, 14, 957, 15, 2676, 472, 18607, 15, 4129, 13, 29649, 13, 1000, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 2198, 1844, 687, 922, 1511, 14, 199, 719, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 1986, 63, 694, 275, 747, 14, 515, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 2344, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 7384, 334, 67, 9, 6171, 13, 7280, 4747, 472, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 402, 199, 3749, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 199, 1589, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 199, 1180, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 199, 1589, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 199, 5875, 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, 3092, 199, 2707, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 199, 32324, 5716, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 199, 568, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 18389, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 2344, 199, 199, 624, 199, 1589, 23633, 365, 282, 849, 14779, 1654, 367, 16191, 199, 624, 199, 199, 646, 984, 199, 3, 13101, 984, 1402, 370, 4756, 314, 664, 27205, 28139, 1083, 14, 199, 9233, 8, 1274, 9, 199, 3, 663, 314, 849, 2644, 370, 2774, 13, 24, 199, 3, 1808, 2146, 370, 663, 314, 2644, 12, 370, 5126, 1125, 315, 473, 1093, 14, 199, 1628, 480, 1274, 14, 409, 27205, 28139, 360, 1624, 13, 24, 26530, 199, 479, 984, 14, 362, 27205, 28139, 1252, 2325, 342, 508, 298, 1624, 13, 24, 2, 199, 199, 646, 747, 12, 2022, 12, 900, 12, 2197, 12, 13397, 12, 5796, 199, 199, 3, 3486, 943, 3423, 14, 199, 318, 3307, 8, 1328, 304, 272, 1434, 275, 2197, 14, 2083, 14, 2131, 1252, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 272, 870, 26503, 83, 1527, 3446, 61, 450, 83, 14007, 602, 12, 1499, 9, 199, 199, 3, 4756, 8059, 2261, 2879, 367, 8586, 13, 1258, 199, 3, 5627, 314, 2569, 1083, 26, 199, 3, 257, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 199, 3, 755, 4756, 63, 7925, 2261, 342, 199, 3, 12677, 642, 1083, 370, 4756, 8586, 370, 1056, 8059, 2261, 14, 199, 318, 4756, 63, 7925, 2261, 837, 272, 13397, 14, 1310, 14, 2139, 905, 3946, 13, 3717, 13, 7852, 13, 12834, 937, 275, 22423, 272, 13397, 14, 1310, 14, 2139, 905, 3946, 13, 3717, 13, 7852, 13, 10385, 937, 275, 298, 2970, 12, 8761, 12, 13053, 12, 18337, 12, 15137, 2, 272, 327, 3550, 2040, 2323, 367, 8059, 2261, 14, 272, 2040, 63, 2139, 275, 2097, 4437, 13, 3717, 401, 298, 56, 13, 4936, 13, 11626, 401, 298, 56, 13, 17935, 13, 3007, 401, 298, 2714, 13, 804, 937, 272, 13397, 14, 1310, 14, 2139, 905, 3946, 13, 3717, 13, 7852, 13, 9883, 937, 275, 19089, 904, 8, 3306, 63, 2139, 9, 199, 199, 3, 1125, 9479, 5492, 199, 533, 4520, 26, 272, 327, 4112, 12, 3182, 12, 9709, 14, 272, 3182, 275, 378, 199, 199, 3, 3101, 14880, 1893, 931, 14, 199, 533, 12826, 8, 785, 304, 272, 19282, 275, 715, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1246, 275, 13986, 342, 272, 347, 9576, 8, 277, 304, 267, 4756, 63, 7925, 2261, 7303, 267, 372, 2022, 14, 4180, 6333, 600, 582, 547, 14, 3742, 12, 298, 3603, 18517, 1246, 5122, 1589, 2986, 1738, 3570, 1552, 272, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 4756, 63, 7925, 2261, 7303, 199, 3, 3101, 14880, 1893, 931, 14, 199, 533, 13986, 8, 785, 304, 272, 19282, 275, 715, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 86, 17, 275, 812, 17, 342, 272, 347, 9576, 8, 277, 304, 267, 4756, 63, 7925, 2261, 7303, 267, 372, 2022, 14, 4180, 6333, 600, 582, 547, 14, 3742, 12, 7205, 298, 3603, 582, 469, 355, 298, 86, 17, 582, 298, 1589, 2986, 1015, 413, 14, 16, 2, 288, 789, 267, 789, 2736, 272, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 4756, 63, 7925, 2261, 7303, 199, 3, 3101, 14880, 1893, 931, 14, 370, 2879, 465, 26, 199, 3, 257, 1455, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1257, 2426, 15, 1246, 15, 86, 17, 15, 14555, 199, 533, 812, 17, 8, 785, 304, 272, 19282, 275, 715, 339, 347, 636, 826, 721, 277, 304, 267, 986, 27, 272, 347, 23860, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 4756, 63, 7925, 2261, 7303, 199, 199, 2344, 199, 973, 1233, 1343, 14, 199, 2344, 199, 3, 2793, 357, 2291, 675, 642, 859, 465, 3555, 14, 199, 692, 636, 354, 363, 1137, 4396, 973, 5727, 272, 746, 2186, 480, 6427, 440, 2291, 531, 199, 199, 3, 1104, 314, 922, 1511, 199, 692, 822, 8, 1274, 14, 3020, 9, 2695, 413, 26, 272, 870, 298, 5943, 51, 23633, 1654, 12, 1898, 334, 67, 9, 6171, 13, 7280, 4747, 472, 2, 272, 870, 298, 7692, 26, 2366, 450, 83, 665, 719, 4335, 2840, 1274, 14, 3020, 59, 16, 566, 272, 870, 298, 259, 1844, 26, 314, 1844, 370, 6938, 737, 2122, 272, 870, 298, 1858, 2893, 5424, 272, 870, 298, 259, 2366, 450, 83, 5851, 1887, 14007, 1274, 14, 3020, 59, 16, 566, 272, 870, 3087, 272, 870, 298, 9295, 2597, 26, 4178, 921, 5031, 14, 957, 15, 2676, 472, 18607, 15, 4129, 13, 29649, 13, 1000, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 3, 2198, 1844, 687, 922, 1511, 14, 199, 719, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 1986, 63, 694, 275, 747, 14, 515, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
golya/FuzzLabs
engine/tests/steps/modules.py
1
1961
from behave import * import os import sys import inspect ROOT_DIR = os.path.dirname( os.path.abspath( inspect.getfile(inspect.currentframe() ))) sys.path.append(ROOT_DIR + "/../../classes") from ConfigurationHandler import ConfigurationHandler from ModuleHandler import ModuleHandler @given('we have root and config') def step_impl(context): assert os.path.isfile(ROOT_DIR + "/../../etc/engine.config") context.root = ROOT_DIR + "/../../" config_file = ROOT_DIR + "/../../etc/engine.config" context.config_data = ConfigurationHandler(config_file).get() @when('we load the modules') def step_impl(context): context.module_inst = ModuleHandler(context.root, context.config_data) context.modules_list = context.module_inst.loaded_modules @then('we get a list of modules') def step_impl(context): status = type(context.modules_list) == list if status: for module in context.modules_list: if not module.get('instance') or \ not module.get('name') or \ not module.get('mtime') or \ not module.get('type'): status = False break context.module_inst.unload_modules() assert status @given('we have modules loaded') def step_impl(context): assert os.path.isfile(ROOT_DIR + "/../../etc/engine.config") root_dir = ROOT_DIR + "/../../" config_file = ROOT_DIR + "/../../etc/engine.config" config_data = ConfigurationHandler(config_file).get() context.module_inst = ModuleHandler(root_dir, config_data) context.modules_list = context.module_inst.loaded_modules status = type(context.modules_list) == list assert status @when('we unload the modules') def step_impl(context): context.module_inst.unload_modules() @then('we get an empty list') def step_impl(context): assert context.module_inst.loaded_modules == []
gpl-2.0
[ 504, 24062, 492, 627, 199, 646, 747, 199, 646, 984, 199, 646, 6485, 199, 199, 5441, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 355, 747, 14, 515, 14, 4832, 8, 490, 6485, 14, 23462, 8, 10955, 14, 1818, 1943, 342, 355, 23183, 199, 199, 1274, 14, 515, 14, 740, 8, 5441, 63, 3022, 435, 3286, 9707, 2888, 531, 199, 504, 11595, 2461, 492, 11595, 2461, 199, 504, 5673, 2461, 492, 5673, 2461, 199, 199, 32, 11809, 360, 1129, 1172, 1738, 436, 1101, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 702, 747, 14, 515, 14, 6292, 8, 5441, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 531, 272, 1067, 14, 1231, 263, 275, 16547, 63, 3022, 435, 3286, 9707, 2, 272, 1101, 63, 493, 260, 275, 16547, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 2, 272, 1067, 14, 888, 63, 576, 275, 11595, 2461, 8, 888, 63, 493, 680, 362, 342, 199, 199, 32, 6526, 360, 1129, 2248, 314, 4621, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 1067, 14, 578, 63, 3615, 275, 5673, 2461, 8, 1100, 14, 1231, 12, 1067, 14, 888, 63, 576, 9, 272, 1067, 14, 3112, 63, 513, 275, 1067, 14, 578, 63, 3615, 14, 4591, 63, 3112, 199, 199, 32, 12726, 360, 1129, 664, 282, 769, 402, 4621, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 2004, 275, 730, 8, 1100, 14, 3112, 63, 513, 9, 508, 769, 339, 340, 2004, 26, 267, 367, 859, 315, 1067, 14, 3112, 63, 513, 26, 288, 340, 440, 859, 14, 362, 360, 842, 358, 503, 971, 2049, 440, 859, 14, 362, 360, 354, 358, 503, 971, 2049, 440, 859, 14, 362, 360, 8180, 358, 503, 971, 2049, 440, 859, 14, 362, 360, 466, 735, 355, 2004, 275, 756, 355, 2059, 339, 1067, 14, 578, 63, 3615, 14, 25477, 63, 3112, 342, 272, 702, 2004, 4388, 199, 32, 11809, 360, 1129, 1172, 4621, 6511, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 702, 747, 14, 515, 14, 6292, 8, 5441, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 531, 272, 1738, 63, 694, 258, 275, 16547, 63, 3022, 435, 3286, 9707, 2, 272, 1101, 63, 493, 221, 275, 16547, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 2, 272, 1101, 63, 576, 221, 275, 11595, 2461, 8, 888, 63, 493, 680, 362, 342, 272, 1067, 14, 578, 63, 3615, 275, 5673, 2461, 8, 1231, 63, 694, 12, 1101, 63, 576, 9, 272, 1067, 14, 3112, 63, 513, 275, 1067, 14, 578, 63, 3615, 14, 4591, 63, 3112, 339, 2004, 275, 730, 8, 1100, 14, 3112, 63, 513, 9, 508, 769, 272, 702, 2004, 199, 199, 32, 6526, 360, 1129, 625, 912, 314, 4621, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 1067, 14, 578, 63, 3615, 14, 25477, 63, 3112, 342, 199, 199, 32, 12726, 360, 1129, 664, 376, 2701, 769, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 702, 1067, 14, 578, 63, 3615, 14, 4591, 63, 3112, 508, 942, 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 ]
[ 24062, 492, 627, 199, 646, 747, 199, 646, 984, 199, 646, 6485, 199, 199, 5441, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 355, 747, 14, 515, 14, 4832, 8, 490, 6485, 14, 23462, 8, 10955, 14, 1818, 1943, 342, 355, 23183, 199, 199, 1274, 14, 515, 14, 740, 8, 5441, 63, 3022, 435, 3286, 9707, 2888, 531, 199, 504, 11595, 2461, 492, 11595, 2461, 199, 504, 5673, 2461, 492, 5673, 2461, 199, 199, 32, 11809, 360, 1129, 1172, 1738, 436, 1101, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 702, 747, 14, 515, 14, 6292, 8, 5441, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 531, 272, 1067, 14, 1231, 263, 275, 16547, 63, 3022, 435, 3286, 9707, 2, 272, 1101, 63, 493, 260, 275, 16547, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 2, 272, 1067, 14, 888, 63, 576, 275, 11595, 2461, 8, 888, 63, 493, 680, 362, 342, 199, 199, 32, 6526, 360, 1129, 2248, 314, 4621, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 1067, 14, 578, 63, 3615, 275, 5673, 2461, 8, 1100, 14, 1231, 12, 1067, 14, 888, 63, 576, 9, 272, 1067, 14, 3112, 63, 513, 275, 1067, 14, 578, 63, 3615, 14, 4591, 63, 3112, 199, 199, 32, 12726, 360, 1129, 664, 282, 769, 402, 4621, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 2004, 275, 730, 8, 1100, 14, 3112, 63, 513, 9, 508, 769, 339, 340, 2004, 26, 267, 367, 859, 315, 1067, 14, 3112, 63, 513, 26, 288, 340, 440, 859, 14, 362, 360, 842, 358, 503, 971, 2049, 440, 859, 14, 362, 360, 354, 358, 503, 971, 2049, 440, 859, 14, 362, 360, 8180, 358, 503, 971, 2049, 440, 859, 14, 362, 360, 466, 735, 355, 2004, 275, 756, 355, 2059, 339, 1067, 14, 578, 63, 3615, 14, 25477, 63, 3112, 342, 272, 702, 2004, 4388, 199, 32, 11809, 360, 1129, 1172, 4621, 6511, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 702, 747, 14, 515, 14, 6292, 8, 5441, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 531, 272, 1738, 63, 694, 258, 275, 16547, 63, 3022, 435, 3286, 9707, 2, 272, 1101, 63, 493, 221, 275, 16547, 63, 3022, 435, 3286, 9707, 6839, 15, 3908, 14, 888, 2, 272, 1101, 63, 576, 221, 275, 11595, 2461, 8, 888, 63, 493, 680, 362, 342, 272, 1067, 14, 578, 63, 3615, 275, 5673, 2461, 8, 1231, 63, 694, 12, 1101, 63, 576, 9, 272, 1067, 14, 3112, 63, 513, 275, 1067, 14, 578, 63, 3615, 14, 4591, 63, 3112, 339, 2004, 275, 730, 8, 1100, 14, 3112, 63, 513, 9, 508, 769, 272, 702, 2004, 199, 199, 32, 6526, 360, 1129, 625, 912, 314, 4621, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 1067, 14, 578, 63, 3615, 14, 25477, 63, 3112, 342, 199, 199, 32, 12726, 360, 1129, 664, 376, 2701, 769, 358, 199, 318, 3650, 63, 5472, 8, 1100, 304, 272, 702, 1067, 14, 578, 63, 3615, 14, 4591, 63, 3112, 508, 942, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mtnsat/ansible-cmdb
lib/mako/exceptions.py
60
12406
# mako/exceptions.py # Copyright (C) 2006-2015 the Mako authors and contributors <see AUTHORS file> # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """exception classes""" import traceback import sys from mako import util, compat class MakoException(Exception): pass class RuntimeException(MakoException): pass def _format_filepos(lineno, pos, filename): if filename is None: return " at line: %d char: %d" % (lineno, pos) else: return " in file '%s' at line: %d char: %d" % (filename, lineno, pos) class CompileException(MakoException): def __init__(self, message, source, lineno, pos, filename): MakoException.__init__(self, message + _format_filepos(lineno, pos, filename)) self.lineno = lineno self.pos = pos self.filename = filename self.source = source class SyntaxException(MakoException): def __init__(self, message, source, lineno, pos, filename): MakoException.__init__(self, message + _format_filepos(lineno, pos, filename)) self.lineno = lineno self.pos = pos self.filename = filename self.source = source class UnsupportedError(MakoException): """raised when a retired feature is used.""" class NameConflictError(MakoException): """raised when a reserved word is used inappropriately""" class TemplateLookupException(MakoException): pass class TopLevelLookupException(TemplateLookupException): pass class RichTraceback(object): """Pull the current exception from the ``sys`` traceback and extracts Mako-specific template information. See the usage examples in :ref:`handling_exceptions`. """ def __init__(self, error=None, traceback=None): self.source, self.lineno = "", 0 if error is None or traceback is None: t, value, tback = sys.exc_info() if error is None: error = value or t if traceback is None: traceback = tback self.error = error self.records = self._init(traceback) if isinstance(self.error, (CompileException, SyntaxException)): self.source = self.error.source self.lineno = self.error.lineno self._has_source = True self._init_message() @property def errorname(self): return compat.exception_name(self.error) def _init_message(self): """Find a unicode representation of self.error""" try: self.message = compat.text_type(self.error) except UnicodeError: try: self.message = str(self.error) except UnicodeEncodeError: # Fallback to args as neither unicode nor # str(Exception(u'\xe6')) work in Python < 2.6 self.message = self.error.args[0] if not isinstance(self.message, compat.text_type): self.message = compat.text_type(self.message, 'ascii', 'replace') def _get_reformatted_records(self, records): for rec in records: if rec[6] is not None: yield (rec[4], rec[5], rec[2], rec[6]) else: yield tuple(rec[0:4]) @property def traceback(self): """Return a list of 4-tuple traceback records (i.e. normal python format) with template-corresponding lines remapped to the originating template. """ return list(self._get_reformatted_records(self.records)) @property def reverse_records(self): return reversed(self.records) @property def reverse_traceback(self): """Return the same data as traceback, except in reverse order. """ return list(self._get_reformatted_records(self.reverse_records)) def _init(self, trcback): """format a traceback from sys.exc_info() into 7-item tuples, containing the regular four traceback tuple items, plus the original template filename, the line number adjusted relative to the template source, and code line from that line number of the template.""" import mako.template mods = {} rawrecords = traceback.extract_tb(trcback) new_trcback = [] for filename, lineno, function, line in rawrecords: if not line: line = '' try: (line_map, template_lines) = mods[filename] except KeyError: try: info = mako.template._get_module_info(filename) module_source = info.code template_source = info.source template_filename = info.template_filename or filename except KeyError: # A normal .py file (not a Template) if not compat.py3k: try: fp = open(filename, 'rb') encoding = util.parse_encoding(fp) fp.close() except IOError: encoding = None if encoding: line = line.decode(encoding) else: line = line.decode('ascii', 'replace') new_trcback.append((filename, lineno, function, line, None, None, None, None)) continue template_ln = 1 source_map = mako.template.ModuleInfo.\ get_module_source_metadata( module_source, full_line_map=True) line_map = source_map['full_line_map'] template_lines = [line for line in template_source.split("\n")] mods[filename] = (line_map, template_lines) template_ln = line_map[lineno - 1] if template_ln <= len(template_lines): template_line = template_lines[template_ln - 1] else: template_line = None new_trcback.append((filename, lineno, function, line, template_filename, template_ln, template_line, template_source)) if not self.source: for l in range(len(new_trcback) - 1, 0, -1): if new_trcback[l][5]: self.source = new_trcback[l][7] self.lineno = new_trcback[l][5] break else: if new_trcback: try: # A normal .py file (not a Template) fp = open(new_trcback[-1][0], 'rb') encoding = util.parse_encoding(fp) fp.seek(0) self.source = fp.read() fp.close() if encoding: self.source = self.source.decode(encoding) except IOError: self.source = '' self.lineno = new_trcback[-1][1] return new_trcback def text_error_template(lookup=None): """Provides a template that renders a stack trace in a similar format to the Python interpreter, substituting source template filenames, line numbers and code for that of the originating source template, as applicable. """ import mako.template return mako.template.Template(r""" <%page args="error=None, traceback=None"/> <%! from mako.exceptions import RichTraceback %>\ <% tback = RichTraceback(error=error, traceback=traceback) %>\ Traceback (most recent call last): % for (filename, lineno, function, line) in tback.traceback: File "${filename}", line ${lineno}, in ${function or '?'} ${line | trim} % endfor ${tback.errorname}: ${tback.message} """) def _install_pygments(): global syntax_highlight, pygments_html_formatter from mako.ext.pygmentplugin import syntax_highlight,\ pygments_html_formatter def _install_fallback(): global syntax_highlight, pygments_html_formatter from mako.filters import html_escape pygments_html_formatter = None def syntax_highlight(filename='', language=None): return html_escape def _install_highlighting(): try: _install_pygments() except ImportError: _install_fallback() _install_highlighting() def html_error_template(): """Provides a template that renders a stack trace in an HTML format, providing an excerpt of code as well as substituting source template filenames, line numbers and code for that of the originating source template, as applicable. The template's default ``encoding_errors`` value is ``'htmlentityreplace'``. The template has two options. With the ``full`` option disabled, only a section of an HTML document is returned. With the ``css`` option disabled, the default stylesheet won't be included. """ import mako.template return mako.template.Template(r""" <%! from mako.exceptions import RichTraceback, syntax_highlight,\ pygments_html_formatter %> <%page args="full=True, css=True, error=None, traceback=None"/> % if full: <html> <head> <title>Mako Runtime Error</title> % endif % if css: <style> body { font-family:verdana; margin:10px 30px 10px 30px;} .stacktrace { margin:5px 5px 5px 5px; } .highlight { padding:0px 10px 0px 10px; background-color:#9F9FDF; } .nonhighlight { padding:0px; background-color:#DFDFDF; } .sample { padding:10px; margin:10px 10px 10px 10px; font-family:monospace; } .sampleline { padding:0px 10px 0px 10px; } .sourceline { margin:5px 5px 10px 5px; font-family:monospace;} .location { font-size:80%; } .highlight { white-space:pre; } .sampleline { white-space:pre; } % if pygments_html_formatter: ${pygments_html_formatter.get_style_defs()} .linenos { min-width: 2.5em; text-align: right; } pre { margin: 0; } .syntax-highlighted { padding: 0 10px; } .syntax-highlightedtable { border-spacing: 1px; } .nonhighlight { border-top: 1px solid #DFDFDF; border-bottom: 1px solid #DFDFDF; } .stacktrace .nonhighlight { margin: 5px 15px 10px; } .sourceline { margin: 0 0; font-family:monospace; } .code { background-color: #F8F8F8; width: 100%; } .error .code { background-color: #FFBDBD; } .error .syntax-highlighted { background-color: #FFBDBD; } % endif </style> % endif % if full: </head> <body> % endif <h2>Error !</h2> <% tback = RichTraceback(error=error, traceback=traceback) src = tback.source line = tback.lineno if src: lines = src.split('\n') else: lines = None %> <h3>${tback.errorname}: ${tback.message|h}</h3> % if lines: <div class="sample"> <div class="nonhighlight"> % for index in range(max(0, line-4),min(len(lines), line+5)): <% if pygments_html_formatter: pygments_html_formatter.linenostart = index + 1 %> % if index + 1 == line: <% if pygments_html_formatter: old_cssclass = pygments_html_formatter.cssclass pygments_html_formatter.cssclass = 'error ' + old_cssclass %> ${lines[index] | syntax_highlight(language='mako')} <% if pygments_html_formatter: pygments_html_formatter.cssclass = old_cssclass %> % else: ${lines[index] | syntax_highlight(language='mako')} % endif % endfor </div> </div> % endif <div class="stacktrace"> % for (filename, lineno, function, line) in tback.reverse_traceback: <div class="location">${filename}, line ${lineno}:</div> <div class="nonhighlight"> <% if pygments_html_formatter: pygments_html_formatter.linenostart = lineno %> <div class="sourceline">${line | syntax_highlight(filename)}</div> </div> % endfor </div> % if full: </body> </html> % endif """, output_encoding=sys.getdefaultencoding(), encoding_errors='htmlentityreplace')
gpl-3.0
[ 3, 26834, 15, 3924, 14, 647, 199, 3, 1898, 334, 35, 9, 8315, 13, 7806, 314, 603, 23564, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 603, 23564, 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, 1971, 3992, 624, 199, 199, 646, 5190, 199, 646, 984, 199, 504, 26834, 492, 4884, 12, 8434, 199, 199, 533, 603, 23564, 1726, 8, 1726, 304, 272, 986, 199, 199, 533, 19103, 1726, 8, 45, 23564, 1726, 304, 272, 986, 199, 199, 318, 485, 908, 63, 493, 1712, 8, 3469, 12, 2086, 12, 1788, 304, 272, 340, 1788, 365, 488, 26, 267, 372, 298, 737, 1004, 26, 450, 68, 1495, 26, 450, 68, 2, 450, 334, 3469, 12, 2086, 9, 272, 587, 26, 267, 372, 298, 315, 570, 1543, 83, 7, 737, 1004, 26, 450, 68, 1495, 26, 450, 68, 2, 450, 334, 1501, 12, 5874, 12, 2086, 9, 421, 199, 533, 24562, 1726, 8, 45, 23564, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1350, 12, 5874, 12, 2086, 12, 1788, 304, 267, 603, 23564, 1726, 855, 826, 721, 277, 12, 2892, 1245, 435, 485, 908, 63, 493, 1712, 8, 3469, 12, 2086, 12, 1788, 430, 267, 291, 14, 3469, 275, 5874, 267, 291, 14, 1712, 275, 2086, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 1365, 275, 1350, 199, 199, 533, 18377, 1726, 8, 45, 23564, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1350, 12, 5874, 12, 2086, 12, 1788, 304, 267, 603, 23564, 1726, 855, 826, 721, 277, 12, 2892, 1245, 435, 485, 908, 63, 493, 1712, 8, 3469, 12, 2086, 12, 1788, 430, 267, 291, 14, 3469, 275, 5874, 267, 291, 14, 1712, 275, 2086, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 1365, 275, 1350, 199, 199, 533, 19022, 547, 8, 45, 23564, 1726, 304, 272, 408, 21597, 1380, 282, 295, 280, 581, 3878, 365, 1202, 1041, 199, 199, 533, 2812, 15919, 547, 8, 45, 23564, 1726, 304, 272, 408, 21597, 1380, 282, 4644, 4349, 365, 1202, 315, 11227, 5655, 590, 624, 199, 199, 533, 5458, 7521, 1726, 8, 45, 23564, 1726, 304, 272, 986, 199, 199, 533, 14132, 4670, 7521, 1726, 8, 4231, 7521, 1726, 304, 272, 986, 199, 199, 533, 30846, 15905, 8, 785, 304, 272, 408, 27318, 314, 1453, 1919, 687, 314, 1124, 1274, 1040, 5190, 436, 5536, 83, 272, 603, 23564, 13, 6100, 1978, 2556, 14, 339, 1666, 314, 4503, 7251, 315, 520, 1121, 1705, 22273, 63, 3924, 2313, 339, 408, 272, 347, 636, 826, 721, 277, 12, 1125, 29, 403, 12, 5190, 29, 403, 304, 267, 291, 14, 1365, 12, 291, 14, 3469, 275, 4873, 378, 398, 340, 1125, 365, 488, 503, 5190, 365, 488, 26, 288, 307, 12, 574, 12, 307, 894, 275, 984, 14, 2804, 63, 815, 342, 398, 340, 1125, 365, 488, 26, 288, 1125, 275, 574, 503, 307, 398, 340, 5190, 365, 488, 26, 288, 5190, 275, 307, 894, 398, 291, 14, 705, 275, 1125, 267, 291, 14, 6502, 275, 291, 423, 826, 8, 6894, 9, 398, 340, 1228, 8, 277, 14, 705, 12, 334, 12626, 1726, 12, 18377, 1726, 2298, 288, 291, 14, 1365, 275, 291, 14, 705, 14, 1365, 288, 291, 14, 3469, 275, 291, 14, 705, 14, 3469, 288, 291, 423, 1989, 63, 1365, 275, 715, 398, 291, 423, 826, 63, 1188, 342, 339, 768, 1829, 272, 347, 1125, 354, 8, 277, 304, 267, 372, 8434, 14, 1971, 63, 354, 8, 277, 14, 705, 9, 339, 347, 485, 826, 63, 1188, 8, 277, 304, 267, 408, 6591, 282, 2649, 6025, 402, 291, 14, 705, 624, 267, 862, 26, 288, 291, 14, 1188, 275, 8434, 14, 505, 63, 466, 8, 277, 14, 705, 9, 267, 871, 20872, 26, 288, 862, 26, 355, 291, 14, 1188, 275, 620, 8, 277, 14, 705, 9, 288, 871, 24094, 26, 355, 327, 481, 5421, 370, 1249, 465, 15564, 2649, 6590, 355, 327, 620, 8, 1726, 8, 85, 1154, 1845, 22, 1333, 1736, 315, 2018, 665, 499, 14, 22, 355, 291, 14, 1188, 275, 291, 14, 705, 14, 589, 59, 16, 61, 267, 340, 440, 1228, 8, 277, 14, 1188, 12, 8434, 14, 505, 63, 466, 304, 288, 291, 14, 1188, 275, 8434, 14, 505, 63, 466, 8, 277, 14, 1188, 12, 283, 4371, 297, 283, 1814, 358, 339, 347, 485, 362, 63, 264, 15317, 63, 6502, 8, 277, 12, 5767, 304, 267, 367, 6488, 315, 5767, 26, 288, 340, 6488, 59, 22, 61, 365, 440, 488, 26, 355, 1995, 334, 2761, 59, 20, 467, 6488, 59, 21, 467, 6488, 59, 18, 467, 6488, 59, 22, 566, 288, 587, 26, 355, 1995, 2008, 8, 2761, 59, 16, 26, 20, 566, 339, 768, 1829, 272, 347, 5190, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 841, 13, 2960, 5190, 5767, 334, 73, 14, 69, 14, 3293, 2366, 267, 1475, 9, 543, 1978, 13, 989, 31137, 2385, 295, 11663, 370, 314, 6330, 1958, 267, 1978, 14, 398, 408, 267, 372, 769, 8, 277, 423, 362, 63, 264, 15317, 63, 6502, 8, 277, 14, 6502, 430, 339, 768, 1829, 272, 347, 3837, 63, 6502, 8, 277, 304, 267, 372, 10822, 8, 277, 14, 6502, 9, 339, 768, 1829, 272, 347, 3837, 63, 6894, 8, 277, 304, 267, 408, 1767, 314, 2011, 666, 465, 5190, 12, 871, 315, 3837, 1865, 14, 267, 408, 398, 372, 769, 8, 277, 423, 362, 63, 264, 15317, 63, 6502, 8, 277, 14, 4471, 63, 6502, 430, 339, 347, 485, 826, 8, 277, 12, 307, 1195, 894, 304, 267, 408, 908, 282, 5190, 687, 984, 14, 2804, 63, 815, 342, 1901, 1520, 13, 1053, 6346, 12, 267, 3035, 314, 5578, 11648, 5190, 2008, 2974, 12, 12254, 314, 3379, 267, 1978, 1788, 12, 314, 1004, 1329, 19477, 3847, 370, 314, 1978, 267, 1350, 12, 436, 1233, 1004, 687, 626, 1004, 1329, 402, 314, 1978, 1041, 398, 492, 26834, 14, 1160, 267, 24496, 275, 1052, 267, 3066, 6502, 275, 5190, 14, 5005, 63, 5842, 8, 454, 67, 894, 9 ]
[ 26834, 15, 3924, 14, 647, 199, 3, 1898, 334, 35, 9, 8315, 13, 7806, 314, 603, 23564, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 603, 23564, 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, 1971, 3992, 624, 199, 199, 646, 5190, 199, 646, 984, 199, 504, 26834, 492, 4884, 12, 8434, 199, 199, 533, 603, 23564, 1726, 8, 1726, 304, 272, 986, 199, 199, 533, 19103, 1726, 8, 45, 23564, 1726, 304, 272, 986, 199, 199, 318, 485, 908, 63, 493, 1712, 8, 3469, 12, 2086, 12, 1788, 304, 272, 340, 1788, 365, 488, 26, 267, 372, 298, 737, 1004, 26, 450, 68, 1495, 26, 450, 68, 2, 450, 334, 3469, 12, 2086, 9, 272, 587, 26, 267, 372, 298, 315, 570, 1543, 83, 7, 737, 1004, 26, 450, 68, 1495, 26, 450, 68, 2, 450, 334, 1501, 12, 5874, 12, 2086, 9, 421, 199, 533, 24562, 1726, 8, 45, 23564, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1350, 12, 5874, 12, 2086, 12, 1788, 304, 267, 603, 23564, 1726, 855, 826, 721, 277, 12, 2892, 1245, 435, 485, 908, 63, 493, 1712, 8, 3469, 12, 2086, 12, 1788, 430, 267, 291, 14, 3469, 275, 5874, 267, 291, 14, 1712, 275, 2086, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 1365, 275, 1350, 199, 199, 533, 18377, 1726, 8, 45, 23564, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1350, 12, 5874, 12, 2086, 12, 1788, 304, 267, 603, 23564, 1726, 855, 826, 721, 277, 12, 2892, 1245, 435, 485, 908, 63, 493, 1712, 8, 3469, 12, 2086, 12, 1788, 430, 267, 291, 14, 3469, 275, 5874, 267, 291, 14, 1712, 275, 2086, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 1365, 275, 1350, 199, 199, 533, 19022, 547, 8, 45, 23564, 1726, 304, 272, 408, 21597, 1380, 282, 295, 280, 581, 3878, 365, 1202, 1041, 199, 199, 533, 2812, 15919, 547, 8, 45, 23564, 1726, 304, 272, 408, 21597, 1380, 282, 4644, 4349, 365, 1202, 315, 11227, 5655, 590, 624, 199, 199, 533, 5458, 7521, 1726, 8, 45, 23564, 1726, 304, 272, 986, 199, 199, 533, 14132, 4670, 7521, 1726, 8, 4231, 7521, 1726, 304, 272, 986, 199, 199, 533, 30846, 15905, 8, 785, 304, 272, 408, 27318, 314, 1453, 1919, 687, 314, 1124, 1274, 1040, 5190, 436, 5536, 83, 272, 603, 23564, 13, 6100, 1978, 2556, 14, 339, 1666, 314, 4503, 7251, 315, 520, 1121, 1705, 22273, 63, 3924, 2313, 339, 408, 272, 347, 636, 826, 721, 277, 12, 1125, 29, 403, 12, 5190, 29, 403, 304, 267, 291, 14, 1365, 12, 291, 14, 3469, 275, 4873, 378, 398, 340, 1125, 365, 488, 503, 5190, 365, 488, 26, 288, 307, 12, 574, 12, 307, 894, 275, 984, 14, 2804, 63, 815, 342, 398, 340, 1125, 365, 488, 26, 288, 1125, 275, 574, 503, 307, 398, 340, 5190, 365, 488, 26, 288, 5190, 275, 307, 894, 398, 291, 14, 705, 275, 1125, 267, 291, 14, 6502, 275, 291, 423, 826, 8, 6894, 9, 398, 340, 1228, 8, 277, 14, 705, 12, 334, 12626, 1726, 12, 18377, 1726, 2298, 288, 291, 14, 1365, 275, 291, 14, 705, 14, 1365, 288, 291, 14, 3469, 275, 291, 14, 705, 14, 3469, 288, 291, 423, 1989, 63, 1365, 275, 715, 398, 291, 423, 826, 63, 1188, 342, 339, 768, 1829, 272, 347, 1125, 354, 8, 277, 304, 267, 372, 8434, 14, 1971, 63, 354, 8, 277, 14, 705, 9, 339, 347, 485, 826, 63, 1188, 8, 277, 304, 267, 408, 6591, 282, 2649, 6025, 402, 291, 14, 705, 624, 267, 862, 26, 288, 291, 14, 1188, 275, 8434, 14, 505, 63, 466, 8, 277, 14, 705, 9, 267, 871, 20872, 26, 288, 862, 26, 355, 291, 14, 1188, 275, 620, 8, 277, 14, 705, 9, 288, 871, 24094, 26, 355, 327, 481, 5421, 370, 1249, 465, 15564, 2649, 6590, 355, 327, 620, 8, 1726, 8, 85, 1154, 1845, 22, 1333, 1736, 315, 2018, 665, 499, 14, 22, 355, 291, 14, 1188, 275, 291, 14, 705, 14, 589, 59, 16, 61, 267, 340, 440, 1228, 8, 277, 14, 1188, 12, 8434, 14, 505, 63, 466, 304, 288, 291, 14, 1188, 275, 8434, 14, 505, 63, 466, 8, 277, 14, 1188, 12, 283, 4371, 297, 283, 1814, 358, 339, 347, 485, 362, 63, 264, 15317, 63, 6502, 8, 277, 12, 5767, 304, 267, 367, 6488, 315, 5767, 26, 288, 340, 6488, 59, 22, 61, 365, 440, 488, 26, 355, 1995, 334, 2761, 59, 20, 467, 6488, 59, 21, 467, 6488, 59, 18, 467, 6488, 59, 22, 566, 288, 587, 26, 355, 1995, 2008, 8, 2761, 59, 16, 26, 20, 566, 339, 768, 1829, 272, 347, 5190, 8, 277, 304, 267, 408, 1767, 282, 769, 402, 841, 13, 2960, 5190, 5767, 334, 73, 14, 69, 14, 3293, 2366, 267, 1475, 9, 543, 1978, 13, 989, 31137, 2385, 295, 11663, 370, 314, 6330, 1958, 267, 1978, 14, 398, 408, 267, 372, 769, 8, 277, 423, 362, 63, 264, 15317, 63, 6502, 8, 277, 14, 6502, 430, 339, 768, 1829, 272, 347, 3837, 63, 6502, 8, 277, 304, 267, 372, 10822, 8, 277, 14, 6502, 9, 339, 768, 1829, 272, 347, 3837, 63, 6894, 8, 277, 304, 267, 408, 1767, 314, 2011, 666, 465, 5190, 12, 871, 315, 3837, 1865, 14, 267, 408, 398, 372, 769, 8, 277, 423, 362, 63, 264, 15317, 63, 6502, 8, 277, 14, 4471, 63, 6502, 430, 339, 347, 485, 826, 8, 277, 12, 307, 1195, 894, 304, 267, 408, 908, 282, 5190, 687, 984, 14, 2804, 63, 815, 342, 1901, 1520, 13, 1053, 6346, 12, 267, 3035, 314, 5578, 11648, 5190, 2008, 2974, 12, 12254, 314, 3379, 267, 1978, 1788, 12, 314, 1004, 1329, 19477, 3847, 370, 314, 1978, 267, 1350, 12, 436, 1233, 1004, 687, 626, 1004, 1329, 402, 314, 1978, 1041, 398, 492, 26834, 14, 1160, 267, 24496, 275, 1052, 267, 3066, 6502, 275, 5190, 14, 5005, 63, 5842, 8, 454, 67, 894, 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,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